NodeHasher

Trait NodeHasher 

Source
pub trait NodeHasher {
    // Required methods
    fn hash_leaf(data: &LeafData) -> [u8; 32];
    fn hash_internal(data: &InternalData) -> [u8; 32];
    fn node_kind(node: &Node) -> NodeKind;
}
Expand description

A trie node hash function specialized for 64 bytes of data.

Note that it is illegal for the produced hash to equal [0; 32], as this value is reserved for the terminator node.

A node hasher should domain-separate internal and leaf nodes in some specific way. The recommended approach for binary hashes is to set the MSB to 0 or 1 depending on the node kind. However, for other kinds of hashes (e.g. Poseidon2 or other algebraic hashes), other labeling schemes may be required.

Required Methods§

Source

fn hash_leaf(data: &LeafData) -> [u8; 32]

Hash a leaf. This should domain-separate the hash according to the node kind.

Source

fn hash_internal(data: &InternalData) -> [u8; 32]

Hash an internal node. This should domain-separate the hash according to the node kind.

Source

fn node_kind(node: &Node) -> NodeKind

Get the kind of the given node.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§