Overview
A public key in Bitcoin is a point on the secp256k1 elliptic curve, derived from a private key through elliptic curve point multiplication. This mathematical operation is a one-way function: given a private key, anyone can compute the corresponding public key, but deriving the private key from a public key is computationally infeasible. Public keys serve as the foundation for Bitcoin addresses and digital signatures.
How Public Keys Are Derived
Key Derivation:
Private Key (256-bit number)
│
▼
Elliptic Curve Multiplication
(point multiplication on secp256k1)
│
▼
Public Key (point on the curve)
│
├──> Compressed: 33 bytes (02 or 03 prefix + x-coordinate)
│ Example: 02b4632d08485ff1...
│
└──> Uncompressed: 65 bytes (04 prefix + x + y coordinates)
Example: 04b4632d08485ff1...
│
▼
Hash (HASH160 = RIPEMD160(SHA256(pubkey)))
│
▼
Bitcoin Address
Compressed vs. Uncompressed
Modern Bitcoin software exclusively uses compressed public keys (33 bytes) rather than uncompressed keys (65 bytes). Since the y-coordinate of a point on the elliptic curve can be calculated from the x-coordinate (with a parity bit), the compressed format stores only the x-coordinate with a prefix byte indicating whether y is even (02) or odd (03). This saves space in transactions and reduces fees.
Role in Transaction Verification
When someone spends bitcoin, they provide a signature and their public key. Every node on the network uses the public key to verify that the signature is valid and that the public key hashes to the address the funds were locked to. This verification process ensures that only the holder of the corresponding private key could have authorized the spend.
Public Key Exposure
In P2PKH and P2WPKH transactions, the public key is hashed to create the address. The actual public key is only revealed when the output is spent. This provides a theoretical layer of quantum resistance for unspent outputs, since an attacker with a quantum computer would need to derive the private key from the public key, which is only exposed at spend time.
Common Misconception
A public key is not the same as a Bitcoin address. The address is derived from the public key through one or more hashing steps. While a public key can be safely shared, Bitcoin best practice is to share addresses instead, as addresses are shorter, include error-detection checksums, and keep the public key hidden until spending time.