From dcd32183b4ad7ae9ead971ccc4e291f9dd194247 Mon Sep 17 00:00:00 2001 From: Aaron Feickert <66188213+AaronFeickert@users.noreply.github.com> Date: Fri, 5 Jul 2024 13:56:29 -0500 Subject: [PATCH 1/2] Use constant-time compressed equality testing --- curve25519-dalek/src/ristretto.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/curve25519-dalek/src/ristretto.rs b/curve25519-dalek/src/ristretto.rs index 1320bbe4..c6872bd0 100644 --- a/curve25519-dalek/src/ristretto.rs +++ b/curve25519-dalek/src/ristretto.rs @@ -215,9 +215,16 @@ use crate::traits::{MultiscalarMul, VartimeMultiscalarMul, VartimePrecomputedMul /// /// The Ristretto encoding is canonical, so two points are equal if and /// only if their encodings are equal. -#[derive(Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Hash)] 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 { fn ct_eq(&self, other: &CompressedRistretto) -> Choice { self.as_bytes().ct_eq(other.as_bytes()) From f36fd77b9e8818b6b053344dbb7e7320b2c94174 Mon Sep 17 00:00:00 2001 From: Aaron Feickert <66188213+AaronFeickert@users.noreply.github.com> Date: Mon, 8 Jul 2024 12:00:05 -0500 Subject: [PATCH 2/2] Lint --- curve25519-dalek/src/ristretto.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/curve25519-dalek/src/ristretto.rs b/curve25519-dalek/src/ristretto.rs index c6872bd0..c04fb468 100644 --- a/curve25519-dalek/src/ristretto.rs +++ b/curve25519-dalek/src/ristretto.rs @@ -215,6 +215,7 @@ use crate::traits::{MultiscalarMul, VartimeMultiscalarMul, VartimePrecomputedMul /// /// The Ristretto encoding is canonical, so two points are equal if and /// only if their encodings are equal. +#[allow(clippy::derived_hash_with_manual_eq)] #[derive(Copy, Clone, Hash)] pub struct CompressedRistretto(pub [u8; 32]);