Heads up: posts on this site are drafted by Claude and fact-checked by Codex. Both can still get things wrong — read with care and verify anything load-bearing before relying on it.
why how

What is public-key cryptography?

Until 1976, encrypting a message required both sides to already share a secret. Public-key crypto broke that chicken-and-egg problem and quietly became the substrate of the modern internet.

Security intro Apr 30, 2026

Why it exists

For most of cryptography’s history, “encrypt a message” meant: pick a key, share it with the other party through some out-of-band channel (a courier, a codebook, a face-to-face meeting), and use that same key on both ends. This is symmetric crypto, and it has a built-in problem the moment your partner is someone you’ve never met: you can’t share a secret over a channel that requires already sharing a secret. Diffie and Hellman named this directly in their 1976 paper New Directions in Cryptography, and proposed the first construction that escapes it. The following year, Rivest, Shamir, and Adleman published RSA (paper in 1978), which added the second half of the picture: digital signatures. Together those two results invented asymmetric crypto.

Why it matters now

Almost every secure thing your computer does today rides on it: every TLS handshake your browser performs, every SSH session, every signed software package (apt, container images, model checkpoints), every passkey login, every Git commit signed by a maintainer, every CA stamp on a domain. If asymmetric crypto vanished overnight the public internet would stop working. It is the layer underneath the layer most engineers think about.

The short answer

public-key crypto = a key pair (public, private) + math designed so the public key can encrypt-to or verify, but only the private key can decrypt or sign

You generate two keys at once, mathematically linked. One you publish; one you guard. The two halves play different roles:

That asymmetry is the whole trick. The companion post signatures vs encryption explains why those operations are not the same primitive run in opposite directions; here we’ll take the conceptual shape as given.

How it works

You don’t need the number theory to use this, but you need the right metaphor. The one that survives contact with reality is the trapdoor function: easy to compute forward, infeasibly hard to invert — unless you know a particular secret (the private key), in which case inverting is easy too.

Two families dominate:

The detail almost everyone gets wrong on first encounter: public-key crypto is almost never used to encrypt the actual data. It’s slow, and the math has sharp edges on large or structured inputs. Real systems use hybrid encryption: generate a fresh symmetric key, encrypt the bulk payload with that (AES-GCM or similar), and use public-key crypto only to encrypt — or, more commonly, agree on — that symmetric key. TLS works exactly this way.

Show the seams

Going deeper