github.com/turingchain2020/turingchain@v1.1.21/wallet/bipwallet/go-bip39/README.md (about) 1 # go-bip39 2 3 A golang implementation of the BIP0039 spec for mnemonic seeds 4 5 6 ## Credits 7 8 English wordlist and test vectors are from the standard Python BIP0039 implementation 9 from the Trezor guys: [https://github.com/trezor/python-mnemonic](https://github.com/trezor/python-mnemonic) 10 11 ## Example 12 13 ```go 14 package main 15 16 import ( 17 "github.com/tyler-smith/go-bip39" 18 "github.com/tyler-smith/go-bip32" 19 "fmt" 20 ) 21 22 func main(){ 23 // Generate a mnemonic for memorization or user-friendly seeds 24 entropy, _ := bip39.NewEntropy(256) 25 mnemonic, _ := bip39.NewMnemonic(entropy) 26 27 // Generate a Bip32 HD wallet for the mnemonic and a user supplied password 28 seed := bip39.NewSeed(mnemonic, "Secret Passphrase") 29 30 masterKey, _ := bip32.NewMasterKey(seed) 31 publicKey := masterKey.PublicKey() 32 33 // Display mnemonic and keys 34 fmt.Println("Mnemonic: ", mnemonic) 35 fmt.Println("Master private key: ", masterKey) 36 fmt.Println("Master public key: ", publicKey) 37 } 38 ```