@permissionless-technologies/upp-sdk 0.1.0

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 (140) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +194 -0
  3. package/dist/asp-TXSAFFD3.cjs +53 -0
  4. package/dist/asp-TXSAFFD3.cjs.map +1 -0
  5. package/dist/asp-ZA3RGN7G.js +4 -0
  6. package/dist/asp-ZA3RGN7G.js.map +1 -0
  7. package/dist/babyjubjub-2MGQVCKB.js +5 -0
  8. package/dist/babyjubjub-2MGQVCKB.js.map +1 -0
  9. package/dist/babyjubjub-MWZLJOVZ.cjs +66 -0
  10. package/dist/babyjubjub-MWZLJOVZ.cjs.map +1 -0
  11. package/dist/chunk-2JQISXBD.js +150 -0
  12. package/dist/chunk-2JQISXBD.js.map +1 -0
  13. package/dist/chunk-3HQ7A6ZM.cjs +61 -0
  14. package/dist/chunk-3HQ7A6ZM.cjs.map +1 -0
  15. package/dist/chunk-5AKBSMEQ.cjs +1008 -0
  16. package/dist/chunk-5AKBSMEQ.cjs.map +1 -0
  17. package/dist/chunk-5V5HSN6Y.js +81 -0
  18. package/dist/chunk-5V5HSN6Y.js.map +1 -0
  19. package/dist/chunk-BH24DZ5S.cjs +91 -0
  20. package/dist/chunk-BH24DZ5S.cjs.map +1 -0
  21. package/dist/chunk-C7QQOJ7T.cjs +67 -0
  22. package/dist/chunk-C7QQOJ7T.cjs.map +1 -0
  23. package/dist/chunk-ERQE57IA.cjs +404 -0
  24. package/dist/chunk-ERQE57IA.cjs.map +1 -0
  25. package/dist/chunk-EUP7MBAH.cjs +165 -0
  26. package/dist/chunk-EUP7MBAH.cjs.map +1 -0
  27. package/dist/chunk-G7VZBCD6.cjs +35 -0
  28. package/dist/chunk-G7VZBCD6.cjs.map +1 -0
  29. package/dist/chunk-GQV47S3N.cjs +10 -0
  30. package/dist/chunk-GQV47S3N.cjs.map +1 -0
  31. package/dist/chunk-GXZ3MTCQ.cjs +527 -0
  32. package/dist/chunk-GXZ3MTCQ.cjs.map +1 -0
  33. package/dist/chunk-JWNXBALH.cjs +57 -0
  34. package/dist/chunk-JWNXBALH.cjs.map +1 -0
  35. package/dist/chunk-KIKBPJXJ.cjs +348 -0
  36. package/dist/chunk-KIKBPJXJ.cjs.map +1 -0
  37. package/dist/chunk-NCW4AE7L.js +8 -0
  38. package/dist/chunk-NCW4AE7L.js.map +1 -0
  39. package/dist/chunk-NDM5EJEV.cjs +70 -0
  40. package/dist/chunk-NDM5EJEV.cjs.map +1 -0
  41. package/dist/chunk-NUIQHTSA.js +489 -0
  42. package/dist/chunk-NUIQHTSA.js.map +1 -0
  43. package/dist/chunk-OQDSHMXU.js +1002 -0
  44. package/dist/chunk-OQDSHMXU.js.map +1 -0
  45. package/dist/chunk-P37MRZ73.js +58 -0
  46. package/dist/chunk-P37MRZ73.js.map +1 -0
  47. package/dist/chunk-PWHOUQOZ.js +335 -0
  48. package/dist/chunk-PWHOUQOZ.js.map +1 -0
  49. package/dist/chunk-S4B7GYLN.js +112 -0
  50. package/dist/chunk-S4B7GYLN.js.map +1 -0
  51. package/dist/chunk-SGZZL5AC.js +59 -0
  52. package/dist/chunk-SGZZL5AC.js.map +1 -0
  53. package/dist/chunk-SQKBT2SH.cjs +122 -0
  54. package/dist/chunk-SQKBT2SH.cjs.map +1 -0
  55. package/dist/chunk-TSF6HEVS.cjs +201 -0
  56. package/dist/chunk-TSF6HEVS.cjs.map +1 -0
  57. package/dist/chunk-V23OSL25.js +48 -0
  58. package/dist/chunk-V23OSL25.js.map +1 -0
  59. package/dist/chunk-W77GRBO4.js +53 -0
  60. package/dist/chunk-W77GRBO4.js.map +1 -0
  61. package/dist/chunk-XV72HNHN.js +399 -0
  62. package/dist/chunk-XV72HNHN.js.map +1 -0
  63. package/dist/chunk-YOWDERVC.js +186 -0
  64. package/dist/chunk-YOWDERVC.js.map +1 -0
  65. package/dist/chunk-Z6ZWNWWR.js +30 -0
  66. package/dist/chunk-Z6ZWNWWR.js.map +1 -0
  67. package/dist/chunk-ZKZV6OI3.cjs +165 -0
  68. package/dist/chunk-ZKZV6OI3.cjs.map +1 -0
  69. package/dist/chunk-ZU6J7KMY.js +159 -0
  70. package/dist/chunk-ZU6J7KMY.js.map +1 -0
  71. package/dist/core/index.cjs +300 -0
  72. package/dist/core/index.cjs.map +1 -0
  73. package/dist/core/index.d.cts +9 -0
  74. package/dist/core/index.d.ts +9 -0
  75. package/dist/core/index.js +11 -0
  76. package/dist/core/index.js.map +1 -0
  77. package/dist/index-BBzvvrhG.d.ts +757 -0
  78. package/dist/index-BGvapsJy.d.cts +2811 -0
  79. package/dist/index-C-jSNw6j.d.cts +757 -0
  80. package/dist/index-ChGaGPzP.d.ts +2811 -0
  81. package/dist/index.cjs +3652 -0
  82. package/dist/index.cjs.map +1 -0
  83. package/dist/index.d.cts +12 -0
  84. package/dist/index.d.ts +12 -0
  85. package/dist/index.js +3112 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/indexer/index.cjs +58 -0
  88. package/dist/indexer/index.cjs.map +1 -0
  89. package/dist/indexer/index.d.cts +206 -0
  90. package/dist/indexer/index.d.ts +206 -0
  91. package/dist/indexer/index.js +5 -0
  92. package/dist/indexer/index.js.map +1 -0
  93. package/dist/keccak-m31-B_AqBbRF.d.cts +70 -0
  94. package/dist/keccak-m31-B_AqBbRF.d.ts +70 -0
  95. package/dist/keys/index.cjs +68 -0
  96. package/dist/keys/index.cjs.map +1 -0
  97. package/dist/keys/index.d.cts +158 -0
  98. package/dist/keys/index.d.ts +158 -0
  99. package/dist/keys/index.js +7 -0
  100. package/dist/keys/index.js.map +1 -0
  101. package/dist/merkle-7KS2EHRF.js +5 -0
  102. package/dist/merkle-7KS2EHRF.js.map +1 -0
  103. package/dist/merkle-HGDC6OB4.cjs +30 -0
  104. package/dist/merkle-HGDC6OB4.cjs.map +1 -0
  105. package/dist/merkle-mteVOlDf.d.cts +188 -0
  106. package/dist/merkle-mteVOlDf.d.ts +188 -0
  107. package/dist/poseidon-UHTJLWQM.js +7 -0
  108. package/dist/poseidon-UHTJLWQM.js.map +1 -0
  109. package/dist/poseidon-WHJSZSNP.cjs +45 -0
  110. package/dist/poseidon-WHJSZSNP.cjs.map +1 -0
  111. package/dist/proof-5OECB3RQ.cjs +45 -0
  112. package/dist/proof-5OECB3RQ.cjs.map +1 -0
  113. package/dist/proof-C4YBP6RY.js +4 -0
  114. package/dist/proof-C4YBP6RY.js.map +1 -0
  115. package/dist/react/index.cjs +2641 -0
  116. package/dist/react/index.cjs.map +1 -0
  117. package/dist/react/index.d.cts +757 -0
  118. package/dist/react/index.d.ts +757 -0
  119. package/dist/react/index.js +2598 -0
  120. package/dist/react/index.js.map +1 -0
  121. package/dist/transfer-2UDHDS7Q.cjs +37 -0
  122. package/dist/transfer-2UDHDS7Q.cjs.map +1 -0
  123. package/dist/transfer-BlmbO-Rd.d.ts +1270 -0
  124. package/dist/transfer-DKZuJnRM.d.cts +1270 -0
  125. package/dist/transfer-KTCXKHS4.js +8 -0
  126. package/dist/transfer-KTCXKHS4.js.map +1 -0
  127. package/dist/types-CJSbxv4q.d.cts +143 -0
  128. package/dist/types-mLybMxNR.d.ts +143 -0
  129. package/dist/utils/index.cjs +178 -0
  130. package/dist/utils/index.cjs.map +1 -0
  131. package/dist/utils/index.d.cts +88 -0
  132. package/dist/utils/index.d.ts +88 -0
  133. package/dist/utils/index.js +9 -0
  134. package/dist/utils/index.js.map +1 -0
  135. package/package.json +119 -0
  136. package/src/contracts/interfaces/IASPRegistry.sol +36 -0
  137. package/src/contracts/interfaces/IUniversalPrivatePool.sol +260 -0
  138. package/src/contracts/interfaces/IVerifiers.sol +68 -0
  139. package/src/deployments/11155111.json +19 -0
  140. package/src/deployments/31337.json +19 -0
@@ -0,0 +1,1270 @@
1
+ import { Address, Hex, PublicClient } from 'viem';
2
+ import { d as buildMerkleTree, a as MerkleProof } from './merkle-mteVOlDf.js';
3
+ import { a as M31Digest } from './keccak-m31-B_AqBbRF.js';
4
+ import * as _permissionless_technologies_upc_sdk from '@permissionless-technologies/upc-sdk';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import { ReactNode } from 'react';
7
+ import { M as MasterKeys, b as StarkMasterKeys } from './types-mLybMxNR.js';
8
+
9
+ /**
10
+ * Core type definitions for UPP SDK
11
+ */
12
+
13
+ /**
14
+ * Note version - increment when note structure changes
15
+ */
16
+ declare const NOTE_VERSION = 5;
17
+ /**
18
+ * A private note in the Universal Private Pool
19
+ */
20
+ interface Note {
21
+ /** Note format version */
22
+ version: number;
23
+ /** Token amount (in wei) */
24
+ amount: bigint;
25
+ /** Random blinding factor */
26
+ blinding: bigint;
27
+ /** Current origin - who is responsible for these funds (updated on merge) */
28
+ origin: Address;
29
+ /** Sender - who sent this specific note (for payment attribution) */
30
+ sender: Address;
31
+ /** ERC20 token address */
32
+ token: Address;
33
+ /** Optional memo/message */
34
+ memo?: string;
35
+ /** Timestamp when note was created */
36
+ timestamp?: number;
37
+ }
38
+ /**
39
+ * Encrypted note data stored on-chain (post-quantum, hash-based)
40
+ */
41
+ interface EncryptedNote {
42
+ /** AES-GCM encrypted note data */
43
+ ciphertext: Hex;
44
+ /** AES-GCM nonce */
45
+ nonce: Hex;
46
+ }
47
+ /**
48
+ * Stealth meta-address (hash-based, post-quantum)
49
+ * Published once, used by senders to encrypt notes to the recipient
50
+ */
51
+ interface StealthMetaAddress {
52
+ /** Owner hash = Poseidon(spendingSecret) */
53
+ ownerHash: bigint;
54
+ /** Viewing hash = Poseidon(viewingSecret) */
55
+ viewingHash: bigint;
56
+ }
57
+ /**
58
+ * One-time address for a specific transaction (simplified for hash-based system)
59
+ */
60
+ interface StealthAddress {
61
+ /** Owner hash for this note */
62
+ ownerHash: bigint;
63
+ /** Search tag for efficient scanning */
64
+ searchTag?: bigint;
65
+ }
66
+ /**
67
+ * On-chain merge record for audit trail
68
+ */
69
+ interface MergeRecord {
70
+ /** Output commitment (the merged note) */
71
+ outputCommitment: Hex;
72
+ /** First input nullifier */
73
+ nullifier1: Hex;
74
+ /** Second input nullifier */
75
+ nullifier2: Hex;
76
+ /** Who performed the merge (new origin) */
77
+ merger: Address;
78
+ /** Token that was merged */
79
+ token: Address;
80
+ /** Block timestamp */
81
+ timestamp: number;
82
+ }
83
+ /**
84
+ * ASP (Association Set Provider) root
85
+ */
86
+ interface ASPRoot {
87
+ /** Merkle root of approved addresses */
88
+ root: bigint;
89
+ /** IPFS hash for off-chain data */
90
+ ipfsHash: Hex;
91
+ /** When this root was published */
92
+ timestamp: number;
93
+ /** Number of addresses in the set */
94
+ leafCount: number;
95
+ }
96
+ /**
97
+ * Shield operation parameters
98
+ */
99
+ interface ShieldParams {
100
+ /** ERC20 token to shield */
101
+ token: Address;
102
+ /** Amount to shield (in wei) */
103
+ amount: bigint;
104
+ /** Optional: recipient owner hash (defaults to self) */
105
+ recipientOwnerHash?: bigint;
106
+ /** Optional: memo to include in note */
107
+ memo?: string;
108
+ }
109
+ /**
110
+ * Transfer operation parameters
111
+ */
112
+ interface TransferParams {
113
+ /** Note to spend */
114
+ note: Note;
115
+ /** Recipient stealth address */
116
+ recipient: StealthAddress;
117
+ /** Amount to send (remainder goes back to sender as change) */
118
+ amount: bigint;
119
+ /** Optional: memo to include */
120
+ memo?: string;
121
+ }
122
+ /**
123
+ * Merge operation parameters
124
+ */
125
+ interface MergeParams {
126
+ /** Notes to merge (must be same token) */
127
+ notes: [Note, Note];
128
+ /** Optional: memo for the merged note */
129
+ memo?: string;
130
+ }
131
+ /**
132
+ * Withdraw operation parameters
133
+ */
134
+ interface WithdrawParams {
135
+ /** Note to withdraw */
136
+ note: Note;
137
+ /** Amount to withdraw */
138
+ amount: bigint;
139
+ /** Recipient address for the tokens */
140
+ recipient: Address;
141
+ /** ASP ID to use for compliance check */
142
+ aspId?: number;
143
+ /** Use ragequit (origin withdrawing own funds) */
144
+ ragequit?: boolean;
145
+ }
146
+ /**
147
+ * Proof for ZK operations
148
+ */
149
+ interface Proof {
150
+ /** Proof points */
151
+ proof: {
152
+ pi_a: [string, string];
153
+ pi_b: [[string, string], [string, string]];
154
+ pi_c: [string, string];
155
+ };
156
+ /** Public signals */
157
+ publicSignals: string[];
158
+ }
159
+ /**
160
+ * Note commitment (hash)
161
+ */
162
+ type Commitment = Hex;
163
+ /**
164
+ * Nullifier (spent note identifier)
165
+ */
166
+ type Nullifier = Hex;
167
+
168
+ /** STARK amount scaling: 1e15 wei per STARK unit (matches contract) */
169
+ declare const STARK_AMOUNT_SCALE: bigint;
170
+ /**
171
+ * A private STARK note in the Universal Private Pool.
172
+ *
173
+ * All field values are M31 elements (< 2^31 - 1).
174
+ * Commitment = keccak_m31(amount, ownerHash[0..4], blinding, origin, token).
175
+ */
176
+ interface StarkNote {
177
+ /** Amount in STARK units (actual wei = amount * STARK_AMOUNT_SCALE) */
178
+ amount: bigint;
179
+ /** Owner hash = keccak_m31(starkSecret) — 4 M31 elements */
180
+ ownerHash: M31Digest;
181
+ /** Random blinding factor (M31) */
182
+ blinding: bigint;
183
+ /** Origin address encoded as M31 (lower 31 bits of address) */
184
+ origin: bigint;
185
+ /** Token address encoded as M31 (lower 31 bits of address) */
186
+ token: bigint;
187
+ /** The leaf index in the STARK Keccak Merkle tree (set after shielding) */
188
+ leafIndex?: number;
189
+ /** The commitment digest (set after computation) */
190
+ commitment?: M31Digest;
191
+ /** Optional memo */
192
+ memo?: string;
193
+ /** Timestamp when note was created */
194
+ timestamp?: number;
195
+ }
196
+ /**
197
+ * STARK stealth meta-address (M31/Keccak-based)
198
+ * Published once, used by senders to encrypt notes to the recipient
199
+ */
200
+ interface StarkStealthMetaAddress {
201
+ /** Owner hash = keccak_m31(starkSecret) — 4 M31 elements */
202
+ ownerHash: M31Digest;
203
+ /** Viewing hash = keccak_m31(starkViewingSecret) — 4 M31 elements */
204
+ viewingHash: M31Digest;
205
+ }
206
+ /**
207
+ * STARK proof for ZK operations (serialized Circle STARK proof)
208
+ */
209
+ interface StarkProof {
210
+ /** Raw serialized Stwo Circle STARK proof bytes */
211
+ proofBytes: Hex;
212
+ /** Public inputs seed (keccak256 of public parameters) */
213
+ publicInputsSeed: Hex;
214
+ }
215
+
216
+ /**
217
+ * ZK Proof Generation and Verification
218
+ *
219
+ * Uses snarkjs for Groth16 proof generation in the browser.
220
+ */
221
+
222
+ /** State tree depth (32 levels = ~4B notes) */
223
+ declare const STATE_TREE_DEPTH = 32;
224
+ /** ASP tree depth (20 levels = ~1M addresses) */
225
+ declare const ASP_TREE_DEPTH$1 = 20;
226
+ /**
227
+ * Circuit types available in UPP (full protocol)
228
+ */
229
+ type UPPCircuitType = 'transfer' | 'merge' | 'withdraw' | 'joinsplit' | 'merge_transfer_2x2' | 'merge_transfer_4x2';
230
+ /**
231
+ * @deprecated Use UPPCircuitType instead
232
+ */
233
+ type CircuitType = 'shield' | 'transfer' | 'merge' | 'withdraw';
234
+ /**
235
+ * @deprecated Stealth circuits are being replaced by UPP circuits
236
+ */
237
+ type StealthCircuitType = '1x2' | '2x2';
238
+ /**
239
+ * Input signals for UPP transfer circuit (1-in-2-out)
240
+ *
241
+ * Matches transfer.circom: Transfer(32, 20)
242
+ * Public: stateRoot, aspRoot, nullifier, outputCommitment1, outputCommitment2, token
243
+ */
244
+ interface UPPTransferCircuitInputs {
245
+ stateRoot: string;
246
+ aspRoot: string;
247
+ nullifier: string;
248
+ outputCommitment1: string;
249
+ outputCommitment2: string;
250
+ token: string;
251
+ inputAmount: string;
252
+ inputOneTimeSecret: string;
253
+ inputBlinding: string;
254
+ inputOrigin: string;
255
+ inputLeafIndex: string;
256
+ inputPathElements: string[];
257
+ inputPathIndices: string[];
258
+ aspPathElements: string[];
259
+ aspPathIndices: string[];
260
+ outputAmount1: string;
261
+ outputPubkeyX1: string;
262
+ outputPubkeyY1: string;
263
+ outputBlinding1: string;
264
+ outputAmount2: string;
265
+ outputPubkeyX2: string;
266
+ outputPubkeyY2: string;
267
+ outputBlinding2: string;
268
+ }
269
+ /**
270
+ * Input signals for UPP withdraw circuit
271
+ *
272
+ * Matches withdraw.circom with optional ASP check (ragequit support)
273
+ */
274
+ interface UPPWithdrawCircuitInputs {
275
+ stateRoot: string;
276
+ aspRoot: string;
277
+ nullifier: string;
278
+ amount: string;
279
+ recipient: string;
280
+ token: string;
281
+ isRagequit: string;
282
+ inputAmount: string;
283
+ inputOneTimeSecret: string;
284
+ inputBlinding: string;
285
+ inputOrigin: string;
286
+ inputLeafIndex: string;
287
+ inputPathElements: string[];
288
+ inputPathIndices: string[];
289
+ aspPathElements: string[];
290
+ aspPathIndices: string[];
291
+ }
292
+ /**
293
+ * @deprecated Use UPPTransferCircuitInputs instead
294
+ */
295
+ interface TransferCircuitInputs {
296
+ stateRoot: bigint;
297
+ aspRoot: bigint;
298
+ nullifier: bigint;
299
+ outputCommitment1: bigint;
300
+ outputCommitment2: bigint;
301
+ token: bigint;
302
+ amount: bigint;
303
+ blinding: bigint;
304
+ origin: bigint;
305
+ statePathElements: bigint[];
306
+ statePathIndices: bigint;
307
+ aspPathElements: bigint[];
308
+ outAmount1: bigint;
309
+ outBlinding1: bigint;
310
+ outOrigin1: bigint;
311
+ outAmount2: bigint;
312
+ outBlinding2: bigint;
313
+ outOrigin2: bigint;
314
+ }
315
+ /**
316
+ * Input signals for shield circuit
317
+ */
318
+ interface ShieldCircuitInputs {
319
+ commitment: bigint;
320
+ token: bigint;
321
+ amount: bigint;
322
+ blinding: bigint;
323
+ origin: bigint;
324
+ }
325
+ /**
326
+ * Input signals for merge circuit
327
+ */
328
+ interface MergeCircuitInputs {
329
+ stateRoot: bigint;
330
+ nullifier1: bigint;
331
+ nullifier2: bigint;
332
+ outputCommitment: bigint;
333
+ newOrigin: bigint;
334
+ token: bigint;
335
+ amount1: bigint;
336
+ blinding1: bigint;
337
+ origin1: bigint;
338
+ token1: bigint;
339
+ pathElements1: bigint[];
340
+ pathIndices1: bigint;
341
+ amount2: bigint;
342
+ blinding2: bigint;
343
+ origin2: bigint;
344
+ token2: bigint;
345
+ pathElements2: bigint[];
346
+ pathIndices2: bigint;
347
+ outputAmount: bigint;
348
+ outputBlinding: bigint;
349
+ }
350
+ /**
351
+ * Input signals for withdraw circuit
352
+ */
353
+ interface WithdrawCircuitInputs {
354
+ stateRoot: bigint;
355
+ aspRoot: bigint;
356
+ nullifier: bigint;
357
+ withdrawAmount: bigint;
358
+ recipient: bigint;
359
+ token: bigint;
360
+ isRagequit: bigint;
361
+ amount: bigint;
362
+ blinding: bigint;
363
+ origin: bigint;
364
+ statePathElements: bigint[];
365
+ statePathIndices: bigint;
366
+ aspPathElements: bigint[];
367
+ }
368
+ /**
369
+ * Circuit inputs union type
370
+ */
371
+ type CircuitInputs = ShieldCircuitInputs | TransferCircuitInputs | MergeCircuitInputs | WithdrawCircuitInputs;
372
+ /**
373
+ * Circuit input for 1x2 stealth transfer (1-in-2-out)
374
+ */
375
+ interface Stealth1x2CircuitInputs {
376
+ root: string;
377
+ nullifierHash: string;
378
+ publicAmount: string;
379
+ recipient: string;
380
+ extDataHash: string;
381
+ inputAmount: string;
382
+ inputOneTimeSecret: string;
383
+ inputBlinding: string;
384
+ inputLeafIndex: string;
385
+ inputPathElements: string[];
386
+ inputPathIndices: string[];
387
+ outputAmount1: string;
388
+ outputPubkeyX1: string;
389
+ outputPubkeyY1: string;
390
+ outputBlinding1: string;
391
+ outputAmount2: string;
392
+ outputPubkeyX2: string;
393
+ outputPubkeyY2: string;
394
+ outputBlinding2: string;
395
+ }
396
+ /**
397
+ * Circuit input for 2x2 stealth transfer (2-in-2-out)
398
+ */
399
+ interface Stealth2x2CircuitInputs {
400
+ root: string;
401
+ nullifierHash1: string;
402
+ nullifierHash2: string;
403
+ publicAmount: string;
404
+ recipient: string;
405
+ extDataHash: string;
406
+ inputAmount1: string;
407
+ inputOneTimeSecret1: string;
408
+ inputBlinding1: string;
409
+ inputLeafIndex1: string;
410
+ inputPathElements1: string[];
411
+ inputPathIndices1: string[];
412
+ inputAmount2: string;
413
+ inputOneTimeSecret2: string;
414
+ inputBlinding2: string;
415
+ inputLeafIndex2: string;
416
+ inputPathElements2: string[];
417
+ inputPathIndices2: string[];
418
+ outputAmount1: string;
419
+ outputPubkeyX1: string;
420
+ outputPubkeyY1: string;
421
+ outputBlinding1: string;
422
+ outputAmount2: string;
423
+ outputPubkeyX2: string;
424
+ outputPubkeyY2: string;
425
+ outputBlinding2: string;
426
+ }
427
+ /**
428
+ * Stealth circuit inputs union
429
+ */
430
+ type StealthCircuitInputs = Stealth1x2CircuitInputs | Stealth2x2CircuitInputs;
431
+ /**
432
+ * Circuit artifact paths
433
+ */
434
+ interface CircuitArtifacts {
435
+ wasm: string;
436
+ zkey: string;
437
+ }
438
+ /**
439
+ * Get circuit artifacts for a UPP circuit
440
+ *
441
+ * @param circuit - UPP circuit type
442
+ * @param baseUrl - Base URL for circuit files (default: '/circuits/')
443
+ */
444
+ declare function getUPPCircuitArtifacts(circuit: UPPCircuitType, baseUrl?: string): CircuitArtifacts;
445
+ /**
446
+ * @deprecated Use getUPPCircuitArtifacts instead
447
+ * Get circuit artifacts for a stealth circuit
448
+ *
449
+ * @param circuit - Circuit type ('1x2' or '2x2')
450
+ * @param baseUrl - Base URL for circuit files (default: '/circuits/')
451
+ */
452
+ declare function getStealthCircuitArtifacts(circuit: StealthCircuitType, baseUrl?: string): CircuitArtifacts;
453
+ /**
454
+ * UPP circuit inputs union type
455
+ */
456
+ type UPPCircuitInputs = UPPTransferCircuitInputs | UPPWithdrawCircuitInputs;
457
+ /**
458
+ * Generate a ZK proof for a UPP circuit
459
+ *
460
+ * @param circuitType - Which UPP circuit to use
461
+ * @param inputs - Circuit input signals
462
+ * @param baseUrl - Base URL for circuit artifacts (default: '/circuits/')
463
+ * @returns Generated proof and public signals
464
+ *
465
+ * @example
466
+ * ```ts
467
+ * const { proof, publicSignals } = await generateUPPProof('transfer', {
468
+ * stateRoot: String(currentRoot),
469
+ * aspRoot: String(aspRoot),
470
+ * // ... other inputs
471
+ * })
472
+ * ```
473
+ */
474
+ declare function generateUPPProof(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string): Promise<ProofResult>;
475
+ /**
476
+ * @deprecated Use generateUPPProof instead
477
+ * Generate a ZK proof for a circuit (UPP protocol circuits)
478
+ */
479
+ declare function generateProof(_circuitType: CircuitType, _inputs: CircuitInputs): Promise<Proof>;
480
+ /**
481
+ * Result from proof generation
482
+ */
483
+ interface ProofResult {
484
+ proof: Proof;
485
+ publicSignals: string[];
486
+ }
487
+ /**
488
+ * Generate a ZK proof for stealth circuit (1x2 or 2x2)
489
+ *
490
+ * @param circuit - Circuit type ('1x2' or '2x2')
491
+ * @param inputs - Circuit input signals
492
+ * @param baseUrl - Base URL for circuit artifacts (default: '/circuits/')
493
+ * @returns Generated proof and public signals
494
+ *
495
+ * @example
496
+ * ```ts
497
+ * const { proof, publicSignals } = await generateStealthProof('1x2', {
498
+ * root: String(merkleRoot),
499
+ * nullifierHash: String(nullifier),
500
+ * // ... other inputs
501
+ * })
502
+ * ```
503
+ */
504
+ declare function generateStealthProof(circuit: StealthCircuitType, inputs: StealthCircuitInputs, baseUrl?: string): Promise<ProofResult>;
505
+ /**
506
+ * Verify a ZK proof
507
+ *
508
+ * @param circuitType - Which circuit was used
509
+ * @param proof - The proof to verify
510
+ * @returns True if proof is valid
511
+ */
512
+ declare function verifyProof(_circuitType: CircuitType, _proof: Proof): Promise<boolean>;
513
+ /**
514
+ * Format proof for on-chain verification
515
+ *
516
+ * Converts snarkjs proof format to Solidity verifier format
517
+ */
518
+ declare function formatProofForContract(proof: Proof): {
519
+ a: [bigint, bigint];
520
+ b: [[bigint, bigint], [bigint, bigint]];
521
+ c: [bigint, bigint];
522
+ };
523
+
524
+ /**
525
+ * Swap Module
526
+ *
527
+ * Core logic for building and interacting with the UPP in-pool swap order book.
528
+ * Framework-agnostic (no React). Reuses withdraw verifier for proofs.
529
+ */
530
+
531
+ /**
532
+ * Swap order as stored on-chain
533
+ */
534
+ interface SwapOrder {
535
+ /** Order ID (= maker's nullifier) */
536
+ orderId: Hex;
537
+ /** Token being sold */
538
+ sellToken: Address;
539
+ /** Original total sell amount */
540
+ sellAmount: bigint;
541
+ /** Remaining sell amount (decremented on each fill) */
542
+ remainingSellAmount: bigint;
543
+ /** Token the maker wants to receive */
544
+ buyToken: Address;
545
+ /** Price: buyToken per sellToken (1e18 fixed-point) */
546
+ rate: bigint;
547
+ /** Accumulated buy token amount from fills */
548
+ accumulatedBuyAmount: bigint;
549
+ /** Maker's ASP ID (public, filterable by takers) */
550
+ makerAspId: bigint;
551
+ /** Required filler ASP (0 = any) */
552
+ requiredFillerAspId: bigint;
553
+ /** Block number after which order expires */
554
+ expiry: bigint;
555
+ /** Whether the maker has claimed */
556
+ claimed: boolean;
557
+ /** Whether the order was cancelled */
558
+ cancelled: boolean;
559
+ }
560
+ /**
561
+ * Parameters to place a swap order
562
+ */
563
+ interface SwapOrderParams {
564
+ /** Token to sell */
565
+ sellToken: Address;
566
+ /** Amount to sell */
567
+ sellAmount: bigint;
568
+ /** Token to buy */
569
+ buyToken: Address;
570
+ /** Price: buyToken per sellToken (1e18 fixed-point) */
571
+ rate: bigint;
572
+ /** Required filler ASP (0n = accept any) */
573
+ requiredFillerAspId?: bigint;
574
+ /** Number of blocks until expiry (from current block) */
575
+ expiryBlocks: bigint;
576
+ }
577
+ /**
578
+ * Parameters to fill a swap order
579
+ */
580
+ interface SwapFillParams {
581
+ /** The order to fill */
582
+ orderId: Hex;
583
+ /** How much sellToken the filler wants (≤ remaining) */
584
+ takeAmount: bigint;
585
+ }
586
+ /**
587
+ * Swap order from event log
588
+ */
589
+ interface SwapOrderEvent {
590
+ orderId: Hex;
591
+ sellToken: Address;
592
+ buyToken: Address;
593
+ sellAmount: bigint;
594
+ rate: bigint;
595
+ makerAspId: bigint;
596
+ requiredFillerAspId: bigint;
597
+ expiry: bigint;
598
+ blockNumber: bigint;
599
+ /** On-chain remaining sell amount (populated by useSwapOrderBook) */
600
+ remainingSellAmount?: bigint;
601
+ /** Whether the order has been claimed */
602
+ claimed?: boolean;
603
+ /** Whether the order has been cancelled */
604
+ cancelled?: boolean;
605
+ }
606
+ /**
607
+ * Swap fill from event log
608
+ */
609
+ interface SwapFillEvent {
610
+ orderId: Hex;
611
+ fillerNullifier: Hex;
612
+ takeAmount: bigint;
613
+ giveAmount: bigint;
614
+ fillerAspId: bigint;
615
+ blockNumber: bigint;
616
+ }
617
+ /** 1e18 fixed-point precision for swap rates */
618
+ declare const RATE_PRECISION: bigint;
619
+ declare const SWAP_ORDER_PLACED_EVENT: {
620
+ readonly type: "event";
621
+ readonly name: "SwapOrderPlaced";
622
+ readonly inputs: readonly [{
623
+ readonly name: "orderId";
624
+ readonly type: "bytes32";
625
+ readonly indexed: true;
626
+ }, {
627
+ readonly name: "sellToken";
628
+ readonly type: "address";
629
+ readonly indexed: true;
630
+ }, {
631
+ readonly name: "buyToken";
632
+ readonly type: "address";
633
+ readonly indexed: true;
634
+ }, {
635
+ readonly name: "sellAmount";
636
+ readonly type: "uint256";
637
+ readonly indexed: false;
638
+ }, {
639
+ readonly name: "rate";
640
+ readonly type: "uint256";
641
+ readonly indexed: false;
642
+ }, {
643
+ readonly name: "makerAspId";
644
+ readonly type: "uint256";
645
+ readonly indexed: false;
646
+ }, {
647
+ readonly name: "requiredFillerAspId";
648
+ readonly type: "uint256";
649
+ readonly indexed: false;
650
+ }, {
651
+ readonly name: "expiry";
652
+ readonly type: "uint256";
653
+ readonly indexed: false;
654
+ }];
655
+ };
656
+ declare const SWAP_ORDER_FILLED_EVENT: {
657
+ readonly type: "event";
658
+ readonly name: "SwapOrderFilled";
659
+ readonly inputs: readonly [{
660
+ readonly name: "orderId";
661
+ readonly type: "bytes32";
662
+ readonly indexed: true;
663
+ }, {
664
+ readonly name: "fillerNullifier";
665
+ readonly type: "bytes32";
666
+ readonly indexed: true;
667
+ }, {
668
+ readonly name: "takeAmount";
669
+ readonly type: "uint256";
670
+ readonly indexed: false;
671
+ }, {
672
+ readonly name: "giveAmount";
673
+ readonly type: "uint256";
674
+ readonly indexed: false;
675
+ }, {
676
+ readonly name: "fillerAspId";
677
+ readonly type: "uint256";
678
+ readonly indexed: false;
679
+ }];
680
+ };
681
+ declare const SWAP_ORDER_CLAIMED_EVENT: {
682
+ readonly type: "event";
683
+ readonly name: "SwapOrderClaimed";
684
+ readonly inputs: readonly [{
685
+ readonly name: "orderId";
686
+ readonly type: "bytes32";
687
+ readonly indexed: true;
688
+ }, {
689
+ readonly name: "accumulatedBuyAmount";
690
+ readonly type: "uint256";
691
+ readonly indexed: false;
692
+ }, {
693
+ readonly name: "refundedSellAmount";
694
+ readonly type: "uint256";
695
+ readonly indexed: false;
696
+ }];
697
+ };
698
+ declare const SWAP_ORDER_CANCELLED_EVENT: {
699
+ readonly type: "event";
700
+ readonly name: "SwapOrderCancelled";
701
+ readonly inputs: readonly [{
702
+ readonly name: "orderId";
703
+ readonly type: "bytes32";
704
+ readonly indexed: true;
705
+ }, {
706
+ readonly name: "refundedSellAmount";
707
+ readonly type: "uint256";
708
+ readonly indexed: false;
709
+ }];
710
+ };
711
+ declare const SWAP_EVENTS_ABI: readonly [{
712
+ readonly type: "event";
713
+ readonly name: "SwapOrderPlaced";
714
+ readonly inputs: readonly [{
715
+ readonly name: "orderId";
716
+ readonly type: "bytes32";
717
+ readonly indexed: true;
718
+ }, {
719
+ readonly name: "sellToken";
720
+ readonly type: "address";
721
+ readonly indexed: true;
722
+ }, {
723
+ readonly name: "buyToken";
724
+ readonly type: "address";
725
+ readonly indexed: true;
726
+ }, {
727
+ readonly name: "sellAmount";
728
+ readonly type: "uint256";
729
+ readonly indexed: false;
730
+ }, {
731
+ readonly name: "rate";
732
+ readonly type: "uint256";
733
+ readonly indexed: false;
734
+ }, {
735
+ readonly name: "makerAspId";
736
+ readonly type: "uint256";
737
+ readonly indexed: false;
738
+ }, {
739
+ readonly name: "requiredFillerAspId";
740
+ readonly type: "uint256";
741
+ readonly indexed: false;
742
+ }, {
743
+ readonly name: "expiry";
744
+ readonly type: "uint256";
745
+ readonly indexed: false;
746
+ }];
747
+ }, {
748
+ readonly type: "event";
749
+ readonly name: "SwapOrderFilled";
750
+ readonly inputs: readonly [{
751
+ readonly name: "orderId";
752
+ readonly type: "bytes32";
753
+ readonly indexed: true;
754
+ }, {
755
+ readonly name: "fillerNullifier";
756
+ readonly type: "bytes32";
757
+ readonly indexed: true;
758
+ }, {
759
+ readonly name: "takeAmount";
760
+ readonly type: "uint256";
761
+ readonly indexed: false;
762
+ }, {
763
+ readonly name: "giveAmount";
764
+ readonly type: "uint256";
765
+ readonly indexed: false;
766
+ }, {
767
+ readonly name: "fillerAspId";
768
+ readonly type: "uint256";
769
+ readonly indexed: false;
770
+ }];
771
+ }, {
772
+ readonly type: "event";
773
+ readonly name: "SwapOrderClaimed";
774
+ readonly inputs: readonly [{
775
+ readonly name: "orderId";
776
+ readonly type: "bytes32";
777
+ readonly indexed: true;
778
+ }, {
779
+ readonly name: "accumulatedBuyAmount";
780
+ readonly type: "uint256";
781
+ readonly indexed: false;
782
+ }, {
783
+ readonly name: "refundedSellAmount";
784
+ readonly type: "uint256";
785
+ readonly indexed: false;
786
+ }];
787
+ }, {
788
+ readonly type: "event";
789
+ readonly name: "SwapOrderCancelled";
790
+ readonly inputs: readonly [{
791
+ readonly name: "orderId";
792
+ readonly type: "bytes32";
793
+ readonly indexed: true;
794
+ }, {
795
+ readonly name: "refundedSellAmount";
796
+ readonly type: "uint256";
797
+ readonly indexed: false;
798
+ }];
799
+ }];
800
+ /**
801
+ * Compute the giveAmount (buyToken) for a given takeAmount (sellToken) at a rate.
802
+ * giveAmount = (takeAmount * rate) / 1e18
803
+ */
804
+ declare function computeGiveAmount(takeAmount: bigint, rate: bigint): bigint;
805
+ /**
806
+ * Compute the maximum takeAmount for a given giveAmount and rate.
807
+ * takeAmount = (giveAmount * 1e18) / rate
808
+ */
809
+ declare function computeTakeAmount(giveAmount: bigint, rate: bigint): bigint;
810
+ /**
811
+ * Compute rate from a desired trade: I want `buyAmount` of buyToken for `sellAmount` of sellToken.
812
+ * rate = (buyAmount * 1e18) / sellAmount
813
+ */
814
+ declare function computeRate(sellAmount: bigint, buyAmount: bigint): bigint;
815
+ /**
816
+ * Format a rate for human display.
817
+ * Returns a string like "0.0005" for rate = 500000000000000n (0.0005e18)
818
+ */
819
+ declare function formatRate(rate: bigint, decimals?: number): string;
820
+ /**
821
+ * Generate a cancel key hash from a secret.
822
+ * The secret should be a random 32-byte value stored by the maker.
823
+ */
824
+ declare function computeCancelKeyHash(cancelSecret: Hex): Hex;
825
+ /**
826
+ * Generate a random cancel secret.
827
+ */
828
+ declare function generateCancelSecret(): Hex;
829
+ /**
830
+ * Filter orders by ASP: only show orders from makers on acceptable ASPs.
831
+ */
832
+ declare function filterOrdersByASP(orders: SwapOrderEvent[], acceptableAspIds: bigint[]): SwapOrderEvent[];
833
+ /**
834
+ * Filter orders by token pair.
835
+ */
836
+ declare function filterOrdersByTokenPair(orders: SwapOrderEvent[], sellToken: Address, buyToken: Address): SwapOrderEvent[];
837
+ /**
838
+ * Check if a filler's ASP is accepted by an order.
839
+ */
840
+ declare function isFillerASPAccepted(order: SwapOrder | SwapOrderEvent, fillerAspId: bigint): boolean;
841
+ /**
842
+ * Store a cancel secret in localStorage, scoped by wallet address.
843
+ * Must be called after placing a swap order.
844
+ */
845
+ declare function storeCancelSecret(orderId: Hex, cancelSecret: Hex, account?: string): void;
846
+ /**
847
+ * Retrieve a cancel secret from localStorage.
848
+ * Returns null if not found (e.g. order was placed by someone else).
849
+ */
850
+ declare function getCancelSecret(orderId: Hex, account?: string): Hex | null;
851
+ /**
852
+ * Remove a cancel secret from localStorage (after claim or cancel).
853
+ */
854
+ declare function removeCancelSecret(orderId: Hex, account?: string): void;
855
+ /**
856
+ * Get all order IDs for a specific wallet address.
857
+ * Falls back to all cancel secrets if no account provided (backward compat).
858
+ */
859
+ declare function getOwnOrderIds(account?: string): Hex[];
860
+ /**
861
+ * Check if an order is still active (not claimed, not cancelled, not expired).
862
+ */
863
+ declare function isOrderActive(order: SwapOrder, currentBlock: bigint): boolean;
864
+ /**
865
+ * Compute the total buyToken amount the maker would receive for a full fill.
866
+ */
867
+ declare function computeTotalBuyAmount(sellAmount: bigint, rate: bigint): bigint;
868
+ /**
869
+ * Compute fill percentage (0-100) for display.
870
+ */
871
+ declare function computeFillPercentage(order: SwapOrder): number;
872
+
873
+ /**
874
+ * ASP (Association Set Provider) Utilities
875
+ *
876
+ * Thin wrapper around @permissionless-technologies/upc-sdk.
877
+ * Provides pool-specific types (ASPProof with aspId) while delegating
878
+ * Merkle tree operations to the compliance SDK.
879
+ *
880
+ * In UPP, every transfer must prove the origin is in an approved ASP's allowlist.
881
+ */
882
+ declare const ASP_TREE_DEPTH = 20;
883
+ /**
884
+ * ASP Merkle proof structure (pool-specific: includes aspId)
885
+ */
886
+ interface ASPProof {
887
+ /** ASP ID */
888
+ aspId: bigint;
889
+ /** ASP's published root */
890
+ aspRoot: bigint;
891
+ /** Path elements (siblings) - 20 levels */
892
+ aspPathElements: bigint[];
893
+ /** Path indices - 20 levels */
894
+ aspPathIndices: number[];
895
+ }
896
+ /**
897
+ * Compute the ASP root for a single-leaf tree
898
+ */
899
+ declare function computeSingleOriginASPRoot(origin: bigint): Promise<bigint>;
900
+ /**
901
+ * Generate ASP proof for a single-origin tree
902
+ */
903
+ declare function generateSingleOriginASPProof(aspId: bigint, origin: bigint): Promise<ASPProof>;
904
+ /**
905
+ * Verify an ASP proof locally (for debugging)
906
+ */
907
+ declare function verifyASPProof(origin: bigint, proof: ASPProof): Promise<boolean>;
908
+ /**
909
+ * Demo ASP configuration
910
+ */
911
+ declare const DEMO_ASP_ID = 1n;
912
+ declare const DEMO_ASP_NAME = "Demo ASP (Single-Origin)";
913
+ /**
914
+ * Create a "universal approval" ASP root
915
+ */
916
+ declare function createDemoASPRoot(origin: bigint): Promise<bigint>;
917
+ /**
918
+ * Build an ASP Merkle tree from multiple origin addresses
919
+ */
920
+ declare function buildASPTree(origins: bigint[]): _permissionless_technologies_upc_sdk.MerkleTree;
921
+ /**
922
+ * Compute the Merkle root for a set of approved origins
923
+ */
924
+ declare function computeMultiOriginASPRoot(origins: bigint[]): Promise<bigint>;
925
+ /**
926
+ * Generate an ASP membership proof for one origin within a multi-origin tree
927
+ */
928
+ declare function generateMultiOriginASPProof(aspId: bigint, origin: bigint, allOrigins: bigint[]): Promise<ASPProof>;
929
+ /**
930
+ * Generate an ASP proof, automatically choosing single-origin or multi-origin
931
+ */
932
+ declare function generateASPProof(aspId: bigint, origin: bigint, approvedOrigins?: bigint[]): Promise<ASPProof>;
933
+
934
+ /** Which proof system created/guards a note */
935
+ type ProofSystemType = 'snark' | 'stark';
936
+ /**
937
+ * A shielded note (UTXO) - Post-quantum hash-based
938
+ *
939
+ * Commitment = Poseidon(amount, ownerHash, blinding, origin, token)
940
+ * where ownerHash = Poseidon(spendingSecret)
941
+ */
942
+ interface ShieldedNote {
943
+ /** Amount of tokens */
944
+ amount: bigint;
945
+ /** Random blinding factor */
946
+ blinding: bigint;
947
+ /** Commitment hash (hex) */
948
+ commitment: string;
949
+ /** Spending secret for this note (hex) - proves ownership via hash preimage */
950
+ ownerSecret: string;
951
+ /** Owner hash = Poseidon(ownerSecret) - what's committed on-chain (hex) */
952
+ ownerHash: string;
953
+ /** Position in Merkle tree */
954
+ leafIndex: number;
955
+ /** Origin address (original depositor) as hex */
956
+ origin: string;
957
+ /** Token address as hex */
958
+ token: string;
959
+ /** Transaction hash */
960
+ txHash?: string;
961
+ /** Note status */
962
+ status: 'pending' | 'confirmed' | 'spent';
963
+ /** Timestamp */
964
+ timestamp: number;
965
+ /** Which proof system created this note (defaults to 'snark' for legacy notes) */
966
+ proofSystem?: ProofSystemType;
967
+ }
968
+ /**
969
+ * Note creation result
970
+ *
971
+ * Commitment = Poseidon(amount, pubkeyX, pubkeyY, blinding, origin, token)
972
+ * where (pubkeyX, pubkeyY) = BabyJubJub(ownerSecret)
973
+ */
974
+ interface NoteCreationResult {
975
+ commitment: bigint;
976
+ /** The secret whose hash is in the commitment (BabyJubJub private key) */
977
+ ownerSecret: bigint;
978
+ /** Poseidon(ownerSecret) - used for search/display */
979
+ ownerHash: bigint;
980
+ /** BabyJubJub public key X coordinate - used in note commitment */
981
+ pubkeyX: bigint;
982
+ /** BabyJubJub public key Y coordinate - used in note commitment */
983
+ pubkeyY: bigint;
984
+ blinding: bigint;
985
+ encryptedNote: string;
986
+ searchTag: bigint;
987
+ amount: bigint;
988
+ origin: bigint;
989
+ token: bigint;
990
+ }
991
+ /**
992
+ * Indexer configuration for advanced usage
993
+ */
994
+ interface IndexerConfig {
995
+ /** Enable IndexedDB storage (default: true if available) */
996
+ useIndexedDB?: boolean;
997
+ /** Custom storage prefix for multi-account support */
998
+ storagePrefix?: string;
999
+ /** Batch size for RPC scanning (default: 200, adapts on rate limits) */
1000
+ batchSize?: number;
1001
+ /** Sync interval for live sync in ms (default: 30000) */
1002
+ liveSyncIntervalMs?: number;
1003
+ /** Starting block for new accounts (skips blocks before account creation) */
1004
+ fromBlock?: number;
1005
+ /** Pool contract address (required for indexer) */
1006
+ contractAddress?: Address;
1007
+ }
1008
+ /**
1009
+ * Context type for UPP Account
1010
+ */
1011
+ interface UPPAccountContextType {
1012
+ /** SNARK master keys (null if not setup) */
1013
+ masterKeys: MasterKeys | null;
1014
+ /** STARK master keys (null if not setup) */
1015
+ starkMasterKeys: StarkMasterKeys | null;
1016
+ /** Connected wallet address */
1017
+ ethAddress: string | null;
1018
+ /** Owner hash (public identifier, hex) — SNARK */
1019
+ ownerHash: string | null;
1020
+ /** Stealth address (bech32m encoded, 0zk prefix) — SNARK */
1021
+ stealthAddress: string | null;
1022
+ /** STARK stealth address (bech32m encoded, 0zs prefix) */
1023
+ starkStealthAddress: string | null;
1024
+ /** All notes */
1025
+ notes: ShieldedNote[];
1026
+ /** Unspent notes */
1027
+ unspentNotes: ShieldedNote[];
1028
+ /** Total balance of unspent notes */
1029
+ balance: bigint;
1030
+ /** Whether account is set up */
1031
+ isSetup: boolean;
1032
+ /** Whether SDK is loading/initializing */
1033
+ isLoading: boolean;
1034
+ /** Whether crypto is ready */
1035
+ cryptoReady: boolean;
1036
+ /** Whether sync is in progress */
1037
+ isSyncing: boolean;
1038
+ /** Last synced block number */
1039
+ lastSyncedBlock: number;
1040
+ /** Set up a new account from wallet signature (low-level) */
1041
+ setupAccount: (signature: Hex) => Promise<void>;
1042
+ /** Connect private account via EIP-712 wallet signature (requires wagmi signTypedData) */
1043
+ connect: (password?: string) => Promise<void>;
1044
+ /** Whether a connect operation is in progress */
1045
+ isConnecting: boolean;
1046
+ /** Clear account and logout */
1047
+ logout: () => void;
1048
+ /** Alias for logout */
1049
+ disconnect: () => void;
1050
+ /** Add a note to the account */
1051
+ addNote: (note: ShieldedNote) => void;
1052
+ /** Mark a note as spent */
1053
+ markNoteSpent: (commitment: string) => void;
1054
+ /** Create note for self (e.g., shield or change output) */
1055
+ createNoteForSelf: (amount: bigint, origin: bigint, token: bigint) => Promise<NoteCreationResult>;
1056
+ /** Get owner hash */
1057
+ getOwnerHash: () => bigint | null;
1058
+ /** Select optimal circuit for a given amount */
1059
+ selectOptimalCircuit: (requiredAmount: bigint, tokenAddress?: string) => {
1060
+ circuit: '1x2' | '2x2' | null;
1061
+ selectedNotes: ShieldedNote[];
1062
+ error?: string;
1063
+ };
1064
+ /** Sync notes from blockchain (requires client to be passed in) */
1065
+ syncNotes: (contractAddress: Address, client: any) => Promise<number>;
1066
+ /** Start live sync (polls for new notes at interval) */
1067
+ startLiveSync: (contractAddress: Address, client: any) => void;
1068
+ /** Stop live sync */
1069
+ stopLiveSync: () => void;
1070
+ /** Whether live sync is active */
1071
+ isLiveSyncing: boolean;
1072
+ }
1073
+ /**
1074
+ * Function signature for EIP-712 typed data signing.
1075
+ * Compatible with wagmi's signTypedDataAsync.
1076
+ */
1077
+ type SignTypedDataFn = (args: {
1078
+ domain: {
1079
+ name: string;
1080
+ version: string;
1081
+ chainId: number;
1082
+ };
1083
+ types: Record<string, Array<{
1084
+ name: string;
1085
+ type: string;
1086
+ }>>;
1087
+ primaryType: string;
1088
+ message: Record<string, unknown>;
1089
+ }) => Promise<Hex>;
1090
+ interface UPPAccountProviderProps {
1091
+ children: ReactNode;
1092
+ /** Ethereum address of connected wallet */
1093
+ ethAddress?: string;
1094
+ /** Chain ID */
1095
+ chainId?: number;
1096
+ /** Indexer configuration */
1097
+ indexerConfig?: IndexerConfig;
1098
+ /** EIP-712 signing function (from wagmi's useSignTypedData().signTypedDataAsync) */
1099
+ signTypedData?: SignTypedDataFn;
1100
+ /** Public client for chain fingerprint validation (e.g. from wagmi usePublicClient) */
1101
+ publicClient?: any;
1102
+ /** Active proof system — filters unspentNotes and balance to only show spendable notes */
1103
+ activeProofSystem?: ProofSystemType;
1104
+ }
1105
+ declare function UPPAccountProvider({ children, ethAddress, chainId, indexerConfig, signTypedData, publicClient: publicClientProp, activeProofSystem, }: UPPAccountProviderProps): react_jsx_runtime.JSX.Element;
1106
+ /**
1107
+ * Hook to access UPP Account context
1108
+ */
1109
+ declare function useUPPAccount(): UPPAccountContextType;
1110
+
1111
+ /**
1112
+ * Transfer Module
1113
+ *
1114
+ * Core logic for building and executing UPP transfers.
1115
+ * This module is framework-agnostic (no React).
1116
+ */
1117
+
1118
+ /**
1119
+ * Transfer stage for progress tracking
1120
+ */
1121
+ type TransferStage = 'selecting_notes' | 'syncing_merkle' | 'creating_outputs' | 'generating_proof' | 'submitting_tx' | 'confirming';
1122
+ /**
1123
+ * A shielded note with all data needed for spending
1124
+ *
1125
+ * Post-quantum: uses ownerSecret/ownerHash instead of BabyJubJub one-time keys.
1126
+ * Ownership is proven via hash preimage: Poseidon(ownerSecret) == ownerHash.
1127
+ */
1128
+ interface SpendableNote {
1129
+ amount: bigint;
1130
+ blinding: bigint;
1131
+ commitment: string;
1132
+ /** Owner secret (hash preimage for ownership proof) */
1133
+ ownerSecret: string;
1134
+ /** Owner hash = Poseidon(ownerSecret) - committed in the note */
1135
+ ownerHash: string;
1136
+ leafIndex: number;
1137
+ /** Origin address (depositor) - required for UPP circuits */
1138
+ origin: bigint;
1139
+ /** Token address - required for UPP circuits */
1140
+ token: bigint;
1141
+ }
1142
+ /**
1143
+ * Merkle proof with associated note
1144
+ */
1145
+ interface MerkleProofWithNote {
1146
+ proof: MerkleProof;
1147
+ note: SpendableNote;
1148
+ }
1149
+ /**
1150
+ * Transfer context (dependencies)
1151
+ */
1152
+ interface TransferContext {
1153
+ /** viem PublicClient for RPC calls */
1154
+ publicClient: PublicClient;
1155
+ /** Contract address */
1156
+ contractAddress: Address;
1157
+ /** Chain ID */
1158
+ chainId: number;
1159
+ /** Circuit base URL (default: '/circuits/') */
1160
+ circuitBaseUrl?: string;
1161
+ /** ASP ID to use (default: DEMO_ASP_ID) */
1162
+ aspId?: bigint;
1163
+ /** All approved origins in the ASP tree (enables multi-origin proofs) */
1164
+ aspApprovedOrigins?: bigint[];
1165
+ }
1166
+ /**
1167
+ * Transfer result
1168
+ */
1169
+ interface TransferBuildResult {
1170
+ /** Circuit type used */
1171
+ circuit: UPPCircuitType;
1172
+ /** Formatted proof for contract */
1173
+ proof: {
1174
+ a: [bigint, bigint];
1175
+ b: [[bigint, bigint], [bigint, bigint]];
1176
+ c: [bigint, bigint];
1177
+ };
1178
+ /** Public signals from proof */
1179
+ publicSignals: string[];
1180
+ /** State tree root */
1181
+ stateRoot: bigint;
1182
+ /** ASP tree root */
1183
+ aspRoot: bigint;
1184
+ /** Nullifier hash */
1185
+ nullifier: bigint;
1186
+ /** Output commitment 1 */
1187
+ outputCommitment1: bigint;
1188
+ /** Output commitment 2 */
1189
+ outputCommitment2: bigint;
1190
+ /** Token address */
1191
+ token: bigint;
1192
+ /** Recipient output */
1193
+ recipientOutput: NoteCreationResult;
1194
+ /** Change output */
1195
+ changeOutput: NoteCreationResult;
1196
+ /** Notes that will be spent */
1197
+ spentNotes: SpendableNote[];
1198
+ }
1199
+ /**
1200
+ * Fetch all commitments from the contract and build a Merkle tree
1201
+ *
1202
+ * @param publicClient - viem PublicClient
1203
+ * @param contractAddress - Contract address
1204
+ * @returns Object with tree and leaves array
1205
+ */
1206
+ declare function syncMerkleTree(publicClient: PublicClient, contractAddress: Address): Promise<{
1207
+ tree: ReturnType<typeof buildMerkleTree>;
1208
+ leaves: bigint[];
1209
+ }>;
1210
+ /**
1211
+ * Get Merkle proofs for a set of notes
1212
+ *
1213
+ * @param notes - Notes to get proofs for
1214
+ * @param leaves - All leaves in the tree
1215
+ * @param tree - Merkle tree instance
1216
+ * @returns Array of proofs with associated notes
1217
+ */
1218
+ declare function getMerkleProofsForNotes(notes: SpendableNote[], leaves: bigint[], tree: ReturnType<typeof buildMerkleTree>): Promise<MerkleProofWithNote[]>;
1219
+ /**
1220
+ * Compute nullifier for a UPP note
1221
+ *
1222
+ * Post-quantum nullifier: Poseidon(ownerSecret, leafIndex, commitment)
1223
+ *
1224
+ * @param ownerSecret - Owner secret (hash preimage)
1225
+ * @param leafIndex - Leaf index in Merkle tree
1226
+ * @param commitment - Note commitment
1227
+ * @returns Nullifier as bigint
1228
+ */
1229
+ declare function computeNullifier(ownerSecret: bigint, leafIndex: number, commitment: bigint): Promise<bigint>;
1230
+ /**
1231
+ * Note with amount for circuit building
1232
+ */
1233
+ interface NoteWithAmount extends NoteCreationResult {
1234
+ amount: bigint;
1235
+ }
1236
+ /**
1237
+ * Build circuit inputs for UPP transfer (1-in-2-out)
1238
+ *
1239
+ * @param noteProof - Merkle proof for input note
1240
+ * @param aspProof - ASP membership proof for input note's origin
1241
+ * @param recipientNote - Output note for recipient
1242
+ * @param changeNote - Output note for change
1243
+ * @returns UPP transfer circuit inputs
1244
+ */
1245
+ declare function buildUPPTransferCircuitInputs(noteProof: MerkleProofWithNote, aspProof: ASPProof, recipientNote: NoteWithAmount, changeNote: NoteWithAmount): Promise<UPPTransferCircuitInputs>;
1246
+ /**
1247
+ * Build a UPP transfer (proof + outputs)
1248
+ *
1249
+ * This prepares everything needed to submit the transaction.
1250
+ * UPP transfer is 1-in-2-out with ASP membership proof.
1251
+ *
1252
+ * @param ctx - Transfer context
1253
+ * @param selectedNote - Note to spend (UPP transfer uses exactly 1 input)
1254
+ * @param recipientNote - Output note for recipient
1255
+ * @param changeNote - Output note for change
1256
+ * @param onStageChange - Optional callback for stage updates
1257
+ * @returns Transfer build result with proof and outputs
1258
+ */
1259
+ declare function buildTransfer(ctx: TransferContext, selectedNote: SpendableNote, recipientNote: NoteWithAmount, changeNote: NoteWithAmount, onStageChange?: (stage: TransferStage) => void): Promise<TransferBuildResult>;
1260
+ /**
1261
+ * Format output for contract call (post-quantum)
1262
+ */
1263
+ declare function formatOutputForContract(note: NoteCreationResult): {
1264
+ commitment: Hex;
1265
+ searchTag: bigint;
1266
+ ownerHash: bigint;
1267
+ encryptedNote: Hex;
1268
+ };
1269
+
1270
+ export { buildUPPTransferCircuitInputs as $, type ASPProof as A, type StealthCircuitType as B, type CircuitArtifacts as C, DEMO_ASP_ID as D, type EncryptedNote as E, type StealthMetaAddress as F, type SwapFillEvent as G, type SwapFillParams as H, type SwapOrder as I, type SwapOrderEvent as J, type SwapOrderParams as K, type TransferContext as L, type MergeParams as M, NOTE_VERSION as N, type TransferParams as O, type Proof as P, type TransferStage as Q, RATE_PRECISION as R, STARK_AMOUNT_SCALE as S, type TransferBuildResult as T, type UPPCircuitInputs as U, type UPPCircuitType as V, type UPPTransferCircuitInputs as W, type UPPWithdrawCircuitInputs as X, type WithdrawParams as Y, buildASPTree as Z, buildTransfer as _, type ASPRoot as a, computeCancelKeyHash as a0, computeFillPercentage as a1, computeGiveAmount as a2, computeMultiOriginASPRoot as a3, computeNullifier as a4, computeRate as a5, computeSingleOriginASPRoot as a6, computeTakeAmount as a7, computeTotalBuyAmount as a8, createDemoASPRoot as a9, useUPPAccount as aA, UPPAccountProvider as aB, type UPPAccountContextType as aC, type ProofSystemType as aD, type IndexerConfig as aE, type SignTypedDataFn as aF, ASP_TREE_DEPTH as aG, filterOrdersByASP as aa, filterOrdersByTokenPair as ab, formatOutputForContract as ac, formatProofForContract as ad, formatRate as ae, generateASPProof as af, generateCancelSecret as ag, generateMultiOriginASPProof as ah, generateProof as ai, generateSingleOriginASPProof as aj, generateStealthProof as ak, generateUPPProof as al, getCancelSecret as am, getMerkleProofsForNotes as an, getOwnOrderIds as ao, getStealthCircuitArtifacts as ap, getUPPCircuitArtifacts as aq, isFillerASPAccepted as ar, isOrderActive as as, removeCancelSecret as at, storeCancelSecret as au, syncMerkleTree as av, verifyASPProof as aw, verifyProof as ax, type NoteCreationResult as ay, type ShieldedNote 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 ProofResult as k, STATE_TREE_DEPTH as l, SWAP_EVENTS_ABI as m, SWAP_ORDER_CANCELLED_EVENT as n, SWAP_ORDER_CLAIMED_EVENT as o, SWAP_ORDER_FILLED_EVENT as p, SWAP_ORDER_PLACED_EVENT as q, type ShieldParams as r, type SpendableNote as s, type StarkNote as t, type StarkProof as u, type StarkStealthMetaAddress as v, type Stealth1x2CircuitInputs as w, type Stealth2x2CircuitInputs as x, type StealthAddress as y, type StealthCircuitInputs as z };