conformal/btcec — pull request #8 by jimmysong (2014-09-25 22:12:35+00:00)
Title: Optimize ScalarMult using endomorphism

Optimize ScalarMult using endomorphism

Note this is on top of two other pr's.

This implements a speedup to ScalarMult using the endomorphism available to secp256k1.

Note the constants lambda, beta, a1, b1, a2 and b2 are from here:

https://bitcointalk.org/index.php?topic=3238.0

For whatever reason, rounding to the nearest integer does not work all the time (about 40% of the time, actually). I had to add 3 regardless so the number of bytes for each K is 17, which does work.

Preliminary tests indicate a speedup of between 17%-20% (BenchScalarMult).

More speedup can probably be achieved once splitK uses something more like what fieldVal uses. Unfortunately, the prime for this math is the order of G (N), not P.

Note the NAF optimization was specifically not done as that's the purview of another issue.

This closes #1