Extended Keys: The Parent of Billions
Extended Keys: The Parent of Billions
In a standard Bitcoin wallet, one private key creates one public key. In a BIP32 Hierarchical Deterministic (HD) Wallet, we use Extended Keys. An extended key is a master key that can generate an infinite tree of "Child" keys.
1. The Extended Secret
An extended key is composed of two parts:
-
The Key (Private or Public): The standard 32-byte or 33-byte ECDSA key.
-
The Chain Code: An extra 32 bytes of "Entropy" that acts as a deterministic salt.
Without the Chain Code, you just have a single key. With it, you have an Extended Key that can derive a predictable sequence of sub-keys.
2. xprv vs. xpub
-
xprv (Extended Private Key): Can generate both child private keys and child public keys. This is the "Master Secret" of your wallet.
-
xpub (Extended Public Key): Can generate child Public Keys but CANNOT generate child private keys.
3. The Tree of Life
HD Wallets are structured like a file system:
-
Root: The Master Extended Key (derived from your Mnemonic Seed).
-
Branches: Accounts (e.g., Personal, Business).
-
Leaves: Individual receiving and change addresses.
4. Why use Extended Keys?
The primary benefit is Security and Portability.
-
Merchant Safety: You can put an
xpubon a web server to generate new receiving addresses for customers. Even if the server is hacked, the hacker only sees your public keys; they cannot steal your funds because they don't have the private keys. -
Single Backup: Because the tree is deterministic, as long as you have the Master Extended Key, you can recover every address and transaction in your history.
| Key Type | Can Generate Private Children? | Can Generate Public Children? |
|---|---|---|
| Private Key | No | Yes (1) |
| xprv | Yes | Yes |
| xpub | No | Yes |
In the next section, we will analyze the Anatomy of an xpub/xprv.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: