A trustless on-chain Semaphore group tree for Soroban/Stellar, companion to the semaphore-stellar library.
In the base library the Merkle tree is kept off-chain and the admin pushes roots (a trust
assumption). Here the tree lives on-chain: members are appended and the Merkle root is
computed on-chain from the actual membership, using a circomlib-compatible Poseidon (via
soroban-poseidon over CAP-75) and the @zk-kit LeanIMT rule. No one — not even the admin —
can publish a root that does not match the real members: the root is derived, not asserted.
The on-chain root is identical to what Semaphore's Group / @zk-kit LeanIMT computes, so
it interoperates with the sdk-29 verifier in the main library.
create_group(admin)→ group idadd_member(group_id, commitment)→ new count (recomputes + emits the root on-chain)root(group_id)→ current Merkle rootmember_count(group_id)
cargo test # on-chain Poseidon == circomlib; on-chain root == @zk-kit LeanIMT (sizes 1..5)
stellar contract buildLive on testnet (see DEPLOYMENT.md): adding members 1..5 yields the exact @zk-kit LeanIMT
root 11512324111804726054755717642058292259866309947044530224809882918003853859592.
Built against soroban-sdk 28 because the Poseidon host primitive is currently only reachable
through soroban-poseidon (sdk-28). The sdk-29 contracts in the other repos consume the root it
produces unchanged. Once the SDK exposes a public Poseidon (≥29), this can move to sdk 29.
⚠️ Prototype — unaudited, testnet only. This code has not been audited and runs only on Stellar testnet with small fixtures. Do not use it with real value or on mainnet.
add_memberrecomputes the whole LeanIMT root on-chain (O(n) hashes per add, O(n²) over a group's life) — large groups can hit Soroban resource limits. An incremental-root optimization is planned.- No dedup of commitments and no max-depth cap; the Semaphore circuit assumes a fixed maximum depth, which the caller must respect.
- Storage TTL is managed:
create_group/add_memberextend the instance storage and the group's admin + leaves entries by ~30 days (bumping when under ~15 days remain), so an actively-used group never archives. A group left completely idle past the bump window still needs a one-time Sorobanrestore.
Proofs reuse Ethereum's Semaphore trusted-setup ceremony (no new ceremony is performed).
MIT — see LICENSE.