Expand description
This module defines the types of a binary merkle trie, generalized over a 256 bit hash function. All lookup paths in the trie are 256 bits.
All nodes are 256 bits. There are three kinds of nodes.
- Internal nodes, which each have two children. The value of an internal node is given by hashing the concatenation of the two child nodes and setting the MSB to 0.
- Leaf nodes, which have zero children. The value of a leaf node is given by hashing the concatenation of the 256-bit lookup path and the hash of the value stored at the leaf, and setting the MSB to 1.
TERMINATORnodes, which have the special value of all 0s. These nodes have no children and serve as a stand-in for an empty sub-trie at any height. Terminator nodes enable the trie to be tractably represented.
All node preimages are 512 bits.
Structs§
- Internal
Data - The data of an internal (branch) node.
- Leaf
Data - The data of a leaf node.
Enums§
- Node
Kind - The kind of a node.
Constants§
- TERMINATOR
- The terminator hash is a special node hash value denoting an empty sub-tree. Concretely, when this appears at a given location in the trie, it implies that no key with a path beginning with the location has a value.
Functions§
- is_
internal - Whether the node hash indicates the node is an internal node.
- is_leaf
- Whether the node hash indicates the node is a leaf.
- is_
terminator - Whether the node holds the special
EMPTY_SUBTREEvalue.
Type Aliases§
- KeyPath
- The path to a key. All paths have a 256 bit fixed length.
- Node
- A node in the binary trie. In this schema, it is always 256 bits and is the hash of either
an
LeafDataorInternalData, or zeroed if it’s aTERMINATOR. - Value
Hash - The hash of a value. In this schema, it is always 256 bits.