-
Notifications
You must be signed in to change notification settings - Fork 257
k256+p256: impl ff::Field trait for FieldElement types
#498
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
Conversation
Allows for writing code which is generic over field elements, such as the optimized SWU implementation added in RustCrypto/traits#854
ff::Field trait for FieldElementff::Field trait for FieldElement types
|
One thing I'm a bit worried about in regard to generic field arithmetic is lazy normalization used by |
| @@ -1,5 +1,7 @@ | |||
| //! Field arithmetic modulo p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1 | |||
| #![allow(clippy::assign_op_pattern, clippy::op_ref)] | |||
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.
Left all of the current arithmetic borrowing as-is in order to not affect performance as part of this PR, but it's probably worth benchmarking removing these in a followup and seeing if it affects performance
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.
Yeah I can fix in a follow up PR. I did this crypto-bigint
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.
It's really easy to fix automatically with cargo clippy --fix, but I just want to make sure it doesn't cause a performance regression
| @@ -1,5 +1,7 @@ | |||
| //! Affine points | |||
| #![allow(clippy::op_ref)] | |||
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.
Could probably fix this in a subsequent PR
How much performance do we loose if normalization is applied with each call? We could add a benchmark for it |
I think it could potentially be a lot for the |
Hmm well not sure how to avoid the leaky then |
|
Given that Going to go ahead and merge this, but I'd love to get some additional feedback if anyone has anything to add in perpetuity. |
Allows for writing code which is generic over field elements, such as the optimized SWU implementation added in RustCrypto/traits#854