[][src]Enum exonum_merkledb::HashTag

#[repr(u8)]#[non_exhaustive]pub enum HashTag {
    Blob,
    ListBranchNode,
    ListNode,
    MapNode,
    MapBranchNode,
}

Prefixes for different types of objects stored in the database. These prefixes are necessary to provide domain separation among hashed objects of different types.

In MerkleDB, all data is presented as objects. Objects are divided into blobs and collections (lists / maps), which in their turn are divided into hashable and non-hashable. The hashable collections are ProofListIndex and ProofMapIndex. For these collections, one can define a single hash which would reflect the entire collection contents. This hash can then be used that a collection contains (or does not contain) certain elements.

Different hashes for leaf and branch nodes of the list are used to secure Merkle tree from the pre-image attack. See more information here.

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Blob

Hash prefix of a blob (i.e., a type implementing BinaryValue, which is stored in the DB as byte sequence).

ListBranchNode

Hash prefix of a branch node in a Merkle tree built for a Merkelized list.

ListNode

Hash prefix of a Merkelized list.

MapNode

Hash prefix of a Merkelized map.

MapBranchNode

Hash prefix of a branch node in a Merkle Patricia tree built for a Merkelized map.

Methods

impl HashTag[src]

pub fn hash_leaf(value: &[u8]) -> Hash[src]

Obtains a hashed value of a leaf in a Merkle tree.

pub fn hash_node(left_hash: &Hash, right_hash: &Hash) -> Hash[src]

Obtains a hashed value of a branch in a Merkle tree.

pub fn hash_single_node(hash: &Hash) -> Hash[src]

Obtains a hashed value of a Merkle tree branch with one child.

pub fn hash_list_node(len: u64, root: Hash) -> Hash[src]

Obtains hash of a Merkelized list. len is the length of the list, and root is the hash of the root node of the Merkle tree corresponding to the list.

h = sha256( HashTag::ListNode || len as u64 || merkle_root )

pub fn empty_list_hash() -> Hash[src]

Obtains hash of an empty Merkelized list.

h = sha256( HashTag::ListNode || 0 || Hash::zero() )

pub fn hash_list<V: BinaryValue + ?Sized>(values: &[V]) -> Hash[src]

Computes the hash for a Merkelized list containing the given values.

pub fn hash_map_node(root: Hash) -> Hash[src]

Obtains hash of a Merkelized map. root is the recursively defined hash of the root node of the binary Patricia Merkle tree corresponding to the map.

h = sha256( HashTag::MapNode || merkle_root )

pub fn hash_map_branch(branch_node: &[u8]) -> Hash[src]

Obtains hash of a branch node in a Merkle Patricia tree. branch_node is the binary serialization of the node.

h = sha256( HashTag::MapBranchNode || branch_node )

See ProofMapIndex for details how branch nodes are serialized.

pub fn hash_single_entry_map(path: &ProofPath, child_hash: &Hash) -> Hash[src]

Obtains hash of a Merkelized map with a single entry.

h = sha256( HashTag::MapBranchNode || path || child_hash )

See ProofMapIndex for details how path is serialized.

pub fn empty_map_hash() -> Hash[src]

Obtains hash of an empty Merkelized map.

The hash is computed as

sha256( HashTag::MapNode || Hash::zero() )

Trait Implementations

impl Clone for HashTag[src]

impl Copy for HashTag[src]

impl Debug for HashTag[src]

Auto Trait Implementations

impl RefUnwindSafe for HashTag

impl Send for HashTag

impl Sync for HashTag

impl Unpin for HashTag

impl UnwindSafe for HashTag

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,