The One Time Pad
Author: chuck_bartowski
Introduction
The One Time Pad (OTP) is a well known example of encryption schemes that provide "perfect secrecy". Informally, this means that observing a ciphertext does no give any information to the eavesdropper. A proof of this fact will be provided later. Crucially we will assume that the sender and the receiver have both access to a common source of random bits.
XOR as a One-Time Pad
XOR(addition modulo 2) can be used as an encryption scheme as follows: The message space is (i.e.: length n bit strings), the key space is and the ciphertext space is also
Encryption:
Decryption:
The correctness of the schemes is easily verifiable. If the encryption produces , then the decryption produces .
In the Python snippet below with use to os
module to generate random bits.
As seen above the receiver with access to the same key can recover the message.
Generalized One-Time Pad
Although XOR is commonly used for the OTP, OTP can be made out of more general objects. If fact We can define an OTP if the message and the keys are objects from a set with a group like structure. (see GroupTheorySection #TODO)
Last updated