Remove Engine associated type from CurveAffine and CurveProjective

The type Curve*::Engine::Fr is equivalent to Curve*::Scalar, making
Engine a redundant associated type.
This commit is contained in:
Jack Grigg 2020-05-06 18:49:03 +12:00
parent 8db20b4466
commit e75b850fe5
3 changed files with 10 additions and 9 deletions

View File

@ -216,7 +216,7 @@ impl<G: CurveProjective> Clone for Point<G> {
}
}
impl<G: CurveProjective> Group<G::Engine> for Point<G> {
impl<G: CurveProjective, E: ScalarEngine<Fr = G::Scalar>> Group<E> for Point<G> {
fn group_zero() -> Self {
Point(G::identity())
}

View File

@ -356,7 +356,6 @@ impl CurveProjective for Fr {
type Affine = Fr;
type Base = Fr;
type Scalar = Fr;
type Engine = DummyEngine;
fn random<R: RngCore + ?Sized>(rng: &mut R) -> Self {
<Fr as Field>::random(rng)
@ -448,7 +447,6 @@ impl CurveAffine for Fr {
type Projective = Fr;
type Base = Fr;
type Scalar = Fr;
type Engine = DummyEngine;
fn identity() -> Self {
<Fr as Field>::zero()

View File

@ -1,6 +1,6 @@
use super::multicore::Worker;
use bit_vec::{self, BitVec};
use ff::{Endianness, Field, PrimeField, ScalarEngine};
use ff::{Endianness, Field, PrimeField};
use futures::Future;
use group::{CurveAffine, CurveProjective};
use std::io;
@ -154,7 +154,7 @@ fn multiexp_inner<Q, D, G, S>(
pool: &Worker,
bases: S,
density_map: D,
exponents: Arc<Vec<<G::Engine as ScalarEngine>::Fr>>,
exponents: Arc<Vec<G::Scalar>>,
mut skip: u32,
c: u32,
handle_trivial: bool,
@ -181,7 +181,7 @@ where
// Create space for the buckets
let mut buckets = vec![G::identity(); (1 << c) - 1];
let one = <G::Engine as ScalarEngine>::Fr::one();
let one = G::Scalar::one();
// Sort the bases into buckets
for (&exp, density) in exponents.iter().zip(density_map.as_ref().iter()) {
@ -196,7 +196,7 @@ where
}
} else {
let mut exp = exp.to_repr();
<<G::Engine as ScalarEngine>::Fr as PrimeField>::ReprEndianness::toggle_little_endian(&mut exp);
<G::Scalar as PrimeField>::ReprEndianness::toggle_little_endian(&mut exp);
let exp = exp
.as_ref()
@ -234,7 +234,7 @@ where
skip += c;
if skip >= <G::Engine as ScalarEngine>::Fr::NUM_BITS {
if skip >= G::Scalar::NUM_BITS {
// There isn't another region.
Box::new(this)
} else {
@ -269,7 +269,7 @@ pub fn multiexp<Q, D, G, S>(
pool: &Worker,
bases: S,
density_map: D,
exponents: Arc<Vec<<G::Engine as ScalarEngine>::Fr>>,
exponents: Arc<Vec<G::Scalar>>,
) -> Box<dyn Future<Item = G, Error = SynthesisError>>
where
for<'a> &'a Q: QueryDensity,
@ -293,6 +293,9 @@ where
multiexp_inner(pool, bases, density_map, exponents, 0, c, true)
}
#[cfg(all(test, feature = "pairing"))]
use ff::ScalarEngine;
#[cfg(feature = "pairing")]
#[test]
fn test_with_bls12() {