Primality Testing By Ho, Ching Hei Cheung, Wai Kwok.

Slides:



Advertisements
Similar presentations
RSA.
Advertisements

Number Theory Algorithms and Cryptography Algorithms Prepared by John Reif, Ph.D. Analysis of Algorithms.
WS Algorithmentheorie 03 – Randomized Algorithms (Primality Testing) Prof. Dr. Th. Ottmann.
Public Key Cryptosystems - RSA Receiver Sender Eavesdroppe r p q p q p q p and q prime.
22C:19 Discrete Structures Integers and Modular Arithmetic
BY : Darshana Chaturvedi.  INTRODUCTION  RSA ALGORITHM  EXAMPLES  RSA IS EFFECTIVE  FERMAT’S LITTLE THEOREM  EUCLID’S ALGORITHM  REFERENCES.
Week 3 - Friday.  What did we talk about last time?  AES  Public key cryptography.
Introduction to Modern Cryptography Lecture 6 1. Testing Primitive elements in Z p 2. Primality Testing. 3. Integer Multiplication & Factoring as a One.
Primality Testing Math 52 Jonathan Sands Work by: Megan Howley Yangxi Leng Juncai Liu.
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
7. Asymmetric encryption-
1 The RSA Algorithm Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
Great Theoretical Ideas in Computer Science.
RSA ( Rivest, Shamir, Adleman) Public Key Cryptosystem
The RSA Cryptosystem and Factoring Integers (II) Rong-Jaye Chen.
מבוא מורחב - שיעור 6 1 Lecture 6 High order procedures Primality testing The RSA cryptosystem.
Cryptography Lecture 11: Oct 12. Cryptography AliceBob Cryptography is the study of methods for sending and receiving secret messages. adversary Goal:
1 Lecture #10 Public Key Algorithms HAIT Summer 2005 Shimrit Tzur-David.
Public Key Cryptography
Public Encryption: RSA
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann.
Dr.Saleem Al_Zoubi1 Cryptography and Network Security Third Edition by William Stallings Public Key Cryptography and RSA.
“RSA”. RSA  by Rivest, Shamir & Adleman of MIT in 1977  best known & widely used public-key scheme  RSA is a block cipher, plain & cipher text are.
Codes, Ciphers, and Cryptography-RSA Encryption
The RSA Algorithm Based on the idea that factorization of integers into their prime factors is hard. ★ n=p . q, where p and q are distinct primes Proposed.
 Introduction  Requirements for RSA  Ingredients for RSA  RSA Algorithm  RSA Example  Problems on RSA.
Topic 18: RSA Implementation and Security
The RSA Algorithm Rocky K. C. Chang, March
Prime Numbers Prime numbers only have divisors of 1 and self
Cryptography A little number theory Public/private key cryptography –Based on slides of William Stallings and Lawrie Brown.
RSA Public Key Algorithm. RSA Algorithm history  Invented in 1977 at MIT  Named for Ron Rivest, Adi Shamir, and Len Adleman  Based on 2 keys, 1 public.
Section 4.3: Fermat’s Little Theorem Practice HW (not to hand in) From Barr Text p. 284 # 1, 2.
Cryptography Dec 29. This Lecture In this last lecture for number theory, we will see probably the most important application of number theory in computer.
Improving Encryption Algorithms Betty Huang Computer Systems Lab
Cryptography Lecture 7: RSA Primality Testing Piotr Faliszewski.
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
A Method for Obtaining Digital Signatures and Public-key Cryptosystems
Public-Key Encryption
1 Public-Key Cryptography and Message Authentication.
Algebra of RSA codes Yinduo Ma Tong Li. Ron Rivest, Adi Shamir and Leonard Adleman.
The RSA Algorithm. Content Review of Encryption RSA An RSA example.
22C:19 Discrete Structures Integers and Modular Arithmetic Fall 2014 Sukumar Ghosh.
Scott CH Huang COM 5336 Cryptography Lecture 6 Public Key Cryptography & RSA Scott CH Huang COM 5336 Cryptography Lecture 6.
Public Key Cryptosystems RSA Diffie-Hellman Department of Computer Engineering Sharif University of Technology 3/8/2006.
Chapter 9 Public Key Cryptography and RSA. Private-Key Cryptography traditional private/secret/single key cryptography uses one key shared by both sender.
Computer Security Lecture 5 Ch.9 Public-Key Cryptography And RSA Prepared by Dr. Lamiaa Elshenawy.
Week 4 - Wednesday.  What did we talk about last time?  Finished DES  AES.
Primality Testing. Introduction The primality test provides the probability of whether or not a large number is prime. Several theorems including Fermat’s.
RSA Cryptosystem Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS Spring 2006 Lecture 8Feb. 09, 2006Carnegie Mellon University.
RSA Algorithm Date: 96/10/17 Wun-Long Yang. Outline Introduction to RSA algorithm RSA efficient implementation & profiling.
MA/CSSE 473 Day 9 Primality Testing Encryption Intro.
Public Key Encryption Major topics The RSA scheme was devised in 1978
High order procedures Primality testing The RSA cryptosystem
Chapter Applications of Number Theory Some Useful Results
CS 2210:0001Discrete Structures Modular Arithmetic and Cryptography
Handbook of Applied Cryptography - CH4, from 4.1~4.3
Introduction to Number Theory
Public Key Cryptosystems - RSA
RSA Cryptosystem Bits PCs Memory MB ,000 4GB 1,020
Private-Key Cryptography
Number Theory and Euclidean Algorithm
Analysis of the RSA Encryption Algorithm
Where Complexity Finally Comes In Handy…
Where Complexity Finally Comes In Handy…
Introduction to Cryptography
Where Complexity Finally Comes In Handy…
Presentation transcript:

Primality Testing By Ho, Ching Hei Cheung, Wai Kwok

Introduction The primality test provides the probability of whether or not a large number is prime. Several theorems including Fermat’s theorem provide idea of primality test. Cryptography schemes such as RSA algorithm heavily based on primality test.

Definitions A Prime number is an integer that has no integer factors other than 1 and itself. On the other hand, it is called composite number. A primality testing is a test to determine whether or not a given number is prime, as opposed to actually decomposing the number into its constituent prime factors (which is known as prime factorization) Use multiple points if necessary.

Algorithms A Naïve Algorithm Pick any integer P that is greater than 2. Try to divide P by all odd integers starting from 3 to square root of P. If P is divisible by any one of these odd integers, we can conclude that P is composite. The worst case is that we have to go through all odd number testing cases up to square root of P. Time complexity is O(square root of N)

Algorithms (Cont.) Fermat’s Theorem Given that P is an integer that we would like to test that it is either a PRIME or not. And A is another integer that is greater than zero and less than P. From Fermat’s Theorem, if P is a PRIME, it will satisfy this two equalities: A^(p-1) = 1(mod P) or A^(p-1)mod P = 1 A^P = A(mod P) or A^P mod P = A For instances, if P = 341, will P be PRIME? -> from previous equalities, we would be able to obtain that: 2^(341-1)mod 341 = 1, if A = 2

Algorithms (Cont.) It seems that 341 is a prime number under Fermat’s Theorem. However, if A is now equal to 3: 3^(341-1)mod 341 = 56 !!!!!!!!! That means Fermat’s Theorem is not true in this case!  Time complexity is O(log n) 

Algorithms (Cont.) Rabin-Miller’s Probabilistic Primality Algorithm The Rabin-Miller’s Probabilistic Primality test was by Rabin, based on Miller’s idea. This algorithm provides a fast method of determining of primality of a number with a controllably small probability of error. Given (b, n), where n is the number to be tested for primality, and b is randomly chosen in [1, n- 1]. Let n-1 = (2^q)*m, where m is an odd integer. B^m = 1(mod n)  i  [0, q-1] such that b^(m2)^i = -1(mod n)

Algorithm (Cont.) If the testing number satisfies either cases, it will be said as “inconclusive”. That means it could be a prime number. From Fermat’s Theorem, it concludes 341 is a prime but it is 11 * 31! Now try to use Rabin-Miller’s Algorithm. Let n be 341, b be 2. then assume: q = 2 and m = 85 (since, n -1 = 2^q*m) 2^85 mod 341 = 32 Since it is not equal to 1, 341 is composite! Time complexity is O(log N)

RSA Algorithm The scheme was developed by Rivest, Shamir, and Adleman. The scheme was used to encrypt plaintext into blocks in order to prevent third party to gain access to private message.

RSA in action: 1. Pick two large prime numbers namely p and q and compute their product and set it as n. n = p*q

RSA in action (cont.): 2. Set public key to send the message. public key (e, n) such that: gcd(  (n), e) = 1; [1<e<  (n)] sender uses public key to encrypt the message before sending it to the recipient.

RSA in action (cont.): 3. Retrieve message using private key. at the recipient’s side, private key(d, n), such that ed = 1mod  (n), need to be obtained in order to get the original message through decryption.

Demonstration for RSA: Pick 2 primes: p=7, q=17 n = p*q n = 119 Compute:  (n) =  (119) =  (7*17) =  (7) *  (17) = 6 * 16 = 96 Find e such that gcd(  (n), e) = 1; [1<e<  (n)] gcd(e, 96) = 1 e = 5  public key(e, n)  Find d such that ed = 1mod  (n) 5d = 1mod96 5d = 96 * k +1, where k is some constant 5d = 96 * 4 + 1, assume k = 4 5d = 385 d = 77  private key(d, n) 

Demonstration for Encryption: ! Base on RSA and the result we got ! Encryption... (message = 19) C = M^e mod n = 19^5 mod 119 = mod 119 = 66

Demonstration for Decryption ! Base on RSA and the result we got ! Decryption... M = C^d mod n M = 66^77 mod 119 M = 1.27 * 10^140 mod 119 M = 19

Reference: An Online Calculator by Ulf Wostner from CCSF php php Definition of Rabin-Miller’s Probabilistic Primality Testing Definition of Primality Testing Primality Test for Applications F.PDF