diff --git a/crypto-primitives/src/merkle_tree/mod.rs b/crypto-primitives/src/merkle_tree/mod.rs index 80e002e..ecc8745 100644 --- a/crypto-primitives/src/merkle_tree/mod.rs +++ b/crypto-primitives/src/merkle_tree/mod.rs @@ -130,7 +130,7 @@ impl MerkleHashTree

{ } // Compute and store the hash values for each leaf. - let last_level_index = level_indices.pop().unwrap(); + let last_level_index = level_indices.pop().unwrap_or(0); let mut buffer = [0u8; 128]; for (i, leaf) in leaves.iter().enumerate() { tree[last_level_index + i] = hash_leaf::(¶meters, leaf, &mut buffer)?;