Top Banner
. Presented By Prabhat Vyas The Complexity of Primality Testing
13

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.

Jan 12, 2016

Download

Documents

Oliver Carson
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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.

.Presented ByPrabhat Vyas

The Complexity of Primality Testing

Page 2: 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.

..

What is Primality Testing?

• Testing whether an integer is prime or not. – An integer p is prime if the only integers that divide p evenly are 1 and p itself.

– If an integer is not prime, it is composite. Every composite number can be written in an unique way as a product of primes.

– Example: 504 = 23 x 32 x 7 prime factorization. 2 128 = 340282366920938463463374607431768211456

Page 3: 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.

Why is Primality Testing Important?

Primality Testing these days is used in computer security algorithms.

Most notable of these is the RSA Algorithm which relies on the apparent difficulty of factoring a large integer.– RSA Codes (Rivest-Shamir-Adelamn) use 128 bit integers that are product of two primes on 64 bits each.

• Public-key cryptography – Uses a 128-bit key k and the message data x is encrypted with a function f k (x) = y.

Page 4: 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.

Properties of Modular Arithmetic

1. [(a mod n) + (b mod n)] mod n = (a + b) mod n

2. [(a mod n) - (b mod n)] mod n = (a - b) mod n

3. [(a mod n) x (b mod n)] mod n = (a x b) mod n

Modular Arithmetic

• Let p be any integer. The integers modulo p are 0,1,…,p-1. • We define +, -, and * on integers modulo p by performing the ordinary operation and keep the remainder of the result divided by p

Page 5: 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.

• The degree of number a modulo p is the smallest positive power that is equal to 1

• If p is a prime, then ap-1 = 1 modulo p. This statement is called Fermat’s theorem.

• The degree of a modulo p (prime) is always a divisor of p-1.

• If p is a prime, there is always some a that has degree p-1 modulo p.

Degree of a Number

Page 6: 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.

Random-Polynomial Primality Testing

• Monte-Carlo algorithm • Theorem: The language of composite

numbers is in RP • The facts:• if p is prime, then xp-1 mod p =1, this is the

Fermat's theorem. • if p is composite, and there is an x at all for

which xp-1 mod p is not 1, then for at least half the values of x in the range 1 to p-1, we shall find xp-1 ≠ 1.

Page 7: 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.

Monte - Carlo algorithm for the composite numbers:

1. Pick an x at random in the range 1 to p - 1.

2. Compute xp-1 modulo p. Note that if p is an n-bit number, then this calculation takes O(n3) time

3. If xp-1 ≠ 1 modulo p, accept; x is composite. Otherwise, halt without accepting.

* If p is prime, then xp-1 = 1 modulo p, so

we always halt without accepting;

Random-Polynomial Primality Testing

Page 8: 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.

Recall for class RP: • A language is accepted in random polynomial time if there is a polynomial-time, randomized Turing machine that has at lease 50% chance of accepting the inputs that is in the language. • If the input is not in the language, then this TM never accepts.

Carmichael numbers:xc-1 = 1 mod c, for the majority of x: 1<=x<=c-1The smallest Carmichael number is 561, Let c= 561 = 3 x 11 x 17 x560

= 1mod561Let x=22560=377396242482154135224155458098826889091692122041644042837 620630024562416239214885208612672517765876754146837503076384489 97705846299247926325614342514326960436

Page 9: 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.

Factor in Random Polynomial Time

 Can We Factor in Random Polynomial Time?• The previous algorithm may tell us that a number is composite,

but does not tell us how to factor the composite number. • It is believed that there is no way to factor numbers, even

using randomness, that takes only polynomial time, or even expected polynomial time.

• If that assumption were incorrect, then the applications that we discussed would be insecure and could not be used.

Page 10: 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.

Nondeterministic Primality Tests

• The language of primes is in NP ∩ co-NP. • The language of composite numbers is also in NP ∩ co-NP. • They are unlikely to be NP-complete. If either are true, then we will have NP=co-NP, and since primes is in RP and if primes is in NP-complete, RP=NP.

Theorem: The set of composite numbers is in NP.PROOF;The nondeterministic, polynomial-time algorithm for the composite numbers is:Step one:

Take p as an n-bit number p, Guess a factor f of at most n-bits.f ≠ 1 and f ≠ p.The time taken by any sequence of choices is O(n).

Step Two:Divide p by f, Check that the remainder is 0.Accept if so. The time taken is O(n2) on a multi tape TM.

Page 11: 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.

Prime is in NP

It’s more difficult to recognize primes • If p is a prime, then there is a number x between 1 and p-1 that has degree p- 1. For example, for prime p = 7, 3 and 5 both have degree of 6. – To check x has degree p-1, have to check x2 ,x3 …….xp-2 are 1. Which requires p-3 multiplications, and require at least time 2n . – A better strategy is: the degree of x modulo a prime p is a divisor of p-1. If we knew prime factors of p-1, we can check xp-1)/q /= 1 mod p . If none of these powers of x is equal to 1, then the degree of x must be p-1. The number of tests is O(n). – To factor p-1 into primes, we non deterministically guess the prime factors of p-1

• Check that their product is indeed p-1 • Check that each is a prime, using the nondeterministic, polynomial-

time algorithm that we designed, recursively. – The running time is O(n5)

Page 12: 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.

Summary of Primality Testing

• The language of prime and composite numbers are in RP and NP, therefore both are in NP ∩ co-NP.

• If they either were NP-complete, then we can prove NP=co-NP,

• If prime testing is NP-complete, if we find a polynomial time algorithm for prime testing, we can prove P=NP.

• It’s possible that primes are in P if Riemann hypothesis is true.

• The problem of sieving prime numbers is different than testing primality, and currently can be done in n/ n loglog n.

Page 13: 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.

THANK YOU