Skip to content

Commit 65a59aa

Browse files
committed
Implement Eq for ProjectiveMontgomeryXpoint
1 parent b7410d1 commit 65a59aa

File tree

1 file changed

+13
-1
lines changed
  • ed448-goldilocks/src/montgomery

1 file changed

+13
-1
lines changed

ed448-goldilocks/src/montgomery/x.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl PartialEq for MontgomeryXpoint {
6262
impl Eq for MontgomeryXpoint {}
6363

6464
/// A Projective point in Montgomery form
65-
#[derive(Copy, Clone, Debug)]
65+
#[derive(Copy, Clone, Debug, Eq)]
6666
pub struct ProjectiveMontgomeryXpoint {
6767
U: FieldElement,
6868
W: FieldElement,
@@ -140,6 +140,12 @@ impl MontgomeryXpoint {
140140
}
141141
}
142142

143+
impl ConstantTimeEq for ProjectiveMontgomeryXpoint {
144+
fn ct_eq(&self, other: &Self) -> Choice {
145+
(self.U * other.W).ct_eq(&(other.U * self.W))
146+
}
147+
}
148+
143149
impl ConditionallySelectable for ProjectiveMontgomeryXpoint {
144150
fn conditional_select(
145151
a: &ProjectiveMontgomeryXpoint,
@@ -153,6 +159,12 @@ impl ConditionallySelectable for ProjectiveMontgomeryXpoint {
153159
}
154160
}
155161

162+
impl PartialEq for ProjectiveMontgomeryXpoint {
163+
fn eq(&self, other: &Self) -> bool {
164+
self.ct_eq(other).into()
165+
}
166+
}
167+
156168
fn differential_add_and_double(
157169
P: &mut ProjectiveMontgomeryXpoint,
158170
Q: &mut ProjectiveMontgomeryXpoint,

0 commit comments

Comments
 (0)