This PR replaces the modexp implementation with a more efficient one. This addresses a performance issue that has been raised to us.
Performance / NEAR gas cost considerations
The PR is all about performance. New benchmarks are added for modexp. We also see the gas cost go down for repro_Emufid2 because that transaction uses the modexp precompile.
Testing
New code includes unit tests. We also have the existing modexp tests.
How should this be reviewed
The code here is a little hard to read because it is implementing very low-level algorithms. Reviewers are welcome to read the papers referenced in the README to help get the overall idea of what is going on in the code. The correctness of this code has also been validated by comparing many cases against the results of other Rust libraries (ibig and num-bigint).
Description
This PR replaces the
modexp
implementation with a more efficient one. This addresses a performance issue that has been raised to us.Performance / NEAR gas cost considerations
The PR is all about performance. New benchmarks are added for
modexp
. We also see the gas cost go down forrepro_Emufid2
because that transaction uses themodexp
precompile.Testing
New code includes unit tests. We also have the existing
modexp
tests.How should this be reviewed
The code here is a little hard to read because it is implementing very low-level algorithms. Reviewers are welcome to read the papers referenced in the README to help get the overall idea of what is going on in the code. The correctness of this code has also been validated by comparing many cases against the results of other Rust libraries (
ibig
andnum-bigint
).