Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cloak.ag/llms.txt

Use this file to discover all available pages before exploring further.

Cloak is a UTXO privacy system on Solana with four active runtime surfaces:
  • Your app’s wallet UX, encrypted local cache, and scan/export flows
  • SDK proof generation, transaction coordination, and chain-note scan/decrypt
  • Shield Pool on-chain proof verifier + state machine
  • Circuit layer constraints (2-in/2-out transaction circuit)

End-to-end flow

Cloak end-to-end runtime architecture

Core transaction model

  • The canonical path is UTXO transact / transact_swap (2 inputs, 2 outputs, tree height 32).
  • Public inputs are 264 bytes: root[32] + publicAmount[8] + extDataHash[32] + mint[32] + nullifiers[64] + commitments[64] + chainNoteHash[32].
  • publicAmount meaning:
    • > 0: deposit into pool
    • < 0: withdrawal from pool
    • = 0: shield-to-shield transfer
  • The same proof/public-input shape is consumed by the on-chain program.

Fee model (gross, fee, net)

  • Fixed fee floor: 0.005 SOL
  • Variable fee: gross * 3 / 1000
  • Total fee model: fixed + variable
  • Net recipient amount: gross - fee
  • Minimum deposit: 10_000_000 lamports
See Fee Model for a worked example and per-flow breakdown.

On-chain state

Shield Pool maintains:
  • Merkle tree (MERKLE_TREE_HEIGHT = 32)
  • Root history ring (ROOT_HISTORY_SIZE = 100)
  • Nullifier PDAs (["nullifier", pool_pubkey, nullifier_hash]) for spent checks
  • Mint-scoped Pool/Treasury PDAs (["pool", mint], ["treasury", mint])
  • SwapState PDA (["swap_state", pool_pubkey, nullifier]) for two-phase swaps

Viewing keys and history scanning

  • Viewing-key registration is enforced by default for SDK transaction paths.
  • User signs a fixed sign-in message; the SDK submits the registration and binds the 32-byte viewing key to the wallet identity.
  • Scanner path is chain-native: SDK reads program transactions from RPC, decrypts compact chain notes with nk, verifies chainNoteHash integrity, and computes running balance/fees.
  • History UIs commonly use encrypted local cache and support explicit Clear cache & rescan.

Program IDs

Current deployment program ID:
  • zh1eLd6rSphLejbFfJEneUwzHRfMKxgzrgkfwA6qRkW (default)
If your app targets a deployment with a different address, pass that programId explicitly to your SDK client.