diff --git a/plonkish_backend/src/circuits/poseidongadget/poseidon/pow5.rs b/plonkish_backend/src/circuits/poseidongadget/poseidon/pow5.rs index 5397b43..ff23fef 100644 --- a/plonkish_backend/src/circuits/poseidongadget/poseidon/pow5.rs +++ b/plonkish_backend/src/circuits/poseidongadget/poseidon/pow5.rs @@ -730,45 +730,39 @@ mod tests { } } - impl_circuit_ext!( - 2, 1, - 3, 2, - 4, 3, - 5, 4, - 6, 5, - 7, 6 - ); + impl_circuit_ext!(2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6); #[test] fn poseidon_permute() { type Pb = HyperPlonk>>; macro_rules! test_poseidon_permute { - ($i:expr, $j:expr) => { - { - let circuit = Halo2Circuit::new::(6, PermuteCircuit::, $j, $i>(PhantomData)); - let param = Pb::setup(&circuit.circuit_info().unwrap(), seeded_std_rng()).unwrap(); - let (pp, vp) = Pb::preprocess(¶m, &circuit.circuit_info().unwrap()).unwrap(); - let proof = { - let mut transcript = Keccak256Transcript::new(()); - Pb::prove(&pp, &circuit, &mut transcript, seeded_std_rng()).unwrap(); - transcript.into_proof() - }; - let result = { - let mut transcript = Keccak256Transcript::from_proof((), proof.as_slice()); - Pb::verify(&vp, circuit.instances(), &mut transcript, seeded_std_rng()) - }; - assert_eq!(result, Ok(())) - } - }; + ($i:expr, $j:expr) => {{ + let circuit = Halo2Circuit::new::( + 6, + PermuteCircuit::, $j, $i>(PhantomData) + ); + let param = Pb::setup(&circuit.circuit_info().unwrap(), seeded_std_rng()).unwrap(); + let (pp, vp) = Pb::preprocess(¶m, &circuit.circuit_info().unwrap()).unwrap(); + let proof = { + let mut transcript = Keccak256Transcript::new(()); + Pb::prove(&pp, &circuit, &mut transcript, seeded_std_rng()).unwrap(); + transcript.into_proof() + }; + let result = { + let mut transcript = Keccak256Transcript::from_proof((), proof.as_slice()); + Pb::verify(&vp, circuit.instances(), &mut transcript, seeded_std_rng()) + }; + assert_eq!(result, Ok(())) + }}; } for i in 2..7 { match i { - 1 => test_poseidon_permute!(1,2), - 2 => test_poseidon_permute!(2,3), - 3 => test_poseidon_permute!(3,4), - 4 => test_poseidon_permute!(4,5), - 5 => test_poseidon_permute!(5,6), - 6 => test_poseidon_permute!(6,7), + 1 => test_poseidon_permute!(1, 2), + 2 => test_poseidon_permute!(2, 3), + 3 => test_poseidon_permute!(3, 4), + 4 => test_poseidon_permute!(4, 5), + 5 => test_poseidon_permute!(5, 6), + 6 => test_poseidon_permute!(6, 7), _ => unreachable!(), } } @@ -942,14 +936,7 @@ mod tests { } } - impl_circuit_ext!( - 2, 1, - 3, 2, - 4, 3, - 5, 4, - 6, 5, - 7, 6 - ); + impl_circuit_ext!(2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6); impl CircuitExt for HashCircuit, 3, 2, 3> { fn instances(&self) -> Vec> { @@ -966,42 +953,40 @@ mod tests { fn poseidon_hash() { type Pb = HyperPlonk>>; macro_rules! test_poseidon_hash { - ($i:expr, $j:expr) => { - { - let message: [Fr; $i] = [Fr::random(OsRng); $i]; - let output = - poseidon::Hash::<_, newParam<$j, $i, 0>, ConstantLength<$i>, $j, $i>::init().hash(message); - let circuit = Halo2Circuit::new::( - 6, - HashCircuit::, $j, $i, $i> { - message: Value::known(message), - output: Value::known(output), - _spec: PhantomData, - }, - ); - let param = Pb::setup(&circuit.circuit_info().unwrap(), seeded_std_rng()).unwrap(); - let (pp, vp) = Pb::preprocess(¶m, &circuit.circuit_info().unwrap()).unwrap(); - let proof = { - let mut transcript = Keccak256Transcript::new(()); - Pb::prove(&pp, &circuit, &mut transcript, seeded_std_rng()).unwrap(); - transcript.into_proof() - }; - let result = { - let mut transcript = Keccak256Transcript::from_proof((), proof.as_slice()); - Pb::verify(&vp, circuit.instances(), &mut transcript, seeded_std_rng()) - }; - assert_eq!(result, Ok(())) - } - }; + ($i:expr, $j:expr) => {{ + let message: [Fr; $i] = [Fr::random(OsRng); $i]; + let output = + poseidon::Hash::<_, newParam<$j, $i, 0>, ConstantLength<$i>, $j, $i>::init().hash(message); + let circuit = Halo2Circuit::new::( + 6, + HashCircuit::, $j, $i, $i> { + message: Value::known(message), + output: Value::known(output), + _spec: PhantomData, + }, + ); + let param = Pb::setup(&circuit.circuit_info().unwrap(), seeded_std_rng()).unwrap(); + let (pp, vp) = Pb::preprocess(¶m, &circuit.circuit_info().unwrap()).unwrap(); + let proof = { + let mut transcript = Keccak256Transcript::new(()); + Pb::prove(&pp, &circuit, &mut transcript, seeded_std_rng()).unwrap(); + transcript.into_proof() + }; + let result = { + let mut transcript = Keccak256Transcript::from_proof((), proof.as_slice()); + Pb::verify(&vp, circuit.instances(), &mut transcript, seeded_std_rng()) + }; + assert_eq!(result, Ok(())) + }}; } for i in 2..7 { match i { - 1 => test_poseidon_hash!(1,2), - 2 => test_poseidon_hash!(2,3), - 3 => test_poseidon_hash!(3,4), - 4 => test_poseidon_hash!(4,5), - 5 => test_poseidon_hash!(5,6), - 6 => test_poseidon_hash!(6,7), + 1 => test_poseidon_hash!(1, 2), + 2 => test_poseidon_hash!(2, 3), + 3 => test_poseidon_hash!(3, 4), + 4 => test_poseidon_hash!(4, 5), + 5 => test_poseidon_hash!(5, 6), + 6 => test_poseidon_hash!(6, 7), _ => unreachable!(), } }