-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | BIP-0032: Hierarchical Deterministic Wallets for Bitcoin and other cryptocurrencies -- -- BIP-0032: Hierarchical Deterministic Wallets for Bitcoin and other -- cryptocurrencies -- -- This library builds in GHC and GHCJS. @package bip32 @version 0.2 -- | BIP-0032 Hierarchical Deterministic Wallets, for bitcoin and -- other cryptocurrencies. module BIP32 -- | Obtain the Base58 representation for an XPrv. -- -- It can be either 111 or 112 bytes in length, and when rendered as -- ASCII it looks something like this: -- --
-- xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi --encodeXPrv :: XPrv -> ByteString -- | Obtain the Base58 representation for an XPub. -- -- It can be either 111 or 112 bytes in length, and when rendered as -- ASCII it looks something like this: -- --
-- xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8 --encodeXPub :: XPub -> ByteString -- | Decode the Base58-encoded XPrv representation. See -- encodeXPrv. decodeXPrv :: ByteString -> Maybe XPrv -- | Decode the Base58-encoded XPub representation. See -- encodeXPub. decodeXPub :: ByteString -> Maybe XPub -- | Decode the Base58-encoded representation of either and XPub or -- an XPub. decode :: ByteString -> Maybe (Either XPub XPrv) -- | Encode the 78 raw XPrv bytes. encodeXPrvRaw :: XPrv -> ByteString -- | Encode the 78 raw XPub bytes. encodeXPubRaw :: XPub -> ByteString -- | Decode the 78 raw XPrv bytes. decodeXPrvRaw :: ByteString -> Maybe XPrv -- | Decode the 78 raw XPub bytes. decodeXPubRaw :: ByteString -> Maybe XPub -- | Encode the 78 raw XPub or XPrv bytes. decodeRaw :: ByteString -> Maybe (Either XPub XPrv) -- | Extended private key. data XPrv XPrv :: Version -> Depth -> Fingerprint -> Index -> Chain -> Prv -> XPrv [xprv_version] :: XPrv -> Version [xprv_depth] :: XPrv -> Depth [xprv_fingerprint] :: XPrv -> Fingerprint [xprv_index] :: XPrv -> Index [xprv_chain] :: XPrv -> Chain [xprv_prv] :: XPrv -> Prv -- | Obtain the XPub corresponding to a particular XPrv, at a -- particular Version. xprvToXPub :: Version -> XPrv -> XPub -- | Derive a XPrv subkey from a parent XPrv key. -- -- Returns Nothing if the given inputs result in an invalid key. subXPrvXPrv :: XPrv -> Index -> Maybe XPrv -- | Behaves exactly like subXPrvXPrv, but deals with Chain -- and Prv, rather than an XPrv. subPrvPrv :: Chain -> Prv -> Index -> Maybe (Chain, Prv) -- | Lazily derive all the child XPrv subkeys from a parent's -- XPrv. -- -- The first child returned is the one at the given Index, if any, -- and the subsequent childs are those immediately after it (see -- indexNext). -- -- The returned Indexes are not necessarily consecutive, since not -- all XPrv and Index combinations are able to derive valid -- keys. However, the produced Indexes do increase monotonically. -- -- If the given Index is hardened, then all produced children will -- have hardened Indexes too. If the given Index is normal, -- then all children will have normal Indexes too. That is, this -- function will never produce children with Indexes belonging to -- another group (normal vs. hardened). subsXPrvXPrv :: XPrv -> Index -> [XPrv] -- | Behaves exactly like subsXPrvXPrv, but deals with Chain -- and Prv, rather than an XPrv. subsPrvPrv :: Chain -> Prv -> Index -> [(Index, Chain, Prv)] -- | Derive XPub subkey from a parent XPrv key. -- -- Notice that while subXPubXPub (xprvToXPub v) xprv -- i will fail with a hardened Index, subXPrvXPub -- v xprv i may succeed. -- -- Returns Nothing if the given inputs result in an invalid key. subXPrvXPub :: Version -> XPrv -> Index -> Maybe XPub -- | Behaves exactly like subXPrvXPub, but deals with Chain, -- Prv and Pub, rather than an XPrv and XPub. subPrvPub :: Chain -> Prv -> Index -> Maybe (Chain, Pub) -- | Lazily derive all the XPub subkeys from a parent XPrv -- key. -- -- The first child returned is the one at the given Index, if any, -- and the subsequent childs are those immediately after it (see -- indexNext). -- -- The returned Indexes are not necessarily consecutive, since not -- all XPrv and Index combinations are able to derive valid -- keys. However, the produced Indexes do increase monotonically. -- -- If the given Index is hardened, then all produced children will -- have hardened Indexes too. If the given Index is normal, -- then all children will have normal Indexes too. That is, this -- function will never produce children with Indexes belonging to -- another group (normal vs. hardened). -- -- Notice that while subsXPubXPub (xprvToXPub v) -- xprv i will fail with a hardened Index, -- subsXPrvXPub v xprv i may succeed. subsXPrvXPub :: Version -> XPrv -> Index -> [XPub] -- | Behaves exactly like subsXPrvXPub, but deals with Chain, -- Prv and Pub, rather than an XPrv and XPub. subsPrvPub :: Chain -> Prv -> Index -> [(Index, Chain, Pub)] -- | Extended private key. data XPub XPub :: Version -> Depth -> Fingerprint -> Index -> Chain -> Pub -> XPub [xpub_version] :: XPub -> Version [xpub_depth] :: XPub -> Depth [xpub_fingerprint] :: XPub -> Fingerprint [xpub_index] :: XPub -> Index [xpub_chain] :: XPub -> Chain [xpub_pub] :: XPub -> Pub -- | Derive a XPub subkey from a parent XPub key. -- -- The given Index is expected to not be hardened. -- -- Returns Nothing if the given inputs result in an invalid key. subXPubXPub :: XPub -> Index -> Maybe XPub -- | Behaves exactly like subXPubXPub, but deals with Chain -- and Pub, rather than an XPub. subPubPub :: Chain -> Pub -> Index -> Maybe (Chain, Pub) -- | Lazily derive all the XPub subkeys from a parent's XPub. -- -- The first child returned is the one at the given Index, if any, -- and the subsequent childs are those immediately after it (see -- indexNext). -- -- The returned Indexes are not necessarily consecutive, since not -- all XPub and Index combinations are able to derive valid -- keys. However, the produced Indexes do increase monotonically. -- -- The produced list will never include a hardened Index. If a -- hardened Index is provided as input, the produced list will be -- empty. subsXPubXPub :: XPub -> Index -> [XPub] -- | Behaves exactly like subsXPubXPub, but deals with Chain -- and Pub, rather than an XPub. subsPubPub :: Chain -> Pub -> Index -> [(Index, Chain, Pub)] -- | Chain code. -- -- Construct with chain. data Chain -- | Construct a Chain code. -- -- See Bitcoin's BIP-0032 for details. -- -- Nothing if the ByteString length is not 32. chain :: ByteString -> Maybe Chain -- | Obtain the 32 raw bytes inside a Chain. unChain :: Chain -> ByteString -- | A derivation path Index. newtype Index Index :: Word32 -> Index [unIndex] :: Index -> Word32 -- | Whether a derivation path Index is hardened. That is, -- <math> or larger. indexIsHardened :: Index -> Bool -- | Increment the given Index by one, but only if doing so would -- result in a new Index in the same index group (normal vs. -- hardened). Otherwise, returns Nothing. indexNext :: Index -> Maybe Index -- | Derivation path depth. -- --