package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/octez-libs.crypto/Tezos_crypto/Hashed/Operation_metadata_list_hash/index.html
Module Hashed.Operation_metadata_list_hash
Source
The element type elt
of the Merkle tree.
elt_bytes x
returns the byte sequence representation of the element x
.
include Tezos_stdlib.Compare.S with type t := t
hash_string ?key inputs
returns a hash.
Raises an Assert_failure
if String.length key > 64
.
compute xs
computes a full binary tree from the list xs
.
In this tree the ith leaf (from left to right) is the ith element of the list xs
. If xs
is the empty list, then the result is the empty tree. If the length of xs
is not a power of 2, then the tree is padded with leaves containing the last element of xs
such that a full tree is obtained.
Example: given the list [1; 2; 3]
, the tree
/\ / \ /\ /\ 1 2 3 3
is built.
A path
to an element in a Merkle tree.
A path
is either:
Left (p, r)
, indicating that the element is in the left subtree, from which the pathp
should be taken to find the element.r
is the left subtree where this branching decision is made.Right (l, p)
, indicating that the element is in the right subtree, from which the pathp
should be taken to find the element.l
is the left subtree where this branching decision is made.Op
, indicating that the path traversal has reached the element.
Example:
/\ / \ /\ /\ 4 5 6 7
The path to the third leaf, containing 6
will be:
Right (node (leaf 4, leaf 5), Left (Op, leaf 7))
Consequently, the path will contain all the information to reconstruct the full tree, except the element to which the path lead.
Encoding of a path.
Encoding of a path, with optional bound max_length
.
The encoding is bounded to log2(max_length) * (size + 1) + 1
bytes.
compute_path xs i
computes the path to the i
th leaf of the Merkle tree computed from xs
, that will also contain the ith element of xs
.