Miller's Algorithm
Consider , the -torsion points of an elliptic curve . Write for the rational function with divisor .
Let be the line between the points and , and let be the function with divisor . Then for all , we have . Let the binary representation of be . Then Miller's algorithm computes as follows.
-
set and
-
for to 0 do
-
set and
-
if then
set and
-
At the end, , and .
By adding extra logic in the above algorithm, we can avoid handling points of infinity when computing the functions. On the last iteration, we know if is odd, and has order 2 if is even.
The functions
Let the curve be .
-
Tangents: At the point , the line describing the tangent at that point is , where .
-
Vertical lines: These are lines between and . Let . Then the vertical line through is .
-
Other lines: The line between and is given by where .
It may be more efficient scale appropriately and do all the divisions at once. If the embedding degree is at least two, and 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 (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:
-
Verticals:
-
Lines:
(TODO: move to optimizations page since it assumes we're using Tate. mention projective coords and mixin) If lies in the ground field and , then many divisions can be avoided since we may scale by quantities such as and in the above equations. These quantities lie in the ground field hence become 1 during exponentiation.
Note
that is, , hence if , we can easily compute using basically squarings. For Solinas primes of the form (where ), computing is an intermediate step in computing , and then we may simply use one of the above formulas to compute .
Sometimes we need to compute . First note
hence
Thus
Under certain conditions(described later), then we have so the last iteration of Miller's algorithm can be simplified.