Shift Cipher

Why
The shift cipher is important because it demonstrates a simple substitution cipher that was used in the past by Julius Caesar.

What
The shift cipher is a monoalphabetic cipher and a cryptosystem that takes messages (from a domain that maintains message ordering such as the alphabet) and shifts them a certain number (key) along the ordering as the encoding. The decoding simply shifts back the same number of elements that was originally shifted.

Vulnerabilities
As a monoalphabetic cipher, the shift cipher is succeptible to frequency analysis attacks

Normal Shift Cipher
The shift cipher requires a key $$k$$ that is used as both the encryption key $$ke$$ and decryption key $$kd$$. Also, we need a number $$N$$ that represents the total number of messages in the message space.

Encoding Normal Shift Cipher
$$E_k(m) = (m + k) modN$$

Decoding Normal Shift Cipher
$$D_k(c) = (c - k) modN$$

Multiplication Cipher
We can create a special shift cipher if we choose the key $$k$$ such that $$gcd(k, N) = 1$$. If this is true, then we are guaranteed that $$(km)modN$$ ranges over the entire message space. We are also guaranteed that an inverse $$k^{-1}$$ exists if the key is relatively prime to the number of elements in the message space.

Encoding Multiplication Cipher
$$E_k(m) = (km)modN$$

Decoding Multiplication Cipher
$$D_k(c) = (k^{-1}c)modN$$

Affine Cipher
We can create another special shift cipher called the affine cipher if we choose a key $$k_1$$ such that $$gcd(k_1, N) = 1$$. Then we choose another number $$k_2$$

Encoding Affine Cipher
$$E_{k_1, k_2}(m) = (k_1m + k_2)modN$$

Decoding Affine Cipher
$$D_{k_1, k_2}(c) = k_1^{-1}(c - k_2)modN$$

Example 1
Setup:
 * Use the normal shift cipher
 * Use the alphabet as the message space, where each letter is a message
 * Take the shift coefficient / key to be 3 (same as the Caesar cipher)

Question: What would BED be encoded to using the above cipher?
Answer: EHG

Question: What would BED be decoded to using the above cipher?

Answer: YBA