Skip to main content

RSA

The setting is that Alice wants to send a message to Bob while making sure that the message cannot be read by an eavesdropper (Eve).

Let pp and qq be two large primes and N=pqN= pq. Moreover, take ee to be a number such that gcd(e,(p1)(q1))=1{\sf gcd}(e,(p-1)(q-1)) = 1. We write d=e1(mod(p1)(q1))d = e^{-1} \pmod{(p-1)(q-1)} (recall that such an inverse exists). The values of NN and ee are made public by Bob (i.e., anyone who wants to send a message to him can use these values to encrypt the message). The rest of the numbers are private and known only to Bob.

  • Encryption: Alice sends message xx to Bob by computing the value E(x)xe(modN)E(x) \equiv x^e \pmod{N}.

  • Decryption: Upon receiving the message yy, Bob computes D(y)yd(modN)D(y) \equiv y^d \pmod{N}.

The correctness of this protocol relies on a simple fact in number theory. The next subsection takes a small detour to cover that fact.

We remark that RSA is not provably secure. Indeed, it seems that the only way for Eve to recover the message xx is trying all numbers from 00 to NN (which is infeasible when NN is, e.g., 512 bits long). Let us try to understand this more systematically. One potential attempt by Eve might be to factor NN into pqp\cdot q, which would allow her to construct d=e1(mod(p1)(q1))d = e^{-1} \pmod{(p-1)(q-1)}. But factoring is also believed to be computationally hard, and this is a standard assumption in computation.

More precisely, the security of RSA depends on the following assumption:

Given N,eN,e and y=xe(modN)y = x^e \pmod{N}, no efficient algorithm can determine xx.