Skip to content

Commit 3228f9b

Browse files
committed
Implement Eq for ProjectiveMontgomeryXpoint
1 parent de32cb5 commit 3228f9b

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
@@ -58,7 +58,7 @@ impl PartialEq for MontgomeryXpoint {
5858
impl Eq for MontgomeryXpoint {}
5959

6060
/// A Projective point in Montgomery form
61-
#[derive(Copy, Clone, Debug)]
61+
#[derive(Copy, Clone, Debug, Eq)]
6262
pub struct ProjectiveMontgomeryXpoint {
6363
U: FieldElement,
6464
W: FieldElement,
@@ -136,6 +136,12 @@ impl MontgomeryXpoint {
136136
}
137137
}
138138

139+
impl ConstantTimeEq for ProjectiveMontgomeryXpoint {
140+
fn ct_eq(&self, other: &Self) -> Choice {
141+
self.U.ct_eq(&other.U) & self.W.ct_eq(&other.W)
142+
}
143+
}
144+
139145
impl ConditionallySelectable for ProjectiveMontgomeryXpoint {
140146
fn conditional_select(
141147
a: &ProjectiveMontgomeryXpoint,
@@ -149,6 +155,12 @@ impl ConditionallySelectable for ProjectiveMontgomeryXpoint {
149155
}
150156
}
151157

158+
impl PartialEq for ProjectiveMontgomeryXpoint {
159+
fn eq(&self, other: &Self) -> bool {
160+
self.ct_eq(other).into()
161+
}
162+
}
163+
152164
fn differential_add_and_double(
153165
P: &mut ProjectiveMontgomeryXpoint,
154166
Q: &mut ProjectiveMontgomeryXpoint,

0 commit comments

Comments
 (0)