1 / 55

Prime Numbers

Prime Numbers. The Fundamental Theorem of Arithmetic Every whole number can be factored uniquely into a product of prime number powers. For example, 123456789=3*3*3607*3803=3 2 *3607*3803 Prime numbers are the code for writing all whole numbers.

rufin
Download Presentation

Prime Numbers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Prime Numbers • The Fundamental Theorem of Arithmetic • Every whole number can be factored uniquely into a product of prime number powers. • For example, 123456789=3*3*3607*3803=32*3607*3803 • Prime numbers are the code for writing all whole numbers. • But factoring or decoding into primes is hard.

  2. Prime Numbers and Pretty Good Privacy

  3. Pretty good privacy • PGP is a tongue in cheek expression for an encryption scheme considered nearly impossible to break. • Use public key encryption based on products of large prime numbers

  4. Euclidean algorithm Eudoxus of Cnidus (about 375 BC), • function gcd(a, b) • if a = 0 return b • while b ≠ 0 • if a > b a := a − b • else b := b − a • return a

  5. Example: Find GCD(24,15) • a is not zero; a=24, b=15 • Reset a-> a-b=25-15=9 • Now 9<15 so reset b-> 15-9=6 • Now a=9>b=6 so reset a-> 9-6=3 • Now b=6>a=3 so reset b->6-3=3 • Now a=b so return a=3.

  6. Euclid’s algorithm: GCD The greatest common divisor of M and N is the largest whole number that divides evenly into both M and N GCD (6 , 15 ) = 3 If GCD (M, N) = 1 then M and N are called relatively prime. Euclid’s algorithm: method to find GCD (M,N)

  7. Euclid’s algorithm M and N whole numbers. Suppose M ≤ N. If N is divisible by M then GCD(M,N) = M. Otherwise, subtract from N the biggest multiple of M that is smaller than N. Call the remainder R. N=MK+R or R=MK-N. If Q divides into both M and N then Q divides into R. So: GCD(M,N) = GCD (M,R). Repeat until R divides into previous.

  8. Example: GCD (105, 77) 77 does not divide 105. Subtract 1*77 from 105. Get R=28 28 does not divide into 77. Subtract 2*28 from 77. Get R=77-56=21 Subtract 21 from 28. Get 7. 7 divides into 21. Done. GCD (105, 77) = 7.

  9. Example: GCD (105, 47) 47 does not divide 105. Subtract 2*47 from 105. Get R=11 11 does not divide into 47. Subtract 4*11 from 47. Get R=47-44=3 3 does not divide 11. Subtract 3*3 from 11. R=2 2 does not divide 3. Subtract 2 from 3. R=1 GCD (105, 47) = 1.

  10. Another example • gcd(1071,1029) • =gcd(1029,42) (42= 1071 mod 1029 • =gcd(42,21) (21= 1029 mod 42) • =gcd(21,0) (0= 42 mod 21) • =21: since b=0, we return a

  11. Run time of Euclidean (O(N^2)).Red: fast, blue: slow

  12. Clicker Exercise: find GCD (1221,121) The GCG of 1221 and 121 is: A) 2 B) 21 C) 11 D) 121 E) 1

  13. [GCD(6251,1473)=] • [1] • [3] • [7] • [11]

  14. Relatively prime • Two numbers M and N are called relatively prime if GCD(M,N)=1. • Example: Any prime number is relatively prime to any number other than itself. GCD(11,9)=1 • Example: Powers of different primes are relatively prime to one another. GCD(9,16)=1 • Two numbers are relatively prime iff their prime factorizations are distinct.

  15. Prime numbers • A whole number is called prime if it is relatively prime to every smaller whole number.

  16. Prime factorization theorem every natural number > 1 can be written as a unique product of prime numbers. • E.G: 6936=2 x 2 x 2 x 3 x 17 x 17=2^3 x 3 x 17^2 • 6936 ≠ any other product of prime powers • practically proved by Euclid, • first “ correct” proof in Disquisitiones Arithmeticae by Gauss.

  17. Large prime numbers Euclid: infinitely many prime numbers Proof: given a list of prime numbers, multiply all of them together and add one. This new number is not divisible by any number on our list. So either the new number is prime, or it is divisible by a prime not on the list.

  18. Euclid’s proof • Consider any finite set of primes. Multiply all of them together and add 1 (see Euclid number). Call this Q • Dividing Q by any of these would give a remainder of 1. • So Q is not divisible by any number in this list. • Any non-prime can be decomposed into a product of primes, • Either Q is prime itself, or there is a prime number in the decomposition of Q that is not in the original finite set of primes. • Either way, there is at least one more prime that was not in the finite set we started with. This argument applies no matter what finite set we began with. So there are more primes than any given finite number.

  19. Infinitude of primes • 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 … • list of prime numbers

  20. Testing for prime numbers • Is 97 a prime number? • How about 111? • How about 12345678987654321?

  21. Finding all prime numbers up to a given size • Sieve of Eratosthenes: Make a square whose side is at least the square root of the given number. Cross out all multiples of two, then all multiples of three, etc.

  22. Group work • Use the sieve of Eratosthenes to compute all primes from 1 to 480. Note that 22*22=484 so you only need to consider all multiples of primes up to 19 which is the largest prime less than 22.

  23. Computers can factor small prime numbers

  24. Primality test • algorithm to determine if “N is prime.” • Factorization is hard; primality testing is easy. • elliptic curve primality test O((log n)^6), • Log(n) is, approximately, the number of digits that n has. • The largest known prime has 17 million digits. Raising this to the 6th power gives a number with about 40 digits. If a computer can execute a trillion operations per second, we re talking on the order of 10^22 seconds. We are talking on the order of quadrillions of years.

  25. RSA 200 • RSA-200 = 2799783391122132787082946763872260162107044678695542853756000992932612840010 7609345671052955360856061822351910951365788637105954482006576775098580557613 579098734950144178863178946295187237869221823983 • RSA-200 = 3532461934402770121272604978198464368671197400197625023649303468776121253679 423200058547956528088349 × 7925869954478333033347085841480059687737975857364219960734330341455767872818 152135381409304740185467

  26. How long to factor RSA 200? • If a k-digit number is the product of two primes • No known algorithm can factor in polynomial time, i.e., that can factor it in time O(k^p) for some constant p. • There are algorithms faster than O((1+ε)^k) i.e., sub-exponential. • For a quantum computer, Peter Shor discovered an algorithm in 1994 that solves it in polynomial time O(N^3) and O(N) memory. • In 2001, the first 7-qubit quantum computer became the first to run Shor's algorithm. It factored the number 15 • GNFS: O(2^(N^(1/3))

  27. RSA competitions • German Federal Agency for Information Technology Security (BSI) team • On May 9, 2005, factored RSA-200, a 663-bit number (200 decimal digits), using the general number field sieve. • …later: RSA-640, a smaller number containing 193 decimal digits (640 bits), on November 4, 2005. • Both factorizations required several months of computer time using the combined power of 80 AMDOpteron CPUs.

  28. [The number 2*3*5*7*11+1=2311 is prime] • True • False

  29. There are lots of primes known to man • Prime number theorem: the number of primes less than or equal to N is on the order of N divided by log N. • http://en.wikipedia.org/wiki/Prime_number_theorem

  30. Largest known prime • 257,885,161 − 1 (2013) • 243,112,609 − 1. (2008)

  31. RSA

  32. RSA history • Algorithm described in 1977 by Ron Rivest, Adi Shamir, and Leonard Adleman at MIT; • Clifford Cocks, a British mathematician working for the UK intelligence agency GCHQ, described an equivalent system in an internal document in 1973. His discovery, however, was not revealed until 1997 due to its top-secret classification, and Rivest, Shamir, and Adleman devised RSA independently of Cocks' work. • MIT was granted U.S. Patent 4,405,829 for a "Cryptographic communications system and method" that used the algorithm in 1983. The patent would have expired in 2003, but was released to the public domain by RSA on 21 September 2000.

  33. Mathematical Cryptography • W.S. Jevons (1835—1882) • The Principles of Science: A Treatise on Logic and Scientific Method (1890s) 'direct' is “easy,” but ‘inverse’ is ‘hard’. encryption is easy; decryption is hard. Multiplication: easy, factoring: hard. Jevons anticipated RSA Algorithm

  34. Simple; multiply numbers • Difficult: factor numbers. • example 34537 x 99991=3453389167 (easy) • M=1459160519 = A xB • Find A and B (difficult) • Computer: check primes up to square-root (roughly 38000).

  35. The RSA encryption algorithm • N=PQ (product of two primes) • Φ(N) = (P-1)(Q-1) • Encryption key: 1<E<φ(N) such that • GCD(E , φ) = 1 • Decryption key: D such that • DE ≡ 1 mod (φ) • M< φ

  36. Encryption/Decryption • C=MEmod (N) • R=CD mod (N) • CLAIM: R=M (the original message)

  37. Short digression: modular arithmetic • A ≡ B mod (C) • Means that B is the remainder when C is divided into A • For example, 13 ≡ 1 mod (12) • If it is 3:30 now then in 13 hours it will be 4:30. • Shorthand: B=mod(A,C) • Arithmetic: • mod (MN, C)=mod(mod(M,C) x mod(N,C), C))

  38. Laws of exponents

  39. Examples • mod((13)25 ,12)= • mod((mod (13 ,12))25, 12)= • mod(125, 12)= mod(1, 12)= 1 • mod((14)25 ,12)= • mod((mod (14 ,12))25, 12)= • mod(225, 12)= mod(mod(24, 12)6 x mod(2,12), 12)= • mod(mod(4, 12)5 x2, 12)=mod(8 , 12)=8

  40. Proof of RSA • C=MEmod (N) • R=CDmod (N) = (MDmod (N))E mod (N) = • (MDEmod (N)) • DE ≡ 1 mod (N) • (M1mod (N)) =M (since M< N) • Fermat’s little theorem: aP-1≡ 1 mod (P)

  41. Plaintext to numbers

  42. Plaintext message • Kill Bill numerical version • Kill Bill == 11 09 12 12 00 02 09 12 12 • M=110912120002091212 • Note: M<φ so may need to send message in pieces, e.g. one letter at a time

  43. Example • 11 09 12 12 00 02 09 12 12 • N = 5 x 7 =35 • Φ=4x6=24 • E=11 then GCD (E, Φ)=1 • D=11 then DxE=121=5x24+1 • So DxE≡1 mod 24 • In this case decryption is just the inverse of encryption because E=D. Generally note true.

  44. EXERCISE • Use the cipher table above to decrypt the following ciphertext into plain text: • 0603012020100230 00 32040303 00 281020 301521 00 14153222100210 00 182120 00 09151420 00 24201511 00 200230041422

  45. Solution: • Flattery will get you nowhere, but don't stop trying

  46. How long to factor large products? what if the number to be factored is not ten digits, but rather 400 digits? square-root : 200 digits. lifetime of universe: approx. 10^{18} seconds. If computer could test one trillion factorizations per second, in the lifetime of the universe it could check 10^{30} possibilities. But there are 10^{200} possibilities.

  47. Pretty Good Privacy

  48. PGP • Based on “public key” cryptography • Binds public key to user name or email address • Authentication: “digital signature” used to verify identity of sender • integrity checking: used to detect whether a message has been altered since it was completed • Encryption: based on RSA/DSA • Decryption based on public key • Web of trust: third party vetting

More Related