Curriculum / Quantum Cryptography / The One-Time Pad: Perfect Secrecy
The One-Time Pad: Perfect Secrecy
Understand perfect secrecy and why key distribution is the hard problem.
The One-Time Pad: Perfect Secrecy
The one-time pad (OTP) is the only known encryption scheme with perfect secrecy in the information-theoretic sense defined by Claude Shannon. That is a remarkable statement: no matter how much computing power an attacker has, they cannot extract any information about the plaintext from an OTP ciphertext.
Shannon's Definition of Perfect Secrecy
Claude Shannon proved in 1949 that an encryption scheme has perfect secrecy if and only if observing the ciphertext gives an attacker zero information about the plaintext. Formally:
P(plaintext = m | ciphertext = c) = P(plaintext = m)
In other words, seeing the ciphertext does not change your belief about what the plaintext might be. Every possible plaintext is equally consistent with every ciphertext.
How OTP Achieves This
The one-time pad works as follows:
- 1.Generate a truly random key K of the same length as the message M
- 2.Encrypt by XOR: C = M XOR K
- 3.Decrypt by XOR again: M = C XOR K (since XOR is its own inverse)
The security argument: for any ciphertext C and any candidate plaintext M', there exists exactly one key K' = C XOR M' that would produce that ciphertext. Since all keys are equally probable (the key is truly random), all plaintexts are equally probable given any ciphertext.
The Three Requirements
OTP is perfectly secure only when three conditions are met:
1. The key is truly random. Pseudorandom keys (from a deterministic algorithm with a seed) do not give information-theoretic security. They give computational security, which is a weaker guarantee.
2. The key is at least as long as the message. This is a consequence of Shannon's theorem: any perfectly secure cipher must have a key space at least as large as the message space.
3. The key is used exactly once. If the same key is reused for two messages, an attacker can XOR the two ciphertexts together to get M1 XOR M2, which leaks information about both messages. (This attack was used to break Soviet OTP messages in the VENONA project.)
This is the opening of the lesson. The full walkthrough, the interactive circuit, and the graded challenge continue inside myqubit.
How this lesson works
A hands-on coding challenge. You write Qiskit-compatible Python in the browser editor, run it instantly via WebAssembly, watch the circuit and Bloch sphere react, and pass automatic output checks. The AI tutor Qubitus gives Socratic hints if you get stuck.
Part of: Quantum Cryptography
Master quantum key distribution, the threat quantum computers pose to classical cryptography, and post-quantum cryptographic standards.
This lesson is part of Pro
Unlock Quantum Cryptography and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.