Skip to content

Commit ae58a77

Browse files
authored
Implement PartialEq + Eq for NonIdentity and NonZeroScalar (#1834)
This is done by the fact that the underlying types implement these traits already.
1 parent 73ffc40 commit ae58a77

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

elliptic-curve/src/point/non_identity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{CurveArithmetic, NonZeroScalar, Scalar};
1818
///
1919
/// In the context of ECC, it's useful for ensuring that certain arithmetic
2020
/// cannot result in the identity point.
21-
#[derive(Clone, Copy, Debug)]
21+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2222
pub struct NonIdentity<P> {
2323
point: P,
2424
}

elliptic-curve/src/scalar/nonzero.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ where
128128
}
129129
}
130130

131+
impl<C> Eq for NonZeroScalar<C> where C: CurveArithmetic {}
132+
131133
impl<C> From<NonZeroScalar<C>> for FieldBytes<C>
132134
where
133135
C: CurveArithmetic,
@@ -256,6 +258,15 @@ where
256258
}
257259
}
258260

261+
impl<C> PartialEq for NonZeroScalar<C>
262+
where
263+
C: CurveArithmetic,
264+
{
265+
fn eq(&self, other: &Self) -> bool {
266+
self.scalar.eq(&other.scalar)
267+
}
268+
}
269+
259270
/// Note: this is a non-zero reduction, as it's impl'd for [`NonZeroScalar`].
260271
impl<C, I> Reduce<I> for NonZeroScalar<C>
261272
where

0 commit comments

Comments
 (0)