Deriving & Cracking BIP32 HD Keys in JavaScript

The latest release of bitcoin-ts now supports BIP32 Hierarchical Deterministic (HD) key derivation, including a method for reversing the non-hardened derivation algorithm.

What is BIP32?

BIP32 is the most common standard for deriving many private keys from a single “master” HD private key. It’s commonly used with 12–word BIP39 mnemonic phrases to make wallet backups easy.

The BIP32 specification standardizes:

  • Master key derivation from a random seed
  • Public derivation — a method for deriving more public keys from a single HD public key (e.g. to create a “watch-only” wallet)
  • “Hardened” derivation — a derivation method which requires the HD private key (for use cases where child keys may be shared)
  • encoding/decoding of HD public keys and HD private keys

BIP32 Support in bitcoin-ts

Like the rest of bitcoin-ts, BIP32 functionality has no external dependencies and is designed to be fully tree-shakable — only the methods directly used by your application are imported, so your build system can produce the smallest possible javascript bundle. With existing cryptographic primitives, adding BIP32 support adds less than 1KB to most wallet applications.

All bitcoin-ts methods provide extensive documentation using the TSDoc standard. In most editor environments, you can hover over a method or type to view its documentation.

Below is a short tutorial and demo for developers. Click the run ► button to see the demo in action, or click open in Repl.it (top right) to view it in the full editor (where hover-tooltip documentation works).

If you have any questions or feedback, please let me know. You can also open an issue on the GitHub repo. Thanks for reading!