group: Rename zero and one to identity and generator
This commit is contained in:
parent
145747c08b
commit
3d1af5bed8
|
@ -218,7 +218,7 @@ impl<G: CurveProjective> Clone for Point<G> {
|
|||
|
||||
impl<G: CurveProjective> Group<G::Engine> for Point<G> {
|
||||
fn group_zero() -> Self {
|
||||
Point(G::zero())
|
||||
Point(G::identity())
|
||||
}
|
||||
fn group_mul_assign(&mut self, by: &G::Scalar) {
|
||||
self.0.mul_assign(by.to_repr());
|
||||
|
|
|
@ -234,7 +234,7 @@ where
|
|||
|
||||
let worker = Worker::new();
|
||||
|
||||
let mut h = vec![E::G1::zero(); powers_of_tau.as_ref().len() - 1];
|
||||
let mut h = vec![E::G1::identity(); powers_of_tau.as_ref().len() - 1];
|
||||
{
|
||||
// Compute powers of tau
|
||||
{
|
||||
|
@ -287,11 +287,11 @@ where
|
|||
powers_of_tau.ifft(&worker);
|
||||
let powers_of_tau = powers_of_tau.into_coeffs();
|
||||
|
||||
let mut a = vec![E::G1::zero(); assembly.num_inputs + assembly.num_aux];
|
||||
let mut b_g1 = vec![E::G1::zero(); assembly.num_inputs + assembly.num_aux];
|
||||
let mut b_g2 = vec![E::G2::zero(); assembly.num_inputs + assembly.num_aux];
|
||||
let mut ic = vec![E::G1::zero(); assembly.num_inputs];
|
||||
let mut l = vec![E::G1::zero(); assembly.num_aux];
|
||||
let mut a = vec![E::G1::identity(); assembly.num_inputs + assembly.num_aux];
|
||||
let mut b_g1 = vec![E::G1::identity(); assembly.num_inputs + assembly.num_aux];
|
||||
let mut b_g2 = vec![E::G2::identity(); assembly.num_inputs + assembly.num_aux];
|
||||
let mut ic = vec![E::G1::identity(); assembly.num_inputs];
|
||||
let mut l = vec![E::G1::identity(); assembly.num_aux];
|
||||
|
||||
fn eval<E: Engine>(
|
||||
// wNAF window tables
|
||||
|
@ -446,7 +446,7 @@ where
|
|||
// Don't allow any elements be unconstrained, so that
|
||||
// the L query is always fully dense.
|
||||
for e in l.iter() {
|
||||
if e.is_zero() {
|
||||
if e.is_identity() {
|
||||
return Err(SynthesisError::UnconstrainedVariable);
|
||||
}
|
||||
}
|
||||
|
@ -472,19 +472,19 @@ where
|
|||
// Filter points at infinity away from A/B queries
|
||||
a: Arc::new(
|
||||
a.into_iter()
|
||||
.filter(|e| !e.is_zero())
|
||||
.filter(|e| !e.is_identity())
|
||||
.map(|e| e.into_affine())
|
||||
.collect(),
|
||||
),
|
||||
b_g1: Arc::new(
|
||||
b_g1.into_iter()
|
||||
.filter(|e| !e.is_zero())
|
||||
.filter(|e| !e.is_identity())
|
||||
.map(|e| e.into_affine())
|
||||
.collect(),
|
||||
),
|
||||
b_g2: Arc::new(
|
||||
b_g2.into_iter()
|
||||
.filter(|e| !e.is_zero())
|
||||
.filter(|e| !e.is_identity())
|
||||
.map(|e| e.into_affine())
|
||||
.collect(),
|
||||
),
|
||||
|
|
|
@ -54,7 +54,7 @@ impl<E: Engine> Proof<E> {
|
|||
.into_affine()
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
||||
.and_then(|e| {
|
||||
if e.is_zero() {
|
||||
if e.is_identity() {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"point at infinity",
|
||||
|
@ -69,7 +69,7 @@ impl<E: Engine> Proof<E> {
|
|||
.into_affine()
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
||||
.and_then(|e| {
|
||||
if e.is_zero() {
|
||||
if e.is_identity() {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"point at infinity",
|
||||
|
@ -84,7 +84,7 @@ impl<E: Engine> Proof<E> {
|
|||
.into_affine()
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
||||
.and_then(|e| {
|
||||
if e.is_zero() {
|
||||
if e.is_identity() {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"point at infinity",
|
||||
|
@ -198,7 +198,7 @@ impl<E: Engine> VerifyingKey<E> {
|
|||
.into_affine()
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
||||
.and_then(|e| {
|
||||
if e.is_zero() {
|
||||
if e.is_identity() {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"point at infinity",
|
||||
|
@ -303,7 +303,7 @@ impl<E: Engine> Parameters<E> {
|
|||
}
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
||||
.and_then(|e| {
|
||||
if e.is_zero() {
|
||||
if e.is_identity() {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"point at infinity",
|
||||
|
@ -325,7 +325,7 @@ impl<E: Engine> Parameters<E> {
|
|||
}
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
||||
.and_then(|e| {
|
||||
if e.is_zero() {
|
||||
if e.is_identity() {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"point at infinity",
|
||||
|
|
|
@ -295,7 +295,7 @@ where
|
|||
);
|
||||
let b_g2_aux = multiexp(&worker, b_g2_aux_source, b_aux_density, aux_assignment);
|
||||
|
||||
if vk.delta_g1.is_zero() || vk.delta_g2.is_zero() {
|
||||
if vk.delta_g1.is_identity() || vk.delta_g2.is_identity() {
|
||||
// If this element is zero, someone is trying to perform a
|
||||
// subversion-CRS attack.
|
||||
return Err(SynthesisError::UnexpectedIdentity);
|
||||
|
|
|
@ -362,15 +362,15 @@ impl CurveProjective for Fr {
|
|||
<Fr as Field>::random(rng)
|
||||
}
|
||||
|
||||
fn zero() -> Self {
|
||||
fn identity() -> Self {
|
||||
<Fr as Field>::zero()
|
||||
}
|
||||
|
||||
fn one() -> Self {
|
||||
fn generator() -> Self {
|
||||
<Fr as Field>::one()
|
||||
}
|
||||
|
||||
fn is_zero(&self) -> bool {
|
||||
fn is_identity(&self) -> bool {
|
||||
<Fr as Field>::is_zero(self)
|
||||
}
|
||||
|
||||
|
@ -450,15 +450,15 @@ impl CurveAffine for Fr {
|
|||
type Scalar = Fr;
|
||||
type Engine = DummyEngine;
|
||||
|
||||
fn zero() -> Self {
|
||||
fn identity() -> Self {
|
||||
<Fr as Field>::zero()
|
||||
}
|
||||
|
||||
fn one() -> Self {
|
||||
fn generator() -> Self {
|
||||
<Fr as Field>::one()
|
||||
}
|
||||
|
||||
fn is_zero(&self) -> bool {
|
||||
fn is_identity(&self) -> bool {
|
||||
<Fr as Field>::is_zero(self)
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ impl<G: CurveAffine> Source<G> for (Arc<Vec<G>>, usize) {
|
|||
.into());
|
||||
}
|
||||
|
||||
if self.0[self.1].is_zero() {
|
||||
if self.0[self.1].is_identity() {
|
||||
return Err(SynthesisError::UnexpectedIdentity);
|
||||
}
|
||||
|
||||
|
@ -173,13 +173,13 @@ where
|
|||
|
||||
pool.compute(move || {
|
||||
// Accumulate the result
|
||||
let mut acc = G::zero();
|
||||
let mut acc = G::identity();
|
||||
|
||||
// Build a source for the bases
|
||||
let mut bases = bases.new();
|
||||
|
||||
// Create space for the buckets
|
||||
let mut buckets = vec![G::zero(); (1 << c) - 1];
|
||||
let mut buckets = vec![G::identity(); (1 << c) - 1];
|
||||
|
||||
let one = <G::Engine as ScalarEngine>::Fr::one();
|
||||
|
||||
|
@ -222,7 +222,7 @@ where
|
|||
// e.g. 3a + 2b + 1c = a +
|
||||
// (a) + b +
|
||||
// ((a) + b) + c
|
||||
let mut running_sum = G::zero();
|
||||
let mut running_sum = G::identity();
|
||||
for exp in buckets.into_iter().rev() {
|
||||
running_sum.add_assign(&exp);
|
||||
acc.add_assign(&running_sum);
|
||||
|
@ -302,7 +302,7 @@ fn test_with_bls12() {
|
|||
) -> G {
|
||||
assert_eq!(bases.len(), exponents.len());
|
||||
|
||||
let mut acc = G::zero();
|
||||
let mut acc = G::identity();
|
||||
|
||||
for (base, exp) in bases.iter().zip(exponents.iter()) {
|
||||
AddAssign::<&G>::add_assign(&mut acc, &base.mul(exp.to_repr()));
|
||||
|
|
Loading…
Reference in New Issue