From e59738b4eecafe2a3d1ebd10544dfd95fe4fd43d Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Fri, 16 Aug 2019 22:52:54 -0600 Subject: [PATCH 01/20] cargo fix --edition for ff --- ff/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ff/src/lib.rs b/ff/src/lib.rs index 482dc46aa..fd1a5023e 100644 --- a/ff/src/lib.rs +++ b/ff/src/lib.rs @@ -266,7 +266,7 @@ pub trait PrimeField: Field { } /// Convert this prime field element into a biginteger representation. - fn from_repr(Self::Repr) -> Result; + fn from_repr(_: Self::Repr) -> Result; /// Convert a biginteger representation into a prime field element, if /// the number is an element of the field. From 4991e53f48db37b6b1317dce6b1486e0f6bd1295 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Fri, 16 Aug 2019 22:58:05 -0600 Subject: [PATCH 02/20] cargo fix --edition for bellman --- bellman/src/gadgets/uint32.rs | 4 ++-- bellman/src/groth16/generator.rs | 6 +++--- bellman/src/groth16/mod.rs | 6 +++--- bellman/src/groth16/prover.rs | 8 ++++---- bellman/src/groth16/tests/mod.rs | 2 +- bellman/src/groth16/verifier.rs | 2 +- bellman/tests/mimc.rs | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bellman/src/gadgets/uint32.rs b/bellman/src/gadgets/uint32.rs index 4c0d37601..ef3f44aea 100644 --- a/bellman/src/gadgets/uint32.rs +++ b/bellman/src/gadgets/uint32.rs @@ -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::>(); @@ -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::>(); diff --git a/bellman/src/groth16/generator.rs b/bellman/src/groth16/generator.rs index 596464f31..2ece8b7ec 100644 --- a/bellman/src/groth16/generator.rs +++ b/bellman/src/groth16/generator.rs @@ -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. diff --git a/bellman/src/groth16/mod.rs b/bellman/src/groth16/mod.rs index 85b7952bf..428176bf9 100644 --- a/bellman/src/groth16/mod.rs +++ b/bellman/src/groth16/mod.rs @@ -1,10 +1,10 @@ use group::{CurveAffine, EncodedPoint}; use pairing::{Engine, PairingCurveAffine}; -use SynthesisError; +use crate::SynthesisError; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; -use multiexp::SourceBuilder; +use crate::multiexp::SourceBuilder; use std::io::{self, Read, Write}; use std::sync::Arc; @@ -465,7 +465,7 @@ impl<'a, E: Engine> ParameterSource for &'a Parameters { #[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}; diff --git a/bellman/src/groth16/prover.rs b/bellman/src/groth16/prover.rs index a502ac332..7fe282f6c 100644 --- a/bellman/src/groth16/prover.rs +++ b/bellman/src/groth16/prover.rs @@ -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( lc: &LinearCombination, diff --git a/bellman/src/groth16/tests/mod.rs b/bellman/src/groth16/tests/mod.rs index e6a36e4bc..d8be98e40 100644 --- a/bellman/src/groth16/tests/mod.rs +++ b/bellman/src/groth16/tests/mod.rs @@ -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}; diff --git a/bellman/src/groth16/verifier.rs b/bellman/src/groth16/verifier.rs index 926955a98..065a3b0fb 100644 --- a/bellman/src/groth16/verifier.rs +++ b/bellman/src/groth16/verifier.rs @@ -4,7 +4,7 @@ use pairing::{Engine, PairingCurveAffine}; use super::{PreparedVerifyingKey, Proof, VerifyingKey}; -use SynthesisError; +use crate::SynthesisError; pub fn prepare_verifying_key(vk: &VerifyingKey) -> PreparedVerifyingKey { let mut gamma = vk.gamma_g2; diff --git a/bellman/tests/mimc.rs b/bellman/tests/mimc.rs index 18aaece94..94c0d63bb 100644 --- a/bellman/tests/mimc.rs +++ b/bellman/tests/mimc.rs @@ -90,12 +90,12 @@ impl<'a, E: Engine> Circuit 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), )?; @@ -110,14 +110,14 @@ impl<'a, E: Engine> Circuit 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( From fc3dd8198bc66cf227bb911f0921b3e918ec3941 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Fri, 16 Aug 2019 22:58:49 -0600 Subject: [PATCH 03/20] cargo fix --edition for group --- group/src/tests/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/group/src/tests/mod.rs b/group/src/tests/mod.rs index 2b58b6ca7..1970667f8 100644 --- a/group/src/tests/mod.rs +++ b/group/src/tests/mod.rs @@ -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() { let mut rng = XorShiftRng::from_seed([ @@ -71,7 +71,7 @@ pub fn curve_tests() { } fn random_wnaf_tests() { - 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, From e12d315ab9db4337207ed14eb8fcfd90084670a4 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Fri, 16 Aug 2019 23:06:18 -0600 Subject: [PATCH 04/20] Warning cleanup --- zcash_primitives/src/jubjub/mod.rs | 2 +- zcash_primitives/src/transaction/components/amount.rs | 4 ++-- zcash_proofs/src/circuit/pedersen_hash.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zcash_primitives/src/jubjub/mod.rs b/zcash_primitives/src/jubjub/mod.rs index 7ab0d0eee..e626db134 100644 --- a/zcash_primitives/src/jubjub/mod.rs +++ b/zcash_primitives/src/jubjub/mod.rs @@ -374,7 +374,7 @@ impl JubjubBls12 { let mut pedersen_circuit_generators = vec![]; // Process each segment - for mut gen in tmp_params.pedersen_hash_generators.iter().cloned() { + for gen in tmp_params.pedersen_hash_generators.iter().cloned() { let mut gen = montgomery::Point::from_edwards(&gen, &tmp_params); let mut windows = vec![]; for _ in 0..tmp_params.pedersen_hash_chunks_per_generator() { diff --git a/zcash_primitives/src/transaction/components/amount.rs b/zcash_primitives/src/transaction/components/amount.rs index 8d358fbda..f3f89afab 100644 --- a/zcash_primitives/src/transaction/components/amount.rs +++ b/zcash_primitives/src/transaction/components/amount.rs @@ -206,7 +206,7 @@ mod tests { #[should_panic] fn add_panics_on_overflow() { let v = Amount(MAX_MONEY); - let sum = v + Amount(1); + let _sum = v + Amount(1); } #[test] @@ -220,7 +220,7 @@ mod tests { #[should_panic] fn sub_panics_on_underflow() { let v = Amount(-MAX_MONEY); - let diff = v - Amount(1); + let _diff = v - Amount(1); } #[test] diff --git a/zcash_proofs/src/circuit/pedersen_hash.rs b/zcash_proofs/src/circuit/pedersen_hash.rs index 21c0bf596..7a541b75e 100644 --- a/zcash_proofs/src/circuit/pedersen_hash.rs +++ b/zcash_proofs/src/circuit/pedersen_hash.rs @@ -163,7 +163,7 @@ mod test { for length in 0..751 { for _ in 0..5 { - let mut input: Vec = (0..length).map(|_| rng.next_u32() % 2 != 0).collect(); + let input: Vec = (0..length).map(|_| rng.next_u32() % 2 != 0).collect(); let mut cs = TestConstraintSystem::::new(); From b0d8747697b0cdac898bd1220d0513d677f142e3 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 16:54:11 -0600 Subject: [PATCH 05/20] cargo fix --edition for zcash_primitives --- zcash_primitives/src/block.rs | 2 +- zcash_primitives/src/group_hash.rs | 4 ++-- zcash_primitives/src/jubjub/fs.rs | 4 ++-- zcash_primitives/src/jubjub/mod.rs | 6 +++--- zcash_primitives/src/lib.rs | 2 +- zcash_primitives/src/merkle_tree.rs | 10 +++++----- zcash_primitives/src/pedersen_hash.rs | 2 +- zcash_primitives/src/primitives.rs | 8 ++++---- zcash_primitives/src/redjubjub.rs | 2 +- zcash_primitives/src/sapling.rs | 2 +- zcash_primitives/src/transaction/builder.rs | 2 +- zcash_primitives/src/transaction/components.rs | 6 +++--- zcash_primitives/src/transaction/mod.rs | 4 ++-- zcash_primitives/src/transaction/sighash.rs | 2 +- zcash_primitives/src/transaction/tests.rs | 6 +++--- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/zcash_primitives/src/block.rs b/zcash_primitives/src/block.rs index 05b65e045..c0eb92fde 100644 --- a/zcash_primitives/src/block.rs +++ b/zcash_primitives/src/block.rs @@ -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]); diff --git a/zcash_primitives/src/group_hash.rs b/zcash_primitives/src/group_hash.rs index dec59cdd0..e67ca4905 100644 --- a/zcash_primitives/src/group_hash.rs +++ b/zcash_primitives/src/group_hash.rs @@ -1,9 +1,9 @@ -use jubjub::{edwards, JubjubEngine, PrimeOrder}; +use crate::jubjub::{edwards, JubjubEngine, PrimeOrder}; use ff::PrimeField; use blake2s_simd::Params; -use constants; +use crate::constants; /// Produces a random point in the Jubjub curve. /// The point is guaranteed to be prime order diff --git a/zcash_primitives/src/jubjub/fs.rs b/zcash_primitives/src/jubjub/fs.rs index 768bd833a..90a179f1f 100644 --- a/zcash_primitives/src/jubjub/fs.rs +++ b/zcash_primitives/src/jubjub/fs.rs @@ -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#try!(write!(f, "0x")); for i in self.0.iter().rev() { - try!(write!(f, "{:016x}", *i)); + r#try!(write!(f, "{:016x}", *i)); } Ok(()) diff --git a/zcash_primitives/src/jubjub/mod.rs b/zcash_primitives/src/jubjub/mod.rs index e626db134..8d9e22736 100644 --- a/zcash_primitives/src/jubjub/mod.rs +++ b/zcash_primitives/src/jubjub/mod.rs @@ -20,9 +20,9 @@ use ff::{Field, PrimeField, SqrtField}; use pairing::Engine; -use group_hash::group_hash; +use crate::group_hash::group_hash; -use constants; +use crate::constants; use pairing::bls12_381::{Bls12, Fr}; @@ -122,7 +122,7 @@ pub trait JubjubParams: Sized { fn generator(&self, base: FixedGenerators) -> &edwards::Point; /// Returns a window table [0, 1, ..., 8] for different magnitudes of some /// fixed generator. - fn circuit_generators(&self, FixedGenerators) -> &[Vec<(E::Fr, E::Fr)>]; + fn circuit_generators(&self, _: FixedGenerators) -> &[Vec<(E::Fr, E::Fr)>]; /// Returns the window size for exponentiation of Pedersen hash generators /// outside the circuit fn pedersen_hash_exp_window_size() -> u32; diff --git a/zcash_primitives/src/lib.rs b/zcash_primitives/src/lib.rs index 1d4806ebe..8bc5fe840 100644 --- a/zcash_primitives/src/lib.rs +++ b/zcash_primitives/src/lib.rs @@ -43,7 +43,7 @@ pub mod zip32; #[cfg(test)] mod test_vectors; -use jubjub::JubjubBls12; +use crate::jubjub::JubjubBls12; lazy_static! { pub static ref JUBJUB: JubjubBls12 = { JubjubBls12::new() }; diff --git a/zcash_primitives/src/merkle_tree.rs b/zcash_primitives/src/merkle_tree.rs index aa1596dda..288ad2149 100644 --- a/zcash_primitives/src/merkle_tree.rs +++ b/zcash_primitives/src/merkle_tree.rs @@ -5,8 +5,8 @@ use std::collections::VecDeque; use std::io::{self, Read, Write}; use std::iter; -use sapling::SAPLING_COMMITMENT_TREE_DEPTH; -use serialize::{Optional, Vector}; +use crate::sapling::SAPLING_COMMITMENT_TREE_DEPTH; +use crate::serialize::{Optional, Vector}; /// A hashable node within a Merkle tree. pub trait Hashable: Clone + Copy { @@ -17,13 +17,13 @@ pub trait Hashable: Clone + Copy { fn write(&self, writer: W) -> io::Result<()>; /// Returns the parent node within the tree of the two given nodes. - fn combine(usize, &Self, &Self) -> Self; + fn combine(_: usize, _: &Self, _: &Self) -> Self; /// Returns a blank leaf node. fn blank() -> Self; /// Returns the empty root for the given depth. - fn empty_root(usize) -> Self; + fn empty_root(_: usize) -> Self; } struct PathFiller { @@ -509,7 +509,7 @@ impl CommitmentTreeWitness { #[cfg(test)] mod tests { use super::{CommitmentTree, CommitmentTreeWitness, Hashable, IncrementalWitness, PathFiller}; - use sapling::Node; + use crate::sapling::Node; use ff::PrimeFieldRepr; use hex; diff --git a/zcash_primitives/src/pedersen_hash.rs b/zcash_primitives/src/pedersen_hash.rs index f21b17bfa..0274a1e66 100644 --- a/zcash_primitives/src/pedersen_hash.rs +++ b/zcash_primitives/src/pedersen_hash.rs @@ -1,5 +1,5 @@ use ff::{Field, PrimeField, PrimeFieldRepr}; -use jubjub::*; +use crate::jubjub::*; #[derive(Copy, Clone)] pub enum Personalization { diff --git a/zcash_primitives/src/primitives.rs b/zcash_primitives/src/primitives.rs index d1282b71e..10a6d6b48 100644 --- a/zcash_primitives/src/primitives.rs +++ b/zcash_primitives/src/primitives.rs @@ -1,14 +1,14 @@ use ff::{Field, PrimeField, PrimeFieldRepr}; -use constants; +use crate::constants; -use group_hash::group_hash; +use crate::group_hash::group_hash; -use pedersen_hash::{pedersen_hash, Personalization}; +use crate::pedersen_hash::{pedersen_hash, Personalization}; use byteorder::{LittleEndian, WriteBytesExt}; -use jubjub::{edwards, FixedGenerators, JubjubEngine, JubjubParams, PrimeOrder}; +use crate::jubjub::{edwards, FixedGenerators, JubjubEngine, JubjubParams, PrimeOrder}; use blake2s_simd::Params as Blake2sParams; diff --git a/zcash_primitives/src/redjubjub.rs b/zcash_primitives/src/redjubjub.rs index 370f63d62..6721b5ed7 100644 --- a/zcash_primitives/src/redjubjub.rs +++ b/zcash_primitives/src/redjubjub.rs @@ -6,7 +6,7 @@ use ff::{Field, PrimeField, PrimeFieldRepr}; use rand_core::RngCore; use std::io::{self, Read, Write}; -use util::hash_to_scalar; +use crate::util::hash_to_scalar; fn read_scalar(reader: R) -> io::Result { let mut s_repr = ::Repr::default(); diff --git a/zcash_primitives/src/sapling.rs b/zcash_primitives/src/sapling.rs index 02282d321..d84eec250 100644 --- a/zcash_primitives/src/sapling.rs +++ b/zcash_primitives/src/sapling.rs @@ -12,7 +12,7 @@ use std::io::{self, Read, Write}; use crate::merkle_tree::Hashable; use crate::redjubjub::{PrivateKey, PublicKey, Signature}; -use JUBJUB; +use crate::JUBJUB; pub const SAPLING_COMMITMENT_TREE_DEPTH: usize = 32; diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs index b0e96f59b..244f41b29 100644 --- a/zcash_primitives/src/transaction/builder.rs +++ b/zcash_primitives/src/transaction/builder.rs @@ -7,7 +7,7 @@ use crate::{ use ff::Field; use pairing::bls12_381::{Bls12, Fr}; use rand::{rngs::OsRng, seq::SliceRandom, CryptoRng, RngCore}; -use zip32::ExtendedSpendingKey; +use crate::zip32::ExtendedSpendingKey; use crate::{ keys::OutgoingViewingKey, diff --git a/zcash_primitives/src/transaction/components.rs b/zcash_primitives/src/transaction/components.rs index 7d2ffbbbb..31a7f4e94 100644 --- a/zcash_primitives/src/transaction/components.rs +++ b/zcash_primitives/src/transaction/components.rs @@ -4,9 +4,9 @@ use ff::{PrimeField, PrimeFieldRepr}; use pairing::bls12_381::{Bls12, Fr, FrRepr}; use std::io::{self, Read, Write}; -use legacy::Script; -use redjubjub::{PublicKey, Signature}; -use JUBJUB; +use crate::legacy::Script; +use crate::redjubjub::{PublicKey, Signature}; +use crate::JUBJUB; pub mod amount; pub use self::amount::Amount; diff --git a/zcash_primitives/src/transaction/mod.rs b/zcash_primitives/src/transaction/mod.rs index 6e2d15f8b..319ba8531 100644 --- a/zcash_primitives/src/transaction/mod.rs +++ b/zcash_primitives/src/transaction/mod.rs @@ -5,8 +5,8 @@ use std::fmt; use std::io::{self, Read, Write}; use std::ops::Deref; -use redjubjub::Signature; -use serialize::Vector; +use crate::redjubjub::Signature; +use crate::serialize::Vector; pub mod builder; pub mod components; diff --git a/zcash_primitives/src/transaction/sighash.rs b/zcash_primitives/src/transaction/sighash.rs index b4e9a69aa..1b05658b5 100644 --- a/zcash_primitives/src/transaction/sighash.rs +++ b/zcash_primitives/src/transaction/sighash.rs @@ -7,7 +7,7 @@ use super::{ Transaction, TransactionData, OVERWINTER_VERSION_GROUP_ID, SAPLING_TX_VERSION, SAPLING_VERSION_GROUP_ID, }; -use legacy::Script; +use crate::legacy::Script; const ZCASH_SIGHASH_PERSONALIZATION_PREFIX: &'static [u8; 12] = b"ZcashSigHash"; const ZCASH_PREVOUTS_HASH_PERSONALIZATION: &'static [u8; 16] = b"ZcashPrevoutHash"; diff --git a/zcash_primitives/src/transaction/tests.rs b/zcash_primitives/src/transaction/tests.rs index 7c770c593..d772944fa 100644 --- a/zcash_primitives/src/transaction/tests.rs +++ b/zcash_primitives/src/transaction/tests.rs @@ -5,9 +5,9 @@ use rand_os::OsRng; use crate::jubjub::{fs::Fs, FixedGenerators}; use super::{components::Amount, sighash::signature_hash, Transaction, TransactionData}; -use legacy::Script; -use redjubjub::PrivateKey; -use JUBJUB; +use crate::legacy::Script; +use crate::redjubjub::PrivateKey; +use crate::JUBJUB; #[test] fn tx_read_write() { From cc0fc98c22e89316631d7ed15a0e20f90cc12623 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 17:07:40 -0600 Subject: [PATCH 06/20] cargo fix --edition for pairing --- pairing/src/bls12_381/ec.rs | 8 ++++---- pairing/src/bls12_381/fq.rs | 10 +++++----- pairing/src/bls12_381/fq12.rs | 4 ++-- pairing/src/bls12_381/fq2.rs | 6 +++--- pairing/src/bls12_381/fq6.rs | 4 ++-- pairing/src/bls12_381/fr.rs | 10 +++++----- pairing/src/bls12_381/mod.rs | 2 +- pairing/src/bls12_381/tests/mod.rs | 2 +- pairing/src/lib.rs | 2 +- pairing/src/tests/engine.rs | 2 +- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pairing/src/bls12_381/ec.rs b/pairing/src/bls12_381/ec.rs index 9a78e37d6..3fc2b43a1 100644 --- a/pairing/src/bls12_381/ec.rs +++ b/pairing/src/bls12_381/ec.rs @@ -626,7 +626,7 @@ pub mod g1 { use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError}; use rand_core::RngCore; use std::fmt; - use {Engine, PairingCurveAffine}; + use crate::{Engine, PairingCurveAffine}; curve_impl!( "G1", @@ -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; @@ -1295,7 +1295,7 @@ pub mod g2 { use group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError}; use rand_core::RngCore; use std::fmt; - use {Engine, PairingCurveAffine}; + use crate::{Engine, PairingCurveAffine}; curve_impl!( "G2", @@ -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; diff --git a/pairing/src/bls12_381/fq.rs b/pairing/src/bls12_381/fq.rs index d27254569..08135e3c1 100644 --- a/pairing/src/bls12_381/fq.rs +++ b/pairing/src/bls12_381/fq.rs @@ -2225,10 +2225,10 @@ fn test_fq_root_of_unity() { #[test] fn fq_field_tests() { - ::tests::field::random_field_tests::(); - ::tests::field::random_sqrt_tests::(); - ::tests::field::random_frobenius_tests::(Fq::char(), 13); - ::tests::field::from_str_tests::(); + crate::tests::field::random_field_tests::(); + crate::tests::field::random_sqrt_tests::(); + crate::tests::field::random_frobenius_tests::(Fq::char(), 13); + crate::tests::field::from_str_tests::(); } #[test] @@ -2244,7 +2244,7 @@ fn test_fq_ordering() { #[test] fn fq_repr_tests() { - ::tests::repr::random_repr_tests::(); + crate::tests::repr::random_repr_tests::(); } #[test] diff --git a/pairing/src/bls12_381/fq12.rs b/pairing/src/bls12_381/fq12.rs index dcfdef14f..097b6926c 100644 --- a/pairing/src/bls12_381/fq12.rs +++ b/pairing/src/bls12_381/fq12.rs @@ -187,6 +187,6 @@ fn test_fq12_mul_by_014() { fn fq12_field_tests() { use ff::PrimeField; - ::tests::field::random_field_tests::(); - ::tests::field::random_frobenius_tests::(super::fq::Fq::char(), 13); + crate::tests::field::random_field_tests::(); + crate::tests::field::random_frobenius_tests::(super::fq::Fq::char(), 13); } diff --git a/pairing/src/bls12_381/fq2.rs b/pairing/src/bls12_381/fq2.rs index 781828055..3587d7350 100644 --- a/pairing/src/bls12_381/fq2.rs +++ b/pairing/src/bls12_381/fq2.rs @@ -958,7 +958,7 @@ fn test_fq2_mul_nonresidue() { fn fq2_field_tests() { use ff::PrimeField; - ::tests::field::random_field_tests::(); - ::tests::field::random_sqrt_tests::(); - ::tests::field::random_frobenius_tests::(super::fq::Fq::char(), 13); + crate::tests::field::random_field_tests::(); + crate::tests::field::random_sqrt_tests::(); + crate::tests::field::random_frobenius_tests::(super::fq::Fq::char(), 13); } diff --git a/pairing/src/bls12_381/fq6.rs b/pairing/src/bls12_381/fq6.rs index b85c95d15..0f434ff84 100644 --- a/pairing/src/bls12_381/fq6.rs +++ b/pairing/src/bls12_381/fq6.rs @@ -378,6 +378,6 @@ fn test_fq6_mul_by_01() { fn fq6_field_tests() { use ff::PrimeField; - ::tests::field::random_field_tests::(); - ::tests::field::random_frobenius_tests::(super::fq::Fq::char(), 13); + crate::tests::field::random_field_tests::(); + crate::tests::field::random_frobenius_tests::(super::fq::Fq::char(), 13); } diff --git a/pairing/src/bls12_381/fr.rs b/pairing/src/bls12_381/fr.rs index 018e67a6e..76f3ffe07 100644 --- a/pairing/src/bls12_381/fr.rs +++ b/pairing/src/bls12_381/fr.rs @@ -1015,13 +1015,13 @@ fn test_fr_root_of_unity() { #[test] fn fr_field_tests() { - ::tests::field::random_field_tests::(); - ::tests::field::random_sqrt_tests::(); - ::tests::field::random_frobenius_tests::(Fr::char(), 13); - ::tests::field::from_str_tests::(); + crate::tests::field::random_field_tests::(); + crate::tests::field::random_sqrt_tests::(); + crate::tests::field::random_frobenius_tests::(Fr::char(), 13); + crate::tests::field::from_str_tests::(); } #[test] fn fr_repr_tests() { - ::tests::repr::random_repr_tests::(); + crate::tests::repr::random_repr_tests::(); } diff --git a/pairing/src/bls12_381/mod.rs b/pairing/src/bls12_381/mod.rs index deb6ffc6c..8fc6bbdfd 100644 --- a/pairing/src/bls12_381/mod.rs +++ b/pairing/src/bls12_381/mod.rs @@ -366,5 +366,5 @@ impl G2Prepared { #[test] fn bls12_engine_tests() { - ::tests::engine::engine_tests::(); + crate::tests::engine::engine_tests::(); } diff --git a/pairing/src/bls12_381/tests/mod.rs b/pairing/src/bls12_381/tests/mod.rs index b5b75a330..636fcfef7 100644 --- a/pairing/src/bls12_381/tests/mod.rs +++ b/pairing/src/bls12_381/tests/mod.rs @@ -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() { diff --git a/pairing/src/lib.rs b/pairing/src/lib.rs index 952185c74..4e1110719 100644 --- a/pairing/src/lib.rs +++ b/pairing/src/lib.rs @@ -87,7 +87,7 @@ pub trait Engine: ScalarEngine { >; /// Perform final exponentiation of the result of a miller loop. - fn final_exponentiation(&Self::Fqk) -> Option; + fn final_exponentiation(_: &Self::Fqk) -> Option; /// Performs a complete pairing operation `(p, q)`. fn pairing(p: G1, q: G2) -> Self::Fqk diff --git a/pairing/src/tests/engine.rs b/pairing/src/tests/engine.rs index fc74f1bbe..b6ae50edb 100644 --- a/pairing/src/tests/engine.rs +++ b/pairing/src/tests/engine.rs @@ -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() { let mut rng = XorShiftRng::from_seed([ From f523ac285d8759773592b2bf1b93fd442269d8ba Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 17:17:21 -0600 Subject: [PATCH 07/20] cargo fmt --- bellman/src/groth16/mod.rs | 2 +- pairing/src/bls12_381/ec.rs | 4 ++-- zcash_primitives/src/group_hash.rs | 2 +- zcash_primitives/src/pedersen_hash.rs | 2 +- zcash_primitives/src/transaction/builder.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bellman/src/groth16/mod.rs b/bellman/src/groth16/mod.rs index 428176bf9..9fa3bc880 100644 --- a/bellman/src/groth16/mod.rs +++ b/bellman/src/groth16/mod.rs @@ -3,8 +3,8 @@ use pairing::{Engine, PairingCurveAffine}; use crate::SynthesisError; -use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use crate::multiexp::SourceBuilder; +use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use std::io::{self, Read, Write}; use std::sync::Arc; diff --git a/pairing/src/bls12_381/ec.rs b/pairing/src/bls12_381/ec.rs index 3fc2b43a1..675999167 100644 --- a/pairing/src/bls12_381/ec.rs +++ b/pairing/src/bls12_381/ec.rs @@ -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 crate::{Engine, PairingCurveAffine}; curve_impl!( "G1", @@ -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 crate::{Engine, PairingCurveAffine}; curve_impl!( "G2", diff --git a/zcash_primitives/src/group_hash.rs b/zcash_primitives/src/group_hash.rs index e67ca4905..8549c5e3e 100644 --- a/zcash_primitives/src/group_hash.rs +++ b/zcash_primitives/src/group_hash.rs @@ -2,8 +2,8 @@ use crate::jubjub::{edwards, JubjubEngine, PrimeOrder}; use ff::PrimeField; -use blake2s_simd::Params; use crate::constants; +use blake2s_simd::Params; /// Produces a random point in the Jubjub curve. /// The point is guaranteed to be prime order diff --git a/zcash_primitives/src/pedersen_hash.rs b/zcash_primitives/src/pedersen_hash.rs index 0274a1e66..835e9c730 100644 --- a/zcash_primitives/src/pedersen_hash.rs +++ b/zcash_primitives/src/pedersen_hash.rs @@ -1,5 +1,5 @@ -use ff::{Field, PrimeField, PrimeFieldRepr}; use crate::jubjub::*; +use ff::{Field, PrimeField, PrimeFieldRepr}; #[derive(Copy, Clone)] pub enum Personalization { diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs index 244f41b29..a5df4c878 100644 --- a/zcash_primitives/src/transaction/builder.rs +++ b/zcash_primitives/src/transaction/builder.rs @@ -1,5 +1,6 @@ //! Structs for building transactions. +use crate::zip32::ExtendedSpendingKey; use crate::{ jubjub::fs::Fs, primitives::{Diversifier, Note, PaymentAddress}, @@ -7,7 +8,6 @@ use crate::{ use ff::Field; use pairing::bls12_381::{Bls12, Fr}; use rand::{rngs::OsRng, seq::SliceRandom, CryptoRng, RngCore}; -use crate::zip32::ExtendedSpendingKey; use crate::{ keys::OutgoingViewingKey, From 7809711a81074e021b1db354c9243d67f8603cc2 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 18:19:11 -0600 Subject: [PATCH 08/20] cargo fix --edition for librustzcash --- librustzcash/src/tests/key_agreement.rs | 2 +- librustzcash/src/tests/key_components.rs | 2 +- librustzcash/src/tests/notes.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/librustzcash/src/tests/key_agreement.rs b/librustzcash/src/tests/key_agreement.rs index ab1cc8414..d942e1085 100644 --- a/librustzcash/src/tests/key_agreement.rs +++ b/librustzcash/src/tests/key_agreement.rs @@ -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, }; diff --git a/librustzcash/src/tests/key_components.rs b/librustzcash/src/tests/key_components.rs index 99d3f524c..a034b9f1b 100644 --- a/librustzcash/src/tests/key_components.rs +++ b/librustzcash/src/tests/key_components.rs @@ -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, }; diff --git a/librustzcash/src/tests/notes.rs b/librustzcash/src/tests/notes.rs index 6f8c0f589..6b48b5ff8 100644 --- a/librustzcash/src/tests/notes.rs +++ b/librustzcash/src/tests/notes.rs @@ -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() { From b35a819a091f32f571a147bf99830c50cb2fb0a8 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 18:24:47 -0600 Subject: [PATCH 09/20] Replace try! macro --- ff/ff_derive/src/lib.rs | 8 ++++---- zcash_primitives/src/jubjub/fs.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ff/ff_derive/src/lib.rs b/ff/ff_derive/src/lib.rs index 5f8e64267..8801a9122 100644 --- a/ff/ff_derive/src/lib.rs +++ b/ff/ff_derive/src/lib.rs @@ -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(()) @@ -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(()) diff --git a/zcash_primitives/src/jubjub/fs.rs b/zcash_primitives/src/jubjub/fs.rs index 90a179f1f..fc14a86de 100644 --- a/zcash_primitives/src/jubjub/fs.rs +++ b/zcash_primitives/src/jubjub/fs.rs @@ -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 { - r#try!(write!(f, "0x")); + r#write!(f, "0x")?; for i in self.0.iter().rev() { - r#try!(write!(f, "{:016x}", *i)); + r#write!(f, "{:016x}", *i)?; } Ok(()) From 09882c6d08fdd323f6dd16729dc00ffba56adb8c Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 18:31:20 -0600 Subject: [PATCH 10/20] Add edition = 2018 --- bellman/Cargo.toml | 1 + ff/Cargo.toml | 1 + ff/ff_derive/Cargo.toml | 1 + group/Cargo.toml | 1 + librustzcash/Cargo.toml | 3 ++- pairing/Cargo.toml | 1 + zcash_primitives/Cargo.toml | 1 + 7 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bellman/Cargo.toml b/bellman/Cargo.toml index 70521e7fb..f21e4e11c 100644 --- a/bellman/Cargo.toml +++ b/bellman/Cargo.toml @@ -7,6 +7,7 @@ license = "MIT/Apache-2.0" name = "bellman" repository = "https://github.com/ebfull/bellman" version = "0.1.0" +edition = "2018" [dependencies] bit-vec = "0.4.4" diff --git a/ff/Cargo.toml b/ff/Cargo.toml index 212f6c43d..93dfb9fa8 100644 --- a/ff/Cargo.toml +++ b/ff/Cargo.toml @@ -7,6 +7,7 @@ documentation = "https://docs.rs/ff/" homepage = "https://github.com/ebfull/ff" license = "MIT/Apache-2.0" repository = "https://github.com/ebfull/ff" +edition = "2018" [dependencies] byteorder = "1" diff --git a/ff/ff_derive/Cargo.toml b/ff/ff_derive/Cargo.toml index 914e39258..e822460f6 100644 --- a/ff/ff_derive/Cargo.toml +++ b/ff/ff_derive/Cargo.toml @@ -7,6 +7,7 @@ documentation = "https://docs.rs/ff/" homepage = "https://github.com/ebfull/ff" license = "MIT/Apache-2.0" repository = "https://github.com/ebfull/ff" +edition = "2018" [lib] proc-macro = true diff --git a/group/Cargo.toml b/group/Cargo.toml index 7d2d5317b..2b09f097a 100644 --- a/group/Cargo.toml +++ b/group/Cargo.toml @@ -11,6 +11,7 @@ description = "Elliptic curve group traits and utilities" documentation = "https://docs.rs/group/" homepage = "https://github.com/ebfull/group" repository = "https://github.com/ebfull/group" +edition = "2018" [dependencies] ff = { path = "../ff" } diff --git a/librustzcash/Cargo.toml b/librustzcash/Cargo.toml index 3256d14a2..8290191ef 100644 --- a/librustzcash/Cargo.toml +++ b/librustzcash/Cargo.toml @@ -6,7 +6,8 @@ authors = [ "Jack Grigg ", "Jay Graber ", "Simon Liu " - ] +] +edition = "2018" [lib] name = "rustzcash" diff --git a/pairing/Cargo.toml b/pairing/Cargo.toml index 759fd3d0f..8fadb3297 100644 --- a/pairing/Cargo.toml +++ b/pairing/Cargo.toml @@ -13,6 +13,7 @@ description = "Pairing-friendly elliptic curve library" documentation = "https://docs.rs/pairing/" homepage = "https://github.com/ebfull/pairing" repository = "https://github.com/ebfull/pairing" +edition ="2018" [dependencies] byteorder = "1" diff --git a/zcash_primitives/Cargo.toml b/zcash_primitives/Cargo.toml index b3173b7d2..5e1bf9139 100644 --- a/zcash_primitives/Cargo.toml +++ b/zcash_primitives/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = [ "Jack Grigg ", ] +edition = "2018" [dependencies] aes = "0.3" From 4b021fcf4d70296750258ce03186b83fc631093a Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 22:01:46 -0600 Subject: [PATCH 11/20] cargo fix --edition-idioms for ff --- ff/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ff/src/lib.rs b/ff/src/lib.rs index fd1a5023e..14e3594d3 100644 --- a/ff/src/lib.rs +++ b/ff/src/lib.rs @@ -1,7 +1,7 @@ #![allow(unused_imports)] -extern crate byteorder; -extern crate rand_core; + + #[cfg(feature = "derive")] #[macro_use] @@ -210,7 +210,7 @@ impl Error for PrimeFieldDecodingError { } impl fmt::Display for PrimeFieldDecodingError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { match *self { PrimeFieldDecodingError::NotInField(ref repr) => { write!(f, "{} is not an element of the field", repr) From a5f25c50589b21f38aa6cc446423934fefdfbfa0 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 22:07:24 -0600 Subject: [PATCH 12/20] cargo fix --edition-idioms for bellman --- bellman/src/groth16/tests/dummy_engine.rs | 4 +-- bellman/src/lib.rs | 30 ++++++++++------------- bellman/src/multiexp.rs | 4 +-- bellman/tests/mimc.rs | 8 +++--- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/bellman/src/groth16/tests/dummy_engine.rs b/bellman/src/groth16/tests/dummy_engine.rs index 4c5874d71..46920786a 100644 --- a/bellman/src/groth16/tests/dummy_engine.rs +++ b/bellman/src/groth16/tests/dummy_engine.rs @@ -16,7 +16,7 @@ const MODULUS_R: Wrapping = Wrapping(64513); pub struct Fr(Wrapping); impl fmt::Display for Fr { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "{}", (self.0).0) } } @@ -149,7 +149,7 @@ impl PartialOrd for FrRepr { } impl fmt::Display for FrRepr { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "{}", (self.0)[0]) } } diff --git a/bellman/src/lib.rs b/bellman/src/lib.rs index 96400c9fe..e8ebaae93 100644 --- a/bellman/src/lib.rs +++ b/bellman/src/lib.rs @@ -1,18 +1,16 @@ -extern crate ff; -extern crate group; -#[cfg(feature = "pairing")] -extern crate pairing; -extern crate rand_core; -extern crate bit_vec; -extern crate blake2s_simd; -extern crate byteorder; -extern crate futures; + + + + + + + + #[cfg(feature = "multicore")] extern crate crossbeam; -#[cfg(feature = "multicore")] -extern crate futures_cpupool; + #[cfg(feature = "multicore")] extern crate num_cpus; @@ -23,11 +21,9 @@ extern crate hex_literal; #[cfg(test)] extern crate rand; -#[cfg(test)] -extern crate rand_xorshift; -#[cfg(test)] -extern crate sha2; + + pub mod domain; pub mod gadgets; @@ -230,7 +226,7 @@ impl Error for SynthesisError { } impl fmt::Display for SynthesisError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { if let &SynthesisError::IoError(ref e) = self { write!(f, "I/O error: ")?; e.fmt(f) @@ -309,7 +305,7 @@ pub trait ConstraintSystem: Sized { /// This is a "namespaced" constraint system which borrows a constraint system (pushing /// a namespace context) and, when dropped, pops out of the namespace context. -pub struct Namespace<'a, E: ScalarEngine, CS: ConstraintSystem + 'a>(&'a mut CS, PhantomData); +pub struct Namespace<'a, E: ScalarEngine, CS: ConstraintSystem>(&'a mut CS, PhantomData); impl<'cs, E: ScalarEngine, CS: ConstraintSystem> ConstraintSystem for Namespace<'cs, E, CS> { type Root = CS::Root; diff --git a/bellman/src/multiexp.rs b/bellman/src/multiexp.rs index fabb97853..b7729a868 100644 --- a/bellman/src/multiexp.rs +++ b/bellman/src/multiexp.rs @@ -153,7 +153,7 @@ fn multiexp_inner( mut skip: u32, c: u32, handle_trivial: bool, -) -> Box::Projective, Error = SynthesisError>> +) -> Box::Projective, Error = SynthesisError>> where for<'a> &'a Q: QueryDensity, D: Send + Sync + 'static + Clone + AsRef, @@ -256,7 +256,7 @@ pub fn multiexp( bases: S, density_map: D, exponents: Arc::Fr as PrimeField>::Repr>>, -) -> Box::Projective, Error = SynthesisError>> +) -> Box::Projective, Error = SynthesisError>> where for<'a> &'a Q: QueryDensity, D: Send + Sync + 'static + Clone + AsRef, diff --git a/bellman/tests/mimc.rs b/bellman/tests/mimc.rs index 94c0d63bb..7db26a5ab 100644 --- a/bellman/tests/mimc.rs +++ b/bellman/tests/mimc.rs @@ -1,7 +1,7 @@ -extern crate bellman; -extern crate ff; -extern crate pairing; -extern crate rand; + + + + // For randomness (during paramgen and proof generation) use rand::thread_rng; From 07c690cf73f89c69f9882d36bd16db1d83ab160f Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 22:08:10 -0600 Subject: [PATCH 13/20] cargo fix --edition-idioms for group --- group/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/group/src/lib.rs b/group/src/lib.rs index 448c5a347..ab8ac0e51 100644 --- a/group/src/lib.rs +++ b/group/src/lib.rs @@ -1,6 +1,6 @@ -extern crate ff; -extern crate rand; -extern crate rand_xorshift; + + + use ff::{PrimeField, PrimeFieldDecodingError, ScalarEngine, SqrtField}; use rand::RngCore; @@ -180,7 +180,7 @@ impl Error for GroupDecodingError { } impl fmt::Display for GroupDecodingError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { match *self { GroupDecodingError::CoordinateDecodingError(description, ref err) => { write!(f, "{} decoding error: {}", description, err) From 9807a5c1cc3bb98d0c122f58f7a3f3c559d32864 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 22:16:40 -0600 Subject: [PATCH 14/20] cargo fix --edition-idioms for pairing --- pairing/src/bls12_381/ec.rs | 12 ++++++------ pairing/src/bls12_381/fq12.rs | 2 +- pairing/src/bls12_381/fq2.rs | 2 +- pairing/src/bls12_381/fq6.rs | 2 +- pairing/src/lib.rs | 11 +++++------ 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pairing/src/bls12_381/ec.rs b/pairing/src/bls12_381/ec.rs index 675999167..6bebc246b 100644 --- a/pairing/src/bls12_381/ec.rs +++ b/pairing/src/bls12_381/ec.rs @@ -18,7 +18,7 @@ macro_rules! curve_impl { } impl ::std::fmt::Display for $affine { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { if self.infinity { write!(f, "{}(Infinity)", $name) } else { @@ -35,7 +35,7 @@ macro_rules! curve_impl { } 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()) } } @@ -656,7 +656,7 @@ pub mod g1 { } impl fmt::Debug for G1Uncompressed { - fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { self.0[..].fmt(formatter) } } @@ -766,7 +766,7 @@ pub mod g1 { } impl fmt::Debug for G1Compressed { - fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { self.0[..].fmt(formatter) } } @@ -1325,7 +1325,7 @@ pub mod g2 { } impl fmt::Debug for G2Uncompressed { - fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { self.0[..].fmt(formatter) } } @@ -1451,7 +1451,7 @@ pub mod g2 { } impl fmt::Debug for G2Compressed { - fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { self.0[..].fmt(formatter) } } diff --git a/pairing/src/bls12_381/fq12.rs b/pairing/src/bls12_381/fq12.rs index 097b6926c..0d6e066ef 100644 --- a/pairing/src/bls12_381/fq12.rs +++ b/pairing/src/bls12_381/fq12.rs @@ -12,7 +12,7 @@ pub struct Fq12 { } impl ::std::fmt::Display for Fq12 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { write!(f, "Fq12({} + {} * w)", self.c0, self.c1) } } diff --git a/pairing/src/bls12_381/fq2.rs b/pairing/src/bls12_381/fq2.rs index 3587d7350..c115dd210 100644 --- a/pairing/src/bls12_381/fq2.rs +++ b/pairing/src/bls12_381/fq2.rs @@ -12,7 +12,7 @@ pub struct Fq2 { } impl ::std::fmt::Display for Fq2 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { write!(f, "Fq2({} + {} * u)", self.c0, self.c1) } } diff --git a/pairing/src/bls12_381/fq6.rs b/pairing/src/bls12_381/fq6.rs index 0f434ff84..e2b49c992 100644 --- a/pairing/src/bls12_381/fq6.rs +++ b/pairing/src/bls12_381/fq6.rs @@ -12,7 +12,7 @@ pub struct Fq6 { } impl ::std::fmt::Display for Fq6 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { write!(f, "Fq6({} + {} * v, {} * v^2)", self.c0, self.c1, self.c2) } } diff --git a/pairing/src/lib.rs b/pairing/src/lib.rs index 4e1110719..4c1f6b742 100644 --- a/pairing/src/lib.rs +++ b/pairing/src/lib.rs @@ -11,13 +11,12 @@ // Force public structures to implement Debug #![deny(missing_debug_implementations)] -extern crate byteorder; -extern crate ff; -extern crate group; -extern crate rand_core; -#[cfg(test)] -extern crate rand_xorshift; + + + + + #[cfg(test)] pub mod tests; From 573ffc4e062d5fda7bcb7337a5ede972d6e34af6 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 22:17:29 -0600 Subject: [PATCH 15/20] cargo fix --edition-idioms for librustzcash --- librustzcash/src/rustzcash.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/librustzcash/src/rustzcash.rs b/librustzcash/src/rustzcash.rs index 0697272a4..8d95880eb 100644 --- a/librustzcash/src/rustzcash.rs +++ b/librustzcash/src/rustzcash.rs @@ -1,16 +1,16 @@ -extern crate bellman; -extern crate blake2b_simd; -extern crate blake2s_simd; -extern crate byteorder; -extern crate ff; -extern crate libc; -extern crate pairing; -extern crate rand_core; -extern crate rand_os; -extern crate zcash_primitives; -extern crate zcash_proofs; -extern crate lazy_static; + + + + + + + + + + + +use lazy_static; use ff::{PrimeField, PrimeFieldRepr}; use pairing::bls12_381::{Bls12, Fr, FrRepr}; From c28ae31c71563e37f5eae088e01bbd25f59fe004 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 22:20:22 -0600 Subject: [PATCH 16/20] cargo fix --edition-idioms for zcash_primitives --- zcash_primitives/src/block.rs | 2 +- zcash_primitives/src/jubjub/fs.rs | 4 +-- zcash_primitives/src/lib.rs | 29 +++++++++---------- .../src/transaction/components.rs | 8 ++--- zcash_primitives/src/transaction/mod.rs | 4 +-- zcash_primitives/src/zip32.rs | 4 +-- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/zcash_primitives/src/block.rs b/zcash_primitives/src/block.rs index c0eb92fde..f2802b4a9 100644 --- a/zcash_primitives/src/block.rs +++ b/zcash_primitives/src/block.rs @@ -10,7 +10,7 @@ use crate::serialize::Vector; pub struct BlockHash(pub [u8; 32]); impl fmt::Display for BlockHash { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let mut data = self.0.clone(); data.reverse(); formatter.write_str(&hex::encode(data)) diff --git a/zcash_primitives/src/jubjub/fs.rs b/zcash_primitives/src/jubjub/fs.rs index fc14a86de..b3c61dc87 100644 --- a/zcash_primitives/src/jubjub/fs.rs +++ b/zcash_primitives/src/jubjub/fs.rs @@ -74,7 +74,7 @@ const NEGATIVE_ONE: Fs = Fs(FsRepr([ pub struct FsRepr(pub [u64; 4]); impl ::std::fmt::Display for FsRepr { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { r#write!(f, "0x")?; for i in self.0.iter().rev() { r#write!(f, "{:016x}", *i)?; @@ -257,7 +257,7 @@ impl PrimeFieldRepr for FsRepr { pub struct Fs(FsRepr); impl ::std::fmt::Display for Fs { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { write!(f, "Fs({})", self.into_repr()) } } diff --git a/zcash_primitives/src/lib.rs b/zcash_primitives/src/lib.rs index 8bc5fe840..5dd5f5865 100644 --- a/zcash_primitives/src/lib.rs +++ b/zcash_primitives/src/lib.rs @@ -1,26 +1,25 @@ #[macro_use] extern crate lazy_static; -extern crate aes; -extern crate blake2b_simd; -extern crate blake2s_simd; -extern crate byteorder; -extern crate crypto_api_chachapoly; -extern crate ff; -extern crate fpe; -extern crate hex; -extern crate pairing; -extern crate rand; -extern crate rand_core; -extern crate rand_os; -extern crate sha2; + + + + + + + + + + + + + #[cfg(test)] #[macro_use] extern crate hex_literal; -#[cfg(test)] -extern crate rand_xorshift; + pub mod block; pub mod constants; diff --git a/zcash_primitives/src/transaction/components.rs b/zcash_primitives/src/transaction/components.rs index 31a7f4e94..001ff42ce 100644 --- a/zcash_primitives/src/transaction/components.rs +++ b/zcash_primitives/src/transaction/components.rs @@ -104,7 +104,7 @@ pub struct SpendDescription { } impl std::fmt::Debug for SpendDescription { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "SpendDescription(cv = {:?}, anchor = {:?}, nullifier = {:?}, rk = {:?}, spend_auth_sig = {:?})", @@ -186,7 +186,7 @@ pub struct OutputDescription { } impl std::fmt::Debug for OutputDescription { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "OutputDescription(cv = {:?}, cmu = {:?}, ephemeral_key = {:?})", @@ -253,7 +253,7 @@ enum SproutProof { } impl std::fmt::Debug for SproutProof { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { match self { SproutProof::Groth(_) => write!(f, "SproutProof::Groth"), SproutProof::PHGR(_) => write!(f, "SproutProof::PHGR"), @@ -275,7 +275,7 @@ pub struct JSDescription { } impl std::fmt::Debug for JSDescription { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "JSDescription( diff --git a/zcash_primitives/src/transaction/mod.rs b/zcash_primitives/src/transaction/mod.rs index 319ba8531..567d68971 100644 --- a/zcash_primitives/src/transaction/mod.rs +++ b/zcash_primitives/src/transaction/mod.rs @@ -28,7 +28,7 @@ const SAPLING_TX_VERSION: u32 = 4; pub struct TxId(pub [u8; 32]); impl fmt::Display for TxId { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let mut data = self.0.clone(); data.reverse(); formatter.write_str(&hex::encode(data)) @@ -74,7 +74,7 @@ pub struct TransactionData { } impl std::fmt::Debug for TransactionData { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "TransactionData( diff --git a/zcash_primitives/src/zip32.rs b/zcash_primitives/src/zip32.rs index 74124068d..8788809c2 100644 --- a/zcash_primitives/src/zip32.rs +++ b/zcash_primitives/src/zip32.rs @@ -198,7 +198,7 @@ impl std::cmp::PartialEq for ExtendedSpendingKey { } impl std::fmt::Debug for ExtendedSpendingKey { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "ExtendedSpendingKey(d = {}, tag_p = {:?}, i = {:?})", @@ -221,7 +221,7 @@ impl std::cmp::PartialEq for ExtendedFullViewingKey { } impl std::fmt::Debug for ExtendedFullViewingKey { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { write!( f, "ExtendedFullViewingKey(d = {}, tag_p = {:?}, i = {:?})", From 76795a90149f0c3ed9e1c53d2b40d653c724c197 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 20 Aug 2019 22:22:03 -0600 Subject: [PATCH 17/20] cargo fmt --- bellman/src/lib.rs | 14 -------------- bellman/tests/mimc.rs | 5 ----- ff/src/lib.rs | 3 --- group/src/lib.rs | 4 ---- librustzcash/src/rustzcash.rs | 12 ------------ pairing/src/lib.rs | 7 ------- zcash_primitives/src/lib.rs | 16 ---------------- 7 files changed, 61 deletions(-) diff --git a/bellman/src/lib.rs b/bellman/src/lib.rs index e8ebaae93..a75c85f27 100644 --- a/bellman/src/lib.rs +++ b/bellman/src/lib.rs @@ -1,13 +1,3 @@ - - - - - - - - - - #[cfg(feature = "multicore")] extern crate crossbeam; @@ -21,10 +11,6 @@ extern crate hex_literal; #[cfg(test)] extern crate rand; - - - - pub mod domain; pub mod gadgets; #[cfg(feature = "groth16")] diff --git a/bellman/tests/mimc.rs b/bellman/tests/mimc.rs index 7db26a5ab..e9a4c7c70 100644 --- a/bellman/tests/mimc.rs +++ b/bellman/tests/mimc.rs @@ -1,8 +1,3 @@ - - - - - // For randomness (during paramgen and proof generation) use rand::thread_rng; diff --git a/ff/src/lib.rs b/ff/src/lib.rs index 14e3594d3..fb692c2f3 100644 --- a/ff/src/lib.rs +++ b/ff/src/lib.rs @@ -1,8 +1,5 @@ #![allow(unused_imports)] - - - #[cfg(feature = "derive")] #[macro_use] extern crate ff_derive; diff --git a/group/src/lib.rs b/group/src/lib.rs index ab8ac0e51..0d50f8a8e 100644 --- a/group/src/lib.rs +++ b/group/src/lib.rs @@ -1,7 +1,3 @@ - - - - use ff::{PrimeField, PrimeFieldDecodingError, ScalarEngine, SqrtField}; use rand::RngCore; use std::error::Error; diff --git a/librustzcash/src/rustzcash.rs b/librustzcash/src/rustzcash.rs index 8d95880eb..ea1676d85 100644 --- a/librustzcash/src/rustzcash.rs +++ b/librustzcash/src/rustzcash.rs @@ -1,15 +1,3 @@ - - - - - - - - - - - - use lazy_static; use ff::{PrimeField, PrimeFieldRepr}; diff --git a/pairing/src/lib.rs b/pairing/src/lib.rs index 4c1f6b742..b5b46e31a 100644 --- a/pairing/src/lib.rs +++ b/pairing/src/lib.rs @@ -11,13 +11,6 @@ // Force public structures to implement Debug #![deny(missing_debug_implementations)] - - - - - - - #[cfg(test)] pub mod tests; diff --git a/zcash_primitives/src/lib.rs b/zcash_primitives/src/lib.rs index 5dd5f5865..644d7fb34 100644 --- a/zcash_primitives/src/lib.rs +++ b/zcash_primitives/src/lib.rs @@ -1,26 +1,10 @@ #[macro_use] extern crate lazy_static; - - - - - - - - - - - - - - #[cfg(test)] #[macro_use] extern crate hex_literal; - - pub mod block; pub mod constants; pub mod group_hash; From fec961777c000b80b60384b8b3b13798ae6565a3 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Wed, 21 Aug 2019 16:11:29 -0600 Subject: [PATCH 18/20] Add edition = 2018 to zcash_proofs --- zcash_proofs/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/zcash_proofs/Cargo.toml b/zcash_proofs/Cargo.toml index b7fa65995..766db6306 100644 --- a/zcash_proofs/Cargo.toml +++ b/zcash_proofs/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = [ "Jack Grigg ", ] +edition = "2018" [dependencies] bellman = { path = "../bellman" } From 53182aa08e305de43464729a372ea4cb7d36c3cd Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Wed, 21 Aug 2019 16:13:10 -0600 Subject: [PATCH 19/20] cargo fix --edition-idioms for zcash_proofs --- zcash_proofs/examples/bench.rs | 8 -------- zcash_proofs/src/lib.rs | 17 ----------------- 2 files changed, 25 deletions(-) diff --git a/zcash_proofs/examples/bench.rs b/zcash_proofs/examples/bench.rs index a5c8a1300..62beb0aa2 100644 --- a/zcash_proofs/examples/bench.rs +++ b/zcash_proofs/examples/bench.rs @@ -1,11 +1,3 @@ -extern crate bellman; -extern crate ff; -extern crate pairing; -extern crate rand_core; -extern crate rand_xorshift; -extern crate zcash_primitives; -extern crate zcash_proofs; - use bellman::groth16::*; use ff::Field; use pairing::bls12_381::{Bls12, Fr}; diff --git a/zcash_proofs/src/lib.rs b/zcash_proofs/src/lib.rs index 385148184..a83964abd 100644 --- a/zcash_proofs/src/lib.rs +++ b/zcash_proofs/src/lib.rs @@ -1,20 +1,3 @@ -extern crate bellman; -extern crate blake2b_simd; -extern crate byteorder; -extern crate ff; -extern crate pairing; -extern crate rand_os; -extern crate zcash_primitives; - -#[cfg(feature = "local-prover")] -extern crate directories; - -#[cfg(test)] -extern crate rand_core; - -#[cfg(test)] -extern crate rand_xorshift; - use bellman::groth16::{prepare_verifying_key, Parameters, PreparedVerifyingKey, VerifyingKey}; use pairing::bls12_381::Bls12; use std::fs::File; From d63fa334ff3a3699fbf609573e5822abc21940d2 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Wed, 21 Aug 2019 16:14:28 -0600 Subject: [PATCH 20/20] Remove unnecessary raw marker Co-Authored-By: str4d --- zcash_primitives/src/jubjub/fs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zcash_primitives/src/jubjub/fs.rs b/zcash_primitives/src/jubjub/fs.rs index b3c61dc87..0d1578ede 100644 --- a/zcash_primitives/src/jubjub/fs.rs +++ b/zcash_primitives/src/jubjub/fs.rs @@ -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 { - r#write!(f, "0x")?; + write!(f, "0x")?; for i in self.0.iter().rev() { - r#write!(f, "{:016x}", *i)?; + write!(f, "{:016x}", *i)?; } Ok(())