Signal Review

How public-key encryption works: a lock anyone can close and only one person can open

From Diffie and Hellman's 1976 paper to the padlock in the browser, without the algebra

September 26, 2026 4 min read

Before 1976 two parties could only exchange secret messages if they had first exchanged a secret key. Public-key cryptography broke that rule, and it now underlies every secure website, software update and encrypted message. This is what the two keys do and why one cannot be derived from the other.

Public-key cryptography is a way of encrypting messages in which the key used to lock a message is different from the key used to unlock it. One key, the public key, can be handed to anyone; the other, the private key, is kept by its owner alone. Anything encrypted with the public key can be decrypted only with the private key.

The idea was published by Whitfield Diffie and Martin Hellman in November 1976 in the paper *New Directions in Cryptography*, and the first practical scheme, RSA, by Ron Rivest, Adi Shamir and Leonard Adleman, followed in 1977 and appeared in the *Communications of the ACM* in 1978.

The problem it solved

Every cipher before it was symmetric: the same key encrypted and decrypted, so two parties had to agree on a secret before they could communicate, and that agreement itself needed a secure channel, a courier, a sealed envelope, a meeting. For a bank with a few branches that was manageable. For a network in which any machine may need to speak to any other, it is impossible: the number of pairwise secrets grows with the square of the number of parties, and none of them can be sent over the network they are meant to protect.

Diffie and Hellman's insight was that a secure channel is not needed if the locking key does not need to be secret. A shop can publish its public key on a sign; a customer encrypts a message with it and sends it in the open; only the shop, holding the private key, can read it. The scheme works if and only if the private key cannot be computed from the public key in any practical time.

Why can't the private key be worked out from the public key?

That property comes from trapdoor one-way functions: operations that are easy to perform in one direction and, as far as anyone knows, infeasible to reverse without a secret. In RSA the operation is multiplication. Multiplying two large prime numbers is quick; recovering them from the product, factoring, is not. The public key contains the product; the private key is built from the two primes. The record for factoring an RSA-type number by general methods, RSA-250, a 250-digit number, took the equivalent of about 2,700 core-years of computing in 2020, according to the team that announced it; keys in use today are 2,048 bits long, some 617 digits, and far beyond that.

Signatures, and the padlock

The two keys can also be used the other way round. A message transformed with the private key can be checked with the public key, and since only the owner could have produced it, the transformation is a digital signature. This is what a browser verifies when it shows a padlock: the site presents a certificate, signed by a certificate authority, binding its name to its public key; the browser checks the signature with the authority's public key, which it already holds.

In practice public-key operations are slow, thousands of times slower than a symmetric cipher, so they are used only at the start. In the TLS protocol that secures the web, the two sides use public-key methods to agree on a fresh symmetric key and then encrypt the actual traffic with it. TLS 1.3, RFC 8446, does this with an elliptic-curve Diffie-Hellman exchange in a single round trip.

Frequently asked questions

What is the difference between a public key and a private key?

The public key can be handed to anyone and locks a message; the private key is kept by its owner alone and is the only key that can unlock what the public key encrypted. Used the other way round, the private key produces signatures that the public key can check.

Why can't the private key be calculated from the public key?

The schemes rest on trapdoor one-way functions, easy to compute in one direction and, as far as anyone knows, infeasible to reverse without a secret. In RSA the public key contains the product of two large primes, the private key is built from the primes, and factoring a 2,048-bit product is far beyond reach.

What does the padlock in a browser actually check?

The site presents a certificate, signed by a certificate authority, that binds its name to its public key. The browser checks that digital signature with the authority's public key, which it already holds.

Why are symmetric ciphers still used alongside public-key methods?

Public-key operations are thousands of times slower than a symmetric cipher, so they are used only at the start. In TLS the two sides use public-key methods to agree on a fresh symmetric key and then encrypt the actual traffic with it.