Skip to content
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

Add simple curve cycle trait for curve cycles #190

Merged
merged 13 commits into from
Feb 4, 2021
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The main features of this release are:
- Small speedups to MSMs
- Big speedups to radix-2 FFTs
- Fix in the assembly arithmetic backend
- Adding new traits for basic curve cycles and pairing based curve cycles

### Breaking changes
- #20 (ark-poly) Move univariate DensePolynomial and SparsePolynomial into a
Expand Down Expand Up @@ -80,6 +81,7 @@ The main features of this release are:
- #169 (ark-poly) Improve radix-2 FFTs by moving to a faster algorithm by Riad S. Wahby.
- #171, #173, #176 (ark-poly) Apply significant further speedups to the new radix-2 FFT.
- #188 (ark-ec) Make Short Weierstrass random sampling result in an element with unknown discrete log
- #190 (ark-ec) Add curve cycle trait and extended pairing cycle trait for all types of ec cycles.

### Bug fixes
- #36 (ark-ec) In Short-Weierstrass curves, include an infinity bit in `ToConstraintField`.
Expand Down
29 changes: 29 additions & 0 deletions ec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ pub fn prepare_g2<E: PairingEngine>(g: impl Into<E::G2Affine>) -> E::G2Prepared
}

/// A cycle of pairing-friendly elliptic curves.
#[deprecated(note = "Please use `PairingFriendlyCycle` instead")]
pub trait CycleEngine: Sized + 'static + Copy + Debug + Sync + Send
where
<Self::E2 as PairingEngine>::G1Projective: MulAssign<<Self::E1 as PairingEngine>::Fq>,
Expand All @@ -324,3 +325,31 @@ where
Fq = <Self::E1 as PairingEngine>::Fr,
>;
}

pub trait CurveCycle
where
<Self::E1 as AffineCurve>::Projective: MulAssign<<Self::E2 as AffineCurve>::BaseField>,
<Self::E2 as AffineCurve>::Projective: MulAssign<<Self::E1 as AffineCurve>::BaseField>,
{
type E1: AffineCurve<
BaseField = <Self::E2 as AffineCurve>::ScalarField,
ScalarField = <Self::E2 as AffineCurve>::BaseField,
>;
type E2: AffineCurve;
}

pub trait PairingFriendlyCycle: CurveCycle {
type Engine1: PairingEngine<
G1Affine = Self::E1,
G1Projective = <Self::E1 as AffineCurve>::Projective,
Fq = <Self::E1 as AffineCurve>::BaseField,
Fr = <Self::E1 as AffineCurve>::ScalarField,
>;

type Engine2: PairingEngine<
G2Affine = Self::E2,
G2Projective = <Self::E2 as AffineCurve>::Projective,
Fq = <Self::E2 as AffineCurve>::BaseField,
Fr = <Self::E2 as AffineCurve>::ScalarField,
>;
}