Chapter 6.1 Coding and Cryptography (Modular Arithmetic and Congruence)
Chapter 6.1 Coding and Cryptography (Modular Arithmetic and Congruence)
EXAMPLE:
ü Earth’s rotation around the sun,
24-hour clock cycle
ü 7 days a week
ü 60 minutes per hour
NOTE:
15 hours added to 18 hours does
not count 33 hours on the clock but
rather 9 hours.
§ Consider two integers x and y and a
natural number n. You can say that
“x and y are congruent modulo n”
(or “x is congruent to y modulo n”) if
the difference of x-y is exactly
divisible by n.
§ The symbol “ ≅ ” is used to denote
congruence.
§ The natural number n is commonly
termed as the modulus of the
congruence 𝒙 ≅ 𝒚.
§ In symbols, 𝒙 ≅ 𝒚 𝒎𝒐𝒅𝒖𝒍𝒐 𝒏
𝒙"𝒚
whenever is an integer.
𝒏
§ The modular value is the remainder
when a given number is divided by
the modulus.
§ The modular value should be less
than the modulus.
Example 1:
Verify the following congruence:
1. 27 ≅ 2 mod 5
2. 19 ≅ 4 mod 7
Example 2:
Evaluate the following operations.
1. 15 + 18 mod 9
2. 72 − 35 mod 11
3. 13 22 mod 6
4. 54 27 mod 23
Example 2:
Evaluate the following operations.
1. 15 + 18 mod 9
Solution:
15 + 18 = 33 = 9(3) + 6 (remainder)
𝟏𝟓 + 𝟖 𝐦𝐨𝐝 𝟗 ≅ 𝟔
OR
15 mod 9 ≅ 6 and 18 mod 9 ≅ 0
15 + 18 mod 9
≅ 15 mod 9 + 18 mod 9
≅ 6 + 0 mod 9 ≅ 6
𝟏𝟓 + 𝟖 𝐦𝐨𝐝 𝟗 ≅ 𝟔
Example 2:
Evaluate the following operations.
2. 72 − 35 𝑚𝑜𝑑 11
Solution:
72 - 35 = 37 = (11)(3) + 4 (remainder)
𝟕𝟐 − 𝟑𝟓 𝒎𝒐𝒅 𝟏𝟏 ≅ 𝟒
OR
72 𝑚𝑜𝑑 11 ≅ 6 and 35 𝑚𝑜𝑑 11 ≅ 2
72 − 35 𝑚𝑜𝑑 11
≅ 72 𝑚𝑜𝑑 11 − 35 𝑚𝑜𝑑 11
≅ 6 − 2 𝑚𝑜𝑑 11 ≅ 4
𝟕𝟐 − 𝟑𝟓 𝒎𝒐𝒅 𝟏𝟏 ≅ 𝟒
Example 2:
Evaluate the following operations.
3. 13 22 mod 6
Solution:
(13)(22) = 286 = (6)(47) + 4 (remainder)
𝟏𝟑)(𝟐𝟐 𝐦𝐨𝐝 𝟔 ≅ 𝟒
OR
13 mod 6 ≅ 1 and 22 mod 6 ≅ 4
13)(22 mod 6
≅ (13 mod 6)(22 mod 6)
≅ (1) 4 mod 6 ≅ 4
𝟏𝟑)(𝟐𝟐 𝐦𝐨𝐝 𝟔 ≅ 𝟒
Example 2:
Evaluate the following operations.
4. 54 27 mod 23
Solution:
(54)(27) = 1458 = (23)(63) + 9 (remainder)
𝟓𝟒)(𝟐𝟕 𝐦𝐨𝐝 𝟐𝟑 ≅ 𝟗
OR
54 mod 23 ≅ 8 and 27 mod 23 ≅ 4
54)(27 mod 23
≅ 54 mod 23 27 mod 23
≅ 8 4 mod 23 ≅ 32 mod 23 ≅ 9
𝟓𝟒)(𝟐𝟕 𝐦𝐨𝐝 𝟐𝟑 ≅ 𝟗
§ Additive Identity Element (0)
𝑟+0=0+𝑟 =𝑟
!
§ Multiplicative Inverse "
1 1
𝑟 = 𝑟 =1
𝑟 𝑟
§ For each integer m, an integer b is its
additive inverse modulo n if:
𝐦 + 𝐛 = 𝟎 𝐦𝐨𝐝 𝐧
§ Similarly, for each integer m, b is its
multiplicative inverse if:
𝐦 𝐛 = 𝟏 𝐦𝐨𝐝 𝐧
𝑥!. = 10 − 9 + 3 7 + 8 + 3 9 + 7 + 3 1 + 2 + 3 7 + 2 + 3 7 + 6 + 3 9 mod 10
𝑥!. = 10 − 154 mod 10
𝑥!. = 10 − 4
𝒙𝟏𝟑 = 𝟔
ANSWER: The check digit is 6.
INTERNATIONAL STANDARD BOOK NUMBER (ISBN)
Example 6:
b. Determine if the ISBN code 978 – 971 – 27 – 2770 – 4 is valid or not.
𝒙𝟏𝟑 = 𝟏𝟎 − 𝒙𝟏 + 𝟑𝒙𝟐 + 𝒙𝟑 + 𝟑𝒙𝟒 + 𝒙𝟓 + 𝟑𝒙𝟔 + 𝒙𝟕 + 𝟑𝒙𝟖 + 𝒙𝟗 + 𝟑𝒙𝟏𝟎 + 𝒙𝟏𝟏 + 𝟑𝒙𝟏𝟐 𝐦𝐨𝐝 𝟏𝟎
𝑥!. = 10 − 9 + 3 7 + 8 + 3 9 + 7 + 3 1 + 2 + 3 7 + 2 + 3 7 + 7 + 3 0 mod 10
𝑥!. = 10 − 128 mod 10
𝑥!. = 10 − 8
𝒙𝟏𝟑 = 𝟐
ANSWER: The ISBN code is NOT VALID.
UNIVERSAL PRODUCT CODE (UPC)
10 2 6 4 16 2 2 3 6 4 2 0 2 2 18 8
Doubled
(Alterna
te)
Sum = 1+0+2+6+4+1+6+2+2+3+6+4+2+0+2+2+1+8+8
= 60 ≅ 0 mod 10
12 0 2 1 0 1 4 3 18 1 8 5 4 3 2 7
Doubled
(Alterna
te)
Sum = 1+2+0+2+1+0+1+4+3+1+8+1+8+5+4+3+2+7
= 53 ≅ 3 mod 10