\varphi(n) is the number of coprimes to n.
Let m and n be two integers such that gcd(m, n) = 1. For any a, b \in \Z there exists x \in \Z such that
x \equiv a \pmod m
x \equiv b \pmod n
For all such solutions, x \bmod (mn) is unique.
f: Z_{mn} \to Z_m \times Z_n is a group isomorphism f(x) = (x \bmod m, x \bmod n). Then f^{-1}(a, b) = an(n^{-1} \bmod m) + bm(m^{-1} \bmod n) \pmod{mn}
For any a, b, m, n \in \Z such that gcd(m, n) = 1 then
\begin{cases} a \equiv b \pmod m \\ a \equiv b \pmod n \\ \end{cases} \iff a \equiv b \pmod{mn}
Let m, n be two integers such that gcd(m, n) = 1. Let u = n(n^{-1} \bmod m) and v = m(m^{-1} \bmod n) then g: (a, b) \mapsto au + bv \bmod{mn} is a ring isomorphism.
Given an integer we output a list of primes whose product is equal to n.
i = 2
x = n
for _ in 2:sqrt(n)
while i divides x
output i
x = x / i
i = i + 1
if x > 1
output x
Utilizing the little fermat theorem. Might call something a prime that isn’t a prime.
for _ in 1:k
b = random(1, n)
x = b^(n-1) mod n
if x != 1
return "not prime"
return "maybe prime"
n is a carmichael number iff it is composite and \forall_{\{a : gcd(a, n) = 1\}} a^{n-1} \equiv 1 \pmod n
We can write n - 1 as 2^st for t odd. When n is prime then b^{n-1} \bmod n = ((b^t)^2\cdots)^2 \bmod n = 1
if n = 2
return "prime"
if n is even
return "composite"
n === 2^s * t + 1
for _ in 1:k
b = random(1, n)
x = b^t mod n
i = 0
if x != 1
while x != n - 1
x = x^2 mod n
i = i + 1
if i == s or x == 1
return "composite"
return "maybe prime"
Complexity: O(k\ell^3)
An integer is prime iff it passes the miller-rabin test for all b \in Z_n^*. If more than a quarter of b \in Z_n^* pass the miller-rabin then all b \in Z_n^* do.
So P[\text{output maybe prime}|\text{n composite}] \le 4^{-k}.
Let p(N) denote the number of prime numbers up till N. Then p(N) \sim \frac{N}{\ln N}. So the chance of a \ell bit number to be prime is \frac{1}{\ell \ln 2}. We then apply miller-rabin test to check if the number is prime. If not, try again. Complexity: O(\ell^4).
If we let k = \frac{1}{2}(\log_2\ell - \log_2\varepsilon) then P[\text{output is not prime}] \le O(\ell) \cdot 4^{-k} = O(\varepsilon)
For any x \in \{0, \cdots, N-1\} and any k we have x^{k \varphi(N)+1} \bmod N = x
RSA with modulus of \ell bits:
Let K be a finite field. For any x \in K we have x^2 = 1 \implies x = 1 \lor x = -1.
Let p be an odd prime number. Then b \in Z_p^* has a square root if and only if b^{\frac{p-1}{2}} \bmod p = 1. Then b is called a quadratic residue.
Let p be a prime number such that p \equiv 3 \pmod 4. For any x \in Z_p we have y^2 \equiv x \pmod p \implies y \equiv x^{\frac{p+1}{4}} \pmod p \lor y \equiv -x^{\frac{p+1}{4}} \pmod p.
let p and q be two different prime numbers and n = pq. Let x \in Z_n and a and b such that
\begin{aligned} x \equiv a^2 \pmod p \\ x \equiv b^2 \pmod q \\ \end{aligned}
We have
x \equiv y^2 \pmod n \iff \begin{cases} y \equiv \pm a \pmod p \\ y \equiv \pm b \pmod q \\ \end{cases}
For p an odd prime
\left(\frac{b}{p}\right) = \begin{cases} 0 & \text{if } b \bmod p = 0 \\ 1 & \text{if b is a quadratic residue in } Z_p^* \\ -1 & \text{if b is not a quadratic residue in } Z_p^* \\ \end{cases}
For n odd
\left(\frac{b}{n}\right) = \left(\frac{b}{p_1}\right)^{\alpha_1} \cdot \ldots \cdot \left(\frac{b}{p_r}\right)^{\alpha_r}
For the factorization of n.
So b \in Z_p^* is a quadratic residue \iff \left(\frac{b}{p}\right) = 1. So b \in Z_n^* is a quadratic residue \implies \left(\frac{b}{n}\right) = 1.
Properties:
Algorithm to compute is in O(\ell^2)
Let QR_n be the subgroup of Z_n^* of all quadratic residues.
\iff
y_0, y_1 \in Z_n
\begin{cases} y_0^2 &\equiv y_1^2 \pmod n \\ y_0 &\not\equiv y_1 \pmod n \\ y_0 &\not\equiv -y_1 \pmod n \\ \end{cases} \implies gcd(y_0 - y_1, n) \notin \{1, n\}
Note: \lambda(n) is the exponent of the group Z_n^*.
RSA-Full \lambda-factoring \implies RSA-Computing order in Z_n^* \implies RSA-Computing \lambda(n) \iff RSA-Factoring.
\begin{gather*} \text{RSADP} \impliedby &\text{RSAKRP}& \impliedby &\text{GOP}& \\ &\Downarrow& &\Updownarrow& \\ &\text{EMP}& \implies &\text{RSAFP}& \\ \end{gather*}