Skip to content
Field Atlas

Atlas / Mathematics / The Number Theory Thread

Field · Emerged 1976 – 1985

Public-Key Cryptography

How can two strangers communicate in secret without ever having shared a secret key?

5 chapters4 min read6 turning points2 open problems

Branched from
Elementary Number Theory + Arithmetic Geometry + Computational Complexity
Branched into
Not yet surveyed past here
Figures
Whitfield Diffie, Martin Hellman, Ralph Merkle, James Ellis, Ron Rivest, Adi Shamir, Leonard Adleman, Clifford Cocks, Neal Koblitz, Victor Miller, Peter Shor, Manindra Agrawal

In brief

For most of history, secret messages required a secret key shared in advance. Public-key cryptography removed that requirement. Everyone publishes a key that anyone can use to lock a message, and only the holder of a matching private key can unlock it. The same idea yields digital signatures, which prove who sent a message.

It rests on number theory. Some operations, like multiplying two large primes, are easy, while reversing them, factoring the product, seems practically impossible. Centuries-old theorems of Fermat and Euler, and the elliptic curves of arithmetic geometry, now secure nearly every connection on the internet. A quantum computer would break them, which is why the field is being rebuilt now.

Key ideas

Public and private keysEnters 1976

A key pair: the public key locks (or verifies), the private key unlocks (or signs). Publishing the public key does not reveal the private one.

Trapdoor one-way functionEnters 1977

Easy to compute, infeasible to invert, unless you know a secret "trapdoor". RSA uses multiplication of primes, where the trapdoor is knowing the factors.

RSAEnters 1977

Choose primes p,qp, q and publish n=pqn = pq with an exponent ee. Encrypt mm as c=me mod nc = m^e \bmod n. Decryption works because of Euler's generalisation of Fermat's little theorem, and computing the decryption key requires factoring nn.

Discrete logarithmEnters 1985

Given gg and gxg^x in a finite group, find xx. Easy one way, apparently hard in reverse. Diffie–Hellman and elliptic-curve cryptography rest on it.

Post-quantum cryptographyEnters 2016 – 2024

Public-key systems built on problems, mostly about lattices, that no known quantum algorithm solves efficiently.

Draws on other domains

Chapter I

The Key Distribution Problem

Every cipher in history had the same weakness. Sender and receiver needed the same secret key, and they had to share it somehow beforehand, by courier, diplomatic bag or codebook. In a world of millions of strangers exchanging data, that was impossible.

In 1976 Whitfield Diffie and Martin Hellman showed it was unnecessary. Take a large prime pp and a base gg. Alice picks a secret aa and sends ga mod pg^a \bmod p; Bob picks bb and sends gb mod pg^b \bmod p. Each raises what they received to their own secret, and both arrive at gab mod pg^{ab} \bmod p. An eavesdropper sees only gag^a and gbg^b, and recovering aa from gag^a, a discrete logarithm, has no known fast method. The arithmetic is from elementary number theory. The idea was new.

Chapter II

RSA

A year later, three MIT researchers, Ron Rivest, Adi Shamir and Leonard Adleman, found a full public-key cipher. Publish n=pqn = pq, the product of two large secret primes, and an exponent ee. Anyone can encrypt a message mm as me mod nm^e \bmod n. Undoing it needs an exponent dd that can be computed only by someone who knows pp and qq, and it works because of Euler's generalisation of Fermat's little theorem: a 1640 curiosity turned into the lock on the world's data.

The story had a secret prologue. At Britain's signals intelligence agency GCHQ, James Ellis had conceived of "non-secret encryption" in 1970. Clifford Cocks found essentially RSA in 1973, and Malcolm Williamson found Diffie–Hellman in 1974. All of it stayed classified until 1997.

Chapter III

Curves and Primes

In 1985 Neal Koblitz and Victor Miller independently proposed moving the discrete logarithm into the group of points on an elliptic curve, the central object of arithmetic geometry. No known shortcut works there, so a 256-bit elliptic-curve key matches a roughly 3,000-bit RSA key. Elliptic curves, studied for their own beauty since Mordell, now carry most secure web traffic.

Cryptography also needs a plentiful supply of large primes, and a fast way to recognise them. In 2002 Manindra Agrawal and his students Neeraj Kayal and Nitin Saxena proved that primality can be decided in guaranteed polynomial time, using a generalisation of Fermat's little theorem. Gauss had called telling primes from composites one of the most important problems in arithmetic, in the Disquisitiones.

Chapter IV

A Closer Look: RSA and Diffie–Hellman with Small Numbers

Real keys use numbers hundreds of digits long, but the mechanics fit on a napkin.

RSA. Choose two primes, p=5p = 5 and q=11q = 11, and publish n=55n = 55. Compute (p−1)(q−1)=40(p - 1)(q - 1) = 40 and choose a public exponent sharing no factor with 40, say e=3e = 3. The private exponent is the dd with 3d≡1(mod40)3d \equiv 1 \pmod{40}: d=27d = 27, since 3×27=81=2×40+13 \times 27 = 81 = 2 \times 40 + 1. The public key is (55,3)(55, 3), and the private key is 2727.

To send the message m=7m = 7, anyone computes

c=73 mod 55=343 mod 55=13.c = 7^3 \bmod 55 = 343 \bmod 55 = 13 .

The key holder recovers it: 1327 mod 55=713^{27} \bmod 55 = 7. It works because of Euler's version of Fermat's little theorem, and finding dd requires knowing (p−1)(q−1)(p-1)(q-1), which requires factoring nn. Factoring 55 is trivial. Factoring a product of two 300-digit primes is, as far as anyone knows, infeasible.

Diffie–Hellman. Alice and Bob agree in public on a prime p=23p = 23 and a base g=5g = 5. Alice secretly picks a=6a = 6 and sends 56 mod 23=85^6 \bmod 23 = 8. Bob secretly picks b=15b = 15 and sends 515 mod 23=195^{15} \bmod 23 = 19. Each raises what they received to their own secret:

196 mod 23=2,815 mod 23=2.19^6 \bmod 23 = 2, \qquad 8^{15} \bmod 23 = 2 .

Both now hold the shared secret 2, which never crossed the wire. An eavesdropper who saw 23, 5, 8 and 19 must recover 6 from 5a≡85^a \equiv 8, a discrete logarithm. With a 2048-bit prime, or on an elliptic curve, no efficient classical method is known. Shor's quantum algorithm would find it quickly, which is why both systems are being replaced.

Chapter V

The Quantum Threat

In 1994 Peter Shor showed that a quantum computer could factor numbers and compute discrete logarithms efficiently. RSA, Diffie–Hellman and elliptic curves would all fall. No machine is yet large enough, but data intercepted now could be read later, so the replacement has already begun. In 2024 the US standards body published its first post-quantum standards, most of them built on hard problems in lattices over rings of algebraic integers.

Beneath it all lies an unproved assumption. Every public-key system presumes that some problems are genuinely hard, that one-way functions exist, and no one has proved it. That question belongs to computational complexity, where it sits beside P versus NP. The security of the digital world rests, in the end, on a conjecture.

Applications

Where it is used

  • The web

    Every HTTPS connection

    When a browser connects securely, it agrees a fresh key with the server using elliptic-curve Diffie–Hellman and checks the server's identity through a chain of digital signatures. Increasingly a post-quantum key exchange is combined with it.

    › Sources (1)
  • Software and identity

    Digital signatures

    Operating-system updates, app stores, electronic passports and legally binding e-signatures are verified with public-key signatures, so tampering is detectable by anyone.

    › Sources (1)
    • National Institute of Standards and Technology (2023). FIPS 186-5: Digital Signature Standard (DSS).
  • Finance

    Cryptocurrencies

    Bitcoin ownership is nothing but control of a private key. Transactions are authorised with elliptic-curve signatures on the curve secp256k1.

    › Sources (1)
    • Nakamoto, S. (2008). Bitcoin: A Peer-to-Peer Electronic Cash System.

Open problems

Where the map runs out

Conjectured, unproven

Do one-way functions exist?

Unproven as of 2026; would imply P ≠ NP.

All of public-key cryptography assumes that some functions are easy to compute but infeasible to invert, and that factoring and discrete logarithms are among them. No one has proved that any such function exists.

Why it is hard

Proving a problem is hard means ruling out every possible algorithm, including ones no one has imagined. That is at least as hard as proving P ≠ NP, the central open problem of computer science. Several known proof techniques are provably too weak.

What resolving it unlocks

A proof would put cryptography on a guaranteed foundation. Its failure, meaning a fast factoring algorithm, would break much of today's security overnight.

› Sources (1)
  • Cook, S. (2006). The P versus NP problem. In J. Carlson, A. Jaffe & A. Wiles (eds.), The Millennium Prize Problems: 87–104. Clay Mathematics Institute / AMS.

Open

Are lattice problems truly quantum-hard?

Open as of 2026; the new standards assume so.

Post-quantum cryptography assumes that finding short vectors in high-dimensional lattices, and related "learning with errors" problems, stay hard even for quantum computers. Decades of attacks support the assumption, but it is not proven.

Why it is hard

Regev showed in 2005 that breaking learning-with-errors would solve worst-case lattice problems, a strong guarantee. But the practical schemes use structured lattices from number rings, whose extra algebraic structure might, in principle, be exploited. Every new quantum algorithm is scrutinised for exactly that.

What resolving it unlocks

Confidence that the replacement for RSA and elliptic curves will last.

› Sources (1)
  • Regev, O. (2009). On lattices, learning with errors, random linear codes, and cryptography. Journal of the ACM 56(6): 34.

Further reading

  1. Singh, S. (1999). The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography. Doubleday.

    A popular history of codes, ending with public-key cryptography and its secret British prehistory.

  2. Levy, S. (2001). Crypto: How the Code Rebels Beat the Government. Viking.

    The story of Diffie, Hellman, RSA and the fight over public cryptography.

  3. Hoffstein, J., Pipher, J. & Silverman, J. H. (2014). An Introduction to Mathematical Cryptography (2nd ed.). Springer.

    An undergraduate textbook covering RSA, elliptic curves and lattice-based systems.