CSS411 Cryptography

ECC Sample Problems 2

Worked solutions for the second ECC problem set: point addition modulo 19 and modulo 31, with extended-Euclid inverses.

12 min read

The two problemsSearch on YouTube

Problem set 2 is a handwritten sheet. It does point addition in two prime fields. The steps are the same as in set 1. Only the modulus and the inverses change.

ProblemModulusPointsCurve
1p=19p = 19P(6,1)P(6,1), Q(2,6)Q(2,6)y2=x3+5x+7y^2 = x^3 + 5x + 7
2p=31p = 31P(8,21)P(8,21), Q(12,26)Q(12,26)not shown on the sheet

Addition formulasSearch on YouTube

λ=(yQ−yPxQ−xP) mod p,xR=(λ2−xP−xQ) mod p\lambda = \left(\frac{y_Q - y_P}{x_Q - x_P}\right) \bmod p, \qquad x_R = (\lambda^2 - x_P - x_Q) \bmod p

yR=(λ(xP−xR)−yP) mod p,P+Q=(xR,yR)y_R = \left(\lambda(x_P - x_R) - y_P\right) \bmod p, \qquad P + Q = (x_R, y_R)

Modular inverse with extended EuclidSearch on YouTube

Each slope contains a division. To divide by aa modulo pp, multiply by a−1a^{-1}. Find xx with a⋅x≡1(modp)a \cdot x \equiv 1 \pmod p.

Inverse of 3 modulo 19Search on YouTube

The sheet uses this inverse in problem 1:

  • 19=6×3+119 = 6 \times 3 + 1
  • 1=19−6×31 = 19 - 6 \times 3
  • so 3−1=−6 mod 19=133^{-1} = -6 \bmod 19 = 13

Check: 3×13=39=38+1≡1(mod19)3 \times 13 = 39 = 38 + 1 \equiv 1 \pmod{19}.

Inverse of 4 modulo 31Search on YouTube

The sheet uses this inverse in problem 2:

  • 31=7×4+331 = 7 \times 4 + 3
  • 4=1×3+14 = 1 \times 3 + 1
  • 1=4−1×3=4−(31−7×4)=8×4−311 = 4 - 1 \times 3 = 4 - (31 - 7 \times 4) = 8 \times 4 - 31
  • so 4−1 mod 31=84^{-1} \bmod 31 = 8

Check: 4×8=32=31+1≡1(mod31)4 \times 8 = 32 = 31 + 1 \equiv 1 \pmod{31}.

Run Euclid forward to get the remainders. Then substitute back until 1 is a sum of multiples of aa and pp. The multiplier of aa is a−1a^{-1}.

Problem 1: modulo 19Search on YouTube

Given. Curve y2=x3+5x+7y^2 = x^3 + 5x + 7, modulus p=19p = 19, points P=(6,1)P = (6, 1) and Q=(2,6)Q = (2, 6).

SlopeSearch on YouTube

λ=6−12−6 mod 19=5−4 mod 19\lambda = \frac{6-1}{2-6} \bmod 19 = \frac{5}{-4} \bmod 19

−4 mod 19=15-4 \bmod 19 = 15, so λ=5/15 mod 19\lambda = 5 / 15 \bmod 19. The sheet cancels 5 and gets 1/31/3. Then λ=3−1 mod 19=13\lambda = 3^{-1} \bmod 19 = 13.

Another route gives the same value. 15−1=1415^{-1} = 14, because 15×14=210=19×11+115 \times 14 = 210 = 19 \times 11 + 1. Then 5×14=70≡13(mod19)5 \times 14 = 70 \equiv 13 \pmod{19}.

λ=13\boxed{\lambda = 13}

x coordinateSearch on YouTube

xR=(132−6−2) mod 19=(169−8) mod 19=161 mod 19x_R = (13^2 - 6 - 2) \bmod 19 = (169 - 8) \bmod 19 = 161 \bmod 19

161=19×8+9161 = 19 \times 8 + 9, so:

xR=9x_R = 9

y coordinateSearch on YouTube

Put xP=6x_P = 6, xR=9x_R = 9 and yP=1y_P = 1 in the formula:

yR=(13(6−9)−1) mod 19=(−39−1) mod 19=−40 mod 19y_R = \left(13(6 - 9) - 1\right) \bmod 19 = (-39 - 1) \bmod 19 = -40 \bmod 19

−40+3×19=17-40 + 3 \times 19 = 17, so:

yR=17y_R = 17

Answer.

P+Q=(9,17)P + Q = (9, 17)

The sheet has two slips in this problem:

  • It subtracts 22 in place of yP=1y_P = 1. It gets −41 mod 19=16-41 \bmod 19 = 16. The correct value is 1717.
  • Its last line writes (13,16)(13, 16). It puts λ=13\lambda = 13 in place of xR=9x_R = 9.

Also, (6,1)(6,1) and (2,6)(2,6) do not satisfy y2=x3+5x+7 mod 19y^2 = x^3 + 5x + 7 \bmod 19. Use this problem only to practise the formulas.

Problem 2: modulo 31Search on YouTube

Given. Modulus p=31p = 31, points P=(8,21)P = (8, 21) and Q=(12,26)Q = (12, 26). The sheet notes that P≠QP \neq Q, so the addition formula applies.

SlopeSearch on YouTube

λ=26−2112−8 mod 31=54 mod 31\lambda = \frac{26 - 21}{12 - 8} \bmod 31 = \frac{5}{4} \bmod 31

Use 4−1 mod 31=84^{-1} \bmod 31 = 8 from the Euclid steps above:

λ=5×8 mod 31=40 mod 31=9\lambda = 5 \times 8 \bmod 31 = 40 \bmod 31 = 9

λ=9\boxed{\lambda = 9}

x coordinateSearch on YouTube

xR=(92−8−12) mod 31=(81−20) mod 31=61 mod 31=30x_R = (9^2 - 8 - 12) \bmod 31 = (81 - 20) \bmod 31 = 61 \bmod 31 = 30

y coordinateSearch on YouTube

Put xP=8x_P = 8, xR=30x_R = 30 and yP=21y_P = 21 in the formula:

yR=(9(8−30)−21) mod 31=(−198−21) mod 31=−219 mod 31y_R = \left(9(8 - 30) - 21\right) \bmod 31 = (-198 - 21) \bmod 31 = -219 \bmod 31

The sheet writes −219=−248+29-219 = -248 + 29. 248=8×31248 = 8 \times 31, so:

yR=29y_R = 29

Answer.

P+Q=(xR,yR)=(30,29)P + Q = (x_R, y_R) = (30, 29)

Comparing the two problemsSearch on YouTube

AspectProblem 1Problem 2
Modulus19193131
Divisor in λ\lambda−4≡15-4 \equiv 1544
Inverse used3−1=133^{-1} = 13 (or 15−1=1415^{-1} = 14)4−1=84^{-1} = 8
λ\lambda131399
xRx_R161 mod 19=9161 \bmod 19 = 961 mod 31=3061 \bmod 31 = 30
yRy_R−40 mod 19=17-40 \bmod 19 = 17−219 mod 31=29-219 \bmod 31 = 29
P+QP + Q(9,17)(9, 17)(30,29)(30, 29)

The steps do not change. Only the modulus, the divisor and its inverse change.

Write each modulus reduction in full. Examiners give method marks for the reductions.

Quick self-testSearch on YouTube

Reduce 5−4\dfrac{5}{-4} modulo 19 and give λ\lambda.

−4≡15(mod19)-4 \equiv 15 \pmod{19}. 5/15≡1/35/15 \equiv 1/3, and 3−1=133^{-1} = 13. So λ=13\lambda = 13.

What is xRx_R in problem 1?

xR=132−6−2=161x_R = 13^2 - 6 - 2 = 161, and 161−8×19=9161 - 8 \times 19 = 9. So xR=9x_R = 9.

What is yRy_R in problem 1, and which value does the formula subtract?

yR=13(6−9)−1=−40≡17(mod19)y_R = 13(6-9) - 1 = -40 \equiv 17 \pmod{19}. The formula subtracts yP=1y_P = 1.

Find 4−1 mod 314^{-1} \bmod 31 with extended Euclid.

31=7×4+331 = 7 \times 4 + 3 and 4=3+14 = 3 + 1. So 1=4−(31−7×4)=8×4−311 = 4 - (31 - 7 \times 4) = 8 \times 4 - 31. Thus 4−1=84^{-1} = 8.

Give P+QP + Q for problem 2.

λ=40 mod 31=9\lambda = 40 \bmod 31 = 9. xR=61 mod 31=30x_R = 61 \bmod 31 = 30. yR=−219 mod 31=29y_R = -219 \bmod 31 = 29. So P+Q=(30,29)P + Q = (30, 29).

Why does problem 2 not use the doubling formula?

P≠QP \neq Q, because 8≠128 \neq 12. The doubling slope λ=(3x2+a)/(2y)\lambda = (3x^2 + a)/(2y) is only for P=QP = Q.

What is P+QP + Q when xP=xQx_P = x_Q and yQ=−yPy_Q = -y_P?

The line is vertical and the slope is not defined. P+Q=OP + Q = O, the point at infinity.

  • Formulas: λ=(yQ−yP)/(xQ−xP)\lambda = (y_Q-y_P)/(x_Q-x_P), xR=λ2−xP−xQx_R = \lambda^2 - x_P - x_Q, yR=λ(xP−xR)−yPy_R = \lambda(x_P - x_R) - y_P. Reduce all values mod pp.
  • Problem 1, p=19p = 19: λ=13\lambda = 13, xR=9x_R = 9, yR=17y_R = 17. The sheet gives (13,16)(13, 16) because of two slips.
  • Problem 2, p=31p = 31: λ=9\lambda = 9 with 4−1=84^{-1} = 8, xR=30x_R = 30, yR=29y_R = 29.
  • Each division is a multiplication by an inverse from extended Euclid.