Is n a prime number

136
Is n a Prime Number? Manindra Agrawal IIT Kanpur March 27, 2006, Delft Manindra Agra w al (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 1 / 47

Transcript of Is n a prime number

Page 1: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 1/136

Is n a Prime Number?

Manindra Agrawal

IIT Kanpur

March 27, 2006, Delft

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 1 / 47

Page 2: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 2/136

Overview

1 The Problem

2 Two Simple, and Slow, Methods

3

Modern Methods

4 Algorithms Based on Factorization of Group Size

5 Algorithms Based on Fermat’s Little Theorem

6 An Algorithm Outside the Two Themes

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 2 / 47

Page 3: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 3/136

Outline

1 The Problem

2 Two Simple, and Slow, Methods

3 Modern Methods

4 Algorithms Based on Factorization of Group Size

5 Algorithms Based on Fermat’s Little Theorem

6 An Algorithm Outside the Two Themes

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 3 / 47

Page 4: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 4/136

The Problem

Given a number n, decide if it is prime.

Easy: try dividing by all numbers less than n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 4 / 47

Page 5: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 5/136

The Problem

Given a number n, decide if it is prime.

Easy: try dividing by all numbers less than n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 4 / 47

Page 6: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 6/136

The Problem

Given a number n, decide if it is prime efficiently.

Not so easy: several non-obvious methods have been found.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 5 / 47

Page 7: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 7/136

The Problem

Given a number n, decide if it is prime efficiently.

Not so easy: several non-obvious methods have been found.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 5 / 47

Page 8: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 8/136

Efficiently Solving a Problem

There should exist an algorithm for solving the problem taking apolynomial in input size number of steps.

For our problem, this means an algorithm taking logO (1) n steps.

Caveat: An algorithm taking log12

n steps would be slower than analgorithm taking loglog log log n n steps for all practical valuesof n!

Notation:

log is logarithm base 2.O (logc n) stands for O (logc n log logO (1) n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 6 / 47

Page 9: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 9/136

Efficiently Solving a Problem

There should exist an algorithm for solving the problem taking apolynomial in input size number of steps.

For our problem, this means an algorithm taking logO (1) n steps.

Caveat: An algorithm taking log12

n steps would be slower than analgorithm taking loglog log log n n steps for all practical valuesof n!

Notation:

log is logarithm base 2.O (logc n) stands for O (logc n log logO (1) n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 6 / 47

Page 10: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 10/136

Efficiently Solving a Problem

There should exist an algorithm for solving the problem taking apolynomial in input size number of steps.

For our problem, this means an algorithm taking logO (1) n steps.

Caveat: An algorithm taking log12

n steps would be slower than analgorithm taking loglog log log n n steps for all practical valuesof n!

Notation:

log is logarithm base 2.O (logc n) stands for O (logc n log logO (1) n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 6 / 47

Page 11: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 11/136

Efficiently Solving a Problem

There should exist an algorithm for solving the problem taking apolynomial in input size number of steps.

For our problem, this means an algorithm taking logO (1) n steps.

Caveat: An algorithm taking log

12

n steps would be slower than analgorithm taking loglog log log n n steps for all practical valuesof n!

Notation:

log is logarithm base 2.O (logc n) stands for O (logc n log logO (1) n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 6 / 47

Page 12: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 12/136

Outline

1

The Problem

2 Two Simple, and Slow, Methods

3 Modern Methods

4 Algorithms Based on Factorization of Group Size

5 Algorithms Based on Fermat’s Little Theorem

6 An Algorithm Outside the Two Themes

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 7 / 47

Page 13: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 13/136

The Sieve of Eratosthenes

Proposed by Eratosthenes (ca. 300 BCE).

1 List all numbers from 2 to n in a sequence.

2 Take the smallest uncrossed number from the sequence and cross outall its multiples.

3 If n is uncrossed when the smallest uncrossed number is greater than√n then n is prime otherwise composite.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 8 / 47

Page 14: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 14/136

Time Complexity

If n is prime, algorithm crosses out all the first√

n numbers before

giving the answer.So the number of steps needed is Ω(

√n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 9 / 47

Page 15: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 15/136

Time Complexity

If n is prime, algorithm crosses out all the first√

n numbers before

giving the answer.So the number of steps needed is Ω(

√n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 9 / 47

Page 16: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 16/136

Wilson’s Theorem

Based on Wilson’s theorem (1770).

Theorem

n is prime iff (n − 1)! = −1 (mod n).

Computing (n − 1)! (mod n) naıvely requires Ω(n) steps.

No significantly better method is known!

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 10 / 47

W ’ T

Page 17: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 17/136

Wilson’s Theorem

Based on Wilson’s theorem (1770).

Theorem

n is prime iff (n − 1)! = −1 (mod n).

Computing (n − 1)! (mod n) naıvely requires Ω(n) steps.

No significantly better method is known!

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 10 / 47

O

Page 18: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 18/136

Outline

1

The Problem

2 Two Simple, and Slow, Methods

3 Modern Methods

4 Algorithms Based on Factorization of Group Size

5 Algorithms Based on Fermat’s Little Theorem

6 An Algorithm Outside the Two Themes

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 11 / 47

F a a I a

Page 19: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 19/136

Fundamental Idea

Nearly all the efficient algorithms for the problem use the following idea.

Identify a finite group G related to number n.

Design an efficienty testable property P (·) of the elements G suchthat P (e ) has different values depending on whether n is prime.

The element e is either from a small set (in deterministic algorithms)or a random element of G (in randomized algorithms).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 12 / 47

Fundamental Idea

Page 20: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 20/136

Fundamental Idea

Nearly all the efficient algorithms for the problem use the following idea.

Identify a finite group G related to number n.

Design an efficienty testable property P (·) of the elements G suchthat P (e ) has different values depending on whether n is prime.

The element e is either from a small set (in deterministic algorithms)or a random element of G (in randomized algorithms).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 12 / 47

Fundamental Idea

Page 21: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 21/136

Fundamental Idea

Nearly all the efficient algorithms for the problem use the following idea.

Identify a finite group G related to number n.

Design an efficienty testable property P (·) of the elements G suchthat P (e ) has different values depending on whether n is prime.

The element e is either from a small set (in deterministic algorithms)or a random element of G (in randomized algorithms).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 12 / 47

Fundamental Idea

Page 22: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 22/136

Fundamental Idea

Nearly all the efficient algorithms for the problem use the following idea.

Identify a finite group G related to number n.

Design an efficienty testable property P (·) of the elements G suchthat P (e ) has different values depending on whether n is prime.

The element e is either from a small set (in deterministic algorithms)or a random element of G (in randomized algorithms).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 12 / 47

Groups and Properties

Page 23: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 23/136

Groups and Properties

The group G is often: A subgroup of Z ∗n or Z ∗n [ζ ] for an extension ring Z n[ζ ].

A subgroup of E (Z n), the set of points on an elliptic curve modulo n.The properties vary, but are from two broad themes.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 13 / 47

Groups and Properties

Page 24: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 24/136

Groups and Properties

The group G is often: A subgroup of Z ∗n or Z ∗n [ζ ] for an extension ring Z n[ζ ].

A subgroup of E (Z n), the set of points on an elliptic curve modulo n.The properties vary, but are from two broad themes.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 13 / 47

Groups and Properties

Page 25: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 25/136

Groups and Properties

The group G is often: A subgroup of Z ∗n or Z ∗n [ζ ] for an extension ring Z n[ζ ].

A subgroup of E (Z n), the set of points on an elliptic curve modulo n.The properties vary, but are from two broad themes.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 13 / 47

Theme I: Factorization of Group Size

Page 26: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 26/136

Theme I: Factorization of Group Size

Compute a complete, or partial, factorization of the size of G

assuming that n is prime.

Use the knowledge of this factorization to design a suitable property.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 14 / 47

Theme I: Factorization of Group Size

Page 27: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 27/136

Theme I: Factorization of Group Size

Compute a complete, or partial, factorization of the size of G

assuming that n is prime.

Use the knowledge of this factorization to design a suitable property.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 14 / 47

Theme II: Fermat’s Little Theorem

Page 28: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 28/136

Theme II: Fermat s Little Theorem

Theorem (Fermat, 1660s)

If n is prime then for every e , e n = e (mod n).

Group G = Z ∗n and property P is P (e ) ≡ e n = e in G .

This property of Z n is not a sufficient test for primality of n.

So try to extend this property to a neccessary and sufficient condition.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 15 / 47

Theme II: Fermat’s Little Theorem

Page 29: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 29/136

Theme II: Fermat s Little Theorem

Theorem (Fermat, 1660s)

If n is prime then for every e , e n = e (mod n).

Group G = Z ∗n and property P is P (e ) ≡ e n = e in G .

This property of Z n is not a sufficient test for primality of n.

So try to extend this property to a neccessary and sufficient condition.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 15 / 47

Outline

Page 30: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 30/136

Outline

1 The Problem

2 Two Simple, and Slow, Methods

3 Modern Methods

4 Algorithms Based on Factorization of Group Size

5 Algorithms Based on Fermat’s Little Theorem

6 An Algorithm Outside the Two Themes

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 16 / 47

Lucas Theorem

Page 31: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 31/136

Theorem (E. Lucas, 1891)

Let n − 1 =t

i =1 p d i i where p i ’s are distinct primes. n is prime iff there is

an e ∈ Z n such that e n−1 = 1 and gcd(e n−1p i − 1, n) = 1 for every

1≤

i ≤

t .

The theorem also holds for a random choice of e .

We can choose G = Z ∗n and P to be the property above.

The test will be efficient only for numbers n such that n−1 is smooth.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 17 / 47

Lucas Theorem

Page 32: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 32/136

Theorem (E. Lucas, 1891)

Let n − 1 =t

i =1 p d i i where p i ’s are distinct primes. n is prime iff there is

an e ∈ Z n such that e n−1 = 1 and gcd(e n−1p i − 1, n) = 1 for every

1≤

i ≤

t .

The theorem also holds for a random choice of e .

We can choose G = Z ∗n and P to be the property above.

The test will be efficient only for numbers n such that n−1 is smooth.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 17 / 47

Lucas Theorem

Page 33: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 33/136

Theorem (E. Lucas, 1891)

Let n − 1 =t

i =1 p d i i where p i ’s are distinct primes. n is prime iff there is

an e ∈ Z n such that e n−1 = 1 and gcd(e n−1p i − 1, n) = 1 for every

1≤

i ≤

t .

The theorem also holds for a random choice of e .

We can choose G = Z ∗n and P to be the property above.

The test will be efficient only for numbers n such that n−1 is smooth.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 17 / 47

Lucas-Lehmer Test

Page 34: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 34/136

G is a subgroup of Z ∗n [√

3] containing elements of order n + 1.

The property P is: P (e ) ≡ e n+1

2 = −1 in Z n[√

3].

Works only for special Mersenne primes of the form n = 2p

−1, p

prime.

For such n’s, n + 1 = 2p .

The property needs to be tested only for e = 2 +√

3.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 18 / 47

Lucas-Lehmer Test

Page 35: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 35/136

G is a subgroup of Z ∗n [√

3] containing elements of order n + 1.

The property P is: P (e ) ≡ e n+1

2 = −1 in Z n[√

3].

Works only for special Mersenne primes of the form n = 2p

−1, p

prime.

For such n’s, n + 1 = 2p .

The property needs to be tested only for e = 2 +√

3.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 18 / 47

Lucas-Lehmer Test

Page 36: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 36/136

G is a subgroup of Z ∗n [√

3] containing elements of order n + 1.

The property P is: P (e ) ≡ e n+1

2 = −1 in Z n[√

3].

Works only for special Mersenne primes of the form n = 2p

−1, p

prime.

For such n’s, n + 1 = 2p .

The property needs to be tested only for e = 2 +√

3.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 18 / 47

Time Complexity

Page 37: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 37/136

Raising 2 +√

3 to n+12 th power requires O (log n) multiplication

operations in Z n.

Overall time complexity is O (log2 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 19 / 47

Time Complexity

Page 38: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 38/136

Raising 2 +√

3 to n+12 th power requires O (log n) multiplication

operations in Z n.

Overall time complexity is O (log2 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 19 / 47

Pocklington-Lehmer Test

Page 39: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 39/136

Theorem (Pocklington, 1914)If there exists a e such that e n−1 = 1 (mod n) and gcd(e

n−1p j − 1, n) = 1

for distinct primes p 1, p 2, . . . , p t dividing n− 1 then every prime factor of n

has the form k ·

t j =1 p j + 1.

Similar to Lucas’s theorem.

Let G = Z ∗n and property P precisely as in the theorem.

The property is tested for a random e .

For the test to work, we needt

j =1 ≥ √n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 20 / 47

Pocklington-Lehmer Test

Page 40: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 40/136

Theorem (Pocklington, 1914)If there exists a e such that e n−1 = 1 (mod n) and gcd(e

n−1p j − 1, n) = 1

for distinct primes p 1, p 2, . . . , p t dividing n− 1 then every prime factor of n

has the form k ·

t j =1 p j + 1.

Similar to Lucas’s theorem.

Let G = Z ∗n and property P precisely as in the theorem.

The property is tested for a random e .

For the test to work, we needt

j =1 ≥ √n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 20 / 47

Pocklington-Lehmer Test

Page 41: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 41/136

Theorem (Pocklington, 1914)If there exists a e such that e n−1 = 1 (mod n) and gcd(e

n−1p j − 1, n) = 1

for distinct primes p 1, p 2, . . . , p t dividing n− 1 then every prime factor of n

has the form k ·

t j =1 p j + 1.

Similar to Lucas’s theorem.

Let G = Z ∗n and property P precisely as in the theorem.

The property is tested for a random e .

For the test to work, we needt

j =1 ≥ √n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 20 / 47

Time Complexity

Page 42: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 42/136

Depends on the difficulty of finding prime factorizations of n − 1whose product is at least

√n.

Other operations can be carried out efficiently.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 21 / 47

Time Complexity

Page 43: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 43/136

Depends on the difficulty of finding prime factorizations of n − 1whose product is at least

√n.

Other operations can be carried out efficiently.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 21 / 47

Elliptic Curves Based Tests

Page 44: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 44/136

Elliptic curves give rise to groups of different sizes associated with thegiven number.

With good probability, some of these groups have sizes that can beeasily factored.

This motivated primality testing based on elliptic curves.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 22 / 47

Elliptic Curves Based Tests

Page 45: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 45/136

Elliptic curves give rise to groups of different sizes associated with thegiven number.

With good probability, some of these groups have sizes that can beeasily factored.

This motivated primality testing based on elliptic curves.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 22 / 47

Elliptic Curves Based Tests

Page 46: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 46/136

Elliptic curves give rise to groups of different sizes associated with thegiven number.

With good probability, some of these groups have sizes that can beeasily factored.

This motivated primality testing based on elliptic curves.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 22 / 47

Goldwasser-Kilian Test

Page 47: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 47/136

This is a randomized primality proving algorithm.

Under a reasonable hypothesis, it is polynomial time on all inputs.

Unconditionally, it is polynomial time on all but negligible fraction of numbers.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 23 / 47

Goldwasser-Kilian Test

Page 48: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 48/136

This is a randomized primality proving algorithm.

Under a reasonable hypothesis, it is polynomial time on all inputs.

Unconditionally, it is polynomial time on all but negligible fraction of numbers.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 23 / 47

Goldwasser-Kilian Test

Page 49: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 49/136

This is a randomized primality proving algorithm.

Under a reasonable hypothesis, it is polynomial time on all inputs.

Unconditionally, it is polynomial time on all but negligible fraction of numbers.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 23 / 47

Goldwasser-Kilian Test

Page 50: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 50/136

Consider a random elliptic curve over Z n.

By a theorem of Lenstra (1987), the number of points of the curve isnearly uniformly distributed in the interval [n + 1− 2

√n, n + 1 + 2

√n]

for prime n.Assuming a conjecture about the density of primes in small intervals,it follows that there are curves with 2q points, for q prime, withreasonable probability.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 24 / 47

Goldwasser-Kilian Test

Page 51: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 51/136

Consider a random elliptic curve over Z n.

By a theorem of Lenstra (1987), the number of points of the curve isnearly uniformly distributed in the interval [n + 1− 2

√n, n + 1 + 2

√n]

for prime n.Assuming a conjecture about the density of primes in small intervals,it follows that there are curves with 2q points, for q prime, withreasonable probability.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 24 / 47

Goldwasser-Kilian Test

Page 52: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 52/136

Consider a random elliptic curve over Z n.

By a theorem of Lenstra (1987), the number of points of the curve isnearly uniformly distributed in the interval [n + 1− 2

√n, n + 1 + 2

√n]

for prime n.Assuming a conjecture about the density of primes in small intervals,it follows that there are curves with 2q points, for q prime, withreasonable probability.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 24 / 47

Goldwasser-Kilian Test

Page 53: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 53/136

Theorem (Goldwasser-Kilian)

Suppose E (Z n) is an elliptic curve with 2q points. If q is prime and there

exists A ∈ E (Z n) = O such that q · A = O then either n is provably prime

or provably composite.

Proof.

Let p be a prime factor of n with p ≤ √n.We have q · A = O in E (Z p ) as well.

If A = O in E (Z p ) then n can be factored.

Otherwise, since q is prime,

|E (Z p )

| ≥q .

If 2q < n + 1 − 2√n then n must be composite.

Otherwise, p + 1 + 2√

p > n2 −

√n which is not possible.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 25 / 47

Goldwasser-Kilian Test

Page 54: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 54/136

Theorem (Goldwasser-Kilian)

Suppose E (Z n) is an elliptic curve with 2q points. If q is prime and there

exists A ∈ E (Z n) = O such that q · A = O then either n is provably prime

or provably composite.

Proof.

Let p be a prime factor of n with p ≤ √n.We have q · A = O in E (Z p ) as well.

If A = O in E (Z p ) then n can be factored.

Otherwise, since q is prime, |E (Z p )| ≥ q .

If 2q < n + 1 − 2√n then n must be composite.

Otherwise, p + 1 + 2√

p > n2 −

√n which is not possible.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 25 / 47

Goldwasser-Kilian Test

Page 55: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 55/136

Theorem (Goldwasser-Kilian)

Suppose E (Z n) is an elliptic curve with 2q points. If q is prime and there

exists A ∈ E (Z n) = O such that q · A = O then either n is provably prime

or provably composite.

Proof.

Let p be a prime factor of n with p ≤ √n.We have q · A = O in E (Z p ) as well.

If A = O in E (Z p ) then n can be factored.

Otherwise, since q is prime, |E (Z p )| ≥ q .

If 2q < n + 1 − 2√n then n must be composite.

Otherwise, p + 1 + 2√

p > n2 −

√n which is not possible.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 25 / 47

Goldwasser-Kilian Test

Page 56: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 56/136

Theorem (Goldwasser-Kilian)

Suppose E (Z n) is an elliptic curve with 2q points. If q is prime and there

exists A ∈ E (Z n) = O such that q · A = O then either n is provably prime

or provably composite.

Proof.

Let p be a prime factor of n with p ≤ √n.We have q · A = O in E (Z p ) as well.

If A = O in E (Z p ) then n can be factored.

Otherwise, since q is prime, |E (Z p )| ≥ q .

If 2q < n + 1 − 2√n then n must be composite.

Otherwise, p + 1 + 2√

p > n2 −

√n which is not possible.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 25 / 47

Goldwasser-Kilian Test

Page 57: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 57/136

1 Find a random elliptic curve over Z n with 2q points.

2 Prove primality of q recursively.

3 Randomly select an A such that q · A = O .4 Infer n to be prime or composite.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 26 / 47

Goldwasser-Kilian Test

Page 58: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 58/136

1 Find a random elliptic curve over Z n with 2q points.

2 Prove primality of q recursively.

3 Randomly select an A such that q · A = O .4 Infer n to be prime or composite.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 26 / 47

Goldwasser-Kilian Test

Page 59: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 59/136

1 Find a random elliptic curve over Z n with 2q points.

2 Prove primality of q recursively.

3 Randomly select an A such that q · A = O .4 Infer n to be prime or composite.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 26 / 47

Goldwasser-Kilian Test

Page 60: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 60/136

1 Find a random elliptic curve over Z n with 2q points.

2 Prove primality of q recursively.

3 Randomly select an A such that q · A = O .4 Infer n to be prime or composite.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 26 / 47

Analysis

Page 61: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 61/136

The algorithm never incorrectly classifies a composite number.

With high probability it correctly classifies prime numbers.

The running time is O (log11 n).

Improvements by Atkin and others result in a conjectured runningtime of O (log4 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 27 / 47

Analysis

Page 62: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 62/136

The algorithm never incorrectly classifies a composite number.

With high probability it correctly classifies prime numbers.

The running time is O (log11 n).

Improvements by Atkin and others result in a conjectured runningtime of O (log4 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 27 / 47

Analysis

Page 63: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 63/136

The algorithm never incorrectly classifies a composite number.

With high probability it correctly classifies prime numbers.

The running time is O (log11 n).

Improvements by Atkin and others result in a conjectured runningtime of O (log4 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 27 / 47

Analysis

Page 64: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 64/136

The algorithm never incorrectly classifies a composite number.

With high probability it correctly classifies prime numbers.

The running time is O (log11 n).

Improvements by Atkin and others result in a conjectured runningtime of O (log4 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 27 / 47

Adleman-Huang Test

Page 65: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 65/136

The previous test is not unconditionally polynomial time on a smallfraction of numbers.

Adleman-Huang (1992) removed this drawback.

They first used hyperelliptic curves to reduce the problem of testingfor n to that of a nearly random integer of similar size.

Then the previous test works with high probability.

The time complexity becomes O (logc n) for c > 30!

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 28 / 47

Adleman-Huang Test

Page 66: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 66/136

The previous test is not unconditionally polynomial time on a smallfraction of numbers.

Adleman-Huang (1992) removed this drawback.

They first used hyperelliptic curves to reduce the problem of testingfor n to that of a nearly random integer of similar size.

Then the previous test works with high probability.

The time complexity becomes O (logc n) for c > 30!

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 28 / 47

Adleman-Huang Test

Page 67: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 67/136

The previous test is not unconditionally polynomial time on a smallfraction of numbers.

Adleman-Huang (1992) removed this drawback.

They first used hyperelliptic curves to reduce the problem of testingfor n to that of a nearly random integer of similar size.

Then the previous test works with high probability.

The time complexity becomes O (logc n) for c > 30!

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 28 / 47

Outline

Page 68: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 68/136

1 The Problem

2 Two Simple, and Slow, Methods

3 Modern Methods

4 Algorithms Based on Factorization of Group Size

5 Algorithms Based on Fermat’s Little Theorem

6 An Algorithm Outside the Two Themes

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 29 / 47

Solovay-Strassen Test

Page 69: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 69/136

A Restatement of FLTIf n is odd prime then for every e , 1 ≤ e < n, e

n−12 = ±1 (mod n).

When n is prime, e is a quadratic residue in Z n iff e n−1

2 = 1 (mod n).

Therefore, if n is prime then

e

n

= e

n−12 (mod n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 30 / 47

Solovay-Strassen Test

Page 70: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 70/136

A Restatement of FLTIf n is odd prime then for every e , 1 ≤ e < n, e

n−12 = ±1 (mod n).

When n is prime, e is a quadratic residue in Z n iff e n−1

2 = 1 (mod n).

Therefore, if n is prime then

e

n

= e

n−12 (mod n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 30 / 47

Solovay-Strassen Test

Page 71: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 71/136

A Restatement of FLTIf n is odd prime then for every e , 1 ≤ e < n, e

n−12 = ±1 (mod n).

When n is prime, e is a quadratic residue in Z n iff e n−1

2 = 1 (mod n).

Therefore, if n is prime then

e

n

= e

n−12 (mod n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 30 / 47

Solovay-Strassen Test

Page 72: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 72/136

Proposed by Solovay and Strassen (1973).

A randomized algorithm based on above property.

Never incorrectly classifies primes and correctly classifies compositeswith probability at least 1

2 .

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 31 / 47

Solovay-Strassen Test

Page 73: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 73/136

Proposed by Solovay and Strassen (1973).

A randomized algorithm based on above property.

Never incorrectly classifies primes and correctly classifies compositeswith probability at least 1

2 .

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 31 / 47

Solovay-Strassen Test

Page 74: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 74/136

Proposed by Solovay and Strassen (1973).

A randomized algorithm based on above property.

Never incorrectly classifies primes and correctly classifies compositeswith probability at least 1

2 .

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 31 / 47

Solovay-Strassen Test

Page 75: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 75/136

1 If n is an exact power, it is composite.2 For a random e in Z n, test if

e

n

= e

n−12 (mod n).

3 If yes, classify n as prime otherwise it is proven composite.

The time complexity is O (log2 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 32 / 47

Solovay-Strassen Test

Page 76: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 76/136

1 If n is an exact power, it is composite.2 For a random e in Z n, test if

e

n

= e

n−12 (mod n).

3 If yes, classify n as prime otherwise it is proven composite.

The time complexity is O (log2 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 32 / 47

Solovay-Strassen Test

Page 77: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 77/136

1 If n is an exact power, it is composite.2 For a random e in Z n, test if

e

n

= e

n−12 (mod n).

3 If yes, classify n as prime otherwise it is proven composite.

The time complexity is O (log2 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 32 / 47

Solovay-Strassen Test

Page 78: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 78/136

1 If n is an exact power, it is composite.2 For a random e in Z n, test if

e

n

= e

n−12 (mod n).

3 If yes, classify n as prime otherwise it is proven composite.

The time complexity is O (log2 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 32 / 47

Analysis

Consider the case when n is a product of two primes p and q

Page 79: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 79/136

Consider the case when n is a product of two primes p and q .

Let a, b ∈ Z p , c ∈ Z q with a residue and b non-residue in Z p .Clearly, < a, c >

n−12 =< b , c >

n−12 (mod q ).

If < a, c >n−1

2 =< b , c >n−1

2 (mod n) then one of them is not in1,−1 and so compositeness of n is proven.

Otherwise, either< a, c >

n

=< a, c >

n−12 (mod n),

or < b , c >

n

=< b , c >n−1

2 (mod n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 33 / 47

Analysis

Consider the case when n is a product of two primes p and q

Page 80: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 80/136

Consider the case when n is a product of two primes p and q .

Let a, b ∈ Z p , c ∈ Z q with a residue and b non-residue in Z p .Clearly, < a, c >

n−12 =< b , c >

n−12 (mod q ).

If < a, c >n−1

2 =< b , c >n−1

2 (mod n) then one of them is not in1,−1 and so compositeness of n is proven.

Otherwise, either< a, c >

n

=< a, c >

n−12 (mod n),

or < b , c >

n =< b , c >

n−12 (mod n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 33 / 47

Analysis

Consider the case when n is a product of two primes p and q

Page 81: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 81/136

Consider the case when n is a product of two primes p and q .

Let a, b ∈ Z p , c ∈ Z q with a residue and b non-residue in Z p .Clearly, < a, c >

n−12 =< b , c >

n−12 (mod q ).

If < a, c >n−1

2 =< b , c >n−1

2 (mod n) then one of them is not in1,−1 and so compositeness of n is proven.

Otherwise, either< a, c >

n

=< a, c >

n−12 (mod n),

or < b , c >n

=< b , c >n−1

2 (mod n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 33 / 47

Analysis

Consider the case when n is a product of two primes p and q

Page 82: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 82/136

Consider the case when n is a product of two primes p and q .

Let a, b ∈ Z p , c ∈ Z q with a residue and b non-residue in Z p .Clearly, < a, c >

n−12 =< b , c >

n−12 (mod q ).

If < a, c >n−1

2 =< b , c >n−1

2 (mod n) then one of them is not in1,−1 and so compositeness of n is proven.

Otherwise, either< a, c >

n

=< a, c >

n−12 (mod n),

or < b , c >n

=< b , c >n−1

2 (mod n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 33 / 47

Miller’s Test

Page 83: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 83/136

Theorem (Another Restatement of FLT)

If n is odd prime and n = 1 + 2s · t , t odd, then for every e , 1 ≤ e < n,

the sequence e

2s −1·t

(mod n), e

2s −2·t

(mod n), . . ., e

t

(mod n) has either all 1’s or a −1 somewhere.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 34 / 47

Miller’s Test

Page 84: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 84/136

This theorem is the basis for Miller’s test (1973).

It is a deterministic polynomial time test.

It is correct under Extended Riemann Hypothesis.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 35 / 47

Miller’s Test

Page 85: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 85/136

This theorem is the basis for Miller’s test (1973).

It is a deterministic polynomial time test.

It is correct under Extended Riemann Hypothesis.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 35 / 47

Miller’s Test

Page 86: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 86/136

This theorem is the basis for Miller’s test (1973).

It is a deterministic polynomial time test.

It is correct under Extended Riemann Hypothesis.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 35 / 47

Miller’s Test

Page 87: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 87/136

1 If n is an exact power, it is composite.

2 For each e , 1 < e ≤ 4log2 n, check if the sequence e 2s −1

·t (mod n),e 2

s −2·t (mod n), . . ., e t (mod n) has either all 1’s or a −1 somewhere.

3

If yes, classify n as prime otherwise composite.

The time complexity of the test is O (log4 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 36 / 47

Miller’s Test

Page 88: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 88/136

1 If n is an exact power, it is composite.

2 For each e , 1 < e ≤ 4log2 n, check if the sequence e 2s −1

·t (mod n),e 2

s −2·t (mod n), . . ., e t (mod n) has either all 1’s or a −1 somewhere.

3

If yes, classify n as prime otherwise composite.

The time complexity of the test is O (log4 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 36 / 47

Miller’s Test

Page 89: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 89/136

1 If n is an exact power, it is composite.

2 For each e , 1 < e ≤ 4log2 n, check if the sequence e 2s −1

·t (mod n),e 2

s −2·t (mod n), . . ., e t (mod n) has either all 1’s or a −1 somewhere.

3

If yes, classify n as prime otherwise composite.

The time complexity of the test is O (log4 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 36 / 47

Miller’s Test

Page 90: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 90/136

1 If n is an exact power, it is composite.

2 For each e , 1 < e ≤ 4log2 n, check if the sequence e 2s −1

·t (mod n),e 2

s −2·t (mod n), . . ., e t (mod n) has either all 1’s or a −1 somewhere.

3

If yes, classify n as prime otherwise composite.

The time complexity of the test is O (log4 n).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 36 / 47

Rabin’s Test

Page 91: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 91/136

A modification of Miller’s algorithm proposed soon after (1974).

Selects e randomly instead of trying all e in the range [2, 4log2 n].

Randomized algorithm that never classfies primes incorrectly and

correctly classifies composites with probabilty at least

3

4 .Time complexity is O (log2 n).

The most popular primality testing algorithm.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 37 / 47

Rabin’s Test

Page 92: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 92/136

A modification of Miller’s algorithm proposed soon after (1974).

Selects e randomly instead of trying all e in the range [2, 4log2 n].

Randomized algorithm that never classfies primes incorrectly and

correctly classifies composites with probabilty at least

3

4 .Time complexity is O (log2 n).

The most popular primality testing algorithm.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 37 / 47

Rabin’s Test

Page 93: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 93/136

A modification of Miller’s algorithm proposed soon after (1974).

Selects e randomly instead of trying all e in the range [2, 4log2 n].

Randomized algorithm that never classfies primes incorrectly and

correctly classifies composites with probabilty at least

3

4 .Time complexity is O (log2 n).

The most popular primality testing algorithm.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 37 / 47

Rabin’s Test

Page 94: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 94/136

A modification of Miller’s algorithm proposed soon after (1974).

Selects e randomly instead of trying all e in the range [2, 4log2 n].

Randomized algorithm that never classfies primes incorrectly and

correctly classifies composites with probabilty at least

3

4 .Time complexity is O (log2 n).

The most popular primality testing algorithm.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 37 / 47

AKS Test

Page 95: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 95/136

Theorem (A Generalization of FLT)

If n is prime then for every e , 1 ≤ e < n, (ζ + e )n = ζ n + e in Z n[ζ ],

ζ r = 1.

A test proposed in 2002 based on this generalization.

The only known deterministic, unconditionally correct, polynomialtime algorithm.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 38 / 47

AKS Test

Page 96: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 96/136

Theorem (A Generalization of FLT)

If n is prime then for every e , 1 ≤ e < n, (ζ + e )n = ζ n + e in Z n[ζ ],

ζ r = 1.

A test proposed in 2002 based on this generalization.

The only known deterministic, unconditionally correct, polynomialtime algorithm.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 38 / 47

AKS Test

Page 97: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 97/136

Theorem (A Generalization of FLT)

If n is prime then for every e , 1 ≤ e < n, (ζ + e )n = ζ n + e in Z n[ζ ],

ζ r = 1.

A test proposed in 2002 based on this generalization.

The only known deterministic, unconditionally correct, polynomialtime algorithm.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 38 / 47

AKS Test

Page 98: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 98/136

1 If n is an exact power or has a small divisor, it is composite.

2 Select a small number r carefully, let ζ r = 1 and consider Z n[ζ ].

3 For each e , 1≤

e ≤

2√

r log n, check if (ζ + e )n = ζ n + e in Z n[ζ ].

4 If yes, n is prime otherwise composite.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27 2006 Delft 39 / 47

AKS Test

Page 99: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 99/136

1 If n is an exact power or has a small divisor, it is composite.

2 Select a small number r carefully, let ζ r = 1 and consider Z n[ζ ].

3 For each e , 1≤

e ≤

2√

r log n, check if (ζ + e )n = ζ n + e in Z n[ζ ].

4 If yes, n is prime otherwise composite.

Manindra Agrawal (IIT Kanpur) Is a Prime Number? March 27 2006 Delft 39 / 47

AKS Test

Page 100: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 100/136

1 If n is an exact power or has a small divisor, it is composite.

2 Select a small number r carefully, let ζ r = 1 and consider Z n[ζ ].

3 For each e , 1≤

e ≤

2√

r log n, check if (ζ + e )n = ζ n + e in Z n[ζ ].

4 If yes, n is prime otherwise composite.

M A (IIT K ) Is P N ? M 27 2006 D 39 / 47

AKS Test

Page 101: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 101/136

1 If n is an exact power or has a small divisor, it is composite.

2 Select a small number r carefully, let ζ r = 1 and consider Z n[ζ ].

3 For each e , 1≤

e

≤2√

r log n, check if (ζ + e )n = ζ n + e in Z n[ζ ].

4 If yes, n is prime otherwise composite.

M A (IIT K ) In

P N ? M 27 2006 D 39 / 47

Analysis

Suppose n has at least two prime factors and let p be one of them

Page 102: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 102/136

Suppose n has at least two prime factors and let p be one of them.

Let S ⊆ Z p [ζ ] such that for every element f (ζ ) ∈ S , f ζ )n = f (ζ n) inZ p [ζ ].

It follows that for every f (ζ ) ∈ S , f (ζ )m = f (ζ m) for any m of theform ni · p j .

Since n is not a power of p , this places an upper bound on the size of S .

If ζ + e ∈ S for every 1 ≤ e ≤ 2√

r log n, then all their products arealso in S .

This makes the size of S bigger than the upper bound above.

M A (IIT K ) In

P N ? M 27 2006 D 40 / 47

Analysis

Suppose n has at least two prime factors and let p be one of them

Page 103: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 103/136

Suppose n has at least two prime factors and let p be one of them.

Let S ⊆ Z p [ζ ] such that for every element f (ζ ) ∈ S , f ζ )n = f (ζ n) inZ p [ζ ].

It follows that for every f (ζ ) ∈ S , f (ζ )m = f (ζ m) for any m of theform ni · p j .

Since n is not a power of p , this places an upper bound on the size of S .

If ζ + e ∈ S for every 1 ≤ e ≤ 2√

r log n, then all their products arealso in S .

This makes the size of S bigger than the upper bound above.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 40 / 47

Analysis

Suppose n has at least two prime factors and let p be one of them.

Page 104: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 104/136

Suppose n has at least two prime factors and let p be one of them.

Let S ⊆ Z p [ζ ] such that for every element f (ζ ) ∈ S , f ζ )n = f (ζ n) inZ p [ζ ].

It follows that for every f (ζ ) ∈ S , f (ζ )m = f (ζ m) for any m of theform ni · p j .

Since n is not a power of p , this places an upper bound on the size of S .

If ζ + e ∈ S for every 1 ≤ e ≤ 2√

r log n, then all their products arealso in S .

This makes the size of S bigger than the upper bound above.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 40 / 47

Analysis

Suppose n has at least two prime factors and let p be one of them.

Page 105: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 105/136

Suppose as at east t o p e acto s a d et p be o e o t e

Let S ⊆ Z p [ζ ] such that for every element f (ζ ) ∈ S , f ζ )n = f (ζ n) inZ p [ζ ].

It follows that for every f (ζ ) ∈ S , f (ζ )m = f (ζ m) for any m of theform ni · p j .

Since n is not a power of p , this places an upper bound on the size of S .

If ζ + e ∈ S for every 1 ≤ e ≤ 2√

r log n, then all their products arealso in S .

This makes the size of S bigger than the upper bound above.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 40 / 47

Analysis

Suppose n has at least two prime factors and let p be one of them.

Page 106: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 106/136

pp p p

Let S ⊆ Z p [ζ ] such that for every element f (ζ ) ∈ S , f ζ )n = f (ζ n) inZ p [ζ ].

It follows that for every f (ζ ) ∈ S , f (ζ )m = f (ζ m) for any m of theform ni · p j .

Since n is not a power of p , this places an upper bound on the size of S .

If ζ + e ∈ S for every 1 ≤ e ≤ 2√

r log n, then all their products arealso in S .

This makes the size of S bigger than the upper bound above.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 40 / 47

Time Complexity

Page 107: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 107/136

Number r is O (log5

n).Time complexity of the algorithm is O (log12 n).

An improvement by Hendrik Lenstra (2002) reduces the timecomplexity to O (log15/2 n).

Lenstra and Pomerance (2003) further reduce the time complexity toO (log6 n).

Bernstein (2003) reduced the time complexity to O (log4 n) at thecost of making it randomized.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 41 / 47

Time Complexity

Page 108: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 108/136

Number r is O (log5

n).Time complexity of the algorithm is O (log12 n).

An improvement by Hendrik Lenstra (2002) reduces the timecomplexity to O (log15/2 n).

Lenstra and Pomerance (2003) further reduce the time complexity toO (log6 n).

Bernstein (2003) reduced the time complexity to O (log4 n) at thecost of making it randomized.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 41 / 47

Time Complexity

5

Page 109: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 109/136

Number r is O (log5

n).Time complexity of the algorithm is O (log12 n).

An improvement by Hendrik Lenstra (2002) reduces the timecomplexity to O (log15/2 n).

Lenstra and Pomerance (2003) further reduce the time complexity toO (log6 n).

Bernstein (2003) reduced the time complexity to O (log4 n) at thecost of making it randomized.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 41 / 47

Time Complexity

5

Page 110: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 110/136

Number r is O (log5

n).Time complexity of the algorithm is O (log12 n).

An improvement by Hendrik Lenstra (2002) reduces the timecomplexity to O (log15/2 n).

Lenstra and Pomerance (2003) further reduce the time complexity toO (log6 n).

Bernstein (2003) reduced the time complexity to O (log4 n) at thecost of making it randomized.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 41 / 47

Page 111: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 111/136

Outline

1 The Problem

Page 112: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 112/136

2 Two Simple, and Slow, Methods

3 Modern Methods

4 Algorithms Based on Factorization of Group Size

5 Algorithms Based on Fermat’s Little Theorem

6 An Algorithm Outside the Two Themes

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 42 / 47

Adleman-Pomerance-Rumeli Test

Page 113: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 113/136

Proposed in 1980.

Is conceptually the most complex algorithm of them all.

Uses multiple groups, ideas derived from both themes, plus new ones!

It is a deterministic algorithm with time complexity logO (log log log n) n.Was speeded up by Cohen and Lenstra (1981).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 43 / 47

Adleman-Pomerance-Rumeli Test

Page 114: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 114/136

Proposed in 1980.

Is conceptually the most complex algorithm of them all.

Uses multiple groups, ideas derived from both themes, plus new ones!

It is a deterministic algorithm with time complexity logO (log log log n) n.Was speeded up by Cohen and Lenstra (1981).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 43 / 47

Adleman-Pomerance-Rumeli Test

Page 115: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 115/136

Proposed in 1980.

Is conceptually the most complex algorithm of them all.

Uses multiple groups, ideas derived from both themes, plus new ones!

It is a deterministic algorithm with time complexity logO (log log log n) n.Was speeded up by Cohen and Lenstra (1981).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 43 / 47

Adleman-Pomerance-Rumeli Test

Page 116: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 116/136

Proposed in 1980.

Is conceptually the most complex algorithm of them all.

Uses multiple groups, ideas derived from both themes, plus new ones!

It is a deterministic algorithm with time complexity logO

(log log logn

) n.Was speeded up by Cohen and Lenstra (1981).

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 43 / 47

Overview of the Algorithm

Page 117: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 117/136

Tries to compute a factor of n.

Let p be a factor of n, p ≤ √n.

Find two sets of primes q 1, q 2, . . . , q t and r 1, r 2, . . . , r u satisfying:

t i =1 q i = logO (log log log n) n. For each j ≤ u , r j − 1 is square-free and has only q i ’s as prime divisors.

u j =1 r j >

√n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 44 / 47

Overview of the Algorithm

Page 118: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 118/136

Tries to compute a factor of n.

Let p be a factor of n, p ≤ √n.

Find two sets of primes q 1, q 2, . . . , q t and r 1, r 2, . . . , r u satisfying:

t

i =1 q i = logO (log log log n) n. For each j ≤ u , r j − 1 is square-free and has only q i ’s as prime divisors.

u j =1 r j >

√n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 44 / 47

Overview of the Algorithm

Page 119: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 119/136

Tries to compute a factor of n.

Let p be a factor of n, p ≤ √n.

Find two sets of primes q 1, q 2, . . . , q t and r 1, r 2, . . . , r u satisfying:

t

i =1 q i = logO (log log log n) n. For each j ≤ u , r j − 1 is square-free and has only q i ’s as prime divisors.

u j =1 r j >

√n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 44 / 47

Overview of the Algorithm

Page 120: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 120/136

Tries to compute a factor of n.

Let p be a factor of n, p ≤ √n.

Find two sets of primes q 1, q 2, . . . , q t and r 1, r 2, . . . , r u satisfying:

t

i =1 q i = logO (log log log n) n. For each j ≤ u , r j − 1 is square-free and has only q i ’s as prime divisors.

u j =1 r j >

√n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 44 / 47

Overview of the Algorithm

Page 121: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 121/136

Tries to compute a factor of n.

Let p be a factor of n, p ≤ √n.

Find two sets of primes q 1, q 2, . . . , q t and r 1, r 2, . . . , r u satisfying:

t

i =1 q i = logO

(log log logn

) n. For each j ≤ u , r j − 1 is square-free and has only q i ’s as prime divisors.

u j =1 r j >

√n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 44 / 47

Overview of the Algorithm

Page 122: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 122/136

Tries to compute a factor of n.

Let p be a factor of n, p ≤ √n.

Find two sets of primes q 1, q 2, . . . , q t and r 1, r 2, . . . , r u satisfying:

t

i =1 q i = logO

(log log logn

) n. For each j ≤ u , r j − 1 is square-free and has only q i ’s as prime divisors.

u j =1 r j >

√n.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 44 / 47

Overview of the Algorithm

Page 123: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 123/136

Let g j be a generator for the group F r j .Let p = g

γ j j (mod r j ) and γ j = δi , j (mod q i ) for every q i | r j − 1.

Compute ‘associated’ primes r j i ∈ r 1, r 2, . . . , r u for each q i .

Cycle through all tuples (α1, α2, . . . , αt ) with 0 ≤ αi < q i .

From a given tuple (α1, α2, . . . , αt ), derive numbers β i , j for1 ≤ j ≤ u , 1 ≤ i ≤ t and q i | r j − 1 such that If p = g αi

j i (mod r j ) for every j then δi , j = β i , j for every j and for every

i with q i | r j − 1.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 45 / 47

Overview of the Algorithm

L j b f h F∗

j

Page 124: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 124/136

Let g j be a generator for the group F r j .Let p = g

γ j j (mod r j ) and γ j = δi , j (mod q i ) for every q i | r j − 1.

Compute ‘associated’ primes r j i ∈ r 1, r 2, . . . , r u for each q i .

Cycle through all tuples (α1, α2, . . . , αt ) with 0 ≤ αi < q i .

From a given tuple (α1, α2, . . . , αt ), derive numbers β i , j for1 ≤ j ≤ u , 1 ≤ i ≤ t and q i | r j − 1 such that If p = g αi

j i (mod r j ) for every j then δi , j = β i , j for every j and for every

i with q i | r j − 1.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 45 / 47

Overview of the Algorithm

L j b f h F∗

j

Page 125: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 125/136

Let g j be a generator for the group F r j .Let p = g

γ j j (mod r j ) and γ j = δi , j (mod q i ) for every q i | r j − 1.

Compute ‘associated’ primes r j i ∈ r 1, r 2, . . . , r u for each q i .

Cycle through all tuples (α1, α2, . . . , αt ) with 0 ≤ αi < q i .

From a given tuple (α1, α2, . . . , αt ), derive numbers β i , j for1 ≤ j ≤ u , 1 ≤ i ≤ t and q i | r j − 1 such that If p = g αi

j i (mod r j ) for every j then δi , j = β i , j for every j and for every

i with q i | r j − 1.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 45 / 47

Overview of the Algorithm

L j b f h F∗

j

Page 126: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 126/136

Let g j be a generator for the group F r j .Let p = g

γ j j (mod r j ) and γ j = δi , j (mod q i ) for every q i | r j − 1.

Compute ‘associated’ primes r j i ∈ r 1, r 2, . . . , r u for each q i .

Cycle through all tuples (α1, α2, . . . , αt ) with 0 ≤ αi < q i .

From a given tuple (α1, α2, . . . , αt ), derive numbers β i , j for1 ≤ j ≤ u , 1 ≤ i ≤ t and q i | r j − 1 such that If p = g αi

j i (mod r j ) for every j then δi , j = β i , j for every j and for every

i with q i | r j − 1.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 45 / 47

Overview of the Algorithm

L t j b t f th F∗

rj

Page 127: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 127/136

Let g j be a generator for the group F r j .Let p = g

γ j j (mod r j ) and γ j = δi , j (mod q i ) for every q i | r j − 1.

Compute ‘associated’ primes r j i ∈ r 1, r 2, . . . , r u for each q i .

Cycle through all tuples (α1, α2, . . . , αt ) with 0 ≤ αi < q i .

From a given tuple (α1, α2, . . . , αt ), derive numbers β i , j for1 ≤ j ≤ u , 1 ≤ i ≤ t and q i | r j − 1 such that If p = g αi

j i (mod r j ) for every j then δi , j = β i , j for every j and for every

i with q i | r j − 1.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 45 / 47

Overview of the Algorithm

F δi j ’ b t t d il

Page 128: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 128/136

From δi , j ’s, p can be constructed easily: Use Chinese remaindering to compute γ j ’s from δi , j ’s. Use Chinese remaindering to compute p (mod

u

j =1 r j ) from g γ j

j ’s. Since

u

j =1 r j >√

n ≥ p , the residue equals p .

β i , j ’s are computed using higher reciprocity laws in extension rings

Z n[ζ i ], ζ q i i = 1.

For most of the composite numbers, the algorithm will fail duringcomputation of β i , j ’s.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 46 / 47

Overview of the Algorithm

From δi j ’s p can be constr cted easil

Page 129: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 129/136

From δi , j s, p can be constructed easily: Use Chinese remaindering to compute γ j ’s from δi , j ’s. Use Chinese remaindering to compute p (mod

u

j =1 r j ) from g γ j

j ’s. Since

u

j =1 r j >√

n ≥ p , the residue equals p .

β i , j ’s are computed using higher reciprocity laws in extension rings

Z n[ζ i ], ζ q i i = 1.

For most of the composite numbers, the algorithm will fail duringcomputation of β i , j ’s.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 46 / 47

Overview of the Algorithm

From δi j ’s p can be constructed easily:

Page 130: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 130/136

From δi , j s, p can be constructed easily: Use Chinese remaindering to compute γ j ’s from δi , j ’s. Use Chinese remaindering to compute p (mod

u

j =1 r j ) from g γ j

j ’s. Since

u

j =1 r j >√

n ≥ p , the residue equals p .

β i , j ’s are computed using higher reciprocity laws in extension rings

Z n[ζ i ], ζ q i i = 1.

For most of the composite numbers, the algorithm will fail duringcomputation of β i , j ’s.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 46 / 47

Overview of the Algorithm

From δi j ’s p can be constructed easily:

Page 131: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 131/136

From δi , j s, p can be constructed easily: Use Chinese remaindering to compute γ j ’s from δi , j ’s. Use Chinese remaindering to compute p (mod

u

j =1 r j ) from g γ j

j ’s. Since

u

j =1 r j >√

n ≥ p , the residue equals p .

β i , j ’s are computed using higher reciprocity laws in extension rings

Z n[ζ i ], ζ q i i = 1.

For most of the composite numbers, the algorithm will fail duringcomputation of β i , j ’s.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 46 / 47

Overview of the Algorithm

From δi j ’s p can be constructed easily:

Page 132: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 132/136

From δi , j s, p can be constructed easily: Use Chinese remaindering to compute γ j ’s from δi , j ’s. Use Chinese remaindering to compute p (mod

u

j =1 r j ) from g γ j

j ’s. Since

u

j =1 r j >√

n ≥ p , the residue equals p .

β i , j ’s are computed using higher reciprocity laws in extension rings

Z n[ζ i ], ζ q i i = 1.

For most of the composite numbers, the algorithm will fail duringcomputation of β i , j ’s.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 46 / 47

Overview of the Algorithm

From δi ,j ’s p can be constructed easily:

Page 133: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 133/136

From δi , j s, p can be constructed easily: Use Chinese remaindering to compute γ j ’s from δi , j ’s. Use Chinese remaindering to compute p (mod

u

j =1 r j ) from g γ j

j ’s. Since

u

j =1 r j >√

n ≥ p , the residue equals p .

β i , j ’s are computed using higher reciprocity laws in extension rings

Z n[ζ i ], ζ q i i = 1.For most of the composite numbers, the algorithm will fail duringcomputation of β i , j ’s.

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 46 / 47

Page 134: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 134/136

Outstanding Questions

Page 135: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 135/136

Is there a ‘practical’, polynomial time deterministic primality test?

Is there a ‘practical’, provably polynomial time, primality proving test?

Are there radically different ways of testing primality efficiently?

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 47 / 47

Outstanding Questions

Page 136: Is n a prime number

8/8/2019 Is n a prime number

http://slidepdf.com/reader/full/is-n-a-prime-number 136/136

Is there a ‘practical’, polynomial time deterministic primality test?

Is there a ‘practical’, provably polynomial time, primality proving test?

Are there radically different ways of testing primality efficiently?

Manindra Agrawal (IIT Kanpur) Is n a Prime Number? March 27, 2006, Delft 47 / 47