Reference
ReferenceContract — ZentraVerifier
The Soroban verifier — methods, the authorize_action state machine, structs, events, and storage.
ZentraVerifier (Soroban) verifies proofs, enforces the state binding and
nullifier uniqueness, settles payments, and emits receipts.
Methods
register_policy(agent, policy_commitment: BytesN<32>, recipient_root: BytesN<32>, epoch_seconds: u64)
authority_state(agent, policy: BytesN<32>) -> AuthorityState
revoke_policy(agent, policy: BytesN<32>) -> Result<(), Error>
verify_proof(proof: Proof, pub_signals: Vec<Fr>) -> Result<bool, Error>
authorize_action(
agent, policy_commitment, proof_bytes: Bytes, recipient, amount: i128, asset,
invoice_hash: BytesN<32>, nullifier: BytesN<32>,
prev_epoch_id: u64, prev_spent: i128, prev_action_count: u64,
) -> Result<(), Error>authorize_action — ordered state machine
Nothing past a failing step runs:
agent.require_auth()- assert
amount > 0— elseInvalidAmount - load
PolicyRecord—PolicyNotFound;PolicyRevokedif revoked - compute
effective_prior(epoch rollover) - assert
prev_*== effective — elseStateMismatch - nullifier unused — else
NullifierUsed new_spent = prev_spent + amount,new_action_count = prev_action_count + 1— elseOverflow- build 14 public inputs + Groth16
verify— elseInvalidProof - atomic writes: mark nullifier, write
AuthorityState, extend TTLs token.transfer(agent → recipient, amount)- compute Poseidon
action_id, emitActionReceipt Ok(())
Structs
struct AuthorityState { epoch_id: u64, spent_in_epoch: i128, action_count: u64 }
struct PolicyRecord { recipient_root: BytesN<32>, epoch_seconds: u64, revoked: bool }
enum DataKey {
Policy(Address, BytesN<32>),
Authority(Address, BytesN<32>),
Nullifier(BytesN<32>),
}Events
ActionReceipt (topics ["receipt"]):
agent, policy, recipient, amount, asset, nullifier, epoch_id, new_action_count, action_idStorage
All persistent. DAY_TTL = 17280 (~1 day at 5s ledgers), RETENTION_TTL = 518400
(~30 days). Nullifiers are persistent — expiry would re-enable replay.
Built with soroban-sdk 26.1.0 (features hazmat-address, hazmat-crypto) and
soroban-poseidon; target wasm32v1-none.