TOPICS
Search

One-Time Pad


A one-time pad is an encryption scheme that combines a plaintext with a uniformly random secret key of the same length, chosen independently of the plaintext and used only once. In its binary form, the ciphertext is obtained by bitwise XOR, and the same key recovers the plaintext,

C=P xor K
(1)
P=C xor K.
(2)

Here P, K, and C are binary strings of length n>=1 (Menezes et al. 1996, p. 192).

The scheme has perfect secrecy. For every plaintext p of positive probability and every ciphertext c,

 Pr(C=c|P=p)=Pr(K=p xor c)=2^(-n),
(3)

so the ciphertext is uniform and independent of the plaintext. In particular,

 Pr(P=p|C=c)=Pr(P=p).
(4)

The plaintext need not itself be uniformly distributed.

If a key is reused for two plaintexts P_1 and P_2, then

 C_1 xor C_2=(P_1 xor K) xor (P_2 xor K)=P_1 xor P_2.
(5)

The two ciphertexts therefore reveal the bitwise XOR of the plaintexts, so key reuse does not provide perfect secrecy in general (Menezes et al. 1996, p. 21).


See also

Ciphertext, Cryptography, Plaintext, XOR

Explore with Wolfram|Alpha

References

Menezes, A. J.; van Oorschot, P. C.; and Vanstone, S. A. Handbook of Applied Cryptography. Boca Raton, FL: CRC Press, 1996. https://cacr.uwaterloo.ca/hac/.

Cite this as:

Weisstein, Eric W. "One-Time Pad." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/One-TimePad.html

Subject classifications