From d548318d3d6e5ee65dd5227e225fcdd6b9e1879b Mon Sep 17 00:00:00 2001 From: Aaron Feickert <66188213+AaronFeickert@users.noreply.github.com> Date: Fri, 2 Aug 2024 17:47:53 -0500 Subject: [PATCH] Use constant-time compressed equality testing --- curve25519-dalek/src/edwards.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/curve25519-dalek/src/edwards.rs b/curve25519-dalek/src/edwards.rs index 53ad4fef..9c99ba1b 100644 --- a/curve25519-dalek/src/edwards.rs +++ b/curve25519-dalek/src/edwards.rs @@ -161,7 +161,8 @@ use crate::traits::{VartimeMultiscalarMul, VartimePrecomputedMultiscalarMul}; /// /// The first 255 bits of a `CompressedEdwardsY` represent the /// \\(y\\)-coordinate. The high bit of the 32nd byte gives the sign of \\(x\\). -#[derive(Copy, Clone, Eq, PartialEq, Hash)] +#[allow(clippy::derived_hash_with_manual_eq)] +#[derive(Copy, Clone, Hash)] pub struct CompressedEdwardsY(pub [u8; 32]); impl ConstantTimeEq for CompressedEdwardsY { @@ -170,6 +171,13 @@ impl ConstantTimeEq for CompressedEdwardsY { } } +impl Eq for CompressedEdwardsY {} +impl PartialEq for CompressedEdwardsY { + fn eq(&self, other: &Self) -> bool { + self.ct_eq(other).into() + } +} + impl Debug for CompressedEdwardsY { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "CompressedEdwardsY: {:?}", self.as_bytes())