-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Affine coordinate are not correctly exposed from the underlying type. #116
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you want to add a z() method too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's necessary. The type is AffinePoint, I don't see why it should have a |
||
// Returns the generator point of the StarkCurve | ||
|
@@ -70,7 +70,7 @@ impl core::ops::Add<AffinePoint> 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(&rhs.0)) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is the to_affine method you are calling
From my understanding it can return values that are different form the one x() and y() are currently returning.
So this is a breaking change.
But I'm not sure it is a bug fix.
The methods documentation says it returens the coordinate, but it's not specified if it's in projective or affine coordinate.
You seems to think it should be affine, but currently it's projective
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify. The current behavior is to return the value of
x
from projective representation of a point, unchanged. The equivalent value in affine representation for x isx/z
.The current version works because if you create a point from (x,y) coordinate, the
z
value will be 1 and converting back to affine you need to dox/1
which is the samex
, but if you perform some operations with the point and want to get back the affine coordinate, thez
value will not be 1 anymore.This changes should not break anything, the mul/add operations were added by me recently in e0eff28