Schoof's algorithm

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Schoof's algorithm is an efficient algorithm to count points on elliptic curves over finite fields. The algorithm has applications in elliptic curve cryptography where it is important to know the number of points to judge the difficulty of solving the discrete logarithm problem in the group of points on an elliptic curve.

The algorithm was published by René Schoof in 1985 and it was a theoretical breakthrough, as it was the first deterministic polynomial time algorithm for counting points on elliptic curves. Before Schoof's algorithm, approaches to counting points on elliptic curves such as the naive and baby-step giant-step algorithms were, for the most part, tedious and had an exponential running time.

This article explains Schoof's approach, laying emphasis on the mathematical ideas underlying the structure of the algorithm.


Let E be an elliptic curve defined over the finite field \mathbb{F}_q, where q=p^n for p a prime and n an integer \geq 1. Over a field of characteristic \neq 2, 3 an elliptic curve can be given by a (short) Weierstrass equation

y^2 = x^3 + Ax + B \,

with A,B\in \mathbb{F}_{q}. The set of points defined over \mathbb{F}_{q} consists of the solutions (a,b)\in\mathbb{F}_{q}^2 satisfying the curve equation and a point at infinity O. Using the group law on elliptic curves restricted to this set one can see that this set E(\mathbb{F}_{q}) forms an abelian group, with O acting as the zero element. In order to count points on an elliptic curve, we compute the cardinality of E(\mathbb{F}_{q}). Schoof's approach to computing the cardinality \sharp E(\mathbb{F}_{q}) makes use of Hasse's theorem on elliptic curves along with the Chinese remainder theorem and division polynomials.

Hasse's theorem[edit]

Hasse's theorem states that if E/\mathbb{F}_{q} is an elliptic curve over the finite field \mathbb{F}_{q}, then \sharp E(\mathbb{F}_q) satisfies

\mid q + 1 - \sharp E(\mathbb{F}_{q}) \mid \leq 2\sqrt{q}.

This powerful result, given by Hasse in 1934, simplifies our problem by narrowing down \sharp E(\mathbb{F}_{q}) to a finite (albeit large) set of possibilities. Defining t to be q + 1 - \sharp E(\mathbb{F}_{q}), and making use of this result, we now have that computing the cardinality of t modulo N where N > 4\sqrt{q}, is sufficient for determining t, and thus \sharp E(\mathbb{F}_{q}). While there is no efficient way to compute t \pmod N directly for general N, it is possible to compute t  \pmod l for l a small prime, rather efficiently. We choose S=\{l_1,l_2,...,l_r\} to be a set of distinct primes such that \prod l_i = N > 4\sqrt{q}. Given t \pmod {l_i} for all l_i\in S, the Chinese remainder theorem allows us to compute t \pmod N.

In order to compute t  \pmod l for a prime l \neq p, we make use of the theory of the Frobenius endomorphism \phi and division polynomials. Note that considering primes l \neq p is no loss since we can always pick a bigger prime to take its place to ensure the product is big enough. In any case Schoof's algorithm is most frequently used in addressing the case q=p since there are more efficient, so called p adic algorithms for small-characteristic fields.

The Frobenius endomorphism[edit]

Given the elliptic curve E defined over \mathbb{F}_{q} we consider points on E over \overline{\mathbb{F}_{q}}, the algebraic closure of \mathbb{F}_{q}; i.e. we allow points with coordinates in \bar{\mathbb{F}}_{q}. The Frobenius endomorphism of \bar{\mathbb{F}}_{q} over \mathbb{F}_q extends to the elliptic curve by  \phi : (x, y) \mapsto (x^{q}, y^{q}).

This map is the identity on E(\mathbb{F}_{q}) and one can extend it to the point at infinity O, making it a group morphism from E(\bar{\mathbb{F}_{q}}) to itself.

The Frobenius endomorphism satisfies a quadratic polynomial which is linked to the cardinality of E(\mathbb{F}_{q}) by the following theorem:

Theorem: The Frobenius endomorphism given by \phi satisfies the characteristic equation

  \phi ^2 - t\phi + q = 0, where  t = q + 1 - \sharp E(\mathbb{F}_q)

Thus we have for all P=(x, y) \in E that (x^{q^{2}}, y^{q^{2}} ) + q(x, y) = t(x^{q}, y^{q}), where + denotes addition on the elliptic curve and q(x,y) and t(x^{q},y^{q}) denote scalar multiplication of (x,y) by q and of (x^{q},y^{q}) by t.

One could try to symbolically compute these points (x^{q^{2}}, y^{q^{2}}), (x^{q}, y^{q}) and q(x, y) as functions in the coordinate ring \mathbb{F}_{q}[x,y]/(y^{2}-x^{3}-Ax-B) of E and the search for a value of t which satisfies the equation. However, the degrees get very large and this approach is impractical.

Schoof's idea was to carry out this computation restricted to points of order l for various small primes l. Fixing an odd prime l, we now move on to solving the problem of determining t_{l}, defined as t  \pmod l, for a given prime l \neq 2, p. If a point (x, y) is in the l-torsion subgroup E[l]=\{P\in E(\bar{\mathbb{F}_{q}}) \mid lP=O \}, then qP = \bar{q}P where \bar{q} is the unique integer such that q \equiv \bar{q}  \pmod l and \mid \bar{q} \mid< l/2. Note that \phi(O) = O and that for any integer r we have r\phi (P) = \phi (rP). Thus \phi (P) will have the same order as P. Thus for (x, y) belonging to E[l], we also have t(x^{q}, y^{q})= \bar{t}(x^{q}, y^{q}) if t \equiv \bar{t}  \pmod l. Hence we have reduced our problem to solving the equation

  (x^{q^{2}}, y^{q^{2}}) + \bar{q}(x, y) \equiv \bar{t}(x^{q}, y^{q}),

where \bar{t} and \bar{q} have integer values in [-(l-1)/2,(l-1)/2].

Computation modulo primes[edit]

The lth division polynomial is such that its roots are precisely the x coordinates of points of order l. Thus, to restrict the computation of (x^{q^{2}}, y^{q^{2}}) + \bar{q}(x, y) to the l-torsion points means computing these expressions as functions in the coordinate ring of E and modulo the lth division polynomial. I.e. we are working in \mathbb{F}_{q}[x,y]/(y^{2}-x^{3}-Ax-B, \psi_{l}). This means in particular that the degree of X and Y defined via (X(x,y),Y(x,y)):=(x^{q^{2}}, y^{q^{2}}) + \bar{q}(x, y) is at most 1 in y and at most (l^2-3)/2 in x.

The scalar multiplication \bar{q}(x, y) can be done either by double-and-add methods or by using the \bar{q}th division polynomial. The latter approach gives:

\bar{q} (x,y) = (x_{\bar{q}},y_{\bar{q}}) = \left( x - \frac {\psi_{\bar{q}-1} \psi_{\bar{q}+1}}{\psi^{2}_{\bar{q}}}, \frac{\psi_{2\bar{q}}}{2\psi^{4}_{\bar{q}}} \right)

where \psi_{n} is the nth division polynomial. Note that y_{\bar{q}}/y is a function in x only and denote it by \theta(x).

We must split the problem into two cases: the case in which (x^{q^{2}}, y^{q^{2}}) \neq \pm \bar{q}(x, y), and the case in which (x^{q^{2}}, y^{q^{2}}) = \pm \bar{q}(x, y). Note that these equalities are checked modulo \psi_l.

Case 1 (x^{q^{2}}, y^{q^{2}}) \neq \pm \bar{q}(x, y)[edit]

By using the addition formula for the group E(\mathbb{F}_{q}) we obtain:

X(x,y) = \left( \frac{y^{q^{2}} - y_{\bar{q}}}{x^{q^{2}} - x_{\bar{q}}} \right) ^{2} - x^{q^{2}} - x_{\bar{q}}.

Note that this computation fails in case the assumption of inequality was wrong.

We are now able to use the x-coordinate to narrow down the choice of \bar{t} to two possibilities, namely the positive and negative case. Using the y-coordinate one later determines which of the two cases holds.

We first show that X is a function in x alone. Consider (y^{q^{2}} - y_{\bar{q}})^{2}=y^{2}(y^{q^{2}-1}-y_{\bar{q}}/y)^{2}. Since q^{2}-1 is even, by replacing y^{2} by x^3+Ax+B, we rewrite the expression as


and have that

X(x)\equiv (x^3+Ax+B)((x^3+Ax+B)^{\frac{q^{2}-1}{2}}-\theta(x))\bmod \psi_l(x).

Now if X \equiv x^{q} _ {\bar{t}}\bmod \psi_l(x) for one \bar{t}\in [0,(l-1)/2] then \bar{t} satisfies

\phi ^{2}(P) \mp \bar{t} \phi(P) + \bar{q}P = O

for all l-torsion points P.

As mentioned earlier, using Y and y_{\bar{t}}^{q} we are now able to determine which of the two values of \bar{t} (\bar{t} or -\bar{t}) works. This gives the value of t\equiv \bar{t}\pmod l. Schoof's algorithm stores the values of \bar{t}\pmod l in a variable t_l for each prime l considered.

Case 2 (x^{q^{2}}, y^{q^{2}}) = \pm \bar{q}(x, y)[edit]

We begin with the assumption that (x^{q^{2}}, y^{q^{2}}) = \bar{q}(x, y). Since l is an odd prime it cannot be that \bar{q}(x, y)=-\bar{q}(x, y) and thus \bar{t}\neq 0. The characteristic equation yields that \bar{t} \phi(P) = 2\bar{q} P. And consequently that \bar{t}^{2}\bar{q} \equiv (2q)^{2}  \pmod l. This implies that q is a square modulo l. Let q \equiv w^{2}  \pmod l. Compute w\phi(x,y) in \mathbb{F}_{q}[x,y]/(y^{2}-x^{3}-Ax-B, \psi_{l}) and check whether 
\bar{q}(x, y)=w\phi(x,y). If so, t_{l} is \pm 2w \pmod l depending on the y-coordinate.

If q turns out not to be a square modulo l or if the equation does not hold for any of w and -w, our assumption that (x^{q^{2}}, y^{q^{2}}) = +\bar{q}(x, y) is false, thus (x^{q^{2}}, y^{q^{2}}) = - \bar{q}(x, y). The characteristic equation gives t_l=0.

Additional case l = 2[edit]

If you recall, our initial considerations omit the case of l = 2. Since we assume q to be odd, q + 1 - t  \equiv  t \pmod  2 and in particular, t_{2} \equiv 0  \pmod 2 if and only if E(\mathbb{F}_{q}) has an element of order 2. By definition of addition in the group, any element of order 2 must be of the form (x_{0}, 0). Thus t_{2} \equiv 0  \pmod 2 if and only if the polynomial x^{3} + Ax + B has a root in \mathbb{F}_{q}, if and only if \gcd(x^{q}-x, x^{3} + Ax + B)\neq 1.

The algorithm[edit]

(1) Choose a set of odd primes S not containing p such that N=\prod_{l\in S} l > 4\sqrt{q}.
(2) Put t_2=0 if \gcd(x^{q}-x, x^{3} + Ax + B)\neq 1, else t_2=1.
(3) Compute the division polynomial \psi_l. All computations in the loop below are performed in the ring \mathbb{F}_{q}[x,y]/(y^{2}-x^{3}-Ax-B, \psi_{l}).
(4) For l \in S do:
(a) Let \bar{q} be the unique integer such that q \equiv \bar{q}  \pmod l and \mid \bar{q} \mid< l/2.
(b) Compute (x^{q}, y^{q}), (x^{q^{2}}, y^{q^{2}}) and (x_{\bar{q}},y_{\bar{q}}) .
(c) if x^{q^{2}}\neq x_{\bar{q}} then
(i) Compute (X,Y) .
(ii) For 1\leq \bar{t} \leq (l-1)/2 do:
(iii) if X = x^{q} _ {\bar{t}} then
(iv) if Y = y^{q} _ {\bar{t}} then t_{l}=\bar{t}; else t_{l}=-\bar{t}.
(d) else if q is a square modulo l then
(i) compute w with q\equiv w^{2} \pmod l
(ii) compute w(x^{q}, y^{q})
(iii) if w(x^{q}, y^{q})=(x^{q^{2}}, y^{q^{2}}) then t_l=2w
(iv) else if w(x^{q}, y^{q})=(x^{q^{2}}, -y^{q^{2}}) then t_l=-2w
(v) else t_{l}=0
(e) else t_{l}=0
(5) Use the Chinese Remainder Theorem to compute t modulo N.

Note that since the set S was chosen so that N>4\sqrt{q}, by Hasse's theorem, we in fact know t and  \sharp E(\mathbb{F}_{q}) = q+1-t precisely.


Most of the computation is taken by the evaluation of \phi(P) and \phi^{2}(P), for each prime l, that is computing x^q, y^q, x^{q^2}, y^{q^2} for each prime l. This involves exponentiation in the ring R = \mathbb{F}_{q}[x, y]/ (y^2-x^3-Ax-B, \psi_l) and requires O(\log q) multiplications. Since the degree of \psi_l is \frac{l^2-1}{2}, each element in the ring is a polynomial of degree O(l^2). By the prime number theorem, there are around O(\log q) primes of size O(\log q), giving that l is O(\log q) and we obtain that O(l^2) = O(\log^2q). Thus each multiplication in the ring R requires O(\log^4 q) multiplications in \mathbb{F}_{q} which in turn requires O(\log^2 q) bit operations. In total, the number of bit operations for each prime l is O(\log^7 q). Given that this computation needs to be carried out for each of the O(\log q) primes, the total complexity of Schoof's algorithm turns out to be O(\log^8 q). Using fast polynomial and integer arithmetic reduces this to \tilde{O}(\log^5 q).

Improvements to Schoof's algorithm[edit]

In the 1990s, Noam Elkies, followed by A. O. L. Atkin, devised improvements to Schoof's basic algorithm by restricting the set of primes S =  \{l_1, \ldots, l_s\} considered before to primes of a certain kind. These came to be called Elkies primes and Atkin primes respectively. A prime l is called an Elkies prime if the characteristic equation: \phi^2-t\phi+ q = 0 splits over \mathbb{F}_l, while an Atkin prime is a prime that is not an Elkies prime. Atkin showed how to combine information obtained from the Atkin primes with the information obtained from Elkies primes to produce an efficient algorithm, which came to be known as the Schoof–Elkies–Atkin algorithm. The first problem to address is to determine whether a given prime is Elkies or Atkin. In order to do so, we make use of modular polynomials, which come from the study of modular forms and an interpretation of elliptic curves over the complex numbers as lattices. Once we have determined which case we are in, instead of using division polynomials, we are able to work with a polynomial that has lower degree than the corresponding division polynomial: O(l) rather than O(l^2). For efficient implementation, probabilistic root-finding algorithms are used, which makes this a Las Vegas algorithm rather than a deterministic algorithm. Under the heuristic assumption that approximately half of the primes up to an O(\log q) bound are Elkies primes, this yields an algorithm that is more efficient than Schoof's, with an expected running time of O(\log^6 q) using naive arithmetic, and \tilde{O}(\log^4 q) using fast arithmetic. It should be noted that while this heuristic assumption is known to hold for most elliptic curves, it is not known to hold in every case, even under the GRH.


Several algorithms were implemented in C++ by Mike Scott and are available with source code. The implementations are free (no terms, no conditions), and make use of the MIRACL library which is distributed under the AGPLv3.

See also[edit]


  • R. Schoof: Elliptic Curves over Finite Fields and the Computation of Square Roots mod p. Math. Comp., 44(170):483–494, 1985. Available at
  • R. Schoof: Counting Points on Elliptic Curves over Finite Fields. J. Theor. Nombres Bordeaux 7:219–254, 1995. Available at
  • G. Musiker: Schoof's Algorithm for Counting Points on E(\mathbb{F}_{q}). Available at
  • V. Müller : Die Berechnung der Punktanzahl von elliptischen kurven über endlichen Primkörpern. Master's Thesis. Universität des Saarlandes, Saarbrücken, 1991. Available at
  • A. Enge: Elliptic Curves and their Applications to Cryptography: An Introduction. Kluwer Academic Publishers, Dordrecht, 1999.
  • L. C. Washington: Elliptic Curves: Number Theory and Cryptography. Chapman & Hall/CRC, New York, 2003.
  • N. Koblitz: A Course in Number Theory and Cryptography, Graduate Texts in Math. No. 114, Springer-Verlag, 1987. Second edition, 1994