diff --git a/plonky2x/src/frontend/merkle/tendermint.rs b/plonky2x/src/frontend/merkle/tendermint.rs index 7a01f6656..9893638aa 100644 --- a/plonky2x/src/frontend/merkle/tendermint.rs +++ b/plonky2x/src/frontend/merkle/tendermint.rs @@ -121,6 +121,7 @@ impl, const D: usize> CircuitBuilder { .collect_vec() } + // leaf_hashes and leaves_enabled should be of size NB_LEAVES. pub fn get_root_from_hashed_leaves( &mut self, leaf_hashes: Vec, @@ -149,14 +150,11 @@ impl, const D: usize> CircuitBuilder { pub fn compute_root_from_leaves( &mut self, - leaves: Vec>, - leaves_enabled: Vec, + leaves: ArrayVariable, NB_LEAVES>, + leaves_enabled: ArrayVariable, ) -> Bytes32Variable { - // TODO: Remove, this is just for debugging. - assert_eq!(leaves.len(), NB_LEAVES); - - let hashed_leaves = self.hash_leaves::(leaves); - self.get_root_from_hashed_leaves::(hashed_leaves, leaves_enabled) + let hashed_leaves = self.hash_leaves::(leaves.as_vec()); + self.get_root_from_hashed_leaves::(hashed_leaves, leaves_enabled.as_vec()) } } @@ -187,7 +185,7 @@ mod tests { let leaves = builder.read::, 32>>(); let enabled = builder.read::>(); - let root = builder.compute_root_from_leaves::<32, 48>(leaves.as_vec(), enabled.as_vec()); + let root = builder.compute_root_from_leaves::<32, 48>(leaves, enabled); builder.write::(root); let circuit = builder.build(); circuit.test_default_serializers();