forked from dalek-cryptography/subtle
-
Notifications
You must be signed in to change notification settings - Fork 6
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 boilerplate implementing comparisons for user-defined types #6
Closed
cosmicexplorer
wants to merge
10
commits into
zkcrypto:main
from
cosmicexplorer:expand-constant-time-cmp
Closed
reduce boilerplate implementing comparisons for user-defined types #6
cosmicexplorer
wants to merge
10
commits into
zkcrypto:main
from
cosmicexplorer:expand-constant-time-cmp
Conversation
This file contains 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
cosmicexplorer
force-pushed
the
expand-constant-time-cmp
branch
2 times, most recently
from
June 30, 2022 07:34
3bb8d59
to
eb31e20
Compare
cosmicexplorer
changed the title
impl
introduce Jul 1, 2022
ConstantTime{Less,Greater}
for slicesIteratedOperation
to apply comparisons lexicographically
cosmicexplorer
commented
Jul 1, 2022
/// impl ConstantTimeGreater for S { | ||
/// fn ct_gt(&self, other: &Self) -> Choice { | ||
/// let mut x = IteratedGreater::initiate(); | ||
/// x.apply_gt(&(self.len as u64), &(other.len as u64)); |
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.
When #7 is merged, this can just be:
Suggested change
/// x.apply_gt(&(self.len as u64), &(other.len as u64)); | |
/// x.apply_gt(&self.len, &other.len); |
cosmicexplorer
changed the title
introduce
introduce tools to enable constant-time comparisons for user-defined aggregate data types
Jul 1, 2022
IteratedOperation
to apply comparisons lexicographically
cosmicexplorer
changed the title
introduce tools to enable constant-time comparisons for user-defined aggregate data types
introduce tools to extend constant-time comparisons to user-defined aggregate data types
Jul 1, 2022
cosmicexplorer
changed the title
introduce tools to extend constant-time comparisons to user-defined aggregate data types
make it easier to extend constant-time comparisons to user-defined aggregate data types
Jul 1, 2022
cosmicexplorer
changed the title
make it easier to extend constant-time comparisons to user-defined aggregate data types
reduce boilerplate implementing comparisons for user-defined aggregate data types
Jul 1, 2022
cosmicexplorer
changed the title
reduce boilerplate implementing comparisons for user-defined aggregate data types
reduce boilerplate implementing comparisons for user-defined types
Jul 1, 2022
cosmicexplorer
force-pushed
the
expand-constant-time-cmp
branch
3 times, most recently
from
July 1, 2022 10:58
138437d
to
c0a3e55
Compare
cosmicexplorer
force-pushed
the
expand-constant-time-cmp
branch
from
July 1, 2022 11:04
c0a3e55
to
8533dce
Compare
This repo is unmaintained, use the original instead: https://github.com/dalek-cryptography/subtle. |
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.
Problem
In signalapp/libsignal#469, we discussed having to hand-roll a constant-time comparison function for a public key with a slice of bytes and an enum tag. After seeing dalek-cryptography#78 where we implement
ConstantTimeEq
for slices, I realized we could extend this method of iterated constant-time computation to make it more fluent to implement comparison operations for structs with multiple fields.Proposed Solution
IteratedOperation
andIteratedEq
to modularize the approach used in the existingConstantTimeEq
impl for slices.ConstantTimeGreater
over a collection of elements asIteratedGreater
.ConstantTimeGreater
for slices usingIteratedGreater
.Convertible
trait which implementsConstantTime{Eq,Greater,Less}
for structs which can be cheaply converted into a constant-time comparable type.Result
ConstantTimeOrd
will be implemented automatically for slices if/when define and implementConstantTime{Partial,}Ord
traits #5 is merged.