verify_merkle_proof

Function verify_merkle_proof 

Source
pub fn verify_merkle_proof(
    participant: &DailyParticipantData,
    proof: &MerkleProof,
    merkle_root: [u8; 32],
) -> bool
Expand description

Verify a merkle proof against a merkle root and participant data.

This is a convenience function for proof verification that can be used both off-chain (for testing) and on-chain (in claim instructions).

§Parameters

  • participant: The participant data to verify
  • proof: The merkle proof
  • merkle_root: The expected merkle root

§Returns

  • true if proof is valid
  • false if proof is invalid

§Example

use miracle_api::{sdk, prelude::DailyParticipantData};

let participant = DailyParticipantData::new([1u8; 32], 1723680000, 1723766400, [1u8; 8], [2u8; 8], 5, 0);
let participants = vec![participant.clone()];
let merkle_tree = sdk::create_merkle_tree(participants);
let proof = merkle_tree.generate_proof(0);

assert!(sdk::verify_merkle_proof(&participant, &proof, merkle_tree.root()));