-
Notifications
You must be signed in to change notification settings - Fork 46
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
feature: eliptic curves #589
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for contracts-stylus ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
…elin-crypto/eliptic-curves
…liptic-curves # Conflicts: # fuzz/Cargo.lock
ad18d44
to
112946f
Compare
merge simple test cases (coverage) |
fix clippy lints |
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.
First pass.
|
||
#[inline] | ||
fn add(self, other: Self) -> Self { | ||
let mut result = self; |
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.
Why can't you use just self + &other
?
/// Elliptic curves can be represented via different "models" with varying | ||
/// efficiency properties. | ||
/// | ||
/// `CurveConfig` bundles together the types that are common |
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.
/// `CurveConfig` bundles together the types that are common | |
/// [`CurveConfig`] bundles together the types that are common |
/// efficiency properties. | ||
/// | ||
/// `CurveConfig` bundles together the types that are common | ||
/// to all models of the given curve, namely the `BaseField` over which the |
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 all models of the given curve, namely the `BaseField` over which the | |
/// to all models of the given curve, namely the [`BaseField`] over which the |
/// | ||
/// `CurveConfig` bundles together the types that are common | ||
/// to all models of the given curve, namely the `BaseField` over which the | ||
/// curve is defined, and the `ScalarField` defined by the appropriate |
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.
/// curve is defined, and the `ScalarField` defined by the appropriate | |
/// curve is defined, and the [`ScalarField`] defined by the appropriate |
|
||
/// Returns `true` if the cofactor is one. | ||
fn cofactor_is_one() -> bool { | ||
Self::COFACTOR[0] == 1 |
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.
Whag if Self::COFACTOR
is an empty slice?
} | ||
|
||
// Invert `tmp`. | ||
tmp = tmp.inverse().unwrap(); // Guaranteed to be nonzero. |
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.
Use expect
} | ||
|
||
impl<P: SWCurveConfig> Affine<P> { | ||
/// Constructs a group element from x and y coordinates. |
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.
/// Constructs a group element from x and y coordinates. | |
/// Constructs a group element from `x` and `y` coordinates. |
point | ||
} | ||
|
||
/// Constructs a group element from x and y coordinates. |
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.
/// Constructs a group element from x and y coordinates. | |
/// Constructs a group element from `x` and `y`coordinates. |
|
||
/// Checks if `self` is a valid point on the curve. | ||
pub fn is_on_curve(&self) -> bool { | ||
if !self.infinity { |
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.
Clippy warning that makes sense.
impl<P: SWCurveConfig> Eq for Projective<P> {} | ||
impl<P: SWCurveConfig> PartialEq for Projective<P> { | ||
fn eq(&self, other: &Self) -> bool { | ||
if self.is_zero() { |
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.
Looks like XOR operation.
Resolves #343
PR Checklist