Professional Documents
Culture Documents
TH1: n is prime:
Q2. You agreed to use a Caesar cipher with a key of k=4 with a friend. While
sitting in a group, the friend hands you over a message that says
“AIHRIWHEC”. Decrypt the message?
Dạng này chia lấy phần dư xong so sánh với bảng chữu cái dưới đây.
Lưu ý: -4 mod 26 = -4 nhưng ta sẽ lấy 26 - 4=22 để theo bảng chữ cái 26 chữ
Với bài encrypt thì ta phải + với k thay vì trừ
The English alphabet:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
A = (0 – 4) mod 26 = 22 W
I = (8 – 4) mod 26 = 4 E
H = (7 – 4) mod 26 = 3 D
R = (17 – 4) mod 26 = 13 N
I = (8 – 4) mod 26 = 4 E
W = (22 – 4) mod 26 = 18 S
H = (7 – 4) mod 26 = 3 D
E = (4 – 4) mod 26 = 0 A
C = (2 – 4) mod 26 = 24 Y
The plain text of AIHRIWHEC is WEDNESDAY
Q3. Suppose you actually forgot the key. How many decryption computations
of the cipher text “QNGWFWD” do you need to perform to reach to the
plaintext?
Because the formula of decryption Caesar cipher is:
C = (X – K) mod 26
If forgot the key, after 26 times rotated the text will come right back to
the original.
Q4. Using the Permutation Cipher with the same key [3 5 1 2 4], what is the
ciphertext for the plaintext GOODTHINGSTAKETIME? (Leave the unfilled
matrix as blank).
(Dạng này nếu đề bài cho key là chữ thì ta xác định thứ tự của các chữ cái trong
bảng rồi thành key. VD: hack key = 3124)
Dạng này ta dịch đề là mã hoá plaintext to ciphertext thì ta sẽ viết bảng theo
thứ tự 1 5 rồi điền các kí tự cần thiết vao nhưng khi đọc theo cột ta phải đọc
theo thứ tự key đề bài cho.(Không có gì thì ta điền X)
Permutation Cipher with a key:
1 2 3 4 5
G O O D T
H I N G S
T A K E T
I M E X X
Q4. Using the Permutation Cipher with the same key [3 5 1 2 4], what is the
plaintext for the ciphertext ONKETSTXGHTIOIAMDGEX? (The unfilled
matrix is filled with letter ‘X’, remove it to get the final answer).
Dạng này ta dịch đề là giải mã ciphertext to plaintext thì ta sẽ viết bảng theo
thứ tự key đề cho rồi truyền câu vào, sau đó sắp xếp lại thứ tự từ 1 5 rồi đọc
theo chiều ngang.
1 2 3 4 5
G O O D T
H I N G S
T A K E T
I M E X X
Write plainttetx of ONKETSTXGHTIOIAMDGEX by write letter each row
from left to right, top to bottom: GOODTHINGSTAKETIME
Q5. Euler totient function of n (we use the Greek symbol phi to denote Euler
totient function) is the number of positive integers that are between 1 and n - 1,
inclusive, and are relatively prime to n. What is the Euler totient function of 72?
Dạng này ta lấy số bài cho phân tách ra thành tích các số nguyên tố sau đó áp
dụng công thức ở đầu
72 = 2 ^ 3 * 3 ^ 2
totient(72) = 72 * (1 – 1/2) * (1 – 1/3) = 24
Q6. Using the same notations as in the lecture, e.g., p and q are the two primes
and e and d are the public key and the private key, respectively, p = 7, q = 13, e
= 7. What is the value of phi(n) where phi(n) is the Euler Totient function of n
and n is the modulus of RSA cipher?
Dạng này thấy có p, q, e ta lấy totient(p*q) là ra kết quả.
P = 7, q = 13, e = 7
totient(7 * 13) = totient(91) = (p – 1) * (q – 1) = 72
Q7. Using the same notations as in the lecture, e.g., p and q are the two primes
and e and d are the public key and the private key, respectively, p = 7, q = 13, e
= 7. Using the phi(n) that you found in the question 6 and the Extended
Euclidean algorithm yields d = 31. What is the ciphertext C when encrypting M
= 19?
p = 7, q = 13, e = 7, d =31, M = 19
totient(7 * 13) = 72
- Formula of Extended Euclidean algorithm:
o Encryption: C = M ^ e mod n
o C = 19 ^ 7 mod 91
= (19 ^ 2 * 19 ^ 2 * 19 ^ 2 * 19) mod 91
= (19 ^ 2 mod 91 * 19 ^ 2 mod 91 * 19 ^ 2 mod 91 * 19 mod 91)
mod 91
= (88 ^ 3 * 19) mod 91 = 33
Q8. Using the same notations as in the lecture, e.g., p and q are the two primes
and e and d are the public key and the private key, respectively, p = 7, q = 13
and e = 7. The attacker performs a chosen-ciphertext attack (CCA). It has a
known ciphertext 18 and wants to retrieve the corresponding plaintext. It
computes c’ = c*r^e mod n and chooses the ciphertext 18*128 mod 91 = 29 and
retrieves the corresponding plaintext, 29. What is the plaintext corresponding to
the ciphertext 18?
p = 7, q = 13, e = 7, C =18, m’ = 29
n = p * q = 13 * 7 = 91
c’ = c*r^e mod n chooses the ciphertext 18*128 mod 91 = 29
r = √7 128 = 2 (bậc của căn là e, trong căn là r^e)
m’ = m*r mod n 29 = m*2 mod 91
m = (k * n + m’) / r = (k * 91 + 29) / 2 (đoạn này lập table chạy giá trị k đến khi
nào lấy được số nguyên với k bé nhất thì dừng)
k = 1, m = 60 (Đáp án là 60)
Q9. Alice and Bob use Diffie-Hellman Key Exchange to share a key with a
common prime p = 17 and a primitive root a=3. If Alice has a public key
Y_A=11, what is her private key X_A?
Y_A=11 , a=3 , p=17
- Use formula Diffie-Hellman Key Exchange:
Y_A = a ^ X_A mod p
11 = 3 ^ X_A mod 17 (Đoạn này CALC từ 0 :>)
X_A = 7
Nhìn kĩ giá trị và công thức để áp dụng chính xác tránh việc thay nhầm số :v