CSEC3616Cybersecurity Engineering

    Elliptic curve cryptography

    Non-examinable material on the curve equation, point addition, curves over prime and binary finite fields, the elliptic curve discrete logarithm problem, ECDH and EC ElGamal, covered in full for readers who want it anyway.

    Not examinable — the lecture flags this material as out of scope for assessment.

    • State the elliptic curve equation over the reals, over a prime field and over a binary field.
    • Explain point addition and point doubling using the line-and-reflect geometric picture.
    • Verify whether a given point lies on a curve over a prime field.
    • State the elliptic curve discrete logarithm problem and work a small brute-force example.
    • Work an ECDH key agreement and an EC ElGamal encryption and decryption by hand.

    24 min read

    This page is non-examinable. The lecture marks the entire elliptic curve section “for information only”. If exam time is short, spend it on the rest of module 6 instead. What follows is the full treatment for anyone who wants it regardless.

    Intuition

    Every scheme so far builds its hard problem out of modular arithmetic on ordinary integers: factoring for RSA, the discrete logarithm for classical Diffie-Hellman. Elliptic curve cryptography keeps the same idea, picking an operation that is easy to run forward and believed hard to reverse, but changes what the numbers are. The elements are no longer integers mod pp; they are points on a curve, and the operation is no longer multiplication; it is a geometric rule for combining two points into a third. The payoff for the added complexity is a discrete logarithm problem that is harder per bit, so the same security comes from a much shorter key.

    Mechanism

    The curve. An elliptic curve E(a,b)E(a,b) is the set of points satisfying y2=x3+ax+by^{2} = x^{3} + ax + b plus one extra point, OO, the point at infinity. It is not a real coordinate pair, but an identity element added so every point has an inverse under the group operation defined below.

    Point addition, geometrically. Take two distinct points PP and QQ on the curve. Draw the straight line through them. Because the curve is cubic, that line intersects it at exactly one more point. Reflect that third point across the xx-axis: the result is P+QP + Q.

    Point negation. The reflection of a point across the xx-axis is its negative: P=(x,y)-P = (x, -y). Three points that lie on one straight line always sum to zero: P+Q+R=OP + Q + R = O when PP, QQ, RR are collinear.

    Point doubling. When P=QP = Q, there is no second point to draw a line through, so use the tangent line at PP instead. The tangent meets the curve at one further point; reflecting that point across the xx-axis gives 2P2P. Repeating this, and combining it with ordinary addition, is how kPkP (the point PP added to itself kk times) is computed efficiently for large kk, the same way repeated squaring makes gkmodpg^k \bmod p fast.

    Mechanism

    Over a finite field. For cryptography the curve is drawn over Zp\mathbb{Z}_p rather than the reals, written Ep(a,b)E_p(a,b): y2x3+ax+b(modp)y^{2} \equiv x^{3} + ax + b \pmod{p} The curve is now a finite set of points plus OO, exactly the kind of finite structure a discrete logarithm problem needs.

    Worked example

    AnswerCorrected: 49 mod 23 = 3 and 739 mod 23 = 3, so 3 congruent to 3 confirms (9,7) lies on E_23(1,1). The source states this reduction as 2, which is a defect in the original slides.

    Take E23(1,1)E_{23}(1,1): y2x3+x+1(mod23)y^2 \equiv x^3 + x + 1 \pmod{23}. Check whether (x,y)=(9,7)(x,y) = (9,7) lies on the curve.

    1. Right-hand side: x3+ax+bx^3 + ax + b with a=1a=1, b=1b=1: 93+1×9+1=729+9+1=7399^3 + 1 \times 9 + 1 = 729 + 9 + 1 = 739.
    2. Left-hand side: y2=72=49y^2 = 7^2 = 49.
    3. Reduce both sides mod 23. 49mod2349 \bmod 23: 23×2=4623 \times 2 = 46, 4946=349 - 46 = 3. So the left side is 33.
    4. 739mod23739 \bmod 23: 23×32=73623 \times 32 = 736, 739736=3739 - 736 = 3. So the right side is also 33.
    5. 33(mod23)3 \equiv 3 \pmod{23}, so the point satisfies the equation, and (9,7)(9,7) lies on E23(1,1)E_{23}(1,1).

    Aside

    This example is a documented source defect (docs/FACTS.md S3), reproduced here corrected. The original slides write the right-hand side as 93+10+19^3 + 10 + 1, where the 1010 looks like a slip of combining ax+b=9+1ax + b = 9 + 1 into a single stray term instead of the two separate terms 99 and 11 that 93+x+19^3 + x + 1 actually needs. Separately, the slides reduce both 49mod2349 \bmod 23 and 739mod23739 \bmod 23 to 22; both should be 33. The final conclusion, that (9,7)(9,7) is on the curve, still holds either way, purely because the arithmetic error was symmetric on both sides. The detailed table of every point on E23(1,1)E_{23}(1,1) that the slides go on to describe did not survive PDF extraction, so it is not reproduced here.

    Mechanism

    Over a binary field. Elliptic curves can also be built over GF(2m)GF(2^m), the same binary-field construction used for AES’s finite fields, using a different equation: y2+xy=x3+ax2+by^{2} + xy = x^{3} + ax^{2} + b Coordinates and coefficients are field elements (bit strings), and addition is XOR throughout, including subtraction, since the two are identical in a field of characteristic 2: adding an element to itself always gives zero.

    Worked check, GF(24)GF(2^4). Take f(x)=x4+x+1f(x) = x^4 + x + 1 as the irreducible polynomial and g=x=0010g = x = 0010 as a generator, so every non-zero field element is some power gig^i. Take the curve with a=g4a = g^4, b=1b = 1, and check whether (x,y)=(g5,g3)(x,y) = (g^5, g^3) lies on it.

    First, the powers of gg needed, each computed by multiplying the previous one by xx and reducing mod f(x)f(x) whenever the result overflows 4 bits (in which case x4x^4 is replaced by x+1=0011x+1 = 0011, since x4x+1(modf(x))x^4 \equiv x+1 \pmod{f(x)}):

    g3=1000g^3 = 1000, g4=0011g^4 = 0011, g5=0110g^5 = 0110, g6=1100g^6 = 1100, g8=0101g^8 = 0101, g14=1001g^{14} = 1001, g15=0001=g0g^{15} = 0001 = g^0.

    Substituting into y2+xy=x3+ax2+by^2 + xy = x^3 + ax^2 + b with x=g5x = g^5, y=g3y = g^3, a=g4a = g^4, b=1b = 1: (g3)2+g5g3=(g5)3+g4(g5)2+1(g^3)^2 + g^5 \cdot g^3 = (g^5)^3 + g^4(g^5)^2 + 1 g6+g8=g15+g14+1g^6 + g^8 = g^{15} + g^{14} + 1

    In binary, using the powers above: 1100+01011100 + 0101 on the left, 0001+1001+00010001 + 1001 + 0001 on the right. XOR each side: 11000101=10011100 \oplus 0101 = 1001 on the left; 000110010001=10010001 \oplus 1001 \oplus 0001 = 1001 on the right. Both sides equal 10011001, so (g5,g3)(g^5, g^3) lies on the curve.

    Mechanism

    The elliptic curve discrete logarithm problem (ECDLP). Given points PP and QQ on Ep(a,b)E_p(a,b) with Q=kPQ = kP, finding kk is believed infeasible for a large enough curve: no method faster than trying values of kk is known. The lecture’s small example, on E23(9,17)E_{23}(9,17), finds kk for P=(16,5)P = (16,5) and Q=(4,5)Q = (4,5) by brute force, listing every multiple of PP in turn:

    P=(16,5)2P=(20,20)3P=(14,14)4P=(19,20)5P=(13,10)P=(16,5) \quad 2P=(20,20) \quad 3P=(14,14) \quad 4P=(19,20) \quad 5P=(13,10) 6P=(7,3)7P=(8,7)8P=(12,17)9P=(4,5)6P=(7,3) \quad 7P=(8,7) \quad 8P=(12,17) \quad 9P=(4,5)

    9P9P matches QQ, so k=9k = 9. This only worked because the curve is tiny. With kk chosen from a space of real-world size, listing every multiple is infeasible, which is exactly the property the scheme relies on.

    Mechanism

    Elliptic curve Diffie-Hellman (ECDH). Both parties, and any attacker, already know the system-wide public parameters: the curve Ep(a,b)E_p(a,b), a base point GG, and GG‘s order nn (the smallest nn with nG=OnG = O, chosen as a large prime). Key agreement mirrors classical Diffie-Hellman with scalar point multiplication in place of modular exponentiation:

    • Alice picks a private scalar nAn_A and publishes PA=nAGP_A = n_A \cdot G.
    • Bob picks a private scalar nBn_B and publishes PB=nBGP_B = n_B \cdot G.
    • Alice computes nAPBn_A \cdot P_B; Bob computes nBPAn_B \cdot P_A.

    nAPB=nA(nBG)=nB(nAG)=nBPAn_A \cdot P_B = n_A \cdot (n_B \cdot G) = n_B \cdot (n_A \cdot G) = n_B \cdot P_A

    Both reach the same point, for the same reason as classical DH: the two scalars commute. Recovering nAn_A from PAP_A and GG alone is the ECDLP, believed infeasible.

    Mechanism

    EC ElGamal encryption. The message is first encoded as a curve point PmP_m. Public parameters: the curve Eq(a,b)E_q(a,b), a generator GG of large order nn.

    Alice (sender)Bob (receiver)
    1Picks private key nB<nn_B < n
    2Publishes PB=nBGP_B = n_B \cdot G
    3Picks a fresh random kk for this message
    4Sends Cm={kG, Pm+kPB}C_m = \{kG,\ P_m + kP_B\}Receives CmC_m
    5Recovers Pm=(Pm+kPB)nB(kG)P_m = (P_m + kP_B) - n_B \cdot (kG)

    The mask kPBkP_B cancels because nB(kG)=k(nBG)=kPBn_B \cdot (kG) = k \cdot (n_B G) = kP_B. Bob reconstructs the same mask Alice applied, using his private key against Alice’s kGkG, and subtracts it back out.

    Worked example

    AnswerBob's public key is (197,167). Alice sends {(136,128), (246,174)}. Bob subtracts the mask and recovers Alice's message point (112,26).

    System parameters: E257(0,4)E_{257}(0,-4): y2=x34y^2 = x^3 - 4, generator G=(2,2)G = (2,2).

    1. Bob’s private key: nB=101n_B = 101.
    2. Bob’s public key: PB=nBG=101(2,2)=(197,167)P_B = n_B G = 101(2,2) = (197,167).
    3. Alice’s message, already encoded as a point: Pm=(112,26)P_m = (112,26). She picks a fresh k=41k = 41.
    4. Alice computes kG=41(2,2)=(136,128)kG = 41(2,2) = (136,128).
    5. Alice computes the mask kPB=41(197,167)=(68,84)kP_B = 41(197,167) = (68,84).
    6. Alice masks the message: Pm+kPB=(112,26)+(68,84)=(246,174)P_m + kP_B = (112,26) + (68,84) = (246,174).
    7. Alice sends Cm={(136,128), (246,174)}C_m = \{(136,128),\ (246,174)\} to Bob.
    8. Bob computes nB(kG)=101(136,128)=(68,84)n_B \cdot (kG) = 101(136,128) = (68,84), the same mask Alice applied, reconstructed from his own private key and the first half of the ciphertext.

    9. Bob subtracts: (246,174)(68,84)=(112,26)(246,174) - (68,84) = (112,26), recovering Alice’s message point exactly.

    Threat

    Reusing the random kk across two different EC ElGamal messages lets an attacker who has both ciphertexts XOR them together, eliminating the mask kPBkP_B and exposing a direct relationship between the two message points, the same failure mode as reusing a one-time pad key.

    Control

    Choose kk fresh, at random, for every single message. A one-time mask stops being one-time the moment it is reused, so the fix is procedural, not mathematical: never let kk repeat.

    Mechanism

    Security and key size. ECC’s security rests on the ECDLP being hard to solve for kk given PP and kPkP. The lecture states the ECDLP is harder, bit for bit, than the classical discrete logarithm or RSA problems, which is why comparable security needs a much shorter key: 256-bit ECC keys are described as very common, with 384-bit for higher security. The slides go on to compare these figures directly against RSA key sizes in a table that did not survive PDF extraction. That specific side-by-side comparison is not reproduced here, but the general shape of it (ECC keys are much shorter than RSA keys for equivalent security) is the fact the practice quiz tests, and is stated directly above.

    Exam detail

    None of the curve arithmetic on this page is examinable. The one fact from this section that appears in the Week 5 practice quiz without a “non-examinable” flag is the general comparison: ECC keys are shorter than RSA’s for equivalent security, because the ECDLP is harder per bit. Treat that one sentence as fair game and everything else here as background.

    Pitfall

    The binary-field curve equation, y2+xy=x3+ax2+by^2 + xy = x^3 + ax^2 + b, is not the prime-field equation with a different modulus swapped in: it has an extra xyxy term and no linear axax term. Do not mix the two forms up if you are reading both.