Chnese Remander Introducton Theorem Dscrete Mathematcs Andre Bulatov
Dscrete Mathematcs Chnese Remander Theorem 34-2 Prevous Lecture Resdues and arthmetc operatons Caesar cpher Pseudorandom generators Inverse resdue Dvsors of 0
Dscrete Mathematcs Modular Arthmetc II 33-3 Lnear Congruences A congruence of the form ax b (mod m) where m s a postve nteger, a and b are ntegers, and x s a varable, s called a lnear congruence. We wll solve lnear congruences If a s relatvely prme wth m, then t has the nverse. Then 1 a a 1 1 a ax b (mod m) x b (mod m) Fnd the nverse of 3 modulo 7 Solve the lnear congruence 3x 4 (mod 7) a 1
Dscrete Mathematcs Chnese Remander Theorem 34-4 The Chnese Remander Theorem A lnear congruence s smlar to a sngle lnear equaton. What about systems of equatons (Sun Tzu s puzzle, 400 460 BC): There are certan thngs whose number s unknown. When dvded by 3, the remander s 2; when dvded by 5, the remander s 3; and when dvded by 7, the remander s 2. What wll be the number of thngs? Ths can be translated nto the followng queston: What are the solutons of the system of congruences x 2 (mod 3) x 3 (mod 5) x 2 (mod 7)
Dscrete Mathematcs Chnese Remander Theorem 34-5 The Chnese Remander Theorem (cntd) Theorem Let m1,m2, K, mk be parwse relatvely prme postve ntegers and a,a, K, arbtrary ntegers. Then the system 1 2 ak x a1 x a2 M x a k (mod m 1) (mod m ) (mod m has a unque soluton modulo m = m1 m2 K mk. (That s, there s a soluton x wth 0 x < m, and all other solutons are congruent modulo m to ths soluton.) 2 k )
Dscrete Mathematcs Chnese Remander Theorem 34-6 The Chnese Remander Theorem (cntd) Proof. We construct a soluton to ths system Set M = m for = 1,2,,k. Thus M s the product of all the m modul except for Snce m and m are relatvely prme when j, Therefore M has the nverse modulo m, that s y such that Let us set m j M y 1(mod Note that M j 0 (mod m ) whenever j, all terms except for the th term n ths sum are congruent to 0 modulo m. As My 1(mod m) we have x a M y a (mod m ) m ) 1M1y 1 + a2m2y2 + akmkyk x = a L+ gcd ( M,m ) 1 =
Dscrete Mathematcs Chnese Remander Theorem 34-7 Sun Tzu s Puzzle x 2 (mod 3) x 3 (mod 5) x 2 (mod 7)
Dscrete Mathematcs Chnese Remander Theorem 34-8 Fermat s Theorem Fermat s Great (Last) Theorem. n n For any n > 2, the equaton x + y = does not have nteger solutons x,y,z > 0 z n It had remaned unproven for 358 years (posed n 1637, proved n 1995) Andrew Wles proved t n 1995
Dscrete Mathematcs Chnese Remander Theorem 34-9 Fermat s Lttle Theorem Fermat s Lttle Theorem. If p s prme and a s an nteger not dvsble by p, then a p 1 1 (mod p) Clearly, t suffces to consder only resdues modulo p. Z 5 0 1 2 3 4 0 1 2 3 4 0 0 0 0 0 0 1 2 3 4 0 2 4 1 3 0 3 1 4 2 0 4 3 2 1
Dscrete Mathematcs Chnese Remander Theorem 34-10 Fermat s Lttle Theorem (cntd) Fermat s Lttle Theorem was mproved by Euler Fermat s Lttle Theorem mproved For any ntegers m and a such that they are relatvely prme ϕ a (m) 1 (mod m) where φ(m) denotes the Euler totent functon, the number of numbers 0 < k < m relatvely prme wth m Example: Z 8
Dscrete Mathematcs Publc Key Cryptography 35-11 Publc Key Cryptography Earler we consdered Caesar cpher. To encrypt and decrypt messages usng ths cpher one needs to know the key Caesar cpher uses the same key for encrypton and decrypton; t s secret, and f one knows the key he knows everythng. Publc key cryptosystems use a dfferent approach Such a system uses dfferent keys for encrypton and decrypton: Every person has a key for encrypton, and can wrte an encrypted message But ths does not help to decrypt the message
Dscrete Mathematcs Publc Key Cryptography 35-12 RSA Cryptosystem RSA stands for the names of the nventors: Rvest, Shamr, Adleman From left to rght: Ron Rvest Ad Shamr Len Adleman RSA key: a modulus n = pq, where p and q are large prme numbers (current standards are 128, 256, or 512 dgts each), n s publc whle p and q are secret, and an exponent e relatvely prme wth (p 1)(q 1)
Dscrete Mathematcs Publc Key Cryptography 35-13 RSA Encrypton In the RSA method, messages are translated nto an nteger (a short message) or a sequence of ntegers Let M be the plantext (the orgnal message). Then the cphertext s the resdue e C M (mod n) Example. Encrypt the message STOP usng the RSA cryptosystem wth p = 43 and q = 59, so that n = 43 59 = 2537, and wth e = 13. Note that gcd(e, (p 1)(q 1)) = gcd(13, 42 58) = 1 Soluton. Translate the letters of STOP nto ther numercal equvalents and group them nto groups of four: 1819 1415 13 Encrypt them usng C M (mod 2537). We get 13 13 1819 2081 (mod 2537) and 1415 2182(mod 2537) Thus, the encrypted message s 2081 2182
Dscrete Mathematcs Publc Key Cryptography 35-14 RSA Decrypton The decrypton key d s the nverse of e modulo (p 1)(q 1). It s secret! Snce gcd(e, (p 1)(q 1)) = 1, the nverse exsts. Indeed, de 1 (mod (p 1)(q 1)), therefore there s k such that de = 1 + k(p 1)(q 1). Hence d e d de 1+ k(p 1)(q 1) C (M ) M M (mod n) Note that φ(n) = n 1 1 1 1 = (p 1)(q 1) p q k(p 1)(q 1) ϕ(n) k By Fermat s Lttle Theorem, M = (M ) 1 (mod n) Hence, C M M Thus C d M (mod d k(p 1)(q 1) n) M (mod n)
Dscrete Mathematcs Publc Key Cryptography 35-15 Example We receve the encrypted message 0981 0461. What s the plantext f t was encrypted usng the RSA cpher from the prevous example. Soluton The encrypton keys were n = 43 59 and e = 13. It s not hard to see that d = 937 s the nverse of 13 modulo 42 58 = 2436. Therefore to decrypt a cpher block C, we compute 937 P C (mod n) In our case we have 937 0981 0704 (mod 2537) and 0461 937 1115 Thus the plantext s 0704 1115, that s HELP (mod 2537)
Dscrete Mathematcs Publc Key Cryptography 35-16 Why RSA Works The secrecy comes from the fact that t s ncredbly dffcult to fnd an nverse modulo a bg number f we do not know t. And we do not know (p 1)(q 1), as we do not know the prme decomposton of n = pq. However, t s also very dffcult to fnd a prme decomposton of a number f ts prme factors are bg. The most effcent factorzaton method known requres bllons of years of work of the fastest computers to factorze a 400-dgt number. We need n to be the product of 2 prme numbers, because the method works only f the message s relatvely prme wth n. Thus n needs to have very few dvsors.
Dscrete Mathematcs Chnese Remander Theorem 34-17 Homework Exercses from the Book: No. 1, 5, 9, 12, 20, 23 (page 696)