Introduction to Modular Arithmetic and Cryptography

advertisement
CS4390/5390 Fall 2013
Shirley Moore, Instructor
Preparation for Sept 5 class
Name __________________________________________
Introduction to Modular Arithmetic and Cryptography
Definitions and Background:
Cryptography (or cryptology) is the study of techniques for secure communication in
the presence of third parties, called adversaries. Cryptography involves encryption,
the conversion of information from a readable state, called plaintext, to apparent
nonsense, called the ciphertext. In cryptography, a key is a piece of information (a
parameter) that determines the functional output of a cryptographic algorithm or
cipher. Without a key, the algorithm would produce no useful result. In encryption, a
key specifies the particular transformation of plaintext into ciphertext, or vice versa
during decryption. There are two basic techniques for encrypting information:
symmetric encryption (also called secret key encryption) and asymmetric encryption
(also called public key encryption). When using a symmetric algorithm, both parties
share the same key for encryption and decryption. To provide privacy, this key
needs to be kept secret. Once somebody else gets to know the key, it is not safe any
more. Symmetric algorithms have the advantage of not consuming too much
computing power. An asymmetric algorithm uses a pair of keys. One is used for
encryption and the other one for decryption. The decryption key, called the private
key, is kept secret, while the encryption key is spread to all who might want to send
encrypted messages and is therefore called the public key. Anyone having the public
key is able to send encrypted messages to the owner of the private key. The private
key cannot be reconstructed from the public key. Asymmetric algorithms seem
ideally suited for real-world use. Because the private key does not have to be shared,
the risk of getting known is much smaller. Each user need only keep one private key
in secret and a collection of public keys. However, asymmetric algorithms are much
slower than symmetric ones. Therefore, in many applications, a combination of both
is used. The asymmetric keys are used for authentication and after this has been
successfully accomplished, one or more symmetric keys are generated and
exchanged using the asymmetric encryption.
Modern cryptography is heavily based on mathematical theory and computer
science practice. Cryptographic algorithms are designed around computational
hardness assumptions, making such algorithms hard to break in practice by any
adversary. It is theoretically possible to break such a system but it is infeasible to do
so by any known practical means. These schemes are termed computationally
secure. There exist information-theoretically secure schemes that provably cannot be
broken even with unlimited computing power—an example is the one-time pad—
but these schemes are more difficult to implement than the best theoretically
breakable but computationally secure mechanisms.
1
Modular arithmetic is key to understanding modern forms of encryption, and it also
demonstrates interesting properties of prime numbers. It incorporates "wrap
around" effects by having some number other than zero play the role of zero in
addition. For example, on a 12-hour clock, the number 12 behaves like zero, because
adding 12 hours to any time (ignoring A.M. or P.M. differences) yields the same time.
A typical addition problem in this scheme would be:
5 + 12 = 5
The number 17 is 5 + 1(12), which is equal to 5 in this system. Similarly, the number
29 is 5 + 2(12), which is also equal to 5, again because the number twelve is acting
like zero in this system. In such a system, 12 is called the modulus. To describe the
number 29, we would say that it is "congruent to 5 modulo 12", or 29 ≡ 5 mod 12.
Note that:
5 ≡ 5 mod 12
17 ≡ 5 mod 12
29 ≡ 5 mod 12
etc.
Any number of the form 5 + n(12) will be congruent to 5 in this system.
Exercises:
1. What is the clock time for 22 hours in a 24-hour world? ______ in a 12-hour world?
______ in a 10-hour world? _______
2. What is the clock time for 54 hours in a 12-hour world? ______ in a 6-hour world?
______ in a 9-hour world? _____ in a 17-hour world? ______
3. Can you find two different worlds such that 78 hours is 6 o’clock? 4 o’clock?
Explain.
4. Can you find two different worlds such that 16 hours is 4 o’clock? Explain.
Modular arithmetic has been used for thousands of years to encrypt messages, for
example by the Roman emperor Caesar. The Caesar cipher is a type of substitution
cipher in which each letter in the plaintext is replaced by a letter some fixed number
of positions down the alphabet. For example, with a left shift of 3, D would be
replaced by A, E would become B, and so on. The method is named after Julius
Caesar, who used it in his private correspondence. The encryption can also be
represented using modular arithmetic by first transforming the letters into
numbers, according to the scheme, A = 0, B = 1,..., Z = 25. Encryption of a letter x by a
shift B can be described mathematically as
E(x) = (x + B ) mod 26
2
Decryption is performed similarly
D(x) = (x – B) mod 26
5. Using a shift cipher with B=7, encrypt and then decrypt the message “JAMES IS A
SPY”.
6. A shift cipher can be broken fairly easily by brute force. Try to use brute force to
decode the message “EXXE GOEX SRGI”.
A shift cipher is a special case of a more general cipher called an affine cipher which
has the form (A*x + B) mod 26. Note that if A = 1 you have a shift cipher, and if B = 0
you have a multiplication cipher.
7. Encrypt the message “SIMPLE” using a multiplication cipher with A=7. Remember
to take your result for each letter mod 26 after you do the multiplication.
8. Now decrypt your answer from problem 7 to recover the original plaintext. To do
this, use the fact that the multiplicative inverse of 7 mod 26 is 15.
9. Now try to encrypt the message “SIMPLE ACT” using a multiplicative cipher with
A=6. Does this work? Why or why not?
10. A can only be used as the factor in a multiplication cipher to encrypt a message
from the alphabet of 26 letters if A has a multiplicative inverse mod 26.
a. Which of the elements of Z26 (the integers mod 26) have a multiplicative
inverse?
b. What is a necessary and sufficient condition for an element x in Z26 to have a
multiplicative inverse?
3
Download