Bip0039::Mnemonic
Inherits Reference / Object
Implements a Bip0039 Mnemonic class.
Ref: bitcoin/bips/bip-0039
Constructors
new(ent : Int32 = 128)
Implements a Bip0039 Mnemonic with a random entropy of ENT bits.
Parameters:
ent(Int32): the bit-size of the random entropy to use (128/160/192/224/256).
mnemonic = Bip0039::Mnemonic.new 256
# => #<Bip0039::Mnemonic:0x7f8be5611d80>
new(hex : String)
Implements a Bip0039 Mnemonic restored from a hexadecimal seed.
Parameters:
hex(String): the hex-seed to use to generate the mnemonic from.
mnemonic = Bip0039::Mnemonic.new "9e885d952ad362caebefe34e91bd2"
# => #<Bip0039::Mnemonic:0x7f8be5611d80>
new(seed : BigInt, ent : Int32 = 128)
Implements a Bip0039 Mnemonic restored from a numeric seed of given size.
Parameters:
seed(BigInt): the numeric seed to use to generate the mnemonic from.ent(Int32): the bit-size of the random entropy to use (128/160/192/224/256).
mnemonic = Bip0039::Mnemonic.new BigInt.new("9e885d952ad362caebefe34e91bd2", 16), 128
# => #<Bip0039::Mnemonic:0x7f8be5611d80>
new(phrase : Array(String))
Implements a Bip0039 Mnemonic restored from a seed phrase.
Parameters:
phrase(Array(String)): the seed phrase to recover the mnemonic from (12/15/18/21/24 words).
mnemonic = Bip0039::Mnemonic.new ["ozone", "drill", "grab", "fiber", "curtain", "grace", "pudding", "thank", "cruise", "elder", "eight", "picnic"]
# => #<Bip0039::Mnemonic:0x7f8be5611d80>
Instance methods
to_hex
Generates a padded hex string containing the seed of the size of ENT bits.
Bip0039::Mnemonic.new.to_hex
# => "9e885d952ad362caeb4efe34a8e91bd2"
to_words
Generates a phrase of words according to the Bip0039 specification
based on the used seed.
Bip0039::Mnemonic.new.to_words
# => ["ozone", "drill", "grab", "fiber", "curtain", "grace", "pudding", "thank", "cruise", "elder", "eight", "picnic"]