< Return to Video

Fermat and Euler (18 min)

  • 0:01 - 0:03
    In the previous segment, we talked about modulo inversion,
  • 0:03 - 0:05
    and we said that Euclid's algorithm gives us
  • 0:05 - 0:09
    an efficient method to find the inverse of an element modulo m.
  • 0:09 - 0:11
    In this segment we are going to forward through time
  • 0:11 - 0:15
    and we're going to move to the 17th and 18th century
  • 0:15 - 0:16
    and we're going to talk about Fermat's and Euler's contributions.
  • 0:16 - 0:21
    Before that, let's do a quick review of what we discussed in the previous segment.
  • 0:21 - 0:24
    So as usual, we're going to let N denote a positive integer,
  • 0:24 - 0:27
    and let's just say that N happens to be a n-bit integer.
  • 0:27 - 0:30
    In other words, it's between 2^n and 2^(n+1).
  • 0:30 - 0:33
    As usual we are going to let p denote a prime.
  • 0:33 - 0:38
    Now we said that Z sub n is the set of integers from 0 to N - 1.
  • 0:38 - 0:41
    And we said that we can add and multiply elements in the set modulo N.
  • 0:41 - 0:46
    We also said the Z_N* is basically the set of invertible elements
  • 0:46 - 0:50
    in Z_N and we proved the simple lemma to say that x is invertible
  • 0:50 - 0:53
    if and only if x is relatively prime to n.
  • 0:53 - 0:57
    And not only did we completely understand which elements are invertible
  • 0:57 - 0:58
    and which aren't,
  • 0:58 - 1:02
    we also showed a very efficient algorithm, based on Euclid's extended algorithm,
  • 1:02 - 1:05
    to find the inverse of an element x in Z_N.
  • 1:05 - 1:10
    And we said that the running time of this algorithm is basically of order n-squared
  • 1:10 - 1:13
    where again n is the number of bits of the number capital N.
  • 1:14 - 1:19
    So as I said, now we're gonna move from Greek times all the way to
  • 1:19 - 1:21
    the 17th century and talk about Fermat.
  • 1:21 - 1:24
    So Fermat stated a number of important theorems.
  • 1:24 - 1:27
    The one that I want to show you here is the following:
  • 1:27 - 1:29
    So suppose I give you a prime "p".
  • 1:29 - 1:33
    Then in fact, for any element x in in Z_p*, it so happens
  • 1:33 - 1:37
    that if I look at x and raise it to the power p-1,
  • 1:37 - 1:39
    I'm gonna get 1 in Z_p.
  • 1:39 - 1:42
    So let's look at a quick example.
  • 1:42 - 1:44
    Suppose I set the number p to be 5
  • 1:44 - 1:50
    and I look at 3 to the power of p-1 - in other words 3 to the power of 4 -
  • 1:50 - 1:54
    3^4 is 81, which in fact is 1 modulo 5.
  • 1:54 - 1:57
    The example satisfies Fermat's theorem.
  • 1:57 - 2:00
    Interestingly Fermat actually didn't prove this theorem himself.
  • 2:00 - 2:05
    The proof actually waited until Euler, who proved it almost a 100 years later
  • 2:05 - 2:07
    and in fact he proved a much more general version of this theorem.
  • 2:09 - 2:11
    So lets look at a simple application of Fermat's theorem.
  • 2:11 - 2:14
    Suppose I look at an element x in Z_p*,
  • 2:14 - 2:18
    and I want to remind you here that p must be a prime.
  • 2:18 - 2:22
    Well, then what do we know? We know that x^(p-1) = 1.
  • 2:22 - 2:28
    Well, we can write x^(p-1) as x*x^(p-2).
  • 2:28 - 2:33
    Well, so now we know that x*x^(p-2) happens to be equal to 1,
  • 2:33 - 2:37
    and what that says is that really the inverse of x modulo p
  • 2:37 - 2:39
    is simply x^(p-2).
  • 2:39 - 2:44
    So this gives us another algorithm for finding the inverse of x modulo a prime:
  • 2:44 - 2:47
    simply raise x the power of p-2
  • 2:47 - 2:49
    and that will give us the inverse of x.
  • 2:49 - 2:53
    It turns out actually this is a fine way to compute inverses modulo a prime,
  • 2:53 - 2:57
    but it has 2 deficiencies compared to Euclid's algorithm.
  • 2:57 - 3:00
    First of all, it only works modulo primes,
  • 3:00 - 3:03
    whereas Euclid's algorithm worked modulo composites as well,
  • 3:03 - 3:06
    and second of all it turns out this algorithm is actually less efficient.
  • 3:06 - 3:09
    When we talk about how to do modular exponentiation
  • 3:09 - 3:11
    - we're gonna do that in the last segment in this module -
  • 3:11 - 3:15
    you'll see that the running time to compute this exponentiation
  • 3:15 - 3:18
    is actually cubic in the size of p,
  • 3:18 - 3:21
    so this will take roughly log^3(p),
  • 3:21 - 3:23
    whereas, if you remember, Euclid's algorithm was able
  • 3:23 - 3:25
    to compute the inverse in quadratic time
  • 3:25 - 3:27
    in the representation of p.
  • 3:29 - 3:32
    So not only is this algorithm less general
  • 3:32 - 3:34
    - it only works for primes -
  • 3:34 - 3:37
    it's also less efficient.
  • 3:37 - 3:38
    So score one for Euclid,
  • 3:38 - 3:43
    but nevertheless, this fact about primes is extremely important
  • 3:43 - 3:45
    and we're going to be making extensive use of it
  • 3:45 - 3:48
    in the next couple of weeks.
  • 3:48 - 3:51
    So let me show you a quick and simple application of Fermat's theorem.
  • 3:51 - 3:54
    Suppose we wanted to generate a large random prime.
  • 3:54 - 3:58
    Say our prime needed to be 1000 bits or so.
  • 3:58 - 4:03
    So the prime we're looking for is on the order of 2^1024, say.
  • 4:03 - 4:05
    So here is a very simple probabilistic algorithm:
  • 4:05 - 4:08
    What we would do is, we would choose a random integer
  • 4:08 - 4:11
    in the interval that was specified,
  • 4:11 - 4:15
    and then we would test whether this integer satisfies Fermat's theorem.
  • 4:15 - 4:17
    In other words, we would test -
  • 4:17 - 4:18
    for example, using the base 2,
  • 4:18 - 4:23
    we would test whether 2^(p-1) equals 1 in Z_p.
  • 4:23 - 4:26
    If the answer is no, if this equality doesn't hold,
  • 4:26 - 4:31
    then we know for sure that the number p that we chose is not a prime.
  • 4:31 - 4:35
    And if that happens, all we do is we go back to step 1
  • 4:35 - 4:36
    and we try another prime.
  • 4:36 - 4:38
    We do this again and again and again,
  • 4:38 - 4:42
    until finally we find an integer that satisfies this condition.
  • 4:42 - 4:44
    And once we find an integer that satisfies this condition,
  • 4:44 - 4:48
    we simply output it and stop.
  • 4:48 - 4:49
    Now it turns out
  • 4:49 - 4:51
    - this is actually a fairly difficult statement to prove -
  • 4:51 - 4:55
    but it turns out, if a random number passes this test,
  • 4:55 - 4:57
    then it's extremely likely to be a prime.
  • 4:57 - 5:00
    In particular, the probability that p is not a prime
  • 5:00 - 5:01
    is very small.
  • 5:01 - 5:06
    It's, like, less than 2^-60 for the range of 1024-bit numbers.
  • 5:06 - 5:08
    As the number gets bigger and bigger,
  • 5:08 - 5:10
    the probability that it passes this test here,
  • 5:10 - 5:16
    but is not a prime, drops to zero very quickly.
  • 5:16 - 5:17
    So this is actually quite an interesting algorithm.
  • 5:17 - 5:21
    You realize: we're not guaranteed that the output is in fact a prime.
  • 5:21 - 5:24
    All we know is that it's very very likely to be a prime.
  • 5:24 - 5:26
    In other words: the only way that it's not a prime
  • 5:26 - 5:28
    is that we got extremely unlucky.
  • 5:28 - 5:34
    In fact, so unlucky that a negligible-probability event just happened.
  • 5:34 - 5:36
    Another way to say this is that,
  • 5:36 - 5:39
    if you look at the set of all 1024-bit integers,
  • 5:39 - 5:44
    then, well, there is the set of primes, when we write "prime" here,
  • 5:44 - 5:46
    and then there is a small number of composites
  • 5:46 - 5:48
    that actually will falsify the test,
  • 5:48 - 5:51
    let's call them F for "false primes".
  • 5:51 - 5:54
    Let's call them FP, for "false primes".
  • 5:54 - 5:56
    There is a very small number of composites
  • 5:56 - 5:59
    that are not prime and yet will pass this test,
  • 5:59 - 6:02
    but as we choose random integers
  • 6:02 - 6:05
    - you know, we choose one here and one here, and so on -
  • 6:05 - 6:06
    as we choose random integers,
  • 6:06 - 6:09
    the probability that we fall into this set of false primes
  • 6:09 - 6:13
    is so small that it's essentially a negligible event
  • 6:13 - 6:15
    that we can ignore.
  • 6:15 - 6:17
    In other words, one can prove that the set of false primes
  • 6:17 - 6:19
    is extremely small,
  • 6:19 - 6:24
    and a random choice is unlikely to pick such a false prime.
  • 6:24 - 6:25
    Now I should mention,
  • 6:25 - 6:28
    in fact, this is a very simple algorithm for generating primes.
  • 6:28 - 6:30
    It's actually by far not the best algorithm.
  • 6:30 - 6:32
    We have much better algorithms now.
  • 6:32 - 6:33
    And in fact, once you have a candidate prime
  • 6:33 - 6:35
    we now have very efficient algorithms
  • 6:35 - 6:37
    that will actually prove beyond a doubt
  • 6:37 - 6:40
    that this candidate prime really is a prime.
  • 6:40 - 6:43
    So we don't even have to rely on probabilistic statements.
  • 6:43 - 6:44
    And nevertheless,
  • 6:44 - 6:45
    this Fermat test is so simple
  • 6:45 - 6:46
    that I just wanted to show you
  • 6:46 - 6:48
    that it's an easy way to generate primes
  • 6:48 - 6:52
    although in reality this is not how primes are generated.
  • 6:52 - 6:54
    As a last point, I'll say that
  • 6:54 - 6:57
    you might be wondering how many times this iteration
  • 6:57 - 7:00
    has to repeat until we actually find a prime.
  • 7:00 - 7:01
    And that's actually a classic result,
  • 7:01 - 7:03
    it's called the Prime Number Theorem
  • 7:03 - 7:04
    which says that
  • 7:04 - 7:05
    after a few hundred iterations
  • 7:05 - 7:09
    we'll find a prime with high probability.
  • 7:09 - 7:10
    So expectation, one would expect
  • 7:10 - 7:14
    a few hundred iterations, no more.
  • 7:14 - 7:16
    Now that we understand Fermat's theorem,
  • 7:16 - 7:18
    the next thing I want to talk about is
  • 7:18 - 7:20
    what's called the structure of (Z_p)*.
  • 7:20 - 7:22
    So here we're going to move a hundred years into the future,
  • 7:22 - 7:24
    into the 18th century,
  • 7:24 - 7:26
    and look at the work of Euler.
  • 7:26 - 7:27
    And one of the first things Euler showed
  • 7:27 - 7:29
    is, in modern language,
  • 7:29 - 7:33
    is that (Z_p)* is what's called a cyclic group.
  • 7:33 - 7:35
    So what does it mean that (Z_p)* is a cyclic group?
  • 7:35 - 7:36
    What it means is:
  • 7:36 - 7:40
    there exists some element g in (Z_p)*
  • 7:40 - 7:43
    such that if we take g and raise it to a bunch of powers,
  • 7:43 - 7:47
    g, g^2, g^3, g^4 and so on and so forth
  • 7:47 - 7:51
    up until we reach g^(p-2)
  • 7:51 - 7:53
    - notice there is no point of going beyond g^(p-2)
  • 7:53 - 7:58
    because g^(p-1) by Fermat's theorem is equal to 1,
  • 7:58 - 8:00
    so then we will cycle back to 1
  • 8:00 - 8:02
    if we go back to g^(p-1),
  • 8:02 - 8:05
    then g^p will be equal to g,
  • 8:05 - 8:07
    g^(p+1) will be equal to g^2, and so on and so forth,
  • 8:07 - 8:09
    so we'll actually get a cycle
  • 8:09 - 8:12
    if we keep raising to higher and higher powers of g,
  • 8:12 - 8:17
    so we might as well stop at the power of g^(p-2).
  • 8:17 - 8:18
    And what Euler showed is
  • 8:18 - 8:20
    that in fact there is an element g
  • 8:20 - 8:23
    such that if we look at all of its powers,
  • 8:23 - 8:27
    all of its powers span the entire group (Z_p)*.
  • 8:27 - 8:31
    Powers of g give us all the elements in (Z_p)*.
  • 8:31 - 8:33
    An element of this type is called a generator.
  • 8:33 - 8:37
    So g would be said to be a generator of (Z_p)*.
  • 8:37 - 8:38
    So let's look at a quick example.
  • 8:38 - 8:40
    Let's look for example at p=7,
  • 8:40 - 8:44
    and let's look at all the powers of 3,
  • 8:44 - 8:47
    which are 3^2, 3^3, 3^4, 3^5.
  • 8:47 - 8:52
    3^6 already, we know, is equal to 1 modulo 7 by Fermat's theorem,
  • 8:52 - 8:54
    so there's no point in looking at 3^6:
  • 8:54 - 8:56
    we know we would just get 1.
  • 8:56 - 8:58
    So here I calculated all of these powers for you,
  • 8:58 - 8:59
    and I wrote them out,
  • 8:59 - 9:04
    and you see that in fact, we get all the numbers in (Z_7)*.
  • 9:04 - 9:10
    In other words, we get 1, 2, 3, 4, 5 and 6.
  • 9:10 - 9:14
    So we would say that 3 is a generator of (Z_7)*.
  • 9:14 - 9:17
    Now I should point out that not every element is a generator.
  • 9:17 - 9:21
    For example, if we look at all the powers of 2,
  • 9:21 - 9:23
    well, that's not going to generate the entire group.
  • 9:23 - 9:26
    In particular, if we look at 2^0, we get 1.
  • 9:26 - 9:28
    2^1, we get 2.
  • 9:28 - 9:34
    2^2 is 4, and 2^3 is 8, which is 1 modulo 7.
  • 9:34 - 9:35
    So we cycled back.
  • 9:35 - 9:37
    And then 2^4 would be 2,
  • 9:37 - 9:40
    2^5 would be 4, and so on and so forth.
  • 9:40 - 9:42
    So if we look at the powers of 2,
  • 9:42 - 9:44
    we just get 1, 2 and 4.
  • 9:44 - 9:45
    We don't get the whole group.
  • 9:45 - 9:50
    And therefore we say that 2 is not a generator of (Z_7)*.
  • 9:50 - 9:52
    Now again, something that we'll use very often
  • 9:52 - 9:56
    is, given an element g of (Z_p)*,
  • 9:56 - 10:00
    if we look at the set of all powers of g,
  • 10:00 - 10:02
    the resulting set is going to be called
  • 10:02 - 10:05
    the group generated by g.
  • 10:05 - 10:07
    OK? So these are all the powers of g,
  • 10:07 - 10:11
    they give us what's called a multiplicative group,
  • 10:11 - 10:12
    again, the technical term doesn't matter,
  • 10:12 - 10:15
    the point is: we're going to call all these powers of g
  • 10:15 - 10:18
    the group generated by g.
  • 10:18 - 10:20
    In fact, there's this notation which I don't use very often:
  • 10:20 - 10:26
    "" to denote this group that's generated by g.
  • 10:26 - 10:29
    And then we call the order of g in (Z_p)*,
  • 10:29 - 10:31
    we simply let that be
  • 10:31 - 10:33
    the size of the group that's generated by g.
  • 10:33 - 10:36
    So in other words,
  • 10:36 - 10:37
    the order of g in (Z_p)*
  • 10:37 - 10:39
    is the size of this group.
  • 10:39 - 10:40
    But another way to think about that
  • 10:40 - 10:43
    is basically, it's the smallest integer a
  • 10:43 - 10:48
    such that g^a is equal to 1 in Z_p.
  • 10:48 - 10:50
    OK? It's basically the smallest power
  • 10:50 - 10:54
    that causes a power of g to be equal to 1.
  • 10:54 - 10:54
    And it's very easy to see that
  • 10:54 - 10:56
    this equality here,
  • 10:56 - 10:59
    basically if we look at all the powers of g
  • 10:59 - 11:03
    - we look at 1, g, g^2, g^3 and so on and so forth,
  • 11:03 - 11:07
    up until we get to g to the order of g minus 1,
  • 11:07 - 11:11
    and then if we look at g to the order of g,
  • 11:11 - 11:14
    this thing is simply going to be equal to 1 by definition.
  • 11:14 - 11:17
    OK? So there's no point in looking into higher powers,
  • 11:17 - 11:19
    we might as well just stop raising to powers here.
  • 11:19 - 11:26
    And as a result, the size of the set,
  • 11:26 - 11:30
    in fact, is the order of g.
  • 11:30 - 11:32
    And you can see that the order is the smallest power
  • 11:32 - 11:34
    such that raising g to that power
  • 11:34 - 11:38
    gives us 1 in Z_p.
  • 11:38 - 11:39
    So I hope this is clear,
  • 11:39 - 11:40
    although it might take a little lateral thinking
  • 11:40 - 11:42
    to absorb all this notation.
  • 11:42 - 11:45
    But in the meantime, let's look at a few examples.
  • 11:45 - 11:48
    So again, let's fix our prime to be 7.
  • 11:48 - 11:50
    And let's look at the order of a number of elements.
  • 11:50 - 11:53
    So what is the order of 3 modulo 7?
  • 11:53 - 11:55
    Well, we're asking: what is the size of the group
  • 11:55 - 11:58
    that 3 generates modulo 7?
  • 11:58 - 12:01
    Well, we said that 3 is a generator of (Z_7)*,
  • 12:01 - 12:04
    so it generates all of (Z_7)*.
  • 12:04 - 12:06
    There are 6 elements in (Z_7)*.
  • 12:06 - 12:12
    And therefore we say that the order of 3 is equal to 6.
  • 12:12 - 12:12
    Similarly I can ask:
  • 12:12 - 12:15
    well, what is the order of 2 modulo 7?
  • 12:15 - 12:17
    And in fact, we already saw the answer.
  • 12:17 - 12:21
    So, let's - I'll ask you, what is the order of 2 modulo 7
  • 12:21 - 12:25
    and see if you can figure out what this answer is.
  • 12:25 - 12:27
    So the answer is 3.
  • 12:27 - 12:28
    And again, the reason is,
  • 12:28 - 12:32
    if we look at the set of powers of 2 modulo 7,
  • 12:32 - 12:34
    well, we have 1, 2, 2^2,
  • 12:34 - 12:37
    and then 2^3 that's already equal to 1,
  • 12:37 - 12:40
    so this is the entire set of powers of 2 modulo 7.
  • 12:40 - 12:42
    There are only three of them.
  • 12:42 - 12:46
    And therefore, the order of 2 modulo 7 is exactly 3.
  • 12:46 - 12:47
    Now let me ask you a trick question:
  • 12:47 - 12:52
    What's the order of 1 modulo 7?
  • 12:52 - 12:53
    Well, the answer is 1,
  • 12:53 - 12:56
    because if you look at the group that's generated by 1,
  • 12:56 - 12:58
    well, there's only one number in that group,
  • 12:58 - 12:59
    namely the number 1.
  • 12:59 - 13:00
    If I raise 1 to a whole bunch of powers,
  • 13:00 - 13:02
    I'm always going to get 1,
  • 13:02 - 13:04
    and therefore the order of 1 modulo 7,
  • 13:04 - 13:06
    in fact, the order of 1 modulo any prime,
  • 13:06 - 13:10
    is always going to be 1.
  • 13:10 - 13:12
    Now, there's an important theorem of Lagrange that
  • 13:12 - 13:16
    - actually, this is a very very special case of what I was telling here.
  • 13:16 - 13:18
    But Lagrange's theorem basically implies
  • 13:18 - 13:21
    that if you look at the order of g modulo p,
  • 13:21 - 13:24
    the order is always going to divide p-1.
  • 13:24 - 13:27
    So in our two example[s], you see
  • 13:27 - 13:30
    6 divides 7 minus 1. 6 divides 6.
  • 13:30 - 13:35
    And similarly, 3 divides 7-1, namely again, 3 divides 6.
  • 13:35 - 13:37
    But this is very general.
  • 13:37 - 13:40
    The order is always going to be a factor of p-1.
  • 13:40 - 13:41
    In fact, I'll tell you,
  • 13:41 - 13:42
    maybe it's a puzzle for you to think about
  • 13:42 - 13:45
    it's actually very easy to deduce Fermat's theorem
  • 13:45 - 13:49
    directly from this fact, from this Lagrange's theorem fact,
  • 13:49 - 13:51
    and so Fermat's theorem really in some sense
  • 13:51 - 13:56
    follows directly from Lagrange's theorem.
  • 13:56 - 13:58
    Lagrange, by the way, did this work in the 19th century,
  • 13:58 - 14:02
    so we can already see how we're making progress through time.
  • 14:02 - 14:03
    We started in Greek times,
  • 14:03 - 14:08
    and already we ended up in the 19th century.
  • 14:08 - 14:09
    And I can tell you that more advanced crypto
  • 14:09 - 14:13
    actually uses 20th-century math very extensively.
  • 14:13 - 14:16
    Now that we understand the structure of (Z_p)*,
  • 14:16 - 14:17
    let's generalize that to composites
  • 14:17 - 14:20
    and look at the structure of (Z_N)*.
  • 14:20 - 14:23
    So what I want to show you here is what's called Euler's theorem,
  • 14:23 - 14:26
    which is a direct generalization of Fermat's theorem.
  • 14:26 - 14:29
    So Euler defined the following function:
  • 14:29 - 14:30
    So given an integer N,
  • 14:30 - 14:34
    we define what's called the phi function, phi of N,
  • 14:34 - 14:38
    to be basically the size of the set (Z_N)*.
  • 14:38 - 14:40
    This is sometimes called "Euler's phi function".
  • 14:40 - 14:43
    The size of the set (Z_N)*.
  • 14:43 - 14:46
    So for example, we already looked at (Z_12)*.
  • 14:46 - 14:49
    We said that (Z_12)* contains these four elements
  • 14:49 - 14:51
    1, 5, 7 and 11,
  • 14:51 - 14:56
    and therefore we say that phi of 12 is simply the number of 4.
  • 14:56 - 14:57
    So let me ask you as a puzzle:
  • 14:57 - 14:59
    What is phi of p?
  • 14:59 - 15:04
    It'll basically be the size of (Z_P)*.
  • 15:04 - 15:05
    And so in fact we said
  • 15:05 - 15:08
    that (Z_P)* contains all of Z_P
  • 15:08 - 15:10
    except for the number zero,
  • 15:10 - 15:13
    and therefore phi of p for any prime p
  • 15:13 - 15:17
    is going to be p-1.
  • 15:17 - 15:19
    Now there's a special case which I'm going to state here
  • 15:19 - 15:21
    we're going to use later for the RSA system:
  • 15:21 - 15:24
    if N happens to be a product of two primes,
  • 15:24 - 15:28
    then phi of N is simply N minus p minus q plus 1.
  • 15:28 - 15:30
    Let me just show you why that's true.
  • 15:30 - 15:32
    Basically, N is the size of Z_N.
  • 15:32 - 15:35
    And now we need to remove all the elements
  • 15:35 - 15:37
    that are not relatively prime to N.
  • 15:37 - 15:40
    Well, how can an element not be relatively prime to N?
  • 15:40 - 15:41
    It's got to be divisible by p,
  • 15:41 - 15:44
    or it's got to be divisible by q.
  • 15:44 - 15:46
    Well, how many elements between zero and N-1
  • 15:46 - 15:49
    are there that are divisible by p?
  • 15:49 - 15:50
    Well, there are exactly q of them.
  • 15:50 - 15:53
    How many elements are there that are divisible by q?
  • 15:53 - 15:55
    Well, there are exactly p of them.
  • 15:55 - 15:58
    So we subtract p to get rid of those divisible by q,
  • 15:58 - 16:01
    we subtract q to get rid of those divisible by p.
  • 16:01 - 16:04
    And you'll notice we subtracted 0 twice,
  • 16:04 - 16:08
    because 0 is divisible both by p and q.
  • 16:08 - 16:09
    And therefore we add 1,
  • 16:09 - 16:12
    just to make sure we subtract 0 only once.
  • 16:12 - 16:13
    And so it's not difficult to see
  • 16:13 - 16:17
    that phi of N is N minus p minus q plus 1.
  • 16:17 - 16:18
    And another way of writing that is simply:
  • 16:18 - 16:22
    p minus 1, times q minus 1.
  • 16:22 - 16:24
    OK? So this is a fact that we will use
  • 16:24 - 16:26
    later on when we will come back
  • 16:26 - 16:29
    and talk about the RSA system.
  • 16:29 - 16:33
    So far, this is just defining this phi function of Euler.
  • 16:33 - 16:36
    But now, Euler put this phi function to really good use.
  • 16:36 - 16:38
    And what he proved is this amazing fact here
  • 16:38 - 16:39
    that basically says
  • 16:39 - 16:43
    that if you give me any element x in (Z_N)*,
  • 16:43 - 16:45
    in fact it so happens that
  • 16:45 - 16:49
    x to the power of phi of N is equal to 1 in Z_N.
  • 16:49 - 16:51
    So you can see that this is a generalization of Fermat's theorem.
  • 16:51 - 16:54
    In particular, Fermat's theorem only applied to primes.
  • 16:54 - 16:57
    For primes we know that phi of p is equal to p-1,
  • 16:57 - 16:58
    and in other words,
  • 16:58 - 17:01
    if N were prime, we would simply write p-1 here,
  • 17:01 - 17:04
    and then we would get exactly Fermat's theorem.
  • 17:04 - 17:06
    The beauty of Euler's theorem is that
  • 17:06 - 17:09
    it applies to composites and not just primes.
  • 17:10 - 17:14
    So let's look at some examples:
  • 17:14 - 17:17
    So let's look at 5 to the power of phi of 12.
  • 17:17 - 17:20
    So 5 is an element of (Z_12)*.
  • 17:20 - 17:23
    If we raise it to the power of phi of 12,
  • 17:23 - 17:24
    we should be getting 1.
  • 17:24 - 17:26
    Well, we know that phi of 12 is 4,
  • 17:26 - 17:30
    so we're raising 5 to the power of 4.
  • 17:30 - 17:32
    5 to the power of 4 is 625.
  • 17:32 - 17:33
    And it's a simple calculation to show that
  • 17:33 - 17:36
    that's equal to 1 modulo 12.
  • 17:36 - 17:38
    So this is proof by example,
  • 17:38 - 17:39
    but of course it's not a proof at all,
  • 17:39 - 17:40
    it's just an example.
  • 17:40 - 17:42
    And in fact, it's not difficult to prove Euler's theorem.
  • 17:42 - 17:44
    And in fact I tell you that Euler's theorem
  • 17:44 - 17:46
    is also a very special case
  • 17:46 - 17:49
    of Lagrange's general theorem.
  • 17:49 - 17:51
    OK. So we said that
  • 17:51 - 17:54
    this is a generalization of Fermat's theorem
  • 17:54 - 17:55
    and in fact, as we'll see,
  • 17:55 - 17:56
    this Euler's theorem
  • 17:56 - 18:00
    is the basis of the RSA cryptosystem.
  • 18:00 - 18:01
    So I'll stop here,
  • 18:01 - 18:03
    and we'll continue with modular quadratic equations
  • 18:03 -
    in the next segment.
Title:
Fermat and Euler (18 min)
Description:

I'll copy them over to "English"

more » « less
Video Language:
English

English, British subtitles

Revisions