Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!--- Please provide a general summary of your changes in the title above --> ## Pull Request type <!-- Please try to limit your pull request to one type; submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [x] Refactoring (no functional changes, no API changes) - [ ] Build-related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? > No dedicated u256 sqr, which can be done with one less u128 mul. `pow_mod` uses `mult_mod` ## What is the new behavior? > Instead of `mult_mod(x, x)`, call the more efficient `sqr_mod(x)` > > A new `u256_wide_sqr` which is largely identical to `u256_wide_mul` is added, > <img width="1582" alt="image" src="https://github.com/keep-starknet-strange/alexandria/assets/11048263/3bf4223b-a751-4932-a9d4-77c6ba67abc1"> `pow_mod` uses `sqr_mod` ```diff - test alexandria_math::tests::mod_arithmetics_test::pow_mod_test ... ok (gas usage est.: 27066340) + test alexandria_math::tests::mod_arithmetics_test::pow_mod_test ... ok (gas usage est.: 26160370) - test alexandria_math::tests::mod_arithmetics_test::pow_mod_1_test ... ok (gas usage est.: 27015940) + test alexandria_math::tests::mod_arithmetics_test::pow_mod_1_test ... ok (gas usage est.: 26109970) - test alexandria_math::tests::mod_arithmetics_test::pow_mod_2_test ... ok (gas usage est.: 27015940) + test alexandria_math::tests::mod_arithmetics_test::pow_mod_2_test ... ok (gas usage est.: 26109970) ``` ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this does introduce a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR, such as screenshots of how the component looks before and after the change. -->
- Loading branch information