Introduction to P2PKH (Pay-to-Public-Key-Hash)

Overview

P2PKH (Pay-to-Public-Key-Hash) is the original Bitcoin address format introduced by Satoshi Nakamoto. These addresses begin with 1 on mainnet and remain widely supported across all Bitcoin wallets and exchanges. Despite the introduction of newer address formats, P2PKH continues to be used for its broad compatibility.

How It Works

P2PKH addresses are derived from a public key through a series of cryptographic operations:

P2PKH Address Anatomy Public Key Hash Generation Public Key 33 bytes (compressed) or 65 bytes SHA-256 RIPEMD160 Public Key Hash (HASH160) 20 bytes Checksum Generation Version 0x00 + PubKey Hash 20 bytes Version + PubKey Hash (21 bytes) SHA256(SHA256(...)) Checksum First 4 bytes Version 1 byte Public Key Hash (HASH160) 20 bytes Checksum 4 bytes 25 bytes total Base58Check Encode P2PKH Address 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2
  1. Generate a public key from the private key using elliptic curve multiplication.
  2. Apply SHA-256 hashing to the public key.
  3. Apply RIPEMD-160 hashing to the SHA-256 result, producing a 160-bit hash (20 bytes).
  4. Add a version byte prefix (0x00 for mainnet, 0x6F for testnet).
  5. Calculate a checksum using double SHA-256 and append the first 4 bytes.
  6. Encode the result using Base58Check encoding.
Info

This process produces a shorter, more user-friendly address while adding an extra layer of security by not exposing the raw public key until funds are spent.

Security Considerations

P2PKH provides security through public key hashing. The public key is only revealed when spending funds, not when receiving them. This offers some protection against potential future attacks on elliptic curve cryptography, as the public key remains hidden until a transaction is signed.

However, once funds are spent from a P2PKH address, the public key is exposed on the blockchain. Reusing addresses after spending reduces security, as the public key becomes permanently visible. For this reason, generating a new address for each transaction is recommended.

Address Format

P2PKH addresses are identifiable by their prefix:

  • Mainnet: Addresses start with 1
  • Testnet: Addresses start with m or n
  • Regtest: Addresses start with m or n

The Base58Check encoding excludes visually ambiguous characters (0, O, I, l) to reduce transcription errors.