Browse Source

Fix MerkleTree leaf index calculation

master
Pratyush Mishra 4 years ago
parent
commit
81f3105a91
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      crypto-primitives/src/merkle_tree/mod.rs

+ 1
- 1
crypto-primitives/src/merkle_tree/mod.rs

@ -130,7 +130,7 @@ impl MerkleHashTree

{

} }
// Compute and store the hash values for each leaf. // 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]; let mut buffer = [0u8; 128];
for (i, leaf) in leaves.iter().enumerate() { for (i, leaf) in leaves.iter().enumerate() {
tree[last_level_index + i] = hash_leaf::<P::H, _>(&parameters, leaf, &mut buffer)?; tree[last_level_index + i] = hash_leaf::<P::H, _>(&parameters, leaf, &mut buffer)?;

Loading…
Cancel
Save