Introduction
RSA is a public-key cryptosystem developed by Ron Rivest, Adi Shamir and Leonard Adleman and published in 1977. The encryption key (public key) and the decryption key (secret key) are distinct. Anyone can encrypt the message but only whom keeps the secret key can decrypt it.
The Core Ideas
From an original message , the encrypted message is created by powering it to an “encryption factor” and modulo to an appropriate value , calculated by:
And then, from the encrypted message , the original message can be recorvered by powering it to a “decryption factor” and also modulo to :
This means , this implies:
Let the “encryption factor” be revealed to the public for encryption and the “decryption factor” be used to decrypt a message and kept private. But how to find those keys, and especially, how to find ?
Moving next, the Euler’s Theorem and the totient function
For any , then in which is the totient function defined by:
Some properties of the totient function:
If , then
If is a prime, then
Applying the Euler’s theorem to the encryption scheme
If letting the original message to be , then the target is to find an appropriate satisfying:
The RSA Algorithm
Choose 2 prime numbers:
Calculate
Choose such that: . This is written in the algorithm as:
Choose \(1
Choose such that
The public key is and secret key is
Encryption:
Decryption:
It is clearly seen that:
Hope this post helps you a better understanding.
You could find an interactive demo of this algorithm here.