Download Cryptography and Network Security - Number Theory | CS 549 and more Exams Cryptography and System Security in PDF only on Docsity! 1 CS595-Cryptography and Network Security Cryptography and Network Security Number Theory Xiang-Yang Li CS595-Cryptography and Network Security 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 int. m,n Prime number P has only positive divisors 1 and p Relatively prime numbers No common divisors for p and q except 1 CS595-Cryptography and Network Security 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 … CS595-Cryptography and Network Security Cont. GCD (a,b) is given by: let g0=b g1=a gi+1 = gi-1 mod gi when gi =0 then gcd(a,b) = gi-1 The algorithm terminates in O(log b) rounds Why? CS595-Cryptography and Network Security 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? Integer a can be factored as a=p1a1 p2a2 p3a3…. pnan where pi is prime number CS595-Cryptography and Network Security 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 a ≡ b, b ≡ c then a ≡ c 2 CS595-Cryptography and Network Security 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 CS595-Cryptography and Network Security Cont. Division a/b mod n multiplied by inverse of b: a/b = a*b-1 mod n b-1*b ≡ 1 mod n 3-1 ≡7 mod 10 because 3*7 ≡ 1 mod 10 Inverse does not always exist! Only when gcd(b,n)=1 CS595-Cryptography and Network Security 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 CS595-Cryptography and Network Security Galois Field If n is constrained to be a prime number p then this forms a Galois field modulo p denoted GF(p) and all the normal laws associated with integer arithmetic work Exponentiation b = ae mod p Discrete Logarithms find x where ax = b mod p CS595-Cryptography and Network Security Inverses and Euclid's Extended GCD Routine If (a,n)=1 then the inverse always exists Can extend Euclid's algorithm to find inverse by keeping track of gi = ui.n + vi.a Extended Euclid's (or binary GCD) algorithm to find inverse of a number a mod n (where (a,n)=1) is: CS595-Cryptography and Network Security 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 2nd step