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

Method verify_proof

header-chain/src/mmr_guest.rs:36–51  ·  view source on GitHub ↗

Verifies an inclusion proof against the current MMR root

(&self, leaf: [u8; 32], mmr_proof: &MMRInclusionProof)

Source from the content-addressed store, hash-verified

34
35 /// Verifies an inclusion proof against the current MMR root
36 pub fn verify_proof(&self, leaf: [u8; 32], mmr_proof: &MMRInclusionProof) -> bool {
37 println!("GUEST: mmr_proof: {:?}", mmr_proof);
38 println!("GUEST: leaf: {:?}", leaf);
39 let mut current_hash = leaf;
40 for i in 0..mmr_proof.inclusion_proof.len() {
41 let sibling = mmr_proof.inclusion_proof[i];
42 if mmr_proof.internal_idx & (1 << i) == 0 {
43 current_hash = hash_pair(current_hash, sibling);
44 } else {
45 current_hash = hash_pair(sibling, current_hash);
46 }
47 }
48 println!("GUEST: calculated subroot: {:?}", current_hash);
49 println!("GUEST: subroots: {:?}", self.subroots);
50 self.subroots.get(mmr_proof.subroot_idx) == Some(&current_hash)
51 }
52}

Callers 1

verifyMethod · 0.45

Calls 3

lenMethod · 0.80
hash_pairFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected