Skip to content

Commit bb6a03a

Browse files
authored
Add depth <= MAX_DEPTH assertion to binary_merkle_root
1 parent b6be49d commit bb6a03a

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • packages/binary-merkle-root/src

packages/binary-merkle-root/src/lib.nr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ pub fn binary_merkle_root<let MAX_DEPTH: u32>(
1717
// Start from the leaf node
1818
let mut node = leaf;
1919

20+
// Validate that the provided depth does not exceed the static MAX_DEPTH
21+
assert(depth <= MAX_DEPTH);
22+
2023
// Iterate through the Merkle proof up to MAX_DEPTH
2124
for i in 0..MAX_DEPTH {
2225
// Only compute hash if the current level is within the tree depth

0 commit comments

Comments
 (0)