








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









(^1) We will often identify the strings of length ๐ with the numbers between 0 and 2 ๐โ1, and switch freely between the two representations, and hence can think of ๐ also as a string in {0, 1}๐. We will also switch between indexing strings starting from 0 and starting from 1 based on convenience.
Reading: Rosulek Chapter 6 has a good description of pseudorandom functions. Katz-Lindell cover pseudorandom functions in a different order than us. The topics of this lecture and the next ones are covered in KL sections 3.4-3.5 (PRFs and CPA security), 4.1-4.3 (MACs), and 8.5 (construction of PRFs from PRG). In the last lecture we saw the notion of pseudorandom generators , and introduced the PRG conjecture , which stated that there exists a pseu- dorandom generator mapping ๐ bits to ๐ + 1 bits. We have seen the length extension theorem, which states that given such a pseudoran- dom generator, there exists a generator mapping ๐ bits to ๐ bits for an arbitrarily large polynomial ๐(๐). But can we extend it even further? Say, to 2 ๐^ bits? Does this question even make sense? And why would we want to do that? This is the topic of this lecture. At a first look, the notion of extending the output length of a pseu- dorandom generator to 2 ๐^ bits seems nonsensical. After all, we want our generator to be efficient and just writing down the output will take exponential time. However, there is a way around this conundrum. While we canโt efficiently write down the full output, we can require that it would be possible, given an index ๐ โ {0, โฆ , 2๐^ โ 1}, to compute the ๐๐กโ^ bit of the output in polynomial time.^1 That is, we require that the function ๐ โฆ ๐บ(๐ )๐ is efficiently computable and (by security of the pseudorandom generator) indistinguishable from a function that maps each index ๐ to an independent random bit in {0, 1}. This is the notion of a pseudorandom function generator which is a bit subtle to de- fine and construct, but turns out to have a great many applications in cryptography.
Definition 4.1 โ Pseudorandom Function Generator. An efficiently com- putable function ๐น taking two inputs ๐ โ {0, 1}โ^ and ๐ โ {0, โฆ , 2|๐ |โ 1} and outputting a single bit ๐น (๐ , ๐) is a pseudorandom function
Compiled on 11.17.2021 22:
112 an intensive introduction to cryptography
(^2) This also allows us to be consistent with the notion of โpolynomial in the size of the input.โ
(PRF) generator if for every polynomial time adversary ๐ด out- putting a single bit and polynomial ๐(๐), if ๐ is large enough then:
๐ โ{0,1}๐
๐ปโ๐ [2๐]โ{0,1}
Some notes on notation are in order. The input 1 ๐^ is simply a string of ๐ ones, and it is a typical cryptography convention to assume that such an input is always given to the adversary. This is simply be- cause by โpolynomial time adversaryโ we really mean polynomial in ๐ (which is our key size or security parameter)^2. The notation ๐ด๐น (๐ ,โ ) means that ๐ด has black box (also known as oracle ) access to the func- tion that maps ๐ to ๐น (๐ , ๐). That is, ๐ด can choose an index ๐, query the box and get ๐น (๐ , ๐), then choose a new index ๐โฒ, query the box to get ๐น (๐ , ๐โฒ), and so on for a polynomial number of queries. The notation ๐ป โ๐ [2๐] โ {0, 1} means that ๐ป is a completely random function that maps every index ๐ to an independent and random different bit.
R Remark 4.2 โ Completely Random Functions. This no- tion of a randomly chosen function can be difficult to wrap your mind around. Try to imagine a table of all of the strings in {0, 1}๐. We now go to each possible input, randomly generate a bit to be its output, and write down the result in the table. When weโre done, we have a length 2 ๐^ lookup table that maps each input to an output that was generated uniformly at random and independently of all other outputs. This lookup table is now our random function ๐ป. In practice itโs too cumbersome to actually generate all 2 ๐^ bits, and sometimes in theory itโs convenient to think of each output as generated only after a query is made. This leads to adopting the lazy evaluation model. In the lazy evaluation model, we imagine that a lazy person is sitting in a room with the same lookup table as before, but with all entries blank. If someone makes some query ๐ป(๐ ), the lazy person checks if the entry for ๐ in the lookup table is blank. If so, the lazy evalu- ator generates a random bit, writes down the result for ๐ , and returns it. Otherwise, if an output has already been generated for ๐ previously (because ๐ has been queried before), the lazy evaluator simply returns this value. Can you see why this model is more convenient in some ways? One last way to think about how a completely random function is determined is to first observe that there exist a total of 22 ๐ functions from {0, 1}๐^ to {0, 1} (can you see why? It may be easier to think of them as functions from [2๐] to {0, 1}). We choose one of them
114 an intensive introduction to cryptography
that on input ๐ โ {0, 1}โ^ and ๐ โ {0, โฆ , 2|๐ |^ โ 1} outputs ๐๐ (๐) is a PRF generator.
Note that the condition of Definition 4.3 corresponds to requiring that for every polynomial ๐ and ๐(๐)-time adversary ๐ด, if ๐ is large enough then
๐ โฑ๐,
where โฑ๐,1 is the set of all functions mapping {0, 1}๐^ to {0, 1} (i.e., the set {0, 1}๐^ โ {0, 1}).
P It is worth while to pause and make sure you un- derstand why Definition 4.3 and Definition 4.1 give different ways to talk about the same object.
Figure 4.1 : In a pseudorandom function, an adversary cannot tell whether they are given a black box that computes the function ๐ โฆ ๐น (๐ , ๐) for some secret ๐ that was chosen at random and fixed, or whether the black box computes a completely random function that tosses a fresh random coin whenever itโs given a new input ๐.
In the next lecture we will see the proof of following theorem (due to Goldreich, Goldwasser, and Micali)
Theorem 4.4 โ PRFs from PRGs. Assuming the PRG conjecture, there exists a secure pseudorandom function generator.
But before we see the proof of Theorem 4.4, let us see why pseudo- random functions could be useful.
pseudorandom functions 115
4.1 ONE TIME PASSWORDS (E.G. GOOGLE AUTHENTICATOR, RSA ID, ETC.)
Until now we have talked about the task of encryption , or protecting the secrecy of messages. But the task of authentication , or protecting the integrity of messages is no less important. For example, consider the case that you receive a software update for your PC, phone, car, pacemaker, etc. over an open channel such as an unencrypted Wi- Fi connection. The contents of that update are not secret, but it is of crucial importance that it was unchanged from the message sent out by the company and that no malicious attacker had modified the code. Similarly, when you log into your bank, you might be much more concerned about the possibility of someone impersonating you and cleaning out your account than you are about the secrecy of your information. Letโs start with a very simple scenario which weโll call the login problem. Alice and Bob share a key as before, but now Alice wants to simply prove her identity to Bob. What makes this challenging is that this time they need to contend with not the passive eavesdropping Eve but the active adversary Mallory , who completely controls the communication channel between them and can modify (or mall ) any message that they send. Specifically for the identity proving case, we think of the following scenario. Each instance of such an identifica- tion protocol consists of some interaction between Alice and Bob that ends with Bob deciding whether to accept it as authentic or reject as an impersonation attempt. Malloryโs goal is to fool Bob into accepting her as Alice. The most basic way to try to solve the login problem is by simply using a password. That is, if we assume that Alice and Bob can share a key, we can treat this key as some secret password ๐ that was se- lected at random from {0, 1}๐^ (and hence can only be guessed with probability 2 โ๐). Why doesnโt Alice simply send ๐ to Bob to prove to him her identity? A momentโs thought shows that this would be a very bad idea. Since Mallory is controlling the communication line, she would learn ๐ after the first identification attempt and could then easily impersonate Alice in future interactions. However, we seem to have just the tool to protect the secrecy of ๐โ encryption. Suppose that Alice and Bob share a secret key ๐ and an additional secret password ๐. Wouldnโt a simple way to solve the login problem be for Alice to send Bob an encryption of the password ๐? After all, the security of the encryption should guarantee that Mallory canโt learn ๐, right?
P
pseudorandom functions 117
an actual random function instead of a pseudo random function. In a truly random function, every one of the values ๐๐ (0), โฆ , ๐๐ (2๐^ โ 1) is chosen independently and uniformly at random from {0, 1}. One useful way to imagine this is using the concept of โlazy evaluationโ. We can think of ๐๐ as determined by tossing 2 ๐^ different coins for the values ๐(0), โฆ , ๐(2๐^ โ 1). Now consider the case where we donโt actually toss the ๐๐กโ^ coin until we need it. The crucial point is that if we have queried the function in ๐ โช 2๐^ places, then when Bob chooses a random ๐ โ [2๐] it is extremely unlikely that any one of the set {๐, ๐ + 1, โฆ , ๐ + โ โ 1} will be one of those locations that we pre- viously queried. Thus, if the function was truly random, Mallory has no information on the value of the function in these coordinates, and would be able to predict (or rather, guess) it in all these locations with probability at most 2 โโ.
P Please make sure you understand the informal rea- soning above, since we will now translate this into a formal theorem and proof.
Theorem 4.5 โ Login protocol via PRF. Suppose that {๐๐ } is a secure pseudorandom function generator and Alice and Bob interact us- ing Protocol PRF-Login for some polynomial number ๐ of sessions (over a channel controlled by Mallory). After observing these in- teractions, Mallory then interacts with Bob, where Bob follows the protocolโs instructions but Mallory has access to arbitrary efficient computation. Then, the probability that Bob accepts the interaction is at most 2 โโ^ + ๐(๐) where ๐(โ ) is some negligible function.
Proof. This proof, as so many others in this course, uses an argument via contradiction. We assume, towards the sake of contradiction, that there exists an adversary ๐ (for Mallory) that can break the identifi- cation scheme PRF-Login with probability 2 โโ^ + ๐ after ๐ interactions. We then construct an attacker ๐ด that can distinguish access to {๐๐ } from access to a random function in ๐๐๐๐ฆ(๐ ) time and with bias at least ๐/2. How do we construct this adversary ๐ด? The idea is as follows. First, we prove that if we ran the protocol PRF-Login using an actual random function, then ๐ would not be able to succeed in impersonating with probability better than 2 โโ^ + ๐๐๐๐๐๐๐๐๐๐. Therefore, if ๐ does do better, then we can use that to distinguish ๐๐ from a random function. The adversary ๐ด gets some black box ๐(โ ) (for oracle ) and will use it while internally simulating all the partiesโ Alice, Bob and Mallory (using ๐ ) in the ๐ + 1 interactions of the PRF-Login protocol. Whenever any
118 an intensive introduction to cryptography
of the parties needs to evaluate ๐๐ (๐), ๐ด will forward ๐ to its black box ๐(โ ) and return the value ๐(๐). It will then output 1 if and only if ๐ succeeds in impersonation in this internal simulation. The argument above showed that if ๐(โ ) is a truly random function, then the proba- bility that ๐ด outputs 1 is at most 2 โโ^ + ๐๐๐๐๐๐๐๐๐๐ (and so in particular less than 2 โโ^ + ๐/2). On the other hand, if ๐(โ ) is the function ๐ โฆ ๐๐ (๐) for some fixed and random ๐ , then this probability is at least 2 โโ^ + ๐. Thus ๐ด will distinguish between the two cases with bias at least ๐/2. We now turn to the formal proof: Claim 1: Let PRF-Login* be the hypothetical variant of the protocol PRF-Login where Alice and Bob share a completely random function ๐ป โถ [2๐] โ {0, 1}. Then, no matter what Mallory does, the probability she can impersonate Alice after observing ๐ interactions is at most 2 โโ^ + (8โ๐ )/2๐. (If PRF-Login* is easier to prove secure than PRF-Login, you might wonder why we bother with PRF-Login in the first place and not sim- ply use PRF-Login. The reason is that specifying a random function ๐ป requires specifying 2 ๐^ bits, and so that would be a huge shared key. So PRF-Login is not a protocol we can actually run but rather a hy- pothetical โmental experimentโ that helps us in arguing about the security of PRF-Login.) Proof of Claim 1: Let ๐ 1 , โฆ , ๐2๐ be the nonces chosen by Bob and recieved by Alice in the first ๐ iterations. That is, ๐ 1 is the nonce cho- sen by Bob in the first iteration while ๐ 2 is the nonce that Alice re- ceived in the first iteration (if Mallory doesnโt modify it then ๐ 1 = ๐ 2 ). Similarly, ๐ 3 is the nonce chosen by Bob in the second iteration while ๐ 4 is the nonce received by Alice and so on and so forth. Let ๐ be the nonce chosen in the ๐ + 1๐ ๐ก^ iteration in which Mallory tries to im- personate Alice. We claim that the probability that there exists some ๐ โ {1, โฆ , 2๐ } such that |๐ โ ๐๐| < 2โ is at most 8โ๐ /2๐. Indeed, let ๐ be the union of all the intervals of the form {๐๐ โ 2โ + 1, โฆ , ๐๐ + 2โ โ 1} for 1 โค ๐ โค 2๐. Since itโs a union of 2๐ intervals each of length less than 4โ, ๐ contains at most 8๐ โ elements, so the probability that ๐ โ ๐ is |๐|/2๐^ โค (8๐ โ)/2๐. Now, if there does not exists a ๐ such that |๐โ๐๐| < 2โ then it means in particular that all the queries to ๐ป(โ ) made by either Alice or Bob during the first ๐ iterations are disjoint from the interval {๐, ๐ + 1, โฆ , ๐ + โ โ 1}. Since ๐ป(โ ) is a completely random function, the values ๐ป(๐), โฆ , ๐ป(๐ + โ โ 1) are chosen uniformly and independently from all the rest of the values of this function. Since Malloryโs message ๐ฆ to Bob in the ๐ + 1๐ ๐ก^ iteration depends only on what she observed in the past, the values ๐ป(๐), โฆ , ๐ป(๐ + โ โ 1) are inde- pendent from ๐ฆ, and hence under the condition that there is no overlap between this interval and prior queries, the probability that they equal ๐ฆ is 2 โโ. QED (Claim 1).
120 an intensive introduction to cryptography
Theorem 4.7 โ PRF length extension. Suppose that PRFs exist. Then for every constant ๐ and polynomial-time computable functions โin, โout โถ โ โ โ with โin(๐), โout(๐) โค ๐๐, there exist a PRF ensem- ble with input length โin and output length โout.
Thus from now on whenever we are given a PRF, we will allow ourselves to assume that it has any polynomial output size that is convenient for us.
4.2 MESSAGE AUTHENTICATION CODES
One time passwords are a tool allowing you to prove your identity to, say, your email server. But even after you did so, how can the server trust that future communication comes from you and not from some attacker that can interfere with the communication channel between you and the server (so called โman in the middleโ attack)? Similarly, one time passwords may allow a software company to prove their identity before they send you a software update, but how do you know that an attacker does not change some bits of this software update on route between their servers and your device? This is where Message Authentication Codes (MACs) come into play- their role is to authenticate not only the identity of the parties but also their communication. Once again we have Alice and Bob , and the adversary Mallory who can actively modify messages (in contrast to the passive eavesdropper Eve). Similar to the case to encryption, Alice has a message ๐ she wants to send to Bob, but now we are not concerned with Mallory learning the contents of the message. Rather, we want to make sure that Bob gets precisely the message ๐ sent by Alice. Actually this is too much to ask for, since Mallory can always decide to block all communication, but we can ask that either Bob gets precisely ๐ or he detects failure and accepts no message at all. Since we are in the private key setting, we assume that Alice and Bob share a key ๐ that is unknown to Mallory. What kind of security would we want? We clearly want Mallory not to be able to cause Bob to accept a message ๐โฒ^ โ ๐. But, like in the encryption setting, we want more than that. We would like Alice and Bob to be able to use the same key for many messages. So, Mallory might observe the interactions of Alice and Bob on messages ๐ 1 , โฆ , ๐๐ before trying to cause Bob to accept a message ๐โฒ๐ +1 โ ๐๐ +1. In fact, to make our notion of security more robust, we will even allow Mallory to choose the messages ๐ 1 , โฆ , ๐๐ (this is known as a chosen message or chosen plaintext attack). The resulting formal definition is below:
pseudorandom functions 121
(^3) Clearly if the adversary outputs a pair (๐, ๐) that it did query from its oracle then that pair will pass verification. This suggests the possibility of a replay attack whereby Mallory resends to Bob a message that Alice sent him in the past. As above, one can thwart this by insisting the every message ๐ begins with a fresh nonce or a value derived from the current time.
(^4) A priori you might ask if we should not also give Mallory an oracle to ๐๐(โ ) as well. After all, in the course of those many interactions, Mallory could also send Bob many messages (๐โฒ, ๐โฒ) of her choice, and observe from his behavior whether or not these passed verification. It is a good exercise to show that adding such an oracle does not change the power of the definition, though we note that this is decidedly not the case in the analogous question for encryption.
Definition 4.8 โ Message Authentication Codes (MAC). Let (๐, ๐ ) (for sign and verify ) be a pair of efficiently computable algorithms where ๐ takes as input a key ๐ and a message ๐, and produces a tag ๐ โ {0, 1}โ, while ๐ takes as input a key ๐, a message ๐, and a tag ๐ , and produces a bit ๐ โ {0, 1}. We say that (๐, ๐ ) is a Message Authentication Code (MAC) if:
If Alice and Bob share the key ๐, then to send a message ๐ to Bob, Alice will simply send over the pair (๐, ๐) where ๐ = ๐๐(๐). If Bob receives a message (๐โฒ, ๐ โฒ), then he will accept ๐โฒ^ if and only if ๐๐(๐โฒ, ๐ โฒ) = 1. Mallory now observes ๐ก rounds of communication of the form (๐๐, ๐๐(๐๐)) for messages ๐ 1 , โฆ , ๐๐ก of her choice, and her goal is to try to create a new message ๐โฒ^ that was not sent by Alice, but for which she can forge a valid tag ๐ โฒ^ that will pass verification. Our notion of security guarantees that sheโll only be able to do so with negligible probability, in which case the MAC is CMA-secure.^4
R Remark 4.9 โ Why can Mallory choose the messages?. The notion of a โchosen message attackโ might seem a little โover the topโ. After all, Alice is going to send to Bob the messages of her choice, rather than those chosen by her adversary Mallory. However, as cryp- tographers have learned time and again the hard way, it is better to be conservative in our security defini- tions and think of an attacker that has as much power as possible. First of all, we want a message authentica- tion code that will work for any sequence of messages, and so itโs better to consider this โworst caseโ setting of allowing Mallory to choose them. Second, in many realistic settings an adversary could have some effect on the messages that are being sent by the parties. This has occurred time and again in cases ranging from web servers to German submarines in World War II, and weโll return to this point when we talk about chosen plaintext and chosen ciphertext attacks on encryption schemes.
pseudorandom functions 123
(^5) This discussion has more to do with computational complexity than cryptography, and so can be safely skipped without harming understanding of future material in this course.
output 1 with probability 1/๐(๐). That means that such an adversary ๐ดโฒ^ can distinguish between an oracle to ๐น (๐, โ ) and an oracle to a random function ๐ป, which gives us a contradiction. โ
4.4 ARBITRARY INPUT LENGTH EXTENSION FOR MACS AND PRFS
So far we required the message to be signed ๐ to be no longer than the key ๐ (i.e., both ๐ bits long). However, it is not hard to see that this requirement is not really needed. If our message is longer, we can divide it into blocks ๐ 1 , โฆ , ๐๐ก and sign each message (๐, ๐๐) individually. The disadvantage here is that the size of the tag (i.e., MAC output) will grow with the size of the message. However, even this is not really needed. Because the tag has length ๐/2 for length ๐ messages, we can sign the tags ๐ 1 , โฆ , ๐๐ก and only output those. The verifier can repeat this computation to verify this. We can continue this way and so get tags of ๐(๐) length for arbitrarily long messages. Hence in the future, whenever we need to, we can assume that our PRFs and MACs can get inputs in {0, 1}โ^ โ i.e., arbitrarily length strings. We note that this issue of length extension is actually quite a thorny and important one in practice. The above approach is not the most efficient way to achieve this, and there are several more practical vari- ants in the literature (see Boneh-Shoup Sections 6.4-6.8). Also, one needs to be very careful on the exact way one chops the message into blocks and pads it to an integer multiple of the block size. Several at- tacks have been mounted on schemes that performed this incorrectly.
4.5 ASIDE: NATURAL PROOFS
Pseudorandom functions play an important role in computational complexity, where they have been used as a way to give โbarrier re- sultsโ for proving results such as P โ NP.^5 Specifically, the Natural Proofs barrier for proving circuit lower bounds says that if strong enough pseudorandom functions exist, then certain types of argu- ments are bound to fail. These are arguments which come up with a property EASY of a Boolean function ๐ โถ {0, 1}๐^ โ {0, 1} such that:
124 an intensive introduction to cryptography
A priori these technical conditions might not seem very โnatu- ralโ but it turns out that many approaches for proving circuit lower bounds (for restricted families of circuits) have this form. The idea is that such approaches find a โnon genericโ property of easily com- putable function, such as finding some interesting correlations be- tween the some input bits and the output. These are correlations that are unlikely to occur in random functions. The lower bound typically follows by exhibiting a function ๐ 0 that does not have this property, and then using that to derive that ๐ 0 cannot be efficiently computed by this particular restricted family of circuits. The existence of strong enough pseudorandom functions can be shown to contradict the existence of such a property EASY , since a pseudorandom function can be computed by a polynomial sized cir- cuit, but it cannot be distinguished from a random function. While a priori a pseudorandom function is only secure for polynomial time distinguishers, under certain assumptions it might be possible to cre- ate a pseudorandom function with a seed of size, say, ๐^5 , that would be secure with respect to adversaries running in time 2 ๐(๐^2 ).