9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.1
CSE565: Computer SecurityLecture 7Number Theory Concepts
CSE565: Computer SecurityLecture 7Number Theory Concepts
 
Shambhu Upadhyaya
Computer Science &Eng.
University at Buffalo
Buffalo, New York14260
Ceisare-UB-1
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.2
Acknowledgments
Acknowledgments
Material is drawn from Lawrie Brown’s slides
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.3
Prime Numbers
Prime Numbers
Prime numbers only have divisors of 1 and self
they cannot be written as a product of othernumbers
note: 1 is prime, but is generally not of interest
E.g., 2,3,5,7 are prime, 4,6,8,9,10 are not
Prime numbers are central to number theory
List of prime number less than 200 is:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 6167 71 73 79 83 89 97 101 103 107 109 113 127 131137 139 149 151 157 163 167 173 179 181 191 193197 199
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.4
Prime Factorization
Prime Factorization
To factor a number n is to write it as aproduct of other numbers: n=a × b × c
Note that factoring a number is relativelyhard compared to multiplying the factorstogether to generate the number
The prime factorization of a number n iswhen it is written as a product of primes
E.g., 91=7×13 ; 3600=24×32×52
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.5
Primality Testing
Primality Testing
Often need to find large prime numbers
Traditional sieve using trial division
i.e., divide by all numbers (primes) in turn lessthan the square root of the number
only works for small numbers
Alternatively can use statistical primality testsbased on properties of primes
for which all primes numbers satisfy property
but some composite numbers, called pseudo-primes, also satisfy the property
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.6
Miller RabinAlgorithm
Miller RabinAlgorithm
A test based on Fermat’s Theorem
Algorithm is:
TEST (n) is:
1. Find integers kq> 0, odd, so that (n–1)=2kq
2. Select a random integer a, 1<a<n–1
3. if aq mod = 1 then return (“maybe prime");
4. for = 0 to – 1 do
5. if (a2jq mod n-1)
  then return (" maybe prime ")
6. return ("composite")
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.7
ProbabilisticConsiderations
ProbabilisticConsiderations
If Miller-Rabin returns “composite” thenumber is definitely not prime
Otherwise it is a prime or a pseudo-prime
Chance it detects a pseudo-prime is < ¼
Hence if repeat test with different randomthen chance of n being prime after t testsis:
Pr(n prime after t tests) = 1-4-t
E.g., for t=10 this probability is >0.99999
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.8
Deterministic PrimalityAlgorithm
Deterministic PrimalityAlgorithm
Prior to 2002, there was no known methodof proving primality of large numbers
Most algorithms produced a probabilisticresult
In 2002, Agrawal, Kayal and Saxenadeveloped a simple deterministic algorithm
Deterministic, but not very efficient
Complexity is polynomial in n
Miller-Rabin is still more popular
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.9
Prime Distribution
Prime Distribution
Prime number theorem states that primesoccur roughly every (ln n) integers
Since we can immediately ignore evensand multiples of 5, in practice only needtest 0.4 ln(n) numbers of size n before welocate a prime
note this is only the “average”sometimes primes are close together, atother times are quite far apart
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.10
Chinese RemainderTheorem
Chinese RemainderTheorem
Used to speed up modulo computations
Working modulo a product of numbers
E.g., mod M = m1m2..mk
Chinese Remainder theorem lets us work ineach moduli mseparately
Since computational cost is proportional tosize, this is faster than working in the fullmodulus M
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.11
Chinese RemainderTheorem
Chinese RemainderTheorem
Can implement CRT in several ways
To compute (A mod M) we can firstlycompute all (ai mod mi) separately andthen combine results to get answer using:
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.12
Primitive Roots
Primitive Roots
From Euler’s theorem we have aø(n)mod n=1
Consider ammod n=1, GCD(a,n)=1
must exist for m= ø(n) but may besmaller
once powers reach m, cycle will repeat
If smallest is m= ø(n) then a is called aprimitive root
If p is prime, then successive powers of a"generate" the group mod p
These are useful but relatively hard to find
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.13
Discrete Logarithmsor Indices
Discrete Logarithmsor Indices
The inverse problem to exponentiation is to find thediscrete logarithm of a number modulo p
That is to find x where ax = b mod p
Written as x=loga b mod p or x=inda,p(b)
If a is a primitive root then always exists, otherwisemay not
x = log3 4 mod 13 (x st 3x = 4 mod 13) has noanswer
x = log2 3 mod 13 = 4 by trying successivepowers
Whilst exponentiation is relatively easy, findingdiscrete logarithms is generally a hard problem
ub-re-logo
Ceisare-UB-1
9/22/15
UB Fall 2015
CSE565: S. Upadhyaya
Lec 7.14
Summary
Summary
Have considered:
Prime numbers
Primality Testing
Chinese Remainder Theorem
Discrete Logarithms