bip32

Pure Haskell BIP32 hierarchical deterministic wallets.
git clone git://git.ppad.tech/bip32.git
Log | Files | Refs | LICENSE

commit 9aca927703f4ea6735e796474fb588597a51b769
parent 2121855c1ec0f971ca9db4da3f30239c0bcb2154
Author: Jared Tobin <jared@jtobin.io>
Date:   Thu, 20 Feb 2025 17:39:32 +0400

lib: master_priv, master_pub

Diffstat:
Mlib/Crypto/HDKey/BIP32.hs | 20++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/Crypto/HDKey/BIP32.hs b/lib/Crypto/HDKey/BIP32.hs @@ -145,9 +145,15 @@ data HDKey = HDKey { , ek_parent :: !(Maybe BS.ByteString) -- parent fingerprint , ek_child :: !BS.ByteString } + deriving (Eq, Show) + +instance Extended HDKey where + identifier (HDKey ekey _ _ _) = case ekey of + Left l -> identifier l + Right r -> identifier r -master :: BS.ByteString -> Maybe HDKey -master seed = do +master_priv :: BS.ByteString -> Maybe HDKey +master_priv seed = do m <- _master seed pure $! HDKey { ek_key = Right m @@ -156,6 +162,16 @@ master seed = do , ek_child = ser32 0 } +master_pub :: BS.ByteString -> Maybe HDKey +master_pub seed = do + m <- _master seed + pure $! HDKey { + ek_key = Left (n m) + , ek_depth = 0 + , ek_parent = Nothing + , ek_child = ser32 0 + } + derive_priv :: HDKey -> Word32 -> Maybe HDKey derive_priv HDKey {..} i = case ek_key of Left _ -> Nothing