| 181 | |
| 182 | #[cfg(test)] |
| 183 | pub(crate) fn test_sponge<F: PrimeField>() -> PoseidonSponge<F> { |
| 184 | use ark_crypto_primitives::sponge::{poseidon::PoseidonConfig, CryptographicSponge}; |
| 185 | use ark_std::test_rng; |
| 186 | |
| 187 | let full_rounds = 8; |
| 188 | let partial_rounds = 31; |
| 189 | let alpha = 17; |
| 190 | |
| 191 | let mds = vec![ |
| 192 | vec![F::one(), F::zero(), F::one()], |
| 193 | vec![F::one(), F::one(), F::zero()], |
| 194 | vec![F::zero(), F::one(), F::one()], |
| 195 | ]; |
| 196 | |
| 197 | let mut v = Vec::new(); |
| 198 | let mut ark_rng = test_rng(); |
| 199 | |
| 200 | for _ in 0..(full_rounds + partial_rounds) { |
| 201 | let mut res = Vec::new(); |
| 202 | |
| 203 | for _ in 0..3 { |
| 204 | res.push(F::rand(&mut ark_rng)); |
| 205 | } |
| 206 | v.push(res); |
| 207 | } |
| 208 | let config = PoseidonConfig::new(full_rounds, partial_rounds, alpha, mds, v, 2, 1); |
| 209 | PoseidonSponge::new(&config) |
| 210 | } |
| 211 | |
| 212 | #[cfg(test)] |
| 213 | pub(crate) mod tests { |