Skip to content

Commit f709468

Browse files
committed
Use constant-time compressed equality testing
1 parent 43a16f0 commit f709468

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

curve25519-dalek/src/edwards.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ use crate::traits::{VartimeMultiscalarMul, VartimePrecomputedMultiscalarMul};
161161
///
162162
/// The first 255 bits of a `CompressedEdwardsY` represent the
163163
/// \\(y\\)-coordinate. The high bit of the 32nd byte gives the sign of \\(x\\).
164-
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
164+
#[allow(clippy::derived_hash_with_manual_eq)]
165+
#[derive(Copy, Clone, Hash)]
165166
pub struct CompressedEdwardsY(pub [u8; 32]);
166167

167168
impl ConstantTimeEq for CompressedEdwardsY {
@@ -170,6 +171,13 @@ impl ConstantTimeEq for CompressedEdwardsY {
170171
}
171172
}
172173

174+
impl Eq for CompressedEdwardsY {}
175+
impl PartialEq for CompressedEdwardsY {
176+
fn eq(&self, other: &Self) -> bool {
177+
self.ct_eq(other).into()
178+
}
179+
}
180+
173181
impl Debug for CompressedEdwardsY {
174182
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
175183
write!(f, "CompressedEdwardsY: {:?}", self.as_bytes())

0 commit comments

Comments
 (0)