Title: Publickey cryptosystem
1Public-key cryptosystem
- Secret-key cryptosystem
- eK dK dK is the same as or derived from eK.
- Called symmetric-key cryptosystem.
- Problem how to distribute eK dK to Alice Bob
securely. - Public-key cryptosystem
- Computationally infeasible to compute dK from eK.
- Called non- symmetric-key cryptosystem.
- eK is made public, called public key
- But dK is kept secret, called private key.
2Public-key system how it works
- Everybody selects its own public key P and
private key S, and publicizes P. - Therefore Alice has (Pa , Sa), and Bob has (Pb ,
Sb). - Everybody knows Pa, Pb,
- Suppose Alice wants to send a message to Bob.
- Alice encrypts the message with Bobs public key
Pb and sends out. - (only) Bob can decrypt the message using his
private key Sb. Nobody else can.
3RSA cryptosystem--preview
- Suppose np?q, where p and q are big primes.
- Select (find) a and b, such that a?b1 mod ?(n).
- K(n,p,q,a,b), publicize n,b, but keep p,q,a
secret. - For any x,y?Zn , define
- eK(x) xb mod n
- dK(y) ya mod n
- Of course, from n,b, it is very difficult to get
a (as well as p,q,?(n)). - The correctness ya (xb)a xba x mod n.
Proof later.
4RSA example (encryption)
- p11, q3,
- n33, ?(n)(p-1)(q-1) 10.2 20
- Select a7, so b3.
- Public key (33,3). And Private key (33,7).
- Suppose x7
- So eK(x) xb mod n 73 mod 33343 mod 33 13.
- Dec dK(y) ya mod n 137 mod 3362748517 mod
337
5RSA signature
- K(n,p,q,a,b), publicize n,b, but keep p,q,a ,
?(n) secret. - For any x?Zn , define signature
- ysigK(x) ? xa mod n
- (x,y) is sent.
- Define verification
- verK(x,y) true iff x ? yb mod n
6RSA example (signature)
- p11, q3,
- n33, ?(n)(p-1)(q-1) 10.2 20
- Select a7, so b3.
- Public key (33,3). And Private key (33,7).
- Suppose x7
- So ysigK(x) xa mod n 77 mod 33823543 mod 33
28. - Dec verK(x,y) yb mod n 283 mod 3321952 mod
337x
7More number theory
- For any positive n,
- Zn is a ring,
- ? (n) ?i1m (piei - piei-1 ) where n ?i1m
piei - b ? Zn has a multiplicative inverse iff gcd(b,
n) 1. - Znb b is coprime to n, then (Zn,?) is a
abelian group.
- ? (modulo n) is associative and commutative.
2. 1 is the multiplicative identity.
3. Any element b ?Zn, there exists b-1 ?Zn,
such that bb-11.
4. Zn is closed under ? (modulo n).
Question how to compute b-1 for any given b
?Zn?
8Euclidean Algorithmcompute gcd(a,b)
- Let r0a, r1b, (suppose a ? b)
- r0 q1 r1 r2 0 ? r2? r1
- r1 q2 r2 r3 0 ? r3? r2
- rm-2 qm-1 rm-1 rm 0 ? rm? rm-1
- rm-1 qm rm
- Then gcd(a,b)gcd(r0, r1)gcd(r1, r2)
- gcd(rm-1, rm) rm
(Why?) - Given n and b, if gcd(n,b)1, then b is coprime
to n and has a multiplicative inverse b-1. But
how to get b-1?
9Extended Euclidean Algorithmcompute inverse
- Define tj and sj in Euclidean Algorithm as
Where qjs is the values in Euclidean Algorithm.
10Extended Euclidean Algorithm--theorems
- Theorem for 0? j ? m, rjsjr0tjr1.
- Corollary suppose gcd(r0,r1)1, then r1-1 tm.
- Proof
- smr0tmr1 rm gcd(r0,r1)1, let both sides be
divided by r0. - 0tmr1 1 mod r0, i.e., tmr1 1 mod r0. so r1-1
tm. - Therefore, for given n and b, use extended
Euclidean Algorithm to compute r2, r3,,rm, and
t2, t3,,tm, (no need for s2, s3,,sm), if rmgt1,
then b is not coprime to n. otherwise, b is
coprime to n and b-1tm.
11Chinese remainder theorem
- Suppose m1,,mr are pairwise relatively prime
(coprime) positive integers, and suppose a1,,ar
are integers. Then the system of r congruences - x ? a1 (mod m1)
-
- x ? ai (mod mi)
-
- x ? ar (mod mr)
- has a unique solution modulo Mm1??mr
- x?i1raiMiyi mod M.
- Where MiM/mi and yiMi-1 mod mi.
12Chinese remainder theorem (CRT)
- Proof
- x is a solution
- x is unique
- Two folds of CRT
- Given x, computer x mod m1,, x mod mr (direct)
- Given x mod m1,, x mod mr, compute x.
13Other facts from number theory
- Divisibility
- If ab, and c is any integer, then abc
- If ab and bc, then ac
- If ab,ac, then abc, and ab-c
- Any natural number n can be written uniquely
(except the order of factors) as a product of
primes - If a prime pab, then pa or pb
- If ma and na, and gcd(m,n)1, then mna
14Other facts from number theory (cont.)
- Congruences
- If a?b mod m and b?c mod m then a?c mod m
- If a?b mod m and c?d mod m then
- ac?bd mod m and a-c?b-d mod m
- and ac?bd mod m
- If a?b mod m then a?b mod d for any dm.
- If a?b mod m and a?b mod n and gcd(m,n)1, then
a?b mod mn.
15Other facts from number theory (cont.)
- (Lagrange) Theorem
- Suppose G is a multiplicative group of order s
and g?G, then the order m of g (i.e., smallest m
such that gm1) divides s. - Corollary
- If b ?Zn, then b?(n)?1 mod n.
16Other facts from number theory (cont.)
- Fermats Little Theorem
- Let p be a prime, any integer a satisfies ap? a
mod p, and any integer a not divisible by p
satisfies ap-1 ?1 mod p. - Euler phi-function
- If p is a prime, then ?(p)p-1 and for any
integer a, ?(pa)pa- pa-1 pa(1-1/p). - If gcd(p,q)1, then ?(pq)?(p)?(q) (from CRT).
- ? (n) ?i1m (piei - piei-1 ) where n ?i1m
piei
17Other facts from number theory (cont.)
- Theorem if p is a prime, then Zp is a cyclic
group. i.e, - There is an element ? of order p-1, called
primitive element. - Zp ?i 0? i ?p-2, ? is also called a
generator. - i.e., any element ?, can be written ?i and the
order of ? is (p-1)/gcd(p-1,i). - If gcd(p-1,i)1, then ? ?i is also a primitive
element. - Therefore, the number of primitive elements in
Zp is ?(p-1).
18Other facts from number theory (cont.)
- Theorem
- Suppose p is a prime and ? ?Zp . Then ? is a
primitive element modulo p iff ?(p-1)/q ?1 mod p
for all primes q such that q(p-1).
19RSA cryptosystem
- Suppose np?q, where p and q are big primes (512
bits). - Select (find) a and b, such that a ? b1 mod ?(n)
((p-1)(q-1)). - K(n,p,q,a,b), publicize n,b, but keep p,q,a
secret. - For any x,y?Zn , define
- eK(x) xb mod n dK(y) ya mod n
- Of course, from n,b, it is very difficult to get
a (as well as p,q,?(n)).
20Proof of RSA
- If x0 ?Zn , then it is correct.
- If x ?Zn , then
- ab1 mod ?(n), abt?(n)1 (for some t).
- ya(xb)a ? x t?(n)1 ? (x?(n))t x ? 1t x ? x
(mod n) - If x ? Zn\Zn , then
How to prove it?