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 verifyproof
: The merkle proofmerkle_root
: The expected merkle root
§Returns
true
if proof is validfalse
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()));