Affine Cipher: WWW - Radford.edu
Affine Cipher: WWW - Radford.edu
Affine Cipher: WWW - Radford.edu
www.radford.edu
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.
6 2 3, 20 4 5 2 2 5, and 7 1 7 .
Two numbers that can be multiplied together to
get another number are called the factors or
divisors of that number. For example,
30 6 5 2
3
5
3
2
5 5
2
3
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.
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 3: Find the gcd(8, 12).
Solution:
8 can be expressed as:
2x2x2
gcd(8,12) = 4
Example 4: Find the gcd(54, 24).
Solution:
Example 4: Find the gcd(54, 24).
Solution:
54 can be expressed as:
2x3x3x3
gcd(54,24) = 6
Example 5: Find the gcd(15, 26).
Solution:
Example 5: Find the gcd(15, 26).
Solution:
15 can be expressed as:
3x5
gcd(15,26) = 1
Note
• Two numbers a and b where the gcd(a, b) 1
are said to be relatively prime.
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.
Fact
• In the modular arithmetic system, a
multiplicative inverse may or may not exist,
depending on the following fact involving the
gcd:
Solution:
Example 8: Does 8 have an inverse with respect
to the modulus 26?
Solution:
Solution:
Example 9: Does 9 have an inverse with
respect to the modulus 26?
Solution:
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:
Example 10: Use the multiplicative inverse table
1
to find 7 MOD 26.
Solution:
7-1 = 15
• 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.
If a b mod m, then
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
17 a 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 (3 x 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
22 (a 4 b) mod 26 (1)
4a b 22 mod 26
19 a b 7 mod 26
15a 15 mod 26
Since 15 MOD 26 11, we can write the
resulting equation from the subtraction as:
11a 15 mod 26
or
100 b 22 mod 26
Subtracting 100 from both sides gives