From 4f3a2b3f78d70a8c3d9b37e90ee8d0b80c1dc9f6 Mon Sep 17 00:00:00 2001 From: Filip Laurentiu Date: Wed, 29 Jan 2025 12:02:32 +0200 Subject: [PATCH] Affine coordinate are not correctly exposed from the underlying type. ProjectivePoints have 3 coordinates (x,y,z) and the AffinePoint incorrectly expose just the (x, y) coordinate without converting the representation from projective to affine. --- crates/starknet-types-core/src/curve/affine_point.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/starknet-types-core/src/curve/affine_point.rs b/crates/starknet-types-core/src/curve/affine_point.rs index 76a73b9..04f515a 100644 --- a/crates/starknet-types-core/src/curve/affine_point.rs +++ b/crates/starknet-types-core/src/curve/affine_point.rs @@ -44,12 +44,12 @@ impl AffinePoint { /// Returns the `x` coordinate of the point. pub fn x(&self) -> Felt { - Felt(*self.0.x()) + Felt(*self.0.to_affine().x()) } /// Returns the `y` coordinate of the point. pub fn y(&self) -> Felt { - Felt(*self.0.y()) + Felt(*self.0.to_affine().y()) } // Returns the generator point of the StarkCurve @@ -70,7 +70,7 @@ impl core::ops::Add for AffinePoint { type Output = AffinePoint; fn add(self, rhs: Self) -> Self::Output { - AffinePoint(self.0.operate_with_affine(&rhs.0)) + AffinePoint(self.0.operate_with_affine(&rhs.0.to_affine())) } }