diff --git a/src/arithmetic/curves.rs b/src/arithmetic/curves.rs index 97a9527..dccf476 100644 --- a/src/arithmetic/curves.rs +++ b/src/arithmetic/curves.rs @@ -2,7 +2,7 @@ //! write code that generalizes over a pair of groups. use core::cmp; -use core::ops::{Add, Sub}; +use core::ops::{Add, Mul, Sub}; use group::prime::{PrimeCurve, PrimeCurveAffine}; use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}; @@ -14,7 +14,7 @@ use std::io::{self, Read, Write}; /// curve group in a "projective" form, where that arithmetic is usually more /// efficient. pub trait CurveExt: - PrimeCurve + PrimeCurve::AffineExt> + group::Group::ScalarExt> + Default + PartialEq @@ -28,6 +28,10 @@ pub trait CurveExt: type ScalarExt: FieldExt; /// The base field over which this elliptic curve is constructed. type Base: FieldExt; + /// The affine version of the curve + type AffineExt: CurveAffine::ScalarExt> + + Mul + + for<'r> Mul; /// Apply the curve endomorphism by multiplying the x-coordinate /// by an element of multiplicative order 3. @@ -75,8 +79,10 @@ pub trait CurveExt: /// This trait is the affine counterpart to `Curve` and is used for /// serialization, storage in memory, and inspection of $x$ and $y$ coordinates. pub trait CurveAffine: - PrimeCurveAffine::ScalarExt> - + Default + PrimeCurveAffine< + Scalar = ::ScalarExt, + Curve = ::CurveExt, + > + Default + Add::Curve> + Sub::Curve> + ConditionallySelectable @@ -87,6 +93,8 @@ pub trait CurveAffine: type ScalarExt: FieldExt; /// The base field over which this elliptic curve is constructed. type Base: FieldExt; + /// The projective form of the curve + type CurveExt: CurveExt::ScalarExt>; /// Personalization of BLAKE2b hasher used to generate the uniform /// random string. diff --git a/src/pasta/curves.rs b/src/pasta/curves.rs index 552944e..e789222 100644 --- a/src/pasta/curves.rs +++ b/src/pasta/curves.rs @@ -90,6 +90,7 @@ macro_rules! new_curve_impl { impl CurveExt for $name { type ScalarExt = $scalar; type Base = $base; + type AffineExt = $name_affine; impl_projective_curve_ext!($name, $name_affine, $iso, $base, $curve_type); @@ -612,6 +613,7 @@ macro_rules! new_curve_impl { impl CurveAffine for $name_affine { type ScalarExt = $scalar; type Base = $base; + type CurveExt = $name; const BLAKE2B_PERSONALIZATION: &'static [u8; 16] = $blake2b_personalization; const CURVE_ID: &'static str = $curve_id;