Keys

Generating random private key

createIdentity()

Shortcut function to create a new random private key and return keys and address as encoded strings.

Returns:keys.Identity – identity including address and keys

Importing private key

identityFromPrivateKey(privKeyBytes)

Returns identity associated with private key

Arguments:
  • privKeyBytes (Uint8Array) –
Returns:

keys.Identity – identity including address and keys

Encryption

decryptPrivateKey(encryptedBytes, password)

Decrypt an AES_GCM encrypted private key

Arguments:
  • encryptedBytes (Uint8Array) –
  • password (string) –
Returns:

Uint8Array – decrypted private key bytes

encryptPrivateKey(clearBytes, password)

Encrypt a private key using AES_GCM

Arguments:
  • clearBytes (Uint8Array) –
  • password (string) –
Returns:

Uint8Array – encrypted private key bytes

Public keys and addresses

In Aergo, addresses are generated directly from public keys. Because of that, it is easy to convert between the two.

publicKeyFromAddress(address)

Retrieve public key from address

Arguments:
  • address (string|keys.BytesConvertible|hashing.StringCovertible) –
Returns:

KeyPair – key pair (with missing private key)

addressFromPublicKey(publicKey)

Encode public key as address

Arguments:
  • publicKey (any) –
Returns:

string – base58check encoded address