CSS411 Cryptography

Elliptic Curve Cryptography

Slide deck 12: elliptic curves over the reals and GF(p), point addition and doubling, the elliptic curve logarithm problem, ECC Diffie-Hellman, ECC encryption and the key-size table.

26 min read

Why elliptic curvesSearch on YouTube

Most public-key schemes (RSA, Diffie-Hellman) use integer or polynomial arithmetic with very large numbers or polynomials. This puts a significant load on the storage and processing of keys and messages.

Elliptic curves are an alternative. They give the same security with smaller bit sizes.

RSA / D-H arithmeticECC arithmetic
Very large integers or polynomialsPoints on a curve, small bit sizes
Heavy storage and processing loadLighter load for the same security

Elliptic curve arithmeticSearch on YouTube

Real elliptic curvesSearch on YouTube

An equation in two variables xx and yy, with coefficients, defines an elliptic curve. The slides use a cubic elliptic curve of this form:

y2=x3+ax+by^2 = x^3 + ax + b

Here xx, yy, aa and bb are all real numbers. The scheme also defines a zero point OO.

  • E(a,b)E(a,b) is the set of points (x,y)(x, y) that satisfy the equation.
  • The set has an addition operation.
  • Geometrically, the sum P+QP + Q is the reflection of the intersection RR.

The line through PP and QQ meets the curve again at a third point RR. The reflection of RR across the xx-axis is P+QP + Q.

Real curve exampleSearch on YouTube

The slide figure shows the curve y2=x3+x+1y^2 = x^3 + x + 1.

  • The points PP and QQ are on the curve.
  • The dashed line through PP and QQ meets the curve a third time, in the upper branch. The figure labels this point −(P+Q)-(P+Q).
  • The vertical dashed line reflects this point across the xx-axis. The result in the lower branch is P+QP+Q.
xyPQ−(P+Q)P+QGeometric rule1. Draw a line through P and Q.2. Find the third point, −(P+Q).3. Reflect it across the x-axis.4. The result is P+Q.Over GF(p), the same rulebecomes the λ formulas.
Point addition on y² = x³ + x + 1: the line through P and Q meets the curve at −(P+Q). Its reflection is P+Q.

Draw a line through two points. Find the third point where the line meets the curve. Reflect that point across the xx-axis. The reflected point is the sum.

Addition over GF(p)Search on YouTube

Cryptography uses a finite field, not real numbers. The same equation is used over GF(p)GF(p) with a prime pp. All arithmetic is mod pp.

Let P(xP,yP)P(x_P, y_P) and Q(xQ,yQ)Q(x_Q, y_Q) be two points on the curve. Then R(xR,yR)=P+QR(x_R, y_R) = P + Q is:

xR=(λ2−xP−xQ) mod px_R = (\lambda^2 - x_P - x_Q) \bmod p

yR=(λ(xP−xR)−yP) mod py_R = \left(\lambda\left(x_P - x_R\right) - y_P\right) \bmod p

The slope λ\lambda depends on whether the two points are equal:

λ={(yQ−yPxQ−xP) mod pif P≠Q(3xP2+a2yP) mod pif P=Q\lambda = \begin{cases} \left(\frac{y_Q - y_P}{x_Q - x_P}\right) \bmod p & \text{if } P \ne Q \\[6pt] \left(\frac{3x_P^2 + a}{2y_P}\right) \bmod p & \text{if } P = Q \end{cases}

CaseNameSlope λ\lambda
P≠QP \ne QPoint addition(yQ−yP)(xQ−xP)−1 mod p(y_Q - y_P)(x_Q - x_P)^{-1} \bmod p
P=QP = QPoint doubling(3xP2+a)(2yP)−1 mod p(3x_P^2 + a)(2y_P)^{-1} \bmod p

Both cases need a multiplicative inverse mod pp.

Compute λ\lambda first. Then compute xRx_R. Then compute yRy_R. Reduce every value mod pp.

xR=λ2−xP−xQyR=λ(xP−xR)−yPx_R = \lambda^2 - x_P - x_Q \qquad y_R = \lambda (x_P - x_R) - y_P

Worked example in E23(1,1)E_{23}(1,1)Search on YouTube

The slide example uses the curve y2=x3+x+1y^2 = x^3 + x + 1 over GF(23)GF(23). The name of this curve is E23(1,1)E_{23}(1,1). Let P=(3,10)P = (3, 10) and Q=(9,7)Q = (9, 7).

Step 1: add PP and QQ.

StepComputationResult
Slopeλ=7−109−3 mod 23=−36=−12 mod 23\lambda = \frac{7 - 10}{9 - 3} \bmod 23 = \frac{-3}{6} = \frac{-1}{2} \bmod 23λ=11\lambda = 11
xRx_R(112−3−9) mod 23=109 mod 23(11^2 - 3 - 9) \bmod 23 = 109 \bmod 2317
yRy_R(11(3−17)−10) mod 23=−164 mod 23(11(3 - 17) - 10) \bmod 23 = -164 \bmod 2320
SumP+QP + Q(17,20)(17, 20)

Step 2: double PP.

StepComputationResult
Slopeλ=3(32)+12×10 mod 23=520=14 mod 23\lambda = \frac{3(3^2) + 1}{2 \times 10} \bmod 23 = \frac{5}{20} = \frac{1}{4} \bmod 23λ=6\lambda = 6
xRx_R(62−3−3) mod 23=30 mod 23(6^2 - 3 - 3) \bmod 23 = 30 \bmod 237
yRy_R(6(3−7)−10) mod 23=−34 mod 23(6(3 - 7) - 10) \bmod 23 = -34 \bmod 2312
Double2P2P(7,12)(7, 12)

The last slope step uses the multiplicative inverse of 44 in Z23Z_{23}. The extended Euclidean algorithm finds it. To confirm: (6×4) mod 23=24 mod 23=1(6 \times 4) \bmod 23 = 24 \bmod 23 = 1.

Check that both results are on the curve. For (17,20)(17, 20): 202=400≡920^2 = 400 \equiv 9, and 173+17+1=4931≡9(mod23)17^3 + 17 + 1 = 4931 \equiv 9 \pmod{23}. For (7,12)(7, 12): 122=144≡612^2 = 144 \equiv 6, and 73+7+1=351≡6(mod23)7^3 + 7 + 1 = 351 \equiv 6 \pmod{23}.

Repeated additionSearch on YouTube

Multiplication of a point by an integer is repeated addition. For example:

4P=P+P+P+P4P = P + P + P + P

ECC schemesSearch on YouTube

The hard problemSearch on YouTube

The slides compare ECC arithmetic with modular arithmetic:

Modular arithmeticECC analog
Modulo multiplyECC addition
Modulo exponentiationECC repeated addition

ECC needs a "hard" problem that is equivalent to the discrete log:

  • Q=kPQ = kP, where QQ and PP belong to a prime curve.
  • It is "easy" to compute QQ from kk and PP.
  • It is "hard" to find kk from QQ and PP.
  • The name of this problem is the elliptic curve logarithm problem.

The slide gives the Certicom example curve E23(9,17)E_{23}(9,17). This is y2=x3+9x+17y^2 = x^3 + 9x + 17 over GF(23)GF(23).

Small curves such as E23(9,17)E_{23}(9,17) are for practice only. On a small curve, a search by hand finds kk. Real curves use hundreds of bits.

ECC Diffie-HellmanSearch on YouTube

ECC can do a key exchange that is analogous to Diffie-Hellman.

StepComputation
CurveThe users select a suitable curve Eq(a,b)E_q(a,b)
Base pointG=(x1,y1)G = (x_1, y_1) with a large order nn, such that nG=OnG = O
Private keysA selects nA<nn_A < n. B selects nB<nn_B < n
Public keysPA=nAGP_A = n_A G and PB=nBGP_B = n_B G
Shared keyK=nAPBK = n_A P_B (A) and K=nBPAK = n_B P_A (B)

The two keys are the same, because:

K=nAPB=nA(nBG)=nAnBG=nB(nAG)=nBPAK = n_A P_B = n_A (n_B G) = n_A n_B G = n_B (n_A G) = n_B P_A

An attacker who sees GG, PAP_A and PBP_B must find kk. This is the hard problem.

Order: Curve, G, Private, Public, Key. To get the shared key, multiply the public point of the other side by your private key.

Encryption and decryptionSearch on YouTube

There are several alternatives for ECC encryption. The slides use the simplest one:

  1. Encode the message MM as a point PmP_m on the elliptic curve.
  2. Select a suitable curve and point GG, as in Diffie-Hellman.
  3. Each user chooses a private key nA<nn_A < n.
  4. Each user computes the public key PA=nAGP_A = n_A G.

To encrypt PmP_m, the sender selects a random kk and sends:

Cm={ kG,  Pm+kPb }C_m = \{\, kG, \; P_m + kP_b \,\}

To decrypt CmC_m, the receiver uses the private key nbn_b and computes:

Pm+kPb−nb(kG)=Pm+k(nbG)−nb(kG)=PmP_m + kP_b - n_b(kG) = P_m + k(n_b G) - n_b(kG) = P_m

The value nb(kG)n_b(kG) is equal to the mask kPbkP_b. Subtraction removes the mask and gives PmP_m.

Slide example: E257(0,−4)E_{257}(0,-4)Search on YouTube

The handwritten slide does a full example on this curve:

y2=x3−4Eq(a,b)=E257(0,−4)G=(2,2)y^2 = x^3 - 4 \qquad E_q(a,b) = E_{257}(0,-4) \qquad G = (2, 2)

Key setup.

PartyComputeResult
Alice, privatenA=41n_A = 41none
Alice, publicPA=41 (2,2)P_A = 41\,(2,2)(136,128)(136, 128)
Bob, privatenB=101n_B = 101none
Bob, publicPB=101 (2,2)P_B = 101\,(2,2)(197,167)(197, 167)
Alice, sharedK=nAPB=41 (197,167)K = n_A P_B = 41\,(197,167)(68,84)(68, 84)
Bob, sharedK=nBPA=101 (136,128)K = n_B P_A = 101\,(136,128)(68,84)(68, 84)

Both sides get the same shared point (68,84)(68, 84).

Encryption. Alice encrypts for Bob.

StepValue
Plaintext point PmP_m(112,26)(112, 26)
Random kk chosen by Alice4141
kG=41 (2,2)kG = 41\,(2,2)(136,128)(136, 128)
kPB=41 (197,167)kP_B = 41\,(197,167)(68,84)(68, 84)
Pm+kPBP_m + kP_B(246,174)(246, 174)
Ciphertext Cm={C1,C2}C_m = \{C_1, C_2\}{(136,128), (246,174)}\{(136, 128),\ (246, 174)\}

Decryption. Bob computes:

C2−nBC1=(246,174)−101 (136,128)=(246,174)−(68,84)=(112,26)C_2 - n_B C_1 = (246,174) - 101\,(136,128) = (246,174) - (68,84) = (112, 26)

Bob gets the plaintext point (112,26)(112, 26).

Follow the mask. Alice adds kPBkP_B to PmP_m. Bob knows nBn_B. He computes nB(kG)n_B(kG), which is equal to k(nBG)=kPBk(n_B G) = kP_B. Then he subtracts it.

ECC securitySearch on YouTube

Security basisSearch on YouTube

  • The security of ECC relies on the elliptic curve logarithm problem.
  • ECC can use much smaller key sizes than RSA, which relies on factoring.
  • For equivalent key lengths, the computations are roughly equivalent.
  • Thus, for similar security, ECC gives significant computational advantages.

Comparable key sizesSearch on YouTube

Symmetric scheme (key size in bits)ECC-based scheme (size of nn in bits)RSA/DSA (modulus size in bits)
56112512
801601024
1122242048
1282563072
1923847680
25651215360

The ECC size is two times the symmetric key size. The RSA/DSA modulus grows much faster. For example, a 160-bit curve gives the same security as an 80-bit symmetric key and a 1024-bit RSA modulus.

Learn the ECC column: 112, 160, 224, 256, 384, 512. It is two times the symmetric column: 56, 80, 112, 128, 192, 256. The RSA column is 512, 1024, 2048, 3072, 7680, 15360.

Quick self-testSearch on YouTube

Why does ECC give the same security as RSA with smaller bit sizes?

RSA and Diffie-Hellman need very large integers or polynomials. These put a load on storage and processing. The elliptic curve logarithm problem is hard at much smaller sizes. For example, a 256-bit ECC key matches a 3072-bit RSA modulus.

Give the equation of a real elliptic curve and the special point.

y2=x3+ax+by^2 = x^3 + ax + b, with x,y,a,bx, y, a, b real numbers. The scheme also defines a zero point OO. E(a,b)E(a,b) is the set of points that satisfy the equation.

Describe the geometric view of P+QP + Q on a real elliptic curve.

Draw the line through PP and QQ. The line meets the curve a third time at RR. The sum P+QP+Q is the reflection of RR across the xx-axis.

State the point addition and doubling formulas over GF(p)GF(p).

xR=(λ2−xP−xQ) mod px_R = (\lambda^2 - x_P - x_Q) \bmod p and yR=(λ(xP−xR)−yP) mod py_R = (\lambda(x_P - x_R) - y_P) \bmod p. If P≠QP \ne Q, λ=(yQ−yP)(xQ−xP)−1 mod p\lambda = (y_Q - y_P)(x_Q - x_P)^{-1} \bmod p. If P=QP = Q, λ=(3xP2+a)(2yP)−1 mod p\lambda = (3x_P^2 + a)(2y_P)^{-1} \bmod p.

Find P+QP+Q and 2P2P for P=(3,10)P=(3,10), Q=(9,7)Q=(9,7) in E23(1,1)E_{23}(1,1).

P+QP+Q: λ=−1/2 mod 23=11\lambda = -1/2 \bmod 23 = 11. xR=109 mod 23=17x_R = 109 \bmod 23 = 17. yR=−164 mod 23=20y_R = -164 \bmod 23 = 20. So P+Q=(17,20)P+Q = (17,20). 2P2P: λ=5/20=1/4 mod 23=6\lambda = 5/20 = 1/4 \bmod 23 = 6. xR=30 mod 23=7x_R = 30 \bmod 23 = 7. yR=−34 mod 23=12y_R = -34 \bmod 23 = 12. So 2P=(7,12)2P = (7,12).

What is the elliptic curve logarithm problem?

Q=kPQ = kP on a prime curve. It is easy to compute QQ from kk and PP. It is hard to find kk from QQ and PP. ECC security relies on this problem.

Write the ECC Diffie-Hellman steps.

Select a curve Eq(a,b)E_q(a,b) and a base point GG with a large order nn, so that nG=OnG = O. Select private keys nA,nB<nn_A, n_B < n. Compute public keys PA=nAGP_A = n_A G and PB=nBGP_B = n_B G. The shared key is K=nAPB=nBPA=nAnBGK = n_A P_B = n_B P_A = n_A n_B G.

Give the ECC encryption and decryption formulas.

Encode MM as a point PmP_m. Encrypt with a random kk: Cm={kG, Pm+kPb}C_m = \{kG,\ P_m + kP_b\}. Decrypt: Pm+kPb−nb(kG)=Pm+k(nbG)−nb(kG)=PmP_m + kP_b - n_b(kG) = P_m + k(n_b G) - n_b(kG) = P_m.

Give the results of the E257(0,−4)E_{257}(0,-4) slide example.

Curve y2=x3−4y^2 = x^3 - 4, G=(2,2)G = (2,2). Alice: nA=41n_A = 41, PA=(136,128)P_A = (136,128). Bob: nB=101n_B = 101, PB=(197,167)P_B = (197,167). Shared key: (68,84)(68,84). Encrypt Pm=(112,26)P_m = (112,26) with k=41k = 41: Cm={(136,128),(246,174)}C_m = \{(136,128),(246,174)\}. Decrypt: (246,174)−(68,84)=(112,26)(246,174) - (68,84) = (112,26).

Give the key-size pairs for 80-bit and 128-bit security.

80-bit symmetric: 160-bit ECC, 1024-bit RSA/DSA. 128-bit symmetric: 256-bit ECC, 3072-bit RSA/DSA.

  • RSA and Diffie-Hellman use very large numbers. Elliptic curves give the same security with smaller bit sizes.
  • A real elliptic curve is y2=x3+ax+by^2 = x^3 + ax + b, with a zero point OO. The sum P+QP+Q is the reflection of the third intersection point RR.
  • Over GF(p)GF(p): xR=λ2−xP−xQx_R = \lambda^2 - x_P - x_Q and yR=λ(xP−xR)−yPy_R = \lambda(x_P - x_R) - y_P. The slope is (yQ−yP)/(xQ−xP)(y_Q - y_P)/(x_Q - x_P) for addition and (3xP2+a)/(2yP)(3x_P^2 + a)/(2y_P) for doubling.
  • Multiplication is repeated addition: 4P=P+P+P+P4P = P+P+P+P. The hard problem is the elliptic curve logarithm problem.
  • ECC Diffie-Hellman: PA=nAGP_A = n_A G, PB=nBGP_B = n_B G, K=nAnBGK = n_A n_B G. Encryption: Cm={kG,Pm+kPb}C_m = \{kG, P_m + kP_b\}. Decryption subtracts nb(kG)n_b(kG).
  • Slide example E257(0,−4)E_{257}(0,-4), G=(2,2)G=(2,2): public keys (136,128)(136,128) and (197,167)(197,167), shared key (68,84)(68,84), ciphertext {(136,128),(246,174)}\{(136,128),(246,174)\}, plaintext (112,26)(112,26).
  • Key sizes: ECC 112 to 512 bits matches symmetric 56 to 256 bits and RSA 512 to 15360 bits.