In encryption, how is it you can decrypt with a private key what was encrypted with a public key, or decrypt with a public key what was encrypted with a private key, but not private-to-private or public-to-public?

791 views

I am having a complete mental block understanding decryption with public and private keys. In my head, I am (apparently) falsely equating decryption to using a *Little Orphan Annie* decoder ring like in the movie *A Christmas Story*.

If a block of data was encrypted with a key, I can’t understand how a another key that is completely different is able to decrypt that data. I know there’s a fair bit of complex math involved, but if you multiple X by Y to get Z, then the only way to get X back from Z is to divide by Y.

* data->public key->encrypted->private key->data
* data->private key->encrypted->public key->data
* data->public key->encrypted->public key->error
* data->private key->encrypted->private key->error

In: 2

11 Answers

Anonymous 0 Comments

Lets take the classic [Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher), also known as a shift cipher, as an example.

In the Caesar cipher we take a letter in the message and replace it with a letter *k* steps later in the alphabet. If the letter we would substitute would fall outside the range of our alphabet we wrap around back to the start of the alphabet and keep going from there. The number *k* is our *encryption key* and we would decrypt by replacing each letter in the ciphertext with the letter *k* steps *before* in the alphabet, wrapping around to the other end of the alphabet as needed.

In this mode the Caesar cipher is a *symmetrical* encryption algorithm, the key used for encryption and decryption is the same.

But assume we can’t go backwards in the alphabet, meaning we can’t do our previously described decryption method. Can we still decrypt the message? Yes we can. We calculate a second key *d* which is (26 – *k*) (for the single-case English alphabet). If we then do the original encryption method again on the ciphertext with *d* as the key our resulting ciphered ciphertext is the original message. We see that by application of the encryption twice with *different keys*, the message has wrapped around back to the plain text. In this mode the Caesar cipher is *asymmetric*, it has a different key for encryption and decryption.

This whole “wrap around when you hit one end of a range of numbers” deal is a mathematical system called modular arithmetic, and I give you one guess as to what mathematical system turns up in most asymmetric encryption algorithms. More advanced encryption systems use exponentiation to wrap around many, many times across *very* large ranges of numbers (this is where you may have heard of the use of very large prime numbers being used in encryption) making the relationship between the encryption and decryption keys harder to figure out.

You are viewing 1 out of 11 answers, click here to view all answers.