Mastering Bitcoin: Chapter 4 - Keys, Addresses, Wallets

·

Chapter Overview

In this chapter, we explore the fundamental cryptographic components that enable Bitcoin ownership and transactions: digital keys, Bitcoin addresses, and wallets. You'll learn how these elements interact to establish secure control over bitcoin funds.

4.1 Introduction to Bitcoin Ownership

Bitcoin ownership isn't determined by physical possession but through digital cryptography:

Ownership is established through mathematical proof rather than physical control. The Bitcoin protocol never stores keys directly—they're generated and managed by users' wallet software independently of the blockchain network.

4.1.1 Public Key Cryptography Fundamentals

Bitcoin utilizes elliptic curve cryptography (ECC) for its security model:

👉 Learn more about elliptic curve cryptography

4.1.2 Private and Public Keys

Each Bitcoin wallet contains cryptographic key pairs:

  1. Private Key (k): A randomly generated 256-bit number serving as ultimate control
  2. Public Key (K): Derived from private key via elliptic curve multiplication (K = k*G)
The public key acts like a bank account number, while the private key functions like a PIN or signature authority.

4.1.3 Private Key Generation

Private keys are simply random numbers within a specific range (1 to n-1, where n ≈ 1.158×10^77). Secure generation requires:

Example private key in hexadecimal:

1E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD

4.1.4 Public Key Derivation

Public keys are computed from private keys using elliptic curve multiplication:

K = k * G

Where:

4.1.5 Elliptic Curve Cryptography Explained

Bitcoin uses the secp256k1 elliptic curve defined by:

y² = (x³ + 7) mod p

Key properties:

4.2 Bitcoin Addresses

A Bitcoin address is a base58check-encoded string representing a public key hash. Address generation involves:

  1. SHA-256 hashing the public key
  2. RIPEMD-160 hashing that result
  3. Adding version byte + checksum
  4. Base58Check encoding

Example address:
1J7mdg5rbQyUHENYdx39WVWK7fsLpEoXZy

4.2.1 Base58Check Encoding

Base58Check provides:

Common version prefixes:

PrefixAddress Type
0x00P2PKH (Pay-to-Pubkey-Hash)
0x05P2SH (Pay-to-Script-Hash)

4.2.2 Key Formats

Private keys have multiple representation formats:

FormatExample
Hexadecimal1E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD
WIF5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn
WIF-CompressedKxFC1jmwwCoACiCAWZ3eXa96mBM6tb3TYzGmf6YwgdGWZgawvrtJ

4.3 Wallet Technologies

4.3.1 Non-Deterministic (Random) Wallets

4.3.2 Deterministic (Seed) Wallets

4.3.3 Mnemonic Code Words

4.3.4 Hierarchical Deterministic Wallets (BIP32/BIP44)

4.4 Advanced Key & Address Types

4.4.1 Encrypted Private Keys (BIP38)

4.4.2 P2SH (Pay-to-Script-Hash)

4.4.3 Vanity Addresses

4.4.4 Paper Wallets

FAQ Section

Q: What's the difference between private and public keys?

A: Private keys (256-bit numbers) generate corresponding public keys via elliptic curve multiplication. Public keys can be freely shared to receive payments, while private keys must remain secret to spend funds.

Q: How are Bitcoin addresses created from public keys?

A: Addresses are RIPEMD160(SHA256(public_key)) hashes encoded in Base58Check format with version prefix and checksum.

Q: What makes HD wallets better than random key wallets?

A: HD wallets derive all keys from a single master seed, enabling:

Q: Are vanity addresses less secure?

A: No—they provide equivalent cryptographic security. However, shorter patterns are easier to brute force, so longer vanity strings (7+ characters) are recommended.

Q: Why use paper wallets?

A: Paper wallets provide:

👉 Explore secure wallet solutions