Class: MasterKey

wallet~MasterKey(options)

Master Key Master BIP32 key which can exist in a timed out encrypted state.

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) fromOptions() → {MasterKey}

Instantiate master key from options.

Source:
Returns:
Type
MasterKey

(static) fromRaw() → {MasterKey}

Instantiate master key from serialized data.

Source:
Returns:
Type
MasterKey

(static) fromReader() → {MasterKey}

Instantiate master key from serialized data.

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) → {Promise}

Decrypt the key permanently without a lock.

Parameters:
Name Type Description
passphrase Buffer | String

Zero this yourself.

Source:
Returns:
Type
Promise

(async, private) _encrypt(passphrase) → {Promise}

Encrypt the key permanently without a lock.

Parameters:
Name Type Description
passphrase Buffer | String

Zero this yourself.

Source:
Returns:
Type
Promise

_lock()

Destroy the key by zeroing the privateKey and chainCode. Stop the timer if there is one.

Source:

(async, private) _unlock(passphrase, timeoutopt) → {Promise}

Decrypt the key without a lock.

Parameters:
Name Type Attributes Default Description
passphrase Buffer | String

Zero this yourself.

timeout Number <optional>
60000

timeout in ms.

Source:
Returns:
  • Returns HDPrivateKey.
Type
Promise

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) → {Promise}

Decrypt the key permanently.

Parameters:
Name Type Description
passphrase Buffer | String

Zero this yourself.

Source:
Returns:
Type
Promise

(async) derive(passphrase) → {Promise}

Derive an aes key based on params.

Parameters:
Name Type Description
passphrase String | Buffer
Source:
Returns:
Type
Promise

(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) → {Promise}

Encrypt the key permanently.

Parameters:
Name Type Description
passphrase Buffer | String

Zero this yourself.

Source:
Returns:
Type
Promise

(private) fromKey(key, mnemonicnullable)

Inject properties from an HDPrivateKey.

Parameters:
Name Type Attributes Description
key HDPrivateKey
mnemonic Mnemonic <nullable>
Source:

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(private) fromRaw(raw)

Inject properties from serialized data.

Parameters:
Name Type Description
raw Buffer
Source:

(private) fromReader(raw)

Inject properties from serialized data.

Parameters:
Name Type Description
raw Buffer
Source:

getSize() → {Number}

Calculate serialization size.

Source:
Returns:
Type
Number

inspectSymbol() → {Object}

Inspect the key.

Source:
Returns:
Type
Object

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

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:

toJSON(networknullable, unsafenullable) → {Object}

Convert master key to a jsonifiable object.

Parameters:
Name Type Attributes Description
network Network <nullable>
unsafe Boolean <nullable>

Whether to include the key data in the JSON.

Source:
Returns:
Type
Object

toRaw() → {Buffer}

Serialize the key in the form of: [enc-flag][iv?][ciphertext?][extended-key?]

Source:
Returns:
Type
Buffer

toWriter() → {Buffer}

Serialize the key in the form of: [enc-flag][iv?][ciphertext?][extended-key?]

Source:
Returns:
Type
Buffer

(async) unlock(passphrase, timeoutopt) → {Promise}

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>
60000

timeout in ms.

Source:
Returns:
  • Returns HDPrivateKey.
Type
Promise

writeKey() → {Buffer}

Serialize key and menmonic to a single buffer.

Source:
Returns:
Type
Buffer