Documentation ¶
Overview ¶
Package bip32 implements Bitcoin BIP32 deterministic wallet key derivation.
Index ¶
- Variables
- func DerivePrivateChild(parentPrivateKey, chainCode []byte, childIndices ...uint32) ([]byte, []byte)
- func DerivePublicChild(parentPublicKey, chainCode []byte, childIndices ...uint32) ([]byte, []byte, error)
- func Deserialize(bs58Key string) (key, chainCode, parentFingerprint []byte, depth byte, index, version uint32, ...)
- func ExampleDerivePrivateChild()
- func ExampleDerivePublicChild()
- func GenerateMasterKey(seed []byte) (masterKey, chainCode []byte, err error)
- func KeyFingerprint(publicKey []byte) ([]byte, error)
- func SerializePrivate(privateKey, chainCode, parentFingerprint []byte, depth byte, ...) string
- func SerializePublic(publicKey, chainCode, parentFingerprint []byte, depth byte, ...) string
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidDerivationIndex = fmt.Errorf("Cannot derive child of public key with index higher than 0x%x", constants.Bip32Hardened)
ErrInvalidDerivationIndex is returned by DerivePublicChild if the given index is above the hardening threshold.
var ErrInvalidExtendedKey = errors.New("Failed to deserialize extended key - Invalid format")
ErrInvalidExtendedKey is returned by Deserialize if it is passed a base58 key which fails to decode correctly.
var ErrInvalidSeed = errors.New("Invalid seed; bit size must be between 128 - 512 bits, and a multiple of 32")
ErrInvalidSeed is returned by GenerateMasterKey if the given seed is not valid.
Functions ¶
func DerivePrivateChild ¶
func DerivePrivateChild(parentPrivateKey, chainCode []byte, childIndices ...uint32) ([]byte, []byte)
DerivePrivateChild recursively derives a child private key and chain code of a given bip32 path from a parent private key and chain code.
func DerivePublicChild ¶
func DerivePublicChild(parentPublicKey, chainCode []byte, childIndices ...uint32) ([]byte, []byte, error)
DerivePublicChild derives a child public key and chain code of a given bip32 path from a parent public key and chain code. Returns ErrInvalidDerivationIndex if any child index is greater than or equal to constants.Bip32Hardened.
The parentPublicKey parameter can be compressed or uncompressed, but this function always returns compressed public keys.
func Deserialize ¶
func Deserialize(bs58Key string) (key, chainCode, parentFingerprint []byte, depth byte, index, version uint32, err error)
Deserialize parses a base58-check encoded extended key (public or private) and returns the key, chain code, parent fingerprint, depth from the master key, child index, version number prefix, and any error encountered during deserialization. Returns ErrInvalidExtendedKey if the key is not valid.
func ExampleDerivePrivateChild ¶
func ExampleDerivePrivateChild()
func ExampleDerivePublicChild ¶
func ExampleDerivePublicChild()
func GenerateMasterKey ¶
GenerateMasterKey generates a master key and chain code from the given seed bytes. Returns ErrInvalidSeed if the seed is not valid.
func KeyFingerprint ¶
KeyFingerprint returns the first 4 bytes of the Hash160 of the given public key. This is used as the fingerprint for serialized extended keys. Note that publicKey can be in compressed or uncompressed form, but will be converted to compressed form before hashing. Returns an error if the public key is not valid.
Types ¶
This section is empty.