-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
secp256k1: Optimize field inverse calc.
This optimizes the field multiplicative inverse calculation to use a more optimal addition chain which reduces the number of field squarings from 258 to 255 and the number field multiplications from 33 to 15. This calculation is primarily involved when converting back to affine space which is done for various things such as: - Calculating public keys - ECDSA signing - Generating shared secrets via ECDHE - Public key recover from a compact signature - Schnorr signing and signature verification - Calculating hierarchical deterministic extended keys The following benchmarks show a before and after comparison of field inversion as well as how it that translates to public key calculation, schnorr signature verification, and recovery from compact signatures: name old time/op new time/op delta ------------------------------------------------------------------------ FieldInverse 12.0µs ± 0% 10.9µs ± 1% -8.96% (p=0.008 n=10+10) PrivateKeyPubKey 35.0µs ± 1% 33.9µs ± 2% -3.18% (p=0.008 n=10+10) SchnorrSigVerify 122µs ± 1% 121µs ± 1% -0.82% (p=0.015 n=10+10) RecoverCompact 137µs ± 1% 135µs ± 1% -1.35% (p=0.002 n=10+10)
- Loading branch information
Showing
1 changed file
with
112 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters