group: Rename into_*(&self) -> to_*(&self)

Rust naming convention uses the into_ prefix for methods that consume
self, and the to_ prefix for methods that take an immutable reference.
This commit is contained in:
Jack Grigg 2020-05-20 11:30:41 +12:00
parent 392a107b31
commit cbe8c5de67
6 changed files with 34 additions and 34 deletions

View File

@ -459,16 +459,16 @@ where
}
}
let g1 = g1.into_affine();
let g2 = g2.into_affine();
let g1 = g1.to_affine();
let g2 = g2.to_affine();
let vk = VerifyingKey::<E> {
alpha_g1: (g1 * &alpha).into_affine(),
beta_g1: (g1 * &beta).into_affine(),
beta_g2: (g2 * &beta).into_affine(),
gamma_g2: (g2 * &gamma).into_affine(),
delta_g1: (g1 * &delta).into_affine(),
delta_g2: (g2 * &delta).into_affine(),
alpha_g1: (g1 * &alpha).to_affine(),
beta_g1: (g1 * &beta).to_affine(),
beta_g2: (g2 * &beta).to_affine(),
gamma_g2: (g2 * &gamma).to_affine(),
delta_g1: (g1 * &delta).to_affine(),
delta_g2: (g2 * &delta).to_affine(),
ic,
};

View File

@ -38,9 +38,9 @@ impl<E: Engine> PartialEq for Proof<E> {
impl<E: Engine> Proof<E> {
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
writer.write_all(self.a.into_compressed().as_ref())?;
writer.write_all(self.b.into_compressed().as_ref())?;
writer.write_all(self.c.into_compressed().as_ref())?;
writer.write_all(self.a.to_compressed().as_ref())?;
writer.write_all(self.b.to_compressed().as_ref())?;
writer.write_all(self.c.to_compressed().as_ref())?;
Ok(())
}
@ -142,15 +142,15 @@ impl<E: Engine> PartialEq for VerifyingKey<E> {
impl<E: Engine> VerifyingKey<E> {
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
writer.write_all(self.alpha_g1.into_uncompressed().as_ref())?;
writer.write_all(self.beta_g1.into_uncompressed().as_ref())?;
writer.write_all(self.beta_g2.into_uncompressed().as_ref())?;
writer.write_all(self.gamma_g2.into_uncompressed().as_ref())?;
writer.write_all(self.delta_g1.into_uncompressed().as_ref())?;
writer.write_all(self.delta_g2.into_uncompressed().as_ref())?;
writer.write_all(self.alpha_g1.to_uncompressed().as_ref())?;
writer.write_all(self.beta_g1.to_uncompressed().as_ref())?;
writer.write_all(self.beta_g2.to_uncompressed().as_ref())?;
writer.write_all(self.gamma_g2.to_uncompressed().as_ref())?;
writer.write_all(self.delta_g1.to_uncompressed().as_ref())?;
writer.write_all(self.delta_g2.to_uncompressed().as_ref())?;
writer.write_u32::<BigEndian>(self.ic.len() as u32)?;
for ic in &self.ic {
writer.write_all(ic.into_uncompressed().as_ref())?;
writer.write_all(ic.to_uncompressed().as_ref())?;
}
Ok(())
@ -261,27 +261,27 @@ impl<E: Engine> Parameters<E> {
writer.write_u32::<BigEndian>(self.h.len() as u32)?;
for g in &self.h[..] {
writer.write_all(g.into_uncompressed().as_ref())?;
writer.write_all(g.to_uncompressed().as_ref())?;
}
writer.write_u32::<BigEndian>(self.l.len() as u32)?;
for g in &self.l[..] {
writer.write_all(g.into_uncompressed().as_ref())?;
writer.write_all(g.to_uncompressed().as_ref())?;
}
writer.write_u32::<BigEndian>(self.a.len() as u32)?;
for g in &self.a[..] {
writer.write_all(g.into_uncompressed().as_ref())?;
writer.write_all(g.to_uncompressed().as_ref())?;
}
writer.write_u32::<BigEndian>(self.b_g1.len() as u32)?;
for g in &self.b_g1[..] {
writer.write_all(g.into_uncompressed().as_ref())?;
writer.write_all(g.to_uncompressed().as_ref())?;
}
writer.write_u32::<BigEndian>(self.b_g2.len() as u32)?;
for g in &self.b_g2[..] {
writer.write_all(g.into_uncompressed().as_ref())?;
writer.write_all(g.to_uncompressed().as_ref())?;
}
Ok(())

View File

@ -332,8 +332,8 @@ where
AddAssign::<&E::G1>::add_assign(&mut g_c, &l.wait()?);
Ok(Proof {
a: g_a.into_affine(),
b: g_b.into_affine(),
c: g_c.into_affine(),
a: g_a.to_affine(),
b: g_b.to_affine(),
c: g_c.to_affine(),
})
}

View File

@ -400,11 +400,11 @@ impl CurveProjective for Fr {
assert_eq!(p.len(), q.len());
for (p, q) in p.iter().zip(q.iter_mut()) {
*q = p.into_affine();
*q = p.to_affine();
}
}
fn into_affine(&self) -> Fr {
fn to_affine(&self) -> Fr {
*self
}
@ -451,7 +451,7 @@ impl CurveAffine for Fr {
Choice::from(if <Fr as Field>::is_zero(self) { 1 } else { 0 })
}
fn into_projective(&self) -> Self::Projective {
fn to_projective(&self) -> Self::Projective {
*self
}
@ -463,7 +463,7 @@ impl CurveAffine for Fr {
unimplemented!()
}
fn into_compressed(&self) -> Self::Compressed {
fn to_compressed(&self) -> Self::Compressed {
unimplemented!()
}
@ -475,7 +475,7 @@ impl CurveAffine for Fr {
unimplemented!()
}
fn into_uncompressed(&self) -> Self::Uncompressed {
fn to_uncompressed(&self) -> Self::Uncompressed {
unimplemented!()
}
}

View File

@ -27,7 +27,7 @@ pub fn verify_proof<'a, E: Engine>(
return Err(SynthesisError::MalformedVerifyingKey);
}
let mut acc = pvk.ic[0].into_projective();
let mut acc = pvk.ic[0].to_projective();
for (i, b) in public_inputs.iter().zip(pvk.ic.iter().skip(1)) {
AddAssign::<&E::G1>::add_assign(&mut acc, &(*b * i));
@ -44,7 +44,7 @@ pub fn verify_proof<'a, E: Engine>(
Ok(E::final_exponentiation(&E::miller_loop(
[
(&proof.a.prepare(), &proof.b.prepare()),
(&acc.into_affine().prepare(), &pvk.neg_gamma_g2),
(&acc.to_affine().prepare(), &pvk.neg_gamma_g2),
(&proof.c.prepare(), &pvk.neg_delta_g2),
]
.iter(),

View File

@ -328,7 +328,7 @@ fn test_with_bls12() {
);
let g = Arc::new(
(0..SAMPLES)
.map(|_| <Bls12 as Engine>::G1::random(rng).into_affine())
.map(|_| <Bls12 as Engine>::G1::random(rng).to_affine())
.collect::<Vec<_>>(),
);