Public-Key Cryptography

Two total strangers can agree on a secret code out in the open, with the whole world watching, and cracking it is nearly impossible — that is the strange trick quietly guarding almost every secure website you visit. Even stranger: British spies solved it first, then buried it as a secret for over two decades.

5 min read · 10 key facts · 18 terms decoded

Illustration for Public-Key Cryptography

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.

Key terms, decoded

certificate authority
An organization trusted to confirm that a public key really belongs to the person or website it claims to belong to.
ciphertext
A message that has been scrambled by encryption so it looks like random nonsense until it is unlocked again.
Diffie-Hellman key exchange
A method that lets two people agree on a shared secret code over an open, watched connection without ever sending the secret itself.
digital signature
A stamp created with a private key that proves a message truly came from a specific person and was not changed along the way.
elliptic curve cryptography
A method of locking and unlocking messages built on a different hard math problem than RSA, often using shorter keys for the same level of security.
Kyber
A newer encryption method designed to stay secure even after powerful quantum computers exist.
man-in-the-middle attack
A trick where someone secretly intercepts and swaps messages between two people who believe they are talking directly to each other.
one-way function
A math process that is quick and easy to do in one direction but takes an enormous amount of time and computing power to undo.
PGP
A software tool that lets people encrypt emails and files so only the intended recipient can read them.
prime number
A whole number greater than 1 that can only be evenly divided by itself and 1.
private key
A secret code that only its owner keeps, used to unlock messages locked with the matching public key, or to prove a message really came from them.
public key
A code that a person shares openly with everyone, used to lock up a message so only the matching private key can unlock it.
Public Key Infrastructure
The overall system of certificate authorities and rules that lets people trust which public key belongs to whom.
quantum computer
A powerful new kind of computer that solves certain math problems far faster than any computer used today.
RSA
A widely used method for locking and unlocking messages that relies on how hard it is to find the two prime numbers that were multiplied together to make a huge number.
SSH
A method for securely connecting to and controlling another computer over the internet.
symmetric key
A single shared secret code that both sides of a conversation use to both lock and unlock messages.
TLS
The technology behind the padlock icon in a web browser that keeps information private as it travels between a device and a website.

This Quicky is an original summary based on the Wikipedia article “Public-key cryptography”, available under the CC BY-SA 4.0 license.