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.
This commit is contained in:
Jack Grigg 2021-12-10 02:04:16 +00:00
parent bfc65d5985
commit fdeb2fb817
1 changed files with 16 additions and 0 deletions

View File

@ -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::<OrchardNullifier, 3, 2, 3> {
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() {