Skip to content

Commit

Permalink
Implement ops::Add<&ProjectivePoint> for &ProjectivePoint
Browse files Browse the repository at this point in the history
  • Loading branch information
pefontana committed Oct 18, 2023
1 parent 05945f1 commit 0a1bd07
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/stark-curve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ impl ProjectivePoint {
projective_point: &ProjectivePoint,
) -> Result<AffinePoint, EllipticCurveError> {
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);
Expand Down

0 comments on commit 0a1bd07

Please sign in to comment.