bip32

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

README.md (2441B)


      1 # bip32
      2 
      3 [![](https://img.shields.io/hackage/v/ppad-bip32?color=blue)](https://hackage.haskell.org/package/ppad-bip32)
      4 ![](https://img.shields.io/badge/license-MIT-brightgreen)
      5 
      6 An implementation of [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) hierarchical deterministic wallets and extended keys.
      7 
      8 ## Usage
      9 
     10 A sample GHCi session:
     11 
     12 ```
     13   > :set -XOverloadedStrings
     14   >
     15   > import Crypto.HDKey.BIP32
     16   >
     17   > -- derive a master node from a master seed
     18   > let Just m = master "plenty of entropy"
     19   >
     20   > -- use 'xpub', 'xprv', etc. to serialize
     21   > xpub m
     22   "xpub661MyMwAqRbcG6TPJvVs1yKFJGtN4vi785g2xDacQ9Luyw3gyAyvY5DNatPzfsUQK4nTUAmQboxw3WYDHtY4vfcGJR4FAuLLaUp2t7ejhoC"
     23   >
     24   > -- derive child nodes via a path
     25   > let child = derive_partial m "m/44'/0'/0'/0/0"
     26   > xpub child
     27   "xpub6GEwJiJFou5PH6LL8cagArvArrXhSaq35XWnT73CShNRBJa9jxHsWnPsydvmN2vcPBg9KHfRyYLiYnUKCJ8ncba4CgzF56n4kpkqMTSFy35"
     28   >
     29   > -- use the 'hd_key' record to extract the extended key
     30   > let Right (XPrv (X sec cod)) = hd_key child
     31   > sec
     32   82064013501759548583899633460204676801585795402966146917762774758050650403971
     33   >
     34   > -- use 'parse' to import an extended key
     35   > let Just hd = parse (xprv child)
     36   > hd == child
     37   True
     38 ```
     39 
     40 ## Documentation
     41 
     42 Haddocks (API documentation, etc.) are hosted at
     43 [docs.ppad.tech/bip32](https://docs.ppad.tech/bip32).
     44 
     45 ## Security
     46 
     47 This library aims at the maximum security achievable in a
     48 garbage-collected language under an optimizing compiler such as GHC, in
     49 which strict constant-timeness can be [challenging to achieve][const].
     50 
     51 The implementation within passes the official [BIP32 test
     52 vectors](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors), and all derivations involving secret keys execute
     53 *algorithmically* in constant time -- see the "Security" notes in the
     54 README of [ppad-secp256k1][secp] for more details.
     55 
     56 If you discover any vulnerabilities, please disclose them via
     57 security@ppad.tech.
     58 
     59 ## Development
     60 
     61 You'll require [Nix][nixos] with [flake][flake] support enabled. Enter a
     62 development shell with:
     63 
     64 ```
     65 $ nix develop
     66 ```
     67 
     68 Then do e.g.:
     69 
     70 ```
     71 $ cabal repl ppad-bip32
     72 ```
     73 
     74 to get a REPL for the main library.
     75 
     76 [nixos]: https://nixos.org/
     77 [flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html
     78 [const]: https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html
     79 [secp]: https://git.ppad.tech/secp256k1