Documentation
¶
Index ¶
Constants ¶
const ( // HardenedOffset is added to child index to indicate hardened derivation (BIP-32). // Indices >= HardenedOffset are hardened; indices < HardenedOffset are normal. HardenedOffset = 0x80000000 )
Variables ¶
var ( // VersionMainPublic is the BIP-32 version bytes for mainnet extended public keys (xpub). VersionMainPublic = []byte{0x04, 0x88, 0xB2, 0x1E} // VersionMainPrivate is the BIP-32 version bytes for mainnet extended private keys (xpriv). VersionMainPrivate = []byte{0x04, 0x88, 0xAD, 0xE4} // VersionTestPublic is the BIP-32 version bytes for testnet extended public keys (tpub). VersionTestPublic = []byte{0x04, 0x35, 0x87, 0xCF} // VersionTestPrivate is the BIP-32 version bytes for testnet extended private keys (tpriv). VersionTestPrivate = []byte{0x04, 0x35, 0x83, 0x94} )
Functions ¶
func MnemonicToSeed ¶
MnemonicToSeed converts a BIP-39 mnemonic and an optional passphrase into a 512-bit binary seed.
Types ¶
type Curve ¶
type Curve interface {
Name() string
MasterKey(seed []byte) (privKey, chainCode []byte, err error)
DerivePrivateChild(privKey, chainCode []byte, index uint32) (childPrivKey, childChainCode []byte, err error)
DerivePublicChild(pubKey, chainCode []byte, index uint32) (childPubKey, childChainCode []byte, err error)
PublicKey(privKey []byte) []byte
}
Curve represents an elliptic curve supported by SLIP-10.
func NewCurve25519 ¶
func NewCurve25519() Curve
func NewEd25519 ¶
func NewEd25519() Curve
func NewNist256p1 ¶
func NewNist256p1() Curve
func NewSecp256k1 ¶
func NewSecp256k1() Curve
type Node ¶
type Node struct {
Curve Curve
IsPrivate bool
PrivKey []byte
PubKey []byte
ChainCode []byte
Depth byte
ParentFP []byte
Index uint32
Version []byte
}
Node represents an extended key in the SLIP-10 hierarchy.
func NewMasterNode ¶
NewMasterNode creates a new master node from a seed for the specified curve.
func NewNodeFromExtendedKey ¶
NewNodeFromExtendedKey creates a node from serialized extended key (xpub/xpriv).
func (*Node) DerivePath ¶
DerivePath derives a child node following the given path (e.g., "m/44'/0'/0'/0/0").
func (*Node) Fingerprint ¶
Fingerprint returns the fingerprint of the node's public key.
func (*Node) String ¶
String returns a safe string representation of the node (does not expose private key).
func (*Node) Wipe ¶
func (n *Node) Wipe()
Wipe overwrites the private key and chain code with zeros to protect sensitive data in memory. It is recommended to call this method when the Node is no longer needed.