How Private Keys Generate All Addresses

Overview

In Bitcoin, a single private key can generate multiple address formats. This is possible because all address types are derived from the same underlying public key, with each format applying different encoding and hashing operations. Understanding this relationship is fundamental to Bitcoin key management and wallet implementation.

The Derivation Chain

Address generation follows a deterministic chain of cryptographic operations:

The following diagram shows the derivation chain:
> Derivation Chain Private Key Public Key Public Key Hash Address

Each step in this chain is a one-way function, meaning it is computationally infeasible to reverse the process. This ensures that addresses can be freely shared without exposing the private key.

Step 1: Private Key Generation

A Bitcoin private key is a randomly generated 256-bit number (32 bytes). It must fall within the valid range for the secp256k1 elliptic curve:

Valid range: From 1 to 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140

The private key can be represented in several formats:

  • Raw Hex: 64 hexadecimal characters.
  • WIF (Wallet Import Format): Base58Check encoded with version prefix.
  • WIF Compressed: WIF with compression flag indicating compressed public key usage.
The following shows the possible private key formats:
Private Key Formatsplaintext
# Raw Hex (32 bytes)
e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35

# WIF (Uncompressed)
5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF

# WIF (Compressed)
L53fCHmQhbNp1B4JipfBtfeHZH7cAibzG9oK19XfiFzxHgAkz6JK

Step 2: Public Key Derivation

The public key is derived from the private key using elliptic curve multiplication on the secp256k1 curve:

Public Key = Private Key × G

Where G is the generator point of the secp256k1 curve. This operation is computationally easy in one direction but infeasible to reverse (the discrete logarithm problem).

Public keys can be represented in two formats:

  • Uncompressed Public Key (65 bytes).
  • Compressed Public Key (33 bytes).

Uncompressed Public Key

The following diagram shows the uncompressed public key format:
Uncompressed Public Key 04 1 byte x-coordinate 32 bytes y-coordinate 32 bytes

The prefix 04 indicates an uncompressed key containing both x and y coordinates.

Compressed Public Key

The following diagram shows the compressed public key format:
Compressed Public Key 02 1 byte x-coordinate 32 bytes y is even 03 1 byte x-coordinate 32 bytes y is odd

Compressed keys store only the x-coordinate with a prefix indicating the y-coordinate's parity:

  • 02: Indicates the y-coordinate is even.
  • 03: Indicates the y-coordinate is odd.

The full y-coordinate can be mathematically recovered from the x-coordinate and the curve equation.

The following shows the possible public key formats:
Public Key Formatsplaintext
# Uncompressed (65 bytes)
04
79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798  # x
483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8  # y

# Uncompressed Full
0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8

# Compressed (33 bytes)
02
79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798

# Compressed Full
0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798

Step 3: Public Key Hashing

Most Bitcoin addresses use a hash of the public key rather than the raw public key. This provides an additional layer of security and produces shorter addresses.

  • HASH160: P2PKH, P2WPKH.
  • SHA-256: P2TR.

Step 4: Address Encoding

The final step converts the public key or its hash into a human-readable address format. Different address types use different encoding schemes.

  • Base58Check: Used by legacy addresses (P2PKH, P2SH).
  • Bech32: Used by native SegWit v0 addresses (P2WPKH, P2WSH).
  • Bech32m: Used by SegWit v1+ addresses (P2TR).

One Key, Multiple Addresses

A single private key produces different addresses for each format, but all addresses represent the same underlying control.

The following table shows address types & examples:
Address Type Encoding Example Address
P2PKH HASH160 → Base58Check 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
P2WPKH HASH160 → Bech32 bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4
P2TR X-Only + Tweak → Bech32m bc1p5d7rjq7g6rdk2yhzks9smlaqtedr4dekq08ge8ztwac72sfr9rusxg3297

Funds sent to any of these addresses can be spent using the same private key. However, the signing process differs slightly for each address type due to different script structures and signature algorithms.

Hierarchical Deterministic (HD) Derivation

While a single private key can generate multiple address formats, modern wallets use HD derivation to generate multiple private keys from a single seed.

The following diagram shows the hierarchical deterministic derivation process:
HD Derivation Mnemonic Seed Master Key Derived Keys Addresses

Each derived key follows the same process described above to generate addresses. This enables:

  • Unlimited Addresses: Generate new addresses for each transaction.
  • Single Backup: One mnemonic phrase recovers all derived keys.
  • Account Separation: Organize keys into accounts for different purposes.
  • Address Type Paths: BIP44/49/84/86 define derivation paths for each address format.

Standard Derivation Paths

The following table shows address types & derivation path:
Address Type BIP Derivation Path
P2PKH BIP44 m/44'/0'/0'/0/0
P2SH-P2WPKH BIP49 m/49'/0'/0'/0/0
P2WPKH BIP84 m/84'/0'/0'/0/0
P2TR BIP86 m/86'/0'/0'/0/0