BIP HD Wallets

Author: Rodolfo Pietro Calabrò
Date: December 12, 2022

This article provides an overview of HD Wallets and their associated Bitcoin Improvement Proposals (BIPs): BIP-39, BIP-32, and BIP-44. It explains these concepts at a high level while including technical insights for advanced readers.


Wallet Basics

What is a Wallet?

A cryptocurrency wallet does not store money. Instead, it stores cryptographic keys that provide access to funds recorded on the blockchain.

  • Private Key: Used to unlock UTXOs (Unspent Transaction Outputs) and sign transactions.
  • Public Address: Derived from the private key, it serves as the wallet’s receiving address.

Bitcoin Address Generation Protocol


Wallet Types

Non-Deterministic Wallets

  • Store randomly generated private keys, with each key unrelated to the others.
  • Important: Backup each private key individually to avoid losing access to funds.

Deterministic Wallets

  • Use a set of mnemonic words to create a seed, which generates a master private key.
  • From the master private key, all other private and public keys can be derived.
  • Advantage: Knowing the mnemonic words allows for regenerating the wallet, making it easier to backup.

HD Wallets (Hierarchical Deterministic Wallets)

HD Wallets, introduced in BIP-32 and BIP-44, are a special type of deterministic wallet.

Key Features of HD Wallets

  • Generate a tree structure of keys, with each key having child, grandchild, and further descendant keys.
  • Enable the management of multiple accounts or coins from a single seed.
  • Simplify backups by requiring only the mnemonic words to regenerate the entire wallet.

HD Deterministic Wallets


Bitcoin Improvement Proposals (BIPs)

BIPs are Bitcoin Improvement Proposals designed to introduce changes or enhancements to the Bitcoin protocol.

  • BIP-39: Standardizes the use of mnemonic phrases for seed generation.
  • BIP-32: Defines HD Wallets and the key derivation tree structure.
  • BIP-44: Extends BIP-32 to provide a multi-account structure for HD Wallets.

For more details, visit the Bitcoin BIPs repository.


BIP-39: Mnemonic Words

BIP-39 introduces a method to generate mnemonic phrases that are converted into a seed, which is then used to derive deterministic wallets.

Overview of the Process

  1. Generate Entropy

    • A random number (entropy) of 128–256 bits is created.
    • Example: For 128 bits of entropy, you might generate 063679ca1b28b5cfda9c186b367e271e.
  2. Generate Checksum

    • Take the SHA-256 hash of the entropy and extract the first ENT/32 bits as the checksum.
    • Append the checksum to the entropy.
  3. Split into 11-bit Segments

    • The result is split into groups of 11 bits.
    • Each group maps to an index in a 2048-word list, forming the mnemonic phrase.
  4. Generate the Seed

    • Concatenate the mnemonic words.
    • Use the PBKDF2 function with the mnemonic and an optional passphrase to generate a 512-bit seed.

Security Note

Using a passphrase improves security, as it creates a completely different seed even if the same mnemonic is used.


BIP-32: Hierarchical Key Derivation

BIP-32 defines the structure and derivation process for HD Wallets.

Key Concepts

  1. Extended Keys

    • Each key (private or public) is extended with a 256-bit chain code for added security.
  2. Key Derivation

    • Keys are derived using elliptic curve cryptography (secp256k1).
    • Child keys are derived from parent keys, forming a hierarchical structure.

Benefits of BIP-32

  • Privacy: Each transaction uses a new address derived from the wallet tree.
  • Backup Simplicity: A single mnemonic phrase can regenerate the entire wallet.

BIP-32 Key Derivation Tree


BIP-44: Multi-Account Structure

BIP-44 builds on BIP-32 to organize wallets into multiple accounts, each with its own set of keys.

Structure

  • Account 0: Default account for most users.
  • External Keychain: Generates new public addresses for receiving funds.
  • Internal Keychain: Used for change addresses and other internal operations.

Use Cases

  • Auditing: Share the extended public key to allow viewing of transactions without exposing private keys.
  • Multi-Account Management: Businesses can manage separate accounts for different offices or purposes.

Conclusion

HD Wallets revolutionize cryptocurrency management by combining privacy, security, and convenience. With standards like BIP-39, BIP-32, and BIP-44, users can safely and efficiently manage multiple accounts and currencies using a single seed phrase.

For deeper insights, explore the Bitcoin BIPs repository.