randombit/botan

Faster modular inversion

Open

#1479 aperta il 8 mar 2018

Vedi su GitHub
 (9 commenti) (1 reazione) (0 assegnatari)C++ (654 fork)auto 404
enhancementhelp wantedperformance

Metriche repository

Star
 (3283 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

At this point modular inversion is one of the major bottlenecks in ECDSA signature generation, at about 30% of the total runtime. Two inversions are required, one for the nonce and the other to convert the point to affine.

Niels Moller sent me an email where he contended that the fastest approach for const time inversion at ECC sizes was using Fermat's little theorem. However in Botan with P-521, using the const time inversion algorithm (that Niels invented) is over twice as fast. So maybe the issue is (also) that our modular exponentiation algorithm is too slow.

I ran some quick checks, OpenSSL seems to take ~210k cycles for const time modular inversion, vs 360k cycles in ct_inverse_mod_odd_modulus. Simply matching that would improve ECDSA signature perf by 15%

Guida contributor