Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann.

Slides:



Advertisements
Similar presentations
1 Complexity ©D.Moshkovitz Cryptography Where Complexity Finally Comes In Handy…
Advertisements

CS 483 – SD SECTION BY DR. DANIYAL ALGHAZZAWI (4) Information Security.
Asymmetric-Key Cryptography
WS Algorithmentheorie 03 – Randomized Algorithms (Primality Testing) Prof. Dr. Th. Ottmann.
MS 101: Algorithms Instructor Neelima Gupta
Primality Testing Patrick Lee 12 July 2003 (updated on 13 July 2003)
BY : Darshana Chaturvedi.  INTRODUCTION  RSA ALGORITHM  EXAMPLES  RSA IS EFFECTIVE  FERMAT’S LITTLE THEOREM  EUCLID’S ALGORITHM  REFERENCES.
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 By Ho, Ching Hei Cheung, Wai Kwok.
COM 5336 Cryptography Lecture 7a Primality Testing
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
WS Algorithmentheorie 03 – Randomized Algorithms (Overview and randomised Quicksort) Prof. Dr. Th. Ottmann.
Great Theoretical Ideas in Computer Science.
Session 4 Asymmetric ciphers.
Dr. Lo’ai Tawalbeh Summer 2007 Chapter 9 – Public Key Cryptography and RSA Dr. Lo’ai Tawalbeh New York Institute of Technology (NYIT) Jordan’s Campus INCS.
OOP/Java1 Public Key Crytography From: Introduction to Algorithms Cormen, Leiserson and Rivest.
RSA ( Rivest, Shamir, Adleman) Public Key Cryptosystem
Public Key Crytography1 From: Introduction to Algorithms Cormen, Leiserson and Rivest.
Randomized Algorithms Prof. Dr. Th. Ottmann University of Freiburg
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
Public Key Cryptography and the RSA Algorithm
Cryptography1 CPSC 3730 Cryptography Chapter 9 Public Key Cryptography and RSA.
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
Private-Key Cryptography traditional private/secret/single key cryptography uses one key shared by both sender and receiver if this key is disclosed communications.
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
Dr.Saleem Al_Zoubi1 Cryptography and Network Security Third Edition by William Stallings Public Key Cryptography and RSA.
1 Pertemuan 08 Public Key Cryptography Matakuliah: H0242 / Keamanan Jaringan Tahun: 2006 Versi: 1.
Public Key Model 8. Cryptography part 2.
 Introduction  Requirements for RSA  Ingredients for RSA  RSA Algorithm  RSA Example  Problems on RSA.
Andreas Steffen, , 4-PublicKey.pptx 1 Internet Security 1 (IntSi1) Prof. Dr. Andreas Steffen Institute for Internet Technologies and Applications.
Prime Numbers Prime numbers only have divisors of 1 and self

J. Wang. Computer Network Security Theory and Practice. Springer 2008 Chapter 3 Public-Key Cryptography and Key Management.
Great Theoretical Ideas in Computer Science.
Cryptography: RSA & DES Marcia Noel Ken Roe Jaime Buccheri.
Chapter 14 Randomized algorithms Introduction Las Vegas and Monte Carlo algorithms Randomized Quicksort Randomized selection Testing String Equality Pattern.
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.
Public Key Cryptography By: Noor Dhia Al- Shakarchy.
Cryptography Lecture 7: RSA Primality Testing Piotr Faliszewski.
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
Information Security -- Part II Public-Key Encryption and Hash Functions Frank Yeong-Sung Lin Information Management Department National Taiwan University.
Public Key Cryptography. symmetric key crypto requires sender, receiver know shared secret key Q: how to agree on key in first place (particularly if.
Cryptography and Network Security Chapter 9 - Public-Key Cryptography
PUBLIC-KEY CRYPTOGRAPH IT 352 : Lecture 2- part3 Najwa AlGhamdi, MSc – 2012 /1433.
Cryptography and Network Security Public Key Cryptography and RSA.
Chapter 3 – Public Key Cryptography and RSA (A). Private-Key Cryptography traditional private/secret/single-key cryptography uses one key shared by both.
Chapter 9 Public Key Cryptography and RSA. Private-Key Cryptography traditional private/secret/single key cryptography uses one key shared by both sender.
ENCRYPTION TAKE 2: PRACTICAL DETAILS David Kauchak CS52 – Spring 2015.
PUBLIC-KEY CRYPTOGRAPHY AND RSA – Chapter 9 PUBLIC-KEY CRYPTOGRAPHY AND RSA – Chapter 9 Principles Applications Requirements RSA Algorithm Description.
CS Modular Division and RSA1 RSA Public Key Encryption To do RSA we need fast Modular Exponentiation and Primality generation which we have shown.
Ch1 - Algorithms with numbers Basic arithmetic Basic arithmetic Addition Addition Multiplication Multiplication Division Division Modular arithmetic Modular.
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
Computer Security Lecture 5 Ch.9 Public-Key Cryptography And RSA Prepared by Dr. Lamiaa Elshenawy.
Primality Testing. Introduction The primality test provides the probability of whether or not a large number is prime. Several theorems including Fermat’s.
Lecture 3 (Chapter 9) Public-Key Cryptography and RSA Prepared by Dr. Lamiaa M. Elshenawy 1.
ECE454/599 Computer and Network Security Dr. Jinyuan (Stella) Sun Dept. of Electrical Engineering and Computer Science University of Tennessee Fall 2012.
Chapter 9 – Public Key Cryptography and RSA Every Egyptian received two names, which were known respectively as the true name and the good name, or the.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Cryptography RSA Algorithm BY : Wesam Fadheel Computer science department - WMU CS-6800 Advanced Theory of Computation Instructor: Dr. Elise De Doncker.
CSEN 1001 Computer and Network Security Amr El Mougy Mouaz ElAbsawi.
Lecture 5 Asymmetric Cryptography. Private-Key Cryptography Traditional private/secret/single key cryptography uses one key Shared by both sender and.
Public Key Encryption Major topics The RSA scheme was devised in 1978
Public Key Encryption.
Private-Key Cryptography
ICS 353: Design and Analysis of Algorithms
Where Complexity Finally Comes In Handy…
Where Complexity Finally Comes In Handy…
Where Complexity Finally Comes In Handy…
Presentation transcript:

Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann

2 Randomized algorithms Classes of randomized algorithms Randomized Quicksort Randomized primality test Cryptography

3 1. Classes of randomized algorithms Las Vegas algorithms always correct; expected running time (“probably fast”) Example: randomized Quicksort Monte Carlo algorithms (mostly correct): probably correct; guaranteed running time Example: randomized primality test

4 2. Quicksort A[l … r-1]p pA[l...m – 1]A[m r] Quicksort Unsorted range A[l, r] in array A

5 Quicksort Algorithm: Quicksort Input: unsorted range [l, r] in array A Output: sorted range [l, r] in array A 1if r > l 2 then choose pivot element p = A[r] 3 m = divide(A, l, r) /* Divide A according to p: A[l],....,A[m – 1]  p  A[m + 1],...,A[r] */ 4Quicksort(A, l, m - 1) Quicksort (A, m + 1, r)

6 The divide step l r

7 divide(A, l, r): returns the index of the pivot element in A can be done in time O(r – l)

8 Worst-case input n elements: Running time: (n-1) + (n-2) + … = n·(n-1)/2

9 3. Randomized Quicksort Algorithm: Quicksort Input: unsorted range [l, r] in array A Output: sorted range [l, r] in array A 1if r > l 2 then randomly choose a pivot element p = A[i] in range [l, r] 3 swap A[i] and A[r] 4 m = divide(A, l, r) /* Divide A according to p: A[l],....,A[m – 1]  p  A[m + 1],...,A[r] */ 5 Quicksort(A, l, m - 1) 6 Quicksort(A, m + 1, r)

10 Analysis 1 n elements; let S i be the i-th smallest element S 1 is chosen as pivot with probability 1/n: Sub-problems of sizes 0 and n-1 S k is chosen as pivot with probability 1/n: Sub-problems of sizes k-1 and n-k S n is chosen as pivot with probability 1/n: Sub-problems of sizes n-1 and 0

11 Analysis 1 Expected running time:

12 4. Primality test Definition: An integer p  2 is prime iff (a | p  a = 1 or a = p). Algorithm: deterministic primality test (naive) Input: integer n  2 Output: answer to the question: Is n prime? if n = 2 then return true if n even then return false for i = 1 to  n/2 do if 2i + 1 divides n then return false return true Complexity:  n)

13 Primality test Goal: Randomized method Polynomial time complexity (in the length of the input) If answer is “not prime”, then n is not prime If answer is “prime”, then the probability that n is not prime is at most p>0 k iterations: probability that n is not prime is at most p k

14 Primality test Observation: Each odd prime number p divides 2 p-1 – 1. Examples: p = 17, 2 16 – 1 = = 17 * 3855 p = 23, 2 22 – 1 = = 23 * Simple primality test: 1 Calculate z = 2 n-1 mod n 2 if z = 1 3 then n is possibly prime 4 else n is definitely not prime Advantage: This only takes polynomial time

15 Simple primality test Definition: n is called pseudoprime to base 2, if n is not prime and 2 n-1 mod n = 1. Example: n = 11 * 31 = mod 341 = 1

16 Randomized primality test Theorem: (Fermat‘s little theorem) If p prime and 0 < a < p, then a p-1 mod p = 1. Definition: n is pseudoprime to base a, if n not prime and a n-1 mod n = 1. Example: n = 341, a = mod 341 = 56  1

17 Randomized primality test Algorithm: Randomized primality test 1 1 Randomly choose a  [2, n-1] 2 Calculate a n-1 mod n 3 if a n-1 mod n = 1 4 then n is possibly prime 5 else n is definitely not prime Prob(n is not prim, but a n-1 mod n = 1 ) ?

18 Carmichael numbers Problem: Carmichael numbers Definition: An integer n is called Carmichael number if a n-1 mod n = 1 for all a with GCD(a, n) = 1. (GCD = greatest common divisor) Example: Smallest Carmichael number: 561 = 3 * 11 * 17

19 Randomized primality test 2 Theorem: If p prime and 0 < a < p, then the only solutions to the equation a 2 mod p = 1 are a = 1 and a = p – 1. Definition: a is called non-trivial square root of 1 mod n, if a 2 mod n = 1 and a  1, n – 1. Example: n = mod 35 = 1

20 Fast exponentiation Idea: During the computation of a n-1 (0 < a < n randomly chosen), test whether there is a non-trivial square root mod n. Method for the computation of a n : Case 1: [n is even] a n = a n/2 * a n/2 Case 2: [n is odd] a n = a (n-1)/2 * a (n-1)/2 * a

21 Fast exponentiation Example: a 62 = (a 31 ) 2 a 31 = (a 15 ) 2 * a a 15 = (a 7 ) 2 * a a 7 = (a 3 ) 2 * a a 3 = (a) 2 * a Complexity: O(log 2 a n log n)

22 Fast exponentiation boolean isProbablyPrime; power(int a, int p, int n) { /* computes a p mod n and checks during the computation whether there is an x with x 2 mod n = 1 and x  1, n-1 */ if (p == 0) return 1; x = power(a, p/2, n) result = (x * x) % n;

23 Fast exponentiation /* check whether x 2 mod n = 1 and x  1, n-1 */ if (result == 1 && x != 1 && x != n –1 ) isProbablyPrime = false; if (p % 2 == 1) result = (a * result) % n; return result; } Complexity: O(log 2 n log p)

24 Randomized primality test 2 primalityTest(int n) { /* carries out the randomized primality test for a randomly selected a */ a = random(2, n-1); isProbablyPrime = true; result = power(a, n-1, n); if (result != 1 || !isProbablyPrime) return false; else return true; }

25 Randomized primality test 2 Theorem: If n is not prime, there are at most integers 0 < a < n, for which the algorithm primalityTest fails.

26 Application: cryptosystems Traditional encryption of messages with secret keys Disadvantages: 1.The key k has to be exchanged between A and B before the transmission of the message. 2.For messages between n parties n(n-1)/2 keys are required. Advantage: Encryption and decryption can be computed very efficiently.

27 Duties of security providers Guarantee…  confidential transmission  integrity of data  authenticity of the sender  reliable transmission

28 Public-key cryptosystems Diffie and Hellman (1976) Idea: Each participant A has two keys: 1.a public key P A accessible to every other participant 2.a private (or: secret) key S A only known to A.

29 Public-key cryptosystems D = set of all legal messages, e.g. the set of all bit strings of finite length Three conditions: 1. P A and S A can be computed efficiently 2. S A (P A (M)) = M and P A (S A (M)) = M (P A, S A are inverse functions) 3. S A cannot be computed from P A (without unreasonable effort) 1-1

30 Encryption in a public-key system A sends a message M to B. Dear Bob, I just checked the new... #*k- + #$<9 {o7::-&$3 (-##!]?8...

31 Encryption in a public-key system 1. A accesses B’s public key P B (from a public directory or directly from B). 2. A computes the encrypted message C = P B (M) and sends C to B. 3. After B has received message C, B decrypts the message with his own private key S B : M = S B (C)

32 Generating a digital signature A sends a digitally signed message M´ to B: 1. A computes the digital signature σ for M´ with her own private key: σ = S A (M´) 2. A sends the pair (M´,σ) to B. 3. After receiving (M´,σ), B verifies the digital signature: P A (σ) = M´ σ can by verified by anybody via the public P A.

33 RSA cryptosystems R. Rivest, A. Shamir, L. Adleman Generating the public and private keys: 1. Randomly select two primes p and q of similar size, each with l+1 bits (l ≥ 500). 2. Let n = p·q 3. Let e be an integer that does not divide (p - 1)·(q - 1). 4. Calculate d = e -1 mod (p - 1)(q - 1) i.e.: d · e ≡ 1 mod (p - 1)(q - 1)

34 RSA cryptosystems 5. Publish P = (e, n) as public key 6. Keep S = (d, n) as private key Divide message (represented in binary) in blocks of size 2·l. Interpret each block M as a binary number: 0 ≤ M < 2 2·l P(M) = M e mod n S(C) = C d mod n