StarkCloak

Prize winner, Starknet Resolve

what it is

StarkCloak is a privacy-preserving mixer for Starknet that lets users break the on-chain link between their wallets.

Every swap, bridge and transfer adds to a traceable record. Exchanges tie KYC data to wallets, and trackers and indexers show holdings and transfers in real time. Moving to a new wallet does not help, because the transfer itself reveals the connection.

With StarkCloak, a wallet deposits ERC-20 tokens together with a hidden commitment. Later, the same user or another wallet withdraws the tokens to a new address by presenting the secret behind that commitment, with nothing on-chain connecting the withdrawal to the original deposit.

how it's made

The mixer is a Cairo contract deployed on Starknet Sepolia, with a React frontend and a Node.js backend intended to run in a TEE. The user first generates a secret and a nullifier and computes commitment = Poseidon(secret, nullifier).

  • Deposit: the user approves the mixer to spend their ERC-20 tokens and calls deposit(commitment, amount). The contract pulls the tokens, stores the commitment and emits a Deposit event.
  • Merkle tree: the backend listens for deposits, builds a Merkle tree with pairwise-sorted hashing, and calls update_root(new_root) on-chain as the contract owner.
  • Withdraw: the user requests a Merkle proof for their commitment and calls withdraw(merkle_proof, secret, nullifier, recipient, amount). The contract recomputes the commitment, verifies the proof, checks the nullifier has not been spent, and transfers the tokens to the recipient.

The harder parts were keeping the backend's Merkle root in sync with on-chain state, handling non-standard ERC-20 allowances on Starknet, and designing the frontend so that API calls do not expose the user.