This course will introduce you to the foundations of modern cryptography, with an eye toward practical applications.

Loading...

From the course by University of Maryland, College Park

Cryptography

415 ratings

This course will introduce you to the foundations of modern cryptography, with an eye toward practical applications.

From the lesson

Week 3

Private-Key Encryption

- Jonathan KatzProfessor, University of Maryland, and Director, Maryland Cybersecurity Center

Maryland Cybersecurity Center

In this lecture,

Â we're going to study the important primitive of pseudorandom functions and

Â their practical instantiation via block ciphers.

Â Informally, a pseudorandom function is something that

Â looks like a random function.

Â So before we can talk more about pseudorandom functions let's first make

Â sure we understand something about random functions.

Â Let's define Funcn to be a set

Â containing all functions mapping strings of length n to strings of length n.

Â The first thing we can ask is, how big is this set?

Â How big is the set Funcn?

Â Well, we can specify any function by its inputs and their corresponding outputs.

Â So here, for the case of n equals 3, I've drawn a table specifying for

Â each possible three bit input, a corresponding three bit output.

Â So the string 000 maps onto the string 011 and so on.

Â Now in fact, you can notice that the first column here is redundant.

Â We don't need to store the list of inputs in their lexicographic order,

Â we can instead just let that be implicit by the ordering in the table itself.

Â So now we just have a single column,

Â a large array containing in each entry a three-bit string.

Â And just as before, we can say that the first input, i.e 000,

Â maps onto the first value in this array, i.e 010, and

Â so on, up until the last possible 3-bit input, 111.

Â Which maps onto the last element of this array, in this case, 000.

Â So we have this array containing 3-bit values.

Â And this array is of size, two to the third.

Â Right, because we have all possible three-bit inputs.

Â There are two to the three such inputs.

Â So we have a total of eight inputs or eight values, rather in our array.

Â In general, we can represent a function from n bit inputs on to

Â n bit outputs by a similar array.

Â Where the array is going to be now of length 2 to the n.

Â With one entry corresponding to every possible n-bit input.

Â And each entry of that array containing an n-bit value,

Â representing the corresponding output.

Â So we can represent the function in Funcn using exactly n times 2 to the n bits.

Â Again that's an array of length 2 to the n with an n-bid

Â entry in each element of the array.

Â Since we have also a correspondence in the other direction, that is,

Â if I take any array of length 2 to the n,

Â containing n-bit strings in each entry, that defines a function in Funcn.

Â And this is in fact a one to one mapping from arrays of length n sorry,

Â arrays of length 2 to the n containing strings of

Â length n to functions from n-bit inputs to n-bit outputs.

Â That tells us that the size of Funcn is exactly equal to the number of

Â strings of length n times 2 to the n.

Â That is the size the Funcn is just 2 to the n times 2 to the n.

Â Note that this is huge, this is doubly exponential in our parameter n.

Â But never the less it's a finite set.

Â So there's nothing funny going on we don't have to worry about

Â continuous probabilities or continuous random variables, or anything like that,

Â we're still on the setting of a very large, but still finite set.

Â Now when I talk about a random function, what I really mean is a uniform function.

Â But I'm just allowing myself to be a bit informal.

Â So what do we mean more carefully speaking by a random function or

Â by a uniform function?

Â Well, very simply this means that we

Â choose a uniform function in this finite set, Funcn.

Â So when you talk about a random function from n-bit inputs to n-bit outputs,

Â I mean we just pick a uniform function, a uniform member of this set Funcn.

Â Its a little bit difficult to think about this or to conceptualize what that means.

Â So we can think about in an alternate way.

Â This is exactly equivalent to just filling out the function table we

Â saw on the previous slide, with a uniform value in every entry.

Â That is, we can imagine starting with a blank table, and then for each possible

Â input that is each possible x of length n, we simply choose the corresponding

Â entry in the table corresponding to the value of the function on that input.

Â With a uniform value in 0,1 to the n.

Â That is we imagine having a table of length 2 to the n.

Â And we simply fill in every entry with a random or a uniform n-bit string.

Â Now in fact rather than thinking about this being done all at once, we can

Â also equivalently think about this being done on the fly as values are needed.

Â That is I can it's equivalent to me choosing a uniform f, and then,

Â probing the value of that function on a bunch of different points, x1, x2, x3.

Â That's equivalent to starting with an empty table, and then when asked for

Â the value of f of x1, I simply fill in the value with that position of

Â the table with a uniform n-bit string.

Â And so on for x2 and x3.

Â Just being careful that if I'm ever asked for the value of f of x1 again,

Â I'm consistent and I choose to return the same value that I returned before.

Â So the point is that there are these two equivalent, or

Â three I guess equivalent ways of thinking about what it means

Â to choose a uniform function from n-bit inputs to n-bit outputs.

Â Now again, a pseudorandom function,

Â is intuitively a function that looks like a uniform function or a random function.

Â But as in our discussion of pseudorandom generators.

Â It doesn't make sense to talk about any fixed function being pseudorandom.

Â And what we're going to do, to do instead is look at keyed functions, which allow us

Â to define a distribution over functions from n-bit inputs to n-bit outputs.

Â So let's let capital F be a function that now takes two inputs and

Â produces one output.

Â And we'll always assume that this F is efficiently computable.

Â That is, it's computable in polynomial time in the length of both of its inputs.

Â We'll define the reduced function F sub k,

Â to be the function mapping n-bit strings, n-bit inputs to n-bit outputs,

Â where we define it by F sub k of x is equal to F of k, x.

Â So we're just basically imagining fixing the first input to capital F,

Â to some fixed value k.

Â Now this fixed first input is going to be called a key and

Â that's why I've denoted it by k.

Â We're going to assume throughout just for simplicity that F is length-preserving.

Â This means that F k of x is only defined if the length of k

Â is equal to the length of x.

Â In which case the length of the output is equal to the length of each of the inputs.

Â Thinking a little bit ahead and thinking in terms of cryptography, this just means

Â that for every value of the security parameter n, we have F defined for keys of

Â length n and inputs of length n, and then producing outputs of length n as well.

Â Now the important thing to know here,

Â is that if we choose a uniform key of length n.

Â Then that is equivalent to choosing the function F sub k,

Â mapping endbit inputs to n-bit outputs.

Â So by choosing a uniform key,

Â we're choosing a function according to some distribution.

Â We can now define a little bit more carefully what we mean by

Â a pseudorandom function.

Â So we'll say that this two input function F, is a pseudorandom function.

Â If F sub k for

Â uniform choice of the key is indistinguishable from a uniform function.

Â More formally, we require that for every polynomial time distinguisher D.

Â D cannot distinguish between the case when it's given what's called oracle access

Â to F sub k, or when it's given oracle access to a completely uniform function f.

Â That is on the left hand side here we have the probability that D returns 1.

Â When D is given access to the function F sub k.

Â Where k is chosen uniformly, giving D access to

Â this function means that we allow D to provide inputs to the function and

Â get back the corresponding outputs, but D can't look inside the function as it were.

Â And in particular can't see anything about the value k being used other than what it

Â can potentially learn from the inputs and outputs that it sees.

Â We compared that to the probability that D outputs 1 when it's

Â given oracle access to a function F chosen uniformly from the set of all functions.

Â On n-bit inputs, and producing n-bit outputs.

Â And we'll, we'll define that capital F is a pseudorandom function

Â if those probabilities are close for every polynomial time D.

Â That is, if the difference between the probabilities that D outputs 1 in

Â those two cases is negligible.

Â It might be a little bit easier to understand the definition,

Â at least on an intuitive level, by looking at a picture.

Â So here we have a polynomial time, distinguisher D, and

Â that distinguisher is going to try to tell the difference between two possibilities.

Â In the first case, what we do is we imagine choosing a function, f uniformly

Â at random from the set of all functions on n-bit inputs and having n-bit outputs.

Â What it means for the attacker to interact with this function is that the attacker

Â can specify inputs of his choice, and get back the corresponding outputs.

Â It can do this adaptively, that is it can choose its

Â next input x2 based on the output f of x1 that it receives.

Â And it can do this as many times as it likes.

Â One thing I'll note is that there's no real point for the attacker to

Â ever repeat an input because it knows that it'll get back the same output.

Â The only randomness here is in the initial choice of F.

Â But once we choose an F and fix it inside the box, f is then a deterministic

Â function that always returns the same output when given any input.

Â We're going to compare that situation to a situation where what we do is choose

Â a uniform key k and then put the function F sub k inside of a box.

Â And we allow the attacker to interact with that box.

Â Again, by submitting inputs and getting the corresponding outputs.

Â As in the first case, it can do this as many times as it likes,

Â adaptively fusing whatever inputs it wants to feed into the box.

Â And we'll say that capital F is a pseudorandom function.

Â If these two worlds, world 0 and world 1,

Â are indistinguishable from the point of the attacker.

Â That is, the attacker can't tell whether it's interacting with a black box

Â containing a, an F chosen uniformly from the set of all functions in Funcn.

Â Or if it's interacting with a box containing F sub k.

Â For a uniformly chosen key k.

Â One thing I want to stress is that in the first case in,

Â in world 0, that function f is being chosen from a huge space of possibilities.

Â Remember the size of func n was 2 to the n times 2 to the n.

Â W explanation to n.

Â Where then the bottom the number of possibilities for

Â f k is at most 2 to the n because k is an n-bit key.

Â And so there are, there are most 2 to the n choices for k.

Â So on the top we have a distribution over a doubly

Â exponential size set of functions.

Â And on the bottom we have the sub-distribution over an exponential size

Â set of functions.

Â Nevertheless capital F is pseudorandom if the attacker can't distinguish these two

Â possibilities apart.

Â [SOUND] Now we can try to connect our

Â notion of pseudorandom functions with the earlier notion of pseudorandom generators.

Â And if you think about it a pseudorandom function is actually much stronger than

Â a pseudorandom generator.

Â And it immediately implies,

Â in particular, a construction of a pseudorandom generator.

Â That is if we have pseudo random function f

Â then we can very easily define the following pseudo random generator.

Â G on input of seed k we'll just output k of 0, 0,

Â 0, 0 concatenated with F k of 0, 0, 0, 1.

Â Right, so intuitively F sub k for a uniform k, looks like a random function,

Â and if that's the case, then applying a uniform function to the 0 input.

Â And then applying a uniform function to the one input

Â is equivalent to choosing two uniform n-bit values, n-bit outputs.

Â And so, what we get is a pseudorandom generator G

Â that maps an n-bit seed to a 2 n-bit output.

Â In fact there's no reason to restrict ourselves to only evaluating F twice.

Â We can define a, a pseudorandom generator G with larger expansion by simply

Â applying F sub k to more values, to more distinct values.

Â So here I'm just defining G of k as f, f, k applied to 0.

Â F, k applied to 1.

Â F,k applied to 2.

Â Where we imagine we're encoding those integers as n-bit strings.

Â More generally we can in fact view a pseudorandom function

Â as a pseudorandom generator with exponentially long output.

Â And that furthermore allows random access to individual chunks of that output,

Â that is we can view the function F sub k.

Â Eh, by looking at the entire function table for F k, that is the value of

Â F k on each possible embed input, and concatenating those all together, right?

Â Intuitively and this is,

Â I'll warn you that this is not quite formally correct, this is just intuition.

Â But intuitively the the fact that Fk looks just like a uniform function, means

Â that the function table for Fk looks like a function table for a uniform function.

Â So just by writing out all possible values of

Â the function on all possible inputs we get some huge table of random looking values.

Â Where moreover, we can access anyone of those values,

Â by simply evaluating Fk on the corresponding input.

Â I next I want to talk about the notion of pseudorandom permutations.

Â If we let F be a length preserving keyed function, as before.

Â Then we'll say that F is furthermore a keyed permutation if the follow two

Â conditions hold.

Â First of all, we'll require that the function Fk, which remember is a function

Â from n-bit inputs to n-bit outputs, should be a bijection for every possible key K.

Â That is the function Fk is one to one and onto.

Â For every possible choice of k,

Â this furthermore this essentially means that F k is a permutation.

Â We'll also require that F k inverse is efficiently computable.

Â If F k is a bijection, then F k has a well-defined inverse, and

Â we'll just add the additional efficiency requirement that we can compute F k

Â inverse given the key k.

Â We'll say then that F is a pseudorandom permutation.

Â If F, k for uniform key k, is indistinguishable from

Â a uniform permutation chosen from the set of all permutations on n bit strings.

Â Block ciphers are very important cryptographic primitives.

Â And these can be viewed as giving us practical instantiations of

Â pseudorandom permutations.

Â That is, if we want to use a pseudorandom permutation in

Â some cryptographic construction.

Â Then the right thing to do is to instantiate that pseudo

Â random permutation with a block cypher.

Â Now for a block cypher there are no asymptotics involved.

Â A block cipher is typically defined on some fixed key length and

Â fixed block length, although there are cases where they're allowed to

Â vary slightly and it gives a fixed output length.

Â So rather than having this function F being defined on all length inputs and

Â all length keys.

Â We'll only have it defined for keys of a certain length.

Â Here denoted by n and what we'll call a key length.

Â And defined only on certain input lengths m,

Â where m is what we'll call the block length.

Â And, because we want this F to be instantiating a pseudorandom permutation.

Â We're going to require that F sub k be hard to

Â distinguish from a uniform permutation F.

Â But actually for the case of block ciphers, we're going to be more stringent.

Â So, it's not going to be sufficient for F sub k for

Â uniform k to be indistinguishable from F.

Â For attackers running in polynomial time, we actually wanted to be hard even for

Â attackers running in time about 2 to the N.

Â That is at the best attack in terms of distinguishing Fk

Â from a uniformed permutation.

Â Should be an exhaustive key search attack.

Â Where the attacker tries to see whether any key k

Â is a possibility that is matches with the inputs and outputs that it seem.

Â It's kind of amazing actually that we have constructions that appear to

Â satisfy this notion.

Â We can't prove that they satisfy the notion of being a,

Â a pseudo-random permutation.

Â However, after many, many years of study, no one's been able to show otherwise.

Â And it's therefore, reasonable to conjecture that they do indeed

Â provide a secure instantiation of pseudorandom permutations.

Â Perhaps the best known of these is AES the advanced encryption standard.

Â AES was standardized by NIST in 2000 based

Â on a public worldwide competition lasting over three years.

Â Essentially teams of cryptographers were allowed to submit their proposals for

Â block cipher constructions.

Â And after three years of study and analysis,

Â NIST chose AES as the block cipher to be standardized.

Â AES provides a block length of 128 bits, and

Â it offers three different key lengths 128, 192, or 256 bits.

Â And again,

Â as far as we know today AES provides the security claimed on the previous slide.

Â That is AES with 128 bit keys seems to provide about 2 to

Â the 128 security, that is security against attackers running in time 2 to the 128,

Â and really that's very that's sufficient.

Â For, any kind of attack you can imagine in practice.

Â I'll mention that AES is like I said, one of the best known block ciphers out there,

Â and there's really no reason to use anything else.

Â You'll find, if you look, that there are other block ciphers available.

Â however, I can really just only recommend using the de,

Â using AES as the default block cipher extra in any construction.

Â Next time, we'll show how to use pseudo random functions aka block

Â ciphers to construct CPA-secure encryption schemes.

Â Coursera provides universal access to the worldâ€™s best education,
partnering with top universities and organizations to offer courses online.