class Bip0039::Mnemonic
- Bip0039::Mnemonic
- Reference
- Object
Overview
Implements a Bip0039
Mnemonic class.
Ref: bitcoin/bips/bip-0039
Defined in:
bip39.crConstructors
-
.new(ent : Int32 = 128)
Implements a
Bip0039
Mnemonic with a random entropy of ENT bits. -
.new(hex : String)
Implements a
Bip0039
Mnemonic restored from a hexadecimal seed. -
.new(seed : BigInt, ent : Int32 = 128)
Implements a
Bip0039
Mnemonic restored from a numeric seed of given size. -
.new(phrase : Array(String))
Implements a
Bip0039
Mnemonic restored from a seed phrase.
Instance Method Summary
-
#ent : Int32
The bit-size of the entropy of the mnemonic.
-
#ent=(ent : Int32)
The bit-size of the entropy of the mnemonic.
-
#seed : BigInt
The random seed of the mnemonic.
-
#seed=(seed : BigInt)
The random seed of the mnemonic.
-
#to_hex : String
Generates a padded hex string containing the seed of the size of ENT bits.
-
#to_words : Array(String)
Generates a phrase of words according to the
Bip0039
specification based on the used seed.
Constructor Detail
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>
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>
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>
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 Method Detail
Generates a padded hex string containing the seed of the size of ENT bits.
Bip0039::Mnemonic.new.to_hex
# => "9e885d952ad362caeb4efe34a8e91bd2"