CS549: Cryptography and Network Security

Size: px
Start display at page:

Download "CS549: Cryptography and Network Security"

Transcription

1 CS549: Cryptography and Network Security by Xiang-Yang Li Department of Computer Science, IIT Cryptography and Network Security 1

2 Notice This lecture note (Cryptography and Network Security) is prepared by Xiang-Yang Li. This lecture note has benefited from numerous textbooks and online materials. Especially the Cryptography and Network Security 2 nd edition by William Stallings and the Cryptography: Theory and Practice by Douglas Stinson. You may not modify, publish, or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted by the author. The author has used his best efforts in preparing this lecture note. The author makes no warranty of any kind, expressed or implied, with regard to the programs, protocols contained in this lecture note. The author shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these. Cryptography and Network Security 2

3 Cryptography and Network Security Elementary Number Theory Xiang-Yang Li Cryptography and Network Security 3

4 Number theory Elementary number theory Main topic of this course divisibility, the Euclidean algorithm to compute greatest common divisors, factorization Fermat's little theorem and Euler's theorem, the Chinese remainder theorem and Euler's φ function are investigated; Analytic number theory Algebraic number theory Geometric number theory Computational number theory Cryptography and Network Security 4

5 Introduction to Number Theory Divisors b a if a=mb for an integer m b a and c b then c a b g and b h then b (mg+nh) for any integers m,n Prime number An integer p is a prime number if it has only positive divisors 1 and p Relatively prime numbers p and q No common positive divisors for p and q except 1 Cryptography and Network Security 5

6 Prime numbers Upto Largest known so far (till 2008, Jan 22) with digits method G10 found at 2008 Mersenne 47?? with digits (found 2006 using proof code G9) When 2 n -1is prime it is said to be a Mersenne prime (a French monk , conjecture 1644). Clearly n must be odd. How many prime numbers are there? Infinity ---- Euclid gave simple proof Proof by contradiction They were also irregularly placed (arbitrary gap) How many in the range [0,n] -- Theta( n / log n) Approximately, the nth prime n log n How many primes with d bits approximately? ~ Theta(2 d /d) Cryptography and Network Security 6

7 Determining Primes? How to determine if a given number n is prime? Deterministic Brute force testing Testing whether a number a n, for a in certain range Random testing A prime number should satisfy some properties If a number x does NOT have any of such properties, then this x is NOT a prime Otherwise, it may be a prime number Properties: for any number a>1, a does not divide x, More properties will be studied and used to design efficient methods Cryptography and Network Security 7

8 Greatest Common Divisor (GCD) Greatest common divisor gcd(a,b) The largest number that divides both a and b Euclid's algorithm Find the GCD of two numbers a and b, a<b Use fact if a and b have divisor d so does a-b, a-2b dma da da da da + b 2b 3b qb nb Cryptography and Network Security 8

9 GCD by factoring Integer n can be factored as n=p 1 a 1 p 2 a 2 p 3 a 3. p n a n where p i is prime number Based on this, we can find the GCD of two numbers A=p a 1 1 p a 2 2 p a 3 3. p a n n where p i is prime number B=p b 1 1 p b 2 2 p b 3 3. p b n n where p i is prime number Then GCD(A,B) is p 1 c 1 p 2 c 2 p 3 c 3. P n c n where c i = min(a i, b i ) For example, gcd(2*3, 3*7)=3; gcd(2*3,0)=6 Cryptography and Network Security 9

10 Cont. GCD (a,b) is given by: let g 0 =b g 1 =a g i+1 = g i-1 mod g i when g i =0 then gcd(a,b) = g i-1 The algorithm terminates in O(log b) rounds Why? Every round, the total number of bits of a and b is decreased by at least one What is a more precise complexity bound? Cryptography and Network Security 10

11 Properties For any two integers a and b Exist integers m and n: gcd(a,b) =ma+bn Example: a=2, b=3; we choose m=-1, n=1 so 2+3=1 a=6, b=11; we choose m=2, n=-1 so 2*6-11=1 Simple proof? Cryptography and Network Security 11

12 Extended Euclidean Algorithm input are two integers a and b, computes their greatest common divisor (gcd) as well as integers x and y such that ax + by =gcd(a, b). It later can also be used to compute the inverse of an integer a 1 mod n Cryptography and Network Security 12

13 Proof Assume we compute gcd(x 0,y 0 ), x 0 >y 0 Let X i =(x i,y i ); 0 x i -q i+1 y i+1 < y i Then X i =M i X i-1, where M i =(0,1; 1,-q i ) Assume the gcd algorithm terminates in n steps We have M n M n-1 M 1 X 0 =(gcd(x 0,y 0 ), 0) T Assume M n M n-1 M 1 =( ) Then ax 0 +by 0 =gcd(x 0,y 0 ) a c The above algorithm is to keep track of a,b,c,d, and x i,y i values. b d Cryptography and Network Security 13

14 Modular Arithmetic Congruence a b mod n says when divided by n that a and b have the same remainder It defines a relationship between all integers a a a b then b a (symmetric) a b, b c then a c (transitive) Cryptography and Network Security 14

15 Cont. addition (a+b) mod n (a mod n) + (b mod n) subtraction a-b mod n a+(-b) mod n multiplication a b mod n derived from repeated addition Possible: a*b 0 where neither a, b 0 mod n Example: 2*3 =0 mod 6 Cryptography and Network Security 15

16 Example Based on mod 7, we define the set of remainders {0, 1, 2, 3, 4, 5, 6} It also defines a relationship: 2=9 mod 7 2+8=3 mod 7 2-8=1 mod 7 Cryptography and Network Security 16

17 Group Theory For mod 7, we can define a group using all numbers {0,1,2,3,4,5,6} and operation + A group contains a set of elements and an operation #, such that Closure: a#b is an element in the group for any a and b Associativity. For all a, b and c in G, the equation (a #b)# c = a # (b# c) holds. Identity element : it has an special element 0: a#0=a for any element a Inverse element: For any element, there is an inverser. (-a) is called the negative a, such that (-a)#a= a#(-a)=0 Cryptography and Network Security 17

18 Addition and Multiplication Integers modulo n with addition and multiplication form a commutative ring with the laws of Associativity (a+b)+c a+(b+c) mod n Commutativity a+b b+a mod n Distributivity (a+b)*c (a*c)+(b*c) mod n Cryptography and Network Security 18

19 Ring (math) A ring is a set R equipped with two binary operations +: R R R and : R R R (where denotes the Cartesian product), called addition and multiplication To qualify as a ring, the set and two operations, (R, +, ), must satisfy the following requirements known as the ring axioms. [2] (R, +, ) is required to be an Abelian group under addition: Closure under addition. For all a, b in R, the result of the operation a + b is also in R. c[ ] 2. Associativity of addition. For all a, b and c in R, the equation (a + b) + c = a + (b + c) holds. 3. Existence of additive identity. There exists an element 0 in R, such that for all elements a in R, the equation 0 + a = a + 0 = a holds. 4. Existence of additive inverse. For each a in R, there exists an element b in R such that a + b = b + a = 0 5. Commutativity of addition. For all a, b in R, the equation a + b = b + a holds. (R, +, ) is required to be a monoid under multiplication: Closure under multiplication. For all a, b in R, the result of the operation a b is also in R. c[ ] 2. Associativity of multiplication. For all a, b, and c in R, the equation (a b) c = a (b c) holds. 3. Existence of multiplicative identity. There exists an element 1 in R, such that for all elements a in R, the equation 1 a = a 1 = a holds. The distributive laws: 1. For all a, b and c in R, the equation a (b + c) = (a b) + (a c) holds. 2. For all a, b and c in R, the equation (a + b) c = (a c) + (b c) holds. Cryptography and Network Security 19

20 4 th arithmetic operation: Division Division b/a mod n multiplied by inverse of a: b/a = b*a -1 mod n a -1* a 1 mod n mod 10 because 3*7 1 mod 10 What is the value of 20/3 mod 7? Value of 1/3 mod 6? Inverse does not always exist! Only when gcd(a,n)=1 Cryptography and Network Security 20

21 Euclid's Extended GCD Routine Theorem: If gcd(a,n)=1 then the inverse of a mod n always exists Can extend Euclid's algorithm to find inverse by keeping track of g i = u i.n + v i.a Extended Euclid's (or binary GCD) algorithm to find inverse of a number a mod n (where (a,n)=1) is: Cryptography and Network Security 21

22 Inverse Inverse(a,n) is given by: X=(x1,x2,x3)=(1,0,n); Y=(y1,y2,y3)=(0,1,a) If y3=0 return x3=gcd(a,n); no inverse If y3=1 return y3=gcd(a,n); y2=a -1 mod n Q=[x3/y3] T=X-Q*Y X=Y; Y=T Goto 2 nd step Cryptography and Network Security 22

23 When inverse exists If gcd(a,n)=1 inverse exists We can find x, y such that ax+ny=1 Then x= a -1 mod n If inverse exists gcd(a,n)=1 Let x be the inverse of a, i.e., ax=1 mod n Then x a=1+q n for some integer q Let gcd(a,n)=d. Then d (x a-q n ) Obviously d=1 since x a-q n =1 Cryptography and Network Security 23

24 Galois Field If n is constrained to be a prime number p then this (+, *, under mod p) forms a Galois field modulo p denoted GF(p) and all the normal laws associated with integer arithmetic work Field has some additional properties (in addition to be a ring) There is a special element 1, such that a*1=a There is another special element 0 such that a+0=a for any a For all element a, there is another number b such that a*b=1 For all element a, there is another element c such that a+c =0 Cryptography and Network Security 24

25 Common arithmetic operations Exponentiation Given a, e, and p, find b = a e mod p How to compute this efficiently? Discrete Logarithms Given a, b, and p, find x where a x = b mod p Value of x is denoted as (log a b mod p) How to compute this efficiently? Cryptography and Network Security 25

26 Efficient computing of exponential Compute a b mod n efficiently when b, n large? Example: compute a 1024 mod Simple approach: repetitively time a 1024 times? Efficient computation: Write number b in binary format as x k x k-1 x k-2.x 2 x 1 x 0 Let t 1 =a mod n. Then compute t i+1 = t i * t i mod n for i<k Then b [ xkxk 1xk 2... x2x1x0] a mod n = a mod n = = 0 i k 0 i k ( 2 ) xi [ a ] mod t x i i i mod n n Time complexity? Cryptography and Network Security 26

27 Efficient Computing of Discrete Log For real numbers, how to compute log a b? Example, log 3 27=3 How to compute log 3 27 mod 5? Find x such that 3 x = 27 mod 5 Thus, find x such that 3 x = 2 mod 5 Try numbers x=1, 2, 3, find x=3, 7,11,. Can we write a program to compute this quickly? Cryptography and Network Security 27

28 Relative primes Two numbers a and n are relative primes if gcd(a,n)=1 Consider all integers 0<a <n How many are relative prime to n? Equivalently, how many a such that a -1 mod n exists Typically Z n ={0,1,2,.,n-1} : all integers 0<= a < n Z n* ={a 0<= a < n, gcd(a,n)=1} All integers in Z n that are co-prime with n Also called reduced residue set mod n Cryptography and Network Security 28

29 Group formed by relative numbers Z n ={0,1,2,.,n-1} : all integers 0<= a < n (Z n,+) forms a group Need to show a special element 0, and inverse of an element a Z n* ={a 0<= a < n, gcd(a,n)=1} (Z n*,*) Need to show a special element 0, and inverse of an element a Cryptography and Network Security 29

30 Euler Totient Function If consider arithmetic modulo n, then a reduced set of residues is a subset of the complete set of residues modulo n which are relatively prime to n eg for n=10, the complete set of residues is {0,1,2,3,4,5,6,7,8,9} the reduced set of residues is {1,3,7,9} The number of elements in the reduced set of residues is called the Euler Totient function φ(n) Cryptography and Network Security 30

31 cont Compute φ(n) If factoring of n is known φ(n)=n Π(1-1/p i ) where p i is its prime factor Otherwise It is expensive! But not proved yet computing φ(n) when knowing fact n =pq but not the number p and q Conjectured to be a hard question But not proved yet. Equivalent to find p and q Cryptography and Network Security 31

32 cont Equivalency: given the fact that n is the production of two prime numbers p and q (but not knowing the values of p and q) finding p,q computing φ(n) Proof If we found p and q, then φ(n)=(p-1)(q-1) if we found φ(n), then solve p, q from equations n = p q ϕ( n) = ( p 1 )( q 1 ) Cryptography and Network Security 32

33 Euler's Theorem Theorem: Let gcd(a,n)=1 then a φ(n) mod n = 1 Proof: consider all reduced residues x i in Z n* ={x 0<= x < n, gcd(x,n)=1} Then ax i,1<=i <= φ(n) also form reduced residues set Using Π ax i = Π x i mod n Using Z n* and az * n are same sets! We have a φ(n) Π x i = Π x i mod n Thus, a φ(n) =1 mod n Using the fact that Π x i has inverse Cryptography and Network Security 33

34 Fermat's Little Theorem Theorem: Let p be a prime and gcd(a,p)=1 then a p-1 mod p = 1 Proof: similar to the proof of Euler s theorem But consider all integers in Z p Generally, for any prime number p a p mod p = a (true for any number a) Generally, for any number n=pq a φ(n)+1 mod n = a (true for any number a) Need to prove for the case gcd(a,n)>1 Do it yourself Cryptography and Network Security 34

35 Chinese Remainder Theorem (CRT) Computer science department organize students for graduation party 25 students a bus, all buses (except one with 20 students) are full 12 students a table for dinner, all tables are full, except one table only has 4 students We know that there are less 300 students How many students graduated? Cryptography and Network Security 35

36 Chinese Remainder Theorem (CRT) By Qin Jiushao Let m 1,m 2,.m k be pair-wise relative prime numbers Assume integer x= a i mod m i for 1<= I <= k Then x= Σ a i e i mod M Where M=Π m i ; M i =M/ m i e i = M i * (M i -1 mod m i ) Proof For each i, the integers m i and M/m i are coprime, and using the extended Euclidean algorithm we can find integers r and s such that r m i + s M/m i = 1. If we set e i = sm/m i, then we have e i =1 mod m i and e i =1 mod m j for j<>i. Cryptography and Network Security 36

37 General CRT Sometimes, the simultaneous congruences can be solved even if the m i 's are not pairwise coprime. a solution x exists if and only if a i a j (mod gcd(n i, n j )) for all i and j. All solutions x are congruent modulo the least common multiple of the n i. Methods: successive substitution Cryptography and Network Security 37

38 Example consider the simultaneous congruences x 3 (mod 4) x 5 (mod 6) Can be transformed to x 3 (mod 4) x 5 (mod 2) x 1 (mod 2) x 5 (mod 3) Then transformed to x 3 (mod 4) x 2 (mod 3) Using CRT X=11 (mod 12) Cryptography and Network Security 38

39 Testing Primality Cryptography and Network Security 39

40 Largest Primes Great Internet Mersenne Prime Search GIMPS (GIMP) ( digits ~ about 12.9 million digits, Aug 08) and ( ~only 11.1 million digits, Sept 08). Cryptography and Network Security 40

41 Primality Testing To check if exists integer a such that a n Primary school method Test a=2,3,4,5,6,.,n-1 Test a=2,3,4,5,, n 0.5 Test a=2,3,5,7,11,., p, where prime number p<=n 0.5 Two slow! Check almost n numbers Check n 0.5 numbers At least around (n/ln n) 0.5 numbers need be checked Example Number n~2 1024, then (n/ln n) 0.5 ~( /1024) 0.5 ~ Assume 2 30 numbers per second, takes about *16 = 2 27 days Any improvement? Cryptography and Network Security 41

42 Classification of Testing Primes The Quick Tests for Small Numbers and Probable Primes Finding Very Small Primes --- trivial division Fermat, Probable-Primality and Pseudoprimes Strong Probable-Primality and a Practical Test The Classical Tests N-1 Tests (and Pepin's Test for Fermats) N+1 Tests (and the Lucas-Lehmer Test for Mersennes) A Combined Test -- and more The General Purpose Tests Neoclassical Tests, especially APR and APR-CL Using Elliptic Curves, especially the ECPP Test A Polynomial Time Algorithm Cryptography and Network Security 42

43 Fermat Little Theorem Based Fermat's theorem gives us a powerful test for compositeness: Given n > 1, choose a > 1 and calculate a n-1 modulo n (there is a very easy way to do quickly by repeated squaring) If the result is not one modulo n, then n is composite. If it is one modulo n, then n might be prime so n is called a weak probable prime base a (or just an a- PRP). Some early articles call all numbers satisfying this test pseudoprimes, but now the term pseudoprime is properly reserved for composite probable-primes. Cryptography and Network Security 43

44 Carmichael number There may be relatively few pseudoprimes, but there are still infinitely many of them for every base a>1, so we need a tougher test. One way to make this test more accurate is to use multiple bases (check base 2, then 3, then 5,...). But still we run into an interesting obstacle called the Carmichael numbers. The composite integer n is a Carmichael number if a n-1 =1 (mod n) for every integer a relatively prime to n. Cryptography and Network Security 44

45 Strong probable-primality and a practical test A better way to make the Fermat test more accurate is to realize that if an odd number n is prime, then the number 1 has just two square roots modulo n: 1 and -1. So the square root of a n-1, a (n-1)/2 (since n will be odd), is either 1 or -1. Algorithm Write n-1 = 2 s d where d is odd and s is non-negative: n is a strong probable-prime base a (an a-sprp) if either a d = 1 (mod n) or (a d ) 2r = -1 (mod n) for some non-negative r less than s. It has been proven ([Monier80] and [Rabin80]) that the strong probable primality test is wrong no more than 1/4th of the time (3 out of 4 numbers which pass it will be prime). Cryptography and Network Security 45

46 Simple Fact Equation x 2 1 mod p has only solutions 1,-1 If p is prime number Simple proof: (x+1)(x-1) 0 mod p So if we find another solution, then p can not be prime number! Miller and Rabin 1975,1980 Randomly chosen integer a If a 2 1 mod p then p is not prime number Integer a is called the witness Otherwise p maybe, or maybe not a prime number Cryptography and Network Security 46

47 Witness Algorithm Witness(a,n) Let b k b k-1 b 1 b 0 be the binary code of n-1 Let d=1 For i=k downto 0 x=d; d=d*d mod n If d=1 and x 1, and x n-1 return TRUE If b i =1 then d=d*a mod n Endfor If d 1 then return TRUE Return FALSE Cryptography and Network Security 47

48 Facts Analyze the result of witness If returns TRUE, then n is not prime number Find other solutions for x 2 1 mod n Otherwise, n maybe prime number Given odd n and random a Witness fails with probability less than 0.5 Run witness algorithm s times If one time, it is TRUE Then n is not prime number Otherwise, Pr(n is prime)>1-2 -s Cryptography and Network Security 48

49 RANDOMIZED METHOD Cryptography and Network Security 49

50 Randomized Methods Las Vegas Method Always produces correct results (may not give answer sometimes) Runs in expected polynomial time Monte Carlo Method Always runs in polynomial time May produce incorrect results with a bounded probability Yes-Biased Monte Carlo Method Answer yes is always correct, but the answer no may be wrong No-biased Monte Carlo Method Answer no is always correct, but the answer yes may be wrong Cryptography and Network Security 50

51 Witness Algorithm Witness Algorithm is based on Monte Carlo Method (Yes-biased MC for Compositeness) It actually test compositeness, not primality When it reports yes, the number is always composite When it reports no, input may be composite, prime Probability Result Pr(input=composite ans=composite)= 1 Pr(ans=prime input=composite)<1/2 Pr(input=composite ans=prime) 1/4 Cryptography and Network Security 51

52 Time Complexity Each round of witness cost O(log n) Unit: integer multiplication and modular arithmetic So the primality testing cost O(s log n) The confidence is 1-2 -s if report prime The confidence is 1 if report non-prime Miller's Test [Miller76]: If the extended Riemann hypothesis is true, then if n is an a-sprp for all integers a with 1 < a < 2(log n) 2, then n is prime. Cryptography and Network Security 52

53 More on proving primes (N-1 test Theorem 1: Let n > 1. If for every prime factor q of n-1 there is an integer a such that a n-1 = 1 (mod n), and a (n-1)/q is not 1 (mod n); then n is prime. Cryptography and Network Security 53

54 N-1 test Theorem 2: Suppose n-1 = FR, where F>R, gcd(f,r) is one and the factorization of F is known. If for every prime factor q of F there is an integer a>1 such that a n-1 = 1 (mod n), and gcd(a (n-1)/q-1,n) = 1; then n is prime. Cryptography and Network Security 54

55 N+1 test for Mersenne number Lucas-Lehmer Test (1930): Let p be an odd prime. The Mersenne number M(p) = 2 p -1 is prime if and only if S(p-2) = 0 (mod M(p)) where S(0) = 4 and S(k+1) = S(k) 2-2. the complexity to O(p 2 log p log log p) or Õ(p 2 ) using fast multiplication using FFT Cryptography and Network Security 55

56 ECPP method What is the next big leap in primality proving? To switch from Galois groups to some other, perhaps easier to work with groups--in this case the points on Elliptic Curves modulo n. An Elliptic curve is a curve of genus one, that is a curve that can be written in the form E(a,b) : y 2 = x 3 + ax + b (with 4a b 2 not zero) for implementation Heuristically, the best version of ECPP is O((log n) 4 +eps) for some eps>0 But not guaranteed to run in poly time (same as another method APR) Cryptography and Network Security 56

57 Improved Deterministic methods Cryptography and Network Security 57

58 AKS method: Deterministic Poly- Time Method In 2002 Agrawal, Kayal and Saxena found a relatively simple deterministic algorithm which relies on no unproved assumptions. Agrawal, Head of CSE, IITK Kayal, Saxena (B.E. 2002), Indian Institute of Technology, Kanpur (IITK), PhD IITK 2006 Gödel Prize (in TCS every year from 1993) and the 2006 Fulkerson Prize (in DMath every 3 year from 1979) There has been a long list of research efforts devoted to find deterministic polynomial time methods for testing primes Cryptography and Network Security 58

59 Basics Theorem: Suppose that a and p are relatively prime integers with p > 1. p is prime if and only if (x-a) p = (x p -a) (mod p) where x is a variable Proof. If p is prime, then p divides the binomial coefficients pcr for r = 1, 2,... p-1. This shows that (x-a) p = (x p -a p ) (mod p), and the equation above follows via Fermat's Little Theorem. On the other hand, if p > 1 is composite, then it has a prime divisor q. Let q k be the greatest power of q that divides p. Then q k does not divide pcq and is relatively prime to a p-q, so the coefficient of the term x q on the left of the equation in the theorem is not zero, but it is on the right. Cryptography and Network Security 59

60 AKS method Input: Integer n > 1 if (n is has the form a b with b > 1) then output COMPOSITE r := 2 while (r < n) { if (gcd(n,r) is not 1) then output COMPOSITE if (r is prime greater than 2) then { let q be the largest factor of r-1 if (q > 4sqrt(r)log n) and (n (r-1)/q is not 1 (mod r)) then break } r := r+1 } for a = 1 to 2sqrt(r)log n { if ( (x-a) n is not (x n -a) (mod x r -1,n) ) then output COMPOSITE } output PRIME; Cryptography and Network Security 60

61 Time Complexity they proved would run in at most O((log n) 12 f(log log n)) time where f is a polynomial AKS also showed that if Sophie Germain primes have the expected distribution [HL23] (and they certainly should!), then the exponent 12 in the time estimate can be reduced to 6, bringing it much closer to the (probabilistic) ECPP method. But of course when actually finding primes it is the unlisted constants that make all of the difference! We will have to wait for efficient implementations of this algorithm (and hopefully clever restatements of the painful for loop) to see how it compares to the others for integers of a few thousand digits. Until then, at least we have learned that there is a polynomial-time algorithm for all integers that both is deterministic and relies on no unproved conjectures! Cryptography and Network Security 61

62 Other related topics Primitive root (Generator) And Quadratic Residue Cryptography and Network Security 62

63 Primitive Root Order of integer ord n (a) The order of a modulo n is the smallest positive k such that a k 1 mod n Primitive Root Integer a is a primitive root of n if the order of a modulo n is φ(n) Not all integers have primitive root Example n=pq for primes p and q Prime p has φ(p-1) primitive roots Cryptography and Network Security 63

64 example the congruence classes mod 14 of 1, 3, 5, 9, 11 and 13. n n^k (mod 14) (only the first instance of each cycle is shown) 1 : 1, 2 : 2, 4, 8 3 : 3, 9, 13, 11, 5, 1 4 : 4, 2, 8 5 : 5, 11, 13, 9, 3, 1 6 : 6, 8 7 : 7, 8 : 8, 9 : 9, 11, 1 10 : 10, 2, 6, 4, 12, 8 11 : 11, 9, 1 12 : 12, 4, 6, 2, 10, 8 13 : 13, 1 14 : 0, Thus 3, 5 are only 2 primitive roots of mod 14 Cryptography and Network Security 64

65 cont When primitive root exists Number n in format of p, 2p, p k, 2p k for some integer k and prime number p Otherwise the primitive root does not exist p = q a 1... q Find a PR for p such that Let a=2, i=1 1 1 If i>k, a is then a PR, otherwise go to step 3 ( p 1)/ q If a i 1 mod p let i=i+1 and go to step 2; otherwise let i=1, and a=a+1 and repeat this step 3. k a k Cryptography and Network Security 65

66 Finding PR of mod n compute Then determine Á(n) the different prime factors of, say Now, for every element m of Zn*, compute má(n )=p i Á(n) p 1 ; p 2 ; ; p k mod n, for all i A number m for which these k results are all different from 1 is a primitive root. Cryptography and Network Security 66

67 Primitive root It is easy to show that, if a is a primitive ax root mod gcd(x; p, is a Á(p)) primitive root if and = 1 only if Thus, if we had just chosen a at random, the probability that it would be a primitive root is about 0.45 (exact probability is ) Á(Á(n))=Á(n)= Á(p 1) p 1 Cryptography and Network Security 67

68 Primitive root If GRH is true, then for every prime p there exists a primitive root modulo p (a generator of the multiplicative group of integers modulo p) which is less than 70 (ln(p)) 2 ; this is often used in many proofs of time complexity. Cryptography and Network Security 68

69 Quadratic Residue Quadratic Residue Integer b is a quadratic residue of modulo integer n if and only if x 2 b mod n has a solution for x Number x is called the square root of b mod n Otherwise b is called quadratic nonresidue Given odd prime p, b is quadratic residue, iff b (p-1)/2 1 mod p b is quadratic nonresidue, iff b (p-1)/2-1 mod p These facts can be used to test primes with probability Cryptography and Network Security 69

70 Computing Square root mod p Given number a, find number x, x 2 =a mod p If p=3 mod 4, then x=a (p+1)/4 mod p is a solution. If p=5 mod 8, a (p-1)/4 =1 mod p then x= a (p+3)/8 mod p If p=5 mod 8, a (p-1)/4 =-1 mod p then x= 2a(4a) (p-5)/8 mod p If p=1 mod 8, h+1 2 x = a N s k p 1= 2 k h Here h is an odd number Cryptography and Network Security 70

71 Compute square-root mod p Find a solution to x 2 =a mod p if exists Let r=0, s=p-1; while s even, {r=r+1; s=s/2;} Choose random n such that n = 1 p Let z=n s mod p; x=a (s+1)/2 mod p; b=a s mod p; If b=1, return x as a solution Let m=1, y=b 2 mod p; while y<>1 {y= y 2 mod p; m=m+1;} If r=m then a is Quadratic non-residue; exit; Let x=xz 2r-m-1 mod p and b=bz 2r-m mod p and z=z 2r-m mod p Go to step 4 The expected running time is O(log 4 p) Cryptography and Network Security 71

72 Jacoby Symbol ( a n ) = Q k i = 1 ( a p i )e i Where n = p e 1 1 pe 2 p e k 2 k 1. ( a ) = 0 if a = 0 mod p p 2. ( a ) = 1 if a is QR mod p p 3. ( a ) = 1 if a is quadratic non-residue p of mod p Cryptography and Network Security 72

73 Compute it efficiently 1. if n is odd and m 1 = m 2 mod n then 2. if n is odd, then ( 2 ( 2 ) = 1 if n = 1; 1 mod 8, and n ) = 1 if n = 3; 3 mod 8 n 3. If n is odd then ( m m 1 2 n 4. if n and m are odd, then ( m ) = ( n ) if m = n = 3 mod 4 n m Otherwise ( m ) = ( n ) n m ( m 1 n ) = ( m 2 n ) ) = ( m 1 n )( m 2 n ) Cryptography and Network Security 73

74 Testing Primes (Solovay & Strassen) Choose a random integer a from [1,n-1] If ( a ) = a(n 1)=2 mod n then n answer n is prime Else answer n is composit e Cryptography and Network Security 74

75 Property If ( a n ) = a(n 1)=2 mod n Number a is called Euler-pseudo prime to the base n For any odd integer n, there are at most half of integers a from [1,n-1] that are Euler-pseudo prime to the base n Thus, Prob( ans=prime input n is composite ) < ½ Prob( input n is composite ans=prime ) bound? pr ob(ajb) = pr ob(bja)pr ob(a) pr ob(b) Cryptography and Network Security 75

76 Some hard questions Factoring, Discrete log Square-root Cryptography and Network Security 76

77 Some hard questions Some questions that are assumed to be hard, will be used as bases for cryptography Integer factorization Given n, find all its prime factors Discrete logarithm Given g, y, and p, find x such that g x y mod p Square root Given b, find x such that x 2 b mod n. Here n is not a prime number Cryptography and Network Security 77

78 Integer Factorization write an integer as product of prime numbers. For example, given the number 45, the prime factorization would be The factorization is always unique, according to the fundamental theorem of arithmetic Given two large prime numbers, it is easy to multiply them. However, given their product, it appears to be difficult to find the factors. This is relevant for many modern systems in cryptography. If a fast method were found for solving the integer factorization problem, then several important cryptographic systems would be broken. Although fast factoring is one way to break these systems, there may be other ways to break them that don't involve factoring. So it is possible that the integer factorization problem is truly hard, yet these systems can still be broken quickly. A rare exception is the BBS generator. It has been proved to be exactly as hard as integer factorization: if you can break the generator in polynomial time then you can factorize integers in polynomial time, and vice versa Cryptography and Network Security 78

79 Current state of the art If a large, n-bit number is the product of two primes that are roughly the same size, no polynomial time factoring algorithm is known the best known algorithms are sub-exponential, but super-polynomial: asymptotic running time by the general number field sieve (GNFS) algorithm, is Polynomial methods known for quantum computer! Cryptography and Network Security 79

80 Sub-exponential There are published algorithms that are faster than O((1+ε) b ) for all positive ε, i.e., sub-exponential, where b is the number of bits of the input Cryptography and Network Security 80

81 Factoring algorithms Special purpose its running time depends on the properties of unknown factors: size, special form, etc. Examples Trial division, Pollard's rho algorithm, Pollard's p-1 algorithm, Lenstra elliptic curve factorization, Congruence of squares, Special number field sieve General purpose running time depends solely on the size of the integer to be factored. This is the type of algorithm used to factor RSA numbers. Most general-purpose algorithms are based on the congruence of squares method. Examples: Quadratic sieve, General number field sieve Cryptography and Network Security 81

82 Factorization for Quantum Computers For an ordinary computer, general number field sieve (GNFS) is the best published algorithm for large n (more than about 100 digits). For a quantum computer, however, Peter Shor discovered an algorithm in 1994 that solves it in polynomial time. This will have significant implications for cryptography if a large quantum computer is ever built. Shor's algorithm takes only O(b 3 ) time and O(b) space on b-bit number inputs. In 2001, the first 7-qubit quantum computer became the first to run Shor's algorithm. It factored the number 15. Cryptography and Network Security 82

83 List of Algorithms Special-purpose A special-purpose factoring algorithm's running time depends on the properties of its unknown factors: size, special form, etc. Exactly what the running time depends on varies between algorithms. Trial division Pollard's rho algorithm Algebraic-group factorisation algorithms amongst which are Pollard's p 1 algorithm, Williams' p+1 algorithm and Lenstra elliptic curve factorization Fermat's factorization method Special number field sieve General-purpose A general-purpose factoring algorithm's running time depends solely on the size of the integer to be factored. This is the type of algorithm used to factor RSA numbers. Most general-purpose factoring algorithms are based on the congruence of squares method. Dixon's algorithm Continued fraction factorization (CFRAC) Quadratic sieve General number field sieve Shanks' square forms factorization (SQUFOF) Cryptography and Network Security 83

84 Discrete Logarithms Y g x mod p Given y, g, and p, compute x as log g (y) Time complexity O(e (ln p)1/3 (ln ln p) 2/3 ) Best known until now In other words, if p is large, then it is very hard to solve the discrete logarithm problem Several protocols are based on this ElGamal discrete log cryptosystem, Diffie-Hellman key exchange and the Digital Signature Algorithm. Current methods: the Pohlig-Hellman algorithm if p-1 is a product of small primes, so this should be avoided in those applications Cryptography and Network Security 84

85 Methods More sophisticated algorithms exist, usually inspired by similar algorithms for integer factorization. These algorithms run faster than the naive algorithm, but none of them runs in polynomial time. Baby-step giant-step (Also known as 'Little-Step Big-Step') Pollard's rho algorithm for logarithms Pollard's lambda algorithm (aka Pollard's kangaroo algorithm) Pohlig-Hellman algorithm Index calculus algorithm Number field sieve Cryptography and Network Security 85

86 Complexity Theory The input length of a problem is the number n of symbols used to characterize it Complexity of a method Function f(n) is order O(g(n)) if f(n)<=c* g(n), for all n>=n 0, for some c Function f(n) is order Ω(g(n)) if f(n)>=c* g(n), for all n>=n 0, for some c Function f(n) is order θ (g(n)) if c1* g(n) <=f(n)<=c2* g(n), for all n>=n 0, for some c1 and c2 Polynomial time algorithm (P) solves any instance of a particular problem with input length n in time O(p(n)), where p is a polynomial Cryptography and Network Security 86

87 Cont. Non-deterministic polynomial time algorithm (NP) is one for which any guess at the solution of an instance of the problem may be checked for validity in polynomial time. NP-complete problems are a subclass of NP problems for which it is known that if any such problem has a polynomial time solution, then all NP problems have polynomial solutions. Co-NP: the complements of NP problems. Cryptography and Network Security 87

Factorization & Primality Testing

Factorization & Primality Testing Factorization & Primality Testing C etin Kaya Koc http://cs.ucsb.edu/~koc koc@cs.ucsb.edu Koc (http://cs.ucsb.edu/~ koc) ucsb ccs 130h explore crypto fall 2014 1/1 Primes Natural (counting) numbers: N

More information

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 9.1 Chapter 9 Objectives

More information

Applied Cryptography and Computer Security CSE 664 Spring 2018

Applied Cryptography and Computer Security CSE 664 Spring 2018 Applied Cryptography and Computer Security Lecture 12: Introduction to Number Theory II Department of Computer Science and Engineering University at Buffalo 1 Lecture Outline This time we ll finish the

More information

Cryptography CS 555. Topic 18: RSA Implementation and Security. CS555 Topic 18 1

Cryptography CS 555. Topic 18: RSA Implementation and Security. CS555 Topic 18 1 Cryptography CS 555 Topic 18: RSA Implementation and Security Topic 18 1 Outline and Readings Outline RSA implementation issues Factoring large numbers Knowing (e,d) enables factoring Prime testing Readings:

More information

ECEN 5022 Cryptography

ECEN 5022 Cryptography Elementary Algebra and Number Theory University of Colorado Spring 2008 Divisibility, Primes Definition. N denotes the set {1, 2, 3,...} of natural numbers and Z denotes the set of integers {..., 2, 1,

More information

Topics in Cryptography. Lecture 5: Basic Number Theory

Topics in Cryptography. Lecture 5: Basic Number Theory Topics in Cryptography Lecture 5: Basic Number Theory Benny Pinkas page 1 1 Classical symmetric ciphers Alice and Bob share a private key k. System is secure as long as k is secret. Major problem: generating

More information

Lecture 6: Cryptanalysis of public-key algorithms.,

Lecture 6: Cryptanalysis of public-key algorithms., T-79.159 Cryptography and Data Security Lecture 6: Cryptanalysis of public-key algorithms. Helsinki University of Technology mjos@tcs.hut.fi 1 Outline Computational complexity Reminder about basic number

More information

Introduction to Information Security

Introduction to Information Security Introduction to Information Security Lecture 5: Number Theory 007. 6. Prof. Byoungcheon Lee sultan (at) joongbu. ac. kr Information and Communications University Contents 1. Number Theory Divisibility

More information

Introduction to Cryptography. Lecture 6

Introduction to Cryptography. Lecture 6 Introduction to Cryptography Lecture 6 Benny Pinkas page 1 Public Key Encryption page 2 Classical symmetric ciphers Alice and Bob share a private key k. System is secure as long as k is secret. Major problem:

More information

Basic Algorithms in Number Theory

Basic Algorithms in Number Theory Basic Algorithms in Number Theory Algorithmic Complexity... 1 Basic Algorithms in Number Theory Francesco Pappalardi Discrete Logs, Modular Square Roots & Euclidean Algorithm. July 20 th 2010 Basic Algorithms

More information

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald)

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald) Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald) 1 Euclid s Algorithm Euclid s Algorithm for computing the greatest common divisor belongs to the oldest known computing procedures

More information

Basic elements of number theory

Basic elements of number theory Cryptography Basic elements of number theory Marius Zimand 1 Divisibility, prime numbers By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a

More information

Basic elements of number theory

Basic elements of number theory Cryptography Basic elements of number theory Marius Zimand By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a k for some integer k. Notation

More information

NUMBER THEORY. Anwitaman DATTA SCSE, NTU Singapore CX4024. CRYPTOGRAPHY & NETWORK SECURITY 2018, Anwitaman DATTA

NUMBER THEORY. Anwitaman DATTA SCSE, NTU Singapore CX4024. CRYPTOGRAPHY & NETWORK SECURITY 2018, Anwitaman DATTA NUMBER THEORY Anwitaman DATTA SCSE, NTU Singapore Acknowledgement: The following lecture slides are based on, and uses material from the text book Cryptography and Network Security (various eds) by William

More information

Corollary 4.2 (Pepin s Test, 1877). Let F k = 2 2k + 1, the kth Fermat number, where k 1. Then F k is prime iff 3 F k 1

Corollary 4.2 (Pepin s Test, 1877). Let F k = 2 2k + 1, the kth Fermat number, where k 1. Then F k is prime iff 3 F k 1 4. Primality testing 4.1. Introduction. Factorisation is concerned with the problem of developing efficient algorithms to express a given positive integer n > 1 as a product of powers of distinct primes.

More information

1 The Fundamental Theorem of Arithmetic. A positive integer N has a unique prime power decomposition. Primality Testing. and. Integer Factorisation

1 The Fundamental Theorem of Arithmetic. A positive integer N has a unique prime power decomposition. Primality Testing. and. Integer Factorisation 1 The Fundamental Theorem of Arithmetic A positive integer N has a unique prime power decomposition 2 Primality Testing Integer Factorisation (Gauss 1801, but probably known to Euclid) The Computational

More information

LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS

LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS Modular arithmetics that we have discussed in the previous lectures is very useful in Cryptography and Computer Science. Here we discuss several

More information

Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m

Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m Outline GCD and Euclid s Algorithm AIT 682: Network and Systems Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography Modulo Arithmetic Modular Exponentiation Discrete Logarithms

More information

Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms AIT 682: Network and Systems Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography Instructor: Dr. Kun Sun Outline GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation

More information

CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms Computer Science CSC 474 Network Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography CSC 474 Dr. Peng Ning 1 Outline GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation

More information

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 9 September 30, 2015 CPSC 467, Lecture 9 1/47 Fast Exponentiation Algorithms Number Theory Needed for RSA Elementary Number Theory

More information

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya BBM 205 Discrete Mathematics Hacettepe University http://web.cs.hacettepe.edu.tr/ bbm205 Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya Resources: Kenneth Rosen,

More information

Numbers. Çetin Kaya Koç Winter / 18

Numbers. Çetin Kaya Koç   Winter / 18 Çetin Kaya Koç http://koclab.cs.ucsb.edu Winter 2016 1 / 18 Number Systems and Sets We represent the set of integers as Z = {..., 3, 2, 1,0,1,2,3,...} We denote the set of positive integers modulo n as

More information

A Few Primality Testing Algorithms

A Few Primality Testing Algorithms A Few Primality Testing Algorithms Donald Brower April 2, 2006 0.1 Introduction These notes will cover a few primality testing algorithms. There are many such, some prove that a number is prime, others

More information

Primality Testing. 1 Introduction. 2 Brief Chronology of Primality Testing. CS265/CME309, Fall Instructor: Gregory Valiant

Primality Testing. 1 Introduction. 2 Brief Chronology of Primality Testing. CS265/CME309, Fall Instructor: Gregory Valiant CS265/CME309, Fall 2018. Instructor: Gregory Valiant Primality Testing [These notes may not be distributed outside this class without the permission of Gregory Valiant.] 1 Introduction Prime numbers are

More information

Number Theory and Algebra: A Brief Introduction

Number Theory and Algebra: A Brief Introduction Number Theory and Algebra: A Brief Introduction Indian Statistical Institute Kolkata May 15, 2017 Elementary Number Theory: Modular Arithmetic Definition Let n be a positive integer and a and b two integers.

More information

Number Theory. Modular Arithmetic

Number Theory. Modular Arithmetic Number Theory The branch of mathematics that is important in IT security especially in cryptography. Deals only in integer numbers and the process can be done in a very fast manner. Modular Arithmetic

More information

PRIMALITY TESTING. Professor : Mr. Mohammad Amin Shokrollahi Assistant : Mahdi Cheraghchi. By TAHIRI JOUTI Kamal

PRIMALITY TESTING. Professor : Mr. Mohammad Amin Shokrollahi Assistant : Mahdi Cheraghchi. By TAHIRI JOUTI Kamal PRIMALITY TESTING Professor : Mr. Mohammad Amin Shokrollahi Assistant : Mahdi Cheraghchi By TAHIRI JOUTI Kamal TABLE OF CONTENTS I- FUNDAMENTALS FROM NOMBER THEORY FOR RANDOMIZED ALGORITHMS:.page 4 1)

More information

ALG 4.0 Number Theory Algorithms:

ALG 4.0 Number Theory Algorithms: Algorithms Professor John Reif ALG 4.0 Number Theory Algorithms: (a) GCD (b) Multiplicative Inverse (c) Fermat & Euler's Theorems (d) Public Key Cryptographic Systems (e) Primality Testing Greatest Common

More information

Lecture 1: Introduction to Public key cryptography

Lecture 1: Introduction to Public key cryptography Lecture 1: Introduction to Public key cryptography Thomas Johansson T. Johansson (Lund University) 1 / 44 Key distribution Symmetric key cryptography: Alice and Bob share a common secret key. Some means

More information

Public Key Encryption

Public Key Encryption Public Key Encryption 3/13/2012 Cryptography 1 Facts About Numbers Prime number p: p is an integer p 2 The only divisors of p are 1 and p s 2, 7, 19 are primes -3, 0, 1, 6 are not primes Prime decomposition

More information

Mathematical Foundations of Public-Key Cryptography

Mathematical Foundations of Public-Key Cryptography Mathematical Foundations of Public-Key Cryptography Adam C. Champion and Dong Xuan CSE 4471: Information Security Material based on (Stallings, 2006) and (Paar and Pelzl, 2010) Outline Review: Basic Mathematical

More information

10 Public Key Cryptography : RSA

10 Public Key Cryptography : RSA 10 Public Key Cryptography : RSA 10.1 Introduction The idea behind a public-key system is that it might be possible to find a cryptosystem where it is computationally infeasible to determine d K even if

More information

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2 Contents 1 Recommended Reading 1 2 Public Key/Private Key Cryptography 1 2.1 Overview............................................. 1 2.2 RSA Algorithm.......................................... 2 3 A Number

More information

CSC 474 Information Systems Security

CSC 474 Information Systems Security CSC Information Systems Security Topic. Basic Number Theory CSC Dr. Peng Ning Basic Number Theory We are talking about integers! Divisor We say that b divides a if a = mb for some m, denoted b a. b is

More information

Instructor: Bobby Kleinberg Lecture Notes, 25 April The Miller-Rabin Randomized Primality Test

Instructor: Bobby Kleinberg Lecture Notes, 25 April The Miller-Rabin Randomized Primality Test Introduction to Algorithms (CS 482) Cornell University Instructor: Bobby Kleinberg Lecture Notes, 25 April 2008 The Miller-Rabin Randomized Primality Test 1 Introduction Primality testing is an important

More information

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory. CSS322: Security and Cryptography Sirindhorn International Institute of Technology Thammasat University Prepared by Steven Gordon on 29 December 2011 CSS322Y11S2L06, Steve/Courses/2011/S2/CSS322/Lectures/number.tex,

More information

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p. Chapter 6 Prime Numbers Part VI of PJE. Definition and Fundamental Results Definition. (PJE definition 23.1.1) An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p. If n > 1

More information

LARGE PRIME NUMBERS (32, 42; 4) (32, 24; 2) (32, 20; 1) ( 105, 20; 0).

LARGE PRIME NUMBERS (32, 42; 4) (32, 24; 2) (32, 20; 1) ( 105, 20; 0). LARGE PRIME NUMBERS 1. Fast Modular Exponentiation Given positive integers a, e, and n, the following algorithm quickly computes the reduced power a e % n. (Here x % n denotes the element of {0,, n 1}

More information

Public Key Algorithms

Public Key Algorithms Public Key Algorithms Raj Jain Washington University in Saint Louis Saint Louis, MO 63130 Jain@cse.wustl.edu Audio/Video recordings of this lecture are available at: http://www.cse.wustl.edu/~jain/cse571-09/

More information

Cryptography. Number Theory with AN INTRODUCTION TO. James S. Kraft. Lawrence C. Washington. CRC Press

Cryptography. Number Theory with AN INTRODUCTION TO. James S. Kraft. Lawrence C. Washington. CRC Press AN INTRODUCTION TO Number Theory with Cryptography James S Kraft Gilman School Baltimore, Maryland, USA Lawrence C Washington University of Maryland College Park, Maryland, USA CRC Press Taylor & Francis

More information

CIS 551 / TCOM 401 Computer and Network Security

CIS 551 / TCOM 401 Computer and Network Security CIS 551 / TCOM 401 Computer and Network Security Spring 2008 Lecture 15 3/20/08 CIS/TCOM 551 1 Announcements Project 3 available on the web. Get the handout in class today. Project 3 is due April 4th It

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security Outline Quadratic residues Useful tests Digital Signatures CPSC 467b: Cryptography and Computer Security Lecture 14 Michael J. Fischer Department of Computer Science Yale University March 1, 2010 Michael

More information

Introduction to Number Theory

Introduction to Number Theory INTRODUCTION Definition: Natural Numbers, Integers Natural numbers: N={0,1,, }. Integers: Z={0,±1,±, }. Definition: Divisor If a Z can be writeen as a=bc where b, c Z, then we say a is divisible by b or,

More information

Chapter 4 Finite Fields

Chapter 4 Finite Fields Chapter 4 Finite Fields Introduction will now introduce finite fields of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public Key concern operations on numbers what constitutes a number

More information

Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems

Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems Cryptography Introduction to Number Theory 1 Preview Integers Prime Numbers Modular Arithmetic Totient Function Euler's Theorem Fermat's Little Theorem Euclid's Algorithm 2 Introduction to Number Theory

More information

Primality Testing- Is Randomization worth Practicing?

Primality Testing- Is Randomization worth Practicing? Primality Testing- Is Randomization worth Practicing? Shubham Sahai Srivastava Indian Institute of Technology, Kanpur ssahai@cse.iitk.ac.in April 5, 2014 Shubham Sahai Srivastava (IITK) Primality Test

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 8 February 1, 2012 CPSC 467b, Lecture 8 1/42 Number Theory Needed for RSA Z n : The integers mod n Modular arithmetic GCD Relatively

More information

The RSA Cryptosystem: Factoring the public modulus. Debdeep Mukhopadhyay

The RSA Cryptosystem: Factoring the public modulus. Debdeep Mukhopadhyay The RSA Cryptosystem: Factoring the public modulus Debdeep Mukhopadhyay Assistant Professor Department of Computer Science and Engineering Indian Institute of Technology Kharagpur INDIA -721302 Objectives

More information

Number Theory and Group Theoryfor Public-Key Cryptography

Number Theory and Group Theoryfor Public-Key Cryptography Number Theory and Group Theory for Public-Key Cryptography TDA352, DIT250 Wissam Aoudi Chalmers University of Technology November 21, 2017 Wissam Aoudi Number Theory and Group Theoryfor Public-Key Cryptography

More information

Cryptography IV: Asymmetric Ciphers

Cryptography IV: Asymmetric Ciphers Cryptography IV: Asymmetric Ciphers Computer Security Lecture 7 David Aspinall School of Informatics University of Edinburgh 31st January 2011 Outline Background RSA Diffie-Hellman ElGamal Summary Outline

More information

LECTURE NOTES IN CRYPTOGRAPHY

LECTURE NOTES IN CRYPTOGRAPHY 1 LECTURE NOTES IN CRYPTOGRAPHY Thomas Johansson 2005/2006 c Thomas Johansson 2006 2 Chapter 1 Abstract algebra and Number theory Before we start the treatment of cryptography we need to review some basic

More information

Biomedical Security. Some Security News 9/17/2018. Erwin M. Bakker. Blockchains are not safe for voting (slashdot.org) : From: paragonie.

Biomedical Security. Some Security News 9/17/2018. Erwin M. Bakker. Blockchains are not safe for voting (slashdot.org) : From: paragonie. Biomedical Security Erwin M. Bakker Some Security News From: NYTimes Blockchains are not safe for voting (slashdot.org) : From Motherboard.vice.com ECDAA: Eliptic Curve Direct Anonymous Attestation for

More information

A. Algebra and Number Theory

A. Algebra and Number Theory A. Algebra and Number Theory Public-key cryptosystems are based on modular arithmetic. In this section, we summarize the concepts and results from algebra and number theory which are necessary for an understanding

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 10 February 19, 2013 CPSC 467b, Lecture 10 1/45 Primality Tests Strong primality tests Weak tests of compositeness Reformulation

More information

Lecture Notes, Week 6

Lecture Notes, Week 6 YALE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE CPSC 467b: Cryptography and Computer Security Week 6 (rev. 3) Professor M. J. Fischer February 15 & 17, 2005 1 RSA Security Lecture Notes, Week 6 Several

More information

Chapter 9 Basic Number Theory for Public Key Cryptography. WANG YANG

Chapter 9 Basic Number Theory for Public Key Cryptography. WANG YANG Chapter 9 Basic Number Theory for Public Key Cryptography WANG YANG wyang@njnet.edu.cn Content GCD and Euclid s Algorithm Modular Arithmetic Modular Exponentiation Discrete Logarithms GCD and Euclid s

More information

CSE 521: Design and Analysis of Algorithms I

CSE 521: Design and Analysis of Algorithms I CSE 521: Design and Analysis of Algorithms I Randomized Algorithms: Primality Testing Paul Beame 1 Randomized Algorithms QuickSelect and Quicksort Algorithms random choices make them fast and simple but

More information

Summary Slides for MATH 342 June 25, 2018

Summary Slides for MATH 342 June 25, 2018 Summary Slides for MATH 342 June 25, 2018 Summary slides based on Elementary Number Theory and its applications by Kenneth Rosen and The Theory of Numbers by Ivan Niven, Herbert Zuckerman, and Hugh Montgomery.

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 9 February 6, 2012 CPSC 467b, Lecture 9 1/53 Euler s Theorem Generating RSA Modulus Finding primes by guess and check Density of

More information

Public-key Cryptography: Theory and Practice

Public-key Cryptography: Theory and Practice Public-key Cryptography Theory and Practice Department of Computer Science and Engineering Indian Institute of Technology Kharagpur Chapter 2: Mathematical Concepts Divisibility Congruence Quadratic Residues

More information

Fermat s Little Theorem. Fermat s little theorem is a statement about primes that nearly characterizes them.

Fermat s Little Theorem. Fermat s little theorem is a statement about primes that nearly characterizes them. Fermat s Little Theorem Fermat s little theorem is a statement about primes that nearly characterizes them. Theorem: Let p be prime and a be an integer that is not a multiple of p. Then a p 1 1 (mod p).

More information

Addition. Ch1 - Algorithms with numbers. Multiplication. al-khwārizmī. al-khwārizmī. Division 53+35=88. Cost? (n number of bits) 13x11=143. Cost?

Addition. Ch1 - Algorithms with numbers. Multiplication. al-khwārizmī. al-khwārizmī. Division 53+35=88. Cost? (n number of bits) 13x11=143. Cost? Ch - Algorithms with numbers Addition Basic arithmetic Addition ultiplication Division odular arithmetic factoring is hard Primality testing 53+35=88 Cost? (n number of bits) O(n) ultiplication al-khwārizmī

More information

CIS 6930/4930 Computer and Network Security. Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography

CIS 6930/4930 Computer and Network Security. Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography CIS 6930/4930 Computer and Network Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography 1 Review of Modular Arithmetic 2 Remainders and Congruency For any integer a and any positive

More information

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

CHAPTER 6. Prime Numbers. Definition and Fundamental Results CHAPTER 6 Prime Numbers Part VI of PJE. Definition and Fundamental Results 6.1. Definition. (PJE definition 23.1.1) An integer p is prime if p > 1 and the only positive divisors of p are 1 and p. If n

More information

Algorithms (II) Yu Yu. Shanghai Jiaotong University

Algorithms (II) Yu Yu. Shanghai Jiaotong University Algorithms (II) Yu Yu Shanghai Jiaotong University Chapter 1. Algorithms with Numbers Two seemingly similar problems Factoring: Given a number N, express it as a product of its prime factors. Primality:

More information

Mathematics for Cryptography

Mathematics for Cryptography Mathematics for Cryptography Douglas R. Stinson David R. Cheriton School of Computer Science University of Waterloo Waterloo, Ontario, N2L 3G1, Canada March 15, 2016 1 Groups and Modular Arithmetic 1.1

More information

YALE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE

YALE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE YALE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE CPSC 467a: Cryptography and Computer Security Notes 13 (rev. 2) Professor M. J. Fischer October 22, 2008 53 Chinese Remainder Theorem Lecture Notes 13 We

More information

Aspect of Prime Numbers in Public Key Cryptosystem

Aspect of Prime Numbers in Public Key Cryptosystem Aspect of Prime Numbers in Public Key Cryptosystem Md.Mehedi Masud, Huma Galzie, Kazi Arif Hossain and Md.Minhaj Ul Islam Computer Science and Engineering Discipline Khulna University, Khulna-9208, Bangladesh

More information

Applied Cryptography and Computer Security CSE 664 Spring 2017

Applied Cryptography and Computer Security CSE 664 Spring 2017 Applied Cryptography and Computer Security Lecture 11: Introduction to Number Theory Department of Computer Science and Engineering University at Buffalo 1 Lecture Outline What we ve covered so far: symmetric

More information

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time. 8 Modular Arithmetic We introduce an operator mod. Let d be a positive integer. For c a nonnegative integer, the value c mod d is the remainder when c is divided by d. For example, c mod d = 0 if and only

More information

Security Issues in Cloud Computing Modern Cryptography II Asymmetric Cryptography

Security Issues in Cloud Computing Modern Cryptography II Asymmetric Cryptography Security Issues in Cloud Computing Modern Cryptography II Asymmetric Cryptography Peter Schwabe October 21 and 28, 2011 So far we assumed that Alice and Bob both have some key, which nobody else has. How

More information

Elementary Number Theory MARUCO. Summer, 2018

Elementary Number Theory MARUCO. Summer, 2018 Elementary Number Theory MARUCO Summer, 2018 Problem Set #0 axiom, theorem, proof, Z, N. Axioms Make a list of axioms for the integers. Does your list adequately describe them? Can you make this list as

More information

THE SOLOVAY STRASSEN TEST

THE SOLOVAY STRASSEN TEST THE SOLOVAY STRASSEN TEST KEITH CONRAD 1. Introduction The Jacobi symbol satisfies many formulas that the Legendre symbol does, such as these: for a, b Z and odd m, n Z +, (1) a b mod n ( a n ) = ( b n

More information

THE MILLER RABIN TEST

THE MILLER RABIN TEST THE MILLER RABIN TEST KEITH CONRAD 1. Introduction The Miller Rabin test is the most widely used probabilistic primality test. For odd composite n > 1 at least 75% of numbers from to 1 to n 1 are witnesses

More information

A Guide to Arithmetic

A Guide to Arithmetic A Guide to Arithmetic Robin Chapman August 5, 1994 These notes give a very brief resumé of my number theory course. Proofs and examples are omitted. Any suggestions for improvements will be gratefully

More information

PRIMES is in P. Manindra Agrawal. NUS Singapore / IIT Kanpur

PRIMES is in P. Manindra Agrawal. NUS Singapore / IIT Kanpur PRIMES is in P Manindra Agrawal NUS Singapore / IIT Kanpur The Problem Given number n, test if it is prime efficiently. Efficiently = in time a polynomial in number of digits = (log n) c for some constant

More information

Part II. Number Theory. Year

Part II. Number Theory. Year Part II Year 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005 2017 Paper 3, Section I 1G 70 Explain what is meant by an Euler pseudoprime and a strong pseudoprime. Show that 65 is an Euler

More information

Introduction. will now introduce finite fields of increasing importance in cryptography. AES, Elliptic Curve, IDEA, Public Key

Introduction. will now introduce finite fields of increasing importance in cryptography. AES, Elliptic Curve, IDEA, Public Key Introduction will now introduce finite fields of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public Key concern operations on numbers where what constitutes a number and the type of

More information

Basic Algorithms in Number Theory

Basic Algorithms in Number Theory Basic Algorithms in Number Theory Algorithmic Complexity... 1 Basic Algorithms in Number Theory Francesco Pappalardi #2 - Discrete Logs, Modular Square Roots, Polynomials, Hensel s Lemma & Chinese Remainder

More information

Elliptic curves: Theory and Applications. Day 3: Counting points.

Elliptic curves: Theory and Applications. Day 3: Counting points. Elliptic curves: Theory and Applications. Day 3: Counting points. Elisa Lorenzo García Université de Rennes 1 13-09-2017 Elisa Lorenzo García (Rennes 1) Elliptic Curves 3 13-09-2017 1 / 26 Counting points:

More information

1 Overview and revision

1 Overview and revision MTH6128 Number Theory Notes 1 Spring 2018 1 Overview and revision In this section we will meet some of the concerns of Number Theory, and have a brief revision of some of the relevant material from Introduction

More information

A SURVEY OF PRIMALITY TESTS

A SURVEY OF PRIMALITY TESTS A SURVEY OF PRIMALITY TESTS STEFAN LANCE Abstract. In this paper, we show how modular arithmetic and Euler s totient function are applied to elementary number theory. In particular, we use only arithmetic

More information

1. Algebra 1.7. Prime numbers

1. Algebra 1.7. Prime numbers 1. ALGEBRA 30 1. Algebra 1.7. Prime numbers Definition Let n Z, with n 2. If n is not a prime number, then n is called a composite number. We look for a way to test if a given positive integer is prime

More information

One can use elliptic curves to factor integers, although probably not RSA moduli.

One can use elliptic curves to factor integers, although probably not RSA moduli. Elliptic Curves Elliptic curves are groups created by defining a binary operation (addition) on the points of the graph of certain polynomial equations in two variables. These groups have several properties

More information

Primality testing: then and now

Primality testing: then and now Seventy-five years of Mathematics of Computation ICERM, November 1 3, 2018 Primality testing: then and now Carl Pomerance Dartmouth College, Emeritus University of Georgia, Emeritus In 1801, Carl Friedrich

More information

Computational Number Theory. Adam O Neill Based on

Computational Number Theory. Adam O Neill Based on Computational Number Theory Adam O Neill Based on http://cseweb.ucsd.edu/~mihir/cse207/ Secret Key Exchange - * Is Alice Ka Public Network Ka = KB O KB 0^1 Eve should have a hard time getting information

More information

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank University of Florida Dept. of Computer & Information Science & Engineering COT 3100 Applications of Discrete Structures Dr. Michael P. Frank Slides for a Course Based on the Text Discrete Mathematics

More information

Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn

Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn Chapter 6 Randomization Algorithm Theory WS 2012/13 Fabian Kuhn Randomization Randomized Algorithm: An algorithm that uses (or can use) random coin flips in order to make decisions We will see: randomization

More information

Factoring Algorithms Pollard s p 1 Method. This method discovers a prime factor p of an integer n whenever p 1 has only small prime factors.

Factoring Algorithms Pollard s p 1 Method. This method discovers a prime factor p of an integer n whenever p 1 has only small prime factors. Factoring Algorithms Pollard s p 1 Method This method discovers a prime factor p of an integer n whenever p 1 has only small prime factors. Input: n (to factor) and a limit B Output: a proper factor of

More information

Number Theory in Cryptology

Number Theory in Cryptology Number Theory in Cryptology Abhijit Das Department of Computer Science and Engineering Indian Institute of Technology Kharagpur October 15, 2011 What is Number Theory? Theory of natural numbers N = {1,

More information

Introduction to Modern Cryptography. Benny Chor

Introduction to Modern Cryptography. Benny Chor Introduction to Modern Cryptography Benny Chor RSA Public Key Encryption Factoring Algorithms Lecture 7 Tel-Aviv University Revised March 1st, 2008 Reminder: The Prime Number Theorem Let π(x) denote the

More information

Linear Congruences. The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence:

Linear Congruences. The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence: Linear Congruences The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence: ax b (mod m), a, b Z, m N +. (1) If x 0 is a solution then so is x k :=

More information

Mathematics of Public Key Cryptography

Mathematics of Public Key Cryptography Mathematics of Public Key Cryptography Eric Baxter April 12, 2014 Overview Brief review of public-key cryptography Mathematics behind public-key cryptography algorithms What is Public-Key Cryptography?

More information

Introduction to Cryptography. Lecture 8

Introduction to Cryptography. Lecture 8 Introduction to Cryptography Lecture 8 Benny Pinkas page 1 1 Groups we will use Multiplication modulo a prime number p (G, ) = ({1,2,,p-1}, ) E.g., Z 7* = ( {1,2,3,4,5,6}, ) Z p * Z N * Multiplication

More information

Counting Prime Numbers with Short Binary Signed Representation

Counting Prime Numbers with Short Binary Signed Representation Counting Prime Numbers with Short Binary Signed Representation José de Jesús Angel Angel and Guillermo Morales-Luna Computer Science Section, CINVESTAV-IPN, Mexico jjangel@computacion.cs.cinvestav.mx,

More information

Numbers, Groups and Cryptography. Gordan Savin

Numbers, Groups and Cryptography. Gordan Savin Numbers, Groups and Cryptography Gordan Savin Contents Chapter 1. Euclidean Algorithm 5 1. Euclidean Algorithm 5 2. Fundamental Theorem of Arithmetic 9 3. Uniqueness of Factorization 14 4. Efficiency

More information

Lemma 1.2. (1) If p is prime, then ϕ(p) = p 1. (2) If p q are two primes, then ϕ(pq) = (p 1)(q 1).

Lemma 1.2. (1) If p is prime, then ϕ(p) = p 1. (2) If p q are two primes, then ϕ(pq) = (p 1)(q 1). 1 Background 1.1 The group of units MAT 3343, APPLIED ALGEBRA, FALL 2003 Handout 3: The RSA Cryptosystem Peter Selinger Let (R, +, ) be a ring. Then R forms an abelian group under addition. R does not

More information

Ma/CS 6a Class 4: Primality Testing

Ma/CS 6a Class 4: Primality Testing Ma/CS 6a Class 4: Primality Testing By Adam Sheffer Reminder: Euler s Totient Function Euler s totient φ(n) is defined as follows: Given n N, then φ n = x 1 x < n and GCD x, n = 1. In more words: φ n is

More information

Overview. Background / Context. CSC 580 Cryptography and Computer Security. March 21, 2017

Overview. Background / Context. CSC 580 Cryptography and Computer Security. March 21, 2017 CSC 580 Cryptography and Computer Security Math for Public Key Crypto, RSA, and Diffie-Hellman (Sections 2.4-2.6, 2.8, 9.2, 10.1-10.2) March 21, 2017 Overview Today: Math needed for basic public-key crypto

More information