Introduction to HD Wallets
Hierarchical Deterministic Wallets (HD Wallets) are a cryptographic method for generating multiple cryptocurrency addresses from a single master seed. Originally introduced in Bitcoin's BIP-0032, this concept is widely used in Ethereum, where you might encounter strings like m/44'/60'/0'/0—part of a derivation path.
Key Features:
- Single Seed Control: All addresses derive from one master seed.
- Selective Sharing: Allows partial wallet access without exposing private keys.
- Backup Efficiency: Eliminates the need to repeatedly back up individual private keys.
Motivation Behind HD Wallets
Problems with Non-Deterministic Wallets:
- Random Private Keys: Early wallets generated random private keys, requiring frequent backups.
- Address Management: Pre-generating addresses (e.g., 100 keys) only delayed backup needs without solving the core issue.
Advantages of Deterministic Wallets:
- Elliptic Curve Magic: Enables public key generation without revealing private keys.
- Hierarchical Structure: Supports multiple key chains from one root, enabling selective sharing (e.g., a webserver generating payment addresses without full wallet access).
Key Insight: Deterministic wallets allow generating addresses "on-the-fly" while maintaining full control via the master private key.
Technical Specification: Key Derivation
Core Components:
- Chain Code: A 32-byte entropy value ensuring child keys aren’t predictable from the parent key alone.
- Extended Keys: Pair a private/public key with a chain code (e.g.,
(k, c)for private keys).
Child Key Derivation (CKD):
Parent Private Key → Child Private Key
- Uses HMAC-SHA512 with the parent chain code and index
i. - For hardened keys (
i ≥ 2³¹), prepends0x00to the parent private key. - For normal keys, uses the parent public key.
- Uses HMAC-SHA512 with the parent chain code and index
Parent Public Key → Child Public Key
- Only works for non-hardened keys (
i < 2³¹). - Fails if attempting hardened derivation (security feature).
- Only works for non-hardened keys (
Parent Private Key → Child Public Key
Two equivalent methods:
- Derive child private key first, then compute its public key (
N(CKDpriv(...))). - Directly derive from parent public key (
CKDpub(N(...))).
- Derive child private key first, then compute its public key (
Parent Public Key → Child Private Key
- Impossible—ensures security against reverse engineering.
Key Tree Notation:
Example:
m/3_H/2/5denotes:- Master → Hardened child 3 → Normal child 2 → Normal child 5.
- Public keys follow parallel paths (e.g.,
M/3/2/5).
BIP-44: Multi-Currency HD Wallets
Path Structure:
m / purpose' / coin_type' / account' / change / address_index- Purpose: Fixed as
44'(BIP-44 compliant). - Coin Type: Ethereum uses
60'(SLIP-0044). - Account: Isolates funds by user-defined categories (e.g.,
0'for savings). - Change:
0= external (receiving),1= internal (change addresses). - Address Index: Incremental from
0(e.g.,/0/0,/0/1).
Account Discovery Algorithm:
- Start with
account = 0. - Scan 20 consecutive unused addresses on the external chain.
- If transactions exist, increment
accountand repeat.
Security Note: Prevents unused accounts from cluttering the wallet.
FAQs
Q1: Why use hardened derivation?
A1: Prevents parent private key exposure if a child key is compromised. Non-hardened keys allow deriving siblings if one key is known.
Q2: What’s the purpose of the chain code?
A2: Adds entropy to ensure child keys aren’t predictable solely from the parent key.
Q3: Can I derive Ethereum addresses from a Bitcoin HD wallet?
A3: Yes! Use coin_type = 60' in the derivation path for Ethereum.
Q4: How does BIP-44 improve privacy?
A4: Separates coins/accounts to avoid address reuse, making transactions harder to trace.
👉 Explore advanced HD wallet implementations
Conclusion
HD wallets revolutionize cryptocurrency management by:
- Simplifying backups (one seed).
- Enabling hierarchical organization (accounts, coins).
- Enhancing security (hardened keys, chain codes).
For Ethereum developers, mastering paths like m/44'/60'/0'/0 is crucial for secure address generation.
👉 Dive deeper into blockchain security