-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This unifies the methods previously exposed by the `PrimeCurveAffine` and `CofactorCurveAffine` traits. The prime-order and cofactor traits are now all marker traits, and their affine-specific traits are automatically derived.
- Loading branch information
Showing
5 changed files
with
70 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,14 @@ | ||
use core::fmt; | ||
use core::ops::{Mul, Neg}; | ||
use ff::PrimeField; | ||
use subtle::Choice; | ||
|
||
use crate::{Curve, Group, GroupEncoding}; | ||
use crate::{Curve, CurveAffine, Group, GroupEncoding}; | ||
|
||
/// This trait represents an element of a prime-order cryptographic group. | ||
pub trait PrimeGroup: Group + GroupEncoding {} | ||
|
||
/// Efficient representation of an elliptic curve point guaranteed to be | ||
/// in the correct prime order subgroup. | ||
pub trait PrimeCurve: Curve<AffineRepr = <Self as PrimeCurve>::Affine> + PrimeGroup { | ||
type Affine: PrimeCurveAffine<Curve = Self, Scalar = Self::Scalar> | ||
+ Mul<Self::Scalar, Output = Self> | ||
+ for<'r> Mul<&'r Self::Scalar, Output = Self>; | ||
} | ||
pub trait PrimeCurve: Curve + PrimeGroup {} | ||
|
||
/// Affine representation of an elliptic curve point guaranteed to be | ||
/// in the correct prime order subgroup. | ||
pub trait PrimeCurveAffine: GroupEncoding | ||
+ Copy | ||
+ Clone | ||
+ Sized | ||
+ Send | ||
+ Sync | ||
+ fmt::Debug | ||
+ PartialEq | ||
+ Eq | ||
+ 'static | ||
+ Neg<Output = Self> | ||
+ Mul<<Self as PrimeCurveAffine>::Scalar, Output = <Self as PrimeCurveAffine>::Curve> | ||
+ for<'r> Mul<&'r <Self as PrimeCurveAffine>::Scalar, Output = <Self as PrimeCurveAffine>::Curve> | ||
{ | ||
type Scalar: PrimeField; | ||
type Curve: PrimeCurve<Affine = Self, Scalar = Self::Scalar>; | ||
|
||
/// Returns the additive identity. | ||
fn identity() -> Self; | ||
|
||
/// Returns a fixed generator of unknown exponent. | ||
fn generator() -> Self; | ||
|
||
/// Determines if this point represents the point at infinity; the | ||
/// additive identity. | ||
fn is_identity(&self) -> Choice; | ||
pub trait PrimeCurveAffine: CurveAffine {} | ||
|
||
/// Converts this element to its curve representation. | ||
fn to_curve(&self) -> Self::Curve; | ||
} | ||
impl<C: CurveAffine> PrimeCurveAffine for C where C::Curve: PrimeCurve {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters