unit 3 part 1
unit 3 part 1
Session: 2024-25
gcd (17, 0) = 17, s = 1, and t = 0. This indicates why we should initialize s1 to 1 and t1 to 0. The answers
can be tested as shown below:
(1 × 17) + (0 × 0) = 17
Given a = 0 and b = 45, find gcd
(a, b) and the values of s and t.
We get gcd (0, 45) = 45, s = 0, and t = 1. This indicates why we should initialize s2 to 0 and t2 to 1.
The answer can be tested as shown below:
(0 × 0) + (1 × 45) = 45
Using the extended Euclidean algorithm, find the gcd of the following pairs
and the value of s and t.
a mod n = r
• 27 mod 5 : r = 2.
• −18 mod 14: r = −4. However, we need to add the modulus (14) to
make it nonnegative. We have r = −4 + 14 = 10. This means that −18
mod 14 = 10.
Set of Residues: Zn
• The result of the modulo operation with modulus n is always an
integer between 0 and n − 1. We can say that the modulo operation
creates a set, which in modular arithmetic is referred to as the set of
least residues modulo n, or Zn.
Congruence
• In cryptography, we often used the concept of congruence instead of
equality. Mapping from Z to Zn is not one-to-one. Infinite members of
Z can map to one member of Zn. For example, the result of 2 mod 10
= 2, 12 mod 10 = 2, 22 mod 2 = 2, and so on. In modular arithmetic,
integers like 2, 12, and 22 are called congruent mod 10. To show that
two integers are congruent, we use the congruence operator (≡). We
add the phrase (mod n) to the right side of the congruence to define
the value of modulus that makes the relationship valid. For example,
we write:
Residue Classes
• A residue class [a] or [a]n is the set of integers congruent modulo n. In
other words, it is the set of all integers such that x = a (mod n). For
example, if n = 5, we have five sets [0], [1], [2], [3], and [4] as shown
below:
• [0] = {…, −15, −10, −5, 0, 5, 10, 15, …}
• [1] = {…, −14, −9, −4, 1, 6, 11, 16, …}
• [2] = {…, −13, −8, −3, 2, 7, 12, 17, …}
• [3] = {…, −12, −7, −5, 3, 8, 13, 18, …}
• [4] = {…, −11, −6, −1, 4, 9, 14, 19, …}
Operations in Zn
• Perform the following operations (the inputs come from Zn):
a. Add 7 to 14 in Z15.
b. Subtract 11 from 7 in Z13.
c. Multiply 11 by 7 in Z20.
Sol.:
(14 + 7) mod 15 → (21) mod 15 = 6
(7 − 11) mod 13 → (−4) mod 13 = 9
(7 × 11) mod 20 → (77) mod 20 = 17
Properties
• First Property: (a + b) mod n = [(a mod n) + (b mod n)] mod n
• Second Property: (a − b) mod n = [(a mod n) − (b mod n)] mod n
• Third Property: (a × b) mod n = [(a mod n) × (b mod n)] mod n
The following shows the application of the above properties:
1. (1,723,345 + 2,124,945) mod 11 = (8 + 9) mod 11 = 6
2. (1,723,345 − 2,124,945) mod 16 = (8 − 9) mod 11 = 10
3. (1,723,345 × 2,124,945) mod 16 = (8 × 9) mod 11 = 6
• To find 10 mod 3, 102 mod 3, 103 mod 3, and so on or to find 10 mod
7, 102 mod 7, 103 mod 7, and so. The third property of the mod
operator is used as:
10n mod x = (10 mod x)n mod x Applying the third property n times.
The gcd (26, 11) is 1, which means that the multiplicative inverse of 11 exists. The
extended Euclidean algorithm gives t1 = −7. The multiplicative inverse is (−7) mod 26 = 19.
In other words, 11 and 19 are multiplicative inverse in Z26. We can see that (11 × 19) mod
26 = 209 mod 26 = 1.
Solve
3x + 5y + 7z ≡ 3 (mod 16)
x + 4y + 13z ≡ 5 (mod 16)
2x + 7y + 3z ≡ 4 (mod 16)
Practice Questions
The following shows the remainders of powers of 10 when divided by 7. We can
prove that the pattern will be repeated for higher powers.
100 mod 7 = 1 101 mod 7 = 3 102 mod 7 = 2
103 mod 7 = −1 104 mod 7 = −3 105 mod 7 = −2
Using the above information, find the remainder of an integer when divided by 7.
Test your method with 631453672.
Solution: The pattern will repeat every 6 powers because 106mod 7=1, starting the
cycle again.
• For 631453672:
631453672=6⋅108+3⋅107+1⋅106+4⋅105+5⋅104+3⋅103+6⋅102+7⋅101+2. 100
106mod7=1 107mod 7=3 108mod 7=2 (since 108=102⋅106 )
calculate the remainders: 12 mod 7 + 9 mod 7 + 1 mod 7 + (-8) mod7 + (-15)
mod 7+ (-3)mod 7+ 12 mod 7 +21 mod 7 + 2 mod 7 =10 mod 7 = 3
The remainder of 631453672 when divided by 7 is 3
Find all solutions to each of the following linear equations:
a. 3x ≡ 4 (mod 5)
b. 4x ≡ 4 (mod 6)
c. 9x ≡ 12 (mod 7)
d. 256x ≡ 442 (mod 60)
Find all solutions to the following sets of linear equations:
a. 3x + 5y ≡ 4 (mod 5)
b. 2x + y ≡ 3 (mod 5)
c. 3x + 2y ≡ 5 (mod 7)
d. 4x + 6y ≡ 4 (mod 7