BSV.Mnemonic (BSV v2.1.0) View Source
A Mnemonic is a string of words representing a large randomly generated number, making it easier for humans to store.
The words are converted to a BSV.Mnemonic.seed/0
which are used to
create a new BSV.ExtKey.t/0
.
This module implemented BIP-39.
Link to this section Summary
Functions
Generates and returns a new BSV.Mnemonic.t/0
using the given binary.
Generates and returns a new random BSV.Mnemonic.t/0
of the specified
BSV.Mnemonic.entropy_length/0
.
Returns the entropy from the given BSV.Mnemonic.t/0
.
Converts the given BSV.Mnemonic.t/0
into a BSV.Mnemonic.seed/0
used
to create an extended master key.
Link to this section Types
Specs
entropy_length() :: 128 | 160 | 192 | 224 | 256
Entropy length
Specs
seed() :: <<_::512>>
Mnemomic seed
Specs
t() :: String.t()
Mnemonic phrase
Link to this section Functions
Specs
Generates and returns a new BSV.Mnemonic.t/0
using the given binary.
The binary entropy must be of a valid BSV.Mnemonic.entropy_length/0
.
Specs
new(entropy_length()) :: t()
Generates and returns a new random BSV.Mnemonic.t/0
of the specified
BSV.Mnemonic.entropy_length/0
.
Specs
Returns the entropy from the given BSV.Mnemonic.t/0
.
Specs
Converts the given BSV.Mnemonic.t/0
into a BSV.Mnemonic.seed/0
used
to create an extended master key.
Optionally a passphrase (sometimes known as the 13th or 25th word) can be added to the mnemonic to modify the returned seed.
Options
The accepted options are:
:encoding
- Optionally encode the seed with either the:base64
or:hex
encoding scheme.:passphrase
- Optionally secure the seed with an additional passphrase.
Examples
iex> Mnemonic.to_seed("six clarify that goddess door gain stick gentle vault bread taxi champion", encoding: :hex)
"23c406db4d7f9abd318746e4edcc06290973f65cd9eb610d28f5260bdbdf907bace3de7f968d83622c4871fd99777b61611bae18046bc2dbb415f7f1799a43e0"
iex> Mnemonic.to_seed("six clarify that goddess door gain stick gentle vault bread taxi champion", passphrase: "testing", encoding: :hex)
"266f2ea4cd63fd190c3f46b35e6a7da63691c8dc2aa9e57fd362674555c5339f2839e54da6530c547653e263978726a775a16209c3cf80ac23cc2594bebd2301"