semaphore_rs_hasher/lib.rs
1use bytemuck::Pod;
2
3/// Hash types, values and algorithms for a Merkle tree
4pub trait Hasher {
5 /// Type of the leaf and node hashes
6 type Hash;
7
8 /// Compute the hash of an intermediate node
9 fn hash_node(left: &Self::Hash, right: &Self::Hash) -> Self::Hash;
10}
11
12/// A marker trait that indicates some useful properties of a hash type
13///
14/// It's not strictly necessary, but for many implementations it's a useful set of constraints
15pub trait Hash: Pod + Eq + Send + Sync {}
16
17impl<T> Hash for T where T: Pod + Eq + Send + Sync {}