RSA is an encryption algorithm, used to securely transmit messages over the internet. It is based on the principle that it is easy to multiply large numbers, but factoring large numbers is very difficult.

The algorithm is implemented as follows:

  1. The receiver chooses two large prime numbers and . Let
  2. The receiver calculates and choose a number relatively prime to . In practice, is often chosen to be
  3. The receiver calculates the modular inverse of modulo , that is,
  4. The receiver distributes the public key and keep secret the private key

Now that the public and private keys have been generated, they can be reused as often as wanted. To transmit a message, follow these steps:

  1. First, the sender converts his message into a number . One common conversion process uses the ASCII alphabet. For example, the message "HELLO" could be encoded as . It is important that , as otherwise the message will be lost when taken modulo , so if  is smaller than the message, it will be sent in pieces.
  2. The sender then calculates  is the ciphertext, or the encrypted message. Besides the public key, this is the only information an attacker will be able to steal.
  3. The receiver computes , by Euler's Theorem retrieving the original number
  4. The receiver translates  back into letters, retrieving the original message.

Proof of step 3

By the definition of , there exists satisfying . Then we have