Caloogy Article
中文

The One-Time Pad and Shannon: The Only Cipher Proven "Absolutely Secure"

Date
Sep 27, 2026
Series
Cryptography
Reading
4 min
Topics
One time padPerfect secrecyShannonXOR

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:

  1. The intuition: why "anything is possible" means "you know nothing"
  2. Real-world use: the Washington–Moscow hotline, the Venona project and why modern encryption doesn't use it
  3. 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:

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

  1. Truly random: it can't be pseudorandom, or an attacker can go after the generator;
  2. As long as the message: the key can't be cycled;
  3. 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

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 mm and any ciphertext cc,

Pr⁡[M=m∣C=c]=Pr⁡[M=m].\Pr[M = m \mid C = c] = \Pr[M = m].

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 (G,+)(G, +) (such as Z26n\mathbb{Z}_{26}^n or F2n\mathbb{F}_2^n), with the key KK uniformly random on GG, independent of MM, and C=M+KC = M + K.

For any m,c∈Gm, c \in G, there is exactly one key k=c−mk = c - m with m+k=cm + k = c. Therefore

Pr⁡[C=c∣M=m]=Pr⁡[K=c−m]=1∣G∣,\Pr[C = c \mid M = m] = \Pr[K = c - m] = \frac{1}{|G|},

which doesn't depend on mm. Perfect secrecy follows from Bayes' rule.

In abstract algebra terms: for each fixed mm, the translation k↦m+kk \mapsto m + k is a bijection from GG to itself, and a uniform distribution stays uniform under a bijection.

This proof works for any finite group, and "k−1k-1 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 ∣K∣≥∣M∣|\mathcal{K}| \ge |\mathcal{M}|.

The reason: fix a possible ciphertext cc. If there are fewer keys than plaintexts, then decrypting cc with every key gives at most ∣K∣<∣M∣|\mathcal{K}| < |\mathcal{M}| different plaintexts, so some plaintext mm can never correspond to cc, meaning Pr⁡[M=m∣C=c]=0≠Pr⁡[M=m]\Pr[M = m \mid C = c] = 0 \neq \Pr[M = m].

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 k=10110001k = 10110001.

  • m1=11001010m_1 = 11001010, c1=m1⊕k=01111011c_1 = m_1 \oplus k = 01111011
  • m2=01100110m_2 = 01100110, c2=m2⊕k=11010111c_2 = m_2 \oplus k = 11010111

An attacker XORs the two ciphertexts: c1⊕c2=10101100=m1⊕m2.c_1 \oplus c_2 = 10101100 = m_1 \oplus m_2.

The key has cancelled out (because k⊕k=0k \oplus k = 0). 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 ≥\ge 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