{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// Private Pool V2 — concrete TypeScript types.\n//\n// Single source of truth for shapes flowing between:\n//   - Browser key derivation (lib/private-pool-keys.ts)\n//   - Note encryption (lib/private-pool-notes.ts)\n//   - Witness builder (lib/private-pool-witness.ts)\n//   - Browser prover (lib/private-pool-prover.ts)\n//   - On-chain submission (api/private-pool/v2/* routes)\n//   - Node-side circuit smoke tests (contracts/scripts/private-pool-v2/)\n//\n// Reference: docs/PRIVATE_POOL_V2_DESIGN.md §17 (Appendix), ADR-001\n// (commitment), ADR-002 (key derivation), ADR-003 (encryption).\n\n// ─────────────────────────────────────────────────────────────────────\n// Constants — kept in code (not env) because changing them changes\n// the circuit + on-chain program; not a runtime tunable.\n// ─────────────────────────────────────────────────────────────────────\n\n/** Pool merkle tree depth — 4B notes capacity. */\nexport const POOL_DEPTH = 32\n\n/** ASP merkle tree depth — same as pool for symmetric witness costs. */\nexport const ASP_DEPTH = 32\n\n/** USDC base unit (6 decimals → micro-USDC). */\nexport const USDC_DECIMALS = 6\n\n// ─────────────────────────────────────────────────────────────────────\n// Payment address — share-friendly identifier the recipient hands to\n// senders. Encodes both spending and viewing public keys (ADR-002).\n// ─────────────────────────────────────────────────────────────────────\nexport interface PaymentAddress {\n  /** 32-byte spending public key (Poseidon1(spending_sk)) — used in commitments. */\n  spendingPk: Uint8Array\n  /** 32-byte X25519 viewing public key — used to encrypt notes for the recipient. */\n  viewingPk: Uint8Array\n}\n\n/** Base58Check encoding of `spendingPk || viewingPk`. ~88-char string. */\nexport type PaymentAddressString = string\n\n// ─────────────────────────────────────────────────────────────────────\n// Note material — the contents of a single private balance entry.\n//\n// `commitment` is computed from (value, ownerPk, blinding, memo) per\n// ADR-001. `spent` and `leafIndex` are off-chain tracking fields the\n// browser maintains; on-chain data only includes the commitment.\n// ─────────────────────────────────────────────────────────────────────\n\nexport interface DecryptedNote {\n  /** Micro-USDC value stored in the note. */\n  value: bigint\n  /** 32-byte recipient pubkey (== owner spending_pk). */\n  ownerPk: Uint8Array\n  /** 32-byte random blinding factor. */\n  blinding: Uint8Array\n  /** Optional 32-byte memo, or null if no memo. */\n  memo: Uint8Array | null\n}\n\nexport interface OwnedNote extends DecryptedNote {\n  /** Position in the pool's commitment tree, set when the note was added. */\n  leafIndex: number\n  /** Slot at which the note was added on chain. */\n  receivedAtSlot: number\n  /** True iff we've observed a tx that spent this note's nullifier. */\n  spent: boolean\n  /** Cached commitment (= Poseidon4 of the note fields). */\n  commitment: Uint8Array\n  /** Cached nullifier (= Poseidon2(commitment, nullifier_sk)). */\n  nullifier: Uint8Array\n}\n\n// ─────────────────────────────────────────────────────────────────────\n// Encrypted note blob — the on-chain (or indexer-served) wire format.\n// Per ADR-003: ChaCha20-Poly1305 + X25519 ephemeral.\n// ─────────────────────────────────────────────────────────────────────\nexport interface EncryptedNoteBlob {\n  /** 32-byte commitment of the note this blob describes. */\n  commitment: Uint8Array\n  /** 32-byte X25519 ephemeral public key the sender used. */\n  ephemeralPk: Uint8Array\n  /** ChaCha20-Poly1305 ciphertext + 16-byte tag (96 bytes for memo-less, 128 with memo). */\n  ciphertext: Uint8Array\n  /** Slot at which the blob was added on chain. */\n  slot: number\n  /** Position in the commitment tree (matches OwnedNote.leafIndex). */\n  leafIndex: number\n}\n\n// ─────────────────────────────────────────────────────────────────────\n// Merkle inclusion witness — pool or ASP path proving membership.\n// ─────────────────────────────────────────────────────────────────────\nexport interface MerklePath {\n  /** 32-byte hash siblings, leaf-to-root order (length == depth). */\n  pathElements: Uint8Array[]\n  /** Bit per level: 0 = leaf is left child, 1 = leaf is right child (length == depth). */\n  pathIndices: number[]\n  /** 32-byte root that this path verifies under. */\n  root: Uint8Array\n}\n\n// ─────────────────────────────────────────────────────────────────────\n// Circuit witnesses — what we feed to snarkjs.fullProve().\n//\n// Field elements are passed as decimal strings (snarkjs's preferred\n// shape). Arrays match circuit signal array sizes (32-deep paths).\n// ─────────────────────────────────────────────────────────────────────\n\n/** Witness for `Deposit.circom`. */\nexport interface DepositWitness {\n  // private\n  ownerPk: string\n  blinding: string\n  memo: string\n\n  // public\n  publicValue: string\n  depositorAddrHash: string\n  fee: string\n}\n\n/** Witness for `Withdraw.circom`. */\nexport interface WithdrawWitness {\n  // private\n  value: string\n  ownerPk: string\n  blinding: string\n  memo: string\n  spendingSk: string\n  nullifierSk: string\n\n  poolPathElements: string[]   // length POOL_DEPTH\n  poolPathIndices: number[]    // length POOL_DEPTH\n  aspPathElements: string[]    // length ASP_DEPTH\n  aspPathIndices: number[]     // length ASP_DEPTH\n\n  // public\n  publicValue: string\n  publicAddress: string\n  fee: string\n}\n\n/** Witness for `CashoutProof.circom` (ADR-012 V3). */\nexport interface CashoutProofWitness {\n  // private\n  value: string\n  ownerPk: string\n  blinding: string\n  memo: string\n  spendingSk: string\n  nullifierSk: string\n\n  // Credit-pool merkle inclusion (depth 24).\n  creditPoolPathElements: string[]\n  creditPoolPathIndices: number[]\n\n  // public\n  publicValue: string\n  publicAddress: string\n  fee: string\n}\n\n/** Witness for `JoinSplit2x2.circom`. */\nexport interface JoinSplitWitness {\n  // ── input note 1 ──\n  inputValue1: string\n  inputOwnerPk1: string\n  inputBlinding1: string\n  inputMemo1: string\n  inputPoolPath1: string[]\n  inputPoolIndices1: number[]\n  inputAspPath1: string[]\n  inputAspIndices1: number[]\n\n  // ── input note 2 ──\n  inputValue2: string\n  inputOwnerPk2: string\n  inputBlinding2: string\n  inputMemo2: string\n  inputPoolPath2: string[]\n  inputPoolIndices2: number[]\n  inputAspPath2: string[]\n  inputAspIndices2: number[]\n\n  // ── spending authority ──\n  spendingSk: string\n  nullifierSk: string\n\n  // ── output note 1 ──\n  outputValue1: string\n  outputOwnerPk1: string\n  outputBlinding1: string\n  outputMemo1: string\n\n  // ── output note 2 ──\n  outputValue2: string\n  outputOwnerPk2: string\n  outputBlinding2: string\n  outputMemo2: string\n\n  // ── public inputs ──\n  publicValueIn: string\n  publicValueOut: string\n  publicAddress: string\n  fee: string\n}\n\n// ─────────────────────────────────────────────────────────────────────\n// Public signals — what the verifier consumes after fullProve().\n//\n// Order matches circom's \"outputs in source order, then public inputs\n// alphabetical\" — see circuit headers for canonical layout. The\n// on-chain program reads these in the same order.\n// ─────────────────────────────────────────────────────────────────────\n\nexport interface DepositPublicSignals {\n  /** outputCommitment */\n  outputCommitment: string\n  /** depositorAddrHash */\n  depositorAddrHash: string\n  /** fee */\n  fee: string\n  /** publicValue */\n  publicValue: string\n}\n\nexport interface WithdrawPublicSignals {\n  /** nullifier */\n  nullifier: string\n  /** root */\n  root: string\n  /** aspRoot */\n  aspRoot: string\n  /** fee */\n  fee: string\n  /** publicAddress */\n  publicAddress: string\n  /** publicValue */\n  publicValue: string\n}\n\nexport interface JoinSplitPublicSignals {\n  /** inputNullifier1 */\n  inputNullifier1: string\n  /** inputNullifier2 */\n  inputNullifier2: string\n  /** outputCommitment1 */\n  outputCommitment1: string\n  /** outputCommitment2 */\n  outputCommitment2: string\n  /** root */\n  root: string\n  /** aspRoot */\n  aspRoot: string\n  /** fee */\n  fee: string\n  /** publicAddress */\n  publicAddress: string\n  /** publicValueIn */\n  publicValueIn: string\n  /** publicValueOut */\n  publicValueOut: string\n}\n\n// ─────────────────────────────────────────────────────────────────────\n// Proof + tx envelopes — what the client sends to the server route.\n// ─────────────────────────────────────────────────────────────────────\n\nexport interface Groth16Proof {\n  pi_a: string[]\n  pi_b: string[][]\n  pi_c: string[]\n  protocol: 'groth16'\n  curve: 'bn128'\n}\n\nexport interface DepositTx {\n  proof: Groth16Proof\n  publicSignals: DepositPublicSignals\n  encryptedNote: EncryptedNoteBlob\n}\n\nexport interface WithdrawTx {\n  proof: Groth16Proof\n  publicSignals: WithdrawPublicSignals\n}\n\nexport interface JoinSplitTx {\n  proof: Groth16Proof\n  publicSignals: JoinSplitPublicSignals\n  /** Length 2; one blob per output commitment. */\n  encryptedNotes: [EncryptedNoteBlob, EncryptedNoteBlob]\n}\n\n// ─────────────────────────────────────────────────────────────────────\n// Pool config — fetched at /api/private-pool/v2/config.\n// ─────────────────────────────────────────────────────────────────────\n\nexport interface PoolConfig {\n  /** Solana program ID hosting the pool (or EVM contract address). */\n  programId: string\n  /** USDC mint / token contract for this pool. */\n  usdcMint: string\n  /** Relayer pubkey (sponsored fee payer). */\n  relayerAddress: string\n  /** Network identifier — `solana-devnet`, `solana`, etc. */\n  network: string\n  /** Current pool merkle root (hex). */\n  currentRoot: string\n  /** Most recent ASP root (hex). */\n  currentAspRoot: string\n  /** Snapshot age — seconds since the ASP root was published. */\n  aspAgeSeconds: number\n  /** 32-byte commitment of `DUMMY_A` — used to pad single-input JoinSplits. */\n  dummyACommitment: string\n  /** 32-byte commitment of `DUMMY_B` — used in 0-input edge cases. */\n  dummyBCommitment: string\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,IAAM,aAAa;AAGnB,IAAM,YAAY;AAGlB,IAAM,gBAAgB;","names":[]}