This package is an implementation of the BIP32 specifications in the Go programming language. You can read the documentation here.
package main
import (
"fmt"
"github.com/augcos/bip32"
"github.com/augcos/bip39"
)
func main() {
// we generate the random entropy
entropy, _ := bip39.GenEntropy(256)
// we generate the mnemonic corresponding to that entropy
mnemonic, _ := bip39.GetMnemonicFromEntropy(entropy)
// finally, we generate the 512-bit seed from the mnemonic, plus a passphrase
seed, _ := bip39.GetSeedFromMnemonic(mnemonic, "passphrase")
// we create the master key
masterKey, _ := bip32.GenMasterKey(seed)
// we derivate the child private key
childKey, _ := bip32.ChildKeyDeriv(masterKey, 0)
// we get the child public key from the private key
pubChildKey, _ := bip32.Neuter(childKey)
// we serialize the child public key
serializedPubChildKey, _ := bip32.Serialization(pubChildKey)
fmt.Println("Public Child Key:", serializedPubMasterKey)
}
- BIP32 specifications
- Mastering Bitcoin by Andreas M. Antonopoulos:
- Tyler Smith's BIP32 Go implementation