* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download howard
Survey
Document related concepts
Transcript
Howard Sueing Damina Townes October 28, 2009 Fundamentals of Algorithms HW 5A 1. (a) Breaking the Code I: A message is intercepted believed to be from “evildoers” allegedly containing the name of an American city that they wish to target. The message is believed to be encoded in Caesar type shift code with an unknown shift. Your task as a cryptanalyst is to quickly decode the name of the city so that appropriate precautions may be taken. The ciphertext received is “FYQFSYF” What is the corresponding plaintext? ABCDEFGHIJKLMNOPQRSTUVWXYZ The deciphered message reads: ATLANTA, therefore the unknown shift it equal to 21. (b) Breaking the Code II: The evildoers from part (a) realize that their code can be broken and switch to public key cryptography. They announce their public key as n=221, e=17 and dare anyone to crack their messages. Believing the cipher to be secure other evildoers send them the following message: 1 37 37 1 139 215 140 139 Taking into account that the terrorists are most likely using the standard encoding (A=1, B=2, C=3, etc.) crack this code to decipher the message. Public Key (n, e) = Public Key (221, 17) e=17 n=221 A T T A C K D C mod 221 = 1 mod 221 = 20 mod 221 = 20 mod 221 = 1 mod 221 = 3 mod 221 = 11 mod 221 = 4 mod 221 = 3 2. (a) Modulus: Find the value of 123456789123456789 mod 1111111111 123456789123456789 mod 1111111111 Applying modular Exponentiation, ab mod n = [(a mod n) (b mod n)] mod n = [(12345678961728394.5) mod (1111111111)] * [(12345678961728394.5) mod (1111111111)] mod (1111111111) =(652822468)*(652822468) mod (1111111111) = 914261588 The blow value returning function was used for the calculation: public static long modexp2(long x, long y, long z) { long result = 1; while (y > 0) { if((y %2) == 1) { result = (result * x) % z; y--; } x = (x * x) % z; y = y / 2; } return result; } (b) Fermat: Use the Fermat primality test to determine if the following numbers are prime. If you determine they are not prime please give the prime factorization. Fermat's little theorem states that if p is prime and 1 ≤ a ≤ n, then (a) 1,000,000,007 if n = 1,000,000,007 1 ≤ a ≤ 1,000,000,007 a=2 then using the online calculator provided, Therefore this number is prime. (b) 1,000,000,011 if n = 1,000,000,011 1 ≤ a ≤ 1,000,000,011 a=2 then using the online calculator provided, Therefore this number is not prime. The prime factorizations are: 3, 29, 11494253. mod n = 1 mod 1000000007 = 1 mod 1000000011 ≠ 1 (c) Suppose we do a Fermat test on a number n and we test 10 bases and n passes the test for each base. What is the probability that we are wrong and n is actually not prime? The Little Fermat Theorem applies for half of the numbers from 0 – (n-1). Therefore the probability of being wrong is 0.5.Finlly, k =10 (1/2)*k = (1/2)*10 = (1/1024)