Closed yelhousni closed 3 years ago
If there are more than one series of 0's for which Karabina's cyclotomic square is better, one can use a Montgomery batch inverse to decompress the results of both series at once. Concretely, this happens for BLS24-315 and yields significant speedup and for BLS12-381 but with minor speedup.
The cost of the final exponentiation is dominated by
Expt()
, which is a square-and-multiply exponentiation by the curve seedu
. Currently, the squarings are implemented as in the Granger-Scott cyclotomic squaring (GS).For the curves implemented in gnark-crypto (except for BN254), there is a series of consecutive 0's in the seed and it might be interesting to switch to the Karabina cyclotomic squaring only of this series.
Karabina's method works on compressed
GT
elements and saves 2 multiplications inF_p^{k/d}
compared to GS, wherek
is the embedding degree andd
the twist degree. The cost of decompression, however, is dominated by an inverse inF_p^{k/d}
.Concretely, given a series of
s
0's in the seed, the trick is worth it if:1
inverse overF_p
costs less than6*s-4
muls overF_p
1
inverse overF_p
costs less than18*s-16
muls overF_p