RSA Encryption
RSA is like putting information into a locked mailbox. Anyone can encrypt, but only the person with the key can open and read its contents.
Setting up our encryption / decryption system
Before we start sending messages, we need to do some setup. We need to establish a system that allows us to encrypt and decrypt.
- First, we arbitrarily pick a set of primes and a and we set . Often times, and are very large (512 bits each) and we don't want the hacker to know them.
- Second, we pick an encryption key relatively prime to .
Our public key, something we distribute to anyone, is . With these two numbers, anyone can have the power to encrypt information into a specific format only we can decrypt.
- Now we derive a decryption key. We don't want the hacker to know this number!
Note, that and are derived in . The reason will become more apparent later in the proof. The decryption key is the inverse of the encryption key, which is astronomically hard for a classical computer to create without knowing . This decryption key is kept only for us to know.
To recap, we have our public and private keys!
Encrypting / Decrypting Messages
Let's say we have a message in the modspace of .
- Encrypting: is our encrypted message
- Decrypting: is our decrypted message
It's that simple! Just by using , we have our encrypted message. And with , we'd have our original message! We use modspace because computers have finite memory.
Why does this work?
We've setup our system such that:
-
- This is because our setup:
- This is because our setup:
Using this property we can rewrite the expression above as (will come in handy later):
We can use the previous relationship to rewrite the message after applying a decryption key:
In this form, we can reduce using the following.
-
- If is not a multiple of , then we can use Fermat's Little Theorem to reduce the expression.
- If is a multiple y , then expression reduces to by definition
- If is not a multiple of , then we can use Fermat's Little Theorem to reduce the expression.
-
- By symmetrical argument as above.
It is divisible by both and invididually. Since and are primes it must be divisible by their product,