Skip to content

Conversation

AaronFeickert
Copy link
Contributor

@AaronFeickert AaronFeickert commented Jul 5, 2024

It's a (fairly?) common design pattern to have certain types use ConstantTimeEq to implement Eq (via PartialEq) for improved safety. For example, curve2519-dalek does this for its Scalar and RistrettoPoint types by coercing the resulting Choice into a bool.

It would be useful to be able to signal to implementers if a type does this. Otherwise, for some applications the only way to guarantee that a type supporting ConstantTimeEq uses it for all equality testing is to check this yourself, and it makes it tricky if you want to do this to build more complex traits.

This PR adds a new EqIsConstantTimeEq marker trait. The intent is to have types that follow this design pattern use it as a signal to implementers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant