diff --git a/src/gadgets/permutation.rs b/src/gadgets/permutation.rs index c6bb10fd..fd96f43a 100644 --- a/src/gadgets/permutation.rs +++ b/src/gadgets/permutation.rs @@ -385,6 +385,7 @@ impl SimpleGenerator for PermutationGenerator { #[cfg(test)] mod tests { use anyhow::Result; + use rand::{seq::SliceRandom, thread_rng}; use super::*; use crate::field::crandall_field::CrandallField; @@ -457,4 +458,27 @@ mod tests { verify(proof, &data.verifier_only, &data.common) } + + #[test] + fn test_permutation_6x6() -> Result<()> { + type F = CrandallField; + let config = CircuitConfig::large_config(); + let pw = PartialWitness::new(config.num_wires); + let mut builder = CircuitBuilder::::new(config); + + let lst: Vec = (0..12).map(|n| F::from_canonical_usize(n)).collect(); + let a: Vec> = lst[..] + .windows(2) + .map(|pair| vec![builder.constant(pair[0]), builder.constant(pair[1])]) + .collect(); + let mut b = a.clone(); + b.shuffle(&mut thread_rng()); + + builder.assert_permutation(a, b); + + let data = builder.build(); + let proof = data.prove(pw).unwrap(); + + verify(proof, &data.verifier_only, &data.common) + } }