diff --git a/Cargo.toml b/Cargo.toml index 7add469..ba5218a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,3 +72,6 @@ sqrt-table = ["alloc", "lazy_static"] repr-c = [] uninline-portable = [] serde = ["hex", "serde_crate"] + +[patch.crates-io] +group = { git = "https://github.com/zkcrypto/group.git", rev = "696c2128529b5a9e18eed46d1da531753695db04" } diff --git a/benches/point.rs b/benches/point.rs index aa10e5c..f0509a1 100644 --- a/benches/point.rs +++ b/benches/point.rs @@ -33,7 +33,7 @@ fn point_bench(c: &mut Criterion, name: &str) { for &n in [100, 1000, 10000].iter() { let input = vec![a; n]; - let mut output = vec![C::AffineRepr::default(); n]; + let mut output = vec![C::Affine::default(); n]; group.bench_function(format!("point batch_normalize/{}", n), |bencher| { bencher.iter(|| C::batch_normalize(input.as_slice(), output.as_mut_slice())); }); diff --git a/src/arithmetic/curves.rs b/src/arithmetic/curves.rs index 636f080..08f8e68 100644 --- a/src/arithmetic/curves.rs +++ b/src/arithmetic/curves.rs @@ -24,7 +24,7 @@ pub trait CurveExt: + Default + ConditionallySelectable + ConstantTimeEq - + From<::Affine> + + From { /// The scalar field of this elliptic curve. type ScalarExt: ff::WithSmallOrderMulGroup<3>; @@ -88,15 +88,13 @@ pub trait CurveExt: #[cfg(feature = "alloc")] #[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] pub trait CurveAffine: - PrimeCurveAffine< - Scalar = ::ScalarExt, - Curve = ::CurveExt, - > + Default - + Add::Curve> - + Sub::Curve> + PrimeCurveAffine + + Default + + Add + + Sub + ConditionallySelectable + ConstantTimeEq - + From<::Curve> + + From { /// The scalar field of this elliptic curve. type ScalarExt: ff::WithSmallOrderMulGroup<3> + Ord; diff --git a/src/curves.rs b/src/curves.rs index 41ccb9a..7016b8e 100644 --- a/src/curves.rs +++ b/src/curves.rs @@ -12,8 +12,8 @@ use alloc::boxed::Box; use ff::{Field, PrimeField}; use group::{ cofactor::{CofactorCurve, CofactorGroup}, - prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup}, - Curve as _, Group as _, GroupEncoding, + prime::{PrimeCurve, PrimeGroup}, + Curve as _, CurveAffine as _, Group as _, GroupEncoding, }; use rand::RngCore; use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}; @@ -168,9 +168,9 @@ macro_rules! new_curve_impl { } impl group::Curve for $name { - type AffineRepr = $name_affine; + type Affine = $name_affine; - fn batch_normalize(p: &[Self], q: &mut [Self::AffineRepr]) { + fn batch_normalize(p: &[Self], q: &mut [Self::Affine]) { assert_eq!(p.len(), q.len()); let mut acc = $base::one(); @@ -207,7 +207,7 @@ macro_rules! new_curve_impl { } } - fn to_affine(&self) -> Self::AffineRepr { + fn to_affine(&self) -> Self::Affine { let zinv = self.z.invert().unwrap_or($base::zero()); let zinv2 = zinv.square(); let x = self.x * zinv2; @@ -244,13 +244,9 @@ macro_rules! new_curve_impl { } } - impl PrimeCurve for $name { - type Affine = $name_affine; - } + impl PrimeCurve for $name {} - impl CofactorCurve for $name { - type Affine = $name_affine; - } + impl CofactorCurve for $name {} impl GroupEncoding for $name { type Repr = [u8; 32]; @@ -610,7 +606,7 @@ macro_rules! new_curve_impl { } } - impl PrimeCurveAffine for $name_affine { + impl group::CurveAffine for $name_affine { type Curve = $name; type Scalar = $scalar; @@ -636,27 +632,6 @@ macro_rules! new_curve_impl { } } - impl group::cofactor::CofactorCurveAffine for $name_affine { - type Curve = $name; - type Scalar = $scalar; - - fn identity() -> Self { - ::identity() - } - - fn generator() -> Self { - ::generator() - } - - fn is_identity(&self) -> Choice { - ::is_identity(self) - } - - fn to_curve(&self) -> Self::Curve { - ::to_curve(self) - } - } - impl GroupEncoding for $name_affine { type Repr = [u8; 32]; diff --git a/src/serde_impl.rs b/src/serde_impl.rs index c26201b..8974535 100644 --- a/src/serde_impl.rs +++ b/src/serde_impl.rs @@ -137,7 +137,7 @@ mod tests { use core::fmt::Debug; use ff::Field; - use group::{prime::PrimeCurveAffine, Curve, Group}; + use group::{Curve, CurveAffine, Group}; use rand::SeedableRng; use rand_xorshift::XorShiftRng;