{"id":66,"date":"2018-07-21T10:21:14","date_gmt":"2018-07-21T10:21:14","guid":{"rendered":"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=66"},"modified":"2018-12-27T09:58:09","modified_gmt":"2018-12-27T09:58:09","slug":"modular-arithmetic","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/chapter\/modular-arithmetic\/","title":{"rendered":"Modular Arithmetic"},"content":{"raw":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/7JJOCUEy_L8\" target=\"_blank\" rel=\"noopener\"><img src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a>\r\n<\/span><\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>Learning Objectives<\/strong>\r\n\r\n&nbsp;\r\n\r\n\u27a2\u00a0\u00a0 To understand the basics of Modular Arithmetic\r\n\r\n\u27a2\u00a0\u00a0 To learn about the binary operation\r\n\r\n\u27a2\u00a0\u00a0 To learn about the additive and multiplicative inverse\r\n\r\n\u27a2\u00a0\u00a0 Some examples related to these concepts\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>6.1 INTRODUCTION<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Modular arithmetic is a system of arithmetic for <a href=\"https:\/\/en.wikipedia.org\/wiki\/Integer\">integers, <\/a>where numbers \"wrap around\" upon reaching a certain value. Modular arithmetic allows us to easily create <a href=\"http:\/\/en.wikipedia.org\/wiki\/Group_%28mathematics%29\">groups, <\/a><a href=\"http:\/\/en.wikipedia.org\/wiki\/Ring_%28mathematics%29\">rings <\/a>and <a href=\"http:\/\/en.wikipedia.org\/wiki\/Field_%28mathematics%29\">fields <\/a>which are fundamental building blocks of most modern public-key cryptosystems.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">For example, <a href=\"http:\/\/en.wikipedia.org\/wiki\/Diffie%E2%80%93Hellman_key_exchange\">Diffie-Hellman <\/a>uses the multiplicative group of integers modulo a prime pp. There are other groups which would work.Modular or clock arithmetic is arithmetic on a circle instead of a number line modulo N , we use only the twelve whole numbers from 0 through N-1<\/p>\r\n&nbsp;\r\n\r\n1:00 and and 13:00 hours are the same(1=13mod12)\r\n\r\n<span style=\"font-size: 1em;text-align: initial\">1:00 and and 25:00 hours are the same(1=25mod12)<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>6.1.1 Usage of Modular Arithmetic<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Modular arithmetic is very well understood in terms of algorithms for various basic operations. That is one of thereason why we use finite fields (AES) in symmetric key cryptography. Cryptography requires hard problems. Some problems become hard with modular arithmetic. For example, logarithms are easy to compute over all integers . but can become hard to compute when you introduce a modular reduction. Similarly with finding roots. Mod-arithmetic is the central mathematical concept in cryptography. Almost any cipher from the Caesar Cipher to the RSA Cipher use it.There are two types of \u201cmod\u201d.<\/p>\r\n&nbsp;\r\n\r\nThe <strong>mod<\/strong> function\r\n\r\n&nbsp;\r\n\r\n\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 Inputs a number <em>a<\/em> and a base <em>b<\/em>\r\n\r\n\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 Outputs <em>a<\/em> <strong>mod<\/strong> <em>b<\/em> a number between 0 and <em>b<\/em> \u20131 inclusive\r\n\r\n\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 This is the remainder of a b\r\n\r\n\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 Similar to Java\u2019s % operator.\r\n\r\n\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 Relates two numbers <em>a, a\u2019<\/em> to each other relative some base <em>b<\/em>\r\n\r\n\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 <em>a a\u2019 <\/em>(mod<em> b<\/em>) means that<em> a <\/em>and<em> a\u2019 <\/em>have the same remainder when dividing by <em>b<\/em>\r\n\r\n&nbsp;\r\n\r\nSimilar to Java\u2019s \u201c%\u201d operator except that answer is always positive. E.G. -10 <strong>mod<\/strong> 3 = 2, but in Java \u201310%3 = -1.\r\n\r\n&nbsp;\r\n\r\nQ:\u00a0\u00a0\u00a0\u00a0 Compute\r\n\r\n&nbsp;\r\n\r\n1.\u00a0\u00a0\u00a0\u00a0\u00a0 113 <strong>mod<\/strong> 24\r\n\r\n2.\u00a0\u00a0\u00a0\u00a0\u00a0 -29 <strong>mod<\/strong> 7\r\n\r\n<\/div>\r\n&nbsp;\r\n<div>\r\n\r\n<strong>6.2 Congruent numbers<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Integers that leave the same remainder when divided by the modulus m are somehow similar, however, not identical. Such numbers are called \"congruent\". For instance, 1 and 13 and 25 and 37 are congruent mod 12 since they all leave the same remainder when divided by 12.<\/p>\r\n&nbsp;\r\n\r\nEquivalently: a mod b = a\u2019 mod b\r\n\r\n&nbsp;\r\n\r\nQ:\u00a0\u00a0\u00a0\u00a0 Which of the following are true?\r\n\r\n&nbsp;\r\n\r\n1.\u00a0\u00a0\u00a0\u00a0\u00a0 3\u00a0\u00a0 3 (mod 17)\r\n\r\n2.\u00a0\u00a0\u00a0\u00a0\u00a0 3\u00a0\u00a0 -3 (mod 17)\r\n\r\n3.\u00a0\u00a0\u00a0\u00a0\u00a0 172\u00a0\u00a0 177 (mod 5)\r\n\r\n4.\u00a0\u00a0\u00a0\u00a0\u00a0 -13\u00a0\u00a0 13 (mod 26)\r\n\r\n&nbsp;\r\n\r\nA:\r\n\r\n&nbsp;\r\n\r\n1.\u00a0\u00a0\u00a0\u00a0\u00a0 3 3 (mod 17) True. any number is congruent to itself (3-3 = 0, divisible by all)\r\n\r\n2.\u00a0\u00a0\u00a0\u00a0\u00a0 3\u00a0\u00a0 -3 (mod 17) False. (3-(-3)) = 6 isn\u2019t divisible by 17.\r\n\r\n3.\u00a0\u00a0\u00a0\u00a0\u00a0 172\u00a0\u00a0 177 (mod 5) True. 172-177 = -5 is a multiple of 5\r\n\r\n4.\u00a0\u00a0\u00a0\u00a0\u00a0 -13\u00a0\u00a0 13 (mod 26) True: -13-13 = -26 divisible by 26.\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The (mod) congruence is useful for manipulating expressions involving the mod function. It lets us view modular arithmetic relative a fixed base, as creating a number system inside of which all the calculations can be carried out.<\/p>\r\n&nbsp;\r\n\r\n\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 a mod b\u00a0\u00a0 a (mod b)\r\n\r\n\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 Suppose a\u00a0\u00a0 a\u2019 (mod b) and c\u00a0\u00a0 c\u2019 (mod b) Then:\r\n\r\n<\/div>\r\n<div>\r\n<p style=\"text-align: left;padding-left: 60px\">\u00a0 \u00a0 \u2013\u00a0 a+c\u00a0\u00a0\u00a0 (a\u2019+c\u2019 )(mod b)<\/p>\r\n<p style=\"text-align: left;padding-left: 60px\">\u2013\u00a0 ac\u00a0\u00a0 a\u2019c\u2019 (mod b)<\/p>\r\n<p style=\"text-align: left;padding-left: 60px\">\u2013\u00a0 a k\u00a0\u00a0 \u00a0a\u2019 k (mod b)<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>6.3Modular Addition<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">First add the two numbers, Secondly, divide the sum by the modulus to compute the remainder. In \"8-hour-land\" where a day lasts only 8 hours, we would add 12 and 9 as follows: First, 12+9 = 21, secondly 21 divided by the modulus 8 leaves a remainder of 5 since 21=2*8+5.<\/p>\r\n&nbsp;\r\n\r\n<strong>6.4 Modular Subtraction<\/strong>\r\n\r\n&nbsp;\r\n\r\nFirst subtract, secondly compute the remainder. Example 1: 25 - 8 = 17 MOD 12 = 5\r\n\r\nExample 2: 50 - 11 = 39 MOD 12 = 3\r\n\r\n&nbsp;\r\n\r\n<strong>6.5 Modular Multiplication<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">A mod expert would find the answer to 123 * 62 mod 12 immediately. It is 6.Without being a Gauss genius, she computes 123 mod 12 = 3 and 62 mod 12 = 2 and multiplies those two answers. To verify this: 123*62 mod 12 = 7626 mod 12 = 6. This computation aid is true for addition and subtraction as well<\/p>\r\n&nbsp;\r\n\r\n<strong>6.6 Computation Rules for Mod Arithmetic<\/strong>\r\n\r\n<\/div>\r\n<div>\r\n\r\n\u00a0 \u00a0 \u25cf\u00a0a + b mod m = (a mod m) + (b mod m)\r\n\r\n\u25cf\u00a0a - b mod m = (a mod m) - (b mod m)\r\n\r\n\u25cf\u00a0a * b mod m = (a mod m) * (b mod m)\r\n\r\n<\/div>\r\n<div>\r\n<p style=\"text-align: center\"><strong>Example 1: <\/strong>Addition Modulo 8<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-69 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-27.png\" alt=\"\" width=\"438\" height=\"587\" \/>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><strong>Example 3: <\/strong>Additive and Multiplicative inverses Modulo 7<\/p>\r\n\r\n<\/div>\r\n<img class=\"size-full wp-image-70 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-28.png\" alt=\"\" width=\"440\" height=\"460\" \/>\r\n<div>\r\n\r\n<strong>\u00a0 6.7 Properties of Modular Arithmetic<\/strong>\r\n\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-71 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-29.png\" alt=\"\" width=\"479\" height=\"321\" \/>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>6.8 Modular Arithmetic Examples<\/strong>\r\n\r\n&nbsp;\r\n\r\nQ:\u00a0\u00a0\u00a0\u00a0 Compute the following.\r\n\r\n&nbsp;\r\n\r\n<strong>1.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><strong>307<\/strong><sup><strong>1001<\/strong><\/sup><strong> mod 102<\/strong>\r\n\r\n<strong>2.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><strong>(-45 \u00b7 77) mod 17<\/strong>\r\n\r\n<strong>3.\u00a0\u00a0<img class=\"alignnone size-full wp-image-72\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-30.png\" alt=\"\" width=\"117\" height=\"65\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0<\/strong>\r\n\r\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><strong>\u00a0<\/strong>\r\n\r\n<strong><img class=\"alignnone size-full wp-image-73\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-31.png\" alt=\"\" width=\"540\" height=\"491\" \/>\u00a0<\/strong>\r\n\r\n<strong>\u00a0<\/strong><span style=\"text-align: initial;font-size: 1em\">Therefore, the answer is 0.<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>6.9 Proving Modular Identities<\/strong>\r\n\r\n&nbsp;\r\n\r\n<img class=\"alignnone size-full wp-image-74\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-32.png\" alt=\"\" width=\"548\" height=\"494\" \/>\r\n\r\n&nbsp;\r\n\r\n<strong>6.10 Simple Encryption and Decryption using Modular Arithmetic<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>6.10.1 Basic Steps involved in Encryption<\/strong>\r\n\r\n&nbsp;\r\n\r\nVariations on the following have been used to encrypt messages for thousands of years.\r\n\r\n&nbsp;\r\n\r\n1.\u00a0\u00a0\u00a0\u00a0\u00a0 Convert a message to capitals.\r\n\r\n2.\u00a0\u00a0\u00a0\u00a0\u00a0 Think of each letter as a number between 1 and 26.\r\n\r\n3.\u00a0\u00a0\u00a0\u00a0\u00a0 Apply an invertible modular function to each number.\r\n\r\n<span style=\"font-size: 1em;text-align: initial\">4.\u00a0\u00a0 Convert back to letters (0 becomes 26).<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>6.10.2 Encryption Example<\/strong>\r\n\r\n&nbsp;\r\n\r\nLet the encryption function be\r\n\r\n<em>f\u00a0 <\/em>(<em>a<\/em>) = (3<em>a<\/em> + 9) <strong>mod<\/strong> 26\r\n\r\n<span style=\"font-size: 1em;text-align: initial\">Encrypt \u201cStop Thief\u201d <\/span>\r\n\r\n<span style=\"font-size: 1em;text-align: initial\">1. STOP THIEF\u00a0\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">(capitals)<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">2. 19,20,15,16 20,8,9,5,6<\/span>\r\n\r\n<span style=\"font-size: 1em\">3. 14,17,2,5 17,7,10,24,1<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">4. NQBE QGJXA<\/span>\r\n\r\n<\/div>\r\n&nbsp;\r\n\r\n<strong>6.10.3 Decryption Example<\/strong>\r\n\r\n&nbsp;\r\n\r\nDecryption works the same, except that you apply the inverse function.\r\n\r\nExample: Find the inverse of\r\n\r\n<em>f <\/em>(<em>a<\/em>) = (3<em>a<\/em> + 9) mod 26\r\n\r\n<em>g <\/em>(<em>a<\/em>) = 3-1 (a - 9)\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">We\u2019ll see that since gcd(3,26) = 1, the inverse of 3 is actually well defined modulo 26 and is the number 9. This gives:<\/p>\r\n<em>g <\/em>(<em>a<\/em>) = 9 (a - 9) mod 26 = (9<em>a <\/em>\u2013 3) mod 26\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>Summary<\/strong>\r\n\r\n\u27a2 The basics of Modular Arithmetic is explored\r\n\r\n\u27a2 The Modular arithmetic operation is explored\r\n\r\n<table>\r\n<tbody>\r\n<tr>\r\n<td><strong>you can view video on Modular Arithmetic<\/strong><\/td>\r\n<td><a href=\"https:\/\/youtu.be\/7JJOCUEy_L8\" target=\"_blank\" rel=\"noopener\"><img class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n\r\n\r\n<img class=\"size-full wp-image-75 alignleft\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-33.png\" alt=\"\" width=\"641\" height=\"425\" \/>","rendered":"<div><span style=\"float: right\"><a href=\"https:\/\/youtu.be\/7JJOCUEy_L8\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"epgp books\" width=\"75px\" height=\"75px;\" \/><\/a><br \/>\n<\/span><\/div>\n<div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Learning Objectives<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u27a2\u00a0\u00a0 To understand the basics of Modular Arithmetic<\/p>\n<p>\u27a2\u00a0\u00a0 To learn about the binary operation<\/p>\n<p>\u27a2\u00a0\u00a0 To learn about the additive and multiplicative inverse<\/p>\n<p>\u27a2\u00a0\u00a0 Some examples related to these concepts<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>6.1 INTRODUCTION<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Modular arithmetic is a system of arithmetic for <a href=\"https:\/\/en.wikipedia.org\/wiki\/Integer\">integers, <\/a>where numbers &#8220;wrap around&#8221; upon reaching a certain value. Modular arithmetic allows us to easily create <a href=\"http:\/\/en.wikipedia.org\/wiki\/Group_%28mathematics%29\">groups, <\/a><a href=\"http:\/\/en.wikipedia.org\/wiki\/Ring_%28mathematics%29\">rings <\/a>and <a href=\"http:\/\/en.wikipedia.org\/wiki\/Field_%28mathematics%29\">fields <\/a>which are fundamental building blocks of most modern public-key cryptosystems.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">For example, <a href=\"http:\/\/en.wikipedia.org\/wiki\/Diffie%E2%80%93Hellman_key_exchange\">Diffie-Hellman <\/a>uses the multiplicative group of integers modulo a prime pp. There are other groups which would work.Modular or clock arithmetic is arithmetic on a circle instead of a number line modulo N , we use only the twelve whole numbers from 0 through N-1<\/p>\n<p>&nbsp;<\/p>\n<p>1:00 and and 13:00 hours are the same(1=13mod12)<\/p>\n<p><span style=\"font-size: 1em;text-align: initial\">1:00 and and 25:00 hours are the same(1=25mod12)<\/span><\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>6.1.1 Usage of Modular Arithmetic<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Modular arithmetic is very well understood in terms of algorithms for various basic operations. That is one of thereason why we use finite fields (AES) in symmetric key cryptography. Cryptography requires hard problems. Some problems become hard with modular arithmetic. For example, logarithms are easy to compute over all integers . but can become hard to compute when you introduce a modular reduction. Similarly with finding roots. Mod-arithmetic is the central mathematical concept in cryptography. Almost any cipher from the Caesar Cipher to the RSA Cipher use it.There are two types of \u201cmod\u201d.<\/p>\n<p>&nbsp;<\/p>\n<p>The <strong>mod<\/strong> function<\/p>\n<p>&nbsp;<\/p>\n<p>\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 Inputs a number <em>a<\/em> and a base <em>b<\/em><\/p>\n<p>\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 Outputs <em>a<\/em> <strong>mod<\/strong> <em>b<\/em> a number between 0 and <em>b<\/em> \u20131 inclusive<\/p>\n<p>\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 This is the remainder of a b<\/p>\n<p>\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 Similar to Java\u2019s % operator.<\/p>\n<p>\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 Relates two numbers <em>a, a\u2019<\/em> to each other relative some base <em>b<\/em><\/p>\n<p>\u25aa\u00a0\u00a0\u00a0\u00a0\u00a0 <em>a a\u2019 <\/em>(mod<em> b<\/em>) means that<em> a <\/em>and<em> a\u2019 <\/em>have the same remainder when dividing by <em>b<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Similar to Java\u2019s \u201c%\u201d operator except that answer is always positive. E.G. -10 <strong>mod<\/strong> 3 = 2, but in Java \u201310%3 = -1.<\/p>\n<p>&nbsp;<\/p>\n<p>Q:\u00a0\u00a0\u00a0\u00a0 Compute<\/p>\n<p>&nbsp;<\/p>\n<p>1.\u00a0\u00a0\u00a0\u00a0\u00a0 113 <strong>mod<\/strong> 24<\/p>\n<p>2.\u00a0\u00a0\u00a0\u00a0\u00a0 -29 <strong>mod<\/strong> 7<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>6.2 Congruent numbers<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Integers that leave the same remainder when divided by the modulus m are somehow similar, however, not identical. Such numbers are called &#8220;congruent&#8221;. For instance, 1 and 13 and 25 and 37 are congruent mod 12 since they all leave the same remainder when divided by 12.<\/p>\n<p>&nbsp;<\/p>\n<p>Equivalently: a mod b = a\u2019 mod b<\/p>\n<p>&nbsp;<\/p>\n<p>Q:\u00a0\u00a0\u00a0\u00a0 Which of the following are true?<\/p>\n<p>&nbsp;<\/p>\n<p>1.\u00a0\u00a0\u00a0\u00a0\u00a0 3\u00a0\u00a0 3 (mod 17)<\/p>\n<p>2.\u00a0\u00a0\u00a0\u00a0\u00a0 3\u00a0\u00a0 -3 (mod 17)<\/p>\n<p>3.\u00a0\u00a0\u00a0\u00a0\u00a0 172\u00a0\u00a0 177 (mod 5)<\/p>\n<p>4.\u00a0\u00a0\u00a0\u00a0\u00a0 -13\u00a0\u00a0 13 (mod 26)<\/p>\n<p>&nbsp;<\/p>\n<p>A:<\/p>\n<p>&nbsp;<\/p>\n<p>1.\u00a0\u00a0\u00a0\u00a0\u00a0 3 3 (mod 17) True. any number is congruent to itself (3-3 = 0, divisible by all)<\/p>\n<p>2.\u00a0\u00a0\u00a0\u00a0\u00a0 3\u00a0\u00a0 -3 (mod 17) False. (3-(-3)) = 6 isn\u2019t divisible by 17.<\/p>\n<p>3.\u00a0\u00a0\u00a0\u00a0\u00a0 172\u00a0\u00a0 177 (mod 5) True. 172-177 = -5 is a multiple of 5<\/p>\n<p>4.\u00a0\u00a0\u00a0\u00a0\u00a0 -13\u00a0\u00a0 13 (mod 26) True: -13-13 = -26 divisible by 26.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The (mod) congruence is useful for manipulating expressions involving the mod function. It lets us view modular arithmetic relative a fixed base, as creating a number system inside of which all the calculations can be carried out.<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 a mod b\u00a0\u00a0 a (mod b)<\/p>\n<p>\u2022\u00a0\u00a0\u00a0\u00a0\u00a0 Suppose a\u00a0\u00a0 a\u2019 (mod b) and c\u00a0\u00a0 c\u2019 (mod b) Then:<\/p>\n<\/div>\n<div>\n<p style=\"text-align: left;padding-left: 60px\">\u00a0 \u00a0 \u2013\u00a0 a+c\u00a0\u00a0\u00a0 (a\u2019+c\u2019 )(mod b)<\/p>\n<p style=\"text-align: left;padding-left: 60px\">\u2013\u00a0 ac\u00a0\u00a0 a\u2019c\u2019 (mod b)<\/p>\n<p style=\"text-align: left;padding-left: 60px\">\u2013\u00a0 a k\u00a0\u00a0 \u00a0a\u2019 k (mod b)<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>6.3Modular Addition<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">First add the two numbers, Secondly, divide the sum by the modulus to compute the remainder. In &#8220;8-hour-land&#8221; where a day lasts only 8 hours, we would add 12 and 9 as follows: First, 12+9 = 21, secondly 21 divided by the modulus 8 leaves a remainder of 5 since 21=2*8+5.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>6.4 Modular Subtraction<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>First subtract, secondly compute the remainder. Example 1: 25 &#8211; 8 = 17 MOD 12 = 5<\/p>\n<p>Example 2: 50 &#8211; 11 = 39 MOD 12 = 3<\/p>\n<p>&nbsp;<\/p>\n<p><strong>6.5 Modular Multiplication<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">A mod expert would find the answer to 123 * 62 mod 12 immediately. It is 6.Without being a Gauss genius, she computes 123 mod 12 = 3 and 62 mod 12 = 2 and multiplies those two answers. To verify this: 123*62 mod 12 = 7626 mod 12 = 6. This computation aid is true for addition and subtraction as well<\/p>\n<p>&nbsp;<\/p>\n<p><strong>6.6 Computation Rules for Mod Arithmetic<\/strong><\/p>\n<\/div>\n<div>\n<p>\u00a0 \u00a0 \u25cf\u00a0a + b mod m = (a mod m) + (b mod m)<\/p>\n<p>\u25cf\u00a0a &#8211; b mod m = (a mod m) &#8211; (b mod m)<\/p>\n<p>\u25cf\u00a0a * b mod m = (a mod m) * (b mod m)<\/p>\n<\/div>\n<div>\n<p style=\"text-align: center\"><strong>Example 1: <\/strong>Addition Modulo 8<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-69 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-27.png\" alt=\"\" width=\"438\" height=\"587\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-27.png 438w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-27-224x300.png 224w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-27-65x87.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-27-225x302.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-27-350x469.png 350w\" sizes=\"auto, (max-width: 438px) 100vw, 438px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><strong>Example 3: <\/strong>Additive and Multiplicative inverses Modulo 7<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-70 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-28.png\" alt=\"\" width=\"440\" height=\"460\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-28.png 440w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-28-287x300.png 287w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-28-65x68.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-28-225x235.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-28-350x366.png 350w\" sizes=\"auto, (max-width: 440px) 100vw, 440px\" \/><\/p>\n<div>\n<p><strong>\u00a0 6.7 Properties of Modular Arithmetic<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-71 aligncenter\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-29.png\" alt=\"\" width=\"479\" height=\"321\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-29.png 479w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-29-300x201.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-29-65x44.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-29-225x151.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-29-350x235.png 350w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>6.8 Modular Arithmetic Examples<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Q:\u00a0\u00a0\u00a0\u00a0 Compute the following.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><strong>307<\/strong><sup><strong>1001<\/strong><\/sup><strong> mod 102<\/strong><\/p>\n<p><strong>2.\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><strong>(-45 \u00b7 77) mod 17<\/strong><\/p>\n<p><strong>3.\u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-72\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-30.png\" alt=\"\" width=\"117\" height=\"65\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-30.png 117w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-30-65x36.png 65w\" sizes=\"auto, (max-width: 117px) 100vw, 117px\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0<\/strong><\/p>\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><strong>\u00a0<\/strong><\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-73\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-31.png\" alt=\"\" width=\"540\" height=\"491\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-31.png 540w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-31-300x273.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-31-65x59.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-31-225x205.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-31-350x318.png 350w\" sizes=\"auto, (max-width: 540px) 100vw, 540px\" \/>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><span style=\"text-align: initial;font-size: 1em\">Therefore, the answer is 0.<\/span><\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>6.9 Proving Modular Identities<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-74\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-32.png\" alt=\"\" width=\"548\" height=\"494\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-32.png 548w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-32-300x270.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-32-65x59.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-32-225x203.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-32-350x316.png 350w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>6.10 Simple Encryption and Decryption using Modular Arithmetic<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>6.10.1 Basic Steps involved in Encryption<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Variations on the following have been used to encrypt messages for thousands of years.<\/p>\n<p>&nbsp;<\/p>\n<p>1.\u00a0\u00a0\u00a0\u00a0\u00a0 Convert a message to capitals.<\/p>\n<p>2.\u00a0\u00a0\u00a0\u00a0\u00a0 Think of each letter as a number between 1 and 26.<\/p>\n<p>3.\u00a0\u00a0\u00a0\u00a0\u00a0 Apply an invertible modular function to each number.<\/p>\n<p><span style=\"font-size: 1em;text-align: initial\">4.\u00a0\u00a0 Convert back to letters (0 becomes 26).<\/span><\/p>\n<\/div>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>6.10.2 Encryption Example<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Let the encryption function be<\/p>\n<p><em>f\u00a0 <\/em>(<em>a<\/em>) = (3<em>a<\/em> + 9) <strong>mod<\/strong> 26<\/p>\n<p><span style=\"font-size: 1em;text-align: initial\">Encrypt \u201cStop Thief\u201d <\/span><\/p>\n<p><span style=\"font-size: 1em;text-align: initial\">1. STOP THIEF\u00a0\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">(capitals)<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">2. 19,20,15,16 20,8,9,5,6<\/span><\/p>\n<p><span style=\"font-size: 1em\">3. 14,17,2,5 17,7,10,24,1<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">4. NQBE QGJXA<\/span><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><strong>6.10.3 Decryption Example<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Decryption works the same, except that you apply the inverse function.<\/p>\n<p>Example: Find the inverse of<\/p>\n<p><em>f <\/em>(<em>a<\/em>) = (3<em>a<\/em> + 9) mod 26<\/p>\n<p><em>g <\/em>(<em>a<\/em>) = 3-1 (a &#8211; 9)<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">We\u2019ll see that since gcd(3,26) = 1, the inverse of 3 is actually well defined modulo 26 and is the number 9. This gives:<\/p>\n<p><em>g <\/em>(<em>a<\/em>) = 9 (a &#8211; 9) mod 26 = (9<em>a <\/em>\u2013 3) mod 26<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Summary<\/strong><\/p>\n<p>\u27a2 The basics of Modular Arithmetic is explored<\/p>\n<p>\u27a2 The Modular arithmetic operation is explored<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>you can view video on Modular Arithmetic<\/strong><\/td>\n<td><a href=\"https:\/\/youtu.be\/7JJOCUEy_L8\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-120\" src=\"http:\/\/epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/2018\/11\/download.png\" alt=\"\" width=\"36\" height=\"36\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-75 alignleft\" src=\"http:\/\/csp11.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/55\/2018\/07\/1-33.png\" alt=\"\" width=\"641\" height=\"425\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-33.png 641w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-33-300x199.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-33-65x43.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-33-225x149.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-content\/uploads\/sites\/55\/2018\/07\/1-33-350x232.png 350w\" sizes=\"auto, (max-width: 641px) 100vw, 641px\" \/><\/p>\n","protected":false},"author":3,"menu_order":5,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":["dr-kulothungan"],"pb_section_license":""},"chapter-type":[],"contributor":[58],"license":[],"class_list":["post-66","chapter","type-chapter","status-publish","hentry","contributor-dr-kulothungan"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/users\/3"}],"version-history":[{"count":6,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters\/66\/revisions"}],"predecessor-version":[{"id":531,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters\/66\/revisions\/531"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapters\/66\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/media?parent=66"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/pressbooks\/v2\/chapter-type?post=66"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/contributor?post=66"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp11\/wp-json\/wp\/v2\/license?post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}