Perfect Secrecy and the One-Time Pad
A guided-inquiry activity for Day 3 (Cryptography). Work in a team of 3 to 4, or on your own. Read each Model, then answer the Critical Thinking Questions in order before peeking at the hints.
Learning objectives
- Use the XOR operation to encrypt and decrypt a message.
- State the three requirements of a one-time pad.
- Explain perfect secrecy: a ciphertext reveals nothing about the plaintext.
- Explain why reusing a one-time pad key breaks its security.
Prerequisites: the XOR operation and binary basics (Day 3, Module 2).
Team roles
Model 1: XOR and the one-time pad
XOR (exclusive or) compares two bits and outputs 1 only when the bits differ.
| a | b | a XOR b |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
A one-time pad encrypts by XOR-ing the message with a random key of the same length.
| bits | ||||||
|---|---|---|---|---|---|---|
| message | 1 | 0 | 1 | 1 | 0 | 0 |
| key (random) | 0 | 1 | 1 | 0 | 1 | 0 |
| ciphertext | 1 | 1 | 0 | 1 | 1 | 0 |
- Using the XOR table, verify the ciphertext row in Model 1 for the first two bit columns.
Check your thinking
Column 1: 1 XOR 0 = 1. Column 2: 0 XOR 1 = 1. Both match the ciphertext row.
- To decrypt, the receiver XORs the ciphertext with the same key. Compute ciphertext XOR key for the first two columns. What do you get?
Check your thinking
Column 1: 1 XOR 0 = 1. Column 2: 1 XOR 1 = 0. You recover the original message bits 1 then 0.
- What does this show about XOR-ing by the same key twice?
Check your thinking
It cancels out: (m XOR k) XOR k = m. Applying the same key twice returns the original.
Model 2: Why the ciphertext tells you nothing
Take the 6-bit ciphertext 110110 from Model 1. A different 6-bit key produces a different message.
| ciphertext | 1 | 1 | 0 | 1 | 1 | 0 |
|---|---|---|---|---|---|---|
| guess key A | 0 | 1 | 1 | 0 | 1 | 0 |
| gives message | 1 | 0 | 1 | 1 | 0 | 0 |
| guess key B | 1 | 1 | 0 | 1 | 0 | 1 |
| gives message | 0 | 0 | 0 | 0 | 1 | 1 |
For every possible message, there is exactly one key that produces this ciphertext.
- From Model 2, if the attacker has only the ciphertext, can they tell which message was sent? Why or why not?
Check your thinking
No. Every possible message is equally possible because some key maps to it. The ciphertext alone gives no information about the message.
- Write your own one-sentence definition of perfect secrecy.
Check your thinking
Perfect secrecy means the ciphertext reveals nothing about the plaintext: seeing the ciphertext does not change what the attacker believes the message could be.
- List the three requirements a key must meet for a one-time pad to be perfectly secret.
Check your thinking
1) truly random, 2) at least as long as the message, 3) used only once and then destroyed.
- Why must the key be as long as the message?
Check your thinking
If the key were shorter it would have to repeat or be reused, which leaks patterns. A key as long as the message lets every message stay equally possible.
- Suppose the same key is used for two messages, giving ciphertexts C1 and C2. What does C1 XOR C2 equal, and why is that bad?
Check your thinking
C1 XOR C2 = M1 XOR M2, because the shared key cancels. That leaks the relationship between the two messages and can reveal both. This is why a one-time pad must be used only once.
- If the one-time pad is unbreakable, why is it rarely used in practice?
Check your thinking
The key must be truly random, as long as all the data, used once, and shared secretly in advance. Distributing that much key material safely is impractical, so real systems use AES with short keys instead.
Do it now
Application
A teammate suggests reusing one strong random key all week to save effort. Using your conclusion from Model 2, explain the risk in two sentences.