Safety: Never type or paste a real recovery phrase, seed, or extended private key into a website, chat, or any tool you do not fully control and trust. Examples on this page come from published specifications, not from a personal wallet.
BIP32 is the standard that turns one seed into a tree of key pairs. A single backup can then cover many receiving and change addresses. Parts of that tree can also be shared: an extended public key can generate new addresses without giving away the ability to spend.
BIP32 is not a mnemonic standard. It predates BIP39 and does not define recovery words. When a BIP39 wallet talks about "derivation," it is usually feeding the 64-byte BIP39 seed into BIP32, then following a later path convention such as BIP44.
Why hierarchical wallets exist
Early Bitcoin wallets created keys at random. To avoid needing a new backup after every payment, the reference client kept a pool of unused keys. Those wallets were awkward to share across devices, and a "neutered" encrypted copy could not even generate new public addresses.
Deterministic wallets fix the backup problem: one seed always produces the same keys. A simple linear chain of keys, though, can only be shared all at once. BIP32's motivation is selective sharing. A shop's web server, for example, can be given only the public branch used to receive customer payments, not the private keys and not the internal change addresses.
The document is informational, assigned on 2012-02-11, and authored by Pieter Wuille. It assumes Bitcoin's secp256k1 curve.
From seed to master key
BIP32 does not start from a master private key chosen directly. The space of extended keys is far larger than the 256-bit keys that actually sit on the curve, so the master key is derived from a seed byte string S.
The seed length may be anywhere from 128 to 512 bits. The specification advises 256 bits. A BIP39 seed is 512 bits (64 bytes), which is a valid BIP32 seed length.
The master key is computed as:
I = HMAC-SHA512(Key = "Bitcoin seed", Data = S)
The left 32 bytes of I become the master private key. The right 32 bytes become the master chain code. If the left 32 bytes are zero or are greater than or equal to the curve order n, the master key is invalid and a new seed must be used.
The HMAC key is the ASCII string Bitcoin seed. That detail matters because other schemes, such as SLIP-0010 for Ed25519, use a different HMAC key. The same seed bytes can therefore produce a different master key if a wallet is not following BIP32's secp256k1 construction.
Extended keys and child derivation
A BIP32 node is not just a private or public key. It is an extended key: the key plus a 32-byte chain code. The chain code is extra entropy so that child keys do not depend on the parent key alone.
Each extended key has 2^31 normal (non-hardened) children, with indices 0 through 2^31 − 1, and 2^31 hardened children, with indices 2^31 through 2^32 − 1. A hardened index i is written with a trailing apostrophe, or as iH, and means i + 2^31.
Child keys are derived with HMAC-SHA512, using the parent's chain code as the HMAC key. For a non-hardened child, the HMAC input is the parent's public key and the index. For a hardened child, the HMAC input is the parent's private key (padded) and the index. In both cases the output is split: the left half is combined with the parent key, and the right half becomes the child's chain code.
Two consequences follow from that design.
An extended private key can derive every descendant private and public key, hardened or not.
An extended public key can derive only non-hardened descendant public keys. It cannot derive hardened children, and it cannot spend funds. That is what makes a watch-only account possible: you export the account's extended public key and generate receiving addresses without placing private keys on the watching device.
Hardened derivation exists because non-hardened branches have a serious limitation. If someone has a parent extended public key and also obtains any non-hardened child private key, they can recover the parent private key. That is why later standards such as BIP44 harden the purpose, coin type, and account levels, and only then use non-hardened derivation for the receiving and change addresses.
Serialization: xpub and xprv
Extended keys are serialized as a 78-byte structure:
- 4 version bytes
- 1 depth byte (zero for the master node)
- 4-byte parent fingerprint (zero for the master)
- 4-byte child number (zero for the master)
- 32-byte chain code
- 33-byte key data (a compressed public key, or a 0x00 prefix plus the private key)
A 4-byte checksum is appended (the first 32 bits of a double SHA-256), and the result is Base58-encoded. The encoded string is always 111 characters.
On mainnet, the version bytes are 0x0488B21E for public keys and 0x0488ADE4 for private keys, which is why the strings start with xpub and xprv. On testnet they start with tpub and tprv. These are the prefixes defined in BIP32 itself. Later conventions such as ypub and zpub are not part of BIP32; they are explained on the extended keys page.
When software imports an extended public key, BIP32 requires it to check that the public key data is a valid point on the curve.
The original wallet layout
After defining the tree, BIP32 suggests a default wallet structure. It is a default only, but clients are encouraged to follow it for compatibility.
The wallet is organized as numbered accounts, with account 0 as the default. Each account has two chains: an external chain for addresses you give out, and an internal chain for change and other addresses that do not need to be shared. In this original layout, the k-th external key of account i is at m/i'/0/k, and the k-th internal key is at m/i'/1/k.
That is not the path used by most modern multi-coin wallets. BIP43 later reserved the first hardened level as a purpose field, and BIP44 placed coin type and account under purpose 44'. BIP32's own default still matters when you are reading older material, or when a wallet really is using the original layout rather than BIP44.
How BIP39 connects
BIP39 stops at the 64-byte seed. BIP32 starts from a seed and builds a tree. A typical "BIP39 wallet" is both: the words produce a seed, and BIP32 (often with BIP44 or a related purpose) produces the keys.
BIP32 does not say which path a Bitcoin wallet should use for legacy, SegWit, or Taproot addresses. That is why two wallets can show different addresses from the same recovery phrase: they may be using different purposes, different script types, or even a different tree standard altogether.
FAQ
Is a BIP32 wallet the same thing as a BIP39 wallet? No. BIP32 is the key tree. BIP39 is a way to encode a seed as words. Many wallets use both. Some wallets use BIP32 with a different seed format, such as Electrum or SLIP39.
If I back up the mnemonic, do I also need to back up the xprv? If the wallet derived that xprv from your seed and you know the path and script type, the mnemonic (plus any passphrase) is the root backup. An xprv is a backup of one node and everything below it, not a substitute for knowing how the wallet used the tree.
Is it safe to share an xpub? An xpub does not let someone spend funds, but it does reveal all non-hardened addresses under that node, which is a privacy leak. If a non-hardened child private key is also leaked, the parent private key can be recovered. Share account-level xpubs only with systems you trust to watch the wallet, and prefer hardened ancestors as BIP44 does.
What does the apostrophe in a path mean? It marks a hardened child. 0' is index 2^31, not index 0.
See also
- BIP39 passphrase
- BIP43: the purpose field
- BIP44: multi-account hierarchy and legacy addresses
- Extended keys: xpub, ypub, zpub
- SLIP39: Shamir backups
- Bitcoin Core descriptors