Skip to content
Elliptic Curves

Elliptic Curves

ECC is a set of public-key cryptographic algorithms based on elliptic curves over finite fields. It is used to create digital signatures and key exchanges.

General definition

As ECC relies on unusual mathematical problems and some concepts are very specific to this, the definition part is more detailed than orther sections.

Note: This section was made using the following resources:

NameAuthor
Elliptic Curves ChallengesCryptoHack
Elliptic Curve notesBen Lynn
An Introduction to Mathematical CryptographyJeffrey Hoffstein, Jill Pipher, Joseph H. Silverman

Elliptic curve

Elliptic curve

Given a field FF and two constants a,bFa, b \in F, an elliptic curve EE over FF is the set of points (x,y)F2(x, y) \in F^2 that satisfy the equation Y2=X3+aX+bY^2 = X^3 + aX + b:

E(F)={(x,y)F2:y2=x3+ax+b}{O}E(F) = \lbrace (x, y) \in F^2 : y^2 = x^3 + ax + b \rbrace \cup \lbrace \mathcal{O} \rbrace

To be a valid elliptic curve, the discriminant Δ=16(4a3+27b2)\Delta = -16(4a^3 + 27b^2) must be non-zero, i.e 4a3+27b204a^3 + 27b^2 \neq 0. Otherwise, the curve is called a singular curve.

We can already notice:

  • The curve is symmetric about the xx-axis, because y2=(y)2y^2 = (-y)^2
  • The curve contains a point at infinity O\mathcal{O}.

Point adition

We can now define the addition of two points on an elliptic curve.

The addition of two points PP and QQ can be defined as follows: Take the line through PP and QQ, and find the third point of intersection with this line. Then reflect this point about the xx-axis. The result is P+QP + Q.
  • If P=QP = Q, then the line is the tangent to the curve at PP.
  • If there is no third point of intersection, then the result is O\mathcal{O} which can be seen as the point at infinity.

This figure represents P+Q=RP + Q = R:

Point addition Point addition

The following properties can be observed:

  • If PP and QQ have rational coordinates, then so does RR.
  • P+O=O+P=PP + \mathcal{O} = \mathcal{O} + P = P (The point at infinity is the identity element.)
  • P+(P)=OP + (-P) = \mathcal{O} (The inverse of a point is its reflection about the xx-axis.)
  • P+Q=Q+PP + Q = Q + P (Addition is commutative.)
  • (P+Q)+R=P+(Q+R)(P + Q) + R = P + (Q + R) (Addition is associative.)

These properties makes the set of points on an elliptic curve coupled with the point addition operation an abelian group.

Point addition can be computed using the following formulas:

  • If PQP \neq Q:

    {xR=λ2xPxQyR=λ(xPxR)yP where λ=yQyPxQxP\begin{cases} x_R = \lambda^2 - x_P - x_Q \\\\ y_R = \lambda(x_P - x_R) - y_P \\\\ \end{cases} \text{ where } \lambda = \frac{y_Q - y_P}{x_Q - x_P}
  • If P=QP = Q:

    {xR=λ22xPyR=λ(xPxR)yP where λ=3xP2+a2yP\begin{cases} x_R = \lambda^2 - 2x_P \\\\ y_R = \lambda(x_P - x_R) - y_P \\\\ \end{cases} \text{ where } \lambda = \frac{3x_P^2 + a}{2y_P}

EC Cryptography

In ellyptic curve cryptography, the coordinates of points are usually in a prime finite field Fp\mathbb{F}_p where pp is a prime number. However, it is also possible to use a binary fields F2m\mathbb{F}_{2^m}.

Because of this, the set of points that verifies the equation of an elliptic curve can no longer be seen as a simple geometric curve. Now, the space can be seen as a rectangular grid of points. The left and right edges of the grid are connected, as well as the top and bottom edges. This is called a torus.

For exemple, here is the set of points of the elliptic curve Y2=X3XY^2 = X^3 − X over F61\mathbb{F}_{61}:

Elliptic curve over a finite field Elliptic curve over a finite field

We notice that:

  • Point addition as we defined it before still works on this grid. See this website for visual examples.
  • O\mathcal{O} is now (0, 0)
  • Because the curve is symmetric about the xx-axis and the space is finite, there is a new symmetry axis at the center of the grid.

Here is python sagemath code that defines the elliptic curve Y2=X3XY^2 = X^3 − X over F61\mathbb{F}_{61} and computes P+QP + Q:

p = 61
F = GF(p)
E = EllipticCurve(F, [-1, 0])
P = E(8, 4)
Q = E(17, 4)
R = P + Q # = R(36, 57)

Scalar multiplication

We can now define the scalar multiplication of a point PP by an integer kk.

The scalar multiplication is defined by iterating addition: kP=P+P++PkP = P + P + \cdots + P (kk times).

This operation is the trapdoor function of ECC, as inversing it is considered to be very hard. This problem is called the elliptic curve discrete logarithm problem (ECDLP): given PP and QQ, find kk such that Q=kPQ = kP.

Tricks

  • Point from x

    Usually, public and private keys are not given as a point PP on the curve but as an integer. It is sometimes easier to work with the xx coordinate of the point, as there are only two possible values for yy for a given xx. If y1y1 is a solution, y2=y1y2 = -y1 is the other one. In addition, using either y1y1 or y2y2 does not change the result of computations.

    Here is a python sagemath function that returns the point PP from its xx coordinate:

    P = E.lift_x(x, all=True)[0]

Attacks

Bad parameters

  • Smooth order using Pohlig–Hellman - Wikipedia

    If the order of the curve is smooth (i.e have a lot of small - under 10**12 - factors), the Pohlig–Hellman algorithm can be used to compute the discrete logarithm very quickly. Consequently, if he order is not prime itself, it must al least contain a large prime factor to prevent this.

    Sagemath’s discrete_log function can be used to compute the discrete logarithm for such primes. This script can be used to generate smooth numbers of selected size while this script can be used to compute the discrete logarithm on EC points.

  • MOV attack - StackExchange

    Some curves are vulnerable if they have a small embedding degree, such as supersingular curves.

    Embedding degree

    The embedding degree is the smallest integer kk such that the curve can be embedded in a field Fpk\mathbb{F}_{p^k}:

    (pk1)=0modE.order(p^k-1) = 0 \mod E.order

    If kk is small, the discrete logarithm can be computed in Fpk\mathbb{F}_{p^k}.

    This script can be used to compute the discrete logarithm on EC points using the MOV attack.

  • Smart’s attack on an anomalous curve

    When the order of the curve is the same as the prime pp of the field, the curve is called an anomalous curve. In this case, the discrete logarithm can be computed using smart’s attack from Lifts and Hensel’s Lemma. A description of the attack can be found here.

    This github repository contains an implementation of smart’s attack.

  • Singular curve - StackExchange

    If the discriminant of the curve Δ=16(4a3+27b2)\Delta = -16(4a^3 + 27b^2) is zero, the curve is called a singular curve. In this case, there is a bijection between the points of the curve and groups where the discrete logarithm is easy to compute.

    This repository contains an implementation of the attack.

Bad implementations

  • CurveBall (CVE-2020-0601) - GitHub

    This attack exploits a vulnerability in the implementation of the Curve25519 curve in Windows crypto API. The implementation does not check the provided generator GG and uses it for computations, making it possible to forge certificates for any domain.

  • Elliptic Curves on Real numbers - Cryptohack

    Discrete logarithm on elliptic curves over real numbers can be reduced to SVP using many methods.