k256+p256: impl ff::Field trait for FieldElement types#498
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.
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.
Yeah I can fix in a follow up PR. I did this crypto-bigint
There was a problem hiding this comment.
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.
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