Skip to content

Commit dcd3218

Browse files
committed
Use constant-time compressed equality testing
1 parent 0964f80 commit dcd3218

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

curve25519-dalek/src/ristretto.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,16 @@ 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+
#[derive(Copy, Clone, Hash)]
219219
pub struct CompressedRistretto(pub [u8; 32]);
220220

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

0 commit comments

Comments
 (0)