-- 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
@package bip32
@version 0.1
-- | 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
-- | Obtain the XPub corresponding to a particular XPrv, at a
-- particular Version.
xprvToXPub :: Version -> XPrv -> XPub
-- | Private key.
--
-- Construct with prv.
data Prv
-- | Construct a Prv key from its raw bytes.
--
--
-- - 32 bytes containing <math>.
--
--
-- See Bitcoin's BIP-0032 for details.
--
-- Nothing if something is not satisfied.
prv :: ByteString -> Maybe Prv
-- | Obtain the 32 raw bytes inside a Prv. See prv.
unPrv :: Prv -> ByteString
-- | Obtain the Pub key for Prv.
prvToPub :: Prv -> Pub
-- | Extended private key.
data XPub
XPub :: !Version -> !Depth -> !Fingerprint -> !Index -> !Chain -> !Pub -> XPub
-- | Public key.
--
-- Construct with pub.
data Pub
-- | Construct a Pub key from its raw bytes.
--
--
-- - 33 bytes in total, containing <math>.
-- - The leftmost byte is either 0x02 or 0x03,
-- depending on the parity of the omitted y coordinate.
-- - The remaining 32 bytes are <math>.
--
--
-- See Bitcoin's BIP-0032 for details.
--
-- Nothing if something is not satisfied.
pub :: ByteString -> Maybe Pub
-- | Obtain the 33 raw bytes inside a Pub. See pub.
--
-- Corresponds to BIP-0032's <math>.
unPub :: Pub -> ByteString
-- | 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
-- | Whether a derivation path Index is hardened. That is,
-- <math> or larger.
indexIsHardened :: Index -> Bool
-- | Derive a child XPub subkey from a parent 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
-- | Derive a child XPrv subkey from a parent a parent XPrv
-- key.
--
-- Returns Nothing if the given inputs result in an invalid key.
subXPrvXPrv :: XPrv -> Index -> Maybe XPrv
-- | Derive a child XPub subkey from a parent 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
-- | Derive a child Pub subkey and Chain code at a particular
-- Index from a parent Pub and Chain code.
--
-- The given Index is expected to not be hardened.
--
-- Returns Nothing if the given inputs result in an invalid key.
subPubPub :: Chain -> Pub -> Index -> Maybe (Chain, Pub)
-- | Derive a child Prv subkey and Chain code at a particular
-- Index from a parent Prv and Chain code.
--
-- Returns Nothing if the given inputs result in an invalid key.
subPrvPrv :: Chain -> Prv -> Index -> Maybe (Chain, Prv)
-- | Derive a child Pub subkey and Chain code at a particular
-- Index from a parent Prv and Chain code.
--
-- Notice that while subPubPub (prvToPub prv) i
-- will fail with a hardened Index, subPrvPub prv
-- i may succeed.
--
-- Returns Nothing if the given inputs result in an invalid key.
subPrvPub :: Chain -> Prv -> Index -> Maybe (Chain, Pub)
-- | Derivation path depth.
--
--
-- - 0 for master nodes — m
-- - 1 for level-1 derived keys — m/0', or
-- m/13, or …
-- - 2 for level-2 derived keys — m/0'/28, or
-- m/44'/0', or …
-- - … up to 255.
--
newtype Depth
Depth :: Word8 -> Depth
[unDepth] :: Depth -> Word8
-- | 4-byte fingerprint of a Pub key.
newtype Fingerprint
Fingerprint :: Word32 -> Fingerprint
[unFingerprint] :: Fingerprint -> Word32
fingerprint :: Pub -> Fingerprint
-- | Version bytes.
newtype Version
Version :: Word32 -> Version
[unVersion] :: Version -> Word32
-- | 0x0488ade4, “xprv”, Bitcoin mainnet private.
version_xprv :: Version
-- | 0x0488b21e, “xpub”, Bitcoin mainnet public.
version_xpub :: Version
-- | 0x04358394, “tprv”, Bitcoin testnet private.
version_tprv :: Version
-- | 0x043587cf, “tpub”, Bitcoin testnet public.
version_tpub :: Version
-- | 0x019d9cfe, “Ltpv”, Litecoin mainnet private.
version_Ltpv :: Version
-- | 0x019da462, “Ltub”, Litecoin mainnet public.
version_Ltub :: Version
-- | 0x0436ef7d, “ttpv”, Litecoin testnet private.
version_ttpv :: Version
-- | 0x0436f6e1, “ttub”, Litecoin testnet public.
version_ttub :: Version
instance GHC.Show.Show BIP32.XPrv
instance GHC.Classes.Eq BIP32.XPrv
instance GHC.Show.Show BIP32.XPub
instance GHC.Classes.Eq BIP32.XPub
instance GHC.Show.Show BIP32.Index
instance GHC.Classes.Ord BIP32.Index
instance GHC.Classes.Eq BIP32.Index
instance GHC.Classes.Eq BIP32.Chain
instance GHC.Show.Show BIP32.Fingerprint
instance GHC.Classes.Eq BIP32.Fingerprint
instance GHC.Show.Show BIP32.Depth
instance GHC.Classes.Eq BIP32.Depth
instance GHC.Show.Show BIP32.Version
instance GHC.Classes.Eq BIP32.Version
instance GHC.Show.Show BIP32.Chain