tensor-toolbox 0.8.1

Toolbox of useful Rust utilities for Tensor Foundation's Solana programs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use anchor_lang::solana_program::keccak::hashv;

pub fn validate_proof(root: &[u8; 32], leaf: &[u8; 32], proof: &[[u8; 32]]) -> bool {
    let mut path = *leaf;
    proof.iter().for_each(|sibling| {
        path = if path <= *sibling {
            hashv(&[&path, sibling]).0
        } else {
            hashv(&[sibling, &path]).0
        };
    });

    path == *root
}