The one-sentence version
Take a key that is truly random, as long as the message and used only once, and XOR it with the message bit by bit (or add it letter by letter). The resulting ciphertext reveals no information at all to anyone, including someone with unlimited computing power. The reason: adding a uniformly random element in a group gives a result that is still uniformly random. Shannon proved this in 1949, and also proved the cost: the key must be at least as long as the message.
This article has three layers:
- The intuition: why "anything is possible" means "you know nothing"
- Real-world use: the Washington–Moscow hotline, the Venona project and why modern encryption doesn't use it
- The mathematics: the definition and proof of perfect secrecy, the lower bound on key length, the collapse of the two-time pad and a worked example
Layer 1: The Intuition
1.1 Encryption by addition
Turn letters into numbers (A=0, B=1, …, Z=25), and add each plaintext letter to the key letter at the same position, modulo 26:
| H | E | L | L | O | |
|---|---|---|---|---|---|
| Plaintext | 7 | 4 | 11 | 11 | 14 |
| Key X M C K L | 23 | 12 | 2 | 10 | 11 |
| Sum mod 26 | 4 | 16 | 13 | 21 | 25 |
| Ciphertext | E | Q | N | V | Z |
Decryption just subtracts it back. Computers usually work in binary, where "adding" is XOR.
1.2 Why it can't be broken
Someone holding the ciphertext EQNVZ can try any 5-letter key:
- Key XMCKL → plaintext HELLO
- Key TQURI → plaintext LATER
- Key RCRVB → plaintext NOWAY
Every 5-letter word corresponds to exactly one key. The key was chosen completely at random, so every plaintext is equally possible. No amount of computing power helps: the problem isn't "it can't be computed" but "the answer simply isn't determined".
1.3 All three conditions are required
- Truly random: it can't be pseudorandom, or an attacker can go after the generator;
- As long as the message: the key can't be cycled;
- Used only once: using it twice brings the whole thing down (see sections 2.2 and 3.4).
Layer 2: Real-World Use
2.1 Real uses
- 1917: Vernam at AT&T invented XOR encryption on the teleprinter; Mauborgne then proposed that the key must be random and used only once.
- The Cold War hotline: the Washington–Moscow hotline, set up in 1963 after the Cuban Missile Crisis, was initially encrypted with one-time paper tape.
- Spy codebooks: agents carried small notebooks full of random digits, tearing off each page after use (which is how the name "one-time pad" came about).
2.2 The Venona project: used twice and it's over
During World War II, under wartime production pressure, the Soviet Union printed some codebook pages more than once. The US Army's Venona project (1943–1980) exploited these reused keys to decrypt thousands of Soviet intelligence cables, exposing spies in the Manhattan Project (such as Klaus Fuchs and the Rosenbergs).
2.3 Why modern encryption doesn't use it
| Problem | Explanation |
|---|---|
| The key is too long | Encrypting a 1 GB video takes 1 GB of truly random key, which must be delivered to the other side securely and in advance |
| Key distribution | If you can securely deliver a 1 GB key, why not just deliver the message? |
| Secrecy only, no tamper protection | An attacker who flips a ciphertext bit flips the matching plaintext bit (malleability), and it goes undetected |
So in practice we use stream ciphers (ChaCha20, AES-CTR): a short key generates a long, "random-looking" keystream, which is then XORed in. Security drops from "information-theoretic" to "computational", in exchange for practicality. See "Linear Feedback Shift Registers".
Quantum key distribution (QKD)
The selling point of QKD is "distributing long keys securely by the laws of physics", which can then be paired with a one-time pad for information-theoretic security. But it needs dedicated fiber or satellites, and both range and rate are limited.
Layer 3: The Mathematics
3.1 The definition of perfect secrecy
Shannon's definition: for any plaintext distribution, any plaintext and any ciphertext ,
Seeing the ciphertext changes nothing at all about what you believe of the plaintext. Equivalently, the distribution of the ciphertext doesn't depend on the plaintext.
3.2 The proof: translation in a group
Let messages, keys and ciphertexts all live in a finite group (such as or ), with the key uniformly random on , independent of , and .
For any , there is exactly one key with . Therefore
which doesn't depend on . Perfect secrecy follows from Bayes' rule.
In abstract algebra terms: for each fixed , the translation is a bijection from to itself, and a uniform distribution stays uniform under a bijection.
This proof works for any finite group, and " shares reveal nothing" in "Shamir's Secret Sharing" is essentially the same argument.
3.3 The key must be at least as long as the message
Shannon also proved that perfect secrecy requires a key space with .
The reason: fix a possible ciphertext . If there are fewer keys than plaintexts, then decrypting with every key gives at most different plaintexts, so some plaintext can never correspond to , meaning .
So "short key + perfect secrecy" is impossible. This is a theorem of information theory, not an engineering problem yet to be solved.
3.4 A worked example: the two-time pad
One key encrypting two messages
Key .
- ,
- ,
An attacker XORs the two ciphertexts:
The key has cancelled out (because ). The attacker gets the XOR of the two plaintexts, which for natural language is almost as good as reading them: guess a common word in one ("the", "weather"), and the matching position in the other decrypts automatically. This is called crib dragging, and it is how Venona worked. (Checked with Python.)
Summary
| Layer | Key points |
|---|---|
| Intuition | Every plaintext has a matching key, so "anything is possible" |
| Algebra | Adding a uniformly random group element gives a uniformly random result |
| Cost | Key message length (Shannon's theorem); it can be used only once |
| Reality | Stream ciphers trade this for practicality; the two-time pad led to the Venona decrypts |