Section2 2
Section2 2
Section2 2
2: Affine Ciphers;
More Modular Arithmetic
Extra Problems
Find the following gcd’s Answers
a. gcd(30, 40) 10
b. gcd(150, 500) 50
c. gcd(187, 455) 1
In shift ciphers, messages are encrypted by using
an additive key. To increase security, we can, in
addition to an additive parameter, encipher
messages using a multiplicative parameter.
30 6 5 2 3 5
3 2
5 5 23
same prime factorization disregardi ng order
• An elementary way to obtain prime
factorizations with small prime factors involves
the use of a calculator and a factor tree. The
next two examples illustrate this technique.
Example 1: Factor 90
Solution:
Example 2: Factor 935
Solution:
Greatest Common Divisor
• The greatest common divisor of two
natural numbers a and b, denoted as
gcd(a, b) , is the largest natural number
that divides a and b with no remainder.
Elementary Method for Computing the gcd of
Two Numbers
Solution:
Example 4: Find the gcd(1190, 935).
Solution:
Example 5: Find the gcd(15, 26).
Solution:
Note
• Two numbers a and b where the gcd(a, b) 1
are said to be relatively prime.
Example 6: Fill in the ( ) for (2) 1, (10) 1,
and (a ) 1 if we are working in the real number
system.
Solution:
Multiplicative Inverses
• In the real number system, every non-zero
number has a multiplicative inverse – the
number you must multiply to a given
number to get 1.
*Note
• In some number systems, multiplicative
inverses in most cases do not exist.
Solution:
Fact
• In the modular arithmetic system, a
multiplicative inverse may or may not exist,
depending on the following fact involving the
gcd:
Solution:
Example 9: Does 9 have and inverse with
respect to the modulus 26?
Solution:
Later in the course, we will see a general
mathematical method for computing multiplicative
inverses. For now, since we will work with a MOD
26 system, we will display a table showing the
numbers in a MOD 26 with their multiplicative
inverses:
MOD 26 Multiplicative Inverse Table
a 1 3 5 7 9 11 15 17 19 21 23 25
a 1MOD 26 1 9 21 15 3 19 7 23 11 5 17 25
Example 10: Use the multiplicative inverse table
1
to find 7 MOD 26.
Solution:
• Multiplicative inverses expand our ability to solve
equations and congruences in modular
arithmetic. This is made possible using the
multiplicative property of modular arithmetic,
which we state next.
ka kb mod m
for any number k.
Example 11: Solve 11x 1 5 mod 26 for x.
Solution:
• Multiplicative inverses in modular arithmetic can
be useful in solving systems of linear equations,
which are useful for cryptanalysis. This next
example illustrates this fact.
Example 12: Solve the system of equations
(congruences)
8a b 18 mod 26
17a b 11 mod 26
Solution:
Mathematical Description of Affine
Ciphers
• Given a and b in Z 26 {0, 1, 2, , 24, 25}
where gcd(a, 26) 1.
Solution:
Note
Recall that for an affine cipher y (ax b) MOD 26
to be defined properly, gcd(a, 26) 1 .
Solution:
Deciphering an Affine Cipher
• For an affine cipher y (ax b) mod 26 where
gcd(a, 26) 1 , decipherment can be done
uniquely. Given the numerical representation of
the plaintext message x and ciphertext
message y , we take
y (ax b) mod 26
Example 15: Decipher the message
“ARMMVKARER” that was encrypted using the
affine cipher
y (3x 5) MOD 26
• Solution:
Cryptanalysis of Affine Ciphers
• For an affine cipher y (ax b) MOD 26, an
enemy must know the multiplicative
parameter a and additive parameter b in
order to decipher and break a message.
Once a and b are known,
x a 1 ( y b) MOD 26
can be computed and the message broken.
Two methods of attack can be used to
attempt to break an affine cipher.
Methods for Breaking and Affine Cipher
(1)
22 (a 4 b) mod 26
Plaintext T x 19corresponds to the ciphertext
H y 7which gives the equation
(2)
7 (a 19 b) mod 26
Rearranging and putting these equations together
gives
4a b 22 mod 26 (1)
19a b 7 mod 26 (2)
or
100 b 22 mod 26
Subtracting 100 from both sides gives