org.sigilaris.core.merkle

Members list

Type members

Classlikes

object MerkleTrie

Merkle Trie operations providing key-value storage with cryptographic verification.

Merkle Trie operations providing key-value storage with cryptographic verification.

A Merkle Trie is a tree structure where:

  • Keys are represented as Nibbles (4-bit sequences)
  • Each node has a hash computed from its contents
  • The root hash uniquely identifies the entire tree state

All operations are effectful and maintain state through MerkleTrieState, which tracks the root hash and accumulated differences.

Attributes

See also

MerkleTrieNode for node structure

MerkleTrieState for state management

Nibbles for key representation

Source
MerkleTrie.scala
Supertypes
class Object
trait Matchable
class Any
Self type
MerkleTrie.type
sealed trait MerkleTrieNode

Represents a node in a Merkle Trie.

Represents a node in a Merkle Trie.

Merkle Trie consists of three types of nodes:

  • Leaf: Terminal node storing a key-value pair
  • Branch: Branch node with only child nodes
  • BranchWithData: Branch node with both child nodes and a value

Attributes

See also

MerkleTrieNode.Leaf for terminal nodes

MerkleTrieNode.Branch for branch nodes

MerkleTrieNode.BranchWithData for branch nodes with values

Example
 val leaf = MerkleTrieNode.leaf(
   prefix = ByteVector(0x12, 0x34).toNibbles,
   value = ByteVector(0xab, 0xcd),
 )
Companion
object
Source
MerkleTrieNode.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Branch
class Leaf

Companion object for MerkleTrieNode with constructors and type definitions.

Companion object for MerkleTrieNode with constructors and type definitions.

Attributes

Companion
trait
Source
MerkleTrieNode.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class MerkleTrieState(root: Option[MerkleRoot], base: Option[MerkleRoot], diff: MerkleTrieStateDiff)

Represents the state of a Merkle Trie with change tracking.

Represents the state of a Merkle Trie with change tracking.

Tracks the current root, base root, and accumulated differences to enable efficient state transitions and merging.

Value parameters

base

base root hash (for tracking changes)

diff

accumulated differences from base

root

current root hash

Attributes

See also

MerkleTrieStateDiff for difference tracking

MerkleTrieNode.MerkleRoot for root hash type

Companion
object
Source
MerkleTrieState.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Companion object for MerkleTrieState with constructors.

Companion object for MerkleTrieState with constructors.

Attributes

Companion
class
Source
MerkleTrieState.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Companion object for MerkleTrieStateDiff with operations.

Companion object for MerkleTrieStateDiff with operations.

Attributes

Source
MerkleTrieStateDiff.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object Nibbles

Companion object for Nibbles providing creation and manipulation methods.

Companion object for Nibbles providing creation and manipulation methods.

Attributes

Source
Nibbles.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Nibbles.type

Types

opaque type MerkleTrieStateDiff

Tracks differences in Merkle Trie state using reference counting.

Tracks differences in Merkle Trie state using reference counting.

Maintains a map from node hashes to (node, reference count) pairs. Positive counts indicate additions, negative counts indicate removals.

Attributes

See also

MerkleTrieState for usage context

Source
MerkleTrieStateDiff.scala
opaque type Nibbles

Represents a bit vector aligned to 4-bit boundaries.

Represents a bit vector aligned to 4-bit boundaries.

Used to represent key paths in Merkle Tries, where each nibble has a value in the range 0-15.

Attributes

Note

The bit size must always be a multiple of 4.

Example
 val bytes   = ByteVector(0x12, 0x34)
 val nibbles = bytes.toNibbles
 nibbles.hex        // "1234"
 nibbles.nibbleSize // 4
Source
Nibbles.scala