Database › Mathematics › Pure mathematics › Number theory
Arithmetic modulo n: Fermat's little theorem a^{p−1} ≡ 1 (mod p), Euler's theorem a^{φ(n)} ≡ 1, and the Chinese remainder theorem make large powers and simultaneous congruences tractable — the basis of RSA cryptography.
Explanation
The invertible residues mod $n$ form a group of order $\varphi(n)$, so Euler's theorem is Lagrange's theorem in disguise. Inverses are found with the extended Euclidean algorithm. In RSA, $n=pq$, $ed\equiv1\pmod{\varphi(n)}$, encryption $m^e$ and decryption $c^d$; security rests on the difficulty of factoring $n$.
The Chinese remainder theorem identifies $\mathbb Z_{mn}$ with $\mathbb Z_m\times\mathbb Z_n$ for coprime $m,n$.
Example 1
Compute $3^{100}\bmod7$.
Solution
$3^6\equiv1$ and $100=96+4$, so $3^{100}\equiv3^4=81\equiv4$.
Example 2
Toy RSA with $p=3$, $q=11$, $e=3$: find $d$ and encrypt then decrypt $m=4$.
Solution
$n=33$, $\varphi=20$, $3d\equiv1$: $d=7$. $c=4^3=64\equiv31$; $31^7\equiv4\pmod{33}$, recovering $m$.