Cryptography

Private & public keys

Public-key cryptography is the idea that lets you own Bitcoin. You have two linked keys: a private key you keep utterly secret, and a public key you can hand to the world. What one locks, only the other can unlock — and you can’t work the secret one out from the public one.

A secret and a name

  • Private key — a gigantic random number that only you know. It’s the master key to your money. Whoever holds it controls the funds; lose it and they’re gone forever.
  • Public key — derived from the private key by a one-way calculation. You can publish it freely. Your Bitcoin address is essentially a public key; it’s how people send you money.

The one-way link is everything. Deriving the public key from the private key is easy. Reversing it — recovering the private key from the public key — is, as far as anyone knows, impossible, even with all the world’s computers. That asymmetry is a trapdoor, and it’s built from the elliptic-curve maths in the last lesson of this section.

Make a real key pair

This isn’t a toy. The box below runs the exact calculation Bitcoin uses: it takes your private key — just a huge number — and derives the matching public key by “multiplying” a fixed starting point on the secp256k1 elliptic curve. Type a key, hit Random for a fresh one, or nudge it with +1 and watch the public key scramble completely. The forward step is instant; going backwards (public → private) is the discrete-logarithm problem, and nobody on Earth can do it.

Public key — X coordinate
Public key — Y coordinate
Compressed public key — what Bitcoin actually stores

A lock with two different keys

Ordinary locks use one key to lock and unlock. Public-key crypto uses a matched pair that work in opposite directions:

  • Anyone can lock a message with your PUBLIC key, and only your PRIVATE key can open it — that’s encryption (sending you a secret).
  • With your PRIVATE key you can produce a signature on a message that anyone can check against your PUBLIC key — proving it came from you, without the key ever leaving your hands. That’s a digital signature, and it’s the part Bitcoin actually uses. (Signing isn’t “encrypting with the private key” — it’s its own operation; Bitcoin signs, it doesn’t encrypt.)

Not your keys, not your coins

This is the deepest break from every money system in the History section. There, your money lived in someone else’s ledger and you trusted them to honour it. With keys, ownership is just knowledge: hold the private key and you can move the coins yourself, with no bank’s permission. That’s what “self-custody” means — and why the phrase “not your keys, not your coins” is a warning about letting an exchange hold your private keys for you.

Owning a key is one thing; using it to authorise a specific payment without ever revealing it is another. That’s the job of a digital signature — next.

Key takeaways

  • Public-key cryptography gives you a private key you keep secret and a public key you share freely — and you can’t work the private one out from the public one.
  • Your address comes from your public key; your private key authorises spending. ‘Not your keys, not your coins.’

Check yourself

What can someone do with only your PUBLIC key?

What does ‘not your keys, not your coins’ warn against?

Spotted an error or have feedback on this lesson? Suggest a correction ↗

Comments

Powered by Nostr — reply from any Nostr client, and zap the lesson over Lightning.