@permissionless-technologies/upp-sdk 0.4.21 → 0.4.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +7 -3
  2. package/dist/chunk-2BSIUEPO.js +343 -0
  3. package/dist/chunk-2BSIUEPO.js.map +1 -0
  4. package/dist/{chunk-V6MW5VOF.cjs → chunk-632LPXPX.cjs} +4 -4
  5. package/dist/{chunk-V6MW5VOF.cjs.map → chunk-632LPXPX.cjs.map} +1 -1
  6. package/dist/{chunk-ND56VNCF.js → chunk-D4VCRPKS.js} +2 -2
  7. package/dist/{chunk-ND56VNCF.js.map → chunk-D4VCRPKS.js.map} +1 -1
  8. package/dist/{chunk-YHBUCKVS.cjs → chunk-DYSU7JYL.cjs} +23 -23
  9. package/dist/{chunk-YHBUCKVS.cjs.map → chunk-DYSU7JYL.cjs.map} +1 -1
  10. package/dist/{chunk-RYEYGGE7.cjs → chunk-IX7HV5TE.cjs} +18 -5
  11. package/dist/chunk-IX7HV5TE.cjs.map +1 -0
  12. package/dist/{chunk-5H27F6W6.cjs → chunk-IYRCJAME.cjs} +13 -9
  13. package/dist/chunk-IYRCJAME.cjs.map +1 -0
  14. package/dist/{chunk-KRLRJ3HN.js → chunk-KR4GB6VC.js} +18 -5
  15. package/dist/chunk-KR4GB6VC.js.map +1 -0
  16. package/dist/{chunk-C7DUABSG.js → chunk-Q6BLTPWV.js} +13 -9
  17. package/dist/chunk-Q6BLTPWV.js.map +1 -0
  18. package/dist/{chunk-7VPW5T5R.js → chunk-UMWY4ICQ.js} +3 -3
  19. package/dist/{chunk-7VPW5T5R.js.map → chunk-UMWY4ICQ.js.map} +1 -1
  20. package/dist/{chunk-PZAV2S5E.cjs → chunk-UYPIWBKM.cjs} +2 -2
  21. package/dist/{chunk-PZAV2S5E.cjs.map → chunk-UYPIWBKM.cjs.map} +1 -1
  22. package/dist/chunk-VVW5VVY3.cjs +347 -0
  23. package/dist/chunk-VVW5VVY3.cjs.map +1 -0
  24. package/dist/{chunk-OLJFKARA.js → chunk-XDWRMHLY.js} +15 -15
  25. package/dist/{chunk-OLJFKARA.js.map → chunk-XDWRMHLY.js.map} +1 -1
  26. package/dist/core/index.cjs +80 -67
  27. package/dist/core/index.d.cts +2 -2
  28. package/dist/core/index.d.ts +2 -2
  29. package/dist/core/index.js +5 -4
  30. package/dist/core/proof-worker-entry.cjs +8 -8
  31. package/dist/core/proof-worker-entry.cjs.map +1 -1
  32. package/dist/core/proof-worker-entry.js +8 -8
  33. package/dist/core/proof-worker-entry.js.map +1 -1
  34. package/dist/{index-PgqOAfcc.d.cts → index-AooYZ0kF.d.cts} +1 -1
  35. package/dist/{index-DsXMd8zh.d.ts → index-CpfUNGm9.d.ts} +1 -1
  36. package/dist/{index-DmowSsZb.d.ts → index-De5B4r0l.d.ts} +9 -3
  37. package/dist/{index-DcfqeWvk.d.cts → index-hNuffoCo.d.cts} +9 -3
  38. package/dist/index.cjs +88 -75
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +3 -3
  41. package/dist/index.d.ts +3 -3
  42. package/dist/index.js +6 -5
  43. package/dist/index.js.map +1 -1
  44. package/dist/indexer/index.cjs +6 -6
  45. package/dist/indexer/index.d.cts +5 -5
  46. package/dist/indexer/index.d.ts +5 -5
  47. package/dist/indexer/index.js +1 -1
  48. package/dist/{proof-VINVGL4F.cjs → proof-X3MVQFFZ.cjs} +14 -13
  49. package/dist/{proof-VINVGL4F.cjs.map → proof-X3MVQFFZ.cjs.map} +1 -1
  50. package/dist/{proof-XQG5DN5N.js → proof-YMXBL4D5.js} +4 -3
  51. package/dist/{proof-XQG5DN5N.js.map → proof-YMXBL4D5.js.map} +1 -1
  52. package/dist/react/index.cjs +123 -39
  53. package/dist/react/index.cjs.map +1 -1
  54. package/dist/react/index.d.cts +44 -6
  55. package/dist/react/index.d.ts +44 -6
  56. package/dist/react/index.js +90 -18
  57. package/dist/react/index.js.map +1 -1
  58. package/dist/{transfer-Cqg235q6.d.ts → transfer-BGzySIhC.d.ts} +124 -5
  59. package/dist/{transfer-B4q3ZTJK.d.cts → transfer-BhB-UuBP.d.cts} +124 -5
  60. package/dist/{transfer-7IFAXV5K.cjs → transfer-H6UWWUSN.cjs} +11 -10
  61. package/dist/{transfer-7IFAXV5K.cjs.map → transfer-H6UWWUSN.cjs.map} +1 -1
  62. package/dist/{transfer-FWCRUWWM.js → transfer-MLVRASM3.js} +5 -4
  63. package/dist/{transfer-FWCRUWWM.js.map → transfer-MLVRASM3.js.map} +1 -1
  64. package/package.json +1 -1
  65. package/src/deployments/11155111.json +12 -12
  66. package/dist/chunk-5H27F6W6.cjs.map +0 -1
  67. package/dist/chunk-C7DUABSG.js.map +0 -1
  68. package/dist/chunk-KRLRJ3HN.js.map +0 -1
  69. package/dist/chunk-RYEYGGE7.cjs.map +0 -1
@@ -207,6 +207,106 @@ interface StarkProof {
207
207
  publicInputsSeed: Hex;
208
208
  }
209
209
 
210
+ /**
211
+ * Circuit Artifact Cache — IndexedDB-based caching for PLONK circuit files.
212
+ *
213
+ * Downloads circuit artifacts (wasm + zkey) with progress reporting via
214
+ * ReadableStream, caches them in IndexedDB, and returns Uint8Array data
215
+ * that can be passed directly to snarkjs.plonk.fullProve().
216
+ *
217
+ * Works in both main thread and Web Worker contexts.
218
+ */
219
+
220
+ /**
221
+ * Current circuit artifact version (date-based).
222
+ * Bump this when circuits are recompiled (new trusted setup, circuit changes).
223
+ * Old cached artifacts are ignored (different key prefix in IndexedDB).
224
+ */
225
+ declare const CIRCUIT_VERSION = "20260330";
226
+ /** Default CDN base URL for circuit artifacts */
227
+ declare const CIRCUIT_CDN_BASE = "https://circuits.upd.io/20260330/";
228
+ /** Progress report during circuit artifact download */
229
+ interface DownloadProgress {
230
+ circuitType: UPPCircuitType;
231
+ artifact: 'wasm' | 'zkey';
232
+ bytesDownloaded: number;
233
+ totalBytes: number;
234
+ /** 0-100 */
235
+ percent: number;
236
+ }
237
+ /** Resolved (binary) circuit artifacts ready for snarkjs */
238
+ interface ResolvedCircuitArtifacts {
239
+ wasm: Uint8Array;
240
+ zkey: Uint8Array;
241
+ }
242
+ /** Per-circuit cache status */
243
+ interface CircuitCacheStatus {
244
+ cached: boolean;
245
+ wasmSize?: number;
246
+ zkeySize?: number;
247
+ }
248
+ declare class CircuitArtifactCache {
249
+ private static _instance;
250
+ static shared(): CircuitArtifactCache;
251
+ /** In-flight download deduplication */
252
+ private inflight;
253
+ private constructor();
254
+ private key;
255
+ private resolveBaseUrl;
256
+ /**
257
+ * Check if both wasm + zkey are cached for a circuit (current CIRCUIT_VERSION).
258
+ */
259
+ isCached(circuit: UPPCircuitType): Promise<boolean>;
260
+ /**
261
+ * Download and cache a circuit's artifacts. No-ops if already cached.
262
+ *
263
+ * @param circuit - Which circuit to preload
264
+ * @param baseUrl - CDN base URL (defaults to `https://circuits.upd.io/${CIRCUIT_VERSION}/`)
265
+ * @param onProgress - Byte-level download progress callback
266
+ * @param signal - AbortSignal for cancellation
267
+ */
268
+ preload(circuit: UPPCircuitType, baseUrl?: string, onProgress?: (p: DownloadProgress) => void, signal?: AbortSignal): Promise<void>;
269
+ /**
270
+ * Get artifacts from cache, downloading if needed.
271
+ * Returns Uint8Array data ready to pass to snarkjs.plonk.fullProve().
272
+ */
273
+ getArtifacts(circuit: UPPCircuitType, baseUrl?: string, onProgress?: (p: DownloadProgress) => void, signal?: AbortSignal): Promise<ResolvedCircuitArtifacts>;
274
+ /**
275
+ * List all cached circuit types (current version only).
276
+ */
277
+ getCachedCircuits(): Promise<UPPCircuitType[]>;
278
+ /**
279
+ * Get cache size information.
280
+ */
281
+ getCacheSize(): Promise<{
282
+ total: number;
283
+ circuits: Record<string, number>;
284
+ }>;
285
+ /**
286
+ * Get cache status for all circuit types.
287
+ */
288
+ getStatus(): Promise<Map<UPPCircuitType, CircuitCacheStatus>>;
289
+ /**
290
+ * Evict a specific circuit from cache (current version).
291
+ */
292
+ evict(circuit: UPPCircuitType): Promise<void>;
293
+ /**
294
+ * Evict all cached circuit artifacts (all versions).
295
+ */
296
+ evictAll(): Promise<void>;
297
+ /**
298
+ * Evict all artifacts for a specific version (for cleaning up after SDK updates).
299
+ */
300
+ evictVersion(version: string): Promise<void>;
301
+ /**
302
+ * Request persistent storage to prevent browser from evicting the cache.
303
+ * Returns true if granted, false if denied or unavailable.
304
+ */
305
+ requestPersistence(): Promise<boolean>;
306
+ private getOrDownload;
307
+ private downloadAndStore;
308
+ }
309
+
210
310
  /**
211
311
  * ZK Proof Generation and Verification (BLS12-381 PLONK)
212
312
  *
@@ -524,17 +624,29 @@ type UPPCircuitInputs = UPPTransferCircuitInputs | UPPWithdrawCircuitInputs | UP
524
624
  /**
525
625
  * PLONK proving stage for progress reporting
526
626
  */
527
- type PlonkProvingStage = 'loading' | 'witness' | 'round1' | 'round2' | 'round3' | 'round4' | 'round5' | 'done';
627
+ type PlonkProvingStage = 'downloading' | 'loading' | 'witness' | 'round1' | 'round2' | 'round3' | 'round4' | 'round5' | 'done';
528
628
  /**
529
629
  * Generate a ZK proof for a UPP circuit (BLS12-381 PLONK)
530
630
  *
631
+ * Downloads circuit artifacts (with caching) and generates a PLONK proof.
632
+ * Artifacts are cached in IndexedDB after first download.
633
+ *
531
634
  * @param circuitType - Which UPP circuit to use
532
635
  * @param inputs - Circuit input signals
533
- * @param baseUrl - Base URL for circuit artifacts (default: '/circuits/')
636
+ * @param baseUrl - Base URL for circuit artifacts (defaults to CDN)
534
637
  * @param onProgress - Optional callback for proving progress
638
+ * @param options - Optional pre-loaded artifacts or download progress callback
535
639
  * @returns Generated proof and public signals
536
640
  */
537
- declare function generateUPPProof(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string, onProgress?: (stage: PlonkProvingStage, message: string) => void): Promise<ProofResult>;
641
+ declare function generateUPPProof(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string, onProgress?: (stage: PlonkProvingStage, message: string) => void, options?: {
642
+ /** Pre-loaded artifacts (bypasses download + cache entirely) */
643
+ artifacts?: {
644
+ wasm: Uint8Array;
645
+ zkey: Uint8Array;
646
+ };
647
+ /** Download progress callback (bytes downloaded / total) */
648
+ onDownloadProgress?: (p: DownloadProgress) => void;
649
+ }): Promise<ProofResult>;
538
650
  /**
539
651
  * @deprecated Use generateUPPProof instead
540
652
  */
@@ -620,6 +732,10 @@ type ProofWorkerResponse = {
620
732
  id: string;
621
733
  stage: PlonkProvingStage;
622
734
  message: string;
735
+ } | {
736
+ type: 'download-progress';
737
+ id: string;
738
+ progress: DownloadProgress;
623
739
  } | {
624
740
  type: 'result';
625
741
  id: string;
@@ -641,7 +757,7 @@ declare class ProofWorkerManager {
641
757
  * @param signal - AbortSignal for cancellation. When aborted, the promise
642
758
  * rejects with AbortError. Call terminate() for hard cancellation.
643
759
  */
644
- prove(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl: string, onProgress?: (stage: PlonkProvingStage, message: string) => void, signal?: AbortSignal): Promise<ProofResult>;
760
+ prove(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl: string, onProgress?: (stage: PlonkProvingStage, message: string) => void, signal?: AbortSignal, onDownloadProgress?: (progress: DownloadProgress) => void): Promise<ProofResult>;
645
761
  /**
646
762
  * Hard-terminate the worker. All pending proofs are rejected.
647
763
  */
@@ -652,9 +768,12 @@ declare class ProofWorkerManager {
652
768
  *
653
769
  * This is the recommended entry point for proof generation. It provides a
654
770
  * unified API regardless of whether a worker is available.
771
+ *
772
+ * Circuit artifacts are automatically cached in IndexedDB after first download.
655
773
  */
656
774
  declare function generateUPPProofAsync(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string, options?: {
657
775
  onProgress?: (stage: PlonkProvingStage, message: string) => void;
776
+ onDownloadProgress?: (progress: DownloadProgress) => void;
658
777
  signal?: AbortSignal;
659
778
  worker?: ProofWorkerManager | null;
660
779
  }): Promise<ProofResult>;
@@ -1476,4 +1595,4 @@ declare function formatOutputForContract(note: NoteCreationResult): {
1476
1595
  encryptedNote: Hex;
1477
1596
  };
1478
1597
 
1479
- export { type WithdrawParams as $, type ASPProof as A, type Stealth2x2CircuitInputs as B, type CircuitArtifacts as C, DEMO_ASP_ID as D, type EncryptedNote as E, type StealthAddress as F, type StealthCircuitInputs as G, type StealthCircuitType as H, type StealthMetaAddress as I, type SwapFillEvent as J, type SwapFillParams as K, type SwapOrder as L, type MergeParams as M, NOTE_VERSION as N, type SwapOrderEvent as O, type PlonkProvingStage as P, type SwapOrderParams as Q, RATE_PRECISION as R, STATE_TREE_DEPTH as S, type TransferBuildResult as T, type TransferContext as U, type TransferParams as V, type TransferStage as W, type UPPCircuitInputs as X, type UPPCircuitType as Y, type UPPTransferCircuitInputs as Z, type UPPWithdrawCircuitInputs as _, type ASPRoot as a, buildASPTree as a0, buildTransfer as a1, buildUPPTransferCircuitInputs as a2, computeCancelKeyHash as a3, computeFillPercentage as a4, computeGiveAmount as a5, computeMultiOriginASPRoot as a6, computeNullifier as a7, computeRate as a8, computeSingleOriginASPRoot as a9, verifyASPProof as aA, verifyProof as aB, type NoteCreationResult as aC, type PlonkProofStruct as aD, type ShieldedNote as aE, useUPPAccount as aF, UPPAccountProvider as aG, type UPPAccountContextType as aH, type ProofSystemType as aI, type IndexerConfig as aJ, type SignTypedDataFn as aK, ASP_TREE_DEPTH as aL, computeTakeAmount as aa, computeTotalBuyAmount as ab, createDemoASPRoot as ac, filterOrdersByASP as ad, filterOrdersByTokenPair as ae, formatOutputForContract as af, formatProofForContract as ag, formatRate as ah, generateASPProof as ai, generateCancelSecret as aj, generateMultiOriginASPProof as ak, generateProof as al, generateSingleOriginASPProof as am, generateStealthProof as an, generateUPPProof as ao, generateUPPProofAsync as ap, getCancelSecret as aq, getMerkleProofsForNotes as ar, getOwnOrderIds as as, getStealthCircuitArtifacts as at, getUPPCircuitArtifacts as au, isFillerASPAccepted as av, isOrderActive as aw, removeCancelSecret as ax, storeCancelSecret as ay, syncMerkleTree as az, ASP_TREE_DEPTH$1 as b, type CircuitType as c, type Commitment as d, DEMO_ASP_NAME as e, type MergeRecord as f, type MerkleProofWithNote as g, type Note as h, type NoteWithAmount as i, type Nullifier as j, type Proof as k, type ProofResult as l, ProofWorkerManager as m, type ProofWorkerRequest as n, type ProofWorkerResponse as o, SWAP_EVENTS_ABI as p, SWAP_ORDER_CANCELLED_EVENT as q, SWAP_ORDER_CLAIMED_EVENT as r, SWAP_ORDER_FILLED_EVENT as s, SWAP_ORDER_PLACED_EVENT as t, type ShieldParams as u, type SpendableNote as v, type StarkNote as w, type StarkProof as x, type StarkStealthMetaAddress as y, type Stealth1x2CircuitInputs as z };
1598
+ export { type TransferParams as $, type ASPProof as A, type ShieldParams as B, CIRCUIT_CDN_BASE as C, DEMO_ASP_ID as D, type EncryptedNote as E, type SpendableNote as F, type StarkNote as G, type StarkProof as H, type StarkStealthMetaAddress as I, type Stealth1x2CircuitInputs as J, type Stealth2x2CircuitInputs as K, type StealthAddress as L, type MergeParams as M, NOTE_VERSION as N, type StealthCircuitInputs as O, type PlonkProvingStage as P, type StealthCircuitType as Q, RATE_PRECISION as R, STATE_TREE_DEPTH as S, type StealthMetaAddress as T, type SwapFillEvent as U, type SwapFillParams as V, type SwapOrder as W, type SwapOrderEvent as X, type SwapOrderParams as Y, type TransferBuildResult as Z, type TransferContext as _, type ASPRoot as a, type TransferStage as a0, type UPPCircuitInputs as a1, type UPPCircuitType as a2, type UPPTransferCircuitInputs as a3, type UPPWithdrawCircuitInputs as a4, type WithdrawParams as a5, buildASPTree as a6, buildTransfer as a7, buildUPPTransferCircuitInputs as a8, computeCancelKeyHash as a9, getUPPCircuitArtifacts as aA, isFillerASPAccepted as aB, isOrderActive as aC, removeCancelSecret as aD, storeCancelSecret as aE, syncMerkleTree as aF, verifyASPProof as aG, verifyProof as aH, type NoteCreationResult as aI, type PlonkProofStruct as aJ, type ShieldedNote as aK, useUPPAccount as aL, UPPAccountProvider as aM, type UPPAccountContextType as aN, type ProofSystemType as aO, type IndexerConfig as aP, type SignTypedDataFn as aQ, ASP_TREE_DEPTH as aR, computeFillPercentage as aa, computeGiveAmount as ab, computeMultiOriginASPRoot as ac, computeNullifier as ad, computeRate as ae, computeSingleOriginASPRoot as af, computeTakeAmount as ag, computeTotalBuyAmount as ah, createDemoASPRoot as ai, filterOrdersByASP as aj, filterOrdersByTokenPair as ak, formatOutputForContract as al, formatProofForContract as am, formatRate as an, generateASPProof as ao, generateCancelSecret as ap, generateMultiOriginASPProof as aq, generateProof as ar, generateSingleOriginASPProof as as, generateStealthProof as at, generateUPPProof as au, generateUPPProofAsync as av, getCancelSecret as aw, getMerkleProofsForNotes as ax, getOwnOrderIds as ay, getStealthCircuitArtifacts as az, ASP_TREE_DEPTH$1 as b, CIRCUIT_VERSION as c, CircuitArtifactCache as d, type CircuitArtifacts as e, type CircuitCacheStatus as f, type CircuitType as g, type Commitment as h, DEMO_ASP_NAME as i, type DownloadProgress as j, type MergeRecord as k, type MerkleProofWithNote as l, type Note as m, type NoteWithAmount as n, type Nullifier as o, type Proof as p, type ProofResult as q, ProofWorkerManager as r, type ProofWorkerRequest as s, type ProofWorkerResponse as t, type ResolvedCircuitArtifacts as u, SWAP_EVENTS_ABI as v, SWAP_ORDER_CANCELLED_EVENT as w, SWAP_ORDER_CLAIMED_EVENT as x, SWAP_ORDER_FILLED_EVENT as y, SWAP_ORDER_PLACED_EVENT as z };
@@ -207,6 +207,106 @@ interface StarkProof {
207
207
  publicInputsSeed: Hex;
208
208
  }
209
209
 
210
+ /**
211
+ * Circuit Artifact Cache — IndexedDB-based caching for PLONK circuit files.
212
+ *
213
+ * Downloads circuit artifacts (wasm + zkey) with progress reporting via
214
+ * ReadableStream, caches them in IndexedDB, and returns Uint8Array data
215
+ * that can be passed directly to snarkjs.plonk.fullProve().
216
+ *
217
+ * Works in both main thread and Web Worker contexts.
218
+ */
219
+
220
+ /**
221
+ * Current circuit artifact version (date-based).
222
+ * Bump this when circuits are recompiled (new trusted setup, circuit changes).
223
+ * Old cached artifacts are ignored (different key prefix in IndexedDB).
224
+ */
225
+ declare const CIRCUIT_VERSION = "20260330";
226
+ /** Default CDN base URL for circuit artifacts */
227
+ declare const CIRCUIT_CDN_BASE = "https://circuits.upd.io/20260330/";
228
+ /** Progress report during circuit artifact download */
229
+ interface DownloadProgress {
230
+ circuitType: UPPCircuitType;
231
+ artifact: 'wasm' | 'zkey';
232
+ bytesDownloaded: number;
233
+ totalBytes: number;
234
+ /** 0-100 */
235
+ percent: number;
236
+ }
237
+ /** Resolved (binary) circuit artifacts ready for snarkjs */
238
+ interface ResolvedCircuitArtifacts {
239
+ wasm: Uint8Array;
240
+ zkey: Uint8Array;
241
+ }
242
+ /** Per-circuit cache status */
243
+ interface CircuitCacheStatus {
244
+ cached: boolean;
245
+ wasmSize?: number;
246
+ zkeySize?: number;
247
+ }
248
+ declare class CircuitArtifactCache {
249
+ private static _instance;
250
+ static shared(): CircuitArtifactCache;
251
+ /** In-flight download deduplication */
252
+ private inflight;
253
+ private constructor();
254
+ private key;
255
+ private resolveBaseUrl;
256
+ /**
257
+ * Check if both wasm + zkey are cached for a circuit (current CIRCUIT_VERSION).
258
+ */
259
+ isCached(circuit: UPPCircuitType): Promise<boolean>;
260
+ /**
261
+ * Download and cache a circuit's artifacts. No-ops if already cached.
262
+ *
263
+ * @param circuit - Which circuit to preload
264
+ * @param baseUrl - CDN base URL (defaults to `https://circuits.upd.io/${CIRCUIT_VERSION}/`)
265
+ * @param onProgress - Byte-level download progress callback
266
+ * @param signal - AbortSignal for cancellation
267
+ */
268
+ preload(circuit: UPPCircuitType, baseUrl?: string, onProgress?: (p: DownloadProgress) => void, signal?: AbortSignal): Promise<void>;
269
+ /**
270
+ * Get artifacts from cache, downloading if needed.
271
+ * Returns Uint8Array data ready to pass to snarkjs.plonk.fullProve().
272
+ */
273
+ getArtifacts(circuit: UPPCircuitType, baseUrl?: string, onProgress?: (p: DownloadProgress) => void, signal?: AbortSignal): Promise<ResolvedCircuitArtifacts>;
274
+ /**
275
+ * List all cached circuit types (current version only).
276
+ */
277
+ getCachedCircuits(): Promise<UPPCircuitType[]>;
278
+ /**
279
+ * Get cache size information.
280
+ */
281
+ getCacheSize(): Promise<{
282
+ total: number;
283
+ circuits: Record<string, number>;
284
+ }>;
285
+ /**
286
+ * Get cache status for all circuit types.
287
+ */
288
+ getStatus(): Promise<Map<UPPCircuitType, CircuitCacheStatus>>;
289
+ /**
290
+ * Evict a specific circuit from cache (current version).
291
+ */
292
+ evict(circuit: UPPCircuitType): Promise<void>;
293
+ /**
294
+ * Evict all cached circuit artifacts (all versions).
295
+ */
296
+ evictAll(): Promise<void>;
297
+ /**
298
+ * Evict all artifacts for a specific version (for cleaning up after SDK updates).
299
+ */
300
+ evictVersion(version: string): Promise<void>;
301
+ /**
302
+ * Request persistent storage to prevent browser from evicting the cache.
303
+ * Returns true if granted, false if denied or unavailable.
304
+ */
305
+ requestPersistence(): Promise<boolean>;
306
+ private getOrDownload;
307
+ private downloadAndStore;
308
+ }
309
+
210
310
  /**
211
311
  * ZK Proof Generation and Verification (BLS12-381 PLONK)
212
312
  *
@@ -524,17 +624,29 @@ type UPPCircuitInputs = UPPTransferCircuitInputs | UPPWithdrawCircuitInputs | UP
524
624
  /**
525
625
  * PLONK proving stage for progress reporting
526
626
  */
527
- type PlonkProvingStage = 'loading' | 'witness' | 'round1' | 'round2' | 'round3' | 'round4' | 'round5' | 'done';
627
+ type PlonkProvingStage = 'downloading' | 'loading' | 'witness' | 'round1' | 'round2' | 'round3' | 'round4' | 'round5' | 'done';
528
628
  /**
529
629
  * Generate a ZK proof for a UPP circuit (BLS12-381 PLONK)
530
630
  *
631
+ * Downloads circuit artifacts (with caching) and generates a PLONK proof.
632
+ * Artifacts are cached in IndexedDB after first download.
633
+ *
531
634
  * @param circuitType - Which UPP circuit to use
532
635
  * @param inputs - Circuit input signals
533
- * @param baseUrl - Base URL for circuit artifacts (default: '/circuits/')
636
+ * @param baseUrl - Base URL for circuit artifacts (defaults to CDN)
534
637
  * @param onProgress - Optional callback for proving progress
638
+ * @param options - Optional pre-loaded artifacts or download progress callback
535
639
  * @returns Generated proof and public signals
536
640
  */
537
- declare function generateUPPProof(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string, onProgress?: (stage: PlonkProvingStage, message: string) => void): Promise<ProofResult>;
641
+ declare function generateUPPProof(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string, onProgress?: (stage: PlonkProvingStage, message: string) => void, options?: {
642
+ /** Pre-loaded artifacts (bypasses download + cache entirely) */
643
+ artifacts?: {
644
+ wasm: Uint8Array;
645
+ zkey: Uint8Array;
646
+ };
647
+ /** Download progress callback (bytes downloaded / total) */
648
+ onDownloadProgress?: (p: DownloadProgress) => void;
649
+ }): Promise<ProofResult>;
538
650
  /**
539
651
  * @deprecated Use generateUPPProof instead
540
652
  */
@@ -620,6 +732,10 @@ type ProofWorkerResponse = {
620
732
  id: string;
621
733
  stage: PlonkProvingStage;
622
734
  message: string;
735
+ } | {
736
+ type: 'download-progress';
737
+ id: string;
738
+ progress: DownloadProgress;
623
739
  } | {
624
740
  type: 'result';
625
741
  id: string;
@@ -641,7 +757,7 @@ declare class ProofWorkerManager {
641
757
  * @param signal - AbortSignal for cancellation. When aborted, the promise
642
758
  * rejects with AbortError. Call terminate() for hard cancellation.
643
759
  */
644
- prove(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl: string, onProgress?: (stage: PlonkProvingStage, message: string) => void, signal?: AbortSignal): Promise<ProofResult>;
760
+ prove(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl: string, onProgress?: (stage: PlonkProvingStage, message: string) => void, signal?: AbortSignal, onDownloadProgress?: (progress: DownloadProgress) => void): Promise<ProofResult>;
645
761
  /**
646
762
  * Hard-terminate the worker. All pending proofs are rejected.
647
763
  */
@@ -652,9 +768,12 @@ declare class ProofWorkerManager {
652
768
  *
653
769
  * This is the recommended entry point for proof generation. It provides a
654
770
  * unified API regardless of whether a worker is available.
771
+ *
772
+ * Circuit artifacts are automatically cached in IndexedDB after first download.
655
773
  */
656
774
  declare function generateUPPProofAsync(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string, options?: {
657
775
  onProgress?: (stage: PlonkProvingStage, message: string) => void;
776
+ onDownloadProgress?: (progress: DownloadProgress) => void;
658
777
  signal?: AbortSignal;
659
778
  worker?: ProofWorkerManager | null;
660
779
  }): Promise<ProofResult>;
@@ -1476,4 +1595,4 @@ declare function formatOutputForContract(note: NoteCreationResult): {
1476
1595
  encryptedNote: Hex;
1477
1596
  };
1478
1597
 
1479
- export { type WithdrawParams as $, type ASPProof as A, type Stealth2x2CircuitInputs as B, type CircuitArtifacts as C, DEMO_ASP_ID as D, type EncryptedNote as E, type StealthAddress as F, type StealthCircuitInputs as G, type StealthCircuitType as H, type StealthMetaAddress as I, type SwapFillEvent as J, type SwapFillParams as K, type SwapOrder as L, type MergeParams as M, NOTE_VERSION as N, type SwapOrderEvent as O, type PlonkProvingStage as P, type SwapOrderParams as Q, RATE_PRECISION as R, STATE_TREE_DEPTH as S, type TransferBuildResult as T, type TransferContext as U, type TransferParams as V, type TransferStage as W, type UPPCircuitInputs as X, type UPPCircuitType as Y, type UPPTransferCircuitInputs as Z, type UPPWithdrawCircuitInputs as _, type ASPRoot as a, buildASPTree as a0, buildTransfer as a1, buildUPPTransferCircuitInputs as a2, computeCancelKeyHash as a3, computeFillPercentage as a4, computeGiveAmount as a5, computeMultiOriginASPRoot as a6, computeNullifier as a7, computeRate as a8, computeSingleOriginASPRoot as a9, verifyASPProof as aA, verifyProof as aB, type NoteCreationResult as aC, type PlonkProofStruct as aD, type ShieldedNote as aE, useUPPAccount as aF, UPPAccountProvider as aG, type UPPAccountContextType as aH, type ProofSystemType as aI, type IndexerConfig as aJ, type SignTypedDataFn as aK, ASP_TREE_DEPTH as aL, computeTakeAmount as aa, computeTotalBuyAmount as ab, createDemoASPRoot as ac, filterOrdersByASP as ad, filterOrdersByTokenPair as ae, formatOutputForContract as af, formatProofForContract as ag, formatRate as ah, generateASPProof as ai, generateCancelSecret as aj, generateMultiOriginASPProof as ak, generateProof as al, generateSingleOriginASPProof as am, generateStealthProof as an, generateUPPProof as ao, generateUPPProofAsync as ap, getCancelSecret as aq, getMerkleProofsForNotes as ar, getOwnOrderIds as as, getStealthCircuitArtifacts as at, getUPPCircuitArtifacts as au, isFillerASPAccepted as av, isOrderActive as aw, removeCancelSecret as ax, storeCancelSecret as ay, syncMerkleTree as az, ASP_TREE_DEPTH$1 as b, type CircuitType as c, type Commitment as d, DEMO_ASP_NAME as e, type MergeRecord as f, type MerkleProofWithNote as g, type Note as h, type NoteWithAmount as i, type Nullifier as j, type Proof as k, type ProofResult as l, ProofWorkerManager as m, type ProofWorkerRequest as n, type ProofWorkerResponse as o, SWAP_EVENTS_ABI as p, SWAP_ORDER_CANCELLED_EVENT as q, SWAP_ORDER_CLAIMED_EVENT as r, SWAP_ORDER_FILLED_EVENT as s, SWAP_ORDER_PLACED_EVENT as t, type ShieldParams as u, type SpendableNote as v, type StarkNote as w, type StarkProof as x, type StarkStealthMetaAddress as y, type Stealth1x2CircuitInputs as z };
1598
+ export { type TransferParams as $, type ASPProof as A, type ShieldParams as B, CIRCUIT_CDN_BASE as C, DEMO_ASP_ID as D, type EncryptedNote as E, type SpendableNote as F, type StarkNote as G, type StarkProof as H, type StarkStealthMetaAddress as I, type Stealth1x2CircuitInputs as J, type Stealth2x2CircuitInputs as K, type StealthAddress as L, type MergeParams as M, NOTE_VERSION as N, type StealthCircuitInputs as O, type PlonkProvingStage as P, type StealthCircuitType as Q, RATE_PRECISION as R, STATE_TREE_DEPTH as S, type StealthMetaAddress as T, type SwapFillEvent as U, type SwapFillParams as V, type SwapOrder as W, type SwapOrderEvent as X, type SwapOrderParams as Y, type TransferBuildResult as Z, type TransferContext as _, type ASPRoot as a, type TransferStage as a0, type UPPCircuitInputs as a1, type UPPCircuitType as a2, type UPPTransferCircuitInputs as a3, type UPPWithdrawCircuitInputs as a4, type WithdrawParams as a5, buildASPTree as a6, buildTransfer as a7, buildUPPTransferCircuitInputs as a8, computeCancelKeyHash as a9, getUPPCircuitArtifacts as aA, isFillerASPAccepted as aB, isOrderActive as aC, removeCancelSecret as aD, storeCancelSecret as aE, syncMerkleTree as aF, verifyASPProof as aG, verifyProof as aH, type NoteCreationResult as aI, type PlonkProofStruct as aJ, type ShieldedNote as aK, useUPPAccount as aL, UPPAccountProvider as aM, type UPPAccountContextType as aN, type ProofSystemType as aO, type IndexerConfig as aP, type SignTypedDataFn as aQ, ASP_TREE_DEPTH as aR, computeFillPercentage as aa, computeGiveAmount as ab, computeMultiOriginASPRoot as ac, computeNullifier as ad, computeRate as ae, computeSingleOriginASPRoot as af, computeTakeAmount as ag, computeTotalBuyAmount as ah, createDemoASPRoot as ai, filterOrdersByASP as aj, filterOrdersByTokenPair as ak, formatOutputForContract as al, formatProofForContract as am, formatRate as an, generateASPProof as ao, generateCancelSecret as ap, generateMultiOriginASPProof as aq, generateProof as ar, generateSingleOriginASPProof as as, generateStealthProof as at, generateUPPProof as au, generateUPPProofAsync as av, getCancelSecret as aw, getMerkleProofsForNotes as ax, getOwnOrderIds as ay, getStealthCircuitArtifacts as az, ASP_TREE_DEPTH$1 as b, CIRCUIT_VERSION as c, CircuitArtifactCache as d, type CircuitArtifacts as e, type CircuitCacheStatus as f, type CircuitType as g, type Commitment as h, DEMO_ASP_NAME as i, type DownloadProgress as j, type MergeRecord as k, type MerkleProofWithNote as l, type Note as m, type NoteWithAmount as n, type Nullifier as o, type Proof as p, type ProofResult as q, ProofWorkerManager as r, type ProofWorkerRequest as s, type ProofWorkerResponse as t, type ResolvedCircuitArtifacts as u, SWAP_EVENTS_ABI as v, SWAP_ORDER_CANCELLED_EVENT as w, SWAP_ORDER_CLAIMED_EVENT as x, SWAP_ORDER_FILLED_EVENT as y, SWAP_ORDER_PLACED_EVENT as z };
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkYHBUCKVS_cjs = require('./chunk-YHBUCKVS.cjs');
4
- require('./chunk-RYEYGGE7.cjs');
3
+ var chunkDYSU7JYL_cjs = require('./chunk-DYSU7JYL.cjs');
4
+ require('./chunk-IX7HV5TE.cjs');
5
5
  require('./chunk-IIUKM5VE.cjs');
6
6
  require('./chunk-XVIICZKW.cjs');
7
+ require('./chunk-VVW5VVY3.cjs');
7
8
  require('./chunk-HEHXSV47.cjs');
8
9
  require('./chunk-G7VZBCD6.cjs');
9
10
 
@@ -11,27 +12,27 @@ require('./chunk-G7VZBCD6.cjs');
11
12
 
12
13
  Object.defineProperty(exports, "buildTransfer", {
13
14
  enumerable: true,
14
- get: function () { return chunkYHBUCKVS_cjs.buildTransfer; }
15
+ get: function () { return chunkDYSU7JYL_cjs.buildTransfer; }
15
16
  });
16
17
  Object.defineProperty(exports, "buildUPPTransferCircuitInputs", {
17
18
  enumerable: true,
18
- get: function () { return chunkYHBUCKVS_cjs.buildUPPTransferCircuitInputs; }
19
+ get: function () { return chunkDYSU7JYL_cjs.buildUPPTransferCircuitInputs; }
19
20
  });
20
21
  Object.defineProperty(exports, "computeNullifier", {
21
22
  enumerable: true,
22
- get: function () { return chunkYHBUCKVS_cjs.computeNullifier; }
23
+ get: function () { return chunkDYSU7JYL_cjs.computeNullifier; }
23
24
  });
24
25
  Object.defineProperty(exports, "formatOutputForContract", {
25
26
  enumerable: true,
26
- get: function () { return chunkYHBUCKVS_cjs.formatOutputForContract; }
27
+ get: function () { return chunkDYSU7JYL_cjs.formatOutputForContract; }
27
28
  });
28
29
  Object.defineProperty(exports, "getMerkleProofsForNotes", {
29
30
  enumerable: true,
30
- get: function () { return chunkYHBUCKVS_cjs.getMerkleProofsForNotes; }
31
+ get: function () { return chunkDYSU7JYL_cjs.getMerkleProofsForNotes; }
31
32
  });
32
33
  Object.defineProperty(exports, "syncMerkleTree", {
33
34
  enumerable: true,
34
- get: function () { return chunkYHBUCKVS_cjs.syncMerkleTree; }
35
+ get: function () { return chunkDYSU7JYL_cjs.syncMerkleTree; }
35
36
  });
36
- //# sourceMappingURL=transfer-7IFAXV5K.cjs.map
37
- //# sourceMappingURL=transfer-7IFAXV5K.cjs.map
37
+ //# sourceMappingURL=transfer-H6UWWUSN.cjs.map
38
+ //# sourceMappingURL=transfer-H6UWWUSN.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"transfer-7IFAXV5K.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"transfer-H6UWWUSN.cjs"}
@@ -1,8 +1,9 @@
1
- export { buildTransfer, buildUPPTransferCircuitInputs, computeNullifier, formatOutputForContract, getMerkleProofsForNotes, syncMerkleTree } from './chunk-OLJFKARA.js';
2
- import './chunk-KRLRJ3HN.js';
1
+ export { buildTransfer, buildUPPTransferCircuitInputs, computeNullifier, formatOutputForContract, getMerkleProofsForNotes, syncMerkleTree } from './chunk-XDWRMHLY.js';
2
+ import './chunk-KR4GB6VC.js';
3
3
  import './chunk-GPF72JFR.js';
4
4
  import './chunk-6IEYWJVS.js';
5
+ import './chunk-2BSIUEPO.js';
5
6
  import './chunk-5QSSX3KR.js';
6
7
  import './chunk-Z6ZWNWWR.js';
7
- //# sourceMappingURL=transfer-FWCRUWWM.js.map
8
- //# sourceMappingURL=transfer-FWCRUWWM.js.map
8
+ //# sourceMappingURL=transfer-MLVRASM3.js.map
9
+ //# sourceMappingURL=transfer-MLVRASM3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"transfer-FWCRUWWM.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"transfer-MLVRASM3.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@permissionless-technologies/upp-sdk",
3
- "version": "0.4.21",
3
+ "version": "0.4.22",
4
4
  "description": "Universal Private Pool SDK - Privacy-preserving token operations for any ERC20",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,21 +1,21 @@
1
1
  {
2
- "UniversalPrivatePool": "0x571f7feba5d25638ba4e05c59668a892ddfeaf4f",
2
+ "UniversalPrivatePool": "0xba5405375ee4c1b5fdcb1b755381edcc38ae28f2",
3
3
  "ASPRegistryHub": "0xfd11c56a23314aa88dfbcc36254f33e5e8b010df",
4
- "TestToken": "0xace09cebc29a3f04002800aceb26931990786538",
5
- "TestToken2": "0x3f10afa4e15949fb36957b1ae3e3b5c93986312c",
4
+ "TestToken": "0xc3cef670aae8228de206c98b67c3d25c520b8f14",
5
+ "TestToken2": "0x4de3efd64d4ce9a4b45f538104bdbaadaf170bed",
6
6
  "verifiers": {
7
- "TransferVerifier": "0x29c822a5b740db73707ea033482cb2772e764357",
8
- "MergeVerifier": "0x5fbd1596811a8971be776e477759ed50063fea22",
9
- "WithdrawVerifier": "0x49e13844d5e39ba4777f237ffc793e0366212fdd",
10
- "JoinSplitVerifier": "0xd0d7200b6684c21213e27713662795ea9bdd5923",
11
- "MergeTransfer2x2Verifier": "0x1abf58c52ab366c5e77d7164b7e50631707f682e",
12
- "MergeTransfer4x2Verifier": "0x83f097a17f9d0defab6a2fe15aa96f8e8a05f0c3"
7
+ "TransferVerifier": "0xe4a737e8e3100709986e1992d8e18cf324965320",
8
+ "MergeVerifier": "0x3a844672f792d3b1216e4e64acd8c5d0301a3a3e",
9
+ "WithdrawVerifier": "0x387afb8566d446c8344e03b8a9c54ba96b22233d",
10
+ "JoinSplitVerifier": "0xe03c270de9b33f72a0656b07ed43f3269d586607",
11
+ "MergeTransfer2x2Verifier": "0xbc1378d567abdfad063cd32b684e03ca29e79b99",
12
+ "MergeTransfer4x2Verifier": "0xd1f75b988e6fd6003204bda6e83eb3186a8dec34"
13
13
  },
14
14
  "starkVerifiers": {
15
- "CircleStarkVerifier": "0x14e8259e31ec564fe5d80680fdabe81da264baa6"
15
+ "CircleStarkVerifier": "0xc92ba214653c616c4546d7edcb7aba8ced3e0a94"
16
16
  },
17
- "deployBlock": 10553557,
18
- "deployTimestamp": 1774873429071,
17
+ "deployBlock": 10555332,
18
+ "deployTimestamp": 1774895534634,
19
19
  "proofSystem": "PLONK",
20
20
  "curve": "BLS12-381",
21
21
  "verifierType": "PlonkVerifierBLS12381"