blob: 933296fd839ef652d5c414bf73a1c8b3006dab46 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# go-bip39
[](https://travis-ci.org/tyler-smith/go-bip39)
[](https://github.com/tyler-smith/go-bip39/blob/master/LICENSE)
[](http://godoc.org/github.com/tyler-smith/go-bip39)
[](https://goreportcard.com/report/github.com/tyler-smith/go-bip39)
[](https://github.com/tyler-smith/go-bip39/issues)
A golang implementation of the BIP0039 spec for mnemonic seeds
## Example
```go
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](https://github.com/bitcoin/bips/tree/master/bip-0039).
Test vectors are from the standard Python BIP0039 implementation from the
Trezor team: [https://github.com/trezor/python-mnemonic](https://github.com/trezor/python-mnemonic)
|