Brief Introduction to RSA Cryptosystem
This is a note on the RSA cryptosystem which covered by Prof. Lauchie MacDonald's course MATH 312 at University of British Columbia.
Public Key Cryptography
In a "public key cryptosystem" there are two keys: a public key and a private key. The public key is used to encrypt messages, and the private key is used to decrypt messages. The public key is made public, and the private key is kept secret.
We denote an encryption procedure , a decryption procedure . They has four properties:
- Deciphering a ciphertext yields the original plaintext : .
- Both and are efficiently computable.
- By publicly revealing , it is not easy to compute .
- If a message is first deciphered and then enciphered, is obtained: .
Encryption and Decryption Methods
Notations and Definitions
Let's denote:
- as the message or plaintext
- as the ciphertext
- as the encryption procedure
- as the decryption procedure
- The pair of positive integers as the public key
- The pair of positive integers as the private key
The encryption and decryption algorithm and are defined as:
How to Choose the Keys
The public key and the private key are chosen as follows:
- You first compute as the product of two large primes and , i.e. .
- Pick a large integer that is relatively prime to , i.e. .
- The integer is finally computed from and by solving the equation . Note there must be a solution for because .
The Underlying Mathematics
We demonstrate the correctness of the deciphering algorithm using an identity due to Euler and Fermat: for any integer (message) which is relatively prime to ,
where is the Euler's totient function, which is the number of positive integers less than and relatively prime to . For prime numbers ,
In our case, because the totinent function is multiplicative, we have
Since is relatively prime to , there exists an multiplicative inverse of modulo , i.e.
Now, we want to prove that and .
The proof of is similar.
Now, we have proved that the encryption and decryption algorithm and are correct.