# README
go-bip39
A golang implementation of the BIP0039 spec for mnemonic seeds
Example
package main
import (
"github.com/tyler-smith/go-bip39"
"github.com/tyler-smith/go-bip32"
"fmt"
)
func main(){
// Generate a mnemonic for memorization or user-friendly seeds
entropy, _ := bip39.NewEntropy(256)
mnemonic, _ := bip39.NewMnemonic(entropy)
// Generate a Bip32 HD wallet for the mnemonic and a user supplied password
seed := bip39.NewSeed(mnemonic, "Secret Passphrase")
masterKey, _ := bip32.NewMasterKey(seed)
publicKey := masterKey.PublicKey()
// Display mnemonic and keys
fmt.Println("Mnemonic: ", mnemonic)
fmt.Println("Master private key: ", masterKey)
fmt.Println("Master public key: ", publicKey)
}
Credits
Wordlists are from the bip39 spec.
Test vectors are from the standard Python BIP0039 implementation from the Trezor team: https://github.com/trezor/python-mnemonic
# Packages
No description provided by the author
# Functions
EntropyFromMnemonic takes a mnemonic generated by this library, and returns the input entropy used to generate the given mnemonic.
GetWordIndex gets word index in wordMap.
GetWordList gets the list of words to use for mnemonics.
IsMnemonicValid attempts to verify that the provided mnemonic is valid.
MnemonicToByteArray takes a mnemonic string and turns it into a byte array suitable for creating another mnemonic.
NewEntropy will create random entropy bytes so long as the requested size bitSize is an appropriate size.
NewMnemonic will return a string consisting of the mnemonic words for the given entropy.
NewSeed creates a hashed seed output given a provided string and password.
NewSeedWithErrorChecking creates a hashed seed output given the mnemonic string and a password.
SetWordList sets the list of words to use for mnemonics.
# Variables
ErrChecksumIncorrect is returned when entropy has the incorrect checksum.
ErrEntropyLengthInvalid is returned when trying to use an entropy set with an invalid size.
ErrInvalidMnemonic is returned when trying to use a malformed mnemonic.
ErrValidatedSeedLengthMismatch is returned when a validated seed is not the same size as the given seed.