Contract 6086307a98dfe02cf67874c8bdfa5fcdcb3354ecad2cf23eca0add65bb4ff9ca

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.8#f46e9e0610213bbb72285566f9dd960ff96d03d8
rsver 1.88.0

Instances

  • CD6OCT3IVWOK5RHAHXXIOJU7NTVWNGMLC53S4WX6PL3O6PXHNENSWKQ5

Interface

Initialize the privacy contract with all denomination pools

fn initialize(env: soroban_sdk::Env) -> Result<(), ContractError>

Deposit assets into a FIXED denomination privacy pool The amount is determined by the denomination pool selected This makes ALL deposits in the same pool identical - hiding amounts from Lobstr UI

Parameters:

  • denomination: Which fixed amount pool (1, 5, 10, or 100 XLM)
  • caller: Who is depositing
  • token: Token contract address
  • commitment: Hash commitment (hiding the secret and recipient)

Example: Everyone depositing to OneXLM pool deposits exactly 1 XLM

fn deposit(
    env: soroban_sdk::Env,
    denomination: Denomination,
    caller: soroban_sdk::Address,
    token: soroban_sdk::Address,
    commitment: soroban_sdk::BytesN<32>,
) -> Result

Withdraw assets from a FIXED denomination privacy pool Uses ZK proof to prove ownership without revealing which deposit is being spent The amount is determined by the denomination pool

Parameters:

  • denomination: Which fixed amount pool to withdraw from
  • proof: ZK-SNARK proof (would use BN254 pairing check in production)
  • nullifier: Prevents double-spending (hash of secret)
  • recipient: Who receives the funds
  • token: Which token to withdraw
fn withdraw(
    env: soroban_sdk::Env,
    denomination: Denomination,
    proof: soroban_sdk::Bytes,
    nullifier: soroban_sdk::BytesN<32>,
    recipient: soroban_sdk::Address,
    token: soroban_sdk::Address,
) -> Result<(), ContractError>

Make a shielded transfer - deposit and withdraw in one transaction Both operations use the SAME denomination (same fixed amount)

fn shielded_transfer(
    env: soroban_sdk::Env,
    denomination: Denomination,
    sender: soroban_sdk::Address,
    token: soroban_sdk::Address,
    commitment: soroban_sdk::BytesN<32>,
    proof: soroban_sdk::Bytes,
    nullifier: soroban_sdk::BytesN<32>,
    recipient: soroban_sdk::Address,
) -> Result<(), ContractError>

Query if a nullifier has been used (public, for transparency)

fn is_nullifier_used_public(
    env: soroban_sdk::Env,
    nullifier: soroban_sdk::BytesN<32>,
) -> bool

Get current commitment count for a specific denomination pool

fn get_commitment_count(env: soroban_sdk::Env, denomination: Denomination) -> u32

Get commitment by index for a specific denomination pool

fn get_commitment(
    env: soroban_sdk::Env,
    denomination: Denomination,
    index: u32,
) -> Option>

Get the fixed amount for a denomination (helper for external callers)

fn get_denomination_amount_public(
    env: soroban_sdk::Env,
    denomination: Denomination,
) -> i128

Create a commitment using Poseidon hash (ZK-friendly) commitment = Poseidon(amount, secret, nullifier, recipient_hash)

fn create_commitment_hash(
    env: soroban_sdk::Env,
    amount: i128,
    secret: soroban_sdk::BytesN<32>,
    nullifier: soroban_sdk::BytesN<32>,
    recipient: soroban_sdk::Address,
) -> soroban_sdk::BytesN<32>

Create a nullifier using Poseidon hash nullifier = Poseidon(secret, index)

fn create_nullifier_hash(
    env: soroban_sdk::Env,
    secret: soroban_sdk::BytesN<32>,
    commitment_index: u32,
) -> soroban_sdk::BytesN<32>

Imports

WebAssembly Text (WAT) ▶