k256+p256+p384: impl Invert trait for Scalar types#741
Merged
Conversation
bcda944 to
e698211
Compare
tarcieri
commented
Feb 3, 2023
| /// variable-time operation can potentially leak secrets through | ||
| /// sidechannels. | ||
| #[allow(non_snake_case)] | ||
| fn invert_vartime(&self) -> CtOption<Self> { |
Member
Author
There was a problem hiding this comment.
@fjarri FYI, there's now a dedicated method for variable-time inversions which is used by the generic ECDSA implementation.
This can probably be adapted to work with k256? I had previously tried to make it fully generic, but due to the use of Self(MODULUS) below it's relying on support in the underlying field implementation.
I tried porting it to k256 and it seemed to work, although ECDSA verification performance was only up by ~3%.
The `Invert` trait now provides an `invert_vartime` method which can use a faster implementation than the constant time version. Leveraging this requires an explicit impl of the trait however, whereas before it was provided by a blanket impl for types which impl `ff::Field`. This includes an implementation of Stein's algorithm for `p256::Scalar` originally provided by @nickray.
e698211 to
5a9ebd8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
Inverttrait now provides aninvert_vartimemethod which can use a faster implementation than the constant time version.Leveraging this requires an explicit impl of the trait however, whereas before it was provided by a blanket impl for types which impl
ff::Field.