Skip to content

Commit d54b196

Browse files
curve: Use constant-time compressed equality testing (#669)
1 parent 445fd7d commit d54b196

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

curve25519-dalek/src/ristretto.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,17 @@ use crate::traits::{MultiscalarMul, VartimeMultiscalarMul, VartimePrecomputedMul
218218
///
219219
/// The Ristretto encoding is canonical, so two points are equal if and
220220
/// only if their encodings are equal.
221-
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
221+
#[allow(clippy::derived_hash_with_manual_eq)]
222+
#[derive(Copy, Clone, Hash)]
222223
pub struct CompressedRistretto(pub [u8; 32]);
223224

225+
impl Eq for CompressedRistretto {}
226+
impl PartialEq for CompressedRistretto {
227+
fn eq(&self, other: &Self) -> bool {
228+
self.ct_eq(other).into()
229+
}
230+
}
231+
224232
impl ConstantTimeEq for CompressedRistretto {
225233
fn ct_eq(&self, other: &CompressedRistretto) -> Choice {
226234
self.as_bytes().ct_eq(other.as_bytes())

0 commit comments

Comments
 (0)