CIS 5371 Cryptography 6. An Introduction to Number Theory 1 C Congruence and d Residue R id classes l Arithmetic modulo n, Zn Solving g linear equations q The Chinese Remainder Theorem Euler’s p phi function The theorems of Fermat and Euler Quadratic residues Legendre & Jacobi symbols 2 A ith ti modulo Arithmetic d l n Examples Zn ={0,1,2, { , , , … , n-1}, }, Zp* = {1,2, … , p-1}, for prime p, Zn* = {all integers k, k 0 < k < n, n with gcd(k,n) gcd(k n) = 1} 1}. 3 S l i li Solving linear equations ti Theorem For any integer n > 1, ax b (mod ( d n)) is solvable, if and only if, gcd (a,n) | b . Examples 6x 18 (mod 36) has 6 solutions: 3, 9, 15, 21, 27, 33. 2x 5 (mod 10), has no solutions. 4 Th Chi The Chinese R Remainder i d Th Theorem Let m1 , , mn be positive integers with gcd(mi , m j ) 1, and let M m1m 2 mr . Then the congruence x c1 (mod m1 ) x c2 (mod m2 ) x cr (mod mr ) has a unique solution z Z M . 5 Th Chi The Chinese R Remainder i d Th Theorem Let ( M / mi ). yi 1 (mod mi ). Then for zi ( M / mi ). yi it is easy to see that z i 1 zi ci (mod ( d M) r is a solution. 6 E Example l S l the Solve th modular d l conguence : x 2 (mod 3) x 3 ((mod 5) x 4 (mod 7) W have We h : M 105, 105 y1 35 1 (mod 3) 2 (mod 3) y 2 211 (mod ( d 5) 1 (mod ( d 5) y 3 15 1 (mod 7) 1 (mod 7) Then z 2 35 2 3 21 1 4 15 1 263 mod 105 53 mod 105 7 E Example l Solve S l the th modular d l conguence : x 1 (mod 2) x 2 (mod 5) x 3 (mod 7) 8 E l ’ phi Euler’s hi f function ti (n) is the number of positive integers k for which gcd(k,n) 1. We have (1) 1 ( p ) p 1, p a prime, ( pq) ( p-1)(q-1), for p,q primes, 1 p ( p e ) p e p e 1 p e (1 ), p a prime, e 1. It follows that if n p1 1 p1 2 p1 1 , is the p prime e e e factorization of n, then 1 1 1 (n) n (1 ) (1 ) (1 )). p1 p2 pk 9 Th theorems The h of f Fermat F and d Euler E l Fermat’ss little theorem Fermat If p is prime then, ap-11 1 (mod ( d p), ) for all integers a: 0 < a < p. Euler’s theorem If gcd (a,n)=1 then a(n) 1 (mod n), 10 L Legendre d &J Jacobi bi symbols b l L QR p be Let b the h set off quadratic d i residues id modd p andd let l QNR p Z p \ QR p be the set of quadratic nonresidues. For x Z p , p prime, the Legendre symbol of x mod p is : pe 1 if x QR p x p 1 if x QNR p Let n p1 p2 pk be the prime factorization of n. For x Z n , the Jakobi symbol of n mod p is : x x x x n p1 p2 pk 11 L Legendre d &J Jacobi bi symbols b l It is easy to see that x x ( p 1) / 2 (mod p ), for p prime. p 12 L Legendre d &J Jacobi bi symbols b l We have : 1 n x mn xy x y 1, and n n n x x m n x y If x y ((mod n ) then n n For m , n odd : 1 (n -1)/2 (-1) n 2 (n 2 -1)/8 (-1) n m n If gcd( m,n ) 1 and m , n 2 then (-1) (m -1)(n -1)/4 n m 13 E Example l Compute 7 4 and 15 15 14