Function tallytree::hash::hash_node[][src]

pub fn hash_node(
    node: &Node,
    v: &Validation
) -> Result<(NodeHash, Option<TallyList>), String>
Expand description

Get the hash of a node in a merkle tally tree.

The hash value is generated from this nodes tally and if applicable the hash of the nodes child nodes or vote reference.

Example:

use tallytree::generate::generate_tree;
use tallytree::hash::hash_node;
use tallytree::Validation;
let tree = generate_tree(vec![
    ([0xaa; 32], vec![1, 0]),
    ([0xbb; 32], vec![0, 1]),
    ([0xcc; 32], vec![1, 0]),
], false).unwrap();
let hash = hash_node(&tree.unwrap(), &Validation::Strict);