1. .
Let us assume that two users namely, Alice and Bob want to
exchange a secret key using the Diffie-Hellman Key exchange
protocol. Assuming the values n=11, g=5, x=2 and y=3, find out the
values of A, B and the secret key K1 or K2.
Prime modulus: n=11
Primitive root (base): g= 5
Private key of Alice: x= 2
Private key of Bob: y=3
Step 1: Calculate Alice’s public value A
A = gx mod n
A = 52 % 11
A = 25 % 11 => 3
Step 2: Calculate Bob’s public value B
B = gy mod n
B = 53 % 11 => 125 % 11 => 4
Step 3: Compute the shared secret key
Alice computes: K1 = Bx mod n
= 42 % 11 => 16 % 11 =>5
Bob computes:
K2 = Ay mod n => 33 % 11 => 27 % 11 => 5
Ans:
A = 3(Alice public key)
B = 4 (Bob public key)
K1= 5 (Alice shared secret key)
K2 = 5 (Bob shared secret key)
For a Vernam Cipher do the following: Using one-time pad
“NCBTZQARX” encode "HOW ARE YOU".
→
Letters are converted to numbers:
A = 0, B = 1, C = 2, ..., Z = 25
The cipher is:
Ci = (Pi + Ki) mod 26
Value Value (P + K)
Position Plaintext Key Cipher
(P) (K) % 26
1 H 7 N 13 20 U
2 O 14 C 2 16 Q
3 W 22 B 1 23 X
4 A 0 T 19 19 T
5 R 17 Z 25 16 Q
6 E 4 Q 16 20 U
7 Y 24 A 0 24 Y
8 O 14 R 17 5 F
9 U 20 X 23 17 R
Ans: “UQXTQUYFR”
Convert plain text to cipher test using Play Fair method.
The key is ‘MONARCHY' and the plain text "FACTIONALISM”.
→Step 1: Create the 5×5 Playfair Matrix
Remove duplicate letters from the key:
Key = "MONARCHY" → Unique letters: M O N A R C H Y
Fill remaining letters of alphabet (I/J are treated as one letter):
Alphabet: A–Z (excluding J, or I/J treated as one)
Unused letters: B D E F G I/K L P Q S T U V W X Z
Final matrix:
M O N A R
C H Y B D
E F G I K
L P Q S T
U V W X Z
Step 2: Prepare Plaintext
Plaintext = "FACTIONALISM"
1. Replace J with I (not needed here).
2. Break into digraphs (pairs of 2 letters). If a pair has the same letter or
is a single letter, insert 'X'.
"FACTIONALISM" → FACTIONALISM
Plaintext Pair Ciphertext Pair
FA IO
CT DL
IO FA
NA AR
LI SE
SM LA
Final Ciphertext:
IODLFAARSELA
In RSA system, the public key of a user is 17 and N = 187. Calculate
the private key and public key?
Given:
• Public exponent e = 17
• Modulus N = 187
• Goal: Find private key d, and confirm public key (e, N)
Step 1: Factor N = 187
• We try small primes:
• 187=11×17 ⇒ p =11, q=171
Step 2: Compute Euler’s totient function ϕ(N)
• ϕ(N) = (p−1)(q−1) = (11−1)(17−1) =10×16 =160
Step 3: Confirm e = 17 is coprime with ϕ(N) = 160
Check: gcd (17,160) =1 OK
Step 4: Compute the modular inverse of e modulo ϕ(N)
We want to find d such that:
d⋅e ≡ 1mod 160 ⇒ d⋅17 ≡ 1 mod 160
This is the modular inverse of 17 modulo 160:
We use the Extended Euclidean Algorithm.
We solve for:
17d ≡ 1 mod 160
Step a b q r
1 160 17 9 7
2 17 7 2 3
3 7 3 2 1
4 3 1 3 0
Now backtrack to express 1 as a combination of 160 and 17.
1 = 7 - 2×3
= 7 - 2×(17 - 2×7)
= 7 - 2×17 + 4×7
= 5×7 - 2×17
= 5×(160 - 9×17) - 2×17
= 5×160 - 45×17 - 2×17
= 5×160 - 47×17
1 = 5×160 − 47×17
1 = −47×17 + 5×160
• Since 5×160≡0(mod160)5 (because any multiple of 160 is divisible by 160),
• The equation becomes:
1 ≡ − 47×17 ( mod 160 )
− 47×17 ≡ 1 (mod 160)
Find the positive modular inverse
(because −47+160=113)
113×17 ≡ 1 (mod 160)
Final Answer:
• Public Key: (e = 17, N = 187)
• Private Key: (d = 113, N = 187)
Perform decryption and encryption using RSA algorithm with p=3, q=11, e=7 and N=5.
Given:
• p=3
• q=11
• e=7
• N=33(5 hobena)
Step 1: Compute N= p×q
• N = 3×11=33
• So N = 5 is wrong, it should be 33
Step 2: Compute Euler’s totient function ϕ(N)
• ϕ(N) = (p−1)(q−1) = (3−1)(11−1) = 2×10 = 20
Step 3: Public key is (e, N) = (7, 33)
• We must ensure gcd(7,20 ) = 1 OK
Step 4: Find Private Key d
• Find d such that:
d×e ≡ 1 (mod 20) ⇒ d×7 ≡ 1 (mod20)
Try values manually or use the Extended Euclidean Algorithm. Try d=3:
• 7×3 = 21 ⇒ 21 mod 20 => 1
d=3
Keys Summary:
• Public Key: (e = 7, N = 33)
• Private Key: (d = 3, N = 33)
In the public-key system using RSA, you intercept the cipher text
CT=1570 sent to a user whose public key is E=79, N=3337. What is the
plain text PT.
Step Dividend Divisor Quotient Remainder
1 3220 79 40 60
2 79 60 1 19
3 60 19 3 3
4 19 3 6 1
5 3 1 3 0
Step 4: Decrypt using the formula:
PT = CTd mod N => 15701019 mod 3337 => 688(ans)
In a public-key system using RSA, you intercept the cipher text C = 10
sent to a user whose public key is e = 5, n = 35. What is the plaintext M?
(8) ii) In an RSA system, the public key of a given user is e = 31, n = 3599.
Determine the private key of this user?
→
Part (i)
Given:
• Ciphertext C=10
• Public key e=5
• n=35
• Find: Plaintext M
Step 1: Factorize n=35n = 35n=35
• 35=5×7
So,
p=5, q=7
Step 2: Compute φ(n)=(p−1)(q−1)
• φ(35)= (5−1)(7−1) = 4×6 = 24
Step 3: Find the private key ddd
• We want to find d such that
• d×e ≡ 1 (mod φ(n))
• d×5 ≡ 1 (mod24)
Step 4: Find d
Try multiples of 24 + 1 divisible by 5:
If d = 5
then 5 * 5 ≡ 1 mod(24)
So d = 5
Step 5: Decrypt ciphertext
M=Cd mod n = 105 mod 35 => 5
M = 5 (ans)