From 5a40a0fe8f42cfe7e2261bbf93d3a604787c30be Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 21 May 2020 09:55:05 +1200 Subject: [PATCH] group: Remove CurveProjective::Base and CurveAffine::Base These associated types were completly unused. The only place we need information about the base field of an elliptic curve is inside Jubjub when operating over its coordinates to implement EC math inside the circuit, and we can handle that either concretely, or with a future trait specifically for that use-case. --- bellman/src/groth16/tests/dummy_engine.rs | 2 -- group/src/lib.rs | 4 +--- pairing/src/bls12_381/ec.rs | 2 -- pairing/src/lib.rs | 6 ++---- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/bellman/src/groth16/tests/dummy_engine.rs b/bellman/src/groth16/tests/dummy_engine.rs index 5686c95c4..2ec5c4eb0 100644 --- a/bellman/src/groth16/tests/dummy_engine.rs +++ b/bellman/src/groth16/tests/dummy_engine.rs @@ -394,7 +394,6 @@ impl PrimeGroup for Fr {} impl CurveProjective for Fr { type Affine = Fr; - type Base = Fr; fn batch_normalize(p: &[Self], q: &mut [Self::Affine]) { assert_eq!(p.len(), q.len()); @@ -436,7 +435,6 @@ impl CurveAffine for Fr { type Compressed = FakePoint; type Uncompressed = FakePoint; type Projective = Fr; - type Base = Fr; type Scalar = Fr; fn identity() -> Self { diff --git a/group/src/lib.rs b/group/src/lib.rs index b2e83b30d..42fac6630 100644 --- a/group/src/lib.rs +++ b/group/src/lib.rs @@ -1,7 +1,7 @@ // Catch documentation errors caused by code changes. #![deny(intra_doc_link_resolution_failure)] -use ff::{Field, PrimeField}; +use ff::PrimeField; use rand::RngCore; use std::fmt; use std::iter::Sum; @@ -97,7 +97,6 @@ pub trait CurveProjective: + GroupOps<::Affine> + GroupOpsOwned<::Affine> { - type Base: Field; type Affine: CurveAffine + Mul + for<'r> Mul; @@ -136,7 +135,6 @@ pub trait CurveAffine: + for<'r> Mul<::Scalar, Output = ::Projective> { type Scalar: PrimeField; - type Base: Field; type Projective: CurveProjective; type Uncompressed: Default + AsRef<[u8]> + AsMut<[u8]>; type Compressed: Default + AsRef<[u8]> + AsMut<[u8]>; diff --git a/pairing/src/bls12_381/ec.rs b/pairing/src/bls12_381/ec.rs index b14f04f4f..b7369901a 100644 --- a/pairing/src/bls12_381/ec.rs +++ b/pairing/src/bls12_381/ec.rs @@ -200,7 +200,6 @@ macro_rules! curve_impl { impl CurveAffine for $affine { type Scalar = $scalarfield; - type Base = $basefield; type Projective = $projective; type Uncompressed = $uncompressed; type Compressed = $compressed; @@ -748,7 +747,6 @@ macro_rules! curve_impl { impl PrimeGroup for $projective {} impl CurveProjective for $projective { - type Base = $basefield; type Affine = $affine; fn batch_normalize(p: &[Self], q: &mut [$affine]) { diff --git a/pairing/src/lib.rs b/pairing/src/lib.rs index 78394fdd4..63a9662f0 100644 --- a/pairing/src/lib.rs +++ b/pairing/src/lib.rs @@ -30,7 +30,7 @@ use subtle::CtOption; /// of prime order `r`, and are equipped with a bilinear pairing function. pub trait Engine: ScalarEngine { /// The projective representation of an element in G1. - type G1: CurveProjective + type G1: CurveProjective + From + GroupOps + GroupOpsOwned @@ -39,7 +39,6 @@ pub trait Engine: ScalarEngine { /// The affine representation of an element in G1. type G1Affine: PairingCurveAffine< - Base = Self::Fq, Scalar = Self::Fr, Projective = Self::G1, Pair = Self::G2Affine, @@ -49,7 +48,7 @@ pub trait Engine: ScalarEngine { + for<'a> Mul<&'a Self::Fr, Output = Self::G1>; /// The projective representation of an element in G2. - type G2: CurveProjective + type G2: CurveProjective + From + GroupOps + GroupOpsOwned @@ -58,7 +57,6 @@ pub trait Engine: ScalarEngine { /// The affine representation of an element in G2. type G2Affine: PairingCurveAffine< - Base = Self::Fqe, Scalar = Self::Fr, Projective = Self::G2, Pair = Self::G1Affine,