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.

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

Maryland Cybersecurity Center

[SOUND].

Â We'll continue our discussion of number theory by introducing the notion

Â of a group.

Â This is actually a very fundamental and important notion both for

Â mathematics in general, as well as for applications to cryptography.

Â Roughly speaking the notion of a group provides a way of reasoning about

Â different objects, that share the same underlying mathematical structure.

Â And hopefully this will be, become more clear when we see the definition, and

Â then see a couple of examples.

Â Now one thing I will say, is that an understanding of groups, and

Â a little rudimentary group theory, is strictly speaking,

Â not necessary to understand crypto or cryptographic applications.

Â But in my opinion, just a little bit of knowledge about the concept of a group.

Â Does make things conceptually easier, it puts things in an appropriate framework,

Â and I think makes it easier to grasp, what's really going on under the hood.

Â And since that's part of what you're interested in learning from this class,

Â I do think it's important to spend some time on basic group theory.

Â So let's jump in and look at the definition.

Â We're only going to be interested here in abelian groups and so

Â that's what I'm going to define.

Â So an abelian group is a set G,

Â a set of elements, along with a binary operation that for this

Â slide we're going to denote by this little circle, defined on the elements of G.

Â This means that for every two elements of G you can compute a circle b,

Â and then get back as a result some other element of the same set.

Â And this has to satisfy certain conditions.

Â And the conditions are the following, so first of all,

Â we require that there exists some element in G that acts as an identity.

Â And, on this slide, we'll denote that element by e.

Â And the property of this element e, the fact that it acts as a, as an identity,

Â means that e.g is equal to g for every element in the set G.

Â We're also going to require that every element in g, has an inverse, h say,

Â such that h.g is equal to this identity element.

Â We require also the notion of associativity which should be

Â familiar to you from basic arithmetic and this just requires that for

Â every three elements f, g and h in the set G.

Â If we first compute g.h, and then compute f dot the result,

Â then that gives the same answer as if we first compute f.g, and

Â then take that intermediate result and take that dot h.

Â So it doesn't matter, in some sense, what order we do the operations.

Â We're only going to consider as I mentioned earlier abelian groups.

Â And abelian groups have the extra property that for all g and h, in the set G,

Â g.h is the same as h.g.

Â And one more piece of notation, the order of a finite group g,

Â and we're only ever going to consider finite groups in this course.

Â The order of a group g is the number of elements in the set G.

Â So let's look at a a piece of notation.

Â So just to simplify matters rather than writing this little

Â circle to represent the group operation.

Â It's very common to, instead, use either additive notation, or

Â multiplicative notation, to denote the group operation.

Â So under additive notation we write g plus h to denote the group operation on g and

Â h, and under multiplicative notation we write either gh or

Â g with a little dot instead of a little circle h.

Â Analogous to the way you would write multiplication of integers in grade

Â school arithmetic.

Â Now it's important to keep in mind that just because we're writing things in

Â this way, does not mean that the group operation,

Â corresponds to integer addition or multiplication.

Â For the most part, in all the examples we talk about in this class ultimately things

Â are going to be based on integer addition or multiplication,

Â though they will not be identical, to integer addition or multiplication.

Â But it's also very easy to consider examples where addition and

Â multiplication of integers is nowhere to be seen, and

Â you define the group operation completely abstractly.

Â But you nevertheless, might write it, using this additive or

Â multiplicative notation.

Â Just a few more pieces of notation to represent the identity element,

Â it's convenient to use, 0 or 1.

Â 0 in the case of additive notation, and a 1 in the case of multiplicative notation.

Â This is again, just something a more convenient way to represent the identity,

Â rather than using e.

Â The inverse of an element, is denoted in the natural way by minus g,

Â if we're using additive notation, or

Â g to the minus 1 power, if we're using multiplicative notation.

Â And when we talk about grouda,

Â group exponentiation, which means repeated application of the group operation,

Â we denote that by m.a when we're using additive notation, which

Â again refers to repeated addition, in quotes, of a to itself a total of m times.

Â Or when using multiplicative notation,

Â we write a to the m, to refer to repeated multiplication of a by itself m times.

Â Where again, we're careful to understand that this does not mean that we're, that

Â we're referring to integer multiplication or integer addition in either case.

Â One thing I'll point out here, I,

Â this starts getting a little bit abstract, but I think it's,

Â if you can understand this, you have a good understanding what's going on.

Â When we write something like m.a using additive notation for

Â the group, a is a group element, and m is an integer.

Â So what we're talking about here is not the group operation, applied to m and a.

Â Right? M is not even necessarily in the group,

Â it's type is that of an integer.

Â But we're, what we're referring to is repeated application of

Â the group operation to the group element a, a total of m times.

Â And here we're assuming that m is a positive integer you can

Â handle negatives and zeros in really pretty much the natural way.

Â And we don't handle fractional m at all.

Â In terms of performing computations in groups, so

Â we're again going to ultimately be interested in the algorithmic efficiency

Â of performing different operations and

Â different computations in the groups that we're going to be working with.

Â And we're always going to implicitly assume that for

Â any groups we're talking about, in the context of cryptography,

Â that it is possible to efficiently recognize, what a group element is.

Â So that is, we're ultimately going to be writing every element of some group

Â as a sequence of bits.

Â And it should be possible, given some sequence of bits, to tell whether or

Â not that represents a valid group element.

Â We also are going to assume that the group operation can be computed efficiently.

Â So again this means that given two group elements,

Â represented by their bit strings, we can compute the group

Â operation on those two group elements, i.e those two strings.

Â And further more that we can compute this group operation in time,

Â polynomial in the length of those strings.

Â Now when I say assume here, I don't mean that we don't think about it all.

Â What I mean is that we, of course, have to analyze for some group of cryptographic

Â interest, that it is indeed possible to perform these operations efficiently.

Â But we will assume that somebody else has done the work for us,

Â and therefore that they can indeed be done efficiently.

Â Now the fact that the group operation can be completed efficiently,

Â means also that group exponentiation can be computed efficiently.

Â And this follows using the same algorithm that we showed last time for

Â performing modular exponentiation, and the connection between the two

Â might become more clear after we show that, in fact,

Â some form of multiplication modulo N can indeed be viewed as a group operation.

Â Let's see an example of a group, this is perhaps the most basic example.

Â So consider the set ZN, which denotes the set of elements from

Â 0 to N minus 1 under addition modulo N.

Â So this means that the group operation here or the operation, is defined as

Â taking any two elements in the set, adding them and taking their result reducing it

Â modulo N to give back an integer in the range 0 to N minus 1.

Â Well it's not too difficult to convince yourself that this does give

Â a valid group, the identity element here is simply 0 which is in the set.

Â The inverse of the element a, is the element minus a reduce modulo N,

Â where we need to reduce modulo N so that we get back something in the same set.

Â Associativity and commutativity of the group operation is immediate, it follows

Â from associativity and commutativity of the underline operation on the integers.

Â And the order of this group is N, because it contains exactly the N elements,

Â the N integers from 0 to N minus 1.

Â And the exponentiation here m.a corresponds to as we

Â said earlier repeated addition of a to itself m times.

Â And as we noted this can be computed efficiently in fact in

Â this case you can compute just by using standard integer arithmetic.

Â This is kind of a coincidence if you want to call it that,

Â due to the fact that the element a here can be viewed both as an element of

Â the set ZN, as well as an integer.

Â Now what happens if we try to extend the previous example and

Â think about multiplication modulo N?

Â Well, the first thing to note is that the same set 0 to N minus1 is not going to

Â be a group under this operation.

Â One would have to be the identity, but for

Â example, the element 0 has no interest, there's nothing,

Â no element in that set when multiplied by 0, is going to give us 1.

Â In fact, even if we exclude 0 from consideration,

Â if we take it out of the set, that doesn't solve the problem because for

Â example, think about the case when N equals 4.

Â While there's no inverse of 2 modulo 4, something that you can check

Â just by brute force and numberating over all the possibilities, right?

Â The set in this case would be the elements 1, 2, and 3 under multiplication modulo 4.

Â And none of 1, or 2, or 3, multiplied by 2 gives 1 when reduced modulo 4.

Â So what we need to do instead is to restrict the elements in our set.

Â So let's first begin with a definition.

Â Say that the element b is invertible modulo N, if there is some other element,

Â b inverse, such as b times b inverse is equal to 1 mod N.

Â In other words we're just defining invertibility modulo N to mean that b

Â ahs an inverse modulo N.

Â And if such a b inverse exists it turns out you can show that it

Â 's unique modulo N.

Â So an element, if it has an inverse has exactly 1 inverse.

Â I'll note also that we can use this to define a notion of division by b.

Â So when we're mark, when we're working with an operation of multiplication modulo

Â N and we say or we talk about division by b in fact what

Â we mean formally is multiplication by b inverse modulo N.

Â And in fact, the notion of division is not really well defined modulo N

Â if the element b does not have an inverse.

Â So the operation of division by b really should only be defined when b

Â is invertible modulo N in the first place.

Â Now the natural question is, which elements are invertible?

Â And we can fully characterize those elements by the following theorem.

Â Element b is invertible modulo N, if and

Â only if the greatest common divisor of b and N, is equal to 1.

Â We're not going to prove that here, although a proof is

Â not incredibly difficult, but it's not really so important for our purposes.

Â And this also means, not only can we characterize invertibility, but

Â we can efficiently test wether a given element is invertible, and

Â this is a consequence of the fact that gcd can be computed in polynomial time,

Â that is, given two integers, being n here, for

Â example, we can compute our greatest common divisor, in polynomial time.

Â This is not trivial, but

Â it is something that has been known since the time of Euclid.

Â The algorithm for doing this, actually, is called the Euclidian algorithm.

Â Now coming back to the question of invertibility.

Â So what we said early,

Â than an element b is invertible if the greatest common divisor of b and N is one.

Â So if we take for example p prime, for considering a prime modulus,

Â then all of the elements between 1 and p minus 1 will invertible modulo p.

Â And that follows from the fact that the greatest common divisor of p,

Â and any integer, less than p, is going to have to be 1, right?

Â Because the only factors of p are 1 and p.

Â Nothing else no,

Â no integer smaller than p can have any other factor than 1 in common with p.

Â A second interesting example is given by a moduli of the form,

Â a product of two primes.

Â So say N is equal to pq, for p and q distinct primes.

Â Then the invertible elements, modulo N, are going to be the integers from 0 to

Â N minus 1, that do not share a factor in common with N other than 1, right?

Â This is just sho,

Â it's just they're re-expressing the fact that the greatest common divisor of

Â the element, and N should be 1.

Â So this means, that we can imagine listing out the elements from 1 to N minus 1 and

Â excluding all the multiples of p, and all the multiples of q.

Â And again, this will, what we're left with is going to consist of

Â exactly the elements whose greatest common divisor with N is equal to 1, and

Â this is a consequence of the fact that that p and q are prime.

Â So it turns out that if we do this, then the set ZN star,

Â which we will define as the set of inverter elements between 1 and

Â N minus 1, is indeed a group under multiplication modulo N.

Â So we came to the question earlier or we, or we noted it earlier,

Â that just looking at multiplication modulo N, does not straight away give us a group,

Â because some, some elements are not invertable.

Â But if we simply take out,

Â if we simply exclude those elements that are not invertible,

Â then what we're left with is a group, and we'll denote that group by ZN star.

Â It's not immediately obvious here that it's a group,

Â because in particular it's not immediately obvious that we have closure,

Â that it is not immediately obvious that if I take two elements a and b,

Â both of which are invertible, then their product ab mod N is also invertible.

Â Never the less this can be shown and, it does in fact hold.

Â The identity is obviously going to be 1.

Â The inverse of a is going to be a inverse mod N.

Â This is where we use the fact that we're restricting attention to

Â invertible elements only.

Â And a before, for the case of ZN, the additive group modulo N, associativity and

Â commutativity here are obvious,

Â because they follow from the same properties over the integers.

Â And, again the exponentiation, that is a to the m,

Â a mod N repeated multiplications of a, m times.

Â And taking the result, modulo N can be computed efficiently as well and

Â this follows from the fact that multiplication can be done efficiently and

Â follows from the exponentiation algorithm we saw in the previous lecture.

Â What's the order of these different groups?

Â Well we'll define phi of N, where phi is a greek letter.

Â To exactly be the number of invertible elements, modulo N.

Â That is, it's the, the set of elements between 1 and

Â N minus 1 whose GCD with N, is equal to 1.

Â And this is precisely the order of ZN star, because we defined ZN star to

Â consist precisely of those elements whose GCD with N is equal to 1.

Â When N is prime we said earlier that every element between 1 and

Â N minus 1 is in ZN star.

Â And so when N is prime phi of N is equal to N minus 1, that is the size or

Â the order of the group ZN star, when N is prime is exactly N minus 1.

Â Furthermore, when N is a product of two distinct primes,

Â then we can compute phi of N using the characterization of the elements of

Â ZN star that we talked about a moment ago.

Â So remember, that ZN star, consists of

Â those elements that we get if we write out the integers from 1 to N minus 1, and

Â then exclude all multiples of p and all multiples of q.

Â So this means, we start with a list of N minus 1 elements.

Â Right, all of the elements from z, from 1 to N minus 1.

Â And then we exclude all the elements of p.

Â Well how many sorry all the multiples of p.

Â Well how many multiples of p are there?

Â Well, we have p, we have 2p, we have 3p,

Â 4p, 5p all the way up to q minus 1 times p.

Â Qp is already too large, qp is equal to N and that's beyond the limit of our set.

Â So if we cross out every multiple of p,

Â there will be exactly q minus 1 elements that we cross out.

Â Similarly if we cross out every multiple of q,

Â we end up crossing out precisely p minus 1 elements.

Â And note here that no element in the range of 1 to N minus 1 can be

Â both a multiple of p and a multiple of q, there is no double counting going on here.

Â Because again, p times q is equal to N, which is beyond the range of our set.

Â So the total number of elements in ZN star, is given by our list,

Â N minus 1, minus the q minus 1 elements we cross out because they're multiples of p,

Â minus the p minus 1 elements we cross out for being multiples of q.

Â And that simplifies to the very nice form p minus 1 times q minus 1.

Â So the upshot is that phi of N when N is a product of two distinct primes,

Â i.e the size of ZN star when N is a product of two distinct primes,

Â is exactly p minus 1 times q minus 1.

Â Okay, so let's go back now to our discussion of abstract group theory.

Â A very important theorem of group theory is called Fermat's little theorem.

Â And it says the following, let G be a finite group of order m.

Â That is, having m elements.

Â Then for any element, in that group, and

Â element G in that group, it holds that g to the m, is equal to the identity.

Â Okay? So, here, we're writing the group,

Â multiplicatively and what the theorem says is that, if m is the order of the group,

Â then if we repeatedly apply the group operation to g,

Â m times, then we get the identity element.

Â The proof is omitted, it's again not something that's very complicated, but

Â it's not very important for our setting, either.

Â Just an an example to illustrate the theorem, if we take the group ZN,

Â the group of elements under addition modulo N, then we said earlier that

Â this group has order N, and therefore what the theorem tells us is that for

Â any element a, in that group, we have that N times a is equal to 0 mod N.

Â This, of course, agrees with our expectation because of course,

Â N times a is going to have to be 0 mod N because Na is divisible by N.

Â But very, be very careful here, note that, as we talked about earlier a here is

Â a group element, and N is an integer, not an element of the group.

Â In particular, the integer N, is not an element of ZN,

Â because ZN contains only the elements from 0 to N minus 1.

Â Anyway, what we're saying here just matches our expectation, but

Â it does fulfill, or it does illustrate an application of the theorem.

Â Another example, if we look at the group ZN star, where this is the group of,

Â invertible elements, modulo N, taken under multiplication modulo N.

Â So what the theorem tells us here, is that for all a, in ZN star,

Â we have that a to the phi of N, is equal to 1 mod N.

Â Right, that is, that if we raise a to the phi of N power or equivalently

Â apply the group operation which is just multiplication, phi of N times to any

Â element a, then we get the identity element in ZN star, which is of course 1.

Â In particular if N is prime, then for all elements a,

Â and ZN star, which is all a between 1 and N minus 1 inclusive,

Â we have a to the N minus 1 is equal to 1 modular N.

Â A Corollary fromage theorem is that if we let G be a finite group of order m,

Â then for any element g, and any integer x.

Â We can always reduce in the exponent, that is,

Â g to the x, is equal to g to the x reduced modulo m.

Â And the proof is one line.

Â So let's write the integer x, as q times m plus r.

Â This is just division with remainder, we divide x by m,

Â we get a quotient q and a remainder r.

Â Well then it holds that g to the x is certainly equal to g to the qm plus r.

Â We can just re-express that as g to the m,

Â to the q times g to the r, but now Fermat's little theorem tells us that g to

Â the m is equal to 1, so this expression simplifies to g to the r and

Â of course r, the remainder of x divided by m, is exactly what bracket x mod m means.

Â And this is very interesting because it means it gives us

Â something that can be used to speed up exponentiation.

Â In particular if we want to compute g to the x in some group, then what we

Â can do is we can always first reduce the exponent x modulo the order of the group.

Â So just to take a, kind of a silly example.

Â If we were computing g to a 1005, in some group of order 10,

Â then rather than computing the exponentiation of g to the 1005,

Â which would require, you know, some number of repeated squarings and multiplications,

Â if we use the exponentiation algorithm, we, I talked about last time.

Â Well what we can do instead is simply reduce the exponent 1,005,

Â modulo the order of the group, that is 10, and get the result 5.

Â And we only then have to compute g to the fifth power.

Â Which is going to be in general much, much simpler.

Â Another corollary is the following, and

Â this corollary is actually both very important but a little bit hard to parse.

Â So I want to walk through it, let's let G be a finite order m.

Â And then for any integer e, I wanted to find the function, f sub e.

Â F sub e is going to be a function on the group, and the function f sub e,

Â is going to take as input,

Â a group element g, and return the group element g to the eth power.

Â Okay, so we're defining a function on the group itself that takes an input and

Â raises it to the eth power.

Â The claim is that if the GCD of e and

Â m is equal to 1, then this function, f sub e, is in fact a permutation,

Â that means it's going to be a bijection, both one to one and onto.

Â So the function f sub e will simply permute the elements of the group,

Â in some way.

Â Moreover, if we let d be equal to e inverse modulo m,

Â and note that, we know that such a d exists precisely because

Â GCD em equals 1 means that e is invertible modulo N.

Â Well then, the function f sub d, that is,

Â raising to the dth power, is the inverse of the function f sub e.

Â So, again, it takes a bit of time to parse this.

Â But what we're saying is that, number one,

Â f sub e is a permutation, under the stated conditions.

Â And furthermore, that f sub d, will also be a permutation and

Â in particular will be the inverse of f sub e.

Â The proof here is again one line.

Â So once you understand what's going on the proof is rather simple.

Â Okay so it's two lines.

Â So the first part follows from the second, that is, if we can show that fd is

Â the inverse of fe, then that in particular implies that fe is a permutation.

Â So, let's prove that.

Â So we want to show that for any element g, if we apply fe to g,

Â and then apply fd to the result, and we should get back the same element g.

Â Well, fd of fe of g.

Â Is by definition g to the e, which is the result of fe of g,

Â and then we take that and apply fd to that we get, we raise that to the d.

Â So it's just g to the e to the d.

Â Algebraically that's just the same thing,

Â as g raised to the power of the product of e and d, but the previous claim,

Â the one we had on the previous slide tells us, that to compute g to the ed,

Â we can reduce the exponent and modulo the order of the group which is m.

Â So that's equal to g to the ed reduced mod m.

Â But e and d are inverses modulo m.

Â So that means that ed mod m, is exactly 1.

Â And of course g to the 1, is just g.

Â And that completes the proof of the theorem.

Â So it shows you how just a few simple facts,

Â about groups can be used to prove relatively powerful results.

Â In the next lecture, we're going to see how this corollary,

Â leads to a computational problem that in turn is very useful for cryptography.

Â You may have even heard about it that is the RSA problem.

Â As a precursor to that, we'll also talk about the related factoring problem.

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