Docsity

Pseudorandom functions from pseudorandom generators and CPA security, Lecture notes of Mathematics

Toggle sidebar
bg1
5
Pseudorandom functions from pseudorandom generators and
CPA security
In this lecture we will see that the PRG conjecture implies the PRF
conjecture. We will also see how PRFs imply an encryption scheme
that is secure even when we encrypt multiple messages with the same
key.
We have seen that PRFโ€™s (pseudorandom functions) are extremely
useful, and weโ€™ll see some more applications of them later on. But
are they perhaps too amazing to exist? Why would someone imagine
that such a wonderful object is feasible? The answer is the following
theorem:
Theorem 5.1 โ€” The PRF Theorem. Suppose that the PRG Conjecture is
true, then there exists a secure PRF collection {๐‘“๐‘ }๐‘ โˆˆ{0,1}โˆ—such that
for every ๐‘ โˆˆ{0,1}๐‘›,๐‘“๐‘ maps {0,1}๐‘›to {0,1}๐‘›.
Figure 5.1: The construction of a pseudorandom
function from a pseudorandom generator can be
illustrated by a depth ๐‘›binary tree. The root is
labeled by the seed ๐‘ and for every internal node ๐‘ฃ
labeled by a string ๐‘ฅโˆˆ{0,1}๐‘›, we use that label ๐‘ฅ
as a seed into the PRG ๐บto label ๐‘ฃโ€™s two children. In
particular, the children of ๐‘ฃare labeled with ๐บ0(๐‘ฅ)
and ๐บ1(๐‘ฅ)respectively. The output of the function ๐‘“๐‘ 
on input ๐‘–is the label of the ๐‘–๐‘กโ„Žleaf counting from left
to right. Note that the numbering of leaf ๐‘–is related to
the bitstring representation of ๐‘–and the path leaf ๐‘–in
the following way: we traverse to leaf ๐‘–from the root
by reading off the ๐‘›bits of ๐‘–left to right and descend
into the left child of the current node for every 0 we
encounter and traverse right for every 1.
Compiled on 11.17.2021 22:35
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Pseudorandom functions from pseudorandom generators and CPA security and more Lecture notes Mathematics in PDF only on Docsity!

Pseudorandom functions from pseudorandom generators and

CPA security

In this lecture we will see that the PRG conjecture implies the PRF conjecture. We will also see how PRFs imply an encryption scheme that is secure even when we encrypt multiple messages with the same key. We have seen that PRFโ€™s (pseudorandom functions) are extremely useful, and weโ€™ll see some more applications of them later on. But are they perhaps too amazing to exist? Why would someone imagine that such a wonderful object is feasible? The answer is the following theorem:

Theorem 5.1 โ€” The PRF Theorem. Suppose that the PRG Conjecture is true, then there exists a secure PRF collection {๐‘“๐‘ }๐‘ โˆˆ{0,1}โˆ— such that for every ๐‘  โˆˆ {0, 1}๐‘›, ๐‘“๐‘  maps {0, 1}๐‘›^ to {0, 1}๐‘›.

Figure 5.1 : The construction of a pseudorandom function from a pseudorandom generator can be illustrated by a depth ๐‘› binary tree. The root is labeled by the seed ๐‘  and for every internal node ๐‘ฃ labeled by a string ๐‘ฅ โˆˆ {0, 1}๐‘›, we use that label ๐‘ฅ as a seed into the PRG ๐บ to label ๐‘ฃโ€™s two children. In particular, the children of ๐‘ฃ are labeled with ๐บ 0 (๐‘ฅ) and ๐บ 1 (๐‘ฅ) respectively. The output of the function ๐‘“๐‘  on input ๐‘– is the label of the ๐‘–๐‘กโ„Ž^ leaf counting from left to right. Note that the numbering of leaf ๐‘– is related to the bitstring representation of ๐‘– and the path leaf ๐‘– in the following way: we traverse to leaf ๐‘– from the root by reading off the ๐‘› bits of ๐‘– left to right and descend into the left child of the current node for every 0 we encounter and traverse right for every 1.

Compiled on 11.17.2021 22:

126 an intensive introduction to cryptography

Figure 5.2 : In the โ€œlazy evaluationโ€ implementation of the black box to the adversary, we label every node in the tree only when we need it. Subsequent traversals do not reevaluate the PRG, leading to reuse of the intermediate seeds. Thus for example, two sibling leaves will correspond to a single call to ๐บ(๐‘ฅ), where ๐‘ฅ is their parentโ€™s label, but with the left child receiving the first ๐‘› bits and the right child receiving the second ๐‘› bits of ๐บ(๐‘ฅ). In this figure check marks correspond to nodes that have been labeled and question marks to nodes that are still unlabeled.

Proof. We describe the proof, see also Chapter 6 of Rosulek or Section 8.5 of Katz-Lindell (section 7.5 in 2nd edition) for alternative exposi- tions. If the PRG Conjecture is true then in particular by the length exten- sion theorem there exists a PRG ๐บ โˆถ {0, 1}๐‘›^ โ†’ {0, 1}2๐‘›^ that maps ๐‘› bits into 2๐‘› bits. Letโ€™s denote ๐บ(๐‘ ) = ๐บ 0 (๐‘ ) โˆ˜ ๐บ 1 (๐‘ ) where โˆ˜ denotes concatenation. That is, ๐บ 0 (๐‘ ) denotes the first ๐‘› bits and ๐บ 1 (๐‘ ) denotes the last ๐‘› bits of ๐บ(๐‘ ). For ๐‘– โˆˆ {0, 1}๐‘›, we define ๐‘“๐‘ (๐‘–) as

๐บ๐‘–๐‘› (๐บ๐‘–๐‘›โˆ’1 (โ‹ฏ ๐บ๐‘– 1 (๐‘ ))).

This corresponds to ๐‘› composed applications of ๐บ๐‘ for ๐‘ โˆˆ {0, 1}. If the ๐‘—๐‘กโ„Ž^ bit of ๐‘–โ€™s binary string is 0 then the ๐‘—๐‘กโ„Ž^ application of the PRG is ๐บ 0 otherwise it is ๐บ 1. This series of successive applications starts with the initial seed ๐‘ . This definition directly corresponds to the depiction in Fig. 5.1, where the successive applications of ๐บ๐‘ correspond to the recursive labeling procedure. By the definition above we can see that to evaluate ๐‘“๐‘ (๐‘–) we need to evaluate the pseudorandom generator ๐‘› times on inputs of length ๐‘›, and so if the pseudorandom generator is efficiently computable then so is the pseudorandom function. Thus, โ€œallโ€ thatโ€™s left is to prove that the construction is secure and this is the heart of this proof. Iโ€™ve mentioned before that the first step of writing a proof is con- vincing yourself that the statement is true, but there is actually an often more important zeroth step which is understanding what the statement actually means. In this case what we need to prove is the following: We need to show that the security of the PRG ๐บ implies the security of the PRF ensemble {๐‘“๐‘ }. Via the contrapositive, this means that we assume that there is an adversary ๐ด that can distinguish in time ๐‘‡ a black box for ๐‘“๐‘ (โ‹…) from a black-box for a random function with advantage ๐œ–. We need to use ๐ด come up with an adversary ๐ท that can distinguish in time ๐‘๐‘œ๐‘™๐‘ฆ(๐‘‡ ) an input of the form ๐บ(๐‘ ) (where ๐‘  is random in {0, 1}๐‘›) from an input of the form ๐‘ฆ where ๐‘ฆ is random in {0, 1}2๐‘›^ with bias at least ๐œ–/๐‘๐‘œ๐‘™๐‘ฆ(๐‘‡ ). Assume that ๐ด as above is a ๐‘‡ -time adversary that wins in the โ€œPRF gameโ€ with advantage ๐œ–. Let us consider the โ€œlazy evaluationโ€ imple- mentation of the black box for ๐ด illustrated in Fig. 5.2. That is, at every point in time there are nodes in the full binary tree that are labeled and nodes which we havenโ€™t yet labeled. When ๐ด makes a query ๐‘–, this query corresponds to the path ๐‘– 1 โ€ฆ ๐‘–๐‘› in the tree. We look at the lowest (furthest away from the root) node ๐‘ฃ on this path which has been labeled by some value ๐‘ฆ, and then we continue labelling the path

128 an intensive introduction to cryptography

Figure 5.4 : In the ๐‘—๐‘กโ„Ž^ hybrid the first ๐‘— internal labels are drawn uniformly at random from ๐‘ˆ๐‘›. All sub- sequent childrenโ€™s labels are produced in the usual way by seeding ๐บ with the label ๐‘ง of the parent and assigning the first ๐‘› bits (๐บ 0 (๐‘ง)) to the left child and the last ๐‘› bits (๐บ 1 (๐‘ง)) to the right child. For exam- ple, for some node ๐‘ฃ๐ฟ๐‘—โˆ’1 at the ๐‘—๐‘กโ„Ž^ level, we generate pseudorandom string ๐บ(๐‘ฃ๐ฟ๐‘—โˆ’1) and label the left child ๐‘ฃ๐ฟ๐‘— = ๐บ 0 (๐‘ฃ๐ฟ๐‘—โˆ’1) and the right child ๐‘ฃ๐‘…๐‘— = ๐บ 1 (๐‘ฃ๐ฟ๐‘—โˆ’1). Note that the labeling scheme for this diagram is dif- ferent from that in the previous figures. This is simply for ease of exposition, we could still index our nodes via the path reaching them from the root.

Figure 5.5 : The ๐‘— + 1๐‘ ๐‘ก^ hybrid differs from the ๐‘—๐‘กโ„Ž in that the process of assigning random labels con- tinues until the ๐‘— + 1๐‘ ๐‘ก^ step as opposed to the ๐‘—๐‘กโ„Ž. The hybrids are otherwise completely identically constructed.

pseudorandom functions from pseudorandom generators and cpa security 129

Figure 5.6 : Distinguisher D is similar to hybrid ๐‘—, in that the nodes in the first ๐‘— layers are assigned completely random labels. When evaluating along a particular path through ๐‘ฃ๐ฟ๐‘—โˆ’1, rather than labeling the two children by applying ๐บ to its label, it simply splits the input ๐‘ฆ into two strings ๐‘ฆ0...๐‘›,๐‘ฆ๐‘›+1...2๐‘›. If ๐‘ฆ is truly random, ๐ท is identical to hybrid ๐‘— + 1. If ๐‘ฆ = ๐บ(๐‘ ) for some random seed ๐‘ , then ๐ท simulates hybrid ๐‘—.

๐ด and the ๐‘—๐‘กโ„Ž^ oracle inside its belly with one difference- when the time comes to label the ๐‘—๐‘กโ„Ž^ node, instead of doing this by applying the pseudorandom generator to the label of its parent ๐‘ฃ (which is what should happen in the ๐‘—๐‘กโ„Ž^ oracle) it uses its input ๐‘ฆ to label the two children of ๐‘ฃ. Now, if ๐‘ฆ was completely random then we get exactly the distribu- tion of the ๐‘— + 1๐‘ ๐‘ก^ oracle, and hence in this case ๐ท simulates internally the ๐‘— + 1๐‘ ๐‘ก^ hybrid. However, if ๐‘ฆ = ๐บ(๐‘ ) for some randomly sampled ๐‘  โˆˆ {0, 1}๐‘›, though it may not be obvious at first, we actually get the distribution of the ๐‘—๐‘กโ„Ž^ oracle. The equivalence between hybrid ๐‘— and distinguisher ๐ท under the condition that ๐‘ฆ = ๐บ(๐‘ ) is non obvious, because in hybrid ๐‘—, the label for the children of ๐‘ฃ๐ฟ๐‘—โˆ’1 was supposed to be the result of applying the pseudorandom generator to the label of ๐‘ฃ๐ฟ๐‘—โˆ’1 and not to some other random string (see Fig. 5.6). However, because ๐‘ฃ was labeled before the ๐‘—๐‘กโ„Ž^ step then we know that it was actually labeled by a random string. Moreover, since we use lazy evaluation we know that step ๐‘— is the first time where we actually use the value of the label of ๐‘ฃ. Hence, if at this point we resampled this label and used a completely independent random string ๐‘  then the distribution of ๐‘ฃ๐ฟ๐‘—โˆ’1 and ๐‘  would be identical. The key observations here are:

  1. The output of ๐ด does not directly depend on the internal labels, but only on the labels of the leaves (since those are the only values returned by the oracle).
  2. The label for an internal vertex ๐‘ฃ is only used once, and that is for generating the labels for its children.

pseudorandom functions from pseudorandom generators and cpa security 131

(^1) Giving Eve the key as a sequence of ๐‘› 1โ€ฒs as op- posed to in binary representation is a common no- tational convention in cryptography. It makes no difference except that it makes the input length for Eve of length ๐‘›, which makes sense since we want to allow Eve to run in ๐‘๐‘œ๐‘™๐‘ฆ(๐‘›) time.

Figure 5.7 : In the CPA game, Eve interacts with the encryption oracle and at the end chooses ๐‘š 0 , ๐‘š 1 , gets an encryption ๐‘โˆ—^ = ๐ธ๐‘˜(๐‘š๐‘) and outputs ๐‘โ€ฒ. She wins if ๐‘โ€ฒ^ = ๐‘

way, they must maintain a synchronized shared state. If the message ๐‘š 1 was dropped by the network, then Bob would not be able to decrypt correctly the encryption of ๐‘š 2. There is another way in which treating many messages as a single tuple is unsatisfactory. In real life, Eve might be able to have some im- pact on what messages Alice encrypts. For example, the Katz-Lindell book describes several instances in World War II where Allied forces made particular military maneuver for the sole purpose of causing the Axis forces to send encryptions of messages of the Alliesโ€™ choosing. To consider a more modern example, today Google uses encryption for all of its search traffic including (for the most part) the ads that are displayed on the page. But this means that an attacker, by pay- ing Google, can cause it to encrypt arbitrary text of their choosing. This kind of attack, where Eve chooses the message she wants to be encrypted is called a chosen plaintext attack. You might think that we are already covering this with our current definition that requires se- curity for every pair of messages and so in particular this pair could be chosen by Eve. However, in the case of multiple messages, we would want to allow Eve to be able to choose ๐‘š 2 after she saw the encryption of ๐‘š 1. All that leads us to the following definition, which is a strengthen- ing of our definition of computational security:

Definition 5.3 โ€” Chosen Plaintext Attack (CPA) secure encryption. An en- cryption scheme (๐ธ, ๐ท) is secure against chosen plaintext attack (CPA secure) if for every polynomial time ๐ธ๐‘ฃ๐‘’, Eve wins with probability at most 1/2 + ๐‘›๐‘’๐‘”๐‘™(๐‘›) in the game defined below:

  1. The key ๐‘˜ is chosen at random in {0, 1}๐‘›^ and fixed.
  2. Eve gets the length of the key 1 ๐‘›^ as input. 1
  3. Eve interacts with ๐ธ for ๐‘ก = ๐‘๐‘œ๐‘™๐‘ฆ(๐‘›) rounds as follows: in the ๐‘–๐‘กโ„Ž round, Eve chooses a message ๐‘š๐‘– and obtains ๐‘๐‘– = ๐ธ๐‘˜(๐‘š๐‘–).
  4. Then Eve chooses two messages ๐‘š 0 , ๐‘š 1 , and gets ๐‘โˆ—^ = ๐ธ๐‘˜(๐‘š๐‘) for ๐‘ โ†๐‘… {0, 1}.
  5. Eve continues to interact with ๐ธ for another ๐‘๐‘œ๐‘™๐‘ฆ(๐‘›) rounds, as in Step 3.
  6. Eve wins if she outputs ๐‘.

Definition 5.3 is illustrated in Fig. 5.7. Our previous notion of com- putational secrecy (i.e., Definition 2.6) corresponds to the case that we skip Steps 3 and 5 above. Since Steps 3 and 5 only give the ad- versary more power (and hence is only more likely to win), CPA security (Definition 5.3) is stronger than computational secrecy (Def- inition 2.6), in the sense that every CPA secure encryption (๐ธ, ๐ท) is

132 an intensive introduction to cryptography

Figure 5.8 : Insecurity of deterministic encryption (^2) If the messages are guaranteed to have high entropy which roughly means that the probability that a message repeats itself is negligible, then it is possible to have a secure deterministic private-key encryption, and this is sometimes used in practice. (Though often some sort of randomization or padding is added to ensure this property, hence in effect creating a randomized encryption.) Deterministic encryptions can sometimes be useful for applications such as efficient queries on encrypted databases. See this lecture in Dan Bonehโ€™s coursera course.

also computationally secure. It turns out that CPA security is strictly stronger , in the sense that without modification, our stream ciphers cannot be CPA secure. In fact, we have a stronger, and intially some- what surprising theorem:

Theorem 5.4 โ€” CPA security requires randomization. There is no CPA secure (๐ธ, ๐ท) where ๐ธ is deterministic.

Proof. The proof is very simple: Eve will only use a single round of interacting with ๐ธ where she will ask for the encryption ๐‘ 1 of 0 โ„“. In the second round, Eve will choose ๐‘š 0 = 0โ„“^ and ๐‘š 1 = 1โ„“, and get ๐‘โˆ—^ = ๐ธ๐‘˜(๐‘š๐‘) she will then output 0 if and only if ๐‘โˆ—^ = ๐‘ 1. โ– 

This proof is so simple that you might think it shows a problem with the definition, but it is actually a real problem with security. If you encrypt many messages and some of them repeat themselves, it is possible to get significant information by seeing the repetition pattern (cue the XKCD cartoon again, see Fig. 5.8). To avoid this issue we need to use a randomized (or probabilistic ) encryption, such that if we encrypt the same message twice we wonโ€™t see two copies of the same ciphertext.^2 But how do we do that? Here pseudorandom functions come to the rescue:

Theorem 5.5 โ€” CPA security from PRFs. Suppose that {๐‘“๐‘ } is a PRF collection where ๐‘“๐‘  โˆถ {0, 1}๐‘›^ โ†’ {0, 1}โ„“, then the following is a CPA secure encryption scheme: ๐ธ๐‘ (๐‘š) = (๐‘Ÿ, ๐‘“๐‘ (๐‘Ÿ) โŠ• ๐‘š) where ๐‘Ÿ โ†๐‘… {0, 1}๐‘›, and ๐ท๐‘ (๐‘Ÿ, ๐‘ง) = ๐‘“๐‘ (๐‘Ÿ) โŠ• ๐‘ง.

Proof. I leave to you to verify that ๐ท๐‘ (๐ธ๐‘ (๐‘š)) = ๐‘š. We need to show the CPA security property. As is usual in PRF-based constructions, we first show that this scheme will be secure if ๐‘“๐‘  was an actually random function, and then use that to derive security. Consider the game above when played with a completely random function and let ๐‘Ÿ๐‘– be the random string chosen by ๐ธ in the ๐‘–๐‘กโ„Ž^ round and ๐‘Ÿโˆ—^ the string chosen in the last round. We start with the following simple but crucial claim: Claim: The probability that ๐‘Ÿโˆ—^ = ๐‘Ÿ๐‘– for some ๐‘– is at most ๐‘‡ /2๐‘›. Proof of claim: For any particular ๐‘–, since ๐‘Ÿโˆ—^ is chosen indepen- dently of ๐‘Ÿ๐‘–, the probability that ๐‘Ÿโˆ—^ = ๐‘Ÿ๐‘– is 2 โˆ’๐‘›. Hence the claim fol- lows from the union bound. QED Given this claim we know that with probability 1 โˆ’ ๐‘‡ /2๐‘›^ (which is 1 โˆ’ ๐‘›๐‘’๐‘”๐‘™(๐‘›)), the string ๐‘Ÿโˆ—^ is distinct from any string that was chosen before. This means that by the lazy evaluation principle, if ๐‘“๐‘ (โ‹…) is a completely random function then the value ๐‘“๐‘ (๐‘Ÿโˆ—) can be thought

134 an intensive introduction to cryptography

a random map might not be a permutation, it is not possible to distinguish with a polynomial number of queries between a black box that computes a random function and a black box that computes a random permutation. Understanding why this is the case, and why this means that ?? is reasonable, is crucial to getting intuition to this notion, and so I suggest you pause now and make sure you understand these points.

As usual with a new concept, we want to know whether it is possi- ble to achieve it and whether it is useful. The former is established by the following theorem:

Theorem 5.6 โ€” PRPโ€™s from PRFs. If the PRF conjecture holds (and hence by Theorem 5.1 also if the PRG conjecture holds) then there exists a pseudorandom permutation collection.

Figure 5.9 : We build a PRP ๐‘ on 2๐‘› bits from three PRFs ๐‘“๐‘  1 , ๐‘“๐‘  2 , ๐‘“๐‘  3 on ๐‘› bits by letting ๐‘๐‘  1 ,๐‘  2 ,๐‘  3 (๐‘ฅ 1 , ๐‘ฅ 2 ) = (๐‘ง 1 , ๐‘ฆ 2 ) where ๐‘ฆ 1 = ๐‘ฅ 1 โŠ• ๐‘“๐‘  1 (๐‘ฅ 2 ), ๐‘ฆ 2 = ๐‘ฅ 2 โŠ• ๐‘“๐‘  2 (๐‘ฆ 1 ) and ๐‘ง 1 = ๐‘“๐‘  3 (๐‘ฆ 2 ) โŠ• ๐‘ฆ 1.

Proof. Fig. 5.9 illustrates the construction of a pseudorandom permu- tation from a pseudorandom function. The construction (known as the Luby-Rackoff construction) uses several rounds of what is known as the Feistel Transformation that maps a function ๐‘“ โˆถ {0, 1}๐‘›^ โ†’ {0, 1}๐‘›^ into a permutation ๐‘” โˆถ {0, 1}2๐‘›^ โ†’ {0, 1}2๐‘›^ using the map (๐‘ฅ, ๐‘ฆ) โ†ฆ (๐‘ฅ, ๐‘“(๐‘ฅ) โŠ• ๐‘ฆ). Specifically, given a PRF family {๐‘“๐‘ } with ๐‘›-bit keys, inputs, and outputs, our candidate PRP family will be called {๐‘๐‘  1 ,๐‘  2 ,๐‘  3 }. Here, ๐‘๐‘  1 ,๐‘  2 ,๐‘  3 โˆถ {0, 1}2๐‘›^ โ†’ {0, 1}2๐‘›^ is calculated on input (๐‘ฅ 1 , ๐‘ฅ 2 ) โˆˆ {0, 1}2๐‘› as follows (see Fig. 5.9):

  • First, map (๐‘ฅ 1 , ๐‘ฅ 2 ) โ†ฆ (๐‘ฆ 1 , ๐‘ฅ 2 ), where ๐‘ฆ 1 = ๐‘ฅ 1 โŠ• ๐‘“๐‘  1 (๐‘ฅ 2 ).

pseudorandom functions from pseudorandom generators and cpa security 135

  • Next, map (๐‘ฆ 1 , ๐‘ฅ 2 ) โ†ฆ (๐‘ฆ 1 , ๐‘ฆ 2 ), where ๐‘ฆ 2 = ๐‘ฅ 2 โŠ• ๐‘“๐‘  2 (๐‘ฆ 1 ).
  • Next, map (๐‘ฆ 1 , ๐‘ฆ 2 ) โ†ฆ (๐‘ง 1 , ๐‘ฆ 2 ), where ๐‘ง 1 = ๐‘ฆ 1 โŠ• ๐‘“๐‘  3 (๐‘ฆ 2 ).
  • Finally, output ๐‘๐‘  1 ,๐‘  2 ,๐‘  3 (๐‘ฅ 1 , ๐‘ฅ 2 ) = (๐‘ง 1 , ๐‘ฆ 2 ).

Each of the first three steps above corresponds to a single round of the Feistel transformation, which is easily seen to be both efficiently computable and efficiently invertible. In fact, we can efficiently calcu- late ๐‘๐‘ โˆ’1 1 ,๐‘  2 ,๐‘  3 (๐‘ง 1 , ๐‘ฆ 2 ) for an arbitrary string (๐‘ง 1 , ๐‘ฆ 2 ) โˆˆ {0, 1}2๐‘›^ by running the above three rounds of Feistel transformations in reverse order. Thus, the real challenge in proving Theorem 5.6 is not showing that {๐‘๐‘  1 ,๐‘  2 ,๐‘  3 } is a valid permutation, but rather showing that it is pseudorandom. The details of remainder of this proof are a bit technical, and can be safely skipped on a first reading. Intuitively, the argument goes like this. Consider an oracle ๐’ช for ๐‘๐‘  1 ,๐‘  2 ,๐‘  3 that answers an adversaryโ€™s query (๐‘ฅ 1 , ๐‘ฅ 2 ) by carrying out the three Feistel transformations outlined above and outputting (๐‘ง 1 , ๐‘ฆ 2 ). First, weโ€™ll show that with high probability, ๐’ช will never encounter the same intermediate string ๐‘ฆ 1 twice, over the course of all queries (unless the adversary makes a duplicate query). Since the string ๐‘ฆ 1 , calculated in Step 1, determines the input on which ๐‘“๐‘  2 is evaluated in Step 2, it follows that the strings ๐‘ฆ 2 calculated in Step 2 will appear to be chosen independently and at random. In particular, they too will be pairwise distinct with high probability. Since the string ๐‘ฆ 2 is in turn passed as input to ๐‘“๐‘  3 in Step 3, it follows that the strings ๐‘ง 1 encountered over the course of all queries will also appear to be chosen independently and at random. Ultimately, this means that the oracleโ€™s outputs (๐‘ง 1 , ๐‘ฆ 2 ) will look like freshly independent, random strings. To make this reasoning precise, notice first that it suffices to estab- lish the security of a variant of ๐‘๐‘  1 ,๐‘  2 ,๐‘  3 in which the pseudorandom functions ๐‘“๐‘  1 , ๐‘“๐‘  2 , and ๐‘“๐‘  3 used in the construction are replaced by truly random functions โ„Ž 1 , โ„Ž 2 , โ„Ž 3 โˆถ {0, 1}๐‘›^ โ†’ {0, 1}๐‘›. Call this vari- ant ๐‘โ„Ž 1 ,โ„Ž 2 ,โ„Ž 3. Indeed, the assumption that {๐‘“๐‘ } is a PRF collection tells us that making this change has only a negligible effect on the output of an adversary with oracle access to ๐‘. With this in mind, our job is to show that for every efficient adversary ๐ด, the difference | Pr[๐ด๐‘โ„Ž^1 ,โ„Ž^2 ,โ„Ž^3 (โ‹…)(1๐‘›) = 1] โˆ’ Pr[๐ด๐ป(โ‹…)(1๐‘›) = 1]| is negligible. In this expression, the first probability is taken over the choice of the random functions โ„Ž 1 , โ„Ž 2 , โ„Ž 3 โˆถ {0, 1}๐‘›^ โ†’ {0, 1}๐‘›^ used in the Feistel transfor- mation, and the second probability is taken over the random function ๐ป โˆถ {0, 1}2๐‘›^ โ†’ {0, 1}2๐‘›. To simplify matters, suppose without loss of generality that ๐ด always makes ๐‘ž(๐‘›) distinct queries to its oracle, de- noted (๐‘ฅ(1) 1 , ๐‘ฅ(1) 2 ), โ€ฆ , (๐‘ฅ(๐‘ž(๐‘›)) 1 , ๐‘ฅ(๐‘ž(๐‘›)) 2 ) in order. Similarly, let ๐‘ฆ(๐‘–) 1 , ๐‘ฆ(๐‘–) 2 , ๐‘ง(๐‘–) 1

pseudorandom functions from pseudorandom generators and cpa security 137

Figure 5.10 : A typical round of a block cipher, ๐‘˜๐‘– is the ๐‘–๐‘กโ„Ž^ round key, ๐‘ฅ๐‘– is the block before the ๐‘–๐‘กโ„Ž^ round and ๐‘ฅ๐‘–+1 is the block at the end of this round.

tel transformation does not suffice to achieve a PRP. Hint: consider an adversary that makes queries of the form (๐‘ฅ 1 , ๐‘ฅ 2 ) where ๐‘ฅ 2 is held fixed and ๐‘ฅ 1 is varied.

The more common name for a pseudorandom permutation is block cipher (though typically block ciphers are expected to meet additional security properties on top of being PRPs). The constructions for block ciphers used in practice donโ€™t follow the construction of Theorem 5. (though they use some of the ideas) but have a more ad-hoc nature. One of the first modern block ciphers was the Data Encryption Standard (DES) constructed by IBM in the 1970โ€™s. It is a fairly good cipher- to this day, as far as we know, it provides a pretty good num- ber of security bits compared to its key length. The trouble is that its key is only 56 bits long, which is no longer outside the reach of mod- ern computing power. (It turns out that subtle variants of DES are far less secure and fall prey to a technique known as differential crypt- analysis; the IBM designers of DES were aware of this technique but kept it secret at the behest of the NSA.) Between 1997 and 2001, the U.S. National Institute of Standards and Technology (NIST) ran a competition to replace DES which resulted in the adoption of the block cipher Rijndael as the new advanced encryption standard (AES). It has a block size (i.e., input length) of 128 bits and a key size (i.e., seed length) of 128, 196, or 256 bits. The actual construction of AES (or DES for that matter) is not ex- tremely illuminating, but let us say a few words about the general principle behind many block ciphers. They are typically constructed by repeating one after the other a number of very simple permuta- tions (see Fig. 5.10). Each such iteration is called a round. If there are ๐‘ก rounds, then the key ๐‘˜ is typically expanded into a longer string, which we think of as a ๐‘ก tuple of strings (๐‘˜ 1 , โ€ฆ , ๐‘˜๐‘ก) via some pseu- dorandom generator known as the key scheduling algorithm. The ๐‘–-th string in the tuple is known as the round key and is used in the ๐‘–๐‘กโ„Ž round. Each round is typically composed of several components: there is a โ€œkey mixing componentโ€ that performs some simple permu- tation based on the key (often as simply as XORโ€™ing the key), there is a โ€œmixing componentโ€ that mixes the bits of the block so that bits that were initially nearby donโ€™t stay close to one another, and then there is some non-linear component (often obtained by applying some simple non-linear functions known as โ€œS boxesโ€ to each small block of the input) that ensures that the overall cipher will not be an affine func- tion. Each one of these operations is an easily reversible operations, and hence decrypting the cipher simply involves running the rounds backwards.

138 an intensive introduction to cryptography

(^3) Partially this is because in the above construction we had to encode a plaintext of length ๐‘› with a ciphertext of length 2๐‘› meaning an overhead of 100 percent in the communication.

Figure 5.11 : In the Electronic Codebook (ECB) mode, every message is encrypted deterministically and independently

Figure 5.12 : An encryption of the Linux penguin (left image) using ECB mode (middle image) vs CBC mode (right image). The ECB encryption is insecure as it reveals much structure about the original image. Image taken from Wikipedia.

Figure 5.13 : In the Cypher-Block-Chaining (CBC) the encryption of the previous message is XORโ€™ed into the current message prior to encrypting. The first message is XORโ€™ed with an initialization vector (IV) that if chosen randomly, ensures CPA security.

5.3 ENCRYPTION MODES

How do we use a block cipher to actually encrypt traffic? Well we could use it as a PRF in the construction above, but in practice people use other ways.^3 The most natural approach would be that to encrypt a message ๐‘š, we simply use ๐‘๐‘ (๐‘š) where {๐‘๐‘ } is the PRP/block cipher. This is known as the electronic code book (ECB) mode of a block cipher (see Fig. 5.11). Note that we can easily decrypt since we can compute ๐‘โˆ’1๐‘  (๐‘š). If the PRP {๐‘๐‘ } only accepts inputs of a fixed length โ„“, we can use ECB mode to encrypt a message ๐‘š whose length is a multiple of โ„“ by writing ๐‘š = (๐‘š 1 , ๐‘š 2 , โ€ฆ , ๐‘š๐‘ก), where each block ๐‘š๐‘– has length โ„“, and then encrypting each block ๐‘š๐‘– separately. The ciphertext output by this encryption scheme is (๐‘๐‘ (๐‘š 1 ), โ€ฆ , ๐‘๐‘ (๐‘š๐‘ก)). A major drawback of ECB mode is that it is a deterministic encryption scheme and hence cannot be CPA secure. Moreover, this is actually a real problem of se- curity on realistic inputs (see Fig. 5.12), so ECB mode should never be used. A more secure way to use a block cipher to encrypt is the cipher block chaining (CBC) mode. The idea of cipher block chaining is to encrypt the blocks of a message ๐‘š = (๐‘š 1 , โ€ฆ , ๐‘š๐‘ก) sequentially. To encrypt the first block ๐‘š 1 , we XOR ๐‘š 1 with a random string known as the initialization vector , or IV , before applying the block cipher ๐‘๐‘ . To encrypt one of the later blocks ๐‘š๐‘–, where ๐‘– > 1, we XOR ๐‘š๐‘– with the encryption of ๐‘š๐‘–โˆ’1 before applying the block cipher ๐‘๐‘ . Formally, the ciphertext consists of the tuple ( IV , ๐‘ 1 , โ€ฆ , ๐‘๐‘ก), where IV is chosen uniformly at random and ๐‘๐‘– = ๐‘๐‘ (๐‘๐‘–โˆ’1 โŠ• ๐‘š๐‘–) for 1 โ‰ค ๐‘– โ‰ค ๐‘ก (we use the convention that ๐‘ 0 = IV ). This encryption process is depicted in Fig. 5.13. In order to decrypt ( IV , ๐‘ 1 , โ€ฆ , ๐‘๐‘ก), we simply calculate ๐‘š๐‘– = ๐‘โˆ’1๐‘  (๐‘๐‘–) โŠ• ๐‘๐‘–โˆ’1 for 1 โ‰ค ๐‘– โ‰ค ๐‘ก. Note that if we lose the block ๐‘๐‘– to traffic in the CBC mode, then we are unable to decrypt the next block ๐‘๐‘–+1, but we can recover from that point onwards. On the one hand, CBC mode is vastly superior to a simple elec- tronic codebook since CBC mode with a random IV is CPA secure (proving this is an excellent exercise). On the other hand, CBC mode suffers from the drawback that the encryption process cannot be par- allelized: the ciphertext block ๐‘๐‘– must be computed before ๐‘๐‘–+1. In the output feedback (OFB) mode we first encrypt the all zero string using CBC mode to get a sequence (๐‘ฆ 1 , ๐‘ฆ 2 , โ€ฆ) of pseudorandom outputs that we can use as a stream cipher. To transmit a message ๐‘š โˆˆ {0, 1}โˆ—, we send the XOR of ๐‘š with the bits output by this stream cipher, along with the IV used to generate the sequence. The receiver can decrypt a ciphertext ( IV , ๐‘) by first using IV to recover (๐‘ฆ 1 , ๐‘ฆ 2 , โ€ฆ), and then taking the XOR of ๐‘ with the appropriate number of bits

140 an intensive introduction to cryptography

One way to protect the movie data, which we model as a string ๐‘ฅ, is to provide consumers with a secure encryption ๐ธ๐‘˜(๐‘ฅ) of the data. Although the secret key ๐‘˜ used to encrypt the data is hidden from consumers, it is provided to device manufacturers so that they can embed it in their TVs and Blu-ray players in some secure, tamper- resistant manner. As long as the key ๐‘˜ is never leaked to the public, this system ensures that only approved devices can decrypt and play a consumerโ€™s copy of the movie. For this reason, we will sometimes refer to ๐‘˜ as the device key. This setup is depicted in Fig. 5.14.

Figure 5.14 : The problem setup for broadcast encryp- tion.

Unfortunately, if we were to implement this scheme exactly as written, it would almost certainly be broken in a matter of days. After all, as soon as even a single device is hacked, the device key ๐‘˜ would be revealed. This would allow the public to access our movieโ€™s data, as well as the data for all future movies we release for these devices! This latter consequence is one that we would certainly want to avoid, and doing so requires the notion of distinct, revocable keys:

Definition 5.8 โ€” Broadcast Encryption Scheme. For our purposes, a broad- cast encryption scheme consists of:

  • A set of ๐‘š distinct devices (or device manufacturers), each of which has access to one of the ๐‘›-bit device keys ๐‘˜ 1 , โ€ฆ , ๐‘˜๐‘š.
  • A decryption algorithm ๐ท that receives as input a ciphertext ๐‘ฆ and a key ๐‘˜๐‘–.

pseudorandom functions from pseudorandom generators and cpa security 141

  • An encryption algorithm ๐ธ that receives as input a plaintext ๐‘ฅ, a key ๐‘˜๐‘š๐‘Ž๐‘ ๐‘ก๐‘’๐‘Ÿ, and a revocation set ๐‘… โІ [๐‘š] of devices (or device manufacturers) that are no longer to be trusted.

Intuitively, a broadcast encryption scheme is secure if ๐ท๐‘˜๐‘– can suc- cessfully recover ๐‘ฅ from ๐ธ๐‘˜๐‘š๐‘Ž๐‘ ๐‘ก๐‘’๐‘Ÿ ,๐‘…(๐‘ฅ) whenever ๐‘– โˆ‰ ๐‘…, but fails to do so whenever ๐‘– โˆˆ ๐‘…. In our example of movie piracy, such an en- cryption scheme would allow us to revoke certain device keys ๐‘˜๐‘– when we find out that they have been leaked. To revoke a key ๐‘˜๐‘–, we would simply include ๐‘– โˆˆ ๐‘… when encrypting all future movies. Doing so prevents ๐‘˜๐‘– from being used to decrypt these movies. Crucially, revok- ing the key ๐‘˜๐‘– of the hacked device ๐‘– doesnโ€™t prevent a secure device ๐‘— โ‰  ๐‘– from continuing to perform decryption on future movie releases; this is exactly what we want in our system. For the sake of brevity, we will not provide a formal definition of security for broadcast encryption schemes, although this can and has been done. Instead, in the remainder of this section, we will describe a couple examples of broadcast encryption schemes, one of which makes clever use of a tree construction, as promised. The simplest construction of a broadcast encryption scheme in- volves letting ๐‘˜๐‘š๐‘Ž๐‘ ๐‘ก๐‘’๐‘Ÿ = (๐‘˜ 1 , โ€ฆ , ๐‘˜๐‘š) be the collection of all device keys and letting ๐ธ๐‘˜๐‘š๐‘Ž๐‘ ๐‘ก๐‘’๐‘Ÿ ,๐‘…(๐‘ฅ) be the concatenation over all ๐‘– โˆ‰ ๐‘… of a secure encryption ๐ธ๐‘˜๐‘– (๐‘ฅ). Device ๐‘– performs decryption by looking up the relevant substring ๐ธ๐‘˜๐‘– (๐‘ฅ) of the ciphertext and decrypting it with ๐‘˜๐‘–. Intuitively, with this scheme, if ๐‘ฅ represents our movie data and there are ๐‘š โ‰ˆ one million devices, then ๐ธ๐‘˜๐‘š๐‘Ž๐‘ ๐‘ก๐‘’๐‘Ÿ ,๐‘…(๐‘ฅ) is just an encryption of one million copies of the movie (one for each device key). Revok- ing the key ๐‘˜๐‘– amounts to only encrypting 999, 999 copies of all future movies, so that device ๐‘– can no longer perform decryption. Clearly, this simple solution to the broadcast encryption prob- lem has two serious inefficiencies: the length of the master key is ๐‘‚(๐‘›๐‘š), and the length of each encryption is ๐‘‚(|๐‘ฅ|๐‘š). One way to address the former problem is to use a key derivation function. That is, we can shorten the master key by choosing a fixed PRF collection {๐‘“๐‘˜}, and calculating each device key ๐‘˜๐‘– by the rule ๐‘˜๐‘– = ๐‘“๐‘˜๐‘š๐‘Ž๐‘ ๐‘ก๐‘’๐‘Ÿ (๐‘–). The latter problem can be addressed using a technique known as hybrid encryption. In hybrid encryption, we encrypt ๐‘ฅ by first choos- ing an ephemeral key ๐‘˜ โ†ฬ‚ ๐‘… {0, 1}๐‘›, encrypting ๐‘˜ฬ‚ using each device key ๐‘˜๐‘– where ๐‘– โˆ‰ ๐‘…, and then outputting the concatenation of these strings ๐ธ๐‘˜๐‘– (ฬ‚๐‘˜), along with a single encryption ๐ธ๐‘˜ฬ‚(๐‘ฅ) of the movie us- ing the ephermal key. Incorporating these two optimizations reduces the length of ๐‘˜๐‘š๐‘Ž๐‘ ๐‘ก๐‘’๐‘Ÿ to ๐‘‚(๐‘›) and the length of each encryption to ๐‘‚(๐‘›๐‘š + |๐‘ฅ|).

pseudorandom functions from pseudorandom generators and cpa security 143

5.5 READING COMPREHENSION EXERCISES

I recommend students do the following exercises after reading the lecture. They do not cover all material, but can be a good way to check your understanding.

Exercise 5.1 Let (๐ธ, ๐ท) be the encryption scheme that we saw in Lec- ture 2 where ๐ธ๐‘˜(๐‘š) = ๐บ(๐‘˜) โŠ• ๐‘š where ๐บ(โ‹…) is a pseudorandom generator. Is this scheme CPA secure?

a. No it is never CPA secure. b. It is always CPA secure. c. It is sometimes CPA secure and sometimes not, depending on the properties of the PRG ๐บ

โ– 

Exercise 5.2 Consider the proof constructing PRFs from PRGs. Up to an order of magnitude, how many invocations of the underlying pseudorandom generator does the pseudorandom function collection make when queried on an input ๐‘– โˆˆ {0, 1}๐‘›?

a. ๐‘› b. ๐‘›^2 c. 1 d. 2 ๐‘›

โ– 

Exercise 5.3 In the following we identify a block cipher with a pseudo- random permutation (PRP) collection. Which of these statements is true:

a. Every PRP collection is also a PRF collection b. Every PRF collection is also a PRP collection c. If {๐‘“๐‘ } is a PRP collection then the encryption scheme ๐ธ๐‘ (๐‘š) = ๐‘“๐‘ (๐‘š) is a CPA secure encryption scheme. d. If {๐‘“๐‘ } is a PRF collection then the encryption scheme ๐ธ๐‘ (๐‘š) = ๐‘“๐‘ (๐‘š) is a CPA secure encryption scheme.

โ–