-
Notifications
You must be signed in to change notification settings - Fork 33
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
Optimize ADDMOD for elliptic curve context #206
Conversation
f0a743f
to
3249565
Compare
Codecov Report
@@ Coverage Diff @@
## master #206 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 9 +1
Lines 1792 1847 +55
=========================================
+ Hits 1792 1847 +55
Flags with carried forward coverage won't be shown. Click here to find out more.
|
44755cf
to
2670a82
Compare
In elliptic curve context the x and y arguments are already reduced modulo mod. Here we can pick up similar condition and provide optimized implementation for such case. This case is 2x faster with little overhead for other cases. Based on holiman/uint256#86.
// Fast path for mod >= 2^192, with x and y at most slightly bigger than mod. | ||
// This is always the case when x and y are already reduced modulo mod. | ||
// Based on https://github.com/holiman/uint256/pull/86. | ||
if ((mod[3] != 0) && (x[3] <= mod[3]) && (y[3] <= mod[3])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this handle the mod[4] != 0
case? i.e. shouldn't it be (mod[4] | mod[3]) != 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no mod[4]
. The mod[3]
is the most significant word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, phew :)
No description provided.