Recently I’m implementing some optimizations related to pairing calculations in elliptic curve cryptography. This note summarises some of my learning so far, and I hope it would be helpful for someone coming from a pure maths background who wants to learn about implementation and optimization details.
Elliptic Curve Pairing For Mathematicians
A pairing in cryptography is a bilinear map with certain computational properties that are very useful for cryptography applications. There are many applications for pairing-based cryptography and I will not go over them here. The Weil pairing was the first proposed pairing map, which is really the Poincaré duality for Étale cohomology. In practice, cryptographers use other related variants (e.g. Tate pairing coming from Poitou-Tate duality) for performance reasons. For someone whose background was not in number theory, I found Silverman’s survey to be a clear conceptual explanation of where the various pairings arise from.
For an elliptic curve (a smooth, projective algebraic curve of genus 1 with a marked point ), its rational points are in bijection with the degree zero part of its Picard group. One proof of this fact is based on a dimensionality argument using Riemann-Roch. Concretely, this map sends a point
to the line bundle represented by the divisor
. Tensor product of line bundles in the Picard group induces a multiplication map on the rational points, which recovers the classical group law.
Miller’s Algorithm
In practice, computing pairings on elliptic curves in some presentation can be challenging although it’s conceptually clear (to algebraic geometers) that they define a bilinear map. The original paper of Miller considers the problem of computing a rational function on an algebraic curve that corresponds to a given divisor (in the sense that the given divisor is equivalent to some effective divisor given that function). For an elliptic curve, this basically boils down to the identity
where is the function of the line passing through
and
, where
is a rational function representing the ratio of two lines that we will define later. Equation 1 follows straightforwardly from the following two identities corresponding to divisors that represent the line passing through
and
and the vertical line at
-coordinate
.
We then set to recover the desired identity. Miller’s algorithm (as described below) then uses (1) at each step to compute the rational function whose divisor corresponds to
for an
-torsion point
, where the proof essentially follows from a telescoping sum argument.
Set
and
Loop
down to
Set
Set
If
Set
Set
End If
End
Loop
Return the value 
(This section follows the presentation in Silverman’s book on the arithmetic of elliptic curves.)
Optimization
There are many techniques to speed up pairing calculations; I’ll probably address them in a later post. The notes gives a detailed discussion on the optimization details of pairing calculations. One particular optimization related to computing the Miller loop is that one can drop the denominator of the line function (so-called “denomination elimination” technique).