Documentation ¶
Overview ¶
Package bip39 is the Golang implementation of the BIP39 spec.
Index ¶
- Variables
- func CheckMnemonic(mnemonic string, lg Language) error
- func IsMnemonicValid(m string, lg Language) bool
- func MnemonicToSeed(mnemonic string, passwd string) []byte
- func NewMnemonic(length int, lang Language) (string, error)
- func NewMnemonicByEntropy(entropy []byte, lang Language) (string, error)
- type Language
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWordLen = errors.New("Invalid word list length") ErrEntropyLen = errors.New("Invalid entropy length") ErrChecksumIncorrect = errors.New("checksum incorrect") )
Error list
Functions ¶
func CheckMnemonic ¶
CheckMnemonic creates entropy from mnemonic
func IsMnemonicValid ¶
IsMnemonicValid validate menemonic
Example ¶
var mnemonic = "check fiscal fit sword unlock rough lottery tool sting pluck bulb random" res := IsMnemonicValid(mnemonic, English) fmt.Println(res)
Output: true
func MnemonicToSeed ¶
MnemonicToSeed creates seed by param passwd can be empty string
Example ¶
mnemonic := "jungle devote wisdom slim census orbit merge order flip sketch add mass" res := MnemonicToSeed(mnemonic, "") fmt.Println(hex.EncodeToString(res))
Output: f38fb5a8ca30abe8cd8a35428911d7277d9125ebc2f019a5d400cd765d1f6f56a552f0b92f8149b0d834f7e5b64a71548840ab7d4c826a58783429e366b21caf
func NewMnemonic ¶
NewMnemonic generates new mnemonic by words length
Example ¶
// Words length can be 12 | 15 | 18 | 21 | 24 NewMnemonic(12, English) NewMnemonic(24, ChineseTraditional) NewMnemonic(12, English) NewMnemonic(15, French) NewMnemonic(18, Italian) NewMnemonic(21, Japanese) NewMnemonic(24, French)
Output:
func NewMnemonicByEntropy ¶
NewMnemonicByEntropy generates new mnemonic by entropy provided
Example ¶
entropy, _ := hex.DecodeString("79079bf165e25537e2dce15919440cc4") mnemonic, _ := NewMnemonicByEntropy(entropy, English) fmt.Println(mnemonic)
Output: jungle devote wisdom slim census orbit merge order flip sketch add mass
Types ¶
Click to show internal directories.
Click to hide internal directories.