Miller’s Algorithm

Consider E[l], the l-torsion points of an elliptic curve E. Write fP for the rational function with divisor l(P)l(O).

Let gP,Q be the line between the points P and Q, and let fc be the function with divisor (fc)=c(P)(cP)(c1)(O). Then for all a,bZ, we have fa+b(Q)=fa(Q)fb(Q)gaP,bP(Q)/g(a+b)P,(a+b)P(Q). Let the binary representation of l be lt,...,l0. Then Miller’s algorithm computes fP(Q) as follows.

  1. set f1 and VP

  2. for it1 to 0 do

    1. set ff2gV,V(Q)/g2V,2V(Q) and V2V

    2. if li=1 then

      1. set ffgV,P(Q)/gV+P,(V+P)(Q) and VV+P

At the end, f=fl(Q)=fP(Q), and V=lP=O.

By adding extra logic in the above algorithm, we can avoid handling points of infinity when computing the g functions. On the last iteration, we know V=P if l is odd, and V has order 2 if l is even.

The gP,Q functions

Let the curve be Y=X3+aX+b.

  • Tangents: At the point (x,y), the line describing the tangent at that point is λX+Y+(y+λx), where λ=3x2+a2y.

  • Vertical lines: These are lines between P and P. Let P=(x,y). Then the vertical line through P is X+(x).

  • Other lines: The line between P=(x1,y1) and Q=(x2,y2) is given by λX+Y+(y1+λx1) where λ=y2y1x2x1.

It may be more efficient scale λ appropriately and do all the divisions at once. If the embedding degree is at least two, and P,Q are in the base field, the Tate exponentiation will get rid of any scaling factors. If the embedding degree is one, then since one has to compute f(Q+R)/f(Q) (which should be computed with one iteration of Miller’s algorithm), the scaling factors in the numerator cancel those in the denominator. Thus the functions may be scaled as follows:

  • Tangents:

(3x2+a)X+(2y)Y+(2y2+x(3x2+a))
  • Verticals:

X+(x)
  • Lines:

(y1y2)X+(x2x1)Y+(x1y2x2y1)

(TODO: move to optimizations page since it assumes we’re using Tate. mention projective coords and mixin) If P lies in the ground field and k>2, then many divisions can be avoided since we may scale by quantities such as 2y and x2x1 in the above equations. These quantities lie in the ground field hence become 1 during exponentiation.

Note

fl+1=flf1glP,Pg(l+1)P,(l+1)P=flgO,PgP,P=fl

that is, fl=fl+1, hence if l=2s1, we can easily compute fl(Q) using basically s squarings. For Solinas primes of the form l=2a+2b1 (where a>b), computing f2b(Q) is an intermediate step in computing f2a(Q), and then we may simply use one of the above formulas to compute f2a+2b(Q)=fl+1(Q)=fl(Q).

Sometimes we need to compute fab. First note

(fb)=b(P)(bP)(b1)(O)

hence

(fbfb)=[(bP)+(bP)2(O)]=(gbP,bP)

Thus

fab=fafbgaP,bP/g(ab)P,(ab)P=fagaP,bPfbgbP,bPg(ab)P,(ab)P

Under certain conditions(described later), then we have fl1=fl so the last iteration of Miller’s algorithm can be simplified.


Ben Lynn blynn@cs.stanford.edu 💡