Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edition 2018 clean up #113

Merged
merged 20 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bellman/src/gadgets/uint32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ mod test {
]);

for _ in 0..1000 {
let mut v = (0..32)
let v = (0..32)
.map(|_| Boolean::constant(rng.next_u32() % 2 != 0))
.collect::<Vec<_>>();

Expand Down Expand Up @@ -436,7 +436,7 @@ mod test {
]);

for _ in 0..1000 {
let mut v = (0..32)
let v = (0..32)
.map(|_| Boolean::constant(rng.next_u32() % 2 != 0))
.collect::<Vec<_>>();

Expand Down
6 changes: 3 additions & 3 deletions bellman/src/groth16/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use pairing::Engine;

use super::{Parameters, VerifyingKey};

use {Circuit, ConstraintSystem, Index, LinearCombination, SynthesisError, Variable};
use crate::{Circuit, ConstraintSystem, Index, LinearCombination, SynthesisError, Variable};

use domain::{EvaluationDomain, Scalar};
use crate::domain::{EvaluationDomain, Scalar};

use multicore::Worker;
use crate::multicore::Worker;

/// Generates a random common reference string for
/// a circuit.
Expand Down
6 changes: 3 additions & 3 deletions bellman/src/groth16/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use group::{CurveAffine, EncodedPoint};
use pairing::{Engine, PairingCurveAffine};

use SynthesisError;
use crate::SynthesisError;

use crate::multiexp::SourceBuilder;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use multiexp::SourceBuilder;
use std::io::{self, Read, Write};
use std::sync::Arc;

Expand Down Expand Up @@ -465,7 +465,7 @@ impl<'a, E: Engine> ParameterSource<E> for &'a Parameters<E> {
#[cfg(test)]
mod test_with_bls12_381 {
use super::*;
use {Circuit, ConstraintSystem, SynthesisError};
use crate::{Circuit, ConstraintSystem, SynthesisError};

use ff::Field;
use pairing::bls12_381::{Bls12, Fr};
Expand Down
8 changes: 4 additions & 4 deletions bellman/src/groth16/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use pairing::Engine;

use super::{ParameterSource, Proof};

use {Circuit, ConstraintSystem, Index, LinearCombination, SynthesisError, Variable};
use crate::{Circuit, ConstraintSystem, Index, LinearCombination, SynthesisError, Variable};

use domain::{EvaluationDomain, Scalar};
use crate::domain::{EvaluationDomain, Scalar};

use multiexp::{multiexp, DensityTracker, FullDensity};
use crate::multiexp::{multiexp, DensityTracker, FullDensity};

use multicore::Worker;
use crate::multicore::Worker;

fn eval<E: Engine>(
lc: &LinearCombination<E>,
Expand Down
2 changes: 1 addition & 1 deletion bellman/src/groth16/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use self::dummy_engine::*;

use std::marker::PhantomData;

use {Circuit, ConstraintSystem, SynthesisError};
use crate::{Circuit, ConstraintSystem, SynthesisError};

use super::{create_proof, generate_parameters, prepare_verifying_key, verify_proof};

Expand Down
2 changes: 1 addition & 1 deletion bellman/src/groth16/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use pairing::{Engine, PairingCurveAffine};

use super::{PreparedVerifyingKey, Proof, VerifyingKey};

use SynthesisError;
use crate::SynthesisError;

pub fn prepare_verifying_key<E: Engine>(vk: &VerifyingKey<E>) -> PreparedVerifyingKey<E> {
let mut gamma = vk.gamma_g2;
Expand Down
8 changes: 4 additions & 4 deletions bellman/tests/mimc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ impl<'a, E: Engine> Circuit<E> for MiMCDemo<'a, E> {
let cs = &mut cs.namespace(|| format!("round {}", i));

// tmp = (xL + Ci)^2
let mut tmp_value = xl_value.map(|mut e| {
let tmp_value = xl_value.map(|mut e| {
e.add_assign(&self.constants[i]);
e.square();
e
});
let mut tmp = cs.alloc(
let tmp = cs.alloc(
|| "tmp",
|| tmp_value.ok_or(SynthesisError::AssignmentMissing),
)?;
Expand All @@ -110,14 +110,14 @@ impl<'a, E: Engine> Circuit<E> for MiMCDemo<'a, E> {
// new_xL = xR + (xL + Ci)^3
// new_xL = xR + tmp * (xL + Ci)
// new_xL - xR = tmp * (xL + Ci)
let mut new_xl_value = xl_value.map(|mut e| {
let new_xl_value = xl_value.map(|mut e| {
e.add_assign(&self.constants[i]);
e.mul_assign(&tmp_value.unwrap());
e.add_assign(&xr_value.unwrap());
e
});

let mut new_xl = if i == (MIMC_ROUNDS - 1) {
let new_xl = if i == (MIMC_ROUNDS - 1) {
// This is the last round, xL is our image and so
// we allocate a public input.
cs.alloc_input(
Expand Down
8 changes: 4 additions & 4 deletions ff/ff_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ fn prime_field_repr_impl(repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenS
impl ::std::fmt::Debug for #repr
{
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
try!(write!(f, "0x"));
write!(f, "0x")?;
for i in self.0.iter().rev() {
try!(write!(f, "{:016x}", *i));
write!(f, "{:016x}", *i)?;
}

Ok(())
Expand All @@ -133,9 +133,9 @@ fn prime_field_repr_impl(repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenS

impl ::std::fmt::Display for #repr {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
try!(write!(f, "0x"));
write!(f, "0x")?;
for i in self.0.iter().rev() {
try!(write!(f, "{:016x}", *i));
write!(f, "{:016x}", *i)?;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion ff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ pub trait PrimeField: Field {
}

/// Convert this prime field element into a biginteger representation.
fn from_repr(Self::Repr) -> Result<Self, PrimeFieldDecodingError>;
fn from_repr(_: Self::Repr) -> Result<Self, PrimeFieldDecodingError>;

/// Convert a biginteger representation into a prime field element, if
/// the number is an element of the field.
Expand Down
4 changes: 2 additions & 2 deletions group/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use ff::{Field, PrimeField};
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;

use {CurveAffine, CurveProjective, EncodedPoint};
use crate::{CurveAffine, CurveProjective, EncodedPoint};

pub fn curve_tests<G: CurveProjective>() {
let mut rng = XorShiftRng::from_seed([
Expand Down Expand Up @@ -71,7 +71,7 @@ pub fn curve_tests<G: CurveProjective>() {
}

fn random_wnaf_tests<G: CurveProjective>() {
use wnaf::*;
use crate::wnaf::*;

let mut rng = XorShiftRng::from_seed([
0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc,
Expand Down
2 changes: 1 addition & 1 deletion librustzcash/src/tests/key_agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rand_os::OsRng;
use zcash_primitives::jubjub::{edwards, JubjubBls12};
use zcash_primitives::primitives::{Diversifier, ViewingKey};

use {
use crate::{
librustzcash_sapling_generate_r, librustzcash_sapling_ka_agree,
librustzcash_sapling_ka_derivepublic,
};
Expand Down
2 changes: 1 addition & 1 deletion librustzcash/src/tests/key_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use zcash_primitives::{

use super::JUBJUB;

use {
use crate::{
librustzcash_ask_to_ak, librustzcash_check_diversifier, librustzcash_crh_ivk,
librustzcash_ivk_to_pkd, librustzcash_nsk_to_nk,
};
Expand Down
4 changes: 2 additions & 2 deletions librustzcash/src/tests/notes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use librustzcash_sapling_compute_cm;
use librustzcash_sapling_compute_nf;
use crate::librustzcash_sapling_compute_cm;
use crate::librustzcash_sapling_compute_nf;

#[test]
fn notes() {
Expand Down
8 changes: 4 additions & 4 deletions pairing/src/bls12_381/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,11 @@ macro_rules! curve_impl {
pub mod g1 {
use super::super::{Bls12, Fq, Fq12, FqRepr, Fr, FrRepr};
use super::g2::G2Affine;
use crate::{Engine, PairingCurveAffine};
use ff::{BitIterator, Field, PrimeField, PrimeFieldRepr, SqrtField};
use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError};
use rand_core::RngCore;
use std::fmt;
use {Engine, PairingCurveAffine};

curve_impl!(
"G1",
Expand Down Expand Up @@ -934,7 +934,7 @@ pub mod g1 {

#[test]
fn g1_generator() {
use SqrtField;
use crate::SqrtField;

let mut x = Fq::zero();
let mut i = 0;
Expand Down Expand Up @@ -1291,11 +1291,11 @@ pub mod g1 {
pub mod g2 {
use super::super::{Bls12, Fq, Fq12, Fq2, FqRepr, Fr, FrRepr};
use super::g1::G1Affine;
use crate::{Engine, PairingCurveAffine};
use ff::{BitIterator, Field, PrimeField, PrimeFieldRepr, SqrtField};
use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError};
use rand_core::RngCore;
use std::fmt;
use {Engine, PairingCurveAffine};

curve_impl!(
"G2",
Expand Down Expand Up @@ -1640,7 +1640,7 @@ pub mod g2 {

#[test]
fn g2_generator() {
use SqrtField;
use crate::SqrtField;

let mut x = Fq2::zero();
let mut i = 0;
Expand Down
10 changes: 5 additions & 5 deletions pairing/src/bls12_381/fq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2225,10 +2225,10 @@ fn test_fq_root_of_unity() {

#[test]
fn fq_field_tests() {
::tests::field::random_field_tests::<Fq>();
::tests::field::random_sqrt_tests::<Fq>();
::tests::field::random_frobenius_tests::<Fq, _>(Fq::char(), 13);
::tests::field::from_str_tests::<Fq>();
crate::tests::field::random_field_tests::<Fq>();
crate::tests::field::random_sqrt_tests::<Fq>();
crate::tests::field::random_frobenius_tests::<Fq, _>(Fq::char(), 13);
crate::tests::field::from_str_tests::<Fq>();
}

#[test]
Expand All @@ -2244,7 +2244,7 @@ fn test_fq_ordering() {

#[test]
fn fq_repr_tests() {
::tests::repr::random_repr_tests::<Fq>();
crate::tests::repr::random_repr_tests::<Fq>();
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions pairing/src/bls12_381/fq12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,6 @@ fn test_fq12_mul_by_014() {
fn fq12_field_tests() {
use ff::PrimeField;

::tests::field::random_field_tests::<Fq12>();
::tests::field::random_frobenius_tests::<Fq12, _>(super::fq::Fq::char(), 13);
crate::tests::field::random_field_tests::<Fq12>();
crate::tests::field::random_frobenius_tests::<Fq12, _>(super::fq::Fq::char(), 13);
}
6 changes: 3 additions & 3 deletions pairing/src/bls12_381/fq2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ fn test_fq2_mul_nonresidue() {
fn fq2_field_tests() {
use ff::PrimeField;

::tests::field::random_field_tests::<Fq2>();
::tests::field::random_sqrt_tests::<Fq2>();
::tests::field::random_frobenius_tests::<Fq2, _>(super::fq::Fq::char(), 13);
crate::tests::field::random_field_tests::<Fq2>();
crate::tests::field::random_sqrt_tests::<Fq2>();
crate::tests::field::random_frobenius_tests::<Fq2, _>(super::fq::Fq::char(), 13);
}
4 changes: 2 additions & 2 deletions pairing/src/bls12_381/fq6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,6 @@ fn test_fq6_mul_by_01() {
fn fq6_field_tests() {
use ff::PrimeField;

::tests::field::random_field_tests::<Fq6>();
::tests::field::random_frobenius_tests::<Fq6, _>(super::fq::Fq::char(), 13);
crate::tests::field::random_field_tests::<Fq6>();
crate::tests::field::random_frobenius_tests::<Fq6, _>(super::fq::Fq::char(), 13);
}
10 changes: 5 additions & 5 deletions pairing/src/bls12_381/fr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,13 +1015,13 @@ fn test_fr_root_of_unity() {

#[test]
fn fr_field_tests() {
::tests::field::random_field_tests::<Fr>();
::tests::field::random_sqrt_tests::<Fr>();
::tests::field::random_frobenius_tests::<Fr, _>(Fr::char(), 13);
::tests::field::from_str_tests::<Fr>();
crate::tests::field::random_field_tests::<Fr>();
crate::tests::field::random_sqrt_tests::<Fr>();
crate::tests::field::random_frobenius_tests::<Fr, _>(Fr::char(), 13);
crate::tests::field::from_str_tests::<Fr>();
}

#[test]
fn fr_repr_tests() {
::tests::repr::random_repr_tests::<Fr>();
crate::tests::repr::random_repr_tests::<Fr>();
}
2 changes: 1 addition & 1 deletion pairing/src/bls12_381/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,5 +366,5 @@ impl G2Prepared {

#[test]
fn bls12_engine_tests() {
::tests::engine::engine_tests::<Bls12>();
crate::tests::engine::engine_tests::<Bls12>();
}
2 changes: 1 addition & 1 deletion pairing/src/bls12_381/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use ff::PrimeFieldRepr;
use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError};

use super::*;
use *;
use crate::*;

#[test]
fn test_pairing_result_against_relic() {
Expand Down
2 changes: 1 addition & 1 deletion pairing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub trait Engine: ScalarEngine {
>;

/// Perform final exponentiation of the result of a miller loop.
fn final_exponentiation(&Self::Fqk) -> Option<Self::Fqk>;
fn final_exponentiation(_: &Self::Fqk) -> Option<Self::Fqk>;

/// Performs a complete pairing operation `(p, q)`.
fn pairing<G1, G2>(p: G1, q: G2) -> Self::Fqk
Expand Down
2 changes: 1 addition & 1 deletion pairing/src/tests/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use group::{CurveAffine, CurveProjective};
use rand_core::SeedableRng;
use rand_xorshift::XorShiftRng;

use {Engine, Field, PairingCurveAffine, PrimeField};
use crate::{Engine, Field, PairingCurveAffine, PrimeField};

pub fn engine_tests<E: Engine>() {
let mut rng = XorShiftRng::from_seed([
Expand Down
2 changes: 1 addition & 1 deletion zcash_primitives/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt;
use std::io::{self, Read, Write};
use std::ops::Deref;

use serialize::Vector;
use crate::serialize::Vector;

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct BlockHash(pub [u8; 32]);
Expand Down
4 changes: 2 additions & 2 deletions zcash_primitives/src/group_hash.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use jubjub::{edwards, JubjubEngine, PrimeOrder};
use crate::jubjub::{edwards, JubjubEngine, PrimeOrder};

use ff::PrimeField;

use crate::constants;
use blake2s_simd::Params;
use constants;

/// Produces a random point in the Jubjub curve.
/// The point is guaranteed to be prime order
Expand Down
4 changes: 2 additions & 2 deletions zcash_primitives/src/jubjub/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ pub struct FsRepr(pub [u64; 4]);

impl ::std::fmt::Display for FsRepr {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
try!(write!(f, "0x"));
r#write!(f, "0x")?;
Eirik0 marked this conversation as resolved.
Show resolved Hide resolved
for i in self.0.iter().rev() {
try!(write!(f, "{:016x}", *i));
r#write!(f, "{:016x}", *i)?;
Eirik0 marked this conversation as resolved.
Show resolved Hide resolved
}

Ok(())
Expand Down
Loading