CRYPTOGRAPHY:
Cryptography means “secret writing”, derived from ‘crypto’ (secret) and ‘graphy’ (writing),,, wow
A cipher is an algorithm that converts plaintext (readable text) into ciphertext (gibberish) using a key
Encryption is the process of converting plaintext to ciphertext; decryption reverses it
CEASER CIPHER:
Julius Caesar used this cipher by shifting letters forwards by 3 positions (e.g., A → D, B → E, C → F…)
Mathematically:
- Letters are mapped to numbers (A → 0, B → 1, C → 2, …, Z → 25)
- Encryption:
- Decryption:
Example:
Encrypt the message “Socrates is mortal” using the Caesar Cipher
AFFINE CIPHERS:
This just generalizes the Caesar cipher to functions of the form
where are arbitrary integers, with the only condition that the resulting be bijective
The pair is called the key of the affine cipher
Theorem: is bijective IF AND ONLY IF , and in that case, find an inverse function (which is the decryption function)
Proof:
First, bijective means that every output has EXACTLY one input. No overlaps, no missing outputs
For to be reversible:
- Each letter must map to a unique encrypted letter
- No two letters can encrypt to the same letter (so both A and N cannot map to → B)
If the , multiple inputs collide to the same output
- For example, let Then,
- “A” (”A”), “N” (”A”)
- Collision occurs!
If , solve for :
Subtract , then multiply by :
Inverse is the number such that
where y represents the encrypted number and x represents the original number
SUBSTITUTION CIPHER:
Substitution ciphers preserve letter frequencies. Example, the most common letter in English is E, so if your cipher translates E to an X, then X will show up the most frequently in the ciphertext.
So, attackers can exploit frequency in order to break the cipher
PUBLIC VS PRIVATE KEY:
Affine ciphers are private key cryptosystems
Private keys: The same key is used to encrypt and decrypt a message
- Kinda like a physical lock and key → only people with the key can open it
Public key: There are two types of keys:
- Public key (shared): Anyone can use it to encrypt a message
- Private key (secret): Only the owner can decrypt a message
- Kinda like a mailbox, anyone can drop off mail in a mailbox, but only the owner can open it
Therefore, everyone can have a public encryption key. The only key that needs to be kept private is the decryption key.
THE RSA CRYPTOSYSTEM:
The encryption key (public) is a pair of integers where (the modulus) is the product of two large primes, and (the exponent) is coprime with the product
The private key is going to be the pair of integers
So:
- Choose two primes and keep them secret
- Compute and release it as part of the public key
- Compute and keep it a secret
- Choose an integer such that AND and release it as part of the public key
- Compute (e.g., Euclid + Bezout: is a Bezout coefficient for in the Bezout identity ) and keep it a secret
Encryption: (anyone can encrypt a message since are known)
Decryption: (only people who can know can use this function)
To encrypt the message , we compute (y is the encrypted message)
To decrypt the message , we compute
Example: