Homework 2: Advanced Cryptography University of Michigan, Winter 2016 Instructor: Chris Peikert Student: SOLUTIONS
Homework 2: Advanced Cryptography University of Michigan, Winter 2016 Instructor: Chris Peikert Student: SOLUTIONS
This homework is due by 7pm on January 29 via the course Canvas page. Start early!
Instructions. Solutions must be typed, preferably in LATEX (a template for this homework is available on the
course web page). Your work will be graded on correctness, clarity, and concision. You should only submit
work that you believe to be correct; if you cannot solve a problem completely, you will get significantly more
partial credit if you clearly identify the gap(s) in your solution. It is good practice to start any long solution
with an informal (but accurate) “proof summary” that describes the main idea.
You may collaborate with others on this problem set and consult external sources. However, you must write
your own solutions and list your collaborators/sources for each problem.
1. (Pseudorandom functions.) Let F be a pseudorandom function. For each the following, state whether F 0
is necessarily a pseudorandom function. If yes, prove it; if not, demonstrate a counterexample.
(a) Fk0 (x) = Fk (0kx)kFk (1kx)
Solution: We claim that F 0 is a pseudorandom function. To show this we use a hybrid argument.
We define hybrid experiments that each give oracle access to a function:
• H0 is the real game: oracle access to Fk0 (x) = Fk (0kx)kFk (1kx) where k ← K is
chosen uniformly at random from the keyspace.
• H1 is oracle access to the function f 0 (x) = f (0kx)kf (1kx), where f : X → Y is a
uniformly random function.
• H2 is the ideal experiment: oracle access to a uniformly random function U : X →
Y ×Y.
Next we show that each of the two terms on the right is negligible, hence so is their sum, as
desired. In fact, we will show that H1 and H2 are identical, so AdvH1 ,H2 (A0 ) = 0.
H0 and H1 are indistinguishable. We use A0 to build an adversary A against F which has
oracle access to some O and works as follows: A runs A0 ; whenever A0 queries some x, A
queries its own oracle to get y0 = O(0kx) and y1 = O(1kx) and gives y0 ky1 to A0 . One
can verify that A perfectly simulates H0 and H1 when O = Fk and O is a uniformly random
function, respectively. Therefore, the advantage of A against F is
Because F is a PRF and A is efficient, AdvF (A) must be negligible, hence so is AdvH0 ,H1 (A0 ).
H1 and H2 are identical. We show that f 0 as defined in H1 is a uniformly random function, and
thus H1 and H2 are actually identical experiments. To see this, observe that every new input x
to f 0 corresponds to two new inputs 0kx, 1kx to f , which returns two uniformly random and
independent values in Y . Thus f 0 is a uniformly random function from X to Y × Y .
Advanced Cryptography Instructor: Chris Peikert
University of Michigan, Winter 2016 Homework 2 Student: SOLUTIONS
Solution: F 0 is never a PRF when F ’s input length ` ≥ 2 (and its output length is at least
1). We describe an effective and efficient attacker A. The attacker first queries its oracle on
x1 = 0`−2 k1 and gets y1 ky2 = O(x1 ), then it queries x2 = 0`−1 to get y3 ky4 = O(x2 ).
Finally, it accepts if and only if y1 = y4 , and rejects otherwise.
When O = Fk0 for some k, we have y1 = y4 = Fk (0`−1 k1) therefore A always accepts. On
the other hand, when O is a truly random function, then because x1 6= x2 , we know that y1
and y4 are uniformly random and independent, hence they are equal (making A accept) with
probability 1/|Y | ≤ 1/2. Thus AdvF (A) = 1 − 1/|Y | ≥ 1/2, which is non-negligible.
1
Therefore, A’s advantage against F 0 is AdvF 0 (A) = 1 − ≥ 1/2, which is non-negligible.
|Y |
(d) (Optional challenge.) Fk0 (x) = G(Fk (x)) where G is a pseudorandom generator.
Solution: F 0 is a PRF. We sketch the solution, leaving the details as an exercise. We first
consider a hybrid game where we give oracle access to H(x) = G(U (x)), where U is a
uniformly random function. A straightforward reduction shows that this is indistinguishable
from the real game, using the fact that F is a PRF.
Next, we consider a sequence of hybrid games for i = 1, 2, . . . , q, where q = poly(n) is an
upper bound on the number of queries the adversary makes. In the ith of these hybrid games,
the first i new queries are answered with uniformly random and independent answers, and the
remainder are answered as G(U (·)). (Duplicate queries are always answered consistently.)
Clearly, the last of these hybrids is identical to the ideal game, i.e., a uniformly random function.
Moreover, a simple reduction shows that adjacent hybrids are indistinguishable, using the fact
that G is a PRG. The reduction receives a string y which is either G(s) (for uniform s) or truly
Advanced Cryptography Instructor: Chris Peikert
University of Michigan, Winter 2016 Homework 2 Student: SOLUTIONS
random. It answers the first i − 1 new queries with random strings, answers the next new query
with y, and answers the remaining new queries by G(U (·)), “lazily” constructing the random
function U itself. One can verify that this reduction perfectly simulates the (i − 1)st or ith
hybrid, depending on whether y is G(s) or truly random, respectively.
2. (Multi-message security vs. adaptive security.) Recall that (non-adaptive) multi-message security for a
symmetric-key encryption scheme (Gen, Enc, Dec) says that for any q = poly(n) and any two tuples
(m1 , . . . , mq ), (m01 , . . . , m0q ) ∈ Mq of messages, the following are computationally indistinguishable:
c
hk ← Gen : (Enck (m1 ), . . . , Enck (mq )i ≈ hk ← Gen : (Enck (m01 ), . . . , Enck (m0q )i.
By contrast, adaptive (or IND-CPA) security says that the following two oracles are indistinguishable:
c
where oracle Ekb (m0 , m1 ) outputs Enck (mb ) (using fresh randomness for each call).
Give a separation between these two definitions: construct a (possibly contrived) scheme and prove it
secure according to the former definition (using some standard assumption), while showing that it is
insecure according to the latter definition.
(Hint: define an Enck (·) that: 1. “acts insecurely” on a secret unpredictable message m∗ , but “acts
securely” on all others; and 2. reveals m∗ via an adaptive attack.)
Solution: Let Π = (Gen, Enc, Dec) be a multi-message-secure scheme with message space M =
{0, 1}n . We construct another scheme Π0 = (Gen0 , Enc0 , Dec0 ) as follows:
• Dec0kkk∗ : if the input is ckk ∗ for some c, output Deck (c); on input 0, output k ∗ .
Notice that the k ∗ component of the key isn’t used in Enc0 , except as a “backdoor” to make it behave
insecurely on the special message m∗ = k ∗ .
Π0 is not IND-CPA secure. We describe an efficient adaptive attacker A: given an oracle O(·, ·), it
first queries the oracle on (m0 , m0 ) ∈ M × M for some arbitrary message m0 and receives some
c0 . Observe that if c0 = 0, then this means that k ∗ = m0 ; otherwise, c0 = ckk ∗ , so in both cases A
learns k ∗ . Next, A queries O on (k ∗ , m) where m 6= k ∗ is an arbitrary message. Finally, A accepts
if the second response is 0, otherwise it rejects. Now clearly,
0
Pr[AEk (·,·) = 1] = 1
and
1
Pr[AEk (·,·) = 1] = 0,
Advanced Cryptography Instructor: Chris Peikert
University of Michigan, Winter 2016 Homework 2 Student: SOLUTIONS
ind-cpa
therefore AdvΠ0 (A) = 1, which is non-negligible.
Π0 is multi-message secure. The intuition is that because the sequences of messages are fixed ahead
of time, it is extremely unlikely that any of them will match the random choice of k ∗ ← M by Gen0 .
Therefore, the “backdoor” will not be triggered for any of them, the multi-message security of Π
ensures the multi-message security of Π0 . We now proceed formally.
We want to show that for any q = poly(n) and for any two tuples (m1 , . . . , mq ), (m01 , . . . , m0q ) ∈
Mq of messages:
c
hk ← Gen, k ∗ ← M : (Enc0kkk∗ (m1 ), . . . , Enc0kkk∗ (mq )i ≈
hk ← Gen, k ∗ ← M : (Enc0kkk∗ (m01 ), . . . , Enc0kkk∗ (m0q )i.
We do this formally using a hybrid argument. Define the following hybrid experiments:
(Enc0kkk∗ (m1 ), . . . , Enc0kkk∗ (mq )) = (Enck (m1 )kk ∗ , . . . , Enc0k (mq )kk ∗ ).
Therefore,
3. In a network where all data is sent via broadcast (e.g., WiFi), we might want communication to be
anonymous. Informally, this that means that an eavesdropping adversary should not be able to learn,
given a ciphertext, anything about who the sender and intended recipient are.
(a) Give a formal definition of anonymity under adaptive chosen-plaintext attack for a symmetric-key
encryption scheme (Gen, Enc, Dec). Your definition should capture (only) the intuition that it is
hard to distinguish which one of two secret keys a ciphertext was encrypted under, even given other
ciphertexts encrypted under those keys.
Solution: We formally capture the following game: first, two secret keys k0 and k1 are
generated. The adversary is given access to three oracles: Enck0 (·), Enck1 (·), and O(·), where
O is either Enck0 (·) or Enck1 (·). The adversary should not be able to tell whether O is Enck0 (·)
or Enck1 (·).
More formally, for every efficient A we require:
c
hk0 ← Gen, k1 ← Gen : AEnck0 (·),Enck1 (·),Enck0 (·) i ≈
hk0 ← Gen, k1 ← Gen : AEnck0 (·),Enck1 (·),Enck1 (·) i.
(b) Does your definition of anonymity imply IND-CPA security (indistinguishability under adaptive
chosen-plaintext attack)? If so, prove it; otherwise, give the simplest counterexample you can find.
(In constructing your counterexample, you may rely on any reasonable assumption).
(c) Does the PRF-based encryption scheme from class satisfy your definition of anonymity? If so,
prove it; otherwise, describe a PRF family for which the encryption scheme is not anonymous. (As
usual, your counterexample may use any reasonable cryptographic assumption.)