Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce amount of modular reduction calls in point add/double #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

capito27
Copy link
Contributor

Another low-ish hanging fruit for #10.

When two integers of a maximal bit size are added together, the result takes at most 1 more bit to store. That property can be taken advantage of such that the modular reduction in the point addition and doubling formulas can mostly be ignored when adding two primefield elements together.

This will end up getting corrected by itself the next time those elements are multiplied together, and it brings some quite nice performance improvements.

In the order of 70% faster point addition / point-scalar multiplication for P-521, and slightly smaller improvements for the other weierstrass curves.

I also took the time to do the same for the other curves, but their new behaviour haven't been tested, as such feel free to let me know if you want me to revert those specific changes.

PS : here is a criterion report highlighting the performance gains on my system
criterion.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant