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:
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:
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>