Proof of RSA Public Key Encryption

This section describes steps to prove RSA Public Key Encryption algorithm. Fermat's little theorem is the key part of the proof.

To proof the RSA public key encryption algorithm, we need to proof the following:

```Given that:
p and q are 2 distinct prime numbers
n = p*q
m = (p-1)*(q-1)
e satisfies 1 > e > n and e and m are coprime numbers
d satisfies d*e mod m = 1
M satisfies 0 => M > n
C = M**e mod n
the following is true:
M == C**d mod n
```

One way to prove the above is to use steps presented by Avi Kak at https://engineering.purdue.edu/kak/compsec/NewLectures/Lecture12.pdf

(a) Prove that "M**(e*d) mod p == M mod p" is true:

```M**(e*d) mod p
= M**(k1*m+1) mod p                # because "d*e mod m = 1"
= (M**(k1*m))*M mop p              # factoring 1 M out
= (M**(k1*(q-1)*(p-1)))*M mod p    # because "m = (p-1)*(q-1)"
= (M**(k2*(p-1)))*M mod p          # set "k2 = k1*(q-1)"
= ((M**(p-1) mod p)**k2)*M mod p   # rearranging "mod p"

If M and p are coprime numbers:
M**(e*d) mod p
= (1**k2)*M mod p                  # Fermat's little theorem:
#    M**(p-1) mod p = 1
# when M and p are coprimes
= M mod p                          # done

Else
M == k*p must be true              # because p is a prime number
M mod p == 0
M**(e*d) mod p == 0
M**(e*d) mod p == M mod p          # done
```

(b) Prove that "M**(e*d) mod q == M mod q" is true in the same process as above.

(c) Prove that "M == C**d mod n" is true:

```M**(e*d) mod p == M mod p    (1) # see proof (a)
M**(e*d) - M == k3*p         (2) # because of modulus operation

M**(e*d) mod q == M mod q    (3) # see proof (b)
M**(e*d) - M == k4*q         (4) # because of modulus operation

M**(e*d) - M == k5*p*q       (5) # because of (2) and (4)
M**(e*d) - M == k5*n         (6) # because n = p*q
M mod n == M**(e*d) mod n    (7) # because of modulus operation
M == M**(e*d) mod n          (8) # because 0=< M < n
M == (M**e mod n)**d mod n   (9) # moving "mod n"

M == C**d mod n             (10) # because C = M**e mod n
```

See you can see, the key part of the proof process is the "Fermat's little theorem", which says that if p is a prime number, then for any integer a, the number "a**p - a" is an integer multiple of p. See http://en.wikipedia.org/wiki/Fermat%27s_little_theorem for more details.

Table of Contents