View Source BitcoinLib.Key.HD.SeedPhrase (BitcoinLib v0.4.2)

A seed phrase can generate a private key. It is a human friendly way to store private keys for disaster recovery.

Link to this section Summary

Functions

Takes two parts of a seed phrase, with a missing word anywhere in between. Returns a list of words that would complete it with a valid checksum

Convert a set of 50 or 99 dice rolls into a 12 or 24 word list

Convert a set of 50 or 99 dice rolls into a 12 or 24 word list

Convert a seed phrase into a seed, with a optional passphrase

Executes the checksum on a seed phrase, making sure it's valid

Create a seed phrase out of entropy

Link to this section Functions

Link to this function

find_possible_missing_words(first_words, last_words)

View Source
@spec find_possible_missing_words(binary(), binary()) :: list()

Takes two parts of a seed phrase, with a missing word anywhere in between. Returns a list of words that would complete it with a valid checksum

examples

Examples

iex> first_words = "work tenant tourist globe among cattle suggest fever begin boil undo"
...> last_words = "work tenant tourist globe among cattle suggest fever begin boil undo slogan"
...> BitcoinLib.Key.HD.SeedPhrase.find_possible_missing_words(first_words, last_words)
["arrange", "broom", "genius", "hurt", "melody", "repeat", "save", "setup", "strategy"]
Link to this function

from_dice_rolls!(dice_rolls)

View Source
@spec from_dice_rolls!(binary()) :: binary()

Convert a set of 50 or 99 dice rolls into a 12 or 24 word list

examples

Examples

iex> "12345612345612345612345612345612345612345612345612"
...> |> BitcoinLib.Key.HD.SeedPhrase.from_dice_rolls!()
"blue involve cook print twist crystal razor february caution private slim medal"
Link to this function

from_dice_rolls(dice_rolls)

View Source
@spec from_dice_rolls(binary()) :: {:ok, binary()} | {:error, binary()}

Convert a set of 50 or 99 dice rolls into a 12 or 24 word list

examples

Examples

iex> "12345612345612345612345612345612345612345612345612"
...> |> BitcoinLib.Key.HD.SeedPhrase.from_dice_rolls()
{:ok, "blue involve cook print twist crystal razor february caution private slim medal"}
Link to this function

to_seed(seed_phrase, passphrase \\ "")

View Source
@spec to_seed(binary(), binary()) :: binary()

Convert a seed phrase into a seed, with a optional passphrase

See https://learnmeabitcoin.com/technical/mnemonic#mnemonic-to-seed

examples

Examples

iex> "brick giggle panic mammal document foam gym canvas wheel among room analyst"
...> |> BitcoinLib.Key.HD.SeedPhrase.to_seed()
"7e4803bd0278e223532f5833d81605bedc5e16f39c49bdfff322ca83d444892ddb091969761ea406bee99d6ab613fad6a99a6d4beba66897b252f00c9dd7b364"
@spec validate(binary()) :: boolean()

Executes the checksum on a seed phrase, making sure it's valid

examples

Examples

iex> "brick giggle panic mammal document foam gym canvas wheel among room analyst"
...> |> BitcoinLib.Key.HD.SeedPhrase.validate()
true
Link to this function

wordlist_from_entropy(entropy)

View Source
@spec wordlist_from_entropy(integer()) :: binary()

Create a seed phrase out of entropy

examples

Examples

iex> 101_750_443_022_601_924_635_824_320_539_097_414_732
...> |> BitcoinLib.Key.HD.SeedPhrase.wordlist_from_entropy()
"erode gloom apart system broom lemon dismiss post artist slot humor occur"