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

format() → {Object}

Inspect the key.

Source:
Returns:
Type
Object

(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:

getJSON(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

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

(private) read(raw)

Inject properties from serialized data.

Parameters:
Name Type Description
raw Buffer
Source:

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}

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

write() → {Buffer}

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

Source:
Returns:
Type
Buffer

writeKey() → {Buffer}

Serialize key and menmonic to a single buffer.

Source:
Returns:
Type
Buffer