CommitmentTree (Anoma v0.34.0)

A simple commitment tree.

Currently stores all commitments forever, and stores the full tree in memory, pending future more sophisticated retention policies. Does not yet store any anchors itself for the same reason--this is a complex policy level decision.

Has a fixed depth.

Fiats that empty subtrees have a hash of 0 for simplicity.

Summary

Functions

Adds commitments to the commitment tree, and returns the new tree and the anchor. TODO handle the tree's filling up

Creates a new CommitmentTree struct.

Types

t()

@type t() :: %CommitmentTree{
  map: %{required(binary()) => non_neg_integer()},
  root: CommitmentTree.Node.t(),
  size: integer(),
  spec: CommitmentTree.Spec.t()
}

Functions

add(tree, cms)

@spec add(t(), [binary()]) :: tuple()

Adds commitments to the commitment tree, and returns the new tree and the anchor. TODO handle the tree's filling up

from_noun(list)

@spec from_noun(Noun.t()) :: {:ok, t()} | :error

new(spec)

@spec new(CommitmentTree.Spec.t()) :: t()

Creates a new CommitmentTree struct.

prove(tree, i)

@spec prove(t(), integer() | binary()) :: CommitmentTree.Proof.t()