From b1f48e71a8969390f5ead54aaf7569180d0e8120 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Fri, 25 Apr 2025 00:23:14 +0200 Subject: [PATCH] Implement `Eq` for `NonIdentity` & `NonZeroScalar` --- elliptic-curve/src/point/non_identity.rs | 2 +- elliptic-curve/src/scalar/nonzero.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/elliptic-curve/src/point/non_identity.rs b/elliptic-curve/src/point/non_identity.rs index 3068afaa0..c985ba7fd 100644 --- a/elliptic-curve/src/point/non_identity.rs +++ b/elliptic-curve/src/point/non_identity.rs @@ -18,7 +18,7 @@ use crate::{CurveArithmetic, NonZeroScalar, Scalar}; /// /// In the context of ECC, it's useful for ensuring that certain arithmetic /// cannot result in the identity point. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct NonIdentity

{ point: P, } diff --git a/elliptic-curve/src/scalar/nonzero.rs b/elliptic-curve/src/scalar/nonzero.rs index 4d2e4c51e..550ef1833 100644 --- a/elliptic-curve/src/scalar/nonzero.rs +++ b/elliptic-curve/src/scalar/nonzero.rs @@ -128,6 +128,8 @@ where } } +impl Eq for NonZeroScalar where C: CurveArithmetic {} + impl From> for FieldBytes where C: CurveArithmetic, @@ -256,6 +258,15 @@ where } } +impl PartialEq for NonZeroScalar +where + C: CurveArithmetic, +{ + fn eq(&self, other: &Self) -> bool { + self.scalar.eq(&other.scalar) + } +} + /// Note: this is a non-zero reduction, as it's impl'd for [`NonZeroScalar`]. impl Reduce for NonZeroScalar where