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, passphrase 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 mnemonic 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 ¶
const mnemonic = "check fiscal fit sword unlock rough lottery tool sting pluck bulb random" fmt.Println(IsMnemonicValid(mnemonic, English))
Output: true
func MnemonicToSeed ¶
MnemonicToSeed creates 64 bytes seed by pbkdf passphrace is optional,it can be empty string
Example ¶
mnemonic := "jungle devote wisdom slim census orbit merge order flip sketch add mass" seed := MnemonicToSeed(mnemonic, "") fmt.Println(base64.StdEncoding.EncodeToString(seed))
Output: 84+1qMowq+jNijVCiRHXJ32RJevC8Bml1ADNdl0fb1alUvC5L4FJsNg09+W2SnFUiECrfUyCalh4NCnjZrIcrw==
func NewMnemonic ¶
NewMnemonic creates new mnemonic by words length for language provided
func NewMnemonicByEntropy ¶
NewMnemonicByEntropy create 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 ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.