Title: Randomized Algorithm
1Randomized Algorithm Public Key Cryptography
- Binhai Zhu
- Computer Science Department, Montana State
University -
2Randomized Algorithm
How to flip a coin?
3Randomized Algorithm
How to flip a coin? Easy. But the interesting
part is that this kind of simple idea can help us
designing algorithms.
4Randomized Algorithm
How to flip a coin? Easy. But the interesting
part is that this kind of simple idea can help us
designing algorithms. Example. Quicksort.
5Randomized Algorithm
How to flip a coin? Easy. But the interesting
part is that this kind of simple idea can help us
designing algorithms. Example. Quicksort. In
designing randomized algorithms, you can assume
that we will toss a dice which can have many
faces. (With a coin, it is a dice with 2 faces.)
6Assistant Hiring Problem
Suppose that you are assigned the job to
interview and hire an office assistant, the rule
is that the current best candidate will be
hired. Assume that the cost to interview a
candidate is Ci and the cost to hire a candidate
is Ch (typically Ch gtgt Ci). What would you do?
7Assistant Hiring Problem
- Assume that the cost to interview a candidate is
Ci and the cost to hire a candidate is Ch
(typically Ch gtgt Ci). - What would you do? Easy!
- Hire-Assistant(n) //1 to n are the candidates
- 1. best ? 0
- 2. For i 1 to n
- interview candidate i
- If i is better than best
- then best ? i
- hire candidate i
8Assistant Hiring Problem
- Assume that the cost to interview a candidate is
Ci and the cost to hire a candidate is Ch
(typically Ch gtgt Ci). - What would you do? Easy!
- Hire-Assistant(n) //1 to n are the candidates
- 1. best ? 0
- 2. For i 1 to n
- interview candidate i
- If i is better than best
- then best ? i
- hire candidate i
- What is the total cost of this algorithm?
9Assistant Hiring Problem
- Assume that the cost to interview a candidate is
Ci and the cost to hire a candidate is Ch
(typically Ch gtgt Ci). - What would you do? Easy!
- Hire-Assistant(n) //1 to n are the candidates
- 1. best ? 0
- 2. For i 1 to n
- interview candidate i
- If i is better than best
- then best ? i
- hire candidate i
- What is the total cost of this algorithm?
- If m candidates are hired, the total cost is
- O(nCimCh).
- As n, Ci, Ch are all constants, m is the crucial
parameter!
10Assistant Hiring Problem
As m n in the worst case, the worst case
running time of Hire-Assistant(-) is O(n(CiCh)).
But intuitively this cant be true in reality
it would be insane to hire all the
candidates! What can we do?
11Assistant Hiring Problem
As m n in the worst case, the worst case
running time of Hire-Assistant(-) is O(n(CiCh)).
But intuitively this cant be true in reality
it would be insane to hire all the
candidates! What can we do? Analyze the
behavior of m, with a randomized algorithm!
12Assistant Hiring Problem
- An algorithm is randomized if its behavior is
determined not only by input but also by random
numbers.
13Assistant Hiring Problem
- An algorithm is randomized if its behavior is
determined not only by input but also by random
numbers. - Randomized-Hire-Assistant(n)
- 0. Randomly permute the list of candidates
- 1. best ? 0
- 2. For i 1 to n
- 3. interview candidate i
- 4. If i is better than best
- 5. then best ? i
- 6. hire candidate i
14Indicator Random Variable IA
IA 1, if event A occurs. IA 0, if event
A does not occur. //let A- be the complement of
A Lemma. Given a sample space S and an event A in
the sample space, let XAIA. Then EXAPrA.
15Indicator Random Variable IA
IA 1, if event A occurs. IA 0, if event
A does not occur. //let A- be the complement of
A Lemma. Given a sample space S and an event A in
the sample space, let XAIA. Then
EXAPrA. Proof. EXA EIA 1
x PrA 0 x PrA- PrA.
16Indicator Random Variable IA
IA 1, if event A occurs. IA 0, if event A
does not occur. //let A- be the complement of
A Lemma. Given a sample space S and an event A in
the sample space, let XAIA. Then
EXAPrA. Example. Lets look at flipping n
coins. Yi random variable denoting the outcome
of the i-th flip Xi IYiH X random variable
denoting the total number of HEADs in n coin
flipping What is EX?
17Indicator Random Variable IA
Lemma. Given a sample space S and an event A in
the sample space, let XAIA. Then
EXAPrA. Example. Lets look at flipping n
coins. Yi random variable denoting the outcome
of the i-th flip Xi IYiH X random variable
denoting the total number of HEADs in n coin
flipping What is EX? X S i1 to n Xi, so EX
E S i1 to n Xi S i1 to n EXi
S i1 to n Prevent Xi occurs S i1 to n ½
n/2
18Analysis of Randomized-Hire-Assistant
Xi Icandidate i is hired i.e., Xi1 if and
only if i is hired. X S i1 to n Xi What is
EX? EX E S i1 to n Xi S i1 to n
EXi S i1 to n Prcandidate i is
hired occurs //is the best S i1 to n
1/i 1 ½ 1/3 1/n O(log n). The
answer is natural, as log n ltlt n.
19Public Key Cryptography
Private Key Cryptography is easy everybody keeps
a secret key for your email account. But this is
not efficient when you (e.g., a bank) need to
communicate with many people.
20Public Key Cryptography
Private Key Cryptography is easy everybody keeps
a secret key for your email account. But this is
not efficient when you (e.g., a bank) need to
communicate with many people. The idea is that
everybody maintains two keys, a private one and a
public one. When Alice sends a message M to Bob,
Alice encrypts the message using Bobs public key
PB, sends PB(M) to Bob and Bob decrypts it using
his own private key SB, i.e., SB(PB(M))M. (The
tricky part is that you cant decrypt the message
using PB.)
21Public Key Cryptography
Another application is called Digital Signatures,
you want to know the message you have received is
from the true party from whom you are expecting a
message. The idea is again that everybody
maintains two keys, a private one and a public
one. When Alice sends a digital signature to Bob,
Alice encrypts the signature M using her secret
key SA, i.e., dSA(M), sends (d,M) to Bob and
Bob decrypts d using Alices public key PA and
verify whether PA(d)M or not. If not, then Bob
can claim that the Alice who sends the signature
is a fake.
22Public Key Cryptography
Another application is called Digital Signatures,
you want to know the message you have received is
from the true party from whom you are expecting a
message. The idea is again that everybody
maintains two keys, a private one and a public
one. When Alice sends a digital signature to Bob,
Alice encrypts the signature M using her secret
key SA, i.e., dSA(M), sends (d,M) to Bob and
Bob decrypts d using Alices public key PA and
verify whether PA(d)M or not. If not, then Bob
can claim that the Alice who sends the signature
is a fake. PA(SA(M))SA(PA(M))M is the
foundation for the whole public key system!
23Public Key Cryptography
Q All these sound like fairy tales, how can it
work? A Mathematics!
24Public Key Cryptography
Q All these sound like fairy tales, how can it
work? A Mathematics! Of course, most of you are
probably not at the level to understand the
proofs yet. But lets at least see a working
algorithm.
25RSA Public Key Cryptography
- Select two large random prime numbers p,q (gt1000
bits). - n pq.
- Select a small odd integer e that is relative
prime to (p-1)(q-1). - Find d such that de 1 (mod (p-1)(q-1)).
- Create keys, public key (e,n),
- secret key (d,n)
- P(M) Me(mod n)
- S(C) Cd (mod n)
26RSA Public Key Cryptography
- Select two large random prime numbers p,q (gt1000
bits). - n pq.
- Select a small odd integer e that is relative
prime to (p-1)(q-1). - Find d such that de 1 (mod (p-1)(q-1)).
- Create keys, public key (e,n),
- secret key (d,n)
- P(M) Me(mod n)
- S(C) Cd (mod n)
- Example
- p11,q29,n319
- (p-1)(q-1)280
- e3
27RSA Public Key Cryptography
- Select two large random prime numbers p,q (gt1000
bits). - n pq.
- Select a small odd integer e that is relative
prime to (p-1)(q-1). - Find d such that de 1 (mod (p-1)(q-1)).
- Create keys, public key (e,n),
- secret key (d,n)
- P(M) Me(mod n)
- S(C) Cd (mod n)
- Example
- p11,q29,n319
- (p-1)(q-1)280
- e3
- d187
28RSA Public Key Cryptography
- Select two large random prime numbers p,q (gt1000
bits). - n pq.
- Select a small odd integer e that is relative
prime to (p-1)(q-1). - Find d such that de 1 (mod (p-1)(q-1)).
- Create keys, public key (e,n),
- secret key (d,n)
- P(M) Me(mod n)
- S(C) Cd (mod n)
- Mde Med M (mod n) is the core of the
proof.