Bitcoin: Generating Private Keys, Public Keys, and Addresses

Β·

Introduction

Bitcoin addresses are derived from cryptographic key pairs through a series of deterministic steps. This guide explains how private keys, public keys, and Bitcoin addresses are generated using Elliptic Curve Cryptography (ECC) and hashing algorithms.


Key Concepts

Bitcoin Addresses


Key Types

All keys use Base58Check encoding for ASCII representation:

  1. Private Key: 256-bit random number.
  2. Public Key: Derived from the private key via ECC.
  3. Address: RIPEMD-160 hash of the public key.

Bitcoin Address Generation Process

Step 1: Generate a Private Key

πŸ‘‰ Learn how to securely store private keys

Step 2: Derive the Public Key

Using the elliptic curve equation K = k * G:

Example (Uncompressed):

04  
06CCAE7536386DA2C5ADD428B099C7658814CA837F94FADE365D0EC6B1519385  
FF83EC5F2C0C8F016A32134589F7B9E97ACBFEFD2EF12A91FA622B38A1449EEB  

Step 3: Create the Address

  1. Hash the public key with SHA-256 β†’ RIPEMD-160 (20-byte hash).
  2. Prepend the network version byte (0x00 for mainnet).
  3. Append a 4-byte checksum (first 4 bytes of SHA-256(SHA-256(version + hash))).
  4. Encode in Base58.

Example:


Technical Details

Compressed Public Keys

Example:

Private Key: de97fdbdb823a197603e1f2cb8b1bded3824147e88ebd47367ba82d4b5600d73  
Compressed Public Key: 037c91259636a5a16538e0603636f06c532dd6f2bb42f8dd33fa0cdb39546cf449  

Base58Check Encoding

Example (Private Key):

Hex: de97fdbdb823a197603e1f2cb8b1bded3824147e88ebd47367ba82d4b5600d73  
Base58Check: 5KWKSRnmzxCjUP1NKR4dNyyHhaZWSGRTbGzBnm1vwgwpoe2AVGQ  

FAQs

1. Why does a public key generate two addresses?

Bitcoin supports compressed and uncompressed public keys, each yielding a unique address.

πŸ‘‰ Explore Bitcoin wallet security tips

2. How is a private key securely generated?

Use a CSPRNG with high entropy (e.g., hardware RNG or /dev/urandom). Avoid simple patterns.

3. What’s the difference between Base58 and Base64?

Base58 excludes ambiguous characters (0, O, I, l, +, /) for better human readability.

4. Can two private keys generate the same address?

No. The ECC algorithm ensures a 1:1 mapping between private keys and public keys.


References