From 6fdca79e895008924e82e5f31098c873edf5f59b Mon Sep 17 00:00:00 2001 From: intx4 Date: Mon, 25 Mar 2024 21:50:27 +0100 Subject: [PATCH] removed redundant imports (nightly build tests) --- .../src/commitment/blake2s/constraints.rs | 1 - .../src/commitment/pedersen/constraints.rs | 1 - .../src/commitment/pedersen/mod.rs | 2 +- .../src/crh/bowe_hopwood/constraints.rs | 16 +++++--------- crypto-primitives/src/crh/bowe_hopwood/mod.rs | 2 +- .../src/crh/injective_map/constraints.rs | 4 +--- .../src/crh/pedersen/constraints.rs | 9 +++----- crypto-primitives/src/crh/pedersen/mod.rs | 2 +- .../src/crh/poseidon/constraints.rs | 1 + .../src/crh/sha256/constraints.rs | 12 ++-------- crypto-primitives/src/crh/sha256/mod.rs | 2 +- .../src/encryption/elgamal/constraints.rs | 2 +- .../src/merkle_tree/constraints.rs | 1 - crypto-primitives/src/merkle_tree/mod.rs | 1 - .../src/merkle_tree/tests/mod.rs | 9 +++----- .../src/prf/blake2s/constraints.rs | 2 +- crypto-primitives/src/prf/blake2s/mod.rs | 1 - crypto-primitives/src/prf/constraints.rs | 2 +- crypto-primitives/src/signature/mod.rs | 4 ++-- .../src/signature/schnorr/constraints.rs | 1 - .../src/signature/schnorr/mod.rs | 2 +- crypto-primitives/src/snark/constraints.rs | 22 ++++++------------- crypto-primitives/src/sponge/absorb.rs | 5 ++--- .../src/sponge/constraints/absorb.rs | 3 +-- .../src/sponge/constraints/mod.rs | 3 +-- crypto-primitives/src/sponge/mod.rs | 1 - .../src/sponge/poseidon/constraints.rs | 2 -- .../src/sponge/poseidon/grain_lfsr.rs | 2 +- crypto-primitives/src/sponge/poseidon/mod.rs | 3 +-- .../src/sponge/poseidon/traits.rs | 3 +-- 30 files changed, 39 insertions(+), 82 deletions(-) diff --git a/crypto-primitives/src/commitment/blake2s/constraints.rs b/crypto-primitives/src/commitment/blake2s/constraints.rs index f38b7378..07f28ca8 100644 --- a/crypto-primitives/src/commitment/blake2s/constraints.rs +++ b/crypto-primitives/src/commitment/blake2s/constraints.rs @@ -3,7 +3,6 @@ use ark_relations::r1cs::{Namespace, SynthesisError}; use crate::{ commitment::{blake2s, CommitmentGadget}, prf::blake2s::constraints::{evaluate_blake2s, OutputVar}, - Vec, }; use ark_ff::{Field, PrimeField}; use ark_r1cs_std::prelude::*; diff --git a/crypto-primitives/src/commitment/pedersen/constraints.rs b/crypto-primitives/src/commitment/pedersen/constraints.rs index f077e295..8386815d 100644 --- a/crypto-primitives/src/commitment/pedersen/constraints.rs +++ b/crypto-primitives/src/commitment/pedersen/constraints.rs @@ -1,7 +1,6 @@ use crate::{ commitment::pedersen::{Commitment, Parameters, Randomness}, crh::pedersen::Window, - Vec, }; use ark_ec::CurveGroup; use ark_ff::{ diff --git a/crypto-primitives/src/commitment/pedersen/mod.rs b/crypto-primitives/src/commitment/pedersen/mod.rs index 6782e9c6..cfcdab74 100644 --- a/crypto-primitives/src/commitment/pedersen/mod.rs +++ b/crypto-primitives/src/commitment/pedersen/mod.rs @@ -1,4 +1,4 @@ -use crate::{crh::CRHScheme, Error, Vec}; +use crate::{crh::CRHScheme, Error}; use ark_ec::CurveGroup; use ark_ff::{BitIteratorLE, Field, PrimeField, ToConstraintField}; use ark_serialize::CanonicalSerialize; diff --git a/crypto-primitives/src/crh/bowe_hopwood/constraints.rs b/crypto-primitives/src/crh/bowe_hopwood/constraints.rs index e1f6f487..e5eef789 100644 --- a/crypto-primitives/src/crh/bowe_hopwood/constraints.rs +++ b/crypto-primitives/src/crh/bowe_hopwood/constraints.rs @@ -2,22 +2,16 @@ use ark_ec::twisted_edwards::{Projective as TEProjective, TECurveConfig}; use ark_ec::CurveConfig; use core::{borrow::Borrow, iter, marker::PhantomData}; -use crate::{ - crh::{ - bowe_hopwood::{Parameters, CHUNK_SIZE}, - pedersen::{self, Window}, - CRHSchemeGadget, TwoToOneCRHSchemeGadget, - }, - Vec, +use crate::crh::{ + bowe_hopwood::{Parameters, CHUNK_SIZE}, + pedersen::{self, Window}, + CRHSchemeGadget, TwoToOneCRHSchemeGadget, }; use ark_ff::Field; -use ark_r1cs_std::{ - alloc::AllocVar, groups::curves::twisted_edwards::AffineVar, prelude::*, uint8::UInt8, -}; +use ark_r1cs_std::{groups::curves::twisted_edwards::AffineVar, prelude::*}; use ark_relations::r1cs::{Namespace, SynthesisError}; use crate::crh::bowe_hopwood::{TwoToOneCRH, CRH}; -use ark_r1cs_std::boolean::Boolean; type ConstraintF

= <

::BaseField as Field>::BasePrimeField; diff --git a/crypto-primitives/src/crh/bowe_hopwood/mod.rs b/crypto-primitives/src/crh/bowe_hopwood/mod.rs index 820727a0..fb2bf0ac 100644 --- a/crypto-primitives/src/crh/bowe_hopwood/mod.rs +++ b/crypto-primitives/src/crh/bowe_hopwood/mod.rs @@ -2,7 +2,7 @@ //! specific Twisted Edwards (TE) curves. See [Section 5.4.17 of the Zcash protocol specification](https://raw.githubusercontent.com/zcash/zips/master/protocol/protocol.pdf#concretepedersenhash) for a formal description of this hash function, specialized for the Jubjub curve. //! The implementation in this repository is generic across choice of TE curves. -use crate::{Error, Vec}; +use crate::Error; use ark_std::rand::Rng; use ark_std::{ fmt::{Debug, Formatter, Result as FmtResult}, diff --git a/crypto-primitives/src/crh/injective_map/constraints.rs b/crypto-primitives/src/crh/injective_map/constraints.rs index 8e9cd703..1a60c842 100644 --- a/crypto-primitives/src/crh/injective_map/constraints.rs +++ b/crypto-primitives/src/crh/injective_map/constraints.rs @@ -14,9 +14,7 @@ use ark_ec::{ }; use ark_ff::fields::{Field, PrimeField}; use ark_r1cs_std::{ - fields::fp::FpVar, - groups::{curves::twisted_edwards::AffineVar as TEVar, CurveVar}, - prelude::*, + fields::fp::FpVar, groups::curves::twisted_edwards::AffineVar as TEVar, prelude::*, }; use ark_relations::r1cs::SynthesisError; diff --git a/crypto-primitives/src/crh/pedersen/constraints.rs b/crypto-primitives/src/crh/pedersen/constraints.rs index fdf2340a..3f64e755 100644 --- a/crypto-primitives/src/crh/pedersen/constraints.rs +++ b/crypto-primitives/src/crh/pedersen/constraints.rs @@ -1,9 +1,6 @@ -use crate::{ - crh::{ - pedersen::{Parameters, Window}, - CRHSchemeGadget as CRHGadgetTrait, - }, - Vec, +use crate::crh::{ + pedersen::{Parameters, Window}, + CRHSchemeGadget as CRHGadgetTrait, }; use ark_ec::CurveGroup; use ark_ff::Field; diff --git a/crypto-primitives/src/crh/pedersen/mod.rs b/crypto-primitives/src/crh/pedersen/mod.rs index eec86e36..97850b86 100644 --- a/crypto-primitives/src/crh/pedersen/mod.rs +++ b/crypto-primitives/src/crh/pedersen/mod.rs @@ -1,4 +1,4 @@ -use crate::{Error, Vec}; +use crate::Error; use ark_std::rand::Rng; use ark_std::{ fmt::{Debug, Formatter, Result as FmtResult}, diff --git a/crypto-primitives/src/crh/poseidon/constraints.rs b/crypto-primitives/src/crh/poseidon/constraints.rs index 9684624c..4e152e7f 100644 --- a/crypto-primitives/src/crh/poseidon/constraints.rs +++ b/crypto-primitives/src/crh/poseidon/constraints.rs @@ -1,4 +1,5 @@ use crate::crh::poseidon::{TwoToOneCRH, CRH}; +use crate::crh::CRHScheme; use crate::crh::{ CRHSchemeGadget as CRHGadgetTrait, TwoToOneCRHSchemeGadget as TwoToOneCRHGadgetTrait, }; diff --git a/crypto-primitives/src/crh/sha256/constraints.rs b/crypto-primitives/src/crh/sha256/constraints.rs index c7080809..bf40c945 100644 --- a/crypto-primitives/src/crh/sha256/constraints.rs +++ b/crypto-primitives/src/crh/sha256/constraints.rs @@ -19,7 +19,6 @@ use ark_r1cs_std::{ R1CSVar, }; use ark_relations::r1cs::{ConstraintSystemRef, Namespace, SynthesisError}; -use ark_std::{vec, vec::Vec}; const STATE_LEN: usize = 8; @@ -383,17 +382,10 @@ where #[cfg(test)] mod test { use super::*; - use crate::crh::{ - sha256::{digest::Digest, Sha256}, - CRHScheme, CRHSchemeGadget, TwoToOneCRHScheme, TwoToOneCRHSchemeGadget, - }; + use crate::crh::{sha256::digest::Digest, CRHScheme, TwoToOneCRHScheme}; use ark_bls12_377::Fr; - use ark_r1cs_std::R1CSVar; - use ark_relations::{ - ns, - r1cs::{ConstraintSystem, Namespace}, - }; + use ark_relations::{ns, r1cs::ConstraintSystem}; use ark_std::rand::RngCore; const TEST_LENGTHS: &[usize] = &[ diff --git a/crypto-primitives/src/crh/sha256/mod.rs b/crypto-primitives/src/crh/sha256/mod.rs index 6010be32..8a2cb1d4 100644 --- a/crypto-primitives/src/crh/sha256/mod.rs +++ b/crypto-primitives/src/crh/sha256/mod.rs @@ -1,5 +1,5 @@ use crate::crh::{CRHScheme, TwoToOneCRHScheme}; -use crate::{Error, Vec}; +use crate::Error; use ark_std::rand::Rng; diff --git a/crypto-primitives/src/encryption/elgamal/constraints.rs b/crypto-primitives/src/encryption/elgamal/constraints.rs index 7527352a..290492d2 100644 --- a/crypto-primitives/src/encryption/elgamal/constraints.rs +++ b/crypto-primitives/src/encryption/elgamal/constraints.rs @@ -11,7 +11,7 @@ use ark_ff::{ Zero, }; use ark_serialize::CanonicalSerialize; -use ark_std::{borrow::Borrow, marker::PhantomData, vec::Vec}; +use ark_std::{borrow::Borrow, marker::PhantomData}; pub type ConstraintF = <::BaseField as Field>::BasePrimeField; diff --git a/crypto-primitives/src/merkle_tree/constraints.rs b/crypto-primitives/src/merkle_tree/constraints.rs index e243079c..4cb764a3 100644 --- a/crypto-primitives/src/merkle_tree/constraints.rs +++ b/crypto-primitives/src/merkle_tree/constraints.rs @@ -6,7 +6,6 @@ use ark_r1cs_std::prelude::*; use ark_relations::r1cs::{Namespace, SynthesisError}; use ark_std::borrow::Borrow; use ark_std::fmt::Debug; -use ark_std::vec::Vec; pub trait DigestVarConverter { type TargetType: Borrow; diff --git a/crypto-primitives/src/merkle_tree/mod.rs b/crypto-primitives/src/merkle_tree/mod.rs index a20f08ae..a5fd30b0 100644 --- a/crypto-primitives/src/merkle_tree/mod.rs +++ b/crypto-primitives/src/merkle_tree/mod.rs @@ -8,7 +8,6 @@ use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use ark_std::borrow::Borrow; use ark_std::collections::{BTreeSet, HashMap}; use ark_std::hash::Hash; -use ark_std::vec::Vec; #[cfg(test)] mod tests; diff --git a/crypto-primitives/src/merkle_tree/tests/mod.rs b/crypto-primitives/src/merkle_tree/tests/mod.rs index 0eae7aad..bd03f443 100644 --- a/crypto-primitives/src/merkle_tree/tests/mod.rs +++ b/crypto-primitives/src/merkle_tree/tests/mod.rs @@ -4,10 +4,7 @@ mod test_utils; mod bytes_mt_tests { - use crate::{ - crh::{pedersen, *}, - merkle_tree::*, - }; + use crate::{crh::*, merkle_tree::*}; use ark_ed_on_bls12_381::EdwardsProjective as JubJub; use ark_ff::BigInteger256; use ark_std::{test_rng, UniformRand}; @@ -190,8 +187,8 @@ mod field_mt_tests { use crate::crh::poseidon; use crate::merkle_tree::tests::test_utils::poseidon_parameters; use crate::merkle_tree::{Config, IdentityDigestConverter, MerkleTree}; - use ark_std::{test_rng, vec::Vec, One, UniformRand}; - + use ark_std::{test_rng, One, UniformRand}; + type F = ark_ed_on_bls12_381::Fr; type H = poseidon::CRH; type TwoToOneH = poseidon::TwoToOneCRH; diff --git a/crypto-primitives/src/prf/blake2s/constraints.rs b/crypto-primitives/src/prf/blake2s/constraints.rs index cd52cf69..fdfd99d7 100644 --- a/crypto-primitives/src/prf/blake2s/constraints.rs +++ b/crypto-primitives/src/prf/blake2s/constraints.rs @@ -1,7 +1,7 @@ use ark_ff::PrimeField; use ark_relations::r1cs::{ConstraintSystemRef, Namespace, SynthesisError}; -use crate::{prf::PRFGadget, Vec}; +use crate::prf::PRFGadget; use ark_r1cs_std::prelude::*; use core::borrow::Borrow; diff --git a/crypto-primitives/src/prf/blake2s/mod.rs b/crypto-primitives/src/prf/blake2s/mod.rs index 7455e18a..b2696c19 100644 --- a/crypto-primitives/src/prf/blake2s/mod.rs +++ b/crypto-primitives/src/prf/blake2s/mod.rs @@ -1,4 +1,3 @@ -use crate::Vec; use blake2::{Blake2s256 as B2s, Blake2sMac}; use digest::Digest; diff --git a/crypto-primitives/src/prf/constraints.rs b/crypto-primitives/src/prf/constraints.rs index bbca88c7..1e09571d 100644 --- a/crypto-primitives/src/prf/constraints.rs +++ b/crypto-primitives/src/prf/constraints.rs @@ -1,7 +1,7 @@ use ark_ff::Field; use core::fmt::Debug; -use crate::{prf::PRF, Vec}; +use crate::prf::PRF; use ark_relations::r1cs::{Namespace, SynthesisError}; use ark_r1cs_std::prelude::*; diff --git a/crypto-primitives/src/signature/mod.rs b/crypto-primitives/src/signature/mod.rs index c7cbddca..1f7cf219 100644 --- a/crypto-primitives/src/signature/mod.rs +++ b/crypto-primitives/src/signature/mod.rs @@ -52,10 +52,10 @@ pub trait SignatureScheme { #[cfg(test)] mod test { - use crate::signature::{schnorr, *}; + use crate::signature::*; use ark_ec::AdditiveGroup; use ark_ed_on_bls12_381::EdwardsProjective as JubJub; - use ark_std::{test_rng, vec::Vec, UniformRand}; + use ark_std::{test_rng, UniformRand}; use blake2::Blake2s256 as Blake2s; fn sign_and_verify(message: &[u8]) { diff --git a/crypto-primitives/src/signature/schnorr/constraints.rs b/crypto-primitives/src/signature/schnorr/constraints.rs index 0f663825..7d19ecc1 100644 --- a/crypto-primitives/src/signature/schnorr/constraints.rs +++ b/crypto-primitives/src/signature/schnorr/constraints.rs @@ -1,4 +1,3 @@ -use crate::Vec; use ark_ec::CurveGroup; use ark_ff::Field; use ark_r1cs_std::prelude::*; diff --git a/crypto-primitives/src/signature/schnorr/mod.rs b/crypto-primitives/src/signature/schnorr/mod.rs index e0584c44..c8c3cf75 100644 --- a/crypto-primitives/src/signature/schnorr/mod.rs +++ b/crypto-primitives/src/signature/schnorr/mod.rs @@ -1,4 +1,4 @@ -use crate::{signature::SignatureScheme, Error, Vec}; +use crate::{signature::SignatureScheme, Error}; use ark_ec::{AffineRepr, CurveGroup}; use ark_ff::{ fields::{Field, PrimeField}, diff --git a/crypto-primitives/src/snark/constraints.rs b/crypto-primitives/src/snark/constraints.rs index 66419198..ba1ef909 100644 --- a/crypto-primitives/src/snark/constraints.rs +++ b/crypto-primitives/src/snark/constraints.rs @@ -1,15 +1,12 @@ use ark_ff::{BigInteger, PrimeField}; -use ark_r1cs_std::prelude::*; -use ark_r1cs_std::{ - fields::{ - emulated_fp::{ - params::{get_params, OptimizationType}, - AllocatedEmulatedFpVar, EmulatedFpVar, - }, - fp::{AllocatedFp, FpVar}, +use ark_r1cs_std::fields::{ + emulated_fp::{ + params::{get_params, OptimizationType}, + AllocatedEmulatedFpVar, EmulatedFpVar, }, - R1CSVar, + fp::{AllocatedFp, FpVar}, }; +use ark_r1cs_std::prelude::*; use ark_relations::r1cs::OptimizationGoal; use ark_relations::{ lc, ns, @@ -18,12 +15,7 @@ use ark_relations::{ }, }; use ark_snark::{CircuitSpecificSetupSNARK, UniversalSetupSNARK, SNARK}; -use ark_std::{ - borrow::Borrow, - fmt, - marker::PhantomData, - vec::{IntoIter, Vec}, -}; +use ark_std::{borrow::Borrow, fmt, marker::PhantomData, vec::IntoIter}; /// This implements constraints for SNARK verifiers. pub trait SNARKGadget> { diff --git a/crypto-primitives/src/sponge/absorb.rs b/crypto-primitives/src/sponge/absorb.rs index ed98bf1d..85241d9f 100644 --- a/crypto-primitives/src/sponge/absorb.rs +++ b/crypto-primitives/src/sponge/absorb.rs @@ -7,8 +7,7 @@ use ark_ec::{ use ark_ff::models::{Fp, FpConfig}; use ark_ff::{BigInteger, Field, PrimeField, ToConstraintField}; use ark_serialize::CanonicalSerialize; -use ark_std::string::String; -use ark_std::vec::Vec; + pub use ark_crypto_primitives_macros::*; @@ -389,7 +388,7 @@ mod tests { use crate::sponge::Absorb; use crate::sponge::{field_cast, CryptographicSponge}; use ark_ff::PrimeField; - use ark_std::{test_rng, vec::Vec, UniformRand}; + use ark_std::{test_rng, UniformRand}; #[test] fn test_cast() { diff --git a/crypto-primitives/src/sponge/constraints/absorb.rs b/crypto-primitives/src/sponge/constraints/absorb.rs index 58779a02..fa943cdf 100644 --- a/crypto-primitives/src/sponge/constraints/absorb.rs +++ b/crypto-primitives/src/sponge/constraints/absorb.rs @@ -13,8 +13,7 @@ use ark_r1cs_std::groups::curves::short_weierstrass::{ use ark_r1cs_std::groups::curves::twisted_edwards::AffineVar as TEAffineVar; use ark_r1cs_std::uint8::UInt8; use ark_relations::r1cs::SynthesisError; -use ark_std::vec; -use ark_std::vec::Vec; + /// An interface for objects that can be absorbed by a `CryptographicSpongeVar` whose constraint field /// is `CF`. pub trait AbsorbGadget { diff --git a/crypto-primitives/src/sponge/constraints/mod.rs b/crypto-primitives/src/sponge/constraints/mod.rs index 0d29efe9..ea4311d0 100644 --- a/crypto-primitives/src/sponge/constraints/mod.rs +++ b/crypto-primitives/src/sponge/constraints/mod.rs @@ -9,8 +9,7 @@ use ark_r1cs_std::uint8::UInt8; use ark_r1cs_std::R1CSVar; use ark_relations::lc; use ark_relations::r1cs::{ConstraintSystemRef, LinearCombination, SynthesisError}; -use ark_std::vec; -use ark_std::vec::Vec; + mod absorb; pub use absorb::*; diff --git a/crypto-primitives/src/sponge/mod.rs b/crypto-primitives/src/sponge/mod.rs index bd8a1d92..e0c84744 100644 --- a/crypto-primitives/src/sponge/mod.rs +++ b/crypto-primitives/src/sponge/mod.rs @@ -1,6 +1,5 @@ use ark_ff::PrimeField; use ark_std::vec; -use ark_std::vec::Vec; /// Infrastructure for the constraints counterparts. #[cfg(feature = "r1cs")] diff --git a/crypto-primitives/src/sponge/poseidon/constraints.rs b/crypto-primitives/src/sponge/poseidon/constraints.rs index 8cbec6d2..276ed0e0 100644 --- a/crypto-primitives/src/sponge/poseidon/constraints.rs +++ b/crypto-primitives/src/sponge/poseidon/constraints.rs @@ -7,8 +7,6 @@ use ark_ff::PrimeField; use ark_r1cs_std::fields::fp::FpVar; use ark_r1cs_std::prelude::*; use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError}; -use ark_std::vec; -use ark_std::vec::Vec; #[derive(Clone)] /// the gadget for Poseidon sponge diff --git a/crypto-primitives/src/sponge/poseidon/grain_lfsr.rs b/crypto-primitives/src/sponge/poseidon/grain_lfsr.rs index 41b83c65..ee9dff06 100644 --- a/crypto-primitives/src/sponge/poseidon/grain_lfsr.rs +++ b/crypto-primitives/src/sponge/poseidon/grain_lfsr.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use ark_ff::{BigInteger, PrimeField}; -use ark_std::vec::Vec; + pub struct PoseidonGrainLFSR { pub prime_num_bits: u64, diff --git a/crypto-primitives/src/sponge/poseidon/mod.rs b/crypto-primitives/src/sponge/poseidon/mod.rs index 69dd01ff..11c2cb80 100644 --- a/crypto-primitives/src/sponge/poseidon/mod.rs +++ b/crypto-primitives/src/sponge/poseidon/mod.rs @@ -5,8 +5,7 @@ use crate::sponge::{ use ark_ff::{BigInteger, PrimeField}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use ark_std::any::TypeId; -use ark_std::vec; -use ark_std::vec::Vec; + /// constraints for Poseidon #[cfg(feature = "r1cs")] diff --git a/crypto-primitives/src/sponge/poseidon/traits.rs b/crypto-primitives/src/sponge/poseidon/traits.rs index 1e85214c..237f8732 100644 --- a/crypto-primitives/src/sponge/poseidon/traits.rs +++ b/crypto-primitives/src/sponge/poseidon/traits.rs @@ -1,7 +1,6 @@ use crate::sponge::poseidon::grain_lfsr::PoseidonGrainLFSR; use crate::sponge::poseidon::PoseidonConfig; -use ark_ff::{fields::models::*, FpConfig, PrimeField}; -use ark_std::{vec, vec::Vec}; +use ark_ff::{fields::models::*, PrimeField}; /// An entry in the default Poseidon parameters pub struct PoseidonDefaultConfigEntry {