Skip to content

Working with ADM key pairs

adamant-al edited this page May 28, 2021 · 7 revisions

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

Refer to keys module to access these methods.

createNewPassPhrase()

Creates new Mnemonic passPhrase with English 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. You can use createHashFromPassPhrase

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

Example:

const address = keys.createAddressFromPublicKey(keysPair.publicKey);
Clone this wiki locally