Keystore¶
Keystore is a specification to store private keys in a secure way. Please see Aergo documentation for format specification.
Generating keystore from private key (encryption)¶
-
keystoreFromPrivateKey
(key, password, kdfParams)¶ Encrypt private key and return keystore data.
import { keystoreFromPrivateKey, createIdentity } from '@herajs/crypto'; const identity = createIdentity(); const keystore = await keystoreFromPrivateKey(identity.privateKey, 'password'); console.log(JSON.stringify(keystore, null, 2));
Arguments: - key (Buffer) –
- password (string) –
- kdfParams (Partial<keystore.ScryptParams>) –
Returns: Promise<keystore.Keystore> –
Reading private key from keystore (decryption)¶
-
identityFromKeystore
(keystore, password)¶ Decrypt keystore and return identity information.
import { identityFromKeystore } from '@herajs/crypto'; const keystore = JSON.parse('keystore file contents'); const identity = await identityFromKeystore(keystore, 'password'); console.log(identity);
Arguments: - keystore (keystore.Keystore) –
- password (string) –
Returns: Promise<keys.Identity> –
-
class
Keystore
()¶ interface
-
Keystore.
aergo_address
¶ type: string
-
Keystore.
cipher
¶ type: keystore.KeystoreCipher
-
Keystore.
kdf
¶ type: keystore.KeystoreKdf
-
Keystore.
ks_version
¶ type: keystore.Version
-
-
class
KeystoreCipher
()¶ interface
-
KeystoreCipher.
algorithm
¶ type: keystore.CipherAlgorithm
-
KeystoreCipher.
ciphertext
¶ type: keystore.HexString
-
KeystoreCipher.
params
¶ type: keystore.CipherParams
-