BSV-ex v0.3.0 BSV.Mnemonic View Source
Module for generating and restoring mnemonic phrases, for the generation of deterministic keys. Implements BIP-39.
A mnemonic phrase is a group of easy to remember words. The phrase can be converted to a binary seed, which in turn is used to generate deterministic keys.
Link to this section Summary
Functions
Returns a list of the allowed mnemonic entropy lengths.
Returns a mnemonic phrase derived from the given binary.
Generates a new mnemonic phrase from the given entropy length (defaults to 256 bits / 24 words).
Returns a binary derived from the given mnemonic phrase.
Returns a wallet seed derived from the given mnemonic phrase and optionally a passphrase.
Returns the mnemonic word list.
Link to this section Types
Mnemonic phrase
Link to this section Functions
Returns a list of the allowed mnemonic entropy lengths.
Returns a mnemonic phrase derived from the given binary.
Examples
iex> BSV.Test.mnemonic_entropy
...> |> BSV.Mnemonic.from_entropy
"organ boring cushion feature wheat juice quality replace concert baby topic scrub"
Generates a new mnemonic phrase from the given entropy length (defaults to 256 bits / 24 words).
Examples
iex> BSV.Mnemonic.generate
...> |> String.split
...> |> length
24
iex> BSV.Mnemonic.generate(128)
...> |> String.split
...> |> length
12
Returns a binary derived from the given mnemonic phrase.
Examples
iex> "organ boring cushion feature wheat juice quality replace concert baby topic scrub"
...> |> BSV.Mnemonic.to_entropy
<<156, 99, 60, 217, 170, 31, 158, 241, 171, 205, 182, 46, 162, 35, 148, 96>>
Returns a wallet seed derived from the given mnemonic phrase and optionally a passphrase.
Options
The accepted options are:
:passphrase
- Optionally protect the seed with an additional passphrase:encoding
- Optionally encode the seed with either the:base64
or:hex
encoding scheme.
Examples
iex> BSV.Mnemonic.from_entropy(BSV.Test.mnemonic_entropy)
...> |> BSV.Mnemonic.to_seed(encoding: :hex)
"380823f725beb7846806d0b88590a0823ea81c0b88cd151f7295772bbe48bbffa9b0f131dce77c4a7168925d466270c12bc0073db917da9f2bb1f4ac59e9fa3b"
iex> BSV.Mnemonic.from_entropy(BSV.Test.mnemonic_entropy)
...> |> BSV.Mnemonic.to_seed(passphrase: "my wallet")
...> |> byte_size
64
Returns the mnemonic word list.