Private key, public key, address: what is the difference?
Every Bitcoin wallet rests on three things that are easy to confuse: the private key, the public key and the address. Each is computed from the previous one, and every step works in one direction only.
Private key: a secret number
The private key is simply a number between 1 and about 1.16·1077, chosen at random. Whoever knows it can spend the coins. These are the numbers this site lists, 100 per page, written in WIF. The first one, k = 1, is 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf.
Public key: a point on a curve
The public key is computed from the private key by multiplication on the elliptic curve secp256k1: the curve’s fixed starting point G is “multiplied” by the private number. The result is another point on the curve, written in 33 bytes (compressed) or 65 bytes (uncompressed). For k = 1 the public key is G itself: 0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798.
Going forward takes a computer a fraction of a millisecond. Going back, from the point to the private number, is the elliptic-curve discrete logarithm problem, and the best known method needs about 2128 steps (see can someone guess my private key). All of Bitcoin’s security rests on this one-way street.
Address: a fingerprint of the public key
A classic address is a fingerprint of the public key: SHA-256 followed by RIPEMD-160, which gives 20 bytes (160 bits). A version byte and a checksum are added and the result is written in Base58. That is why addresses are shorter than public keys and why a mistyped address is almost always rejected. For k = 1 the fingerprint of the compressed public key gives 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH.
A fingerprint also works in one direction only: from an address you cannot get the public key, let alone the private key. That has a useful side effect: until you spend from an address for the first time, nobody but you even knows its public key.
One key, many addresses
The same private key can control several different addresses, depending on how the public key is written and which address type the wallet uses:
- 1… (P2PKH), the oldest type, from the compressed or the uncompressed public key. For k = 1 these are two different addresses:
1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMHand1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm. - 3… (P2SH), the address of a script, used among others by multi-signature wallets and early SegWit wallets.
- bc1q… (SegWit, P2WPKH), the same 20-byte fingerprint in a newer format. For k = 1 it is
bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4, the example address from the standard that introduced the format (BIP173). - bc1p… (Taproot), which contains a (slightly modified) public key directly instead of its fingerprint.
Our catalog shows one address per key: the 1… address of the compressed public key. The note under the table says so; the other addresses of the same key are not checked.
What happens when you spend
To spend coins from an address, your wallet publishes the public key and a digital signature made with the private key. Anyone can check that the signature matches the public key and that the public key matches the address, but nobody learns the private key from it. A signature proves that you know the key without revealing it.
Two practical consequences:
- After the first spend, the public key of that address is public for good. That does not help today’s attackers, but it is one reason not to reuse addresses (see quantum computers and Bitcoin), and reuse also hurts your privacy.
- Modern wallets generate a fresh address for every payment, all derived from one seed phrase.
In short
- Private key: a secret number. Never show it to anyone.
- Public key: computed from the private key; revealed when you spend.
- Address: a fingerprint of the public key. You can share it freely; it is what you give to someone who wants to pay you.