MCPcopy Create free account
hub / github.com/BitVM/BitVM / get_subroot

Method get_subroot

header-chain/src/mmr_native.rs:130–141  ·  view source on GitHub ↗
(&self, leaf: [u8; 32])

Source from the content-addressed store, hash-verified

128 }
129
130 pub fn get_subroot(&self, leaf: [u8; 32]) -> [u8; 32] {
131 let mut current_hash = leaf;
132 for i in 0..self.inclusion_proof.len() {
133 let sibling = self.inclusion_proof[i];
134 if self.internal_idx & (1 << i) == 0 {
135 current_hash = hash_pair(current_hash, sibling);
136 } else {
137 current_hash = hash_pair(sibling, current_hash);
138 }
139 }
140 current_hash
141 }
142}
143
144#[cfg(test)]

Callers 1

verify_proofMethod · 0.80

Calls 2

lenMethod · 0.80
hash_pairFunction · 0.70

Tested by

no test coverage detected