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:
- Generate a public key from the private key using elliptic curve multiplication.
- Apply SHA-256 hashing to the public key.
- Apply RIPEMD-160 hashing to the SHA-256 result, producing a 160-bit hash (20 bytes).
- Add a version byte prefix (0x00 for mainnet, 0x6F for testnet).
- Calculate a checksum using double SHA-256 and append the first 4 bytes.
- Encode the result using Base58Check encoding.
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.