Monday, Oct 29 Today we will talk about inverses in modular arithmetic, and the use of inverses to solve linear congruences. For your quiz in recitation this week, refer to these exercise generators: GCD as a linear combination Multiplicative inverse mod m Solve linear congruence Fermat's Little Theorem There is no online quiz this week. 1
Solving Linear Congruences (from Wednesday) EXERCISE 1. Find x such that 10x 33 (mod 7). A. 2 B. 4 C. 5 D. 6 E. None of these 2. Find x such that 10x 21 (mod 4) A. 0 B. 1 C. 2 D. 3 E. None of these On Wednesday, we used trial-and-error calculations to find that the answer for exercise 1 is B and the answer for exercise 2 is E. Note that, since 4 is a solution to the congruence in exercise 1, any other integer that is congruent to 4 (mod 7) will also be a solution, so there are infinitely many solutions. However, 4 is the unique positive solution that is less than the modulus 7. When we solve a linear congruence, we are always interested in the unique solution that is a positive integer less than the modulus m, if there is such a solution. 2
Also note that trial and error would not be practical if the modulus m were a much larger number, such as 230 or 1590090309007787699945731038830484828024036552967. On Wednesday, we mentioned that there is an algebraic method for efficiently deciding whether a linear congruence has a unique solution mod m, and for finding that solution (if it exists). The method involves using a multiplicative inverse. 3
Multiplicative inverses To solve linear congruences efficiently, first recall the idea of multiplicative inverse. For a nonzero real number a, the multiplicative inverse of a is the unique real number, denoted 1/a or a 1, having the property a a 1 = 1 We use the multiplicative inverse to solve linear equations in real numbers. For instance, to solve the linear equation 12x = 7 we multiply both sides of the equation by 1/12, the inverse of 12: 12x = 7 1 12 12x = 1 12 7 12 12 x = 7 12 1 x = 7 12 x = 7! 12 4
Multiplicative Inverses in Modular Arithmetic The multiplicative inverse (if it exists) of a mod m, denoted either a or a 1, is the unique integer having the property a 1 a 1 (mod m), 0<a 1 <m We can use the multiplicative inverse mod m to solve linear congruences in a manner similar to the use of the inverse to solve a linear equation in real numbers. The solution to ax b(mod m) is x = a 1 b(mod m) where a 1 is the multiplicative inverse of a mod m, if the inverse exists. 5
EXAMPLE Suppose we know that 2 4 1 (mod 7); that is, we know that the inverse of 4 mod 7 is 2. Then we can solve the linear congruence 4x 6 (mod 7) without having to resort to trial and error. 4x 6(mod 7) 2 4x 2 6(mod 7) 1 x (2 6)(mod 7) //because 2 4 mod 7 = 1 x = 12 mod 7 x = 5 Note that in modular arithmetic, where our domain is the set of integers, notation like 1/4 doesn t make sense, so we don t want to say that we multiplied both sides by ¼. 6
Theorem: (Existence of an inverse mod m) If a, m are integers, m>0, then there exists an integer a such that a a 1(mod m) if and only if GCD(a,m) = 1. In other words, the integer a will have an inverse mod m if and only if a, m, are relatively prime. This means that a linear congruence ax b (mod m) will have a unique solution (mod m) if and only gcd(m, a) = 1. Proof: 7
EXERCISE Which of these will have a unique solution 0<x<42 (that is, a unique solution mod 42)? A. 35x 19 (mod 42) B. 25x 19 (mod 42) C. Both A and B D. None of these 8
The proof of the previous theorem tells us not only how to tell if an integer a will have an inverse mod m, but it tells us how to find that inverse: 1. If gcd(m, a) > 1, then the inverse of a does not exist. 2. If gcd(m, a) = 1, use the extended Euclidean algorithm to write the linear combination 1 = ms + at. The coefficient t gives us a 1 : If 0<t<m, then t is the inverse of a. Otherwise, t mod m is the inverse of a. Corollary: The linear congruence ax b(mod m) will have a unique solution 0 x<m if and only if gcd(a, m) = 1. If gcd(a, m) 1, then there will be no solution, unless m is a multiple of a; in that case, there will be multiple solutions. 9
Example Find the inverse of 17(mod 31), and use it to solve the linear congruence 17x 15(mod 31) 10
MULTIPLICATIVE INVERSES in CRYPTOGRAPHY Modular arithmetic and inverses can be used to encrypt/decrypt messages, digital signatures, et c, as follows. First, our message M will be coded as an integer or block of integers. To encrypt our integer message M, pick a (large) modulus m and an encryption key e that is an integer that is relatively prime to m. (To be precise, the pair (e, m) is the encryption key). Let our encrypted message, C, be (e M) mod m. C = (e M) mod m is sent to recipients. To decrypt C, recipients multiply the encrypted message C by e 1. (e 1 C)mod m = (e 1 e M) mod m = M. 11
EXAMPLE Suppose our message is M = 58. Our intended recipients know that our encryption key is e = 418 with modulus m = 8335. Then our encrypted message is C = (418 58) mod 8335 = 24244 mod 8335 = 7574 We send our encrypted message: 7574. The recipient calculates that the multiplicative inverse of 418 mod 8335 is 6002 and uses that to decrypt our encrypted message: (6002 7574) mod 8335 = 45459148 mod 8335 =58 12