Number theory meets cryptography: why RSA works and what makes it secure
Every theorem in this series -- Fermat, Euler, the extended Euclidean algorithm, CRT -- corresponds to a component of the RSA cryptosystem. We trace each connection, work through a concrete example, and discuss the factoring barrier that underpins RSA's security.
Number theory was long celebrated as the purest branch of mathematics – beautiful, ancient, and seemingly devoid of practical application. That reputation changed in 1977, when Rivest, Shamir, and Adleman combined several classical theorems into a public-key cryptosystem that transformed the way the world communicates securely. In this final article, we trace how each theorem from this series feeds into the RSA cryptosystem.
1 The idea behind public-key cryptography
2 How RSA works
Choose two large random primes and , and compute .
Compute (Euler's totient function).
Choose with (the standard choice is ).
Compute satisfying (via the extended Euclidean algorithm).
Primes (Article 3): the choice of and .
Euler's totient function (Article 4): computing .
Extended Euclidean algorithm (Article 2): computing .
Encryption: (using the public key ).
Decryption: (using the private key ).
3 Why decryption recovers the plaintext: Euler's theorem is the key
Why does hold?
4 The security guarantee: the hardness of factoring
Multiplication: runs in time – trivial.
Factoring: the fastest known classical algorithm (the general number field sieve) runs in – sub-exponential but still infeasible for large .
Factoring a 2048-bit modulus is estimated to take thousands of years with current hardware.
5 How each article contributes to RSA
Article 1 (Modular arithmetic): all RSA computations live in the world of .
Article 2 (Euclidean algorithm): the private key is computed as the modular inverse of modulo .
Article 3 (Fundamental Theorem of Arithmetic): the uniqueness of prime factorization is the premise on which security rests.
Article 4 (Fermat–Euler): Euler's theorem proves that decryption recovers the plaintext.
Article 5 (Chinese Remainder Theorem): CRT-RSA performs decryption modulo and modulo separately, then combines, for a significant speedup.
Article 6 (Quadratic residues): the Rabin cryptosystem (a variant of RSA) rests on the theory of quadratic residues.
Article 7 (Continued fractions): Wiener's attack on RSA with a small private key uses continued fractions to crack the system.
6 A worked example
Key generation: , ; ; .
Choose ().
Extended Euclidean algorithm: yields (since ).
Encryption: .
Decryption: (computed by repeated squaring).
7 Looking ahead: the quantum threat
8 Series summary
Modular arithmetic: the projection that discards information. The ring .
The Euclidean algorithm: an -time algorithm built on an invariant. Bé
The Fundamental Theorem of Arithmetic: uniqueness of prime factorization, resting on Euclid's lemma.
Fermat's little theorem: the group structure of . The inverse .
The Chinese Remainder Theorem: divide and conquer in algebra. .
Quadratic residues: the 2-to-1 nature of . The law of quadratic reciprocity.
Continued fractions: the Euclidean algorithm from another angle. Best rational approximations and Pell's equation.
RSA cryptography: the confluence of every theorem in the series.
Mathematics "between the lines" — exploring the intuition textbooks leave out, written in LaTeX on Folio.