The Mathematics of RSA Encryption


The Quotient Remainder Theorem:
Given integers m, and n>0, there exist unique integers a and r such that m= a∙n + r where n > r ≥ 0 .
In particular m = r mod(n) .
 
Lemma 1:
Let p be a prime. Let e , 0 <e< p, and d, 0 < d< d' <p then ed' ≠ ed (mod p).
  Proof:
If ed' = ed (mod p) then e(d'-d)=0 (mod p) . That is e(d'-d)=ap But p is a prime.
 
Lemma 2:
Let p be a prime. For every e , 0 <e< p, there is a unique d, 0<d<p such that ed= 1 (mod p). In particular (p-1)!=1 (mod p).
  Proof:
A counting argument. There are p-1 integers 0<d<p and from Lemma 1 ed (mod p) is unique for each. So for some d ,ed= 1 (mod p).
To compute (p - 1)! (mod p). If p=2 then (p - 1)!=1. for p > 2, 1 2 = 1 (mod p). and (p - 1) 2 = 1 (mod p).
For 1 < e < p -1 , e2 ≠1 (mod p). If it were then (e-1)(e+1)=0 mod(p) but p ∤(e -1) and p ∤(e+1).
So e≠d where ed=1 (mod p). So (p - 1)! is a product of integers or pairs of integers = 1 (mod p) .

Fermat's Little Theorem:

Let p be a prime which does not divide the integer a, then a (p-1) = 1 (mod p).

  Proof:
Noting that we can assume 0 < a < p, and that ma ≠na (mod p) for 0 <m ≠n < p , The set of integers

(1a , 2a,....,(p-1)a) are unique (mod p) As in Lemma 2 , their product a (p-1) (p-1)! = 1 (mod p) . But

(p-1)!=1 (mod p) so a (p-1) =1 (mod p) .


A Special Case of the Chinese Remainder Theorem:

Let p q be 2 primes. Then for any a and b,the system of equations
            x=a (mod p)
            x=b (mod q)
has a unique solution for x (mod pq).

  Proof:
Let p' and q' be such that pp'=1 (mod q) and qq'=1 (mod p) . Let x = bpp' + aqq'
 
            (bpp' + aqq') (mod p)=aqq' (mod p)=a
and
            (bpp' + aqq') (mod q)=bpp' (mod q)=b

To prove uniqueness check that if z satifies the equations then (x-z) =0 mod (p) and mod (q) so is divisable by p and q , hence =0 mod (p) and mod (q) .


The RSA Computation:

For any a, a(p-1)(q-1)=1 mod (pq)

  Proof:
          a(p-1)(q-1)=1(q-1)=1 mod(p)
and
          a(p-1)(q-1)=1(p-1)=1 mod(q)

The computation now follows by uniqueness of solution.