Commit graph

10 commits

Author SHA1 Message Date
Dave Collins 87968edb1d Import btcec repo into btcec directory. 2015-02-06 10:09:24 -06:00
Jimmy Song 6c36218ef3 Optimize ScalarMult with NAF
Use Non-Adjacent Form (NAF) of large numbers to reduce ScalarMult computation times.

Preliminary results indicate around a 8-9% speed improvement according to BenchmarkScalarMult.

The algorithm used is 3.77 from Guide to Elliptical Curve Crytography by Hankerson, et al.

This closes #3
2015-02-05 08:28:51 -06:00
Jimmy Song 95b23c293c Optimize ScalarMult using endomorphism
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

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.

Changed both ScalarMult and ScalarBaseMult to take advantage of curve.N to reduce k.
This results in a 80% speedup to large values of k for ScalarBaseMult.
Note the new test BenchmarkScalarBaseMultLarge is how that speedup number can
be checked.

This closes #1
2015-02-03 14:14:21 -06:00
Dave Collins 45d21a254c Update btcec import paths to new location. 2015-01-16 18:02:57 -06:00
Jimmy Song ae28fe6d97 Use btcec structs instead of ecdsa structs everywhere.
This change should make it so that only btcec relies on the crypto/ecdsa package for secp256k1 math.
2014-10-12 22:36:06 -05:00
Jimmy Song d69442834c Optimize ScalarBaseMult
Code uses a windowing/precomputing strategy to minimize ECC math.
Every 8-bit window of the 256 bits that compose a possible scalar multiple has a complete map that's pre-computed.
The precomputed data is in secp256k1.go and the generator for that file is in gensecp256k1.go

Also fixed a spelling error in a benchmark test.

Results so far seem to indicate the time taken is about 35% of what it was before.

Closes #2
2014-09-24 19:07:58 -05:00
Dave Collins 22014931d4 goimports -w . 2014-07-02 19:39:37 -05:00
Dave Collins 58cab817f0 Add 2014 to copyright dates. 2014-01-08 23:51:37 -06:00
Dave Collins ac7e4de201 Add field and point addition/multiplicaiton tests.
This commit adds 100% test coverage for the new code.  This brings the
overall btcec coverage up to 99.76%.
2013-12-20 15:09:58 -06:00
Dave Collins 6e9cc57131 Initial implementation. 2013-06-13 14:38:54 -05:00