Note: chainCode property is essentially a private part
of a secret "master" key, it should be guarded from unauthorized access. Byte-array
getters return copies so callers cannot mutate an HDKey's internal state. These
snapshots remain caller-owned and are not zeroed by wipePrivateData().
For backwards compatibility, JSON.stringify() currently serializes both the
private and public extended keys of an HDKey. Treat the result as secret key
material. A future v3 release will make automatic JSON serialization public-only.
The full API is:
class HDKey { public static HARDENED_OFFSET: number; public static fromMasterSeed(seed: Uint8Array, versions: Versions): HDKey; public static fromExtendedKey(base58key: string, versions: Versions): HDKey; public static fromJSON(json: { xpriv: string } | { xpub: string }): HDKey; readonly versions: Versions; readonly depth: number =
The module implements bip32 standard:
check it out for additional documentation.
BIP32 is a bad standard. It would be great if we've had something better.
Network IDs (different currencies) are taken from a single GitHub document
called SLIP-0044
There were new projects, which did not yet have SLIP. Exchanges added support of
those projects to their cold wallets. Then after the projects were added to SLIP,
the exchanges were required to re-generate their cold wallets - a complicated task
BIP32 is unusable for many different elliptic curves. For example, ETH2 uses bls12-381
curve, and with bip32 54% of generated keys would be invalid. So, they’re using much better
BLS-only EIP-2333 as a replacement.
It’s easy to shoot yourself in foot with non-hardened keys, which
could allow simple de-anonimization of all addresses
Security
The library has been audited:
at version 2.2.0, in Apr 2026, by ourselves (self-audited)
The library was initially developed for js-ethereum-cryptography.
At commit ae00e6d7,
it was extracted to a separate package called micro-bip32.
After the audit we've decided to use @scure NPM namespace for security.
Supply chain security
Commits are signed with PGP keys to prevent forgery. Be sure to verify the commit signatures
Releases are made transparently through token-less GitHub CI and Trusted Publishing. Be sure to verify the provenance logs for authenticity.
Rare releasing is practiced to minimize the need for re-audits by end-users.
Dependencies are minimized and strictly pinned to reduce supply-chain risk.
We use as few dependencies as possible.
Version ranges are locked, and changes are checked with npm-diff.
Dev dependencies are excluded from end-user installs; they’re only used for development and build steps.
For this package, there are 3 dependencies; and a few dev dependencies: