Docsity

Lecture Slides on Primality Testing - Cryptography and Data Security | COMP 7120, Study notes of Computer Science

Partial preview of the text

Download Lecture Slides on Primality Testing - Cryptography and Data Security | COMP 7120 and more Study notes Computer Science in PDF only on Docsity!

Primality testing^ „^ Let

π(N) be number of prime numbers that are less than or equal to N. „ Prime number theorem:

π(N)

≈^

N/ln(N)

„^ If n

≥^ 17, N/ln(N) <

π(N) < 1.26 N/ln(N)

„^ e. g. N = p or q in n=p q.

p^

≈^ q

≈^2

„^ Pr(N is a prime| odd N

≈^2

512 )

≈^ 1/ln(

512 ) =

1/355. „^ Easier to prove “N” is composite than toprove “N” is a prime. (why ?)

Definition 5.1^ „^ yes-biased Monte Carlo algorithm: arandomized algorithm in which “yes” isalways correct, “no” may be incorrect.

„^ “yes” or “no” is a decision by an algorithmfor a problem (e.g. Is N composite ?) „^ pr(incorrect answer| “yes”) = 0.

„^ If pr(incorrect answer| “no”)

, then

the algorithm has error probability of

Primality test for a largeinteger^ „^ probabilistic test:

„^ can be highly efficient „^ tiny probability of making an error

„^ deterministic test:

„^ no general polynomial-time algorithmavailable until Agrawal, Kayal, and Saxena(2002) [AKS algorithm] „^ AKS algorithm is still not yet practical for alarge prime number.

Probabilistic composite tests^ „^ Solovay-Strassen Algorithm (Algorithm 5.6,page 182) is a yes-biased algorithm witherror probability at most 1/2.^ „^ Miller-Rabin Algorithm (Algorithm 5.7, page188) is a yes-biased algorithm with errorprobability at most 1/4.^ „^ We can perform several independent randomtests to drastically reduce the errorprobability.

Miller-Rabin Algorithm^ „^ n-1 = 2

k^ m, m is odd. „^ Choose “a” randomlybetween 1 to n-1. „^ b

Å^ a

m^ mod n. „^ if b = 1, then return(“prime”) „^ for i=0 to k-1 do

„^ if b=-1, then return(“prime”) „^ else b

Å^ b

2 mod n.

„^ return (“composite”)

„^ Recall that for aprime n,

„^ a n-1^ =1 mod n. „^ If a

n-1=1 mod n, then n can be apossible prime. „ If many such “a” arefound, it is verylikely n is a prime.

Factoring Algorithms^ „^ Factorization is much harder thanprimality testing.

„^ no known polynomial time algorithm.

„^ Trial division: try all primes p

≤^

0.5n

„^ simple but not very efficient for a large n. „^ suitable when n has many small primefactors. „^ not effective for RSA (why not ?).

Pollard rho Algorithm (n,x

„^ Choose a initial sees x

and f(x)=x 1

„^ x

Å

x^1

, x’

Å

f(x) mod n,

„^ p

Å

gcd(x-x’, n).

„^ while (p=1) do

„^ x

Å

f(x) mod n, „^ x’

Å

f(x’) mod n, x’

Å

f(x’) mod n

„^ p

Å

gcd(x-x’, n)

„^ if(p<n) return (p) else return (“fail”)

Factoring Algorithm in Practice

O(exp[(1.92+o(1)) (ln1/3n)

[ln ln(n)]

2/3])

number field sieve

O(exp[(1+o(1)) [ln p lnln(p)]

0.5])

elliptic curve (p issmallest prime | n)

O(exp[(1+o(1)) [(ln n)ln ln(n)]

0.5])

quadratic sieve

Asymptotic RunningTime

Factoring Algorithms

Other Attacks on RSA^ „^ computing

φ(n)

„^ find decryption exponent (d) of RSA „^ Wiener’s low decryption exponentattack.

Computing

(n)

„^ If both n and

φ(n) are known, then we

can find the factorization of n. why? „ n=pq,

φ(n) =(p-1)(q-1).

„^ Plug q=n/p in the equation for

φ(n),

„^ p

2 – (n-

φ(n)+1) p + n = 0.

„^ we can then easily solve the quadraticequation of p.

Find decryption exponent^ „^ If the information about d (decryptionexponent) is known, the n can befactored.

„^ implication: we cannot not simply changeother d’s with n unchanged. „^ Algorithm 5. 10: randomized algorithm thatcan factor n in a polynomial time (page204)

Wiener’s low decryptionexponent attack^ „^ If d (decryption exponent) is too small,the n can be factored.

„^ Algorithm 5. 11: based on extendedEuclidean algorithm and continued fractiontechnique (page 204) „^ implication: we cannot not use too smalld’s as decryption exponent.

„^ we choose simpler “e” as a public key thensolve for “d” which is usually not too small.

Algorithm 5.2 (Rabin)^ „^ Let n=p q, p=3 mod 4, q=3 mod 4.^ „^ P=C=Z

*. K={(n,p,q)}. n is public key.n

„^ Encryption:

„^ e

(x) = xK

2 mod n

„^ Decryption:

„^ d

(y) = yK

1/^

mod n (how ?)

Find y

mod n?

„^ Require n=pq, p=3 mod 4 and q=3 mod n. „^ Recall y

(p-1)

= 1 mod p (and y

(q-1)

= 1 mod q)

„^ Since y=x

2 mod p, we have y

(p-1)/

= 1 mod p.

„^ We can show that x= ±y

(p+1)/

mod p satisfies

(^2) x= y mod p. „ Likewise, x= ±y

(q+1)/

mod q satisfies x

2 = y

mod q. „ We can find four solutions using ChineseRemainder Theorem.