diff --git a/examples/fold_sha256.rs b/examples/fold_sha256.rs index a5f6578d..25233b71 100644 --- a/examples/fold_sha256.rs +++ b/examples/fold_sha256.rs @@ -10,7 +10,6 @@ use ark_crypto_primitives::crh::{ }, CRHScheme, CRHSchemeGadget, }; -use ark_crypto_primitives::sponge::poseidon::{find_poseidon_ark_and_mds, PoseidonConfig}; use ark_ff::{BigInteger, PrimeField, ToConstraintField}; use ark_r1cs_std::{fields::fp::FpVar, ToBytesGadget, ToConstraintFieldGadget}; use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError}; @@ -23,6 +22,7 @@ use ark_vesta::{constraints::GVar as GVar2, Projective as Projective2}; use folding_schemes::commitment::pedersen::Pedersen; use folding_schemes::folding::nova::{get_r1cs, Nova, ProverParams, VerifierParams}; use folding_schemes::frontend::FCircuit; +use folding_schemes::transcript::poseidon::poseidon_test_config; use folding_schemes::{Error, FoldingScheme}; /// This is the circuit that we want to fold, it implements the FCircuit trait @@ -53,31 +53,6 @@ impl FCircuit for Sha256FCircuit { } } -pub fn poseidon_test_config() -> PoseidonConfig { - let full_rounds = 8; - let partial_rounds = 31; - let alpha = 5; - let rate = 2; - - let (ark, mds) = find_poseidon_ark_and_mds::( - F::MODULUS_BIT_SIZE as u64, - rate, - full_rounds, - partial_rounds, - 0, - ); - - PoseidonConfig::new( - full_rounds as usize, - partial_rounds as usize, - alpha, - mds, - ark, - rate, - 1, - ) -} - /// cargo test --example simple #[cfg(test)] pub mod tests { @@ -103,7 +78,7 @@ pub mod tests { } } -// this method computes the Prover & Verifier parameters for the example. For a real world use case +// This method computes the Prover & Verifier parameters for the example. For a real world use case // those parameters should be generated carefuly (both the PoseidonConfig and the PedersenParams) #[allow(clippy::type_complexity)] fn nova_setup>( diff --git a/src/commitment/kzg.rs b/src/commitment/kzg.rs index 47b9d0bb..debab156 100644 --- a/src/commitment/kzg.rs +++ b/src/commitment/kzg.rs @@ -197,7 +197,7 @@ mod tests { use ark_std::{test_rng, UniformRand}; use super::*; - use crate::transcript::poseidon::{tests::poseidon_test_config, PoseidonTranscript}; + use crate::transcript::poseidon::{poseidon_test_config, PoseidonTranscript}; #[test] fn test_kzg_commitment_scheme() { diff --git a/src/commitment/mod.rs b/src/commitment/mod.rs index 18fe0c00..fdba674a 100644 --- a/src/commitment/mod.rs +++ b/src/commitment/mod.rs @@ -41,7 +41,7 @@ mod tests { use super::kzg::{KZGProver, KZGSetup, ProverKey}; use super::pedersen::Pedersen; use crate::transcript::{ - poseidon::{tests::poseidon_test_config, PoseidonTranscript}, + poseidon::{poseidon_test_config, PoseidonTranscript}, Transcript, }; diff --git a/src/commitment/pedersen.rs b/src/commitment/pedersen.rs index b711cc8b..1feee431 100644 --- a/src/commitment/pedersen.rs +++ b/src/commitment/pedersen.rs @@ -165,7 +165,7 @@ mod tests { use ark_std::UniformRand; use super::*; - use crate::transcript::poseidon::{tests::poseidon_test_config, PoseidonTranscript}; + use crate::transcript::poseidon::{poseidon_test_config, PoseidonTranscript}; #[test] fn test_pedersen_vector() { diff --git a/src/folding/circuits/sum_check.rs b/src/folding/circuits/sum_check.rs index b570198b..e0da76b4 100644 --- a/src/folding/circuits/sum_check.rs +++ b/src/folding/circuits/sum_check.rs @@ -176,7 +176,7 @@ mod tests { use crate::{ folding::circuits::sum_check::{IOPProofVar, VPAuxInfoVar}, transcript::{ - poseidon::{tests::poseidon_test_config, PoseidonTranscript, PoseidonTranscriptVar}, + poseidon::{poseidon_test_config, PoseidonTranscript, PoseidonTranscriptVar}, Transcript, TranscriptVar, }, utils::{ diff --git a/src/folding/hypernova/nimfs.rs b/src/folding/hypernova/nimfs.rs index da408e16..6872db1f 100644 --- a/src/folding/hypernova/nimfs.rs +++ b/src/folding/hypernova/nimfs.rs @@ -373,7 +373,7 @@ where pub mod tests { use super::*; use crate::ccs::tests::{get_test_ccs, get_test_z}; - use crate::transcript::poseidon::tests::poseidon_test_config; + use crate::transcript::poseidon::poseidon_test_config; use crate::transcript::poseidon::PoseidonTranscript; use ark_std::test_rng; use ark_std::UniformRand; diff --git a/src/folding/nova/circuits.rs b/src/folding/nova/circuits.rs index 2679afc6..26885a5f 100644 --- a/src/folding/nova/circuits.rs +++ b/src/folding/nova/circuits.rs @@ -476,7 +476,7 @@ pub mod tests { get_committed_instance_coordinates, nifs::NIFS, traits::NovaR1CS, Witness, }; use crate::frontend::tests::CubicFCircuit; - use crate::transcript::poseidon::tests::poseidon_test_config; + use crate::transcript::poseidon::poseidon_test_config; #[test] fn test_committed_instance_var() { diff --git a/src/folding/nova/cyclefold.rs b/src/folding/nova/cyclefold.rs index cb2d9c37..54dbb74d 100644 --- a/src/folding/nova/cyclefold.rs +++ b/src/folding/nova/cyclefold.rs @@ -402,7 +402,7 @@ pub mod tests { use ark_std::UniformRand; use crate::folding::nova::nifs::tests::prepare_simple_fold_inputs; - use crate::transcript::poseidon::tests::poseidon_test_config; + use crate::transcript::poseidon::poseidon_test_config; #[test] fn test_committed_instance_cyclefold_var() { diff --git a/src/folding/nova/decider_eth_circuit.rs b/src/folding/nova/decider_eth_circuit.rs index 44bd75be..b79bc26c 100644 --- a/src/folding/nova/decider_eth_circuit.rs +++ b/src/folding/nova/decider_eth_circuit.rs @@ -453,7 +453,7 @@ pub mod tests { use crate::commitment::pedersen::Pedersen; use crate::folding::nova::{get_pedersen_params_len, ProverParams, VerifierParams}; use crate::frontend::tests::{CubicFCircuit, CustomFCircuit, WrapperCircuit}; - use crate::transcript::poseidon::tests::poseidon_test_config; + use crate::transcript::poseidon::poseidon_test_config; use crate::FoldingScheme; use crate::ccs::r1cs::{extract_r1cs, extract_w_x}; diff --git a/src/folding/nova/mod.rs b/src/folding/nova/mod.rs index 10457965..d9efa2d7 100644 --- a/src/folding/nova/mod.rs +++ b/src/folding/nova/mod.rs @@ -654,7 +654,7 @@ pub mod tests { use crate::commitment::pedersen::Pedersen; use crate::frontend::tests::CubicFCircuit; - use crate::transcript::poseidon::tests::poseidon_test_config; + use crate::transcript::poseidon::poseidon_test_config; #[test] fn test_ivc() { diff --git a/src/folding/nova/nifs.rs b/src/folding/nova/nifs.rs index a8670a12..b95053f2 100644 --- a/src/folding/nova/nifs.rs +++ b/src/folding/nova/nifs.rs @@ -209,7 +209,7 @@ pub mod tests { use crate::commitment::pedersen::{Params as PedersenParams, Pedersen}; use crate::folding::nova::circuits::ChallengeGadget; use crate::folding::nova::traits::NovaR1CS; - use crate::transcript::poseidon::{tests::poseidon_test_config, PoseidonTranscript}; + use crate::transcript::poseidon::{poseidon_test_config, PoseidonTranscript}; use crate::utils::vec::vec_scalar_mul; #[allow(clippy::type_complexity)] diff --git a/src/folding/protogalaxy/folding.rs b/src/folding/protogalaxy/folding.rs index ba5f8e73..21a65fa5 100644 --- a/src/folding/protogalaxy/folding.rs +++ b/src/folding/protogalaxy/folding.rs @@ -370,7 +370,7 @@ mod tests { use crate::ccs::r1cs::tests::{get_test_r1cs, get_test_z}; use crate::commitment::{pedersen::Pedersen, CommitmentProver}; - use crate::transcript::poseidon::{tests::poseidon_test_config, PoseidonTranscript}; + use crate::transcript::poseidon::{poseidon_test_config, PoseidonTranscript}; pub(crate) fn check_instance( r1cs: &R1CS, diff --git a/src/transcript/poseidon.rs b/src/transcript/poseidon.rs index 7d57adb6..45431b55 100644 --- a/src/transcript/poseidon.rs +++ b/src/transcript/poseidon.rs @@ -115,43 +115,41 @@ impl TranscriptVar for PoseidonTranscriptVar { } } +/// WARNING the method poseidon_test_config is for tests only +pub fn poseidon_test_config() -> PoseidonConfig { + let full_rounds = 8; + let partial_rounds = 31; + let alpha = 5; + let rate = 2; + + let (ark, mds) = ark_crypto_primitives::sponge::poseidon::find_poseidon_ark_and_mds::( + F::MODULUS_BIT_SIZE as u64, + rate, + full_rounds, + partial_rounds, + 0, + ); + + PoseidonConfig::new( + full_rounds as usize, + partial_rounds as usize, + alpha, + mds, + ark, + rate, + 1, + ) +} + #[cfg(test)] pub mod tests { use super::*; - use ark_crypto_primitives::sponge::poseidon::find_poseidon_ark_and_mds; use ark_pallas::{constraints::GVar, Fq, Fr, Projective}; use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar, groups::CurveVar, R1CSVar}; use ark_relations::r1cs::ConstraintSystem; use ark_vesta::Projective as E2Projective; use std::ops::Mul; - /// WARNING the method poseidon_test_config is for tests only - #[cfg(test)] - pub fn poseidon_test_config() -> PoseidonConfig { - let full_rounds = 8; - let partial_rounds = 31; - let alpha = 5; - let rate = 2; - - let (ark, mds) = find_poseidon_ark_and_mds::( - F::MODULUS_BIT_SIZE as u64, - rate, - full_rounds, - partial_rounds, - 0, - ); - - PoseidonConfig::new( - full_rounds as usize, - partial_rounds as usize, - alpha, - mds, - ark, - rate, - 1, - ) - } - #[test] fn test_transcript_and_transcriptvar_get_challenge() { // use 'native' transcript diff --git a/src/utils/espresso/sum_check/mod.rs b/src/utils/espresso/sum_check/mod.rs index 08ca0334..25c228cd 100644 --- a/src/utils/espresso/sum_check/mod.rs +++ b/src/utils/espresso/sum_check/mod.rs @@ -211,7 +211,7 @@ pub mod tests { use ark_poly::MultilinearExtension; use ark_std::test_rng; - use crate::transcript::poseidon::tests::poseidon_test_config; + use crate::transcript::poseidon::poseidon_test_config; use crate::transcript::poseidon::PoseidonTranscript; use crate::transcript::Transcript; use crate::utils::sum_check::SumCheck;