diff --git a/crates/starknet-types-core/src/curve/affine_point.rs b/crates/starknet-types-core/src/curve/affine_point.rs index b5e271b..c82d6e6 100644 --- a/crates/starknet-types-core/src/curve/affine_point.rs +++ b/crates/starknet-types-core/src/curve/affine_point.rs @@ -5,10 +5,9 @@ use lambdaworks_math::cyclic_group::IsGroup; use lambdaworks_math::elliptic_curve::short_weierstrass::curves::stark_curve::StarkCurve; use lambdaworks_math::elliptic_curve::short_weierstrass::point::ShortWeierstrassProjectivePoint; use lambdaworks_math::elliptic_curve::traits::{EllipticCurveError, FromAffine}; -use lambdaworks_math::field::element::FieldElement; -use lambdaworks_math::field::fields::fft_friendly::stark_252_prime_field::Stark252PrimeField; use lambdaworks_math::unsigned_integer::traits::IsUnsignedInteger; +#[derive(Debug, Clone, PartialEq, Eq)] pub struct AffinePoint(pub(crate) ShortWeierstrassProjectivePoint); impl AffinePoint { @@ -23,13 +22,13 @@ impl AffinePoint { } /// Returns the `x` coordinate of the point. - pub fn x(&self) -> &FieldElement { - self.0.x() + pub fn x(&self) -> Felt { + Felt(*self.0.x()) } /// Returns the `y` coordinate of the point. - pub fn y(&self) -> &FieldElement { - self.0.y() + pub fn y(&self) -> Felt { + Felt(*self.0.y()) } } @@ -47,17 +46,17 @@ impl ops::AddAssign<&AffinePoint> for AffinePoint { } } -impl ops::Mul<&Felt> for &AffinePoint { +impl ops::Mul for &AffinePoint { type Output = AffinePoint; - fn mul(self, rhs: &Felt) -> AffinePoint { + fn mul(self, rhs: Felt) -> AffinePoint { AffinePoint(self.0.operate_with_self(rhs.0.representative())) } } impl ops::Mul for &AffinePoint where - T: IsUnsignedInteger, // Asumiendo que "exponent" es una trait + T: IsUnsignedInteger, { type Output = AffinePoint; diff --git a/crates/starknet-types-core/src/curve/projective_point.rs b/crates/starknet-types-core/src/curve/projective_point.rs index 916eaa1..bdfdd6b 100644 --- a/crates/starknet-types-core/src/curve/projective_point.rs +++ b/crates/starknet-types-core/src/curve/projective_point.rs @@ -4,8 +4,6 @@ use lambdaworks_math::cyclic_group::IsGroup; use lambdaworks_math::elliptic_curve::short_weierstrass::curves::stark_curve::StarkCurve; use lambdaworks_math::elliptic_curve::short_weierstrass::point::ShortWeierstrassProjectivePoint; use lambdaworks_math::elliptic_curve::traits::{EllipticCurveError, FromAffine}; -use lambdaworks_math::field::element::FieldElement; -use lambdaworks_math::field::fields::fft_friendly::stark_252_prime_field::Stark252PrimeField; use lambdaworks_math::unsigned_integer::traits::IsUnsignedInteger; use crate::curve::affine_point::AffinePoint; @@ -32,18 +30,18 @@ impl ProjectivePoint { } /// Returns the `x` coordinate of the point. - pub fn x(&self) -> &FieldElement { - self.0.x() + pub fn x(&self) -> Felt { + Felt(*self.0.x()) } /// Returns the `y` coordinate of the point. - pub fn y(&self) -> &FieldElement { - self.0.y() + pub fn y(&self) -> Felt { + Felt(*self.0.y()) } /// Returns the `z` coordinate of the point. - pub fn z(&self) -> &FieldElement { - self.0.z() + pub fn z(&self) -> Felt { + Felt(*self.0.z()) } } @@ -61,10 +59,10 @@ impl ops::AddAssign<&ProjectivePoint> for ProjectivePoint { } } -impl ops::Mul<&Felt> for &ProjectivePoint { +impl ops::Mul for &ProjectivePoint { type Output = ProjectivePoint; - fn mul(self, rhs: &Felt) -> ProjectivePoint { + fn mul(self, rhs: Felt) -> ProjectivePoint { ProjectivePoint(self.0.operate_with_self(rhs.0.representative())) } }