Skip to content

Keystore

@aeternity/aepp-sdk/es/utils/keystore

KeyStore module

Example

import * as Keystore from '@aeternity/aepp-sdk/es/utils/keystore'

Example

const { Keystore } = require('@aeternity/aepp-sdk')

@aeternity/aepp-sdk/es/utils/keystore.recover(password, keyObject) ⇒ Buffer

Recover plaintext private key from secret-storage key object.

Kind: static method of @aeternity/aepp-sdk/es/utils/keystore
Returns: Buffer - Plaintext private key.

Param Type Description
password String Keystore object password.
keyObject Object Keystore object.

@aeternity/aepp-sdk/es/utils/keystore.dump(name, password, privateKey, nonce, salt, [options]) ⇒ Object

Export private key to keystore secret-storage format.

Kind: static method of @aeternity/aepp-sdk/es/utils/keystore

Param Type Description
name String Key name.
password String User-supplied password.
privateKey String Private key.
nonce Buffer Randomly generated 24byte nonce.
salt Buffer Randomly generated 16byte salt.
[options] Object Encryption parameters.
[options.kdf] String Key derivation function (default: pbkdf2).
[options.cipher] String Symmetric cipher (default: constants.cipher).
[options.kdfparams] Object KDF parameters (default: constants.).

@aeternity/aepp-sdk/es/utils/keystore~str2buf(str, [enc]) ⇒ buffer

Convert a string to a Buffer. If encoding is not specified, hex-encoding will be used if the input is valid hex. If the input is valid base64 but not valid hex, base64 will be used. Otherwise, utf8 will be used.

Kind: inner method of @aeternity/aepp-sdk/es/utils/keystore
Returns: buffer - Buffer (bytearray) containing the input data.

Param Type Description
str string String to be converted.
[enc] string Encoding of the input string (optional).

@aeternity/aepp-sdk/es/utils/keystore~encrypt(plaintext, key, nonce, [algo]) ⇒ buffer

Symmetric private key encryption using secret (derived) key.

Kind: inner method of @aeternity/aepp-sdk/es/utils/keystore
Returns: buffer - Encrypted data.

Param Type Description
plaintext buffer | string Data to be encrypted.
key buffer | string Secret key.
nonce buffer | string Randomly generated nonce.
[algo] string Encryption algorithm (default: DEFAULTS.crypto.symmetric_alg).

@aeternity/aepp-sdk/es/utils/keystore~decrypt(ciphertext, key, nonce, [algo]) ⇒ buffer

Symmetric private key decryption using secret (derived) key.

Kind: inner method of @aeternity/aepp-sdk/es/utils/keystore
Returns: buffer - Decrypted data.

Param Type Description
ciphertext buffer | Uint8Array Data to be decrypted.
key buffer | Uint8Array Secret key.
nonce buffer | Uint8Array Nonce from key-object.
[algo] string Encryption algorithm.

@aeternity/aepp-sdk/es/utils/keystore~deriveKey(password, nonce, [options]) ⇒ buffer

Derive secret key from password with key derivation function.

Kind: inner method of @aeternity/aepp-sdk/es/utils/keystore
Returns: buffer - Secret key derived from password.

Param Type Description
password string User-supplied password.
nonce buffer | Uint8Array Randomly generated nonce.
[options] Object Encryption parameters.
[options.kdf] string Key derivation function (default: DEFAULTS.crypto.kdf).
[options.kdf_params] Object KDF parameters (default: DEFAULTS.crypto.kdf_params).

@aeternity/aepp-sdk/es/utils/keystore~marshal(name, derivedKey, privateKey, nonce, salt, [options]) ⇒ Object

Assemble key data object in secret-storage format.

Kind: inner method of @aeternity/aepp-sdk/es/utils/keystore

Param Type Description
name buffer Key name.
derivedKey buffer Password-derived secret key.
privateKey buffer Private key.
nonce buffer Randomly generated 24byte nonce.
salt buffer Randomly generated 16byte salt.
[options] Object Encryption parameters.
[options.kdf] string Key derivation function (default: argon2id).
[options.cipher] string Symmetric cipher (default: constants.cipher).
[options.kdf_params] Object KDF parameters (default: constants.).