8.16.0.1
BIP-32
(require bip32) | package: bip32 |
Provides a Racket implementation of Bitcoin Improvement Proposal 32.
1 Extended Keys
struct
(struct xmeta ( version depth parent-fingerprint child-index chain-code)) version : bytes? depth : byte? parent-fingerprint : bytes? child-index : exact-nonnegative-integer? chain-code : bytes?
Extended public or private key metadata.
struct
(struct xpub (point))
point : jacobian-point?
Extended public key. Subtype of xmeta.
struct
(struct xpriv (exponent))
exponent : exact-nonnegative-integer?
Extended private key. Subtype of xmeta.
2 Serialization
procedure
str : string?
Parses str as an xpub.
procedure
(xpub->string x) → string?
x : xpub?
Converts an xpub to its string representation.
procedure
str : string?
Parses str as an xpriv.
procedure
(xpriv->string x) → string?
x : xpriv?
Converts an xpriv to its string representation.
3 Key Derivation
procedure
x : xpub? i : exact-nonnegative-integer?
Derives the ith child of x. Hardened derivations are not possible,
so i must be less than 231.
procedure
x : xpriv? i : exact-nonnegative-integer?
Derives the ith child of x. When i is less than 231,
a non-hardened derivation is performed. Otherwise, a hardened derivation is performed.
An error will be raised if i is equal to or greater than 232.
Returns the public key corresponding to x.
4 Derivation Paths
procedure
(string->path str) → (listof/c exact-nonnegative-integer?)
str : string?
Parses the path string str.
procedure
root : xpub? path : (listof/c exact-nonnegative-integer?)
Folds CKDpub over the elements of path with initial xpub root.
procedure
root : xpriv? path : (listof/c exact-nonnegative-integer?)
Folds CKDpriv over the elements of path with initial xpriv root.