HW4

Seungyun Lee·2026년 4월 19일

Cybersecurity

목록 보기
20/24

4.1 Encrypt and decrypt by means of the RSA algorithm with the following system parameters

1

n=pq=311=33n = p \cdot q = 3 \cdot 11 = 33
ϕ(n)=(p1)(q1)=210=20\phi(n) = (p - 1)(q - 1) = 2 \cdot 10 = 20
7e1(mod20)7 \cdot e \equiv 1 \pmod{20}
73=211(mod20)7 \cdot 3 = 21 \equiv 1 \pmod{20}, e=3e = 3

Public(e,n)=(3,33)(e, n) = (3, 33),
Private (d,n)=(7,33)(d, n) = (7, 33)

y53(mod33)y \equiv 5^3 \pmod{33}
y=125(mod33)y = 125 \pmod{33}

267(mod33)26 \equiv -7 \pmod{33}
x267(mod33)x \equiv 26^7 \pmod{33}
(7)74(7)=285(mod33)(-7)^7 \equiv 4 \cdot (-7) = -28 \equiv 5 \pmod{33}
x=5x = 5

2

n=511=55n = 5 \cdot 11 = 55
ϕ(n)=40\phi(n) = 40
3d1(mod40)3 \cdot d \equiv 1 \pmod{40}
Public (e,n)=(3,55)(e, n) = (3, 55)
Private (d,n)=(27,55)(d, n) = (27, 55)
y93(mod55)y \equiv 9^3 \pmod{55}
x1427(mod55)x \equiv 14^{27} \pmod{55}
142=19631(mod55)14^2 = 196 \equiv 31 \pmod{55}
144312=96126(mod55)14^4 \equiv 31^2 = 961 \equiv 26 \pmod{55}
148262=67616(mod55)14^8 \equiv 26^2 = 676 \equiv 16 \pmod{55}
1416162=25636(mod55)14^{16} \equiv 16^2 = 256 \equiv 36 \pmod{55}

142736163114(mod55)14^{27} \equiv 36 \cdot 16 \cdot 31 \cdot 14 \pmod{55}
3614=5049(mod55)36 \cdot 14 = 504 \equiv 9 \pmod{55}
x=9x = 9

2. Compute the two public keys and the common key for the DHKE scheme with the parameters p = 467, α = 2, and

1

Alice's Public Key: Aαa(modp)A \equiv \alpha^a \pmod p
Bob's Public Key: Bαb(modp)B \equiv \alpha^b \pmod p
Common Secret Key: KBa(modp)Ab(modp)K \equiv B^a \pmod p \equiv A^b \pmod p

p=467,α=2,a=3,b=5p = 467, \alpha = 2, a = 3, b = 5

A23(mod467)A \equiv 2^3 \pmod{467}, A=8A = 8
B25(mod467)B \equiv 2^5 \pmod{467}, B=32B = 32

K323(mod467)K \equiv 32^3 \pmod{467}
K=32768(mod467)K = 32768 \pmod{467}
32768=46770+7832768 = 467 \cdot 70 + 78
K=78K = 78

Alice's Public Key: A=8A = 8
Bob's Public Key: B=32B = 32
Common Key: K=78K = 78

2

p=467,α=2,a=400,b=134p = 467, \alpha = 2, a = 400, b = 134
A2400(mod467)A \equiv 2^{400} \pmod{467}
A=137A = 137
B2134(mod467)B \equiv 2^{134} \pmod{467}
B=84B = 84

K84400(mod467)K \equiv 84^{400} \pmod{467}

Alice's Public Key: A=137A = 137
Bob's Public Key: B=84B = 84
Common Key: K=90K = 90

3 Encrypt the following messages with the Elgamal scheme (p = 467 and α = 2)

ElGamal Formula

βαd(modp)\beta \equiv \alpha^d \pmod p
C1αi(modp)C_1 \equiv \alpha^i \pmod p
KMβi(modp)K_M \equiv \beta^i \pmod p
C2xKM(modp)C_2 \equiv x \cdot K_M \pmod p

KMC1d(modp)K_M \equiv C_1^d \pmod p
xC2KM1(modp)x \equiv C_2 \cdot K_M^{-1} \pmod p

  1. kpr=d=105,i=213,x=33k_{pr} = d = 105, i = 213, x = 33
    β2105(mod467)=226\beta \equiv 2^{105} \pmod{467} = 226
    C12213(mod467)=29C_1 \equiv 2^{213} \pmod{467} = 29
    KM226213(mod467)=234K_M \equiv 226^{213} \pmod{467} = 234
    C2332347722(mod467)=250C_2 \equiv 33 \cdot 234 \equiv 7722 \pmod{467} = 250
    (C1,C2)=(29,250)(C_1, C_2) = (29, 250)

    KM29105(mod467)=234K_M \equiv 29^{105} \pmod{467} = 234
    2341(mod467)=2234^{-1} \pmod{467} = 2
    x2502=50033(mod467)x \equiv 250 \cdot 2 = 500 \equiv 33 \pmod{467}

  2. kpr=d=105,i=123,x=33k_{pr} = d = 105, i = 123, x = 33
    β2105(mod467)=226\beta \equiv 2^{105} \pmod{467} = 226
    C12123(mod467)=274C_1 \equiv 2^{123} \pmod{467} = 274
    KM226123(mod467)=353K_M \equiv 226^{123} \pmod{467} = 353
    C23335311649(mod467)=441C_2 \equiv 33 \cdot 353 \equiv 11649 \pmod{467} = 441
    (C1,C2)=(274,441)(C_1, C_2) = (274, 441)
    Decrypt
    KM274105(mod467)=353K_M \equiv 274^{105} \pmod{467} = 353
    3531(mod467)=340353^{-1} \pmod{467} = 340
    x441340=149940(mod467)=33x \equiv 441 \cdot 340 = 149940 \pmod{467} = 33

  3. kpr=d=300,i=45,x=248k_{pr} = d = 300, i = 45, x = 248
    β2300(mod467)=153\beta \equiv 2^{300} \pmod{467} = 153
    C1245(mod467)=220C_1 \equiv 2^{45} \pmod{467} = 220
    KM15345(mod467)=328K_M \equiv 153^{45} \pmod{467} = 328
    C224832881344(mod467)=86C_2 \equiv 248 \cdot 328 \equiv 81344 \pmod{467} = 86
    (C1,C2)=(220,86)(C_1, C_2) = (220, 86)
    Decrypt
    KM220300(mod467)=328K_M \equiv 220^{300} \pmod{467} = 328
    3281(mod467)=383328^{-1} \pmod{467} = 383
    x86383=32938(mod467)=248x \equiv 86 \cdot 383 = 32938 \pmod{467} = 248

  4. kpr=d=300,i=47,x=248k_{pr} = d = 300, i = 47, x = 248
    β2300(mod467)=153\beta \equiv 2^{300} \pmod{467} = 153
    C1247(mod467)=413C_1 \equiv 2^{47} \pmod{467} = 413
    KM15347(mod467)=314K_M \equiv 153^{47} \pmod{467} = 314
    C224831477872(mod467)=350C_2 \equiv 248 \cdot 314 \equiv 77872 \pmod{467} = 350
    (C1,C2)=(413,350)(C_1, C_2) = (413, 350)
    Decrypte
    KM413300(mod467)=314K_M \equiv 413^{300} \pmod{467} = 314
    3141(mod467)=409314^{-1} \pmod{467} = 409
    x350409=143150(mod467)=248x \equiv 350 \cdot 409 = 143150 \pmod{467} = 248

4.4 Considering the four examples from Problem we see that the Elgamal scheme is

nondeterministic: A given plaintext x has many valid ciphertext, e.g., both x = 33 and x =
248 have the same ciphertext in the problem above.

1. Why is the Elgamal signature scheme nondeterministic?

The ElGamal scheme is nondeterministic because a random ephemeral key (ii) is chosen for every encryption process. Even if the plaintext and the public key remain identical, a different value of ii will produce a completely different ciphertext pair. This inherent randomness prevents attackers from analyzing repeating patterns.

2. How many valid ciphertexts exist for each message x (general expression)?

How many are there for the system in Problem 4.1 (numerical answer)?
The number of valid ciphertexts corresponds to the number of available choices for the random variable ii. Since ii is selected from the multiplicative group modulo pp, the general expression is p1p - 1.
For the system in Problem 4.1 where p=467p = 467, the numerical answer is 466466.

3. Is RSA crypto system nondeterministic once the public key has been chosen?

No, textbook RSA is deterministic. The algorithm relies on the fixed mathematical equation yxe(modn)y \equiv x^e \pmod n. Unless an external randomized padding scheme (such as OAEP) is applied, encrypting the same plaintext with a given public key will always generate the exact same ciphertext.

5. Given EC:

E: 𝑦2 ≡ 𝑥3 + 2𝑥 + 2 mod 17.
All points on the curve form a cyclic group and that the order is #E = 19. The basepoint/primitive element is 𝑃 = (5,1), please calculate 2P, 3P, 4P, 5P, 6P, 7P, 8P, 9P, 10P, 11P, 12P, 13P, 14P, 15P, 16P, 17P, 18P and 19P

Elliptic Curve E:y2x3+2x+2(mod17)E: y^2 \equiv x^3 + 2x + 2 \pmod{17}
Base point P=(5,1)P = (5, 1)
Order #E=19\#E = 19

P=(5,1)P = (5, 1)
2P=(6,3)2P = (6, 3)
3P=2P+P=(10,6)3P = 2P + P = (10, 6)
4P=3P+P=(3,1)4P = 3P + P = (3, 1)
5P=4P+P=(9,16)5P = 4P + P = (9, 16)
6P=5P+P=(16,13)6P = 5P + P = (16, 13)
7P=6P+P=(0,6)7P = 6P + P = (0, 6)
8P=7P+P=(13,7)8P = 7P + P = (13, 7)
9P=8P+P=(7,6)9P = 8P + P = (7, 6)

Using Symmetry
(19k)P=kP(19-k)P = -kP, (x,y(modp))(x, -y \pmod p)

10P=9P=(7,6(mod17))=(7,11)10P = -9P = (7, -6 \pmod{17}) = (7, 11)
11P=8P=(13,7(mod17))=(13,10)11P = -8P = (13, -7 \pmod{17}) = (13, 10)
12P=7P=(0,6(mod17))=(0,11)12P = -7P = (0, -6 \pmod{17}) = (0, 11)
13P=6P=(16,13(mod17))=(16,4)13P = -6P = (16, -13 \pmod{17}) = (16, 4)
14P=5P=(9,16(mod17))=(9,1)14P = -5P = (9, -16 \pmod{17}) = (9, 1)
15P=4P=(3,1(mod17))=(3,16)15P = -4P = (3, -1 \pmod{17}) = (3, 16)
16P=3P=(10,6(mod17))=(10,11)16P = -3P = (10, -6 \pmod{17}) = (10, 11)
17P=2P=(6,3(mod17))=(6,14)17P = -2P = (6, -3 \pmod{17}) = (6, 14)
18P=P=(5,1(mod17))=(5,16)18P = -P = (5, -1 \pmod{17}) = (5, 16)
19P=O19P = \mathcal{O} (Point at infinity)

profile
Design Verification engineer

0개의 댓글