subtle
subtle copied to clipboard
Add a marker trait for equality testing
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.