This fixes the following issues with engine-modexp:
addition overflow in big_sq that would lead to incorrect output (and a crash in debug mode)
assert failure in sub_to_same_size that would lead to incorrect output
slow modular exponentiation with even modulus. The bottleneck was the routine were the inverse of A mod M was computed, where M is a power of two. This inversion function has been replaced with the algorithm found in this paper, which is much faster.
Performance / NEAR gas cost considerations
The performance of modular exponentiation with even modulus is improved. Performance remains the same for odd modulus.
Testing
Extensive fuzz testing, was was also the method used to detect the issues that this PR addresses.
Description
This fixes the following issues with
engine-modexp
:Performance / NEAR gas cost considerations
The performance of modular exponentiation with even modulus is improved. Performance remains the same for odd modulus.
Testing
Extensive fuzz testing, was was also the method used to detect the issues that this PR addresses.
How should this be reviewed
Additional information