The Soroban contract is the on-chain execution boundary for the Stellar privacy pool.

Entrypoint

The current contract exposes one public transaction entrypoint:
pub fn transact(
    env: &Env,
    from: Address,
    proof_bytes: Bytes,
    pub_signals_bytes: Bytes,
    encoded: Bytes,
) -> Result<(), Error>
The method handles private transfers and public token legs through proof inputs and public signals.
ArgumentSourceMeaning
fromStellar walletAuthenticated transaction signer
proof_bytesSDKSerialized Groth16 proof
pub_signals_bytesSDKSerialized public inputs/outputs for the circuit
encodedApplication/SDK flowEncrypted audit payload emitted by the contract

Execution sequence

Contract responsibilities

  • Require authentication from from.
  • Parse Groth16 proof bytes and public signal bytes.
  • Check that stateRoot is in recent root history.
  • Read nullifier hashes from public signals and reject reused hashes.
  • Verify the proof with the stored verification key.
  • Store either zero output commitments or exactly two output commitments.
  • Store leaf ephemeral BabyJubJub public keys next to commitment leaves.
  • Update LeafCount, TREE_ROOT_KEY, PairwiseFrontier, and the root-history ring buffer.
  • Apply public deposit transfers from from to the contract.
  • Apply public withdrawal transfers from the contract to the public Stellar account encoded in withdrawAddressHi / withdrawAddressLo.
  • Emit AuditEncodedDigest with message_name = "transact" and digest = encoded.

Operation shapes

The user-facing operation names map to the single transact entrypoint.
User-facing operationtransact representation
DepositPublic deposit token leg plus one or two private output commitments
WithdrawalPrivate input commitment spend plus public withdrawal token leg
TransferPrivate input commitment spend plus private output commitments
Mixed transactionCombination of private input spends, private output commitments, public deposits, and public withdrawals

Public getters

The contract exposes getters for pool state used by applications and the SDK:
GetterPurpose
get_merkle_rootCurrent Merkle root
get_merkle_depthTree depth
get_commitment_countNumber of stored leaves
get_commitmentsCommitment leaves
get_leaf_ephemeralEphemeral public key for a leaf
get_pairwise_frontierCurrent pairwise frontier
is_nulifier_hash_consumedNullifier-consumed check
is_known_rootRoot-history membership check
get_token_balanceToken balance held by the contract
get_public_slot_configPublic input/output slot configuration
get_adminContract admin

Audit event

The contract event is the handoff from the on-chain privacy pool to the off-chain audit pipeline:
#[contractevent(topics = ["audit", "encoded_digest"], data_format = "single-value")]
pub struct AuditEncodedDigest {
    #[topic]
    message_name: String,
    digest: Bytes,
}
The Stellar scanner maps the audit topic to event_type = transact and stores digest as audit.cyphertext.