Stange’s Algorithm for Elliptic Nets
November 8th, 2007In Shipsey’s algorithm1 for EDS, the septuples centred on terms mk and (m+1)k can be used to construct the septuple about 2mk, (2m+1)k or (2m+2)k from that about k. With k=1 this gives rise to a double-and-add algorithm, such that term n can be obtained in logarithmic time; knowledge of larger k introduces an additional speedup.
However, Shipsey’s approach makes use of various inverses, potentially giving division-by-zero errors for a sequence corresponding to a point of finite order (any point, in the finite field cases of interest for pairing computations). Further, the recurrence relation for a rank 2 elliptic net is more complicated than for an EDS, and we ultimately wish to find terms (m,0) and (m,1). Stange provides an algorithm to achieve this, replacing the septuple with an 11-element block centred on k as follows:
| (k-1,1) | (k,1) | (k+1,1) | |||||
| (k-3,0) | (k-2,0) | (k-1,0) | (k,0) | (k+1,0) | (k+2,0) | (k+3,0) | (k+4,0) |
Notice that the blocks centred at any of m, m-1 or m+1 will contain the information needed to compute the pairing. Thus we generate such a block by a double-and-add algorithm.
Algorithm
Double-and-add Algorithm
INPUT: Integer n and block centred at 1.
OUTPUT: Block centred at n.
- Compute binary digits di of n such that n=(dkdk-1…d1)2 with dk=1.
- Set c=1 (centre)
- For i=k-1 down to 1 do:
- If d_i=0 Compute block with centre 2c; Set c to 2c
- Else, Compute block with centre 2c+1; Set c to 2c+1
- Return final block.
Clearly, this requires procedures to generate new blocks from old- Stange2 gives formulae for these ((12)-(17)). A speed-up (Id. S5.1) can be achieved by computing commonly used squares/products at each step, denoted by the A(i) (squares) and B(i) (products) below.
Double

DoubleAdd

The inversions in the recurrence formulae are independent of k, so are precomputed and made available to Double and DoubleAdd as multipliers. Including multiplication by these values, the total cost of a block double/double-and-add is 35 multiplications, 7 squarings, 11 additions and no inversions.
A minor refinement
Define a 10-element short block centred at k by
| (k-1,1) | (k,1) | (k+1,1) | ||||
| (k-3,0) | (k-2,0) | (k-1,0) | (k,0) | (k+1,0) | (k+2,0) | (k+3,0) |
shortDouble
Notice from the Double dependencies that the (k+4,0) term is necessary only to generate (2k+4,0). Thus given a short block centred at k, we can double it to obtain the short block centred at 2k, with the following dependencies:

The inversions in the recurrence formulae are independent of k, so are precomputed and made available to shortDouble as multipliers. Including multiplication by these values, the total cost of a short block double is 31 multiplications, 6 squarings, 10 additions and no inversions.
shortDoubleAdd
From the DoubleAdd dependencies it can be seen that the missing (k+4,0) is required for both (2k+4,0) and (2k+5,0)- although the latter can be dropped for a short block, the former cannot. Thus it is not possible to adapt this choice of recurrence formulae to give a DoubleAdd for short blocks. Nonetheless, the basic algorithm can be ammended to exploit the simpler short block Double once no further DoubleAdds are required; as the short block is sufficient for finding the Tate Pairing.
Algorithm
Amended Double-and-add Algorithm
INPUT: Integer n and block centred at 1.
OUTPUT: Block centred at n.
- Compute s,p such that p is odd and n=2sp.
- Compute binary digits di of p such that p=(dkdk-1…d1)2 with dk=1.
- Set c=1 (centre)
- For i=k-1 down to 1 do:
- If d_i=0 Compute block with centre 2c using Double; Set c to 2c
- Else, Compute block with centre 2c+1 using DoubleAdd; Set c to 2c+1
- This gives the block with centre p, and thus the short block with centre p.
- For i from 1 to s do:
- Compute short block with centre 2c using shortDouble; Set c to 2c
- Return final block.
The efficiency gain of this variant depends on n- if n is a power of 2, then we may proceed entirely by shortDouble with 47 instead of 53 operations, a saving of around 11 percent (this will vary depending on the precise cost of multiplication, squaring and addition). If, however, n is odd then there is no gain. Thus pairing computation can be improved in the case of points with order a high power of two.
Implementation
A SAGE ellnet class is available, which implements all these ideas for rank 2 (Stange’s algorithm, with precomputation of inverses, caching of commonly-used factors at each step, and finishing by short blocks). See this post for how to generate nets from points and compute pairings.
References
1: Shipsey- Elliptic Divisibility Sequences (Download)
2: Stange- The Tate Pairing via Elliptic Nets (Preprint)
