MODULAR ARITHMETIC. Suppose I told you it was 10:00 a.m. What time is it 6 hours from now? The time you use everyday is a cycle of 12 hours, divided up into a cycle of 60 minutes. For every time you pass 12, you start over with 1 again. This is "mod 12" arithmetic. Let's set up a picture. You put 0 through 11 in a circle. Then to figure out what the answer to a modular math question, you begin at 0 and count around the clock a certain amount of times. The number you end up on is the answer. Example: We want to calculate 32 (mod 12). We start at 0 and go all the way back to 0. This uses up 12 of the hours. We have 32-12 =20 left. We go around again. We have 20-12 = 8 left. Therefore 32 (mod 12) is equal to 8 or 32 8 (mod 12) What is 27 (mod 12)? What is 38 (mod 12)? What is -7 (mod 12)? What about 155 mod 12? QUESTION: Why do you think we label the clock 0 through 11, instead of 1-12? Okay, now try 155 mod 12 again.
Classwork: 1. It would be mod if we did minutes instead of hours. 2. Where would the minute hand be 342 minutes from 10:00? 3. What time would it be (including the hour) for problem 2? 4. If it is 10:50 now, what time will it be in 268 minutes? 5. What month would it be 43 months from now? 6. If it is 1:00 right now, what time was it 76 hours ago? 7. Today is March 17, 2005, which is also known as St. Patrick s Day. Which day of the week will St. Patrick s Day fall on NEXT YEAR? 8. Try to figure out which day of the week you were born on? Remember that there are 365 days in most years and 366 days in leap years (.,1992, 1996, 2000, 2004,.).
CRYPTOGRAPHY We hope you understood the modular arithmetic lesson. This kind of mathematics is used in defending the United States and other countries during wars and other times when there is information that has to be kept confidential. It was used during the Civil War in the 1860's and even thousands of years ago during Caesar's Roman Empire. People who wanted to communicate with allies but not their enemies would send encrypted messages back and forth. An encrypted message takes the letters and numbers of a message and transforms them into a different series of letters and numbers that do not make sense unless you know the code to unscramble them. If you know the code, then you can read the message. Amazingly complex scrambling procedures can stump highly trained people and even computers. We will talk about simple ciphers. A cipher is the method by which you encrypt a message. Before we begin, we must first create a numerical alphabet by assigning numbers, beginning with zero, to each letter of the alphabet. A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Most ciphers use modular arithmetic during some steps of the encryption and decryption process. We have used the numbers 0 through 25 to represent English letters, so we will use mod 26 in all our cipher examples.
SHIFT CIPHER We will encipher the message BRIAN IS A SPY using a shift cipher of 7, or a shift key of 7. Step 1: We translate our message into our numerical alphabet. B R I A N I S A S P Y Step 2: We now shift our cipher by adding our shift value (7) to each of the numbers from our codewords. B: I: S: R: S: P: I: Y: A: A: N: Step 3: We now translate the numbers back into our letters using our numerical alphabet. So BRIAN IS A SPY becomes To make life harder for spies, most encrypters remove punctuation and group the letters in "words" that are usually five letters long. Therefore BRIAN IS A SPY, with a shift key of 7, is really written: Another Example: Encipher the message Shamrock Shake using a shift key of 20. DECIPHERING AN ENCODED MESSAGE. Suppose you know the shift key is 10. Decrypt the following message. (What would you need to do to each letter to get your original letter back?) MBIZD YQBKZ RI
Using Frequency of Letters to help us out, if we are using a shift cipher Table 1: Frequency of occurrence of the 26 Letters in a random sample of 100 characters Letter Frequency Letter Frequency A 8.167 N 6.749 B 1.492 O 7.507 C 2.782 P 1.929 D 4.253 Q 0.095 E 12.702 R 5.987 F 2.228 S 6.327 G 2.015 T 9.056 H 6.094 U 2.758 I 6.966 V 0.978 J 0.153 W 2.360 K 0.772 X 1.974 L 4.025 Y 0.074 M 2.406 Z 0.074 Suppose we have the following ciphertext, which has been enciphered using the shift cipher: DPYOT YCPTY QZCNP XPYED TXXPO TLEPW J 1. What is the most frequent letter used in this ciphertext? 2. If is e, then our key is. If is e, then our key is 3. Decode the message using the cheat sheet handout for each of the possible keys.
0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 B C D E F G H I J K L M N O P Q R S T U V W X Y Z A 2 C D E F G H I J K L M N O P Q R S T U V W X Y Z A B P 3 D E F G H I J K L M N O P Q R S T U V W X Y Z A B C l 4 E F G H I J K L M N O P Q R S T U V W X Y Z A B C D a 5 F G H I J K L M N O P Q R S T U V W X Y Z A B C D E i 6 G H I J K L M N O P Q R S T U V W X Y Z A B C D E F n 7 H I J K L M N O P Q R S T U V W X Y Z A B C D E F G t 8 I J K L M N O P Q R S T U V W X Y Z A B C D E F G H e 9 J K L M N O P Q R S T U V W X Y Z A B C D E F G H I x 10 K L M N O P Q R S T U V W X Y Z A B C D E F G H I J t 11 L M N O P Q R S T U V W X Y Z A B C D E F G H I J K 12 M N O P Q R S T U V W X Y Z A B C D E F G H I J K L 13 N O P Q R S T U V W X Y Z A B C D E F G H I J K L M 14 O P Q R S T U V W X Y Z A B C D E F G H I J K L M N 15 P Q R S T U V W X Y Z A B C D E F G H I J K L M N O 16 Q R S T U V W X Y Z A B C D E F G H I J K L M N O P 17 R S T U V W X Y Z A B C D E F G H I J K L M N O P Q 18 S T U V W X Y Z A B C D E F G H I J K L M N O P Q R 19 T U V W X Y Z A B C D E F G H I J K L M N O P Q R S 20 U V W X Y Z A B C D E F G H I J K L M N O P Q R S T 21 V W X Y Z A B C D E F G H I J K L M N O P Q R S T U 22 W X Y Z A B C D E F G H I J K L M N O P Q R S T U V 23 X Y Z A B C D E F G H I J K L M N O P Q R S T U V W 24 Y Z A B C D E F G H I J K L M N O P Q R S T U V W X 25 Z A B C D E F G H I J K L M N O P Q R S T U V W X Y
MULTIPLICATION CIPHER This is similar to the shift cipher, except that you multiply and divide instead of add and subtract. We'll start with a simple example. Let's work with the word SIMPLE SIMPLE in the numeric alphabet is 1) We will use the "multiplier" 7. Multiply the numeric alphabet numbers each by the "multiplier" and do (mod 26). S becomes I becomes M becomes P becomes L becomes E becomes 2) Use the multiplier 10 and encrypt the word FANS. (F =5, A = 0, N = 13, S = 18) 3) Does this seem right to you? Why do you think this happened? 4) Which multipliers will be okay when doing (mod 26)? Decrypting a multiplier cipher How do we decrypt a message using the multiplication cipher? We already know that SIMPLE encrypted with multiplier 7 is WEGBZC. How do we get back to SIMPLE from WEGBZC? Before we answer this question, let s first go back to something we already know how to do. If we wanted to solve 7x=33, we multiply 7 by its multiplicative inverse 1/7. This gives us 1 on the left hand side. Decipher WEGBZC: we need to multiply each number by the inverse of 7 in modular arithmetic. The inverse of 7 (mod 26) is a number N so that 7*N is equal to 1 (mod 26). 5) What is the inverse of 7 (mod 26)? 6) Now multiply each letter in WEGBZC by your answer to get back to SIMPLE