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:
- The receiver chooses two large prime numbers and . Let
- The receiver calculates and choose a number relatively prime to . In practice, is often chosen to be
- The receiver calculates the modular inverse of modulo , that is,
- 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:
- 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.
- 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.
- The receiver computes , by Euler's Theorem retrieving the original number
- The receiver translates back into letters, retrieving the original message.
Proof of step 3
By the definition of , there exists satisfying . Then we have