IncrementalMerkleTree

scalus.crypto.tree.IncrementalMerkleTree
See theIncrementalMerkleTree companion object

Off-chain incremental Merkle tree.

Fixed-depth binary Merkle tree backed by a persistent (structurally-shared) tree.

  • append replaces one leaf and rebuilds O(depth) nodes on the path — everything else is shared with the previous version.
  • rootHash is O(1) — just the root node's hash.
  • proveMembership / proveAppend walk root→leaf collecting siblings — O(depth).
  • Empty subtrees are shared: an empty tree of depth 20 uses only 21 node objects.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

Append a new key to the next available slot.

Append a new key to the next available slot.

Attributes

def capacity: Int

Number of leaf slots (2^depth).

Number of leaf slots (2^depth).

Attributes

def contains(key: ByteString): Boolean

Check if a key is in the tree.

Check if a key is in the tree.

Attributes

Generate an append proof for the next empty slot.

Generate an append proof for the next empty slot.

Returns siblings (D * 32 bytes) for slot size.

Attributes

Generate a membership proof for a key.

Generate a membership proof for a key.

Returns D * 33 bytes: D repetitions of (direction[1] + sibling[32]). direction is 0 (left child) or 1 (right child).

Attributes

Current root hash.

Current root hash.

Attributes

Concrete fields

val depth: Int
val size: Int