Constructor
new MasterKey(options)
Create a master key.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Members
(static) alg :Number
Key derivation algorithms.
Type:
- Number
Properties:
Name | Type | Description |
---|---|---|
PBKDF2 |
Number | |
SCRYPT |
Number |
- Default Value:
{"PBKDF2":0,"SCRYPT":1}
- Source:
(static) algByVal :String
Key derivation algorithms by value.
Type:
- String
- Default Value:
["PBKDF2","SCRYPT"]
- Source:
(static, constant) SALT :Buffer
Key derivation salt.
Type:
- Buffer
- Source:
Methods
(static) fromKey(key, mnemonicnullable) → {MasterKey}
Instantiate master key from an HDPrivateKey.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
HDPrivateKey | ||
mnemonic |
Mnemonic |
<nullable> |
- Source:
Returns:
- Type
- MasterKey
(static) isMasterKey(obj) → {Boolean}
Test whether an object is a MasterKey.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object |
- Source:
Returns:
- Type
- Boolean
(async, private) _decrypt(passphrase, cleanopt) → {Promise.<(Buffer|null)>}
Decrypt the key permanently without a lock.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
passphrase |
Buffer | String | Zero this yourself. |
||
clean |
Boolean |
<optional> |
false |
- Source:
Returns:
- Type
- Promise.<(Buffer|null)>
(async, private) _encrypt(passphrase, cleanopt) → {Promise.<(Buffer|null)>}
Encrypt the key permanently without a lock.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
passphrase |
Buffer | String | Zero this yourself. |
||
clean |
Boolean |
<optional> |
false |
- Source:
Returns:
- Type
- Promise.<(Buffer|null)>
_lock()
Destroy the key by zeroing the privateKey and chainCode. Stop the timer if there is one.
- Source:
(async, private) _unlock(passphrase, timeoutopt) → {Promise.<HDPrivateKey>}
Decrypt the key without a lock.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
passphrase |
Buffer | String | Zero this yourself. |
||
timeout |
Number |
<optional> |
60 | timeout in seconds. |
- Source:
Returns:
- Type
- Promise.<HDPrivateKey>
decipher(data, iv) → {Buffer}
Decrypt data with in-memory aes key.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer | |
iv |
Buffer |
- Source:
Returns:
- Type
- Buffer
(async) decrypt(passphrase, cleanopt) → {Promise.<(Buffer|null)>}
Decrypt the key permanently.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
passphrase |
Buffer | String | Zero this yourself. |
||
clean |
Boolean |
<optional> |
false |
- Source:
Returns:
- Type
- Promise.<(Buffer|null)>
(async) derive(passwd) → {Promise.<Buffer>}
Derive an aes key based on params.
Parameters:
Name | Type | Description |
---|---|---|
passwd |
String | Buffer |
- Source:
Returns:
- Type
- Promise.<Buffer>
(async) destroy()
Destroy the key permanently.
- Source:
encipher(data, iv) → {Buffer}
Encrypt data with in-memory aes key.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer | |
iv |
Buffer |
- Source:
Returns:
- Type
- Buffer
(async) encrypt(passphrase, cleanopt) → {Promise.<(Buffer|null)>}
Encrypt the key permanently.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
passphrase |
Buffer | String | Zero this yourself. |
||
clean |
Boolean |
<optional> |
false |
- Source:
Returns:
- Type
- Promise.<(Buffer|null)>
format() → {Object}
Inspect the key.
- Source:
Returns:
- Type
- Object
fromKey(key, mnemonicnullable)
Inject properties from an HDPrivateKey.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
HDPrivateKey | ||
mnemonic |
Mnemonic |
<nullable> |
- Source:
fromOptions(options) → {this}
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Returns:
- Type
- this
getJSON(networkopt, nullable, unsafeopt, nullable) → {Object}
Convert master key to a jsonifiable object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
network |
Network |
<optional> <nullable> |
|
unsafe |
Boolean |
<optional> <nullable> |
Whether to include the key data in the JSON. |
- Source:
Returns:
- Type
- Object
getSize() → {Number}
Calculate serialization size.
- Source:
Returns:
- Type
- Number
keySize() → {Number}
Calculate key serialization size.
- Source:
Returns:
- Type
- Number
(async) lock() → {Promise}
Destroy the key by zeroing the privateKey and chainCode. Stop the timer if there is one.
- Source:
Returns:
- Type
- Promise
read(br) → {this}
Inject properties from serialized data.
Parameters:
Name | Type | Description |
---|---|---|
br |
bio.BufferReader |
- Source:
Returns:
- Type
- this
readKey(data)
Inject properties from serialized key.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
(private) start(timeoutopt)
Start the destroy timer.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
timeout |
Number |
<optional> |
60 | timeout in seconds. |
- Source:
(private) stop()
Stop the destroy timer.
- Source:
(async) unlock(passphrase, timeoutopt) → {Promise.<HDPrivateKey>}
Decrypt the key and set a timeout to destroy decrypted data.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
passphrase |
Buffer | String | Zero this yourself. |
||
timeout |
Number |
<optional> |
60 | timeout in seconds. |
- Source:
Returns:
- Type
- Promise.<HDPrivateKey>
write(bw) → {BufioWriter}
Serialize the key in the form of:
[enc-flag][iv?][ciphertext?][extended-key?]
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufioWriter |
- Source:
Returns:
- Type
- BufioWriter
writeKey() → {Buffer}
Serialize key and menmonic to a single buffer.
- Source:
Returns:
- Type
- Buffer