From fdeb2fb81736a0d7c46c149cdf6ed57038a33007 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 10 Dec 2021 02:04:16 +0000 Subject: [PATCH] poseidon: Add circuit test case that fails This exposes a bug in the way padding was being handled by the invalid sponge-duplex hybrid construction. --- src/circuit/gadget/poseidon/pow5.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/circuit/gadget/poseidon/pow5.rs b/src/circuit/gadget/poseidon/pow5.rs index f8ba67c4..639a4545 100644 --- a/src/circuit/gadget/poseidon/pow5.rs +++ b/src/circuit/gadget/poseidon/pow5.rs @@ -823,6 +823,22 @@ mod tests { assert_eq!(prover.verify(), Ok(())) } + #[test] + fn poseidon_hash_longer_input() { + let message = [Fp::rand(), Fp::rand(), Fp::rand()]; + let output = + poseidon::Hash::<_, OrchardNullifier, ConstantLength<3>, 3, 2>::init().hash(message); + + let k = 7; + let circuit = HashCircuit:: { + message: Some(message), + output: Some(output), + _spec: PhantomData, + }; + let prover = MockProver::run(k, &circuit, vec![]).unwrap(); + assert_eq!(prover.verify(), Ok(())) + } + #[test] fn hash_test_vectors() { for tv in crate::primitives::poseidon::test_vectors::fp::hash() {