By A.Xu ma OS
1. Introduction
Every time you log in to online banking or buy something online, your data is protected by mathematics. One of the most famous systems for doing this is RSA, named after Ron Rivest, Adi Shamir and Leonard Adleman, who published it in 1978.
RSA is a public-key cryptographic system whose security relies on prime numbers and modular arithmetic. Unlike symmetric encryption, RSA uses two keys: a public key, which can be shared openly, and a private key, which must remain secret.
Its central idea is the construction of a trapdoor function: an operation that is easy to perform but computationally infeasible to reverse without additional information, known as the trapdoor.
2. Constructing RSA
RSA starts with two distinct prime numbers, and , which are multiplied to produce the modulus . The prime factors are kept secret, whilst their product becomes public.
Then it uses Euler’s totient function, , which counts the positive integers up to that are co-prime to . Since and are distinct primes,
An integer is then chosen such that and . In practice, is almost always used. To reverse the process, we find an integer satisfying
Therefore, is the multiplicative inverse of modulo , and can be calculated efficiently using the Extended Euclidean Algorithm.
The public key is , and forms an essential part of the private key.
A message is first converted into an integer with . Encryption and decryption are then defined by
respectively, where is the original message and is the ciphertext.
2.1 A Worked Example
Take the small primes and . Then
Choosing , which is co-prime to 3120, the Extended Euclidean Algorithm gives , since
To encrypt the message , we calculate . To decrypt, we calculate , and the original message is recovered. Real RSA works in exactly the same way, but with primes hundreds of digits long.
3. Why Does RSA Work?
The correctness of RSA follows from Euler’s theorem, which states that
Since , we can write for some integer .
Substituting the encryption equation into the decryption equation gives
By Euler’s theorem, . Since both and lie between and , this means , and the original message is recovered.
There is, however, a subtlety: Euler’s theorem requires . RSA must also work when the message shares a factor with .
This can be established using the Chinese Remainder Theorem. Since , it is sufficient to prove that
Consider the congruence modulo . If , the result is immediate. Otherwise, Fermat’s Little Theorem gives . Since , divides , and it follows that
for some integer . The same argument applies modulo . The Chinese Remainder Theorem therefore gives
for every message .
4. Euler’s Function and Carmichael’s Function
Although Euler’s totient function is sufficient for constructing RSA keys, is not the smallest exponent that guarantees the required result.
A more precise function is Carmichael’s function, , defined as the smallest positive integer such that for every co-prime to .
For an RSA modulus consisting of two distinct primes, . Using the identity , we obtain
Therefore, .
The distinction is important: counts the integers relatively prime to , whereas describes the smallest universal exponent for which Euler’s theorem holds.
Instead of requiring , RSA can therefore use the weaker condition
This is sufficient for correct decryption because Carmichael’s function guarantees that whenever . When shares a factor with , the argument from Section 3 still works modulo and modulo , since and both divide .
In modern implementations, Carmichael’s function is preferred because it gives the smallest valid private exponent , and modern standards for generating RSA keys specify it. In our example, , which gives instead of , since .
5. The Trapdoor
The security of RSA comes from the difference between performing an operation and reversing it.
Calculating is computationally trivial, even for very large values of . However, reversing it without the private key is believed to be infeasible. The trapdoor is knowing the primes and : with them, anyone can calculate and then , but nobody knows an efficient way to find from and alone. In fact, knowing is enough to factorise , so finding this way is as hard as factorising.
RSA therefore exploits the difficulty of factorising sufficiently large integers into primes. In practice, these primes are usually 1024 bits long, a decimal order of magnitude around , so the modulus is a 2048-bit number of around . The largest RSA challenge number factorised so far has only 896 bits, a record set in September 2026, and factorising a 2048-bit modulus with known methods is far beyond the reach of any existing computer. However, a large enough quantum computer could factorise such numbers efficiently using Shor’s algorithm, which is why new “post-quantum” cryptographic systems are being developed.
The version of RSA described here, known as “textbook RSA”, always encrypts the same message to the same ciphertext, which makes it insecure on its own. Real implementations therefore always use padding schemes such as RSA-OAEP, which add randomness to the message before it is encrypted. For highly classified data, the bit length can also be increased, for example to 4096 bits.
6. Conclusion
RSA demonstrates a fascinating paradox: mathematical operations can be easy to perform but extraordinarily difficult to reverse. By turning number theory into the foundation of digital privacy, it shows that maths is not just about finding solutions, but also about exploiting the limits of computation.
References
“Carmichael Function.” Wolfram MathWorld. https://mathworld.wolfram.com/CarmichaelFunction.html.
Rivest, Ronald L., Adi Shamir, and Leonard Adleman. “A Method for Obtaining Digital Signatures and Public-Key Cryptosystems.” Communications of the ACM, vol. 21, no. 2, 1978, pp. 120–126. https://doi.org/10.1145/359340.359342.
“RSA.” Stanford University Applied Cryptography Group. https://crypto.stanford.edu/pbc/notes/crypto/rsa.html.
“RSA Factoring Challenge.” Wikipedia, Wikimedia Foundation. https://en.wikipedia.org/wiki/RSA_Factoring_Challenge.
“Totient Function.” Wolfram MathWorld. https://mathworld.wolfram.com/TotientFunction.html.





Leave a Reply