circuits_lib::bridge_circuit::merkle_tree

Function verify_merkle_proof

Source
pub fn verify_merkle_proof(
    mid_state_txid: [u8; 32],
    inclusion_proof: &BlockInclusionProof,
    root: [u8; 32],
) -> bool
Expand description

Verifies a Merkle proof against a given root using the “mid-state” tree approach.

  • mid_state_txid: The transaction ID of the leaf node for which the proof is provided.
  • inclusion_proof: The proof path containing sibling nodes from the “mid-state” Merkle tree.
  • root: The expected Bitcoin Merkle root of the block.

This function recalculates the root using inclusion_proof.get_root() (which applies the SPV security measure of SHA256-ing mid-state proof elements) and compares it to the expected root.