Section4.1notesall

advertisement
1
Section 4.1: Primes, Factorization, and the Euclidean
Algorithm
Practice HW (not to hand in)
From Barr Text
p. 160 # 6, 7, 8, 11, 12, 13
The purpose of the next two sections that we cover is to provide the mathematics
background needed to understand the RSA Cryptosystem, which is a modern
cryptosystem in wide use today. We start out by reviewing and expanding our study of
prime numbers.
Prime Numbers
Recall that a prime number p is a number whose only divisors are 1 and itself (1 and p).
A number that is not prime is said to be composite. The following set represents the set of
primes that are less than 100:
{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97…}
A larger list of primes can be found in the Barr text on pp. 370-372.
Facts About Primes
1. There are an infinite number of primes.
2. Every natural number can be factored into a product of primes (Fundamental
Theorem of Arithmetic).
Determining the Primality of Larger Positive Integers
Because of its use in cryptology and other applications, mathematical techniques for
determining whether large numbers are prime have been targets of intense research.
We study some elementary factors for determining the primality of numbers.
Fact: 2 is the only even prime. Any even number larger than 2 is not prime since 2 is a
divisor.
Example 1: Is 10000024 prime?
Solution: 10000024 is an even number and 10000024  2  5000012 . Thus, 10000024 is
not prime.
█
How do we determine if large positive integers are prime? The next example illustrates an
elementary method for doing this?
2
Example 2: Is 127 prime?
Solution: The fundamental theorem of arithmetic says that all numbers can be factored into
a product of prime factors. We test prime factors starting with 2. However, we initially see
that the primes 2, 3, 5, 7, 11, 13, 17 do not divide 127. How many prime divisors do we
need test? We could stop at prime divisors less than 63 since 2  63  126 and any divisor
of 127 larger than 63 would have to produce another divisor less than 2. We can do better
than this. Noting that 1111  121  127 , 1113  143  127 , and 13 13  169  127 we
see that to solve the equation 13x  127 requires a solution less than the 127  11.3 .
Since all prime less than 127 have been shown not to be divisors, we can conclude that
127 is prime.
█
Example 2 provides the justification for the following primality test for prime numbers.
Square Root Test for Determining Prime Numbers
Let n > 1 be a natural number. If no prime number {2, 3, 5, 7, 11, 13, …} less than
a divisor of n, than n is prime.
n is
Example 3: Determine if 839 is prime.
Solution: Noting that 839  28.9 and testing all prime divisors less than this number,
we see that 2, 3, 5, 7, 11, 13, 17, 19, and 23 all fail to divide 839. Thus 839 is prime.
█
Example 4: Determine if 1073 is prime.
Solution: Noting that 1073  32.8 and testing all prime divisors less than this number,
we see that after testing 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29 that 29 evenly divides 1073,
that is, 1073  29  37 . Hence, 1073 is not prime.
█
Example 5: Determine if 1709 is prime.
Solution: Noting that 1709  41.3 and testing all prime divisors less than this number,
we see that 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, and 41 all fail to divide 1709. Thus
1709 is prime.
█
As the numbers tested get larger, the square root test for primality does have limitations.
The next example illustrates this fact.
3
Example 6: Determine if 958090550047 is prime.
Solution: Note that 958090550047  978821.000003 and that there are 76990 primes
less than this number. This makes it impractical to use the square root test to determine if
958090550047 is prime. However, it can be show using more sophisticated test that
958090550047 is indeed prime.
█
Being able to determine whether large numbers are prime will be important later on when
we study the RSA cryptosystem. To deal with larger numbers, much more sophisticated
tests for primality testing have been developed and are an on going topic of research. The
largest prime number discovered up to December 2005 was the number 230402457  1 ,
which is a 9152052 digit prime number.
Factorization of Composite Numbers
Recall that a number that is not prime, it is composite. If a number is composite, it can be
factored into prime factors other than 1 and itself. We review some basic techniques of
factoring in the following examples.
Example 7: Factor 3267 into a product of prime factors.
Solution: Noting that 3267  57.2 so that we have a place to stop testing prime divisors
in case 3267 is prime, we see that
Hence, 3267  33  112 .
Example 7: Factor 429229 into a product of prime factors.
Solution: Noting that 429229  655.15 so that we have a place to stop testing prime
divisors in case 429229 is prime, we see that
█
4
Thus, 429229  192  29  41 .
█
Example 8: Factor 1511 into a product of prime factors.
Solution: Noting that 1511  38.9 , we see that none of the primes 2, 3, 5, 7, 11, 13, 17,
19, 23, 29, 31, or 37 divides 1511. Thus, by the square root test, 1511 must be prime and
has as its only factors 1 and itself.
█
The Greatest Common Divisor of Two Numbers
Recall that the greatest common divisor of two numbers, denoted as gcd(a,b), is the largest
number that divides a and b evenly with no remainder. For example, gcd(10, 20). = 10 and
gcd(72, 108)=36. Previously, we saw a method to find the gcd that involved multiplying
the prime factors that both numbers had in common. This method is inefficient for find the
greatest common divisor of larger numbers since it is harder factor numbers with larger
prime factors. However, there is a well known method known as the Euclidean algorithm
that will allows us to find the greatest common divisor of larger numbers which we state
next.
The Euclidean Algorithm
The Euclidean Algorithm makes repeated use of the division algorithm to find the greatest
common divisor of two numbers. If we are given two numbers a and b where a  b , we
comput
a  q1b  r1
b  q2 r1  r2
r1  q3r2  r3
r2  q4 r3  r4

rn 3  qn 1rn  2  rn 1
rrn  2  qn rn 1  rn  gcd( a, b)
rn 1  qn 1rn  0
5
/The last nonzero remainder, rn , is the greatest common divisor of a and b, that is,
gcd( a, b)  rn .
Example 9: Find the greatest common divisor of a = 2299 and b = 627.
Solution: Noting that 2299 > 627 and applying the Euclidean algorithm gives
2299  3  627  418
627  1  418  209  gcd( 2299,627)
418  2  209  0
/Since the last non-zero remainder is 209, gcd(2299, 627)=209.
█
Example 10: Find the greatest common divisor of a = 54321 and b = 9875.
Solution: Noting that 54321 > 9875 and applying the Euclidean algorithm gives
54321  5  9875  4946
9875  1  4946  4929
4946  1  4929  17
4929  289  17  16
17  1  16  1  gcd( 54321,9875)
16  1  16  0
Since the last non-zero remainder is 1, gcd(54321, 9875)= 1.
Theorem: For any two positive integers a and b, there are integers s and t where
as + bt = gcd(a, b)
Note: To find s and t, we solve for the remainders starting with the first step in the
Euclidean algorithm, substituting each remainder we obtain into the remainders we obtain
in successive steps until the greatest common divisor of a and b is reached.
Example 10: Find s and t where as + bt = gcd(a, b), where a = 2299 and b = 627.
Solution: We use the results from Example 8 but extend the results by solving for each
remainder and then substituting into the given successive equation:
2299  3  627  418  418  2299  3  627  a  3b
627  1  418  209  209  627  1  418  b  (a  3b)  b  a  3b  a  4b
█
6
Hence,  a  4b  209 or a(1)  b(4)  209  gcd( a, b) . Hence s = -1 and t = 4. One can
check the answer by computing as+bt = (2299)(-1) + (627)(4) = 209.
█
Example 11: Find s and t where as + bt = gcd(a, b), where a = 54321 and b = 9875.
Solution: We use the results from Example 9 but extend the results by solving for each
remainder and then substituting into the given successive equation:
54321  5  9875  4946  4946  54321  5  9875  a  5b
9875  1  4946  4929  4929  9875  4946  b  (a  5b)  b  a  5b  a  6b
4946  1  4929  17  17  4946  4929  (a  5b)  (a  6b)  a  5b  a  6b  2a  11b
4929  289  17  16  4929  289  17  (a  6b)  289(2a  11b)  a  6b  578a  3179b  579a  3185b
17  1  16  1  1  17  16  (2a  11b)  (579a  3185b)  2a  11b  579a  3185b  581a  3196b
Since 581a – 3196b = a(581) + b(-3196) = 1 = gcd(a, b). Hence, s = 581 and t = -3196.
█
Using the previous results, we want to consider the problem of solving the modular
equation
bt  1 MOD a
for t. Here, t represents the multiplicative inverse of b MOD a, that is, the number you must
multiply b by to get 1 in MOD a arithmetic. In mathematical notation, we say that
t  b1 MOD a . The next example illustrates how Example 11 a special case illustrating
how this problem is solved.
Example 12: Consider a = 54321 and b = 9875 and consider the problem of solving
bt  1 MOD a or 9875t  1 MOD 54321. In Example 11, we solved as + bt = gcd(a, b),
and obtained t = -3196. Since we are working in MOD 54321 arithmetic, we can convert t
to its equivalent positive representation by computing t = -3196 MOD 54321 = 51125. We
claim that t = 51125 is the multiplicative inverse b MOD a = 9875 MOD 54321, that is
b 1  51125 . We can verify this by computing
bt MOD a = (9875)(51125) MOD 54321 = 504859375 MOD 54321 = 1.
█
We generalize the results of Example 12 in the following corollary.
Corollary: If a and b are relatively prime (gcd(a, b) = 1), then b has an inverse modulo a.
That is, b 1 MOD a exists. Then
bt = 1 MOD a has a solution t  b 1 .
7
Fact: t  b 1 is computed by solving as + bt = 1. To ensure t > 0, compute t = t MOD a
to convert t to its positive representation.
Example 13: Compute 131 MOD 81 .
Solution: We want to solve as + bt = 1 where a = 81 and b = 13. To find s and t, we
perform the Euclidean algorithm on a and b and perform the remainder substitution
process.
81  6  13  3  3  81  6  13  a  6b
13  4  3  1  1  13  4  3  b  4(a  6b)  b  4a  24b  4a  25b
3  1 3  0
Hence a(-4) + b(25) =1 and thus t = 25. Since t is already positive, we don’t have to worry
about converting it to positive form. Thus, b1  131  t  25 . We can check our answer
by computing b  b1 MOD a  (13)(35) MOD 81  325 MOD 81  1 .
█
Example 14: Compute 291 MOD 83.
Solution: We want to solve as + bt = 1 where a = 83 and b = 29. To find s and t, we
perform the Euclidean algorithm on a and b and perform the remainder substitution
process.
83  2  29  25  25  83  2  29  a  2b
29  1  25  4  4  29  25  b  (a  2b)  b  a  2b  a  3b
25  6  4  1  1  25  4  6  (a  2b)  6(a  3b)  a  2b  6a  18b  7a  20b
6  1 6  0
Hence, a(7) + b(-20) =1 and thus t = -20. Since t is negative, we convert it to positive form
by computing t = t MOD a = -20 MOD 83 = 63. Thus, b1  291  t  63. We can
check our answer by computing b  b1 MOD a  (29)(63) MOD 83  1827 MOD 83  1
█
Example 15: Solve 7x + 1 = 4 MOD 26 for x.
Solution: We must first isolate x on one side of the equation.
7 x  1  4 MOD 26
7x  3 MOD 26
x  (7  1  3) MOD 26
8
To finish this problem, we need to find 7 1 MOD 26 . We want to solve as + bt = 1 where a
= 26 and b = 7. To find s and t, we perform the Euclidean algorithm on a and b and
perform the remainder substitution process.
26  3  7  5  5  26  3  7  a  3b
7  1  5  2  2  7  5  b  (a  3b)  b  a  3b  a  4b
5  2  2  1  1  5  2  2  (a  3b)  2(a  4b)  a  3b  2a  8b  3a  11b
2  2 1  0
Hence, a(3) + b(-11) =1 and thus t = -11. Since t is negative, we convert it to positive form
by computing t = t MOD a = -11 MOD 83 = 15. Thus, b1  71  t  15. We can
check our answer by computing b  b1 MOD a  (7)(15) MOD 26  104 MOD 26  1
Completing the above problem, we have
x  (71  3) MOD 26  (15  3) MOD 26  45 MOD 26  19.
█
Note: If gcd( a, b)  1 , b 1 MOD a does not exist.
Example 16: Compute 121 MOD 40 .
Solution: From the Euclidean algorithm, setting a = 40 and b = 12, we see that
40  3  12  4
12  3  4  0
Thus, gcd(1a, b)  gcd( 40,12)  4  1 . Hence, 121 MOD 40 does not exist.
█
Download