-
Notifications
You must be signed in to change notification settings - Fork 150
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
Change elliptic curve new point function #970
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #970 +/- ##
==========================================
+ Coverage 71.49% 71.67% +0.17%
==========================================
Files 156 156
Lines 33969 34271 +302
==========================================
+ Hits 24287 24564 +277
- Misses 9682 9707 +25 ☔ View full report in Codecov by Sentry. |
@@ -15,4 +17,16 @@ pub trait IsEdwards: IsEllipticCurve + Clone + Debug { | |||
- FieldElement::<Self::BaseField>::one() | |||
- Self::d() * x.pow(2_u16) * y.pow(2_u16) | |||
} | |||
|
|||
// Edwards equation in projective coordinates. | |||
// a * x^2 * z^2 + y^2 * z^2 - z^4 = d * x^2 * y^2 |
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.
This could be more efficient just by factoring out z^2. We can update that in future PR
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.
Overall it looks correct, however:
- Did we check that the use of
.unwrap_unchecked()
actually provides any advantage over regular.unwrap()
? - I would suggest, regardless of which kind of
unwrap
we use, that we do something like the following:
let val = Curve::new(...);
debug_assert!(val.is_some());
val.unwrap()
That way we can make sure the condition holds in debug builds, without introducing any checking overhead in release builds.
Change elliptic curve new point function
Description
This PR changes the function
new
for every elliptic curve in Lambdaworks. In the previous version, this function creates a new curve point but doesn't check if it satisfies the curve equation. In this PR the function checks if the point is valid returning aResult
.