Smart Contract Reference
Pool Contract
The core privacy pool. Handles atomic ZK transactions (deposit, withdraw, transfer) and operator disbursements for x402 payments.
transact(proof, ext_data, sender)
Execute an atomic ZK transaction. The contract:
- Verifies the Groth16 proof via the verifier contract
- Checks that the Merkle root matches a stored root
- Verifies input nullifiers are not spent, then marks them
- Transfers USDC (direction depends on
ext_amountsign) - Inserts output commitments into the Merkle tree
Parameters:
proof: Groth16 proof struct (a, b, c points + public inputs)ext_data: External data (recipient, ext_amount, encrypted_output0, encrypted_output1)sender: Address that authorizes the transaction
disburse(recipient, amount)
Operator-only. Transfer USDC from pool to a registered service address. Used by the batch operator for x402 payments.
get_root() → U256
Read the current Merkle tree root. No gas cost (read-only simulate).
update_asp_membership(new_contract_id)
Admin-only. Update the ASP membership contract reference.
Groth16 Verifier Contract
Verifies Groth16 proofs on-chain using Stellar Protocol 25 BN254 host functions.
verify(proof, public_inputs) → bool
Performs the BN254 pairing check: e(A, B) = e(alpha, beta) * e(IC, gamma) * e(C, delta)
Uses native host functions: bn254_g1_add, bn254_g1_mul, bn254_pairing_check.
ASP Membership Contract
Binary Merkle tree (10 levels) for inclusion proofs.
insert_leaf(leaf) → (index, root)
Insert a new leaf. Returns the leaf index and updated root.
get_root() → U256
Current tree root.
ASP Non-Membership Contract
Sparse Merkle tree (10 levels) for exclusion proofs.
insert(key, value)
Insert or update a key-value pair.
delete(key)
Remove a key.
verify_non_membership(key, siblings) → bool
Verify that a key does NOT exist in the tree.