RSA cryptography is based on the following theorems:
Proof:
Consider the numbers
,
, ...
, all modulo
. They are all different.
If any of them were the same, say
,
then
so
must be a multiple
of
. But since all
and
are less than
,
.
Thus
,
, ...,
must be a
rearrangement of
. So modulo
, we
have:
Proof:
Same idea as above. Suppose
. Then suppose that
the
numbers less than
that are relatively prime to
are:
Then
,
, ...,
are also
relatively prime to
, and must all be different, so they
must just be a rearrangement of the
, ...,
in some
order. Thus:
Proof:
If
then
divides
. Similarly,
divides
. But
and
are relatively prime,
so
divides
. Consequently,
.
Based on these three theorems, here is why the RSA encryption scheme works.
Let
be the secret message, let
and
be two different
(large) prime numbers, let
be a (relatively small) number
that is relatively prime to
, and let
be a
number such that
. Let
.
The
encoded message is
, and we need to
show that the decoded message is given by
.
Proof: Since
,
. Thus:
But
, so
.
By exactly similar reasoning,
, so
by the Chinese remainder theorem,
.
Finally, given
, to find
such that
,
we can use the extension of Fermat's theorem to get
, so
is a suitable
value for
.