package octez-libs

  1. Overview
  2. Docs
A package that contains multiple base libraries used by the Octez suite

Install

Dune Dependency

Authors

Maintainers

Sources

tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65

doc/octez-libs.tezos-sapling/Tezos_sapling/Storage/Make_Storage/Tree/index.html

Module Make_Storage.TreeSource

Sourcemodule H = C.Hash
Sourceval max_uint32 : int64

Incremental Merkle Tree * * A tree of height h contains 2^h leaves and h+1 levels of nodes with * leaves at level 0 and root at level h. * * The leaves are commitments and the tree is treated as always filled * with a default value H.uncommitted. This allows to have proofs of * membership, or witnesses, of fixed size. * * All the nodes at the same level of an empty tree have the same hash, * which can be computed from the default value of the leaves. This is * stored in the uncommitted list. * * Any subtree filled with default values is represented by the Empty * constructor and given its height it's possible to compute its hash * using the uncommitted list. * * The leaves are indexed by their position pos, ranging from 0 to * (2^h)-1. The encoding of pos limits the possible size of the tree. * In any case the only valid height for the Sapling library is 32, so even * if the library encodes positions as uint64, they never exceed uint32. * * The tree is incremental in the sense that leaves cannot be modified but * only added and exclusively in successive positions. * The type t contains the size of the tree which is also the next position * to fill. * * Given that elements are added and retrieved by position, it is possible * to use this information to efficiently navigate the tree. * Given a tree of height h and a position pos, if pos < pow2 (h-1) only * the left subtree needs to be inspected recursively. Otherwise only the * right needs to be visited, decreasing pos by pow2 (h-1). * * In order to avoid storing the height for each subtree (or worse * recomputing it), each function with suffix `_height` expects the height * of the tree as parameter. These functions are only for internal use and * are later aliased by functions using the default height of a Sapling * incremental Merkle tree.

Sourcetype tree =
  1. | Empty
  2. | Leaf of C.Commitment.t
  3. | Node of H.t * tree * tree
Sourceval get_root_height : tree -> int -> H.t
Sourceval pow2 : int -> int64
Sourceval split_at : Tezos_stdlib.Compare.Int64.t -> 'a list -> 'a list * 'a list
Sourceval hash : height:int -> tree -> tree -> H.t
Sourceval insert_node : tree -> tree -> int -> Tezos_stdlib.Compare.Int64.t -> C.Commitment.t list -> tree
Sourceval get_cm_height : tree -> Tezos_stdlib.Compare.Int64.t -> int -> C.Commitment.t
Sourceval get_witness_height : tree -> int -> Tezos_stdlib.Compare.Int64.t -> bytes

Create the witness in the format required by Sapling.

  • height of the merkle tree (32 for Sapling)
  • a list of size of hash (32 for Pedersen hash) and hash
  • the position as little-endian uint64
Sourceval fold_from_height : pos:Tezos_stdlib.Compare.Int64.t -> f:('a -> C.Commitment.t -> 'a) -> init:'a -> tree -> int -> 'a
Sourcetype t = int64 * tree
Sourceval encoding : (int64 * tree) Data_encoding.encoding
Sourceval empty : int64 * tree
Sourceval size : ('a * 'b) -> 'a
Sourceval default_height : int
Sourceval max_size : int64
Sourceval get_root : ('a * tree) -> H.t
OCaml

Innovation. Community. Security.