commit a9d2426ff70b6a84f423c58bf98db2f79fc6b4c0
parent 2553c8b4f66d498125016baf7aed5442a125976a
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 22 Feb 2025 13:20:07 +0400
meta: misc comments/description
Diffstat:
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/lib/Crypto/HDKey/BIP32.hs b/lib/Crypto/HDKey/BIP32.hs
@@ -13,7 +13,8 @@
-- Maintainer: Jared Tobin <jared@ppad.tech>
--
-- [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)
--- hierarchical deterministic wallets.
+-- hierarchical deterministic wallets and extended keys, with support for
+-- both serialization and parsing.
module Crypto.HDKey.BIP32 (
-- * Hierarchical deterministic keys
@@ -111,6 +112,7 @@ newtype XPub = XPub (X Secp256k1.Projective)
newtype XPrv = XPrv (X Integer)
deriving (Eq, Show)
+-- | Key types supporting identifier/fingerprint calculation.
class Extended k where
-- | Calculate the identifier for an extended key.
identifier :: k -> BS.ByteString
@@ -186,7 +188,7 @@ n (XPrv (X sec cod)) =
-- | A BIP32 hierarchical deterministic key.
--
--- This differs from the lower-level "extended" key in that it carries all
+-- This differs from lower-level "extended" keys in that it carries all
-- information required for serialization.
data HDKey = HDKey {
hd_key :: !(Either XPub XPrv) -- ^ extended public or private key
@@ -281,6 +283,9 @@ parse_path bs = case BS.uncons bs of
--
-- Fails with 'Nothing' if derivation is impossible, or if the
-- provided path is invalid.
+--
+-- >>> let hd = master "my very secret master seed"
+-- >>> derive hd "m/44'/0'/0'/0/0"
derive
:: HDKey
-> BS.ByteString -- ^ derivation path
@@ -302,6 +307,9 @@ derive hd pat = case parse_path pat of
--
-- Fails with 'error' if derivation is impossible, or if the provided
-- path is invalid.
+--
+-- >>> let hd = master "my very secret master seed"
+-- >>> derive hd "m/44'/0'/0'/0/0"
derive_partial
:: HDKey
-> BS.ByteString
diff --git a/ppad-bip32.cabal b/ppad-bip32.cabal
@@ -11,7 +11,9 @@ build-type: Simple
tested-with: GHC == 9.8.1
extra-doc-files: CHANGELOG
description:
- BIP32 hierarchical deterministic wallets
+ [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)
+ hierarchical deterministic wallets and extended keys, with support for
+ serialization and parsing.
source-repository head
type: git
@@ -27,11 +29,11 @@ library
build-depends:
base >= 4.9 && < 5
, bytestring >= 0.9 && < 0.13
- , ppad-base58
- , ppad-ripemd160
+ , ppad-base58 >= 0.2 && < 0.3
+ , ppad-ripemd160 >= 0.1.3 && < 0.2
, ppad-secp256k1 >= 0.2.2 && < 0.3
- , ppad-sha256
- , ppad-sha512
+ , ppad-sha256 >= 0.2.3 && < 0.3
+ , ppad-sha512 >= 0.1.3 && < 0.2
test-suite bip32-tests
type: exitcode-stdio-1.0