everykey.exposed
EN

Learn

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:

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:

In short

Start at page 1All articles