Prime recognition and factorization

Slides:



Advertisements
Similar presentations
Number Theory Algorithms and Cryptography Algorithms Prepared by John Reif, Ph.D. Analysis of Algorithms.
Advertisements

Computer Science CSC 474Dr. Peng Ning1 CSC 474 Information Systems Security Topic 2.3 Basic Number Theory.
Cryptography and Network Security
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.
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.
Factoring Polynomials
Computability and Complexity
Agrawal-Kayal-Saxena Presented by: Xiaosi Zhou
Primality Testing Patrick Lee 12 July 2003 (updated on 13 July 2003)
22C:19 Discrete Structures Integers and Modular Arithmetic
Lecture 8: Primality Testing and Factoring Piotr Faliszewski
Introduction to Modern Cryptography Lecture 6 1. Testing Primitive elements in Z p 2. Primality Testing. 3. Integer Multiplication & Factoring as a One.
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
1 The RSA Algorithm Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
Announcements: 1. Pass in Homework 5 now. 2. Term project groups and topics due by Friday 1.Can use discussion forum to find teammates 3. HW6 posted, due.
The RSA Cryptosystem and Factoring Integers (II) Rong-Jaye Chen.
Factoring 1 Factoring Factoring 2 Factoring  Security of RSA algorithm depends on (presumed) difficulty of factoring o Given N = pq, find p or q and.
Tirgul 8 Universal Hashing Remarks on Programming Exercise 1 Solution to question 2 in theoretical homework 2.
and Factoring Integers
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.
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann.
Factoring Algorithms Ref: D. Stinson, Cryptography - Theory and Practice, 2001.
Chapter 8 – Introduction to Number Theory Prime Numbers
Cryptography and Network Security Chapter 8. Chapter 8 – Introduction to Number Theory The Devil said to Daniel Webster: "Set me a task I can't carry.
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.
RSA Question 2 Bob thinks that p and q are primes but p isn’t. Then, Bob thinks ©Bob:=(p-1)(q-1) = Á(n). Is this true ? Bob chooses a random e (1 < e
Public key ciphers 1 Session 5.
Topic 18: RSA Implementation and Security
Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Copyright © The McGraw-Hill Companies, Inc. Permission required.
Section 5.1 Number Theory.

Information Security and Management 4. Finite Fields 8
Section 4.3: Fermat’s Little Theorem Practice HW (not to hand in) From Barr Text p. 284 # 1, 2.
The Polynomial Time Algorithm for Testing Primality George T. Gilbert.
Great Theoretical Ideas in Computer Science.
The Complexity of Primality Testing. What is Primality Testing? Testing whether an integer is prime or not. – An integer p is prime if the only integers.
Basic Concepts in Number Theory Background for Random Number Generation 1.For any pair of integers n and m, m  0, there exists a unique pair of integers.
PRIMES is in P Manindra Agrawal NUS Singapore / IIT Kanpur.
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
1 Elliptic curves cryptography CHAPTER 8: Elliptic Curves Cryptography and factorization Cryptography based on manipulation of points of so called elliptic.
Great Theoretical Ideas in Computer Science.
6.4 Factoring.
22C:19 Discrete Structures Integers and Modular Arithmetic Fall 2014 Sukumar Ghosh.
CS/ECE Advanced Network Security Dr. Attila Altay Yavuz
1 Elliptic curves cryptography CHAPTER 8: Elliptic Curves Cryptographyand factorization Cryptography based on manipulation of points of so called elliptic.
Scott CH Huang COM 5336 Cryptography Lecture 6 Public Key Cryptography & RSA Scott CH Huang COM 5336 Cryptography Lecture 6.
Introduction Synthetic division, along with your knowledge of end behavior and turning points, can be used to identify the x-intercepts of a polynomial.
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.
Week 4 - Wednesday.  What did we talk about last time?  Finished DES  AES.
9.1 Primes and Related Congruence Equations 23 Sep 2013.
CHAPTER 8: Elliptic Curves Cryptography and factorization
Chapter 1 Algorithms with Numbers. Bases and Logs How many digits does it take to represent the number N >= 0 in base 2? With k digits the largest number.
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.
1 Diffie-Hellman (Key Exchange) Protocol Rocky K. C. Chang 9 February 2007.
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and Algorithms.
Key Exchange in Systems VPN usually has two phases –Handshake protocol: key exchange between parties sets symmetric keys –Traffic protocol: communication.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
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.
Public Key Encryption Major topics The RSA scheme was devised in 1978
CSE565: Computer Security Lecture 7 Number Theory Concepts
CHAPTER 8: Elliptic Curves Cryptography and factorization
Handbook of Applied Cryptography - CH4, from 4.1~4.3
Randomness and Computation: Some Prime Examples
Introduction to Number Theory
Number Theory (Chapter 7)
Cryptography and Network Security
Section 5.1 Number Theory.
Section 5.1 Number Theory.
Presentation transcript:

Prime recognition and factorization IV054 Prime recognition and factorization The key problems for the development of RSA cryptosystem are that of prime recognition and integer factorization. August 2002 first polynomial time algorithm has been discovered that allows to determine whether a given m bit integer is a prime. Algorithm works in time O(m12). Fast randomized algorithms for prime recognition has been known since 1977. One of the simplest one is due to Rabin and will be presented later. For integer factorization situation is somehow different. No polynomial time classical algorithm is known. Simple, but not efficient factorization algorithms are known. Several sophisticated distributed factorization algorithms are known that allowed to factorize, using enormous computation power, surprisingly large integers. Progress in integer factorization, due to progress in algorithms and technology, has been recently enormous. Polynomial time quantum algorithms for integer factorization are known since 1994 (P. Shor). Several simple and some sophisticated factorization algorithms will be presented and illustrated in the following. Prime recognition and factorization

Rabin-Miller's prime recognition IV054 Rabin-Miller's prime recognition Rabin-Miller's Monte Carlo prime recognition algorithm is based on the following result from number theory. Lemma Let nÎN. Denote, for 1 Ł x Ł n, by C(x) the condition: Either , or there is an for some i, such that If C(x) holds for some 1 Ł x Ł n, then n is not a prime. If n is not a prime, then C(x) holds for at least half of x between 1 and n. Algorithm: Choose randomly integers x1,x2,…,xm such that 1 Ł xi Ł n. For each xi determine whether C(xi) holds. Claim: If C(xi) holds for some i, then n is not a prime for sure. Otherwise n is prime, with probability of error 2 -m. Prime recognition and factorization

Fermat numbers factorization IV054 Fermat numbers factorization Factorization of so-called Fermat numbers 22^i + 1 is a good example to illustrate progress that has been made in the area of factorization. Pierre de Fermat (1601-65) expected that all numbers Fi = 22^i + 1 i ł 1 are primes. This is true for i = 1,…,4. F1 = 5, F2 = 17, F3 = 257, F4 = 65537. 1732 L. Euler found that F5 = 4294967297 = 641 · 6700417 1880 Landry+LeLasser found that F6 = 18446744073709551617 = 274177 · 67280421310721 1970 Morrison+Brillhart found factorization for F7 =(39 digits) F7 = 340282366920938463463374607431768211457 = = 5704689200685129054721 · 59649589127497217 1980 Brent+Pollard found factorization for F8 1990 A. K. Lenstra+… found factorization for F9 (155 digits) Fermat test: If , then n is not prime. Prime recognition and factorization

POLLARD’s p-1 algorithm Pollard’s algorithm (to factor n given a bound b). a := 2; for j=2 to b do a:= aj mod n; f:= gcd(a-1,n); if 1 < f < n then f is a factor of n otherwise failure Let p be a prime divisor of n and q < b for every prime q|(p-1). (Hence (p-1)|b!). At the end of the for-loop we therefore have a Ξ 2b! (mod n) and therefore a Ξ 2b! ( mod p) By Fermat theorem 2p-1 Ξ 1 (mod p) and since (p-1)|b! we have that p|(a-1) p|d = gcd(a-1,n) Prime recognition and factorization

Elliptic curve method for integer factorization IV054 Elliptic curve method for integer factorization Basic idea: To factorize an integer n one keeps choosing randomly elliptic curves and performs certain computations that include gcd(x, n) evaluations, for various x, and that these computations continue only if all gcd(x, n) = 1. If n is a prime, these evaluations are always successful. However if n is composite, some of the evaluated gcd(x, n) will be different from 1, providing a factor of n. H. W. Lenstra has shown that if n is not a prime, then there is an elliptic curve such that the above computations provide a factor of n. An elliptic curve is a set of points (x, y) of an equation y2 = x3 + ax + b where 4a3+27b2 ¹ 0. A crucial idea is that one can define addition of two points of an elliptic curve and an “inverse element'' of a point of the curve, in such a way that one gets an additive group of points, with a special “null'' point 0 in the infinity. The point that is a sum of two points P1, P2 on the curve that do not have the same x coordinate is defined as the x-axis reflection of the intersection of the line through these points with the curve. . Prime recognition and factorization

Formulas for operations on points IV054 Formulas for operations on points If P1 = (x1, y1), P2 = (x2, y2), the P1 = (x1, -y1) 0, if P1 = -P2 ; P1 + P2 = P2, if P1 = 0; P1, if P2 = 0. Otherwise P1 + P2 = (x3, y3) x3 = -x1 - x2 + l2; y3 = -y1 + l(x1 - x3); New key idea: All points and operations are taken modulo an integer p. {In this case it has to hold that 4a3 + 27b2 ¹ 0 mod p. Example p = 11, a = 1, b = 6 (y2 = x3 + x + 6), P1 = (2,7), P1 + P1 = (5,2), 3P1 = (P1 + P1) + P1 = (8,3). According to the Lagrange Theorem, to every point P there is a k Ł p such that P + P + … + P = 0. k Prime recognition and factorization

Prime recognition and factorization IV054 EXAMPLE An example to see how one can use elliptic curves to factor an integer. Let n = 35. Choose an elliptic curve: i.e. y2 º x3 + x - 1 Choose a point: P = (1, 1) Compute 9P: 2P = (2,2), 4P = (0,22), 8P = (16, 19), gcd(15,35) = 5 is a factor of n = 35. In order to compute P + 8P one has to compute 15-1 mod 35 and in order to do that we need first to compute gcd(15, 35) ¹ 1. Now we can formulate the basic idea of factorization using elliptic curve method. Generate many elliptic curves, choose many points P on them and for sufficiently large integer k compute kP. In realizing the above strategy, what can be done in a very distributed way, provided a root generates and distributed elliptic curves and points, one often needs to compute gcd(x, n) for various x. If at least once such a gcd(x, n) ¹ 1 we have a factor of n. Prime recognition and factorization

IV054 EXAMPLE Problem: How to choose k? Idea: If one searches for m-digit factors, one chooses k in such a way that k is a multiple of as many of m-digit numbers as possible which do not have too large prime factors. In such a case one has a good chance that k is a multiple of the number of elements of the group of points of elliptic curves modulo n. Method: One chooses an integer B and takes as k the product of all maximal powers of primes smaller than B. Example In order to find a 6-digit factor one chooses B = 147 and k = 27 ·34 · 53 · 72 · 112 · 13 ·…· 139. The following table shows B and the number of elliptic curves one has to test: Computation time by the eliptic curves method depends on the size of factors. number of digits of to-be-factors 6 9 12 18 24 30 B 147 682 2462 23462 162730 945922 number of curves 10 55 231 833 2594 Prime recognition and factorization

Method of quadratic sieve to factorize n IV054 Method of quadratic sieve to factorize n Basic idea: One finds x, y such that n | (x2 - y 2) Reasoning: If n divides (x + y)(x - y) and n does not divide neither x+y nor x-y, then one factor of n has to divide x+y and another one x-y. Example n = 7429 = 2272 -2102, X = 227, Y = 210 x – y = 17 x + y = 437 gcd(17, 7429) = 17 gcd(437, 7429) = 437. How to find X and Y? One forms a system of (modular) linear equations and determines X and Y from the solutions of the system. number of digits of n 50 60 70 80 90 100 110 120 number of equations 3000 4000 7400 15000 30000 51000 120000 245000 Prime recognition and factorization

Method of quadratic sieve to factorize n IV054 Method of quadratic sieve to factorize n Step 1 One finds numbers x such that x2 - n is small and has small factors. Example 832 – 7429 = -540 = (-1) · 22 · 33 · 5 872 – 7429 = 140 = 22 · 5 · 7 relations 882 – 7429 = 315 = 32 · 5 · 7 Step 2 One multiplies some of the relations if their product is a square. For example (872 – 7429)(882 – 7429) = 22 · 32 · 52 · 72 = 2102 Now (87 · 88)2 º (872 - 7429)(882 - 7429) mod 7429 2272 º 2102 mod 7429 Hence 7429 divides 2272-2102. Formation of equations: For the i-th relation one takes a variable li and forms the expression ((-1) · 22 · 33 · 5)l1 · (22 · 5 · 7)l2 · (32 · 5 · 7)l3 = (-1)l1 · 22l1 + 2l2 · 32l1 + 2l2 · 5l1 + l2 + l3 · 7l2 +l3 If this is to form a quadrat the following equations have to hold . Prime recognition and factorization

Method of quadratic sieve to factorize n IV054 Method of quadratic sieve to factorize n Problem How to find relations? Using the algorithm called Quadratic sieve method. Step 1 One chooses a set of primes that can be factors - a so-called factor basis. One chooses an m such that m2 - n is small and considers numbers (m + u)2 - n for –k Ł u Ł k for small k. One then tries to factor all (m + u)2 - n with primes from the factor basis, from the smallest to the largest. In order to factor a 129-digit number from the RSA challenge they used 8 424 486 relations 569 466 equations 544 939 elements in the factor base u -3 1 2 3 (m + u)2 - n -540 -373 -204 -33 140 315 492 Sieve with 2 -135 -51 35 123 Sieve with 3 -5 -17 -11 41 Sieve with 5 -1 7 Sieve with 7 Prime recognition and factorization

The rho method of integer factorization IV054 The rho method of integer factorization Basic idea 1. Choose an easy to compute f: Zn ® Zn and x0 Î Zn. Example f(x) = x2 + 1 2. Keep computing xj+1 = f(xj), j = 0,1,2,… and gcd(xj - xk, n), k Ł j. (Observe that if xj º xk mod r for a prime factor r of n, then gcd(xj - xk, n) ł r.) Example n = 91, f(x) = x2+1, x0 = 1, x1 = 2, x2 = 5, x3 = 26 gcd(x3 - x2, n) = gcd(26 - 5, 91) = 7 Remark: In the rho method it is important to choose f in such a way that f maps Zn into Zn in a ”random'' way. Basic question: How good is the rho method? (How long we expect to have to wait before we get two values xj, xk such that gcd(xj - xk, n) ¹ 1 if n is not a prime?) Prime recognition and factorization

IV054 Basic lemma Given: n, f:Zn ® Zn and x0ÎZn We ask how many iterations are needed to get xj º xk mod r where r is a prime factor of n. Lemma Let S be a set, r = |S|. Given a map f:S ® S, x0ÎS, let xj+1 = f(xj), j ł 0. Let l > 0, Then the proportion of pairs (f, x0) for which x0, x1,…, xl are distinct, where f runs over all mappings from S to S and x0 over all S, is less than e-l. Proof Number of pairs (x0, f) is r r+1. How many pairs (x0, f) are there for which x0,…, xl are distinct? r choices for x0, r-1 for x1, r-2 for x2,… The values of f for each of the remaining r - l values are arbitrary - there are r r - l possibilities for those values. Total number of ways of choosing x0 and f such that x0,…, xl are different is and the proportion of pairs with such a property is For we have Prime recognition and factorization

Prime recognition and factorization IV054 RHO-ALGORITHM A simplification of the basic idea: For each k compute gcd(xk - xj, n) for just one j < k. Choose f:Zn ® Zn, x0, compute xk = f(xk-1), k > 0. If k is an (h +1)-bit integer, i.e. 2h Ł k Ł 2h+1, then compute gcd(xk, x2^h-1). Example n = 4087, f(x) = x2 + x + 1, x0 = 2 x1 = f(2) = 7, gcd(x1 - x0, n) = 1 x2 = f(7) = 57, gcd(x2 - x1, n) = gcd(57 – 7, n) = 1 x3 = f(57) = 3307, gcd(x3 - x1, n) = gcd(3307 - 7, n) = 1 x4 = f(3307) = 2745, gcd(x4 - x3, n) = gcd(2745 - 3307, n) = 1 x5 = f(2746) = 1343, gcd(x5 - x3, n) = gcd(1343 - 3307, n) = 1 x6 = f(1343) = 2626, gcd(x6 - x3, n) = gcd(2626 - 3307, n) = 1 x7 = f(2626) = 3734, gcd(x7 - x3, n) = gcd(3734 - 3307, n) = 61 Disadvantage We likely will not detect the first case such that for some k0 there is a j0 < k0 such that gcd(xk0 - xj0, n) > 1. This is no real problem! Let k0 has h +1 bits. Set j = 2h+1 -1, k = j + k 0 - j0. k has (h+2) bits, gcd(xk - xj, n) > 1 k < 2h+2 = 4 · 2h Ł 4k0. Prime recognition and factorization

Prime recognition and factorization IV054 RHO-ALGORITHM Theorem Let n be odd + composite and 1 < r < sqrt(n) its factor. If f, x0 are chosen randomly, then rho algorithm reveals r in bit operations with high probability. More precisely, there is a constant C > 0 such that for any l > 0, the probability that the rho algorithm fails to find a nontrivial factor of n in bit operations is less than e - l. Proof Let C1 be a constant such that gcd(y - z, n) can be computed in C1log3n bit operations whenever y, z < n. Let C2 be a constant such that f(x) mod n can be computed in C2log2n bit operations if x < n. If k0 is the first index for which there exists j0 < k0 with xk0 º xj0 mod r, then the rho-algorithm finds r in k Ł 4k0 steps. The total number of bit operations is bounded by -> 4k0(C1log3n + C2log2n) By Lemma the probability that k0 is greater than is less than e - l. If , then the number of bits operations needed to find r is bounded by If we choose C > 4sqrt(2)(C1 + C2), then we have that r will be found in bit operations - unless we made uniformed choice of (f, x0) the probability of what is at most e - l. Prime recognition and factorization

Simple factorization strategy to factor an integer n IV054 Simple factorization strategy to factor an integer n 1.For i = 3, 5,… till [10logn] check whether i |n. If such an i is found we have a factor. Otherwise: 2. Fermat test: Verify whether 2n-1 º 1 mod n. If yes, n is probably prime. To confirm it use Lucas test. 3. Lucas test: Lucas sequence: U0 = 0, U1 = 1, Ui + 1 = Ui – qUi - 1, i ł 1. Lucas theorem: If n is prime, n>q, (1 - 4q|n) = -1, then n|Un+1. Test: Find the smallest D such that (D|n) = -1, put D = 1 - 4q, check whether Un+1 º 0 mod n. If not, n is composite. Otherwise n is prime with large probability. Remark No composite integer is known that would satisfy both Fermat and Lucas tests. (A proof of this fact exists for n < 25 · 109.) Homework: Factorize: 7500596246954111183. Prime recognition and factorization

Prime recognition and factorization IV054 Computation of Un+1 Homework Factor 277 – 3 Factor 279 – 3 Prime recognition and factorization

Factorization of a 512-bit number IV054 Factorization of a 512-bit number On August 22, 1999, a team of scientifists from 6 countries found, after 7 months of computing, using 300 very fast SGI and SUN workstations and Pentium II, factors of the so-called RSA-155 number with 512 bits (about 155 digits). RSA-155 was a number from a Challenge list issue by the US company RSA Data Security and “represented'' 95% of 512-bit numbers used as the key to protect electronic commerce and financinal transmissions on Internet. Factorization of RSA-155 would require in total 37 years of computing time on a single computer. When in 1977 Rivest and his colleagues challenged the world to factor RSA- 129, he estimated that, using knowledge of that time, factorization of RSA-129 would require 1016 years. Prime recognition and factorization

IV054 LARGE NUMBERSq FACTORIZATION of very large NUMBERS Hindus named many large numbers - one having 153 digits. Romans initially had no terms for numbers larger than 104. Greeks had a popular belief that no number is larger than the total count of sand grains needed to fill the universe. Large numbers with special names: googol - 10100 golplex - 1010^100 FACTORIZATION of very large NUMBERS W. Keller factorized F23471 which has 107000 digits. J. Harley factorized: 1010^1000 +1. One factor: 316,912,650,057,350,374,175,801,344,000,001 1992 E. Crandal, Doenias proved, using a computer that F22, which has more than million of digits, is composite (but no factor of F22 is known). Number was used to develop a theory of the distribution of prime numbers. Prime recognition and factorization