novitski / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
Apache License 2.0
0 stars 0 forks source link

Use ECAlgorithms.sumOfTwoMultiplies in ECKey.recoverFromSignature #492

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When performing two EC point multiplications on the same curve and summing the 
result, there is an algorithm for doing it considerably faster, which is 
encapsulated in BC's ECAlgorithms.sumOfTwoMultiplies method.

I note an opportunity to use this in ECKey.recoverFromSignature():

        ECPoint p1 = CURVE.getG().multiply(eInvrInv);
        ECPoint p2 = R.multiply(srInv);
        ECPoint.Fp q = (ECPoint.Fp) p2.add(p1);

=>

        ECPoint.Fp q = (ECPoint.Fp)ECAlgorithms.sumOfTwoMultiplies(CURVE.getG(), eInvrInv, R, srInv);

BTW, as of release 1.50 BC's EC performance is drastically improved, and there 
are further improvements particular to sumOfTwoMultiplies as well. I am not 
sure how long it will take for SpongyCastle to pick up this new release though.

Original issue reported on code.google.com by peter.de...@gmail.com on 6 Dec 2013 at 4:34

GoogleCodeExporter commented 9 years ago
Thanks for the code reviews Peter, it's appreciated! A performance boost in BC 
would be great, we definitely notice the perf hit sometimes especially with 
micropayments.

Once SpongyCastle follows your release we'll upgrade and utilise these tips. 
Key recovery is not a performance sensitive task as it's hardly used today, but 
who knows if that might change in future, so the optimisation is useful. If SC 
seems to be lagging then we poke the guy who does it, or simply redo the 
renaming in our own branch.

Original comment by hearn@google.com on 6 Dec 2013 at 10:48

GoogleCodeExporter commented 9 years ago
I note the low priority for this, but just to clarify: sumOfTwoMultiplies has 
been in BC for a long time, and is not new to 1.50; so it can be used already. 
In 1.50 we rewrote it to use the Joint Sparse Form representation, which gives 
a significant (further) reduction in the number of point additions required.

Original comment by peter.de...@gmail.com on 15 Dec 2013 at 2:42

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 8cc1920fa273.

Original comment by hearn@google.com on 15 Dec 2013 at 10:55