mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-10 16:01:28 +01:00
Merkle tree fails to compute the root when there's no need in dummy nodes - fix
This commit is contained in:
committed by
Pratyush Mishra
parent
97ca70b854
commit
4e0d92a6ec
@@ -161,14 +161,16 @@ impl<P: MerkleTreeConfig> MerkleHashTree<P> {
|
||||
let mut cur_height = tree_height;
|
||||
let mut padding_tree = Vec::new();
|
||||
let mut cur_hash = tree[0].clone();
|
||||
while cur_height < (Self::HEIGHT - 1) as usize {
|
||||
cur_hash = hash_inner_node::<P::H>(¶meters, &cur_hash, &empty_hash, &mut buffer)?;
|
||||
padding_tree.push((cur_hash.clone(), empty_hash.clone()));
|
||||
cur_height += 1;
|
||||
}
|
||||
|
||||
let root_hash = hash_inner_node::<P::H>(¶meters, &cur_hash, &empty_hash, &mut buffer)?;
|
||||
|
||||
let root_hash = if cur_height < Self::HEIGHT as usize {
|
||||
while cur_height < (Self::HEIGHT - 1) as usize {
|
||||
cur_hash = hash_inner_node::<P::H>(¶meters, &cur_hash, &empty_hash, &mut buffer)?;
|
||||
padding_tree.push((cur_hash.clone(), empty_hash.clone()));
|
||||
cur_height += 1;
|
||||
}
|
||||
hash_inner_node::<P::H>(¶meters, &cur_hash, &empty_hash, &mut buffer)?
|
||||
} else {
|
||||
cur_hash
|
||||
};
|
||||
end_timer!(new_time);
|
||||
|
||||
Ok(MerkleHashTree {
|
||||
|
||||
Reference in New Issue
Block a user