From 0a1bd0718163143b47c9c21ac91800321007f47a Mon Sep 17 00:00:00 2001 From: Pedro Fontana Date: Wed, 18 Oct 2023 18:22:19 -0300 Subject: [PATCH] Implement ops::Add<&ProjectivePoint> for &ProjectivePoint --- crates/stark-curve/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/stark-curve/src/lib.rs b/crates/stark-curve/src/lib.rs index ce4c92e..38346e0 100644 --- a/crates/stark-curve/src/lib.rs +++ b/crates/stark-curve/src/lib.rs @@ -24,12 +24,20 @@ impl ProjectivePoint { projective_point: &ProjectivePoint, ) -> Result { Ok(AffinePoint(ShortWeierstrassProjectivePoint::from_affine( - projective_point.0.x().clone(), - projective_point.0.y().clone(), + *projective_point.0.x(), + *projective_point.0.y(), )?)) } } +impl ops::Add<&ProjectivePoint> for &ProjectivePoint { + type Output = ProjectivePoint; + + fn add(self, rhs: &ProjectivePoint) -> ProjectivePoint { + ProjectivePoint(self.0.operate_with(&rhs.0)) + } +} + impl ops::AddAssign<&ProjectivePoint> for ProjectivePoint { fn add_assign(&mut self, rhs: &ProjectivePoint) { self.0 = self.0.operate_with(&rhs.0);