group: Renaming prior to trait refactor

This will reduce the size of the subsequent refactor diff.
This commit is contained in:
Jack Grigg 2020-05-29 21:52:39 +12:00
parent 8142ece846
commit a77b2c8623
6 changed files with 25 additions and 25 deletions

View File

@ -12,7 +12,7 @@
//! [Groth16]: https://eprint.iacr.org/2016/260
use ff::PrimeField;
use group::CurveProjective;
use group::CofactorCurve;
use super::SynthesisError;
@ -196,23 +196,23 @@ pub trait Group<Scalar: PrimeField>: Sized + Copy + Clone + Send + Sync {
fn group_sub_assign(&mut self, other: &Self);
}
pub struct Point<G: CurveProjective>(pub G);
pub struct Point<G: CofactorCurve>(pub G);
impl<G: CurveProjective> PartialEq for Point<G> {
impl<G: CofactorCurve> PartialEq for Point<G> {
fn eq(&self, other: &Point<G>) -> bool {
self.0 == other.0
}
}
impl<G: CurveProjective> Copy for Point<G> {}
impl<G: CofactorCurve> Copy for Point<G> {}
impl<G: CurveProjective> Clone for Point<G> {
impl<G: CofactorCurve> Clone for Point<G> {
fn clone(&self) -> Point<G> {
*self
}
}
impl<G: CurveProjective> Group<G::Scalar> for Point<G> {
impl<G: CofactorCurve> Group<G::Scalar> for Point<G> {
fn group_zero() -> Self {
Point(G::identity())
}

View File

@ -3,7 +3,7 @@ use std::ops::{AddAssign, MulAssign};
use std::sync::Arc;
use ff::{Field, PrimeField};
use group::{CurveAffine, CurveProjective, Group, Wnaf};
use group::{CurveAffine, CofactorCurve, Group, Wnaf};
use pairing::Engine;
use super::{Parameters, VerifyingKey};

View File

@ -5,7 +5,7 @@ use std::sync::Arc;
use futures::Future;
use ff::{Field, PrimeField};
use group::{CurveAffine, CurveProjective};
use group::{CurveAffine, CofactorCurve};
use pairing::Engine;
use super::{ParameterSource, Proof};

View File

@ -1,5 +1,5 @@
use ff::{Field, PrimeField};
use group::{CurveAffine, CurveProjective, Group, GroupEncoding, PrimeGroup, UncompressedEncoding};
use group::{CurveAffine, CofactorCurve, Group, GroupEncoding, PrimeGroup, UncompressedEncoding};
use pairing::{Engine, MillerLoopResult, MultiMillerLoop, PairingCurveAffine};
use rand_core::RngCore;
@ -393,7 +393,7 @@ impl Group for Fr {
impl PrimeGroup for Fr {}
impl CurveProjective for Fr {
impl CofactorCurve for Fr {
type Affine = Fr;
fn to_affine(&self) -> Fr {
@ -425,7 +425,7 @@ impl AsRef<[u8]> for FakePoint {
}
impl CurveAffine for Fr {
type Projective = Fr;
type Curve = Fr;
type Scalar = Fr;
fn identity() -> Self {
@ -440,7 +440,7 @@ impl CurveAffine for Fr {
Choice::from(if <Fr as Field>::is_zero(self) { 1 } else { 0 })
}
fn to_projective(&self) -> Self::Projective {
fn to_curve(&self) -> Self::Curve {
*self
}
}

View File

@ -1,4 +1,4 @@
use group::{CurveAffine, CurveProjective};
use group::{CurveAffine, CofactorCurve};
use pairing::{MillerLoopResult, MultiMillerLoop};
use std::ops::{AddAssign, Neg};
@ -27,7 +27,7 @@ pub fn verify_proof<'a, E: MultiMillerLoop>(
return Err(SynthesisError::MalformedVerifyingKey);
}
let mut acc = pvk.ic[0].to_projective();
let mut acc = pvk.ic[0].to_curve();
for (i, b) in public_inputs.iter().zip(pvk.ic.iter().skip(1)) {
AddAssign::<&E::G1>::add_assign(&mut acc, &(*b * i));

View File

@ -2,7 +2,7 @@ use super::multicore::Worker;
use bit_vec::{self, BitVec};
use ff::{Endianness, Field, PrimeField};
use futures::Future;
use group::{CurveAffine, CurveProjective};
use group::{CofactorCurve, CurveAffine};
use std::io;
use std::iter;
use std::ops::AddAssign;
@ -25,17 +25,17 @@ pub trait Source<G: CurveAffine> {
fn skip(&mut self, amt: usize) -> Result<(), SynthesisError>;
}
pub trait AddAssignFromSource: CurveProjective {
pub trait AddAssignFromSource: CofactorCurve {
/// Parses the element from the source. Fails if the point is at infinity.
fn add_assign_from_source<S: Source<<Self as CurveProjective>::Affine>>(
fn add_assign_from_source<S: Source<<Self as CofactorCurve>::Affine>>(
&mut self,
source: &mut S,
) -> Result<(), SynthesisError> {
AddAssign::<&<Self as CurveProjective>::Affine>::add_assign(self, source.next()?);
AddAssign::<&<Self as CofactorCurve>::Affine>::add_assign(self, source.next()?);
Ok(())
}
}
impl<G> AddAssignFromSource for G where G: CurveProjective {}
impl<G> AddAssignFromSource for G where G: CofactorCurve {}
impl<G: CurveAffine> SourceBuilder<G> for (Arc<Vec<G>>, usize) {
type Source = (Arc<Vec<G>>, usize);
@ -162,8 +162,8 @@ fn multiexp_inner<Q, D, G, S>(
where
for<'a> &'a Q: QueryDensity,
D: Send + Sync + 'static + Clone + AsRef<Q>,
G: CurveProjective,
S: SourceBuilder<<G as CurveProjective>::Affine>,
G: CofactorCurve,
S: SourceBuilder<<G as CofactorCurve>::Affine>,
{
// Perform this region of the multiexp
let this = {
@ -274,8 +274,8 @@ pub fn multiexp<Q, D, G, S>(
where
for<'a> &'a Q: QueryDensity,
D: Send + Sync + 'static + Clone + AsRef<Q>,
G: CurveProjective,
S: SourceBuilder<<G as CurveProjective>::Affine>,
G: CofactorCurve,
S: SourceBuilder<<G as CofactorCurve>::Affine>,
{
let c = if exponents.len() < 32 {
3u32
@ -296,8 +296,8 @@ where
#[cfg(feature = "pairing")]
#[test]
fn test_with_bls12() {
fn naive_multiexp<G: CurveProjective>(
bases: Arc<Vec<<G as CurveProjective>::Affine>>,
fn naive_multiexp<G: CofactorCurve>(
bases: Arc<Vec<<G as CofactorCurve>::Affine>>,
exponents: Arc<Vec<G::Scalar>>,
) -> G {
assert_eq!(bases.len(), exponents.len());