CS304 Scribe Week1
CS304 Scribe Week1
1 Cryptography
Cryptography:-
→ In cryptography, we develop the algorithms to get security.
→ Cryptography is the study of secure communications techniques that allow only the sender and
intended recipient of a message to view its contents.
Cryptanalysis:-
→ In cryptanalysis, we try to break the security of designed algorithm.
→ Cryptanalysis is the study of ciphertext, ciphers and cryptosystems with the aim of understand-
ing how they work and finding and improving techniques for defeating or weakening them.
Cryptology:-
→ Cryptology = Cryptography + Cryptanalysis.
→ Cryptology is the science of secure communications.
2 Types of Cryptosystem
1. Symmetric Key Cryptosystem
• Symmetric key cryptosystem has one secret key.
2. Public Key Cryptosystem
• Public key cryptosystem has two keys: 1. public key and 2. secret key.
• E(P, e) = C
• D(C, d) = P
1
Confidentiality:-
• Plaintext: It is original message.
• Encryption Algorithm: It is function to encrypt the message.
• Ciphertext: It is unreadable form of the plaintext.
• Decryption Algorithm: It is function to decrypt the ciphertext.
• Encryption Key: Key for encryption.
• Decryption Key: Key for decryption.
→ Encryption Function:
• (m, Key) = C, where m = message (plaintext), key = encryption key and c = ciphertext.
• Encryption function defined as P X Key = Ciphertext(c)
→ Decryption Function:
• (C, Key) = m, where m = message (plaintext), key = decryption key and c = ciphertext.
• Decryption function defined as C X Key = Plaintext(m)
4 CAESAR Cipher
→ Named after Julius Caeser → Shifting the letters of a message by k places.
agreed value of k = 3.
E.g.: D → G (Right shift by 3).
E(x, 3) = (x + 3)%26 = C
D(C, 3) = (x + 26 − 3)%26
5 Transposition Cipher
→ M = m1 m2 m3 ...mt
→ e : permutation on t elements → secret key
Secret Key
1 2 3 4 5 6
6 4 1 3 5 2
E.g.: CAESER
C A E S E R
R S C E A A
2
6 Substitution Cipher
Only difference between Transposition and Substitution is that transposition’s size of domain =
size of codomain.
Plain text: A B C
Cipher text: Z D A
7 Affine Cipher
A B C ... Z
0 1 2 ... 25
A → Z26
k = secret key = (a, b)ϵZ26 × Z26 and gcd(a, 26) = 1
→ Encryption:
e(m, k) = (am + b)mod26 = c
→ Decryption:
d(c, k) = ((c − b)a−1 )mod26
a ∗ a−1 = 1mod26
Proof
gcd(x, m) = 1
0 ̸= xϵZm
gcd(x, m) = 1
x ∗m y = 1
xy = 1modm
m∥(xy − 1)
xy − 1 = t m
1 = t1 m + xy for some t1
∴ gcd(x, m) = t1 m + xy
8 Playfair Cipher
→ Placing secret key in the form of a table with all remaining elements in 5 × 5 table. → I = J so
one of them is excluded(usually J). → For each pair (c[i], c[i+1]) where i is even and c[i] denotes
the character at ith index, we do the following:
1. If both the letters are in the same column: Take the letter below each one (going back to the
top if at the bottom).
2. If both the letters are in the same row: Take the letter to the right of each one (going back
to the leftmost if at the rightmost position).
3. Else: Form a rectangle with the two letters and take the letters on the horizontal opposite
corner of the rectangle.
3
E.g.: Secret key = PLAYFAIR EXAMPLE
Plaintext: HIDE P L A Y F
HI DE I R E X M
↓ ↓ B C D G H
BM OD K N O Q S
Ciphertext: BMOD T U V W Z
→ For odd length, we add an X to the end. ODD → OD DX