Skip to content

Commit 07c098f

Browse files
committed
Use constant-time compressed equality testing
1 parent 485ffab commit 07c098f

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
@@ -215,9 +215,17 @@ use crate::traits::{MultiscalarMul, VartimeMultiscalarMul, VartimePrecomputedMul
215215
///
216216
/// The Ristretto encoding is canonical, so two points are equal if and
217217
/// only if their encodings are equal.
218-
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
218+
#[allow(clippy::derived_hash_with_manual_eq)]
219+
#[derive(Copy, Clone, Hash)]
219220
pub struct CompressedRistretto(pub [u8; 32]);
220221

222+
impl Eq for CompressedRistretto {}
223+
impl PartialEq for CompressedRistretto {
224+
fn eq(&self, other: &Self) -> bool {
225+
self.ct_eq(other).into()
226+
}
227+
}
228+
221229
impl ConstantTimeEq for CompressedRistretto {
222230
fn ct_eq(&self, other: &CompressedRistretto) -> Choice {
223231
self.as_bytes().ct_eq(other.as_bytes())

0 commit comments

Comments
 (0)