Skip to content

Working with ADM key pairs

Aleksei Lebedev edited this page Sep 29, 2019 · 7 revisions

The library offers to create new passPhrase, make public and private key pair and ADM address. Read more about ADAMANT account and key pair.

Refer to adamant-api/helpers/keys module to access these methods:

const keys = require('adamant-api/helpers/keys');

createNewPassPhrase()

Creates new Mnemonic passPhrase with Engish words.

Parameters: none.

Returns: new random passPhrase, String

makeKeypairFromHash(hash)

Creates public and private keys with provided hash using Sodium (NaCl).

Parameters:

  • hash — SHA-256 hash of passPhase to generate key pair, Hash object from crypto library

Returns:

  • publicKey of key pair
  • privateKey of key pair

createHashFromPassPhrase(passPhrase)

Creates SHA-256 hash from provided passPhrase.

Parameters:

  • passPhrase — 12 words Mnemonic passPhrase to generate hash, String

Returns: generated Hash object from crypto library

createKeypairFromPassPhrase(passPhrase)

Creates public and private keys with provided passPhrase using Sodium (NaCl).

Parameters:

  • passPhrase — 12 words Mnemonic passPhrase to generate hash, String

Returns:

  • publicKey of key pair
  • privateKey of key pair

Example:

let keysPair;
try {
    keysPair = keys.createKeypairFromPassPhrase(config.passphrase);
} catch (e) {
    exit('Passphrase is not valid! Error: ' + e);
}

createAddressFromPublicKey(publicKey)

Generates ADAMANT address from provided publicKey.

Parameters:

  • publicKey — account's publicKey

Returns: ADAMANT address, String

Clone this wiki locally