Function tallytree::proof::inclusion::verify_inclusion_proof[][src]

pub fn verify_inclusion_proof(
    proof: &InclusionProof,
    vote_reference: &VoteReference,
    v: &Validation
) -> Result<(NodeHash, TallyList, TallyList), String>
Expand description

Verify that a inclusion proof is valid for a vote reference.

Returns:

  • Merkle root hash of merkle proof
  • Tally of the entire tree
  • Tally for given vote reference

Example:

use tallytree::generate::generate_tree;
use tallytree::proof::inclusion::{create_inclusion_exclusion_proof, verify_inclusion_proof};
use tallytree::Validation;
use tallytree::hash::hash_node_ref;

let tree = generate_tree(vec![
  ([0xaa; 32], vec![1, 0]),
  ([0xcc; 32], vec![1, 0]),
], true).unwrap();
let v = &Validation::Strict;
let (inclusion, _) = create_inclusion_exclusion_proof(&tree, &[0xaa; 32], v).unwrap();
let (merkle_tree_hash, _, _) = verify_inclusion_proof(&inclusion, &[0xaa; 32], v).unwrap();
assert_eq!(merkle_tree_hash, hash_node_ref(&tree, v).unwrap().unwrap().0);