4.6 Exercises

Alice is learning about the shift cipher. She chooses a random threeletter word (so all threeletter words in the dictionary have the same probability) and encrypts it using a shift cipher with a randomly chosen key (that is, each possible shift has probability 1/26). Eve intercepts the ciphertext mxp.
Compute $P(M=cat\mid C=mxp)$. (Hint: Can mxp shift to cat?)
Use your result from part (a) to show that the shift cipher does not have perfect secrecy (this is also true because there are fewer keys than ciphertexts; see the proposition at the end of the first section).

Alice is learning more advanced techniques for the shift cipher. She now chooses a random fiveletter word (so all fiveletter words in the dictionary have the same probability) and encrypts it using a shift cipher with a randomly chosen key (that is, each possible shift has probability 1/26). Eve intercepts the ciphertext evire. Show that
$$P(M=arena\mid C=evire)=1/2.$$(Hint: Look at Exercise 1 in Chapter 2.)

Suppose a message $m$ is chosen randomly from the set of all fiveletter English words and is encrypted using an affine cipher mod 26, where the key is chosen randomly from the 312 possible keys. The ciphertext is $HHGZC$. Compute the conditional probability $\text{Prob}(m=HELLO\phantom{\rule{thickmathspace}{0ex}}\mid \phantom{\rule{thinmathspace}{0ex}}c=HHGZC)$. Use the result of this computation to determine whether of not affine ciphers have perfect secrecy.

Alice is learning about the Vigenère cipher. She chooses a random sixletter word (so all sixletter words in the dictionary have the same probability) and encrypts it using a Vigenère cipher with a randomly chosen key of length 3 (that is, each possible key has probability $1/{26}^{3}$). Eve intercepts the ciphertext eblkfg.
Compute the conditional probability $P(M=attack\mid C=eblkfg)$.
Use your result from part (a) to show that the Vigenère cipher does not have perfect secrecy.

Alice and Bob play the following game (this is the CI Game of Section 4.5). Alice chooses two twoletter words ${m}_{0}$ and ${m}_{1}$ and gives them to Bob. Bob randomly chooses $b=0$ or 1. He encrypts ${m}_{b}$ using a shift cipher (with a randomly chosen shift) to get a ciphertext $c$, which he gives to Alice. Alice then guesses whether ${m}_{0}$ or ${m}_{1}$ was encrypted.
Alice chooses ${m}_{0}=HI$ and ${m}_{1}=NO$. What is the probability that Alice guesses correctly?
Give a choice of ${m}_{0}$ and ${m}_{1}$ that Alice can make so that she is guaranteed to be able to guess correctly.

Bob has a weak pseudorandom generator that produces $N$ different $M$bit keys, each with probability $1/N$. Alice and Bob play Game R. Alice makes a list of the $N$ possible pseudorandom keys. If the number $r$ that Bob gives to her is on this list, she guesses that the number is chosen pseudorandomly. If it is not on the list, she guess that it is random.
Show that
$$P(r\text{is on the list}\mid r\text{is random})={\displaystyle \frac{N}{{2}^{M}}}$$and
$$P(r\text{is on the list}\mid r\text{is pseudorandom})=1.$$Show that
$$\begin{array}{rl}& P(r\text{is random}\bigcap r\text{is on the list})={\displaystyle \frac{1}{2}}\left({\displaystyle \frac{N}{{2}^{M}}}\right)\\ & P(r\text{is random}\bigcap r\text{is not on the list})={\displaystyle \frac{1}{2}}\left(1{\displaystyle \frac{N}{{2}^{M}}}\right)\\ & P(r\text{is pseudorandom}\bigcap r\text{is on the list})={\displaystyle \frac{1}{2}}\\ & P(r\text{is pseudorandom}\bigcap r\text{is not on the list})=0.\end{array}$$Show that Alice wins with probability
$$\frac{1}{2}}\left(1{\displaystyle \frac{N}{{2}^{M}}}\right)+{\displaystyle \frac{1}{2}}\text{.$$Show that if $N/{2}^{M}=1\u03f5$ then Alice wins with probability $\frac{1}{2}}+{\displaystyle \frac{1}{2}}\u03f5$. (This shows that if the pseudorandom generator misses a fraction of the possible keys, then Alice has an advantage in the game, provided that she can make a list of all possible outputs of the generator. Therefore, it is necessary to make $N$ large enough that making such a list is infeasible.)

Suppose Alice knows that Bob’s pseudorandom key generator has a slight bias and that with probability 51% it produces a key with more 1’s than 0’s. Alice and Bob play the CI Game. Alice chooses messages ${m}_{0}=000\cdots 0$ and ${m}_{1}=111\cdots 1$ to Bob, who randomly chooses $b\in \{0\text{,}\text{}1\}$ and encrypts ${m}_{b}$ with a onetime pad using his pseudorandom key generator. He gives the ciphertext $c={m}_{b}\oplus r$ (where $r$ is his pseudorandom key) to Alice. Alice computes $s=c\oplus {m}_{0}$. If $s$ has more 1’s than 0’s, she guesses that $b=0$. If not, she guesses that $b=1$. For simplicity in the following, we assume that the message lengths are odd (so there cannot be the same number of 1’s and 0’s).
Show that exactly one of ${m}_{0}\oplus r$ and ${m}_{1}\oplus r$ has more 1’s than 0’s.
Show that $P(s\text{has more 1's}\mid b=0)=.51$
Show that $P(s\text{has fewer 1's}\mid b=1)=.51$
Show that Alice has a probability .51 of winning.

In the onetime pad, suppose that some plaintexts are more likely than others. Show that the key and the ciphertext are not independent. That is, show that there is a key $k$ and a ciphertext $c$ such that
$$P(C=c\phantom{\rule{thinmathspace}{0ex}}\bigcap \phantom{\rule{thinmathspace}{0ex}}K=k)\ne P(C=c)\phantom{\rule{thinmathspace}{0ex}}P(K=k)\text{.}$$(Hint: The righthand side of this equation is independent of $k$ and $c$. What about the lefthand side?)

Alice and Bob are playing the R Game. Suppose Alice knows that Bob’s pseudorandom number generator always has a 1 at the beginning of its output. If Alice sees this initial 1, she guesses that the output is from the pseudorandom generator. And if this 1 is not present, Alice knows that $r$ is random. Show that Alice guesses correctly with probability 3/4.

Suppose Bob uses a pseudorandom number generator to produce a onetime pad, but the generator has a slight bias, so each bit it produces has probability 51% of being 1 and only 49% of being 0. What strategy can Alice use so that she expects to win the CI Game more than half the time?

At the end of the semester, the professor randomly chooses and sends one of two possible messages:
$${m}_{0}=YOUPASSED\phantom{\rule{1em}{0ex}}\text{and}\phantom{\rule{1em}{0ex}}{m}_{1}=YOUFAILED\text{.}$$To add to the excitement, the professor encrypts the message using one of the following methods:
Shift cipher
Vigenère cipher with key length 3
Onetime pad.
You receive the ciphertext and want to decide whether the professor sent ${m}_{0}$ or ${m}_{1}$. For each method (a), (b), (c), explain how to decide which message was sent or explain why it is impossible to decide. You may assume that you know which method is being used. (For the Vigenère, do not do frequency analysis; the message is too short.)

On Groundhog Day, the groundhog randomly chooses and sends one of two possible messages:
$$\begin{array}{rl}{m}_{0}& =SIXMOREWEEKSOFWINTER\\ {m}_{1}& =SPRINGARRIVESINMARCH\text{.}\end{array}$$To add to the mystery, the groundhog encrypts the message using one of the following methods: shift cipher, Vigenère cipher with key length 4 (using four distinct shifts), onetime pad. For each of the following ciphertexts, determine which encryption methods could have produced that ciphertext, and for each of these possible encryption methods, decrypt the message or explain why it is impossible to decrypt.
ABCDEFGHIJKLMNOPQRST
UKZOQTGYGGMUQHYKPVGT
UQUMPHDVTJYIUJQQCSFL.

Alice encrypts the messages ${M}_{1}$ and ${M}_{2}$ with the same onetime pad using only capital letters and spaces, as in Section 4.3. Eve knows this, intercepts the ciphertexts ${C}_{1}$ and ${C}_{2}$, and also learns that the decryption of ${M}_{1}$ is THE LETTER * ON THE MAP GIVES THE LOCATION OF THE TREASURE. Unfortunately for Eve, she cannot read the missing letter *. However, the 12th group of seven bits in ${C}_{1}$ is $1001101$ and the 12th group in ${C}_{2}$ is $0110101$. Find the missing letter.