Oh My God
Important note!
The key idea behind the algorithm is that, while the Private Key and Public Key are different, they’re mathematically related. It’s impossible to guess how to go from one to the other.
What:
So, the crux of Asymmetric Encryption is that you can come up with a Private-Public Key pair that’s pretty damn secure. How do you do that though? Using this Algorithm.
Encrypting the Message:
We’ll use the following Encryption formula
Where:
- is the ciphertext (the encrypted message).
- is the message that is being encrypted.
- is the public exponent (public key entry 1).
- is the modulus (public key entry 2).
Basically:
- Given a public key like
(5,14)
, you take your message, putkey[0]
as an exponent, and get the modulus ofkey[1]
as your ciphertext.
Example:
- For this example, my public key is
(5,14)
. My private key is(11,14)
- If I want to send the secret message
B
, I represent it as ASCII with2
. - My cipher text is:
- Therefore, my secret message
B
is encrypted asD
Decrypting the Message
It’s literally the same, but using the private key.
How’d you come up with those keys??
- Pick 2 (HUGE) prime numbers.
- Get the product of those numbers.
- Get the amount of co-prime numbers with 14.
- Co-prime: A number that does not share any factors with another. 1
- This number can be got with the formula:
- Come up with a number that follows the following criteria:
- is co-prime with both and .
- Note how is both of those.
- Finally, we want to come up with a number - your letter for decrypting.
- Choose such that:
- There’ll be infinite amount of options to choose from. There’s some (more complicated) rules to this.