CS255
Chris Pollett
Apr 13, 2015
Modular-Exponentiation(a, b, n) 1 d=1, k = length of b //k is high order bit 2 for i = k down to 0: 3 d = ( d * d ) mod n 4 if b_i = 1: 5 d = (d * a) mod n 6 return d
Theorem. The RSA functions `P` and `S` on the last slides define inverse transformations.
Proof. `P(S(M)) = S(P(M))= M^(ed) mod n`. Since `e` and `d` are multiplicative
inverses modulo `phi(n) = (p-1)(q-1)`, `ed = 1+k(p-1)(q-1)`
for some `k`. If `M equiv 0 mod n`, then `M^(ed) equiv 0 mod n` so we are done. If `M` is not congruent to `0 mod p`,
we have
`M^(ed) equiv M(M^(p-1))^(k(q-1)) mod p`
`equiv M(1)^(k(q-1)) mod p`
`equiv M mod p`
and a similar result holds `mod q`. By the Chinese Remainder Theorem,
this implies `M^(ed) equiv M (mod n)`.
Which of the following is true?
Witness(a,n) 1 let n - 1 = 2^t*u, where t >= 1 and u is odd 2 x_0 = Modular-Exponentiation(a, u, n) 3 for i = 1 to t: 4 x_i = (x_(i-1))^2 mod n 5 if x_i = 1 and x_(i-1) != 1 and x_(i-1) = != n-1: 6 return true 7 if x_t != 1: 8 return true 9 return false
Miller-Rabin(n, s) 1 for j = 1 to s 2 a = Random(1, n - 1) 3 if Witness(a, n): 4 return "Composite" 5 return "Prime"
Theorem. If `n` is composite, then the number of witnesses to compositeness is at least `(n-1)/2`.
Proof. We show the number of non-witnesses is at most `(n-1)/2`. First, any non-witness must be in `ZZ_n^(star)` as it must satisfy `a^(n-1) equiv 1 mod n`, i.e., `a cdot a^(n-2) equiv 1 mod n`; thus, it has an inverse. So we know `gcd(a,n) | 1` and hence `gcd(a, n) = 1`. Next we show that all non-witnesses are contained in a proper subgroup of `ZZ_n^(star)`. This implies the Theorem. There two cases to consider: