The Secret You Can Shout From a Rooftop
Imagine handing a stranger a locked box with an open slot on top. Anyone walking by can drop a letter in and seal it shut, but only you, holding the one matching key, can open the box and read it. That is the strange trick behind public-key cryptography: two total strangers, who have never met or exchanged a secret, can still communicate in total privacy while the whole world watches.
Every person using this system holds two keys instead of one. The public key can be handed to anyone, printed on a business card, or posted online. The private key never leaves its owner. A journalist can publish their public key so any anonymous source can send an encrypted tip, yet only the journalist, holding the private key, can unlock it.
The genius lies in a math trick called a one-way function: something painfully easy to do in one direction and nearly impossible to undo in the other.
Britain's Twenty-Five-Year Secret
Here is the part that sounds like fiction: public-key cryptography was invented once, kept secret, then invented again from scratch. In 1970, a British intelligence mathematician named James H. Ellis dreamed up the idea of "non-secret encryption" while working for GCHQ, but he could not figure out how to actually build it.
Three years later, in 1973, his colleague Clifford Cocks quietly worked out what we now call RSA encryption. In 1974, another colleague, Malcolm J. Williamson, independently developed the equivalent of the Diffie-Hellman key exchange. None of it was published. Britain classified the whole discovery.
Meanwhile, working with none of that knowledge, American researchers reached the same destination in public: Whitfield Diffie and Martin Hellman published their key exchange in 1976, and Ron Rivest, Adi Shamir, and Leonard Adleman published RSA in 1978. The public did not learn Britain got there first until declassification in 1997.
The Math Problem Even Computers Struggle With
Multiplying two enormous prime numbers together takes a computer a fraction of a second. Taking that giant product and working backward to find the original two primes can take an unimaginably long time. That lopsided difficulty is exactly what RSA, one of the most widely used public-key algorithms, is built on.
This kind of one-way math problem is not new. In 1874, mathematician William Stanley Jevons casually asked his readers which two numbers multiply together to make 8,616,460,799, describing the exact idea behind modern encryption decades before the first computer existed.
Other systems lean on different hard problems entirely, including the Diffie-Hellman key exchange and elliptic curve cryptography, but the underlying bet is always the same: forward math is trivial, backward math is brutal.
Two Keys, Two Very Different Jobs
Public-key cryptography actually does two separate jobs, and it is easy to mix them up. The first is encryption: anyone holding a public key can scramble a message into unreadable ciphertext, but only the private key can turn it back into words. The second is the digital signature: the private key stamps a message, and anyone with the matching public key can confirm it is genuine, without ever being able to forge one themselves.
Because this asymmetric math is computationally heavy, almost nothing uses it alone. Everyday tools like PGP, SSH, and the padlock icon in your browser, powered by TLS, use public-key cryptography just long enough to safely hand over a lighter-weight symmetric key. From there, the faster symmetric key does the heavy lifting for the rest of the conversation.
The Weak Link Was Never the Math
Breaking the underlying math of public-key cryptography by brute force is theoretically possible but practically hopeless, even accounting for known shortcuts against RSA. Attackers rarely bother trying. Instead, they go after the handshake itself: a man-in-the-middle attack intercepts a public key mid-transmission and swaps in a fake one, tricking both sides into encrypting messages for an eavesdropper instead of each other.
To stop this, the internet leans on certificate authorities that vouch for who owns which public key, forming a system called Public Key Infrastructure. But that trust chain has its own weak point: if a certificate authority itself gets compromised, attackers can mint convincing fake certificates.
Even flawless encryption has a blind spot: it hides what a message says, but not who sent it, when, or how long it was.
A Countdown Called Quantum
Public-key cryptography has quietly secured the internet for decades, but its expiration date may already be visible on the horizon. Quantum computers, once powerful enough, are expected to make short work of the very math problems that RSA and Diffie-Hellman rely on, the kind that ordinary computers would need eons to solve.
Cryptographers are not waiting around. Newer, quantum-resistant algorithms like Kyber are already being developed, designed to keep the same trick, strangers agreeing on a secret in plain sight, working even after quantum computers arrive.
It is a strange race: the same open mathematical curiosity that quietly protects nearly every secure website today might need to reinvent itself before the next great leap in computing arrives.
