Class: Mnemonic

hd~Mnemonic(options)

HD Mnemonic

Constructor

new Mnemonic(options)

Create a mnemonic.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
bit Number <nullable>

Bits of entropy (Must be a multiple of 8) (default=128).

entropy Buffer <nullable>

Entropy bytes. Will be generated with options.bits bits of entropy if not present.

phrase String <nullable>

Mnemonic phrase (will be generated if not present).

language String <nullable>

Language.

Source:

Members

(static, constant) languages :Array.<String>

List of languages.

Type:
  • Array.<String>
Default Value:
  • ["simplified chinese","traditional chinese","english","french","italian","japanese","spanish"]
Source:

Methods

(static) fromEntropy(entropy, langnullable) → {Mnemonic}

Instantiate mnemonic from entropy.

Parameters:
Name Type Attributes Description
entropy Buffer
lang String <nullable>
Source:
Returns:
Type
Mnemonic

(static) fromJSON(json) → {Mnemonic}

Instantiate mnemonic from json object.

Parameters:
Name Type Description
json Object
Source:
Returns:
Type
Mnemonic

(static) fromOptions(options) → {Mnemonic}

Instantiate mnemonic from options.

Parameters:
Name Type Description
options Object
Source:
Returns:
Type
Mnemonic

(static) fromPhrase(phrase) → {Mnemonic}

Instantiate mnemonic from a phrase (validates checksum).

Parameters:
Name Type Description
phrase String
Source:
Throws:

on bad checksum

Returns:
Type
Mnemonic

(static) fromRaw(data) → {Mnemonic}

Instantiate mnemonic from serialized data.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Mnemonic

(static) fromReader(br) → {Mnemonic}

Instantiate mnemonic from buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:
Returns:
Type
Mnemonic

(static) getLanguage(word) → {String}

Determine a single word's language.

Parameters:
Name Type Description
word String
Source:
Throws:

on not found.

Returns:

Language.

Type
String

(static) getWordlist(lang) → {Object}

Retrieve the wordlist for a language.

Parameters:
Name Type Description
lang String
Source:
Returns:
Type
Object

(static) isMnemonic(obj) → {Boolean}

Test whether an object is a Mnemonic.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

destroy()

Destroy the mnemonic (zeroes entropy).

Source:

(private) fromEntropy(entropy, langnullable)

Inject properties from entropy.

Parameters:
Name Type Attributes Description
entropy Buffer
lang String <nullable>
Source:

(private) fromJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(private) fromPhrase(phrase)

Inject properties from phrase.

Parameters:
Name Type Description
phrase String
Source:

(private) fromRaw(data)

Inject properties from serialized data.

Parameters:
Name Type Description
data Buffer
Source:

(private) fromReader(br)

Inject properties from buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:

getEntropy() → {Buffer}

Get or generate entropy.

Source:
Returns:
Type
Buffer

getPhrase() → {String}

Generate a mnemonic phrase from chosen language.

Source:
Returns:
Type
String

getSize() → {Number}

Calculate serialization size.

Source:
Returns:
Type
Number

inspectSymbol() → {String}

Inspect the mnemonic.

Source:
Returns:
Type
String

toJSON() → {Object}

Convert mnemonic to a json-friendly object.

Source:
Returns:
Type
Object

toRaw() → {Buffer}

Serialize mnemonic.

Source:
Returns:
Type
Buffer

toSeed(passphrasenullable) → {Buffer}

Generate the seed.

Parameters:
Name Type Attributes Description
passphrase String <nullable>
Source:
Returns:

pbkdf2 seed.

Type
Buffer

toString() → {String}

Convert the mnemonic to a string.

Source:
Returns:
Type
String

toWriter()

Write the mnemonic to a buffer writer.

Source: