This article collapses some theorems and subjects necessary to complete the cryptography course at [https://crypto.stanford.edu/pbc/notes/numbertheory/].
The theorem states that for any integer
If
From the previous section is clear that
These are well covered in [https://crypto.stanford.edu/pbc/notes/numbertheory/exp.html] so I won't delve them. The absence of a structure of the powers of
From the previous example is clear that we will always face nonunits every time we deal with some
When we deal with multiplicative groups, we don't normally care a lot about non-units, since every reasoning made in the former sections and everything said into [https://github.com/Z323323/Group-theory-elements]. Nonetheless it's important to consider them because they exist (and they are a problem).
Check [https://github.com/Z323323/From-Fermat-to-the-group-theory]. It contains every necessary proof of both theorems.
First, consider this [https://crypto.stanford.edu/pbc/notes/numbertheory/order.html].
I give you
- to better understand why
$ed = k(\phi(N)) + 1$ ->$d = e^{-1} \mod \phi(N)$ , just note that the first formula means that$ed$ divided by$\phi(N)$ must be$k + 1$ , which in turn means that$ed \equiv 1 \mod \phi(N)$ , and the second formula follows after this (I know everything is quite magical in this field). -
$a$ (which is our message to encrypt) must be coprime with$N$ , indeed this algorithm is only used to share a second key (which will be coprime with$N$ ), but this generation will not be performed by the owner of the secret key; instead the$2nd$ peer will use the public key to encrypt his AES key, and send it to the owner of the secret key, which will decrypt this second key and use it to start the exchange of encrypted session using AES.
- the whole computational problem introduced by the algorithm is to find
$e^{-1} \mod \phi(N)$ where$\{e, N\}$ is our public key (we can't multiply the message$a$ by$e$ because$e$ is calculated$\mod \phi(N)$ not$\mod N$ , hence the inverses wouldn't match$\mod N$ thus not giving back the message$a$ ).
Since everything said, the problem of breaking RSA is to find
To fully understand this section it's preferable that you have read [https://github.com/Z323323/Group-theory-elements].
This is the most intuitive while probably the worst primality test.
By Fermat's Little Theorem:
Hence taking a random integer
is verified, should we conclude that
Let's fire a counter-example to show that it's not always the case:
hence it's clearly not a prime. But:
is verified by every
Now, since these congruences are exactly wrote to match the Fermat's Little Theorem, there will be
fooling this test. Now the actual reason why these
Remember that applying the CRT to the first two congruences, means to find the number of solutions (the numbers)
do NOT map the solutions of the first two congruences. Indeed there are only
To conclude, there exist some numbers called the 'Carmichael numbers' like
Refer to [https://crypto.stanford.edu/pbc/notes/numbertheory/carmichael.html].
The linked resource is quite self-explainatory, but I'll provide a couple clarifications since it's not simple. The whole first section aims to prove that Carmichael numbers must be composed by at least
Following the 'best case scenario' reasoning, I have to say that I think that if we follow the
$n - 1 = q(p - 1) + q - 1$ $n - 1 = p(q - 1) + p - 1$
Every congruence below will need to be verified in order to fool the Fermat test. Remember this doesn't mean that
Let
-
$a^{q(p - 1) + q - 1} \equiv 1 \mod p = a^{q(p - 1)}a^{q - 1} \equiv 1 \mod p = a^{q - 1} \equiv 1 \mod p$ iff$a$ is a generator for a subgroup of order$o | q - 1$ and$o | p - 1$ -
$a^{q(p - 1) + q - 1} \equiv 1 \mod q = a \equiv 1 \mod q$ iff$a$ is a generator for a subgroup of order$o | p - 1$ and$o | q - 1$ -
$a^{p(q - 1) + p - 1} \equiv 1 \mod p = a \equiv 1 \mod p$ iff$a$ is a generator for a subgroup of order$o | q - 1$ and$o | p - 1$ -
$a^{p(q - 1) + p - 1} \equiv 1 \mod q = a^{p(q - 1)}a^{p - 1} \equiv 1 \mod q = a^{p - 1} \equiv 1 \mod q$ iff$a$ is a generator for a subgroup of order$o | p - 1$ and$o | q - 1$ $->$ -
$o = q - 1 | p - 1$ is the case which has the most number of solutions
Let's now consider the case
thus, in order to have
we will have
is satisfied too having
and
but
Also
thus if
thus if
Summing all up we have that under
-
$n = qlp, p > q > l$ where$q, l, p$ are odd primes (because if$l = 2$ then$qlp - 1$ would be odd and$p - 1, q - 1, l - 1$ wouldn't be able to divide it, note also that this reasoning holds for$n$ being composed by more than$3$ primes) -
$p - 1 < ql - 1$ , and$p - 1 | ql - 1 | qlp - 1$ -
$q - 1 | lp - 1 | qlp - 1$ ($q - 1 < lp - 1$ implied) -
$l - 1 | qp - 1 | qlp - 1$ ($l - 1 < qp - 1$ implied)
Now,
Now, let's analyze the probability of fooling the Fermat test. Let's say
The upper bound probability of
but
always. And then we can consider
This means that