What makes a one-time pad secret?

Use a secret row of bits to hide a message. Then see what someone who sees only the ciphertext can learn.

Follow the worked example below to see how to recover a message and why one ciphertext fits several possibilities.

The same pad reverses the flips

In Lesson 3.1, whole messages became rows of bits. This example uses just two bits so you can see all four possibilities. As you saw in Lesson 3.2, a mask bit of 1 flips a bit. Applying the same mask again flips those bits back. With message 01 and pad 10, encryption gives 01 XOR 10 = 11. The receiver already has the secret pad and recovers 11 XOR 10 = 01.

The pad is a secret row of bits as long as the message. Draw it uniformly, so all bit strings of that length are equally likely. The pad is drawn independently of the message, kept secret, and used to encrypt only one message. The receiver’s use of that pad to recover the same message is part of the same exchange.

Include every pad value in the draw. Pad 00 leaves the example message unchanged. The observer sees only the ciphertext, so they cannot tell if you drew 00 or any other pad.

One ciphertext, four possible messages

Imagine you see ciphertext 11 and the pad is secret. Each pad gives you a different possible message.

All four possibilities for ciphertext 11
PadPossible message
0011
0110
1001
1100

For each candidate message, exactly one of the four pads would give the observed ciphertext. Each pad is equally likely and drawn without regard to the message, so each candidate message had the same one-in-four chance of producing this ciphertext. The ciphertext gives you no reason to change your earlier guesses about the message. For example, if you thought 00 was twice as likely as 01 before seeing the ciphertext, those odds stay the same.

This is perfect secrecy for messages of the same length. The ciphertext still reveals the message’s length. The two-bit example makes all the possibilities easy to see. The same reasoning applies to longer messages when the pad meets the same requirements. See Shannon’s original paper on secrecy systems and the optional formal proof by Boneh and Shoup.

Check your understanding

Suppose the pad is still drawn independently of the message, but 00 is more likely than 10. Seeing ciphertext 11, which candidate does that observation favor, message 11 or message 01? Why?

Show the answer

The observation favors 11 because it would produce the ciphertext with pad 00, the more likely pad. Message 01 needs pad 10. The ciphertext can now shift the observer’s earlier odds toward 11.