Public-key cryptography: how to communicate secretly with someone you have never met
The idea of public-key cryptography explained clearly: public and private keys, one-way functions, digital signatures, certificates, the secret British history, attacks and today’s uses.
For millennia cryptography had a rule that seemed like a law of nature: to communicate secretly you must first share a secret. Sender and recipient had to meet, or trust a courier, to exchange the key. In 1976 two American researchers published an idea that overturned this rule: you can communicate secretly with anyone, using a key that everyone can know.
This is public-key cryptography, also called asymmetric cryptography. Everyone has two mathematically linked keys: a public one, to be distributed freely, and a private one, to be kept safe. What is encrypted with the public key can only be opened with the private key; what is signed with the private key is verified with the public key. Without this idea there would be no e-commerce, digital signatures, HTTPS websites or encrypted messaging apps.
What it makes possible
- Confidentiality
- Anyone can encrypt a message for you with your public key; only you can read it.
- Signature
- You can sign a document with your private key; anyone can verify that it is yours and intact.
- Key agreement
- Two people can agree on a secret key while communicating only in public.
- Authentication
- You can prove you hold a private key without ever revealing it, as passkeys do.
The best-known algorithms are RSA, Diffie-Hellman key exchange and elliptic curves; their most widespread application is the digital signature.
The pages of this topic
Public-key cryptography: how it works
The open padlock as a metaphor, encryption with the public key, signing with the private key and hybrid cryptography.
Public-key cryptography: history
From the secret insights of Britain’s GCHQ to Diffie and Hellman’s paper, from RSA to elliptic curves and certificate infrastructures.
Public-key cryptography: the maths
Trapdoor one-way functions: multiplication and factoring, modular exponentiation and the discrete logarithm.
Public-key cryptography: worked example
A digital signature with small numbers, using the example RSA keys, to see how private and public keys work together.
Public-key cryptography: weaknesses and attacks
The man-in-the-middle attack, weak keys, side channels and the quantum threat: where public-key cryptography can fail.
Public-key cryptography today
Where public-key cryptography is used every day: HTTPS, digital signatures, messaging, passkeys, cryptocurrencies, software updates.
Public-key cryptography: try it yourself
Exercises on modular exponentiation, one-wayness and verifying a signature, with solutions.
Public-key cryptography: frequently asked questions
Short answers to the most common doubts about public-key cryptography.