Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann

Slides:



Advertisements
Similar presentations
Cryptography and Network Security
Advertisements

Chapter 8 – Introduction to Number Theory. Prime Numbers prime numbers only have divisors of 1 and self –they cannot be written as a product of other.
Computability and Complexity
Having Proofs for Incorrectness
Agrawal-Kayal-Saxena Presented by: Xiaosi Zhou
Primality Testing Patrick Lee 12 July 2003 (updated on 13 July 2003)
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
Introduction to Modern Cryptography Lecture 6 1. Testing Primitive elements in Z p 2. Primality Testing. 3. Integer Multiplication & Factoring as a One.
Primality Testing By Ho, Ching Hei Cheung, Wai Kwok.
COM 5336 Cryptography Lecture 7a Primality Testing
Fuw-Yi Yang1 演算法概論 Introduction to Algorithms Department of Computer Science and Information Engineering, Chaoyang University of Technology 朝陽科技大學資工系 Speaker:
Basic properties of the integers
The RSA Cryptosystem and Factoring Integers (II) Rong-Jaye Chen.
Complexity1 Pratt’s Theorem Proved. Complexity2 Introduction So far, we’ve reduced proving PRIMES  NP to proving a number theory claim. This is our next.
CMSC 250 Discrete Structures Number Theory. 20 June 2007Number Theory2 Exactly one car in the plant has color H( a ) := “ a has color”  x  Cars –H(
Speaker: Fuw-Yi Yang 楊伏夷 伏夷非征番, 道德經 察政章(Chapter 58) 伏者潛藏也
Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Chapter 8 – Introduction to Number Theory Prime Numbers
Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Speaker: Fuw-Yi Yang 楊伏夷 伏夷非征番, 道德經 察政章(Chapter 58) 伏者潛藏也
Chapter Number Theory 4 4 Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Copyright © The McGraw-Hill Companies, Inc. Permission required.

CSCI 1900 Discrete Structures
Information Security and Management 4. Finite Fields 8
Fuw-Yi Yang1 數位系統 Digital Systems Department of Computer Science and Information Engineering, Chaoyang University of Technology 朝陽科技大學資工系 Speaker: Fuw-Yi.
PRIMES is in P Manindra Agrawal NUS Singapore / IIT Kanpur.
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 13 Other Systems Department of Computer Science and Information Engineering,
CS/ECE Advanced Network Security Dr. Attila Altay Yavuz
Fuw-Yi Yang1 數位系統 Digital Systems Department of Computer Science and Information Engineering, Chaoyang University of Technology 朝陽科技大學資工系 Speaker: Fuw-Yi.
9/22/15UB Fall 2015 CSE565: S. Upadhyaya Lec 7.1 CSE565: Computer Security Lecture 7 Number Theory Concepts Shambhu Upadhyaya Computer Science & Eng. University.
Primality Testing. Introduction The primality test provides the probability of whether or not a large number is prime. Several theorems including Fermat’s.
9.1 Primes and Related Congruence Equations 23 Sep 2013.
MA/CSSE 473 Day 10 Primality Testing. MA/CSSE 473 Day 10 In-class exam: Friday, Sept 28 –You may bring a two-sided 8.5x11 inch piece of paper containing.
MA/CSSE 473 Day 09 Modular Division Revisited Fermat's Little Theorem Primality Testing.
CS480 Cryptography and Information Security
Fuw-Yi Yang1 數位系統 Digital Systems Department of Computer Science and Information Engineering, Chaoyang University of Technology 朝陽科技大學資工系 Speaker: Fuw-Yi.
Fuw-Yi Yang1 數位系統 Digital Systems Department of Computer Science and Information Engineering, Chaoyang University of Technology 朝陽科技大學資工系 Speaker: Fuw-Yi.
Fuw-Yi Yang1 數位系統 Digital Systems Department of Computer Science and Information Engineering, Chaoyang University of Technology 朝陽科技大學資工系 Speaker: Fuw-Yi.
Fuw-Yi Yang1 數位系統 Digital Systems Department of Computer Science and Information Engineering, Chaoyang University of Technology 朝陽科技大學資工系 Speaker: Fuw-Yi.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
MA/CSSE 473 Day 9 Primality Testing Encryption Intro.
PRIMES is in P Manindra Agrawal Neeraj Kayal Nitin Saxena Dept of CSE, IIT Kanpur.
A Prime Example CS Lecture 20 A positive integer p  2 is prime if the only positive integers that divide p are 1 and p itself. Positive integers.
Speaker: Fuw-Yi Yang 楊伏夷 伏夷非征番, 道德經 察政章(Chapter 58) 伏者潛藏也
MA/CSSE 473 Day 08 Randomized Primality Testing Carmichael Numbers
Speaker: Fuw-Yi Yang 楊伏夷 伏夷非征番, 道德經 察政章(Chapter 58) 伏者潛藏也
Public Key Encryption Major topics The RSA scheme was devised in 1978
CSE565: Computer Security Lecture 7 Number Theory Concepts
PRIME NUMBERS PRESENTED BY : NANDAN GOEL.
Probabilistic Algorithms
Handbook of Applied Cryptography - CH4, from 4.1~4.3
Numerical Algorithms x x-1 Numerical Algorithms
Randomness and Computation: Some Prime Examples
MA/CSSE 473 Day 08 Randomized Primality Testing Carmichael Numbers
Copyright © 2016, 2013, and 2010, Pearson Education, Inc.
Introduction to Number Theory
Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann
Public Key Cryptosystems - RSA
Number Theory (Chapter 7)
Cryptography and Network Security
Foundations of Discrete Mathematics
Introduction to Cryptography
Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
演算法概論 Introduction to Algorithms
Mathematical Background for Cryptography
Speaker: Fuw-Yi Yang 楊伏夷 伏夷非征番, 道德經 察政章(Chapter 58) 伏者潛藏也
Patrick Lee 12 July 2003 (updated on 13 July 2003)
From the last time: gcd(a, b) can be characterized in two different ways: It is the least positive value of ax + by where x and y range over integers.
Presentation transcript:

Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 7 Prime Number Generation Department of Computer Science and Information Engineering, Chaoyang University of Technology 朝陽科技大學資工系 Speaker: Fuw-Yi Yang 楊伏夷 伏夷非征番, 道德經 察政章(Chapter 58) 伏者潛藏也 道紀章(Chapter 14) 道無形象, 視之不可見者曰夷 Fuw-Yi Yang

Contents Trial division Fermat test Carmichael Numbers Miller-Rabin test Random primes Fuw-Yi Yang

7.1 Trial Division Theorem 7.1.1 If n is a composite positive integer, then n has a prime divisor p which is less than or equal to (n)1/2. Proof. Let n = ab with a > 1 and b > 1. Therefore we have a  (n)1/2 or b  (n)1/2, since otherwise n = ab > (n)1/2(n)1/2 > n. Suppose that a  (n)1/2. By Theorem 1.11.2, a has a prime divisor p which also divides n. Then p  a  n, and this proves the assertion. Fuw-Yi Yang

7.1 Trial Division Theorem 7.1.1 suggests the following algorithm to test whether n is prime. The algorithm checks, for all prime number p that are less than or equal to n, whether they divide n. If a prime divisor of n is found, then n is composite. Otherwise, n is prime. The prime numbers p  (n)1/2 can either be generated by the sieve of Eratosthenes or be obtained from a pre-computed table. It is also possible to test whether n is divisible by any odd, positive integer m  (n)1/2. This procedure is call trial division. Fuw-Yi Yang

7.1 Trial Division Example 7.1.2 We use trial division to decide whether n = 15413 is prime. Sol. The odd primes p  (n)1/2 = 124 are 3, 5, 7, 11, 13, 17, 19, 23, 29,31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113. None of them divides n. Trial division can also be used to find the prime factorization of n. If a prime factor p is found, then n is replaced by n/p and trial division is applied again. This is repeated until n is proven prime. See example next Fuw-Yi Yang

7.1 Trial Division Example 7.1.3 We factor 476 by trial division. Sol. The first prime divisor that we find is 2 and 476/2 = 238. The prime factorization of 476 is 22 * 7 * 17. If n is large, then trial division becomes very inefficient. In factoring algorithms, trial division is typically used to find all primes factors that are less than 106. Fuw-Yi Yang

7.1 Trial Division To estimate the running time of trial division, we need an estimate for the number of primes below a given bound. Definition 7.1.4 If x is a positive real number, then (x) denotes the number of primes that are less than or equal to x. Example 7.1.5 We have (1) = 0, (4) = 2, (124) = 30, see example 7.1.2. Fuw-Yi Yang

7.1 Trial Division [1] J. Rosser and L. Schoenfeld, “Approximate formulas for some functions of prime numbers,” Illinois Journal of Mathematics, 6:64-94, 1962. Theorem 7.1.6 [1] 1. For x  17, we have (x) > x / log x. 2. For x > 1, we have (x) < 1.25506(x / log x). It follows from Theorem 7.1.6 that at least (n)1/2 / log (n)1/2  divisions are necessary to prove n prime. For the RSA cryptosystem, we need primes that are greater than 1075. To prove the primality of such a number, more than 0.36 * 1036 divisions are necessary. This is impossible. Fuw-Yi Yang

7.2 Fermat Test It is very expensive to prove that a given positive integer is prime. But there are very efficient algorithms that prove the primality of a positive integer with high probability. Such algorithms are called primamity tests. A first example of a primality test is the Fermat test. It is based on Fermat’s theorem (2.11.1) in the following version. Theorem 7.2.1 If n is a prime number, then an-1 = 1 mod n for all a  Z with gcd(a, n) =1. Fuw-Yi Yang

7.2 Fermat Test Theorem 7.2.1 If n is a prime number, then an-1 = 1 mod n for all a  Z with gcd(a, n) =1. This theorem can be used to determine that a positive integer is composite. We choose a positive integer a  {1, 2, …, n-1}. We use fast exponentiation to compute y = an-1 mod n. If y  1 then y is composite by Theorem 7.2.1. If y = 1 then we do not know whether n is prime or composite. Fuw-Yi Yang

7.2 Fermat Test Example 7.2.2 Consider n = 341 = 11 * 31. We have 2340 = 1 mod 341 although n is composite. On the other hand, we have 3340 = 56 mod 341, then n is proven composite. If the Fermat test proves that n is composite, it does not find a divisor of n. It only shows that n lacks a property that all prime numbers have. Therefore, the Fermat test cannot be used as a factoring algorithm. Fuw-Yi Yang

7.3 Carmichael Numbers The Fermat test can prove that a positive integer n is composite, but it cannot prove n is prime. However, if the Fermat test was not able to find a proof for the compositness of n for many bases a, then it seems likely that n is prime. Unfortunately, there are composite integers that cannot be proven composite by the Fermat test with any basis. They are call Carmichael numbers and we discuss them now. Fuw-Yi Yang

7.3 Carmichael Numbers We need two definitions. If n is odd composite number and if a is an integer that satisfies an-1 = 1 mod n, then n is called a pseudoprime to the base a. If n is a pseudoprime to the base a for all integers with gcd(a, n) = 1, then n is called a Carmochael number. The smallest Carmochael number is 561 = 3* 11* 17. It has been shown that there are infinitely many Carmochael number. Fuw-Yi Yang

7.3 Carmichael Numbers Because of the existence of Carmochael number, the Fermat test is not optimal for practical use. A better choice is the Miller-Rabin test, which will be described shortly. For the analysis of the Miller-Rabin test, we need the following characterization of Charmichael numbers. Fuw-Yi Yang

7.3 Carmichael Numbers Theorem 7.3.1 An odd composite number n  3 is a Charmichael number if and only if it is square free (it has no multiple prime divisors, and for each prime divisor p of n the integer p-1 divides n-1). Proof. Let n  3 be a Charmichael number. Then an-1 = 1 mod n ---- 7.1 for any integer a that is prime to n. Let p be a prime divisor of n, and let a be a primitive root mod p that is prime to n (constructed by CRT). Then Eq. 7.1 implies an-1 = 1 mod p. By Theorem 2.9.2, p-1, the order of a divides n-1. see next page Fuw-Yi Yang

7.3 Carmichael Numbers Proof. It remains to show that p2 does not divides n. Suppose that p2 divides n. Then (p-1)p divides (n), and the multiplicative group of residues mod n contains an element of order (p-1)p. This implies that (p-1)p divides n-1. This is impossible because p is a divisor of n. Conversely, let n be a square-free and assume that p-1 divides n-1 for all prime divisors p of n. Let a be an integer that is prime to n. Then ap-1 = 1 mod p (Fermat’s little theorem), an-1 = 1 mod p (p-1 | n-1 ), an-1 = 1 mod n (prime divisors of n are pairwise distinct). endofproof Fuw-Yi Yang

7.3 Carmichael Numbers Note: gcd(p, q) =1  px + qy = 1 Let w = a mod p; w = a mod q; Proof (by yangfy).  w = [a q(q-1mod p) + a p(p-1mod q)] mod pq  w = a [q(1 - px)/q + p(1- qy)/p] mod pq  w = a [1 - px + 1- qy mod pq  w = a [2 -1] mod pq = a mod pq endof proof Fuw-Yi Yang

7.3 Carmichael Numbers Note: gcd(p, q, r) =1  px + qy = 1  pqu + rv = 1 Let w = a mod p; w = a mod q; w = a mod r; Proof (by yangfy). By px + qy = 1 and w = a mod p; w = a mod q  w = a mod pq By pqu + rv = 1 and w = a mod pq; w = a mod r  w = a mod pqr endof proof Fuw-Yi Yang

7.4 Miller-Rabin Test This section we describe the Miller-Rabin test. Contrary to the Fermat test, the Miller-Rabin test can prove the compositeness of any composite positive integer. In other words, there is no analog of Carmichael numbers for the Miller-Rabin test . The Miller-Rabin test is based on a modification of Fermat’s little theorem. The situation is the following. Let n be an odd, positive integer, and let s = max{r  N ={1, 2,…}: 2r divides n - 1}, so 2s is the largest power of 2 that divides n - 1. Set d = (n - 1)/ 2s, then d is odd. Fuw-Yi Yang

7.4 Miller-Rabin Test Theorem 7.4.1 If n is a prime and if a is an integer that is prime to n, then with the previous notation we have either ad = 1 mod n or there exists r in the set {0, 1, …, s-1}with a2r  d = -1 mod n. Proof see next page. If n is a prime, then at least one of the conditions from Theorem 7.4.1 holds. Therefore, if we find an integer a that is prime to n, and that satisfies neither ad = 1 mod n nor a2r  d = -1 mod n for some r  {0, 1, …, s-1}, then n is proven composite. Such an integer is called a witness for the compositeness of n. Fuw-Yi Yang

7.4 Miller-Rabin Test Proof. Let a be an integer that is prime to n. The order of the multiplicative group of residues mod n is n - 1 = 2s  d because n is a prime number. Therefore, the order k of the residue class ad + nZ is a power of 2. If this order is k = 1 = 20, then ad = 1 mod n. If k > 1, then k = 2l with 1  l  s. The residue class a2l-1  d + nZ has order 2. The only element of order 2 in (Z / nZ)* is -1 + nZ. This implies a2r  d = -1 mod n for r = l - 1. Fuw-Yi Yang

7.4 Miller-Rabin Test For the efficiency of the Miller-Rabin test, it is important that there are sufficiently many witness for the compositeness of a composite number. Theorem 7.4.3 If n  3 is an odd composite number, then the set {0, 1, …, n-1} contains at most (n - 1)/4 numbers that are prime to n and not witnesses for the compositeness of n. Fuw-Yi Yang

7.5 Random Primes We want to generate a random number of bit length k. We generate a random odd k-bit number (Section 4.6). For this purpose, we set the first and last bit of n = 1, and the remaining k-2 bits are chosen randomly with uniform distribution. Then we test whether n is prime. See next page Fuw-Yi Yang

7.5 Random Primes First, we check whether n is divisible by a prime number below a predefined bound B, typically B = 106. If no prime divisor of n is found, then we apply the Miller-Rabin test t times. The choice t = 3 suffices to make the error probability less than (1/2)80 if k  1000. If this test finds no witness for the compositeness of n, then n is considered prime. If trial division is much more efficiency than the Miller-Rabin test, then a large B can be chosen. Fuw-Yi Yang