Expand description
Append-only Poseidon Merkle tree for the Vote Commitment Tree (Gov Steps V1).
This tree holds both Vote Authority Notes (VANs) and Vote Commitments (VCs) as leaves. Domain separation (DOMAIN_VAN / DOMAIN_VC) is applied when constructing leaf values (in circuits / chain); this crate stores and hashes already-committed field elements.
Insertion order (per cosmos-sdk-messages-spec):
MsgDelegateVote→ append 1 leaf (VAN)MsgCastVote→ append 2 leaves (new VAN, then VC)
§Architecture
The crate is split into server and client layers with a sync API boundary:
- Shared types (
MerkleHashVote,Anchor,MerklePath) — used by both sides. TreeServer— authoritative full tree: append, checkpoint, serve data viaTreeSyncApi.TreeClient— sparse tree: sync from server, mark positions, generate witnesses.TreeSyncApi— trait defining the communication boundary (in-process for POC, maps to Cosmos SDK endpoints in production).
Built on incrementalmerkletree / shardtree (same crates that back Orchard’s
note commitment tree), with two substitutions:
- Hash: Poseidon (no layer tagging) instead of Sinsemilla
- Empty leaf:
poseidon_hash(0, 0)instead ofFp::from(2)
Re-exports§
pub use client::SyncError;pub use client::TreeClient;pub use server::AppendFromKvError;pub use server::MemoryTreeServer;pub use server::SyncableServer;pub use server::TreeServer;pub use sync_api::TreeSyncApi;
Modules§
- client
- Client-side vote commitment tree.
- kv_
shard_ store KvShardStore— aShardStoreimplementation backed by Go’s Cosmos KV store via C function pointer callbacks.- memory_
server SyncableServer— augments [GenericTreeServer] with per-block leaf tracking and implementsTreeSyncApifor in-process sync.- serde
- Binary serialization for shard trees and checkpoints.
- server
- Generic and production vote commitment tree servers.
- sync_
api - Communication boundary between server and client.
Structs§
- Anchor
- A committed vote commitment tree root at a specific block height.
- Merkle
Hash Vote - Leaf and internal node digest for the vote commitment tree.
- Merkle
Path - Merkle authentication path from a leaf to the tree root.
Constants§
- DOMAIN_
VC - Domain tag for Vote Commitments (matches
orchard::vote_proof::circuit::DOMAIN_VC). - MERKLE_
PATH_ BYTES - Serialized size: 4 bytes (position u32 LE) + 32 * TREE_DEPTH bytes (auth path).
- TREE_
DEPTH - Fixed depth of the Vote Commitment Tree (2^24 ≈ 16.7M leaf capacity).
Functions§
- poseidon_
hash - Poseidon hash of two field elements (delegates to imt-tree for circuit consistency).
- poseidon_
hash_ 6 - Poseidon hash of six field elements (
ConstantLength<6>, width 3, rate 2). - vote_
commitment_ hash - Compute the vote commitment leaf hash (arity-5 Poseidon).