1. Algebra 1.7. Prime numbers

Size: px
Start display at page:

Download "1. Algebra 1.7. Prime numbers"

Transcription

1 1. ALGEBRA Algebra 1.7. Prime numbers Definition Let n Z, with n 2. If n is not a prime number, then n is called a composite number. We look for a way to test if a given positive integer is prime or composite. The first test is based on Fermat s little theorem Fermat Test This test is based on Fermat s little theorem. If n is a prime number and a Z, with gcd(a, n) = 1, then Fermat s little theorem implies that a n 1 1 (mod n). Thus if a n 1 1 (mod n), then n is composite. Fermat Test Let n Z, with n 2. Let a Z, with gcd(a, n) = 1. If a n 1 1 (mod n), then we say that n passes the Fermat test for a (mod 341), so 341 passes the Fermat test for (mod 341), so 341 does not passes the Fermat test for 3. Hence 341 is a composite number (in fact, 341 = 11 31). Remark Since the test is based on modular arithmetic it suffices to take 1 a n, but in fact we will assume 1 < a < n, for 1 and n are not the numbers you want to test on. If for such an a we have gcd(a, n) 1, then 1 < gcd(a, n) < n, so n is composite. Thus always first calculate the greatest common divisor. Definition Let n be a composite number, a Z, with gcd(a, n) = 1. If n passes the Fermat test for a, we say that n is an a-pseudo prime. If n is an a-pseudo prime for all a Z with gcd(a, n) = 1, then n is called a Carmichael number. If n is an even number with n 2, then it is clearly not prime. We are mainly interested in odd numbers. The following theorem tells us that Carmichael numbers exist, that is there exist numbers n that passes the Fermat test for any a Z, with gcd(a, n) = 1. Theorem Let n Z, with n 3 and n odd. Then n is a Carmichael number if and only if n = p 1 p 2 p s, where s 2, p 1,..., p s are distinct odd prime numbers, and (p i 1) (n 1) for all i {1, 2,..., s}. Proof. Suppose n = p 1 p 2 p s, where s 2, p 1,..., p s are distinct odd prime numbers, and (p i 1) (n 1) for all i {1, 2,..., s}. Consider the isomorphism ( Z /n Z ) = ( Z /p 1 Z ) ( Z /p 2 Z ) ( Z /p s Z ) [b] n ([b] p1, [b] p2,..., [b] ps ). For each i {1, 2,..., s} the group ( Z /p i Z ) is a cyclic group of order p i 1 and (p i 1) (n 1). Hence for each i {1, 2,..., s} we have ([b] pi ) n 1 = [1] pi, that is (([b] p1, [b] p2,..., [b] ps )) n 1 = ([1] p1, [1] p2,..., [1] ps ). It follows that for any element of g ( Z /n Z ), we have o(g) (n 1). Now let a Z, with gcd(a, n) = 1. Then [a] n ( Z /n Z ), so ([a] n ) n 1 = [1] n. Hence a n 1 1 (mod n), and thus n

2 1. ALGEBRA 31 is an a-pseudo prime. Since this is true for any a Z with gcd(a, n) = 1, it follows that n is a Carmichael number. Suppose n is a Carmichael number. If a Z, with gcd(a, n) = 1, then a n 1 1 (mod n), that is ([a] n ) n 1 = [1] n. In particular o([a] n ) divides n 1, for any [a] n ( Z /n Z ). Write n = p r1 1 pr2 2 prs s, where p 1,..., p s are distinct odd prime numbers and r i 1, for all i {1, 2,..., s}. Consider the isomorphism ( Z /n Z ) = ( Z /p r1 1 Z ) ( Z /p r2 2 Z ) ( Z /p rs s Z ) [b] n ([b] r p 1, [b] r 1 p 2,..., [b] 2 p rs ). s For each i {1, 2,..., s} let β i be a generator of the cyclic group ( Z /p ri i Z ) and let a i Z, with 1 a i < n, be such that ( Z /n Z ) = ( Z /p r1 1 Z ) ( Z /p r2 2 Z ) ( Z /p ri i Z )... ( Z /p rs s Z ) [a i ] n (1, 1,..., β i,..., 1) Thus o([a i ] n ) = p r1 1 i (p i 1). So for each i {1, 2,..., s}, p r1 1 i (p i 1) divides n 1, whence r i = 1, since p i and n 1 are relatively prime. Thus n = p 1 p 2 p s, where p 1,..., p s are distinct odd prime numbers, and (p i 1) (n 1) for all i {1, 2,..., s}. Since n is not prime we have s 2.. Some Carmichael numbers are 561 = , for 560 = ; 1105 = , for 1104 = ; 1729 = , for 1728 = Remark It was shown in 1994 that there are an infinite number of Carmichael numbers Miller-Rabin Test Let n be an odd number, s = max{r Z 2 r divides n 1} and d = n 1 2 s. So n 1 = 2 s d, with d Z an odd number, and s and d are easely calculated. Lemma Let n be an odd prime number and a Z, with gcd(a, n) = 1. One of the following holds: (i) a d 1 (mod n). (ii) there exists an r {0,..., s 1}, such that a d 2r 1 (mod n). Proof. Let n be an odd prime and a Z, with gcd(a, n) = 1, so [a] n ( Z /n Z ). Since n is an odd prime the group ( Z /n Z ) is cyclic of order n 1. In particular, it has only one element of order 2, namely [ 1] n. Let k = o([a d ] n ). Since ([a d ] n ) 2s = ([a] n ) n 1 = [1] n, we have k 2 s. If k = 1, then [a d ] n = [1] n, so (i) holds. If k 1, then k = 2 l, for certain 1 l s. Now [1] n = ([a d ] n ) 2l = (([a d ] n ) 2l 1 ) 2 and ([a d ] n ) 2l 1 [1] n. Thus ([a d ] n ) 2l 1 is an element of order 2. Whence ([a d ] n ) 2l 1 = [ 1] n, that is a d 2l 1 1 (mod n). Let r = l 1, then 0 r < s and a d 2r 1 (mod n), so (ii) holds.

3 1. ALGEBRA 32 Miller-Rabin Test Let n Z, be n an odd number with n 2. Let a Z, with gcd(a, n) = 1. Consider the sequence [a d ] n, ([a d ] n ) 2,..., ([a d ] n ) 2s 1. If either this sequence is all 1, or 1 appears in it, then we say that n passes the Miller-Rabin test for a. Since ([a d ] n ) 2i+1 = (([a d ] n ) 2i ) 2, the lemma states that if n is a prime then either this sequence is all 1, or 1 appears in it. So all primes pass the Miller-Rabin test for any a Z with gcd(a, n) = 1. The answer depends only on a (mod n), so one can assume that 1 a < n. Remark Observe that for a = 1 and a = n 1, n passes the Miller-Rabin test for a. Definition Let n be a composite number, a Z, with gcd(a, n) = 1. If n passes the Miller-Rabin test for a, we say that n is a strong a-pseudo prime, and a will be called a false witness. If n does not pass the Miller-Rabin test for a, we say that a is a witness for n being a composite number. Let n = 561, which is a Carmichael number, then n 1 = Consider the sequence [a 35 ] n, ([a 35 ] n ) 2, ([a 35 ] n ) 4, ([a 35 ] n ) 8. If a = 2, then the sequence is 263, 166, 67, 1; 2 is a witness that 561 is composite; If a = 101, then the sequence is 1, 1, 1, 1; 101 is a false witness; If a = 103, then the sequence is 1, 1, 1, 1; 103 is a false witness; Thus 561 is a strong 101-pseudo prime and a strong 103-pseudo prime. Lemma Any strong a-pseudo prime is also an a-pseudo prime. Proof. If either [a d ] n = [1] n or ([a d ] n ) 2r = [ 1] n, for some 0 r < s, then ([a d ] n ) 2s = [1] n. Hence ([a] n ) n 1 = [1] n, so n passes the Fermat test for a. Let n be an odd number and a Z, with gcd(a, n) = 1, and d, s Z such that n 1 = 2 s d, with d an odd number. Suppose n is a strong a-pseudo prime. Since it is also a a-pseudo prime, we have ([a d ] n ) 2s = [1] n. Thus the order of [a d ] n divides 2 s. If ([a d ] n ) 2r = [ 1] n, for some 0 r < s, then o([a d ] n ) = 2 r+1. Though it is not true that if o([a d ] n ) = 2 r+1, then ([a d ] n ) 2r = [ 1] n. The element ([a d ] n ) 2r will be of order 2, but need not be [ 1] n. Moreover, we have [a d ] n = [1] n if and only if o([a d ] n ) = 1. Thus the order of [a d ] n determines whether the sequence is all 1 or the place where a [ 1] n could appear. Before we can determine false witnesses we need a lemma about d-th powers of elements in Abelian groups. Lemma Let G be a finite Abelian group d Z with d 1 an odd number and r Z, with r 0. Let A r = {a G o(a) = 2 r }, the set of elements of order 2 r, and K = {g G o(g) d}, the set of elements whose order divides d. Then {g g d A r } = {ak a A r, k K}. Moreover, {g g d A r } = A r K.

4 1. ALGEBRA 33 Proof. Consider ψ : G G defined by ψ : g g d. Since G is Abelian this is a homomorphism of groups. If a A r, then o(a d ) = o(a) so ψ(a r ) A r. On the other hand, if a, b A r with ψ(a) = ψ(b), then a d = b d and so (ab 1 ) d = 1. But (ab 1 ) 2r = 1 and gcd(d, 2 r ) = 1, so ab 1 = 1. Hence a = b. Since A r is a finite set we have A r = ψ(a r ). Let X={g g d A r } and Y = {ak a A r, k K}. We claim that X = Y. Let g X, then g d = a for some a A r. By the above a = b d, for some b A r. So g d = b d. Hence (gb 1 ) d = 1. Hence gb 1 K and g = b(gb 1 ) Y. On the other hand, if g Y then g = ak for some a A r and k K, then g d = (ak) d = a d k d = a d A r, so g X. If a 1, a 2 A r and k 1, k 2 K, with a 1 k 1 = a 2 k 2, then a 1 2 a 1 = k 2 k1 1. But o(a 1 2 a 1) 2 r and o(k 2 k1 1 ) d, hence o(a 1 2 a 1) = o(k 2 k1 1 ) = 1. It follows that a 1 = a 2 and k 1 = k 2 and thus {ak a A r, k K} = A r K. We find the numbers a, 1 < a < 561 for which n = 561 is a strong a-pseudo prime. Since 561 = we consider the isomorphism ( Z /561 Z ) = ( Z /3 Z ) ( Z /11 Z ) ( Z /17 Z ) [b] 561 ([b] 3, [b] 11, [b] 17 ). Since all three latter groups are cyclic, they contain exactly one element of order 2. Since 560 = the sequence becomes [a 35 ] 561, ([a 35 ] 561 ) 2, ([a 36 ] 561 ) 22, ([a 35 ] 561 ) 23. Case 1. [a 35 ] 561 = [1] 561. This holds if and only if o([a] 561 ) divides 35. Hence if and only if o([a] 3 ), o([a] 11 ) and o([a] 17 ), divide 35. It follows that o([a] 3 ) = 1, o([a] 11 ) divides 5 and o([a] 17 ) = 1. So there are 5 possibilities, one of which is ([1] 561 ). The elements of order 5 in ( Z /11 Z ) are [3] 11, [4] 11, [5] 11 and [9] 11. Thus the elements are ([1] 3, [b] 11, [1] 17 ), with [b] 11 {[3] 11, [4] 11, [5] 11, [9] 11, [1] 11 }, that is [256] 561, [103] 561, [511] 561, [460] 561 and [1] 561. Case 2. [a 35 ] 561 = [ 1] 561. This holds if and only ([a] 3, [a] 11, [a] 17 ) 35 = ([ 1] 3, [ 1] 11, [ 1] 17 ). This holds if and only if o([a 35 ] 3 ) = o([a 35 ] 11 ) = o([a 35 ] 17 ) = 2. The elements are ([ 1] 3, [b] 11, [ 1] 17 ), with [b] 11 {[ 3] 11, [ 4] 11, [ 5] 11, [ 9] 11, [ 1] 11 }, that is [305] 561, [458] 561, [50] 561 [101] 561 and [560] 561. Case 3. ([a 35 ] 561 ) 2i = [ 1] 561, with i 1. This holds if and only if ([a 35 ] 3, [a 35 ] 11, [a 35 ] 17 )) 2i = ([ 1] 3, [ 1] 11, [ 1] 17 ). Hence, if and only if o([a 35 ] 3 ) = o([a 35 ] 11 ) = o([b 35 ] 17 ) = 2 i+1. Observe that there are no possibilities for the algorithm to give such a sequence as an answer as ( Z /3 Z ) does not contain elements of order 4. Let n = 481 and a Z, with 1 a < 481 and gcd(a, n) = 1. We count the number of values of a such that 481 is a strong a-pseudo prime. We have ( Z /481 Z ) = ( Z /13 Z ) ( Z /37 Z ). Since n 1 = 480 = and the sequence becomes [a 15 ] 481, ([a 15 ] 481 ) 2, ([a 15 ] 481 ) 22, ([a 15 ] 481 ) 23, ([a 15 ] 481 ) 24. Case 1. [a 15 ] 481 = [1] 481. This holds if and only if ([a 15 ] 13, [a 15 ] 37 ) = ([1] 13, [1] 37 ). Hence, if and only if o([a] 13 ) 15 and o([a] 37 ) 15. We look at the 2 groups separately. In ( Z /13 Z ) we have that, since gcd(15, 12) = 3, [a 15 ] 13 = [1] 13 if and only if [a 3 ] 13 = [1] 13. Moreover, this group is cyclic so has 3 elements with this property. In ( Z /37 Z ) we have that, since gcd(15, 36) = 3, [a 15 ] 37 = [1] 37 if and only if [a 3 ] 37 = [1] 37. Moreover, this group is cyclic so has 3 elements with this property. Hence there are 3 3 = 9 values for a in this case.

5 1. ALGEBRA 34 Case 2. [a 15 ] 481 = [ 1] 481. This holds if and only if ([a 15 ] 13, [a 15 ] 37 ) = ([ 1] 13, [ 1] 37 ). Hence, if and only if o([a 15 ] 13 ) = o([a 15 ] 37 ) = 2. Hence there are 3 3 = 9 values for a in this case. Case 3. ([a 15 ] 481 ) 2 = [ 1] 481. This holds if and only if (([a 15 ] 13 ) 2, ([a 15 ] 37 ) 2 ) = ([ 1] 13, [ 1] 37 ). Hence, if and only if o([a 15 ] 13 ) = o([a 15 ] 37 ) = 4. Hence there are 6 6 = 36 values for a in this case. Case 4. ([a 15 ] 481 ) 2i = [ 1] 481, with i 2. This holds if and only if (([a 15 ] 13 ) 2i, ([a 15 ] 37 ) 2i ) = ([ 1] 13, [ 1] 37 ). Hence, if and only if o([a 15 ] 13 ) = o([a 15 ] 37 ) = 2 i+1. This is not possible for ( Z /13 Z ) has no elements of order 8. Hence there are 54 a Z, with 1 a < 481 and gcd(a, n) = 1, that are a false witness. We will redo this calculation now in a different, more down to earth, way. Let n = 481 and a Z, with 1 a < 481 and gcd(a, n) = 1. We count the number of values of a such that 481 is a strong a-pseudo prime. We have ( Z /481 Z ) = ( Z /13 Z ) ( Z /37 Z ). Since n 1 = 480 = and the sequence becomes [a 15 ] 481, ([a 15 ] 481 ) 2, ([a 15 ] 481 ) 22, ([a 15 ] 481 ) 23, ([a 15 ] 481 ) 24. Case 1. The calculation remains the same as in the previous way. Case 2. [a 15 ] 481 = [ 1] 481. This holds if and only if ([a 15 ] 13, [a 15 ] 37 ) = ([ 1] 13, [ 1] 37 ). We look at the 2 groups separately. In ( Z /13 Z ) we have [a 15 ] 13 = [ 1] 13 if and only if [a 30 ] 13 = 1 and [a 15 ] 13 1, for the group has only one element of order 2, namely [ 1] 13. Thus [a 15 ] 13 = [ 1] 13 if and only if o([a] 13 ) 30 and o([a] 13 ) 15. Since gcd(12, 30) = 6, gcd(12, 15) = 3 and the group is cyclic, there are 6 3 = 3 choices for [a] 13. In ( Z /37 Z ) we have [a 15 ] 37 = [ 1] 13 if and only if [a 30 ] 37 = 1 and [a 15 ] 37 1, for the group has only one element of order 2, namely [ 1] 37. Thus [a 15 ] 37 = [ 1] 37 if and only if o([a] 37 ) 30 and o([a] 37 ) 15. Since gcd(36, 30) = 6, gcd(36, 15) = 3 and the group is cyclic, there are 6 3 = 3 choices for [a] 37. Hence 3 3 = 9 numbers in total. Case 3. [a 30 ] 481 = [ 1] 481. This holds if and only if ([a 30 ] 13, [a 30 ] 37 ) = ([ 1] 13, [ 1] 37 ). We look at the 2 groups separately. In ( Z /13 Z ) we have [a 30 ] 13 = [ 1] 13 if and only if [a 60 ] 13 = 1 and [a 30 ] 13 1, for the group has only one element of order 2, namely [ 1] 13 ). Thus [a 30 ] 13 = [ 1] 13 if and only if o([a] 13 ) 60 and o([a] 13 ) 30. Since gcd(12, 60) = 12, gcd(12, 30) = 6 and the group is cyclic, there are 12 6 = 6 choices for [a] 13. In ( Z /37 Z ) we have [a 30 ] 37 = [ 1] 13 if and only if [a 60 ] 37 = 1 and [a 30 ] 37 1, for the group has only one element of order 2, namely [ 1] 37 ). Thus [a 30 ] 37 = [ 1] 37 if and only if o([a] 37 ) 60 and o([a] 37 ) 30. Since gcd(36, 60) = 12, gcd(36, 30) = 6 and the group is cyclic there are 12 6 = 6 choices for [a] 37. Hence 6 6 = 36 numbers in total. Case 4. ([a 15 ] 481 ) 2i = [ 1] 481, with i 2. This holds if and only if (([a 15 ] 13 ) 2i, ([a 15 ] 37 ) 2i ) = ([ 1] 13, [ 1] 37 ). We look at the first group. In ( Z /13 Z ) we have [a 15 ] 2i 13 = [ 1] 13 if and only if [a 15 ] 2i+1 13 = [1] 13 and [a 15 ] 2i 13 [ 1] 13, for the group has only one element of order 2, namely [ 1] 13 ). Thus [a 15 ] 2i 13 = [ 1] 13 if and only if o([a] 13 ) 15 2 i+1 and o([a] 13 ) 15 2 i+1. Since gcd(12, 15 2 i+1 ) = 12 and gcd(12, 15 2 i ) = 12, there are no possible choices for [a] 13. Hence there are 54 a Z, with 1 a < 481 and gcd(a, n) = 1, that are a false witness. Lemma For any odd composite number n there exists an a Z, with 1 < a < n and gcd(a, n) = 1, such that a is a witness for n being composite.

6 1. ALGEBRA 35 Proof. Let n = p r1 1 pr2 2 prt t, where p 1,..., p t are distinct odd prime numbers and r i 1, for all i {1, 2,..., t} be the factorization of n in primes. Let n 1 = 2 s d, with d odd. Consider the isomorphism ( Z /n Z ) = ( Z /p r1 1 Z ) ( Z /p r2 2 Z ) ( Z /p rt t Z ) [b] n ([b] r p 1, [b] r 1 p 2,..., [b] r ). 2 p t t Suppose t 2. Let a Z, with 1 < a < n, be such that [a] n ([ 1] p r 1 1, [1] p r 2,..., [1] r 2 p t ). Then t [a d ] n = [a] n [±1] n, since d is odd and t 2, and ([a d ] n ) 2 = [1] n. If s = 1, then the sequence consists only of [a d ] n, and a is a witness. If s 2, then the sequence starts with [a d ] n, [1] n,..., hence a is a witness. If t = 1 and r 1 > 1, then gcd(d, p 1 ) = 1. In this case we have ( Z /n Z ) = ( Z /p r1 1 Z ), which is a group cyclic group of order p r1 1 1 (p 1 1). Let a Z, with 1 < a < n, be such that [a] n has order p 1 (there are p 1 1 of them). Since o([a d ] n ) = p 1 we have o([a d ] n ) 2i = p 1 too. Hence ([a d ] n ) 2i [ 1] n, since o([ 1] n ) = 2, thus a is a witness. In fact there are many witnesses. Theorem (Rabin, 1980) Let n 3 be an odd composite number. At most 1 4 a Z, with 1 < a < n and gcd(a, n) = 1, is a false witness. of the numbers Let n 3 be an odd composite number and a Z, with 1 < a < n. If gcd(a, n) 1, then n is composite. If gcd(a, n) = 1, then the probability that n passes the Miller-Rabin test for a is at most. In fact, there are better estimates one can make. 1 4 Remarks Between 1 and there are prime numbers, pseudo primes and 3291 strong 2-pseudo primes. In practice one can use the Miller-Rabin test to create large prime numbers. We look for a prime p with p < Then, in base 2, p can represented as a bit string of length 128, which starts and ends with 1. Now choose a random bit string of length 128, which starts and end with 1, and let n be the corresponding number in base 2. Then apply the following probabilistic test to see if the number is prime: Check if n is divisible by a prime less then 10 6 (there is a known list of these primes). If not, then apply the Miller-Rabin test for 3 different values of a. If the number has survived this test then the probability that n is not a prime is less then ( 1 2 )80. In 2002 Manindra Agrawal, Neeraj Kayal, and Nitin Saxena, created a deterministic primalityproving algorithm. The algorithm, known as the AKS primality test, determines whether a number is prime or composite within polynomial time (over the number of digits). Current implementations are not fast enough yet. Lemma Let n be an odd number and a Z, with gcd(a, n) = 1. If n is an a-pseudo prime, but not a strong a-pseudo prime, then there exist a fast algorithm to find some factors of n. Proof. Let n 1 = 2 s d, with d odd. Consider the sequence [a d ] n, ([a d ] n ) 2,..., ([a d ] n ) 2s 1, ([a d ] n ) 2s. Since n is an a-pseudo prime we have ([a d ] n ) 2s = [1] n. Since but not a strong a-pseudo prime the sequence [a d ] n, ([a d ] n ) 2,..., ([a d ] n ) 2s 1 is not all 1 nor does it contain [ 1] n. Whence there exists an 0 l < s, such that ([a d ] n ) 2l [±1] n, and ([a d ] n ) 2l+1 = [1] n. Let b Z, with 0 b < n such that b a 2l d (mod n). Then b 2 1 (mod n)

7 1. ALGEBRA 36 and b ±1 (mod n). In particular, n divides (b 2 1) = (b + 1)(b 1). If gcd(n, b 1) = 1, then n (b+1), contradicting the fact that b 1 (mod n). If gcd(n, b 1) = n, then n (b 1), contradicting the fact that b 1 (mod n). Hence 1 < gcd(n, b 1) < n. Similarly 1 < gcd(n, b + 1) < n. Let n = 561, which is a Carmichael number, and a = 2. Then n 1 = 560 = The sequence [2 35 ] n, ([2 35 ] n ) 2, ([2 35 ] n ) 4, ([2 35 ] n ) 8, ([2 35 ] n ) 16 equals 263, 166, 67, 1, 1. Let b = 67, then gcd(561, 66) = 11 and gcd(561, 68) = 17. Thus 11 and 17 are divisors of 561. Indeed 561 = In particular, if n is the product of two odd primes, then the above algorithm give a way of factorizing n into primes. The RSA-modules should therefore not be of this type.

Factorization & Primality Testing

Factorization & Primality Testing Factorization & Primality Testing C etin Kaya Koc http://cs.ucsb.edu/~koc koc@cs.ucsb.edu Koc (http://cs.ucsb.edu/~ koc) ucsb ccs 130h explore crypto fall 2014 1/1 Primes Natural (counting) numbers: N

More information

Applied Cryptography and Computer Security CSE 664 Spring 2018

Applied Cryptography and Computer Security CSE 664 Spring 2018 Applied Cryptography and Computer Security Lecture 12: Introduction to Number Theory II Department of Computer Science and Engineering University at Buffalo 1 Lecture Outline This time we ll finish the

More information

Primality Testing. 1 Introduction. 2 Brief Chronology of Primality Testing. CS265/CME309, Fall Instructor: Gregory Valiant

Primality Testing. 1 Introduction. 2 Brief Chronology of Primality Testing. CS265/CME309, Fall Instructor: Gregory Valiant CS265/CME309, Fall 2018. Instructor: Gregory Valiant Primality Testing [These notes may not be distributed outside this class without the permission of Gregory Valiant.] 1 Introduction Prime numbers are

More information

Corollary 4.2 (Pepin s Test, 1877). Let F k = 2 2k + 1, the kth Fermat number, where k 1. Then F k is prime iff 3 F k 1

Corollary 4.2 (Pepin s Test, 1877). Let F k = 2 2k + 1, the kth Fermat number, where k 1. Then F k is prime iff 3 F k 1 4. Primality testing 4.1. Introduction. Factorisation is concerned with the problem of developing efficient algorithms to express a given positive integer n > 1 as a product of powers of distinct primes.

More information

Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn

Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn Randomization Randomized Algorithm: An algorithm that uses (or can use) random coin flips in order to make decisions We will see: randomization

More information

Introduction to Number Theory. The study of the integers

Introduction to Number Theory. The study of the integers Introduction to Number Theory The study of the integers of Integers, The set of integers = {... 3, 2, 1, 0, 1, 2, 3,...}. In this lecture, if nothing is said about a variable, it is an integer. Def. We

More information

Advanced Algorithms and Complexity Course Project Report

Advanced Algorithms and Complexity Course Project Report Advanced Algorithms and Complexity Course Project Report Eklavya Sharma (2014A7PS0130P) 26 November 2017 Abstract This document explores the problem of primality testing. It includes an analysis of the

More information

NUMBER THEORY. Anwitaman DATTA SCSE, NTU Singapore CX4024. CRYPTOGRAPHY & NETWORK SECURITY 2018, Anwitaman DATTA

NUMBER THEORY. Anwitaman DATTA SCSE, NTU Singapore CX4024. CRYPTOGRAPHY & NETWORK SECURITY 2018, Anwitaman DATTA NUMBER THEORY Anwitaman DATTA SCSE, NTU Singapore Acknowledgement: The following lecture slides are based on, and uses material from the text book Cryptography and Network Security (various eds) by William

More information

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald)

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald) Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald) 1 Euclid s Algorithm Euclid s Algorithm for computing the greatest common divisor belongs to the oldest known computing procedures

More information

MATH 145 Algebra, Solutions to Assignment 4

MATH 145 Algebra, Solutions to Assignment 4 MATH 145 Algebra, Solutions to Assignment 4 1: a) Find the inverse of 178 in Z 365. Solution: We find s and t so that 178s + 365t = 1, and then 178 1 = s. The Euclidean Algorithm gives 365 = 178 + 9 178

More information

Instructor: Bobby Kleinberg Lecture Notes, 25 April The Miller-Rabin Randomized Primality Test

Instructor: Bobby Kleinberg Lecture Notes, 25 April The Miller-Rabin Randomized Primality Test Introduction to Algorithms (CS 482) Cornell University Instructor: Bobby Kleinberg Lecture Notes, 25 April 2008 The Miller-Rabin Randomized Primality Test 1 Introduction Primality testing is an important

More information

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 9.1 Chapter 9 Objectives

More information

p = This is small enough that its primality is easily verified by trial division. A candidate prime above 1000 p of the form p U + 1 is

p = This is small enough that its primality is easily verified by trial division. A candidate prime above 1000 p of the form p U + 1 is LARGE PRIME NUMBERS 1. Fermat Pseudoprimes Fermat s Little Theorem states that for any positive integer n, if n is prime then b n % n = b for b = 1,..., n 1. In the other direction, all we can say is that

More information

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications n-bit unsigned integer representation Represent integer x as sum of powers of 2: If x = n 1 i=0 b i 2 i where each b i

More information

ECEN 5022 Cryptography

ECEN 5022 Cryptography Elementary Algebra and Number Theory University of Colorado Spring 2008 Divisibility, Primes Definition. N denotes the set {1, 2, 3,...} of natural numbers and Z denotes the set of integers {..., 2, 1,

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 10 February 19, 2013 CPSC 467b, Lecture 10 1/45 Primality Tests Strong primality tests Weak tests of compositeness Reformulation

More information

LARGE PRIME NUMBERS. In sum, Fermat pseudoprimes are reasonable candidates to be prime.

LARGE PRIME NUMBERS. In sum, Fermat pseudoprimes are reasonable candidates to be prime. LARGE PRIME NUMBERS 1. Fermat Pseudoprimes Fermat s Little Theorem states that for any positive integer n, if n is prime then b n % n = b for b = 1,..., n 1. In the other direction, all we can say is that

More information

Introduction to Public-Key Cryptosystems:

Introduction to Public-Key Cryptosystems: Introduction to Public-Key Cryptosystems: Technical Underpinnings: RSA and Primality Testing Modes of Encryption for RSA Digital Signatures for RSA 1 RSA Block Encryption / Decryption and Signing Each

More information

LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS

LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS Modular arithmetics that we have discussed in the previous lectures is very useful in Cryptography and Computer Science. Here we discuss several

More information

Chapter 7 Randomization Algorithm Theory WS 2017/18 Fabian Kuhn

Chapter 7 Randomization Algorithm Theory WS 2017/18 Fabian Kuhn Chapter 7 Randomization Algorithm Theory WS 2017/18 Fabian Kuhn Randomization Randomized Algorithm: An algorithm that uses (or can use) random coin flips in order to make decisions We will see: randomization

More information

A polytime proof of correctness of the Rabin-Miller algorithm from Fermat s Little Theorem

A polytime proof of correctness of the Rabin-Miller algorithm from Fermat s Little Theorem A polytime proof of correctness of the Rabin-Miller algorithm from Fermat s Little Theorem Grzegorz Herman and Michael Soltys November 24, 2008 Abstract Although a deterministic polytime algorithm for

More information

Lecture 31: Miller Rabin Test. Miller Rabin Test

Lecture 31: Miller Rabin Test. Miller Rabin Test Lecture 31: Recall In the previous lecture we considered an efficient randomized algorithm to generate prime numbers that need n-bits in their binary representation This algorithm sampled a random element

More information

PRIMALITY TESTING. Professor : Mr. Mohammad Amin Shokrollahi Assistant : Mahdi Cheraghchi. By TAHIRI JOUTI Kamal

PRIMALITY TESTING. Professor : Mr. Mohammad Amin Shokrollahi Assistant : Mahdi Cheraghchi. By TAHIRI JOUTI Kamal PRIMALITY TESTING Professor : Mr. Mohammad Amin Shokrollahi Assistant : Mahdi Cheraghchi By TAHIRI JOUTI Kamal TABLE OF CONTENTS I- FUNDAMENTALS FROM NOMBER THEORY FOR RANDOMIZED ALGORITHMS:.page 4 1)

More information

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications casting out 3s Theorem: A positive integer n is divisible by 3 if and only if the sum of its decimal digits is divisible

More information

Ma/CS 6a Class 4: Primality Testing

Ma/CS 6a Class 4: Primality Testing Ma/CS 6a Class 4: Primality Testing By Adam Sheffer Reminder: Euler s Totient Function Euler s totient φ(n) is defined as follows: Given n N, then φ n = x 1 x < n and GCD x, n = 1. In more words: φ n is

More information

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory. CSS322: Security and Cryptography Sirindhorn International Institute of Technology Thammasat University Prepared by Steven Gordon on 29 December 2011 CSS322Y11S2L06, Steve/Courses/2011/S2/CSS322/Lectures/number.tex,

More information

LARGE PRIME NUMBERS (32, 42; 4) (32, 24; 2) (32, 20; 1) ( 105, 20; 0).

LARGE PRIME NUMBERS (32, 42; 4) (32, 24; 2) (32, 20; 1) ( 105, 20; 0). LARGE PRIME NUMBERS 1. Fast Modular Exponentiation Given positive integers a, e, and n, the following algorithm quickly computes the reduced power a e % n. (Here x % n denotes the element of {0,, n 1}

More information

Lecture 6: Deterministic Primality Testing

Lecture 6: Deterministic Primality Testing Lecture 6: Deterministic Primality Testing Topics in Pseudorandomness and Complexity (Spring 018) Rutgers University Swastik Kopparty Scribe: Justin Semonsen, Nikolas Melissaris 1 Introduction The AKS

More information

PRIMES is in P. Manindra Agrawal. NUS Singapore / IIT Kanpur

PRIMES is in P. Manindra Agrawal. NUS Singapore / IIT Kanpur PRIMES is in P Manindra Agrawal NUS Singapore / IIT Kanpur The Problem Given number n, test if it is prime efficiently. Efficiently = in time a polynomial in number of digits = (log n) c for some constant

More information

RSA Key Generation. Required Reading. W. Stallings, "Cryptography and Network-Security, Chapter 8.3 Testing for Primality

RSA Key Generation. Required Reading. W. Stallings, Cryptography and Network-Security, Chapter 8.3 Testing for Primality ECE646 Lecture RSA Key Generation Required Reading W. Stallings, "Cryptography and Network-Security, Chapter 8.3 Testing for Primality A.Menezes, P. van Oorschot, and S. Vanstone, Handbook of Applied Cryptography

More information

CSE 521: Design and Analysis of Algorithms I

CSE 521: Design and Analysis of Algorithms I CSE 521: Design and Analysis of Algorithms I Randomized Algorithms: Primality Testing Paul Beame 1 Randomized Algorithms QuickSelect and Quicksort Algorithms random choices make them fast and simple but

More information

Shor s Algorithm. Elisa Bäumer, Jan-Grimo Sobez, Stefan Tessarini May 15, 2015

Shor s Algorithm. Elisa Bäumer, Jan-Grimo Sobez, Stefan Tessarini May 15, 2015 Shor s Algorithm Elisa Bäumer, Jan-Grimo Sobez, Stefan Tessarini May 15, 2015 Integer factorization n = p q (where p, q are prime numbers) is a cryptographic one-way function Classical algorithm with best

More information

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006 Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Spring 2006 1 / 1 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 2.4 2.6 of Rosen Introduction I When talking

More information

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points.

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points. Math 152, Problem Set 2 solutions (2018-01-24) All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points. 1. Let us look at the following equation: x 5 1

More information

Primality Testing- Is Randomization worth Practicing?

Primality Testing- Is Randomization worth Practicing? Primality Testing- Is Randomization worth Practicing? Shubham Sahai Srivastava Indian Institute of Technology, Kanpur ssahai@cse.iitk.ac.in April 5, 2014 Shubham Sahai Srivastava (IITK) Primality Test

More information

Chapter 1. Number of special form. 1.1 Introduction(Marin Mersenne) 1.2 The perfect number. See the book.

Chapter 1. Number of special form. 1.1 Introduction(Marin Mersenne) 1.2 The perfect number. See the book. Chapter 1 Number of special form 1.1 Introduction(Marin Mersenne) See the book. 1.2 The perfect number Definition 1.2.1. A positive integer n is said to be perfect if n is equal to the sum of all its positive

More information

CSC 373: Algorithm Design and Analysis Lecture 30

CSC 373: Algorithm Design and Analysis Lecture 30 CSC 373: Algorithm Design and Analysis Lecture 30 Allan Borodin April 5, 2013 1 / 12 Announcements and Outline Announcements Two misstated questions on term test Grading scheme for term test 3: 1 Test

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 9 February 6, 2012 CPSC 467b, Lecture 9 1/53 Euler s Theorem Generating RSA Modulus Finding primes by guess and check Density of

More information

CS 4770: Cryptography. CS 6750: Cryptography and Communication Security. Alina Oprea Associate Professor, CCIS Northeastern University

CS 4770: Cryptography. CS 6750: Cryptography and Communication Security. Alina Oprea Associate Professor, CCIS Northeastern University CS 4770: Cryptography CS 6750: Cryptography and Communication Security Alina Oprea Associate Professor, CCIS Northeastern University March 15 2018 Review Hash functions Collision resistance Merkle-Damgaard

More information

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}. 2 Arithmetic This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}. (See [Houston, Chapters 27 & 28]) 2.1 Greatest common divisors Definition 2.16. If a, b are integers, we say

More information

CSE 311: Foundations of Computing. Lecture 12: Two s Complement, Primes, GCD

CSE 311: Foundations of Computing. Lecture 12: Two s Complement, Primes, GCD CSE 311: Foundations of Computing Lecture 12: Two s Complement, Primes, GCD n-bit Unsigned Integer Representation Represent integer as sum of powers of 2: If 2 where each {0,1} then representation is b

More information

Algorithms (II) Yu Yu. Shanghai Jiaotong University

Algorithms (II) Yu Yu. Shanghai Jiaotong University Algorithms (II) Yu Yu Shanghai Jiaotong University Chapter 1. Algorithms with Numbers Two seemingly similar problems Factoring: Given a number N, express it as a product of its prime factors. Primality:

More information

3 The fundamentals: Algorithms, the integers, and matrices

3 The fundamentals: Algorithms, the integers, and matrices 3 The fundamentals: Algorithms, the integers, and matrices 3.4 The integers and division This section introduces the basics of number theory number theory is the part of mathematics involving integers

More information

About complexity. Number theoretical algorithms

About complexity. Number theoretical algorithms Page 1 About complexity We define the class informally P in the following way: P = The set of all problems that can be solved by a polynomial time algorithm, i.e., an algorithm that runs in time O(n k

More information

ALG 4.0 Number Theory Algorithms:

ALG 4.0 Number Theory Algorithms: Algorithms Professor John Reif ALG 4.0 Number Theory Algorithms: (a) GCD (b) Multiplicative Inverse (c) Fermat & Euler's Theorems (d) Public Key Cryptographic Systems (e) Primality Testing Greatest Common

More information

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p. Chapter 6 Prime Numbers Part VI of PJE. Definition and Fundamental Results Definition. (PJE definition 23.1.1) An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p. If n > 1

More information

Mathematics for Cryptography

Mathematics for Cryptography Mathematics for Cryptography Douglas R. Stinson David R. Cheriton School of Computer Science University of Waterloo Waterloo, Ontario, N2L 3G1, Canada March 15, 2016 1 Groups and Modular Arithmetic 1.1

More information

Lecture 11 - Basic Number Theory.

Lecture 11 - Basic Number Theory. Lecture 11 - Basic Number Theory. Boaz Barak October 20, 2005 Divisibility and primes Unless mentioned otherwise throughout this lecture all numbers are non-negative integers. We say that a divides b,

More information

Algorithmic number theory. Questions/Complaints About Homework? The division algorithm. Division

Algorithmic number theory. Questions/Complaints About Homework? The division algorithm. Division Questions/Complaints About Homework? Here s the procedure for homework questions/complaints: 1. Read the solutions first. 2. Talk to the person who graded it (check initials) 3. If (1) and (2) don t work,

More information

About complexity. We define the class informally P in the following way:

About complexity. We define the class informally P in the following way: About complexity We define the class informally P in the following way: P = The set of all problems that can be solved by a polynomial time algorithm, i.e., an algorithm that runs in time O(n k ) in the

More information

Ma/CS 6a Class 4: Primality Testing

Ma/CS 6a Class 4: Primality Testing Ma/CS 6a Class 4: Primality Testing By Adam Sheffer Send anonymous suggestions and complaints from here. Email: adamcandobetter@gmail.com Password: anonymous2 There aren t enough crocodiles in the presentations

More information

Some Facts from Number Theory

Some Facts from Number Theory Computer Science 52 Some Facts from Number Theory Fall Semester, 2014 These notes are adapted from a document that was prepared for a different course several years ago. They may be helpful as a summary

More information

10 Concrete candidates for public key crypto

10 Concrete candidates for public key crypto 10 Concrete candidates for public key crypto In the previous lecture we talked about public key cryptography and saw the Diffie Hellman system and the DSA signature scheme. In this lecture, we will see

More information

CSE 311 Lecture 13: Primes and GCD. Emina Torlak and Kevin Zatloukal

CSE 311 Lecture 13: Primes and GCD. Emina Torlak and Kevin Zatloukal CSE 311 Lecture 13: Primes and GCD Emina Torlak and Kevin Zatloukal 1 Topics Modular arithmetic applications A quick wrap-up of Lecture 12. Primes Fundamental theorem of arithmetic, Euclid s theorem, factoring.

More information

Public Key Encryption

Public Key Encryption Public Key Encryption 3/13/2012 Cryptography 1 Facts About Numbers Prime number p: p is an integer p 2 The only divisors of p are 1 and p s 2, 7, 19 are primes -3, 0, 1, 6 are not primes Prime decomposition

More information

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya BBM 205 Discrete Mathematics Hacettepe University http://web.cs.hacettepe.edu.tr/ bbm205 Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya Resources: Kenneth Rosen,

More information

The running time of Euclid s algorithm

The running time of Euclid s algorithm The running time of Euclid s algorithm We analyze the worst-case running time of EUCLID as a function of the size of and Assume w.l.g. that 0 The overall running time of EUCLID is proportional to the number

More information

Groups, Rings, and Finite Fields. Andreas Klappenecker. September 12, 2002

Groups, Rings, and Finite Fields. Andreas Klappenecker. September 12, 2002 Background on Groups, Rings, and Finite Fields Andreas Klappenecker September 12, 2002 A thorough understanding of the Agrawal, Kayal, and Saxena primality test requires some tools from algebra and elementary

More information

Applied Cryptography and Computer Security CSE 664 Spring 2017

Applied Cryptography and Computer Security CSE 664 Spring 2017 Applied Cryptography and Computer Security Lecture 11: Introduction to Number Theory Department of Computer Science and Engineering University at Buffalo 1 Lecture Outline What we ve covered so far: symmetric

More information

4 Number Theory and Cryptography

4 Number Theory and Cryptography 4 Number Theory and Cryptography 4.1 Divisibility and Modular Arithmetic This section introduces the basics of number theory number theory is the part of mathematics involving integers and their properties.

More information

Senior Math Circles Cryptography and Number Theory Week 2

Senior Math Circles Cryptography and Number Theory Week 2 Senior Math Circles Cryptography and Number Theory Week 2 Dale Brydon Feb. 9, 2014 1 Divisibility and Inverses At the end of last time, we saw that not all numbers have inverses mod n, but some do. We

More information

WXML Final Report: AKS Primality Test

WXML Final Report: AKS Primality Test WXML Final Report: AKS Primality Test Amos Turchet, Travis Scholl, Rohan Hiatt, Daria Mićović, Blanca Viña Patiño, Bryan Tun Pey Quah Winter 2017 1 Introduction Prime numbers are fascinating objects in

More information

Part II. Number Theory. Year

Part II. Number Theory. Year Part II Year 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005 2017 Paper 3, Section I 1G 70 Explain what is meant by an Euler pseudoprime and a strong pseudoprime. Show that 65 is an Euler

More information

4 Powers of an Element; Cyclic Groups

4 Powers of an Element; Cyclic Groups 4 Powers of an Element; Cyclic Groups Notation When considering an abstract group (G, ), we will often simplify notation as follows x y will be expressed as xy (x y) z will be expressed as xyz x (y z)

More information

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime. PUTNAM TRAINING NUMBER THEORY (Last updated: December 11, 2017) Remark. This is a list of exercises on Number Theory. Miguel A. Lerma Exercises 1. Show that the sum of two consecutive primes is never twice

More information

1 The Fundamental Theorem of Arithmetic. A positive integer N has a unique prime power decomposition. Primality Testing. and. Integer Factorisation

1 The Fundamental Theorem of Arithmetic. A positive integer N has a unique prime power decomposition. Primality Testing. and. Integer Factorisation 1 The Fundamental Theorem of Arithmetic A positive integer N has a unique prime power decomposition 2 Primality Testing Integer Factorisation (Gauss 1801, but probably known to Euclid) The Computational

More information

Lecture # 12. Agenda: I. Vector Program Relaxation for Max Cut problem. Consider the vectors are in a sphere. Lecturer: Prof.

Lecture # 12. Agenda: I. Vector Program Relaxation for Max Cut problem. Consider the vectors are in a sphere. Lecturer: Prof. Lecture # 12 Lecturer: Prof. Allan Borodin Scribe: Yeleiny Bonilla Agenda: I. Finish discussion of Vector Program Relaxation for Max-Cut problem. II. Briefly discuss same approach for Max-2-Sat. III. The

More information

Lecture 7: Fingerprinting. David Woodruff Carnegie Mellon University

Lecture 7: Fingerprinting. David Woodruff Carnegie Mellon University Lecture 7: Fingerprinting David Woodruff Carnegie Mellon University How to Pick a Random Prime How to pick a random prime in the range {1, 2,, M}? How to pick a random integer X? Pick a uniformly random

More information

Introduction to Quantum Information Processing QIC 710 / CS 768 / PH 767 / CO 681 / AM 871

Introduction to Quantum Information Processing QIC 710 / CS 768 / PH 767 / CO 681 / AM 871 Introduction to Quantum Information Processing QIC 71 / CS 768 / PH 767 / CO 681 / AM 871 Lecture 8 (217) Jon Yard QNC 3126 jyard@uwaterloo.ca http://math.uwaterloo.ca/~jyard/qic71 1 Recap of: Eigenvalue

More information

1 Overview and revision

1 Overview and revision MTH6128 Number Theory Notes 1 Spring 2018 1 Overview and revision In this section we will meet some of the concerns of Number Theory, and have a brief revision of some of the relevant material from Introduction

More information

CS483 Design and Analysis of Algorithms

CS483 Design and Analysis of Algorithms CS483 Design and Analysis of Algorithms Lectures 2-3 Algorithms with Numbers Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments

More information

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time. 8 Modular Arithmetic We introduce an operator mod. Let d be a positive integer. For c a nonnegative integer, the value c mod d is the remainder when c is divided by d. For example, c mod d = 0 if and only

More information

Improving the Accuracy of Primality Tests by Enhancing the Miller-Rabin Theorem

Improving the Accuracy of Primality Tests by Enhancing the Miller-Rabin Theorem Improving the Accuracy of Primality Tests by Enhancing the Miller-Rabin Theorem Shyam Narayanan Fourth Annual MIT-PRIMES Conference Mentor: David Corwin Project Proposed by Stefan Wehmeier and Ben Hinkle

More information

Mathematical Foundations of Cryptography

Mathematical Foundations of Cryptography Mathematical Foundations of Cryptography Cryptography is based on mathematics In this chapter we study finite fields, the basis of the Advanced Encryption Standard (AES) and elliptical curve cryptography

More information

Pseudoprimes and Carmichael Numbers

Pseudoprimes and Carmichael Numbers Pseudoprimes and Carmichael Numbers Emily Riemer MATH0420 May 3, 2016 1 Fermat s Little Theorem and Primality Fermat s Little Theorem is foundational to the study of Carmichael numbers and many classes

More information

CSCI3390-Lecture 16: Probabilistic Algorithms: Number Theory and Cryptography

CSCI3390-Lecture 16: Probabilistic Algorithms: Number Theory and Cryptography CSCI3390-Lecture 16: Probabilistic Algorithms: Number Theory and Cryptography 1 Two Problems Problem 1. Generate Primes Find a prime number p of between 200 and 1000 decimal digits that has never been

More information

Linear Congruences. The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence:

Linear Congruences. The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence: Linear Congruences The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence: ax b (mod m), a, b Z, m N +. (1) If x 0 is a solution then so is x k :=

More information

MATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology.

MATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology. MATH 501 Discrete Mathematics Lecture 6: Number theory Prof. Dr. Slim Abdennadher, slim.abdennadher@guc.edu.eg German University Cairo, Department of Media Engineering and Technology 1 Number theory Number

More information

A. Algebra and Number Theory

A. Algebra and Number Theory A. Algebra and Number Theory Public-key cryptosystems are based on modular arithmetic. In this section, we summarize the concepts and results from algebra and number theory which are necessary for an understanding

More information

Chuck Garner, Ph.D. May 25, 2009 / Georgia ARML Practice

Chuck Garner, Ph.D. May 25, 2009 / Georgia ARML Practice Some Chuck, Ph.D. Department of Mathematics Rockdale Magnet School for Science Technology May 25, 2009 / Georgia ARML Practice Outline 1 2 3 4 Outline 1 2 3 4 Warm-Up Problem Problem Find all positive

More information

A Few Primality Testing Algorithms

A Few Primality Testing Algorithms A Few Primality Testing Algorithms Donald Brower April 2, 2006 0.1 Introduction These notes will cover a few primality testing algorithms. There are many such, some prove that a number is prime, others

More information

Primes and Factorization

Primes and Factorization Primes and Factorization 1 A prime number is an integer greater than 1 with no proper divisors. The list begins 2, 3, 5, 7, 11, 13, 19,... See http://primes.utm.edu/ for a wealth of information about primes.

More information

Math 547, Exam 1 Information.

Math 547, Exam 1 Information. Math 547, Exam 1 Information. 2/10/10, LC 303B, 10:10-11:00. Exam 1 will be based on: Sections 5.1, 5.2, 5.3, 9.1; The corresponding assigned homework problems (see http://www.math.sc.edu/ boylan/sccourses/547sp10/547.html)

More information

Number Theory and Group Theoryfor Public-Key Cryptography

Number Theory and Group Theoryfor Public-Key Cryptography Number Theory and Group Theory for Public-Key Cryptography TDA352, DIT250 Wissam Aoudi Chalmers University of Technology November 21, 2017 Wissam Aoudi Number Theory and Group Theoryfor Public-Key Cryptography

More information

basics of security/cryptography

basics of security/cryptography RSA Cryptography basics of security/cryptography Bob encrypts message M into ciphertext C=P(M) using a public key; Bob sends C to Alice Alice decrypts ciphertext back into M using a private key (secret)

More information

NOTES ON SIMPLE NUMBER THEORY

NOTES ON SIMPLE NUMBER THEORY NOTES ON SIMPLE NUMBER THEORY DAMIEN PITMAN 1. Definitions & Theorems Definition: We say d divides m iff d is positive integer and m is an integer and there is an integer q such that m = dq. In this case,

More information

Basic elements of number theory

Basic elements of number theory Cryptography Basic elements of number theory Marius Zimand By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a k for some integer k. Notation

More information

Basic elements of number theory

Basic elements of number theory Cryptography Basic elements of number theory Marius Zimand 1 Divisibility, prime numbers By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a

More information

Ch 4.2 Divisibility Properties

Ch 4.2 Divisibility Properties Ch 4.2 Divisibility Properties - Prime numbers and composite numbers - Procedure for determining whether or not a positive integer is a prime - GCF: procedure for finding gcf (Euclidean Algorithm) - Definition:

More information

8 Primes and Modular Arithmetic

8 Primes and Modular Arithmetic 8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.

More information

Chapter 5.1: Induction

Chapter 5.1: Induction Chapter.1: Induction Monday, July 1 Fermat s Little Theorem Evaluate the following: 1. 1 (mod ) 1 ( ) 1 1 (mod ). (mod 7) ( ) 8 ) 1 8 1 (mod ). 77 (mod 19). 18 (mod 1) 77 ( 18 ) 1 1 (mod 19) 18 1 (mod

More information

SOLUTIONS Math 345 Homework 6 10/11/2017. Exercise 23. (a) Solve the following congruences: (i) x (mod 12) Answer. We have

SOLUTIONS Math 345 Homework 6 10/11/2017. Exercise 23. (a) Solve the following congruences: (i) x (mod 12) Answer. We have Exercise 23. (a) Solve the following congruences: (i) x 101 7 (mod 12) Answer. We have φ(12) = #{1, 5, 7, 11}. Since gcd(7, 12) = 1, we must have gcd(x, 12) = 1. So 1 12 x φ(12) = x 4. Therefore 7 12 x

More information

Exercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.

Exercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93. Exercises Exercises 1. Determine whether each of these integers is prime. a) 21 b) 29 c) 71 d) 97 e) 111 f) 143 2. Determine whether each of these integers is prime. a) 19 b) 27 c) 93 d) 101 e) 107 f)

More information

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer? Chapter 3: Theory of Modular Arithmetic 25 SECTION C Solving Linear Congruences By the end of this section you will be able to solve congruence equations determine the number of solutions find the multiplicative

More information

Math 546, Exam 2 Information.

Math 546, Exam 2 Information. Math 546, Exam 2 Information. 10/21/09, LC 303B, 10:10-11:00. Exam 2 will be based on: Sections 3.2, 3.3, 3.4, 3.5; The corresponding assigned homework problems (see http://www.math.sc.edu/ boylan/sccourses/546fa09/546.html)

More information

MATH 420 FINAL EXAM J. Beachy, 5/7/97

MATH 420 FINAL EXAM J. Beachy, 5/7/97 MATH 420 FINAL EXAM J. Beachy, 5/7/97 1. (a) For positive integers a and b, define gcd(a, b). (b) Compute gcd(1776, 1492). (c) Show that if a, b, c are positive integers, then gcd(a, bc) = 1 if and only

More information

Kevin James. MTHSC 412 Section 3.4 Cyclic Groups

Kevin James. MTHSC 412 Section 3.4 Cyclic Groups MTHSC 412 Section 3.4 Cyclic Groups Definition If G is a cyclic group and G =< a > then a is a generator of G. Definition If G is a cyclic group and G =< a > then a is a generator of G. Example 1 Z is

More information

Math 120 HW 9 Solutions

Math 120 HW 9 Solutions Math 120 HW 9 Solutions June 8, 2018 Question 1 Write down a ring homomorphism (no proof required) f from R = Z[ 11] = {a + b 11 a, b Z} to S = Z/35Z. The main difficulty is to find an element x Z/35Z

More information

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II CS 5319 Advanced Discrete Structure Lecture 9: Introduction to Number Theory II Divisibility Outline Greatest Common Divisor Fundamental Theorem of Arithmetic Modular Arithmetic Euler Phi Function RSA

More information

The primitive root theorem

The primitive root theorem The primitive root theorem Mar Steinberger First recall that if R is a ring, then a R is a unit if there exists b R with ab = ba = 1. The collection of all units in R is denoted R and forms a group under

More information