Struct smtree::tree::SparseMerkleTree[][src]

pub struct SparseMerkleTree<P> { /* fields omitted */ }
Expand description

Paddable sparse Merkle tree.

Implementations

The constructor.

Panics if the input height exceeds MAX_HEIGHT.

A simple Merkle tree constructor, where all items are added next to each other from left to right. Note that zero padding secret is used and the height depends on the input list size. Use this helper constructor only when simulating a plain Merkle tree.

Returns the height of the SMT.

Returns the number of nodes in the SMT.

Returns the tree node by reference.

Panics if the reference is out of range.

Returns the tree node by references.

Panics if the reference is out of range.

Returns the tree node by references.

Panics if the reference is out of range.

Returns the reference to the root ndoe.

Returns the raw data of the root.

Returns the data of the root that is visible in the Merkle proof.

Returns the tree node of a queried tree index.

Panics if the the height of the input index doesn’t match with the tree height.

If the node doesn’t exist, return None.

Returns the index-reference pairs of all tree nodes in a BFS order.

Returns the index-node pairs of all tree nodes.

Returns the index-node pairs of all leaf nodes.

Returns the index-node pairs of all padding nodes.

Returns the index-node pairs of all internal nodes.

Check if the tree indexes in the list are all valid and sorted.

If the height of some index doesn’t match with the height of the tree, return TreeError::HeightNotMatch.

If the indexes are not in order, return TreeError::IndexNotSorted.

If there are duplicated indexes in the list, return TreeError::IndexDuplicated.

Construct SMT from the input list of sorted index-value pairs, index being the sorting key.

If the height of some index in the input list doesn’t match with the height of the tree, return TreeError::HeightNotMatch.

If the indexes in the input list are not in order, return TreeError::IndexNotSorted.

If there are duplicated indexes in the list, return TreeError::IndexDuplicated.

Build SMT from the input list of sorted index-value pairs, index being the sorting key.

Panics if the input list is not valid.

Update the tree by modifying the leaf node of a certain tree index.

Panics if the height of the input index doesn’t match with that of the tree.

Returns the references to the input leaf node and siblings of nodes long the Merkle path from the root to the leaf. The result is a list of references [leaf, sibling, ..., sibling].

If the input leaf node doesn’t exist, return None.

Panics if the height of the input index is different from the height of the tree.

Returns the references to the input leaves and siblings of nodes long the batched Merkle paths from the root to the leaves. The result is a list of references [leaf, ..., leaf, sibling, ..., sibling].

If the root or some input leaf node doesn’t exist, return None.

If the input list is empty, return an empty vector.

Panics if the input list is not valid.

Returns the tree index of closest left/right (depending on input direction) node in the tree.

Returns the index-reference pairs to necessary padding nodes to prove that the input index is the left/right (depending on the input direction) most real leaf in the tree. Note that the reference is the offset from the end of the sibling list.

Returns the index-reference pairs to necessary padding nodes to prove that there are no other real leaf nodes between the input indexes in the tree. Note that the reference is the offset from the end of the sibling list.

Panics if the input indexes don’t have the same height or not in the right order.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.