curve: Use constant-time compressed equality testing (#669)

This commit is contained in:
Aaron Feickert 2025-07-07 16:01:55 -05:00 committed by GitHub
parent 445fd7d59d
commit d54b196d18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -218,9 +218,17 @@ use crate::traits::{MultiscalarMul, VartimeMultiscalarMul, VartimePrecomputedMul
/// ///
/// The Ristretto encoding is canonical, so two points are equal if and /// The Ristretto encoding is canonical, so two points are equal if and
/// only if their encodings are equal. /// only if their encodings are equal.
#[derive(Copy, Clone, Eq, PartialEq, Hash)] #[allow(clippy::derived_hash_with_manual_eq)]
#[derive(Copy, Clone, Hash)]
pub struct CompressedRistretto(pub [u8; 32]); pub struct CompressedRistretto(pub [u8; 32]);
impl Eq for CompressedRistretto {}
impl PartialEq for CompressedRistretto {
fn eq(&self, other: &Self) -> bool {
self.ct_eq(other).into()
}
}
impl ConstantTimeEq for CompressedRistretto { impl ConstantTimeEq for CompressedRistretto {
fn ct_eq(&self, other: &CompressedRistretto) -> Choice { fn ct_eq(&self, other: &CompressedRistretto) -> Choice {
self.as_bytes().ct_eq(other.as_bytes()) self.as_bytes().ct_eq(other.as_bytes())