State Tree Structure

Shielded State Tree Structure - Technical Specification

This document provides a detailed technical specification of the shielded state tree structure used in the Roru Protocol.

Tree Architecture

Binary Merkle Tree

Tree Type: Binary Merkle tree

Properties:

  • Depth: 32 levels

  • Capacity: 2^32 leaves (4,294,967,296 notes)

  • Hash function: SHA-256

  • Leaf nodes: Note commitments

  • Internal nodes: Hash of children

Tree Structure:

Level 0 (Root):                    [State Root]
Level 1:                    [Node 0]        [Node 1]
Level 2:              [Node 0]    [Node 1]  [Node 2]    [Node 3]
...
Level 32 (Leaves):   [Note 0] [Note 1] ... [Note 2^32-1]

Node Structure

Leaf Node:

Internal Node:

Commitment Structure

Note Commitment

Commitment Format:

Commitment Generation:

Commitment Properties:

  • Hiding: Commitment doesn't reveal value

  • Binding: Cannot change value without changing commitment

  • Additive: Can add commitments homomorphically

Tree Operations

Insertion

Insert Process:

  1. Find next available leaf position

  2. Create leaf node with commitment

  3. Update path to root

  4. Recalculate hashes

  5. Update state root

Insertion Algorithm:

Deletion (Nullification)

Nullification Process:

  1. Mark note as spent

  2. Generate nullifier

  3. Add nullifier to nullifier set

  4. Note remains in tree (for history)

  5. Cannot be used again

Nullification Algorithm:

Merkle Proofs

Proof Structure

Merkle Proof Format:

Proof Generation

Generation Algorithm:

Proof Verification

Verification Algorithm:

State Root

Root Calculation

Root Properties:

  • Commits to entire tree

  • Single hash value

  • Updated with each transaction

  • Verifiable by anyone

Root Format:

Root Updates

Update Process:

  1. Transaction processed

  2. Tree updated

  3. New root calculated

  4. Root signed

  5. Root published

Update Algorithm:

Incremental Updates

Efficient Updates

Update Strategy:

  • Only update changed paths

  • Cache intermediate hashes

  • Batch updates when possible

  • Incremental root calculation

Update Algorithm:

Sparse Tree Representation

Efficient Storage

Sparse Tree:

  • Only store non-empty nodes

  • Use hash map for nodes

  • Efficient memory usage

  • Fast lookups

Storage Format:

Sparse Tree Operations

Lookup:

Update:

Batch Operations

Batch Updates

Batch Processing:

  • Process multiple updates together

  • Optimize tree traversal

  • Reduce hash computations

  • Faster overall processing

Batch Algorithm:

Performance Characteristics

Complexity

Operations:

  • Insert: O(log n)

  • Proof generation: O(log n)

  • Proof verification: O(log n)

  • Root update: O(log n)

  • Lookup: O(log n)

Space:

  • Full tree: O(n)

  • Sparse tree: O(k log n) where k is number of notes

  • Proof size: O(log n)

Optimization

Optimization Techniques:

  • Caching intermediate hashes

  • Batch processing

  • Parallel computation

  • Efficient data structures

Security Properties

Security Guarantees

Tree Security:

  • Collision resistance (SHA-256)

  • Binding commitments

  • Tamper resistance

  • Integrity verification

Privacy:

  • Commitments hide values

  • Proofs don't reveal paths

  • No information leakage

  • Complete privacy

Conclusion

The state tree provides:

  • Efficiency: Logarithmic operations

  • Scalability: Supports billions of notes

  • Security: Cryptographic guarantees

  • Privacy: Hidden state

  • Performance: Optimized operations

Understanding the tree structure is essential for protocol development and optimization.

Last updated