package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=aa2f5bc99cc4ca2217c52a1af2a2cdfd3b383208cb859ca2e79ca0903396ca1d
sha512=d68bb3eb615e3dcccc845fddfc9901c95b3c6dc8e105e39522ce97637b1308a7fa7aa1d271351d5933febd7476b2819e1694f31198f1f0919681f1f9cc97cb3a
doc/octez-libs.crypto/Tezos_crypto/Hashed/Operation_list_list_hash/index.html
Module Hashed.Operation_list_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
.