Documentation ¶
Overview ¶
Package bip39 implements the bip39 protocol https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki This protocol relates closely with bip32 (https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) and allows a memorable word list to be generated for a user of a wallet to store. This is a bit more user friendly than users dealing with hex strings etc.
Users can supply an additional entropy by supplying an optional passcode which is used to generate the seed.
The seed can then be passed to an hd (bip32) private key generation function to produce the wallet private master key.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLength = errors.New("invalid number of bits requested, " + "should be a multiple of 32 and between 128 and 256 (inclusive)") ErrInvalidMnemonic = errors.New("invalid mnemonic; length should be a multiple of 3 between 12 and 24") ErrInvalidWordlist = errors.New("mnemonic contains invalid word (word not in approved wordlist)") )
Sentinel errors raised by the lib.
var English = strings.Split(strings.TrimSpace(english), "\n")
English is a slice of mnemonic words taken from the bip39 specification https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt
Functions ¶
func GenerateEntropy ¶
GenerateEntropy will generate a bytearray of cryptographically random bytes with the length of bytes determined by the length supplied.
If the length is invalid a bip39.ErrInvalidLength will be returned.
func Mnemonic ¶
Mnemonic will create a new mnemonic sentence using the supplied entropy bytes, if the entropy supplied is not a valid length a bip39.ErrInvalidLength error will be returned.
An optional passcode can be supplied which will be used in the returned seed to provide an additional security measure.
func MnemonicToSeed ¶
MnemonicToSeed will validate a mnemonic and then generate the seed to be used in a BIP32 masterkey generation call.
This can be used if re-generating a wallet from an existing mnemonic.