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 ceecd32ac4
commit 5f1607c9b5
11 changed files with 99 additions and 103 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@ pub fn verify_proof<'a, E: Engine>(
return Err(SynthesisError::MalformedVerifyingKey); 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)) { for (i, b) in public_inputs.iter().zip(pvk.ic.iter().skip(1)) {
AddAssign::<&E::G1>::add_assign(&mut acc, &(*b * i)); 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( Ok(E::final_exponentiation(&E::miller_loop(
[ [
(&proof.a.prepare(), &proof.b.prepare()), (&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), (&proof.c.prepare(), &pvk.neg_delta_g2),
] ]
.iter(), .iter(),

View File

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

View File

@ -107,7 +107,7 @@ pub trait CurveProjective:
fn batch_normalize(p: &[Self], q: &mut [Self::Affine]); fn batch_normalize(p: &[Self], q: &mut [Self::Affine]);
/// Converts this element into its affine representation. /// Converts this element into its affine representation.
fn into_affine(&self) -> Self::Affine; fn to_affine(&self) -> Self::Affine;
/// Recommends a wNAF window table size given a scalar. Always returns a number /// Recommends a wNAF window table size given a scalar. Always returns a number
/// between 2 and 22, inclusive. /// between 2 and 22, inclusive.
@ -152,7 +152,7 @@ pub trait CurveAffine:
fn is_identity(&self) -> Choice; fn is_identity(&self) -> Choice;
/// Converts this element into its affine representation. /// Converts this element into its affine representation.
fn into_projective(&self) -> Self::Projective; fn to_projective(&self) -> Self::Projective;
/// Attempts to deserialize an element from its compressed encoding. /// Attempts to deserialize an element from its compressed encoding.
fn from_compressed(bytes: &Self::Compressed) -> CtOption<Self>; fn from_compressed(bytes: &Self::Compressed) -> CtOption<Self>;
@ -167,7 +167,7 @@ pub trait CurveAffine:
/// Converts this element into its compressed encoding, so long as it's not /// Converts this element into its compressed encoding, so long as it's not
/// the point at infinity. /// the point at infinity.
fn into_compressed(&self) -> Self::Compressed; fn to_compressed(&self) -> Self::Compressed;
/// Attempts to deserialize an element from its uncompressed encoding. /// Attempts to deserialize an element from its uncompressed encoding.
fn from_uncompressed(bytes: &Self::Uncompressed) -> CtOption<Self>; fn from_uncompressed(bytes: &Self::Uncompressed) -> CtOption<Self>;
@ -182,5 +182,5 @@ pub trait CurveAffine:
/// Converts this element into its uncompressed encoding, so long as it's not /// Converts this element into its uncompressed encoding, so long as it's not
/// the point at infinity. /// the point at infinity.
fn into_uncompressed(&self) -> Self::Uncompressed; fn to_uncompressed(&self) -> Self::Uncompressed;
} }

View File

@ -41,7 +41,7 @@ pub fn curve_tests<G: CurveProjective>() {
let mut z2 = z; let mut z2 = z;
z2.add_assign(&r); z2.add_assign(&r);
z.add_assign(&r.into_affine()); z.add_assign(&r.to_affine());
assert_eq!(z, z2); assert_eq!(z, z2);
assert_eq!(z, r); assert_eq!(z, r);
@ -50,12 +50,8 @@ pub fn curve_tests<G: CurveProjective>() {
// Transformations // Transformations
{ {
let a = G::random(&mut rng); let a = G::random(&mut rng);
let b = a.into_affine().into_projective(); let b = a.to_affine().to_projective();
let c = a let c = a.to_affine().to_projective().to_affine().to_projective();
.into_affine()
.into_projective()
.into_affine()
.into_projective();
assert_eq!(a, b); assert_eq!(a, b);
assert_eq!(b, c); assert_eq!(b, c);
} }
@ -211,7 +207,7 @@ fn random_negation_tests<G: CurveProjective>() {
assert!(bool::from(t3.is_identity())); assert!(bool::from(t3.is_identity()));
let mut t4 = t1; let mut t4 = t1;
t4.add_assign(&t2.into_affine()); t4.add_assign(&t2.to_affine());
assert!(bool::from(t4.is_identity())); assert!(bool::from(t4.is_identity()));
assert_eq!(t1.neg(), t2); assert_eq!(t1.neg(), t2);
@ -239,7 +235,7 @@ fn random_doubling_tests<G: CurveProjective>() {
tmp2.add_assign(&b); tmp2.add_assign(&b);
let mut tmp3 = a; let mut tmp3 = a;
tmp3.add_assign(&b.into_affine()); tmp3.add_assign(&b.to_affine());
assert_eq!(tmp1, tmp2); assert_eq!(tmp1, tmp2);
assert_eq!(tmp1, tmp3); assert_eq!(tmp1, tmp3);
@ -255,8 +251,8 @@ fn random_multiplication_tests<G: CurveProjective>() {
for _ in 0..1000 { for _ in 0..1000 {
let mut a = G::random(&mut rng); let mut a = G::random(&mut rng);
let mut b = G::random(&mut rng); let mut b = G::random(&mut rng);
let a_affine = a.into_affine(); let a_affine = a.to_affine();
let b_affine = b.into_affine(); let b_affine = b.to_affine();
let s = G::Scalar::random(&mut rng); let s = G::Scalar::random(&mut rng);
@ -291,9 +287,9 @@ fn random_addition_tests<G: CurveProjective>() {
let a = G::random(&mut rng); let a = G::random(&mut rng);
let b = G::random(&mut rng); let b = G::random(&mut rng);
let c = G::random(&mut rng); let c = G::random(&mut rng);
let a_affine = a.into_affine(); let a_affine = a.to_affine();
let b_affine = b.into_affine(); let b_affine = b.to_affine();
let c_affine = c.into_affine(); let c_affine = c.to_affine();
// a + a should equal the doubling // a + a should equal the doubling
{ {
@ -301,7 +297,7 @@ fn random_addition_tests<G: CurveProjective>() {
aplusa.add_assign(&a); aplusa.add_assign(&a);
let mut aplusamixed = a; let mut aplusamixed = a;
aplusamixed.add_assign(&a.into_affine()); aplusamixed.add_assign(&a.to_affine());
let adouble = a.double(); let adouble = a.double();
@ -329,17 +325,17 @@ fn random_addition_tests<G: CurveProjective>() {
// Mixed addition // Mixed addition
// (a + b) + c // (a + b) + c
tmp[3] = a_affine.into_projective(); tmp[3] = a_affine.to_projective();
tmp[3].add_assign(&b_affine); tmp[3].add_assign(&b_affine);
tmp[3].add_assign(&c_affine); tmp[3].add_assign(&c_affine);
// a + (b + c) // a + (b + c)
tmp[4] = b_affine.into_projective(); tmp[4] = b_affine.to_projective();
tmp[4].add_assign(&c_affine); tmp[4].add_assign(&c_affine);
tmp[4].add_assign(&a_affine); tmp[4].add_assign(&a_affine);
// (a + c) + b // (a + c) + b
tmp[5] = a_affine.into_projective(); tmp[5] = a_affine.to_projective();
tmp[5].add_assign(&c_affine); tmp[5].add_assign(&c_affine);
tmp[5].add_assign(&b_affine); tmp[5].add_assign(&b_affine);
@ -347,7 +343,7 @@ fn random_addition_tests<G: CurveProjective>() {
for i in 0..6 { for i in 0..6 {
for j in 0..6 { for j in 0..6 {
assert_eq!(tmp[i], tmp[j]); assert_eq!(tmp[i], tmp[j]);
assert_eq!(tmp[i].into_affine(), tmp[j].into_affine()); assert_eq!(tmp[i].to_affine(), tmp[j].to_affine());
} }
assert!(tmp[i] != a); assert!(tmp[i] != a);
@ -369,8 +365,8 @@ fn random_transformation_tests<G: CurveProjective>() {
for _ in 0..1000 { for _ in 0..1000 {
let g = G::random(&mut rng); let g = G::random(&mut rng);
let g_affine = g.into_affine(); let g_affine = g.to_affine();
let g_projective = g_affine.into_projective(); let g_projective = g_affine.to_projective();
assert_eq!(g, g_projective); assert_eq!(g, g_projective);
} }
@ -386,10 +382,10 @@ fn random_transformation_tests<G: CurveProjective>() {
} }
for _ in 0..5 { for _ in 0..5 {
let s = between.sample(&mut rng); let s = between.sample(&mut rng);
v[s] = v[s].into_affine().into_projective(); v[s] = v[s].to_affine().to_projective();
} }
let expected_v = v.iter().map(|v| v.into_affine()).collect::<Vec<_>>(); let expected_v = v.iter().map(|v| v.to_affine()).collect::<Vec<_>>();
let mut normalized = vec![G::Affine::identity(); v.len()]; let mut normalized = vec![G::Affine::identity(); v.len()];
G::batch_normalize(&v, &mut normalized); G::batch_normalize(&v, &mut normalized);
@ -405,29 +401,29 @@ fn random_encoding_tests<G: CurveProjective>() {
]); ]);
assert_eq!( assert_eq!(
G::Affine::from_uncompressed(&G::Affine::identity().into_uncompressed()).unwrap(), G::Affine::from_uncompressed(&G::Affine::identity().to_uncompressed()).unwrap(),
G::Affine::identity() G::Affine::identity()
); );
assert_eq!( assert_eq!(
G::Affine::from_compressed(&G::Affine::identity().into_compressed()).unwrap(), G::Affine::from_compressed(&G::Affine::identity().to_compressed()).unwrap(),
G::Affine::identity() G::Affine::identity()
); );
for _ in 0..1000 { for _ in 0..1000 {
let mut r = G::random(&mut rng).into_affine(); let mut r = G::random(&mut rng).to_affine();
let uncompressed = r.into_uncompressed(); let uncompressed = r.to_uncompressed();
let de_uncompressed = G::Affine::from_uncompressed(&uncompressed).unwrap(); let de_uncompressed = G::Affine::from_uncompressed(&uncompressed).unwrap();
assert_eq!(de_uncompressed, r); assert_eq!(de_uncompressed, r);
let compressed = r.into_compressed(); let compressed = r.to_compressed();
let de_compressed = G::Affine::from_compressed(&compressed).unwrap(); let de_compressed = G::Affine::from_compressed(&compressed).unwrap();
assert_eq!(de_compressed, r); assert_eq!(de_compressed, r);
r = r.neg(); r = r.neg();
let compressed = r.into_compressed(); let compressed = r.to_compressed();
let de_compressed = G::Affine::from_compressed(&compressed).unwrap(); let de_compressed = G::Affine::from_compressed(&compressed).unwrap();
assert_eq!(de_compressed, r); assert_eq!(de_compressed, r);
} }

View File

@ -57,7 +57,7 @@ macro_rules! curve_impl {
impl ::std::fmt::Display for $projective { impl ::std::fmt::Display for $projective {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "{}", self.into_affine()) write!(f, "{}", self.to_affine())
} }
} }
@ -221,7 +221,7 @@ macro_rules! curve_impl {
Choice::from(if self.infinity { 1 } else { 0 }) Choice::from(if self.infinity { 1 } else { 0 })
} }
fn into_projective(&self) -> $projective { fn to_projective(&self) -> $projective {
(*self).into() (*self).into()
} }
@ -247,7 +247,7 @@ macro_rules! curve_impl {
} }
} }
fn into_compressed(&self) -> Self::Compressed { fn to_compressed(&self) -> Self::Compressed {
$compressed::from_affine(*self) $compressed::from_affine(*self)
} }
@ -276,7 +276,7 @@ macro_rules! curve_impl {
} }
} }
fn into_uncompressed(&self) -> Self::Uncompressed { fn to_uncompressed(&self) -> Self::Uncompressed {
$uncompressed::from_affine(*self) $uncompressed::from_affine(*self)
} }
} }
@ -795,7 +795,7 @@ macro_rules! curve_impl {
} }
} }
fn into_affine(&self) -> $affine { fn to_affine(&self) -> $affine {
(*self).into() (*self).into()
} }
@ -1476,15 +1476,15 @@ pub mod g1 {
assert!(b.is_on_curve() && b.is_in_correct_subgroup_assuming_on_curve()); assert!(b.is_on_curve() && b.is_in_correct_subgroup_assuming_on_curve());
assert!(c.is_on_curve() && c.is_in_correct_subgroup_assuming_on_curve()); assert!(c.is_on_curve() && c.is_in_correct_subgroup_assuming_on_curve());
let mut tmp1 = a.into_projective(); let mut tmp1 = a.to_projective();
tmp1.add_assign(&b.into_projective()); tmp1.add_assign(&b.to_projective());
assert_eq!(tmp1.into_affine(), c); assert_eq!(tmp1.to_affine(), c);
assert_eq!(tmp1, c.into_projective()); assert_eq!(tmp1, c.to_projective());
let mut tmp2 = a.into_projective(); let mut tmp2 = a.to_projective();
tmp2.add_assign(&b); tmp2.add_assign(&b);
assert_eq!(tmp2.into_affine(), c); assert_eq!(tmp2.to_affine(), c);
assert_eq!(tmp2, c.into_projective()); assert_eq!(tmp2, c.to_projective());
} }
#[test] #[test]

View File

@ -65,8 +65,8 @@ fn uncompressed_test_vectors<G: CurveProjective>(expected: &[u8]) {
{ {
let mut expected = expected; let mut expected = expected;
for _ in 0..1000 { for _ in 0..1000 {
let e_affine = e.into_affine(); let e_affine = e.to_affine();
let encoded = e_affine.into_uncompressed(); let encoded = e_affine.to_uncompressed();
v.extend_from_slice(encoded.as_ref()); v.extend_from_slice(encoded.as_ref());
let mut decoded = <G::Affine as CurveAffine>::Uncompressed::default(); let mut decoded = <G::Affine as CurveAffine>::Uncompressed::default();
@ -92,8 +92,8 @@ fn compressed_test_vectors<G: CurveProjective>(expected: &[u8]) {
{ {
let mut expected = expected; let mut expected = expected;
for _ in 0..1000 { for _ in 0..1000 {
let e_affine = e.into_affine(); let e_affine = e.to_affine();
let encoded = e_affine.into_compressed(); let encoded = e_affine.to_compressed();
v.extend_from_slice(encoded.as_ref()); v.extend_from_slice(encoded.as_ref());
let mut decoded = <G::Affine as CurveAffine>::Compressed::default(); let mut decoded = <G::Affine as CurveAffine>::Compressed::default();
@ -132,7 +132,7 @@ fn test_g2_compressed_valid_vectors() {
#[test] #[test]
fn test_g1_uncompressed_invalid_vectors() { fn test_g1_uncompressed_invalid_vectors() {
{ {
let z = G1Affine::identity().into_uncompressed(); let z = G1Affine::identity().to_uncompressed();
{ {
let mut z = z; let mut z = z;
@ -165,7 +165,7 @@ fn test_g1_uncompressed_invalid_vectors() {
} }
} }
let o = G1Affine::generator().into_uncompressed(); let o = G1Affine::generator().to_uncompressed();
{ {
let mut o = o; let mut o = o;
@ -248,7 +248,7 @@ fn test_g1_uncompressed_invalid_vectors() {
#[test] #[test]
fn test_g2_uncompressed_invalid_vectors() { fn test_g2_uncompressed_invalid_vectors() {
{ {
let z = G2Affine::identity().into_uncompressed(); let z = G2Affine::identity().to_uncompressed();
{ {
let mut z = z; let mut z = z;
@ -281,7 +281,7 @@ fn test_g2_uncompressed_invalid_vectors() {
} }
} }
let o = G2Affine::generator().into_uncompressed(); let o = G2Affine::generator().to_uncompressed();
{ {
let mut o = o; let mut o = o;
@ -392,7 +392,7 @@ fn test_g2_uncompressed_invalid_vectors() {
#[test] #[test]
fn test_g1_compressed_invalid_vectors() { fn test_g1_compressed_invalid_vectors() {
{ {
let z = G1Affine::identity().into_compressed(); let z = G1Affine::identity().to_compressed();
{ {
let mut z = z; let mut z = z;
@ -425,7 +425,7 @@ fn test_g1_compressed_invalid_vectors() {
} }
} }
let o = G1Affine::generator().into_compressed(); let o = G1Affine::generator().to_compressed();
{ {
let mut o = o; let mut o = o;
@ -506,7 +506,7 @@ fn test_g1_compressed_invalid_vectors() {
#[test] #[test]
fn test_g2_compressed_invalid_vectors() { fn test_g2_compressed_invalid_vectors() {
{ {
let z = G2Affine::identity().into_compressed(); let z = G2Affine::identity().to_compressed();
{ {
let mut z = z; let mut z = z;
@ -539,7 +539,7 @@ fn test_g2_compressed_invalid_vectors() {
} }
} }
let o = G2Affine::generator().into_compressed(); let o = G2Affine::generator().to_compressed();
{ {
let mut o = o; let mut o = o;

View File

@ -13,8 +13,8 @@ pub fn engine_tests<E: Engine>() {
]); ]);
for _ in 0..10 { for _ in 0..10 {
let a = E::G1::random(&mut rng).into_affine(); let a = E::G1::random(&mut rng).to_affine();
let b = E::G2::random(&mut rng).into_affine(); let b = E::G2::random(&mut rng).to_affine();
assert!(a.pairing_with(&b) == b.pairing_with(&a)); assert!(a.pairing_with(&b) == b.pairing_with(&a));
assert!(a.pairing_with(&b) == E::pairing(a, b)); assert!(a.pairing_with(&b) == E::pairing(a, b));
@ -24,10 +24,10 @@ pub fn engine_tests<E: Engine>() {
let z1 = E::G1Affine::identity().prepare(); let z1 = E::G1Affine::identity().prepare();
let z2 = E::G2Affine::identity().prepare(); let z2 = E::G2Affine::identity().prepare();
let a = E::G1::random(&mut rng).into_affine().prepare(); let a = E::G1::random(&mut rng).to_affine().prepare();
let b = E::G2::random(&mut rng).into_affine().prepare(); let b = E::G2::random(&mut rng).to_affine().prepare();
let c = E::G1::random(&mut rng).into_affine().prepare(); let c = E::G1::random(&mut rng).to_affine().prepare();
let d = E::G2::random(&mut rng).into_affine().prepare(); let d = E::G2::random(&mut rng).to_affine().prepare();
assert_eq!( assert_eq!(
E::Fqk::one(), E::Fqk::one(),
@ -67,8 +67,8 @@ fn random_miller_loop_tests<E: Engine>() {
let p2 = E::pairing(a, b); let p2 = E::pairing(a, b);
let a = a.into_affine().prepare(); let a = a.to_affine().prepare();
let b = b.into_affine().prepare(); let b = b.to_affine().prepare();
let p1 = E::final_exponentiation(&E::miller_loop(&[(&a, &b)])).unwrap(); let p1 = E::final_exponentiation(&E::miller_loop(&[(&a, &b)])).unwrap();
@ -88,10 +88,10 @@ fn random_miller_loop_tests<E: Engine>() {
let mut abcd = ab; let mut abcd = ab;
abcd.mul_assign(&cd); abcd.mul_assign(&cd);
let a = a.into_affine().prepare(); let a = a.to_affine().prepare();
let b = b.into_affine().prepare(); let b = b.to_affine().prepare();
let c = c.into_affine().prepare(); let c = c.to_affine().prepare();
let d = d.into_affine().prepare(); let d = d.to_affine().prepare();
let abcd_with_double_loop = let abcd_with_double_loop =
E::final_exponentiation(&E::miller_loop(&[(&a, &b), (&c, &d)])).unwrap(); E::final_exponentiation(&E::miller_loop(&[(&a, &b), (&c, &d)])).unwrap();