Cryptography mathematics studies how numbers, functions, and keys are used to protect information. This cheat sheet helps students connect algebra, number theory, and modular arithmetic to real encryption methods. It is useful for solving cipher problems, checking key conditions, and understanding why secure communication depends on hard math problems.
Key Facts
- In modular arithmetic, a ≡ b mod n means a and b have the same remainder when divided by n.
- A Caesar cipher encrypts a letter number x using E(x) = (x + k) mod 26, where k is the shift key.
- A Caesar cipher decrypts using D(y) = (y - k) mod 26, then adjusts the result to a number from 0 to 25.
- An affine cipher encrypts using E(x) = (ax + b) mod 26, where gcd(a, 26) = 1 is required.
- An affine cipher decrypts using D(y) = a^-1(y - b) mod 26, where a^-1 is the modular inverse of a.
- A number a has a modular inverse mod n only when gcd(a, n) = 1.
- In RSA, choose primes p and q, compute n = pq and phi(n) = (p - 1)(q - 1), then choose e with gcd(e, phi(n)) = 1.
- RSA encryption uses c = m^e mod n, and RSA decryption uses m = c^d mod n where ed ≡ 1 mod phi(n).
Vocabulary
- Plaintext
- The original readable message before encryption is applied.
- Ciphertext
- The scrambled message produced after encryption.
- Key
- A number or set of numbers that controls how a message is encrypted or decrypted.
- Modular arithmetic
- A system of arithmetic where numbers wrap around after reaching a fixed modulus.
- Modular inverse
- The modular inverse of a mod n is a number a^-1 such that aa^-1 ≡ 1 mod n.
- Public key
- A key shared openly so others can encrypt messages or verify digital information.
Common Mistakes to Avoid
- Using normal division instead of remainders is wrong because modular arithmetic depends on the remainder after division by the modulus.
- Forgetting to wrap negative values is wrong because results like -3 mod 26 should be rewritten as 23.
- Choosing any value of a in an affine cipher is wrong because a must satisfy gcd(a, 26) = 1 to make decryption possible.
- Confusing the public exponent e with the private exponent d is wrong because e encrypts in RSA while d reverses the operation.
- Using letters without assigning consistent numbers is wrong because changing between A = 0 and A = 1 systems changes the encrypted result.
Practice Questions
- 1 Encrypt the letter H using a Caesar cipher with A = 0 and shift k = 5.
- 2 Find 17 mod 5, 38 mod 9, and -4 mod 26.
- 3 For the affine cipher E(x) = (5x + 8) mod 26, encrypt the letter C using A = 0.
- 4 Explain why RSA can have a public encryption key without making the private decryption key easy to find.
Understanding Cryptography Mathematics
Modular arithmetic is easiest to picture as a clock with a fixed number of positions. After the final position, counting returns to the start. This creates a useful rule for encryption because every calculation stays within a limited set of values.
Negative results need care. A shift backward from zero may produce a negative number at first, but it represents a position near the end of the alphabet cycle. Students should choose one letter numbering system and keep it throughout a problem.
Mixing a system that starts at zero with one that starts at one causes many wrong answers. It is worth checking each result by converting the final number back into a letter.
The affine cipher shows why not every multiplication key works. Multiplication can merge different input letters into the same output letter when the key shares a factor with the alphabet size. Once two inputs have merged, decryption cannot tell them apart.
A valid multiplication key avoids this problem because it has an inverse in the modular system. The Euclidean algorithm is a practical way to test this condition and to find the inverse. Students often make the mistake of treating an ordinary decimal inverse as a modular inverse.
In modular work, the needed number is one that gives a remainder of one after multiplication by the key. Checking that multiplication is a reliable final step.
RSA uses a different idea from simple substitution ciphers. One key can be published for anyone to use, while a separate key is kept secret for decoding. The system is built so that the two key operations undo each other for valid messages.
Its security comes from the difficulty of factoring a very large number that was made by multiplying two secret primes. Knowing that product alone does not normally reveal the primes quickly. In classroom examples, the primes are small enough to calculate by hand.
Real systems use primes with hundreds or thousands of digits. The value based on the two primes is important because it controls which exponent pairs can work together.
Modern secure websites, banking apps, and messaging services use cryptography, but they rarely encrypt every piece of data with RSA alone. Public key methods are slower than symmetric methods for large files. A common design uses public key encryption to safely establish a short shared secret, then uses that secret for fast encryption of the data.
Cryptography also needs more than secrecy. Systems must detect changed messages and confirm who sent them. When studying cipher exercises, separate the roles of the message, ciphertext, key, modulus, and inverse before calculating.
Keep each intermediate remainder clear. Small arithmetic errors can spread through every later step, while a careful check after each operation usually finds them.