Public Key Cryptography Flashcards
Primality Testing, why?
RSA needs big primes
Simple Prime Number Generation
Create random number and check
Efficient Prime Checker
Miller Rabin (Method of Choice) Just as fast as fermat, less error.
______________
Fermat Test
quick O(||n||) operations per run
run t times with different a
correct answer if n prime
may give false answer for composite number
Fermat Test Lemma
if p is prime and gcd(a,p)=1 then aˆ(p-1)=1 (mod p)
Fermat Test
- pick random a< n
- check gcd(a,n)=1
- check wether n satisfies Fermat test lemma.
Carmichael Number
is a composite number that passes the Fermat test for every base a. (561 is the smallest Carmichael number)
Composite Number
A composite number is a positive integer that can be formed by multiplying two smaller positive integers. Equivalently, it is a positive integer that has at least one divisor other than 1 and itself. Every positive integer is composite, prime, or the unit 1, so the composite numbers are exactly the numbers that are not prime and not a unit.
How many Carmichael Numbers exist
infinite (Lemma Alford, Granville, Pomerance, 1994)
Miller-Rabin Test versus Fermat
Miller -rabin : Primality test without the problem of Carmichael numbers (that occur in Fermats test)
Miller-Rabin Test
Idea:
if n prime, then xˆ2=1 mod n only has x = +1
in Fermat aˆ(n-1) is an even power
taking roots we should arrive at -1
for odd powers, we cannot compute root (Find root equivalent to factoring), so we must stop
Miller-Rabin Test Properties
if n not prime <= p(n)/4 choices of a failed
run test t times, takes O(t * ||n||) arithmetic operations
—-> error chance <= (1/4)ˆt
Prime and Prejudice
- usually testing few small numbers suffices
- many implementation fix(ed?) t or bases a_i
- but error chance needs randomness
- in crypto always consider adversarial input
Failure chance against adversary implementations
OpenSSl 1.1.1pre6 fix t=2 for log n >=1300, failure chance 1/16
GNU GMP bases a_i depend deterministically on n, 100% failure for t<=15
LibTomMath t<= 256 use first t primes as bases 100 % failure
AKS Primality Test
“Primes in P” -2002 paper- first provable polynomial-time algorithm
Idea Let a,n in Natural numbers.
We have (x+a)ˆn= xˆn + a in Z[x] if n is prime
reduce this modulo smaller polynomial
takes time O(||n||ˆ(6+e)). —> too long
Sieve of Erathosthenes
- Not a primality test
- Good method to generate all primes p<=n
Function E(n):
create array a_i= 1 for i<=n i=2 while iˆ2 <=n do if a_i = 1 then for j =2 , ...., round_down(n/i) do a_(i*j) =0 return {p: a_p=1}
_________________
running time O(n log log n) space O(n)
Primality Tests- Overview
Fermat : easy, fast, can have errors, fails for some numbers
Miller -Rabin: Method of choice
as fast as fermat
also one sided error
repeated independent calls reduce error to a direction of 0
in most libraries, but many implementations were (are?) vulnerable to malicious input (prime and prejudice)
AKS: no error, slow
Erathosthenes: no test, but a method to generate all primes.
only recommended for n