Skip to content

Commit

Permalink
Remove redundant imports, nightly check
Browse files Browse the repository at this point in the history
  • Loading branch information
autquis committed Mar 11, 2024
1 parent c899a53 commit 6cbaad7
Show file tree
Hide file tree
Showing 32 changed files with 34 additions and 84 deletions.
1 change: 0 additions & 1 deletion crypto-primitives/src/commitment/blake2s/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/commitment/pedersen/constraints.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
commitment::pedersen::{Commitment, Parameters, Randomness},
crh::pedersen::Window,
Vec,
};
use ark_ec::CurveGroup;
use ark_ff::{
Expand Down
2 changes: 1 addition & 1 deletion crypto-primitives/src/commitment/pedersen/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
16 changes: 5 additions & 11 deletions crypto-primitives/src/crh/bowe_hopwood/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P> = <<P as CurveConfig>::BaseField as Field>::BasePrimeField;

Expand Down
2 changes: 1 addition & 1 deletion crypto-primitives/src/crh/bowe_hopwood/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 1 addition & 3 deletions crypto-primitives/src/crh/injective_map/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/crh/injective_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use ark_ec::{
};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::borrow::Borrow;
use ark_std::vec::Vec;
#[cfg(feature = "r1cs")]
pub mod constraints;

Expand Down
9 changes: 3 additions & 6 deletions crypto-primitives/src/crh/pedersen/constraints.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crypto-primitives/src/crh/pedersen/mod.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
2 changes: 1 addition & 1 deletion crypto-primitives/src/crh/poseidon/constraints.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::crh::poseidon::{TwoToOneCRH, CRH};
use crate::crh::CRHScheme;
use crate::crh::{
CRHSchemeGadget as CRHGadgetTrait, TwoToOneCRHSchemeGadget as TwoToOneCRHGadgetTrait,
};
use crate::sponge::constraints::CryptographicSpongeVar;
use crate::sponge::poseidon::constraints::PoseidonSpongeVar;
use crate::sponge::poseidon::PoseidonConfig;
use crate::{crh::CRHScheme, Vec};

use crate::sponge::Absorb;
use ark_ff::PrimeField;
Expand Down
12 changes: 2 additions & 10 deletions crypto-primitives/src/crh/sha256/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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] = &[
Expand Down
2 changes: 1 addition & 1 deletion crypto-primitives/src/crh/sha256/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::crh::{CRHScheme, TwoToOneCRHScheme};
use crate::{Error, Vec};
use crate::Error;

use ark_std::rand::Rng;

Expand Down
2 changes: 1 addition & 1 deletion crypto-primitives/src/encryption/elgamal/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C> = <<C as CurveGroup>::BaseField as Field>::BasePrimeField;

Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/merkle_tree/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<From, To: ?Sized> {
type TargetType: Borrow<To>;
Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/merkle_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::{crh::CRHScheme, Error};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::borrow::Borrow;
use ark_std::hash::Hash;
use ark_std::vec::Vec;

#[cfg(test)]
mod tests;
Expand Down
7 changes: 2 additions & 5 deletions crypto-primitives/src/merkle_tree/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -120,7 +117,7 @@ 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<F>;
Expand Down
2 changes: 1 addition & 1 deletion crypto-primitives/src/prf/blake2s/constraints.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/prf/blake2s/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::Vec;
use blake2::{Blake2s256 as B2s, Blake2sMac};
use digest::Digest;

Expand Down
2 changes: 1 addition & 1 deletion crypto-primitives/src/prf/constraints.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
4 changes: 2 additions & 2 deletions crypto-primitives/src/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S: SignatureScheme>(message: &[u8]) {
Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/signature/schnorr/constraints.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::Vec;
use ark_ec::CurveGroup;
use ark_ff::Field;
use ark_r1cs_std::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion crypto-primitives/src/signature/schnorr/mod.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
22 changes: 7 additions & 15 deletions crypto-primitives/src/snark/constraints.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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<F: PrimeField, ConstraintF: PrimeField, S: SNARK<F>> {
Expand Down
4 changes: 1 addition & 3 deletions crypto-primitives/src/sponge/absorb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ 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::*;

Expand Down Expand Up @@ -389,7 +387,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() {
Expand Down
3 changes: 1 addition & 2 deletions crypto-primitives/src/sponge/constraints/absorb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F: PrimeField> {
Expand Down
2 changes: 0 additions & 2 deletions crypto-primitives/src/sponge/constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ 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::*;
Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/sponge/merlin/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::sponge::{Absorb, CryptographicSponge};
use crate::Vec;
pub use merlin::Transcript;

impl CryptographicSponge for Transcript {
Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/sponge/mod.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down
2 changes: 0 additions & 2 deletions crypto-primitives/src/sponge/poseidon/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion crypto-primitives/src/sponge/poseidon/grain_lfsr.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(dead_code)]

use ark_ff::{BigInteger, PrimeField};
use ark_std::vec::Vec;

pub struct PoseidonGrainLFSR {
pub prime_num_bits: u64,
Expand Down
2 changes: 0 additions & 2 deletions crypto-primitives/src/sponge/poseidon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ 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")]
Expand Down
3 changes: 1 addition & 2 deletions crypto-primitives/src/sponge/poseidon/traits.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 6cbaad7

Please sign in to comment.