@arcanetech/stellar-privacy-pool-zk-sdk 0.9.1-rc.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 (43) hide show
  1. package/dist/ciphertext-blob.d.ts +17 -0
  2. package/dist/circuit-artifacts.d.ts +9 -0
  3. package/dist/circuit-urls-2x2-COiK1uEc.mjs +6 -0
  4. package/dist/circuit-urls-2x2-COiK1uEc.mjs.map +1 -0
  5. package/dist/circuit-urls-2x2-DVpZIkgS.js +12 -0
  6. package/dist/circuit-urls-2x2-DVpZIkgS.js.map +1 -0
  7. package/dist/circuit-urls-2x2.d.ts +3 -0
  8. package/dist/circuit-urls-6x6-CqdzNC4I.js +12 -0
  9. package/dist/circuit-urls-6x6-CqdzNC4I.js.map +1 -0
  10. package/dist/circuit-urls-6x6-Dtp8u02o.mjs +6 -0
  11. package/dist/circuit-urls-6x6-Dtp8u02o.mjs.map +1 -0
  12. package/dist/circuit-urls-6x6.d.ts +3 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.js +3114 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/derived-escrow-key.d.ts +10 -0
  17. package/dist/domain-separators.d.ts +16 -0
  18. package/dist/ephemeral-key.d.ts +28 -0
  19. package/dist/index.d.ts +30 -0
  20. package/dist/index.mjs +3875 -0
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/kyt-flow.d.ts +60 -0
  23. package/dist/kyt-onboarding.d.ts +36 -0
  24. package/dist/kyt-passage.d.ts +83 -0
  25. package/dist/output-note-encryption.d.ts +72 -0
  26. package/dist/prover.d.ts +5 -0
  27. package/dist/sdk.d.ts +130 -0
  28. package/dist/shared-secret.d.ts +24 -0
  29. package/dist/stealth-address.d.ts +23 -0
  30. package/dist/stealth-sign-message.d.ts +20 -0
  31. package/dist/stealth-signature.d.ts +29 -0
  32. package/dist/transaction-audit.d.ts +26 -0
  33. package/dist/types.d.ts +64 -0
  34. package/dist/wasm.d.ts +1 -0
  35. package/dist/withdrawal-transaction-input.d.ts +162 -0
  36. package/dist/witness.d.ts +3 -0
  37. package/dist/zk-artifact-url.d.ts +4 -0
  38. package/dist/zk-layout.d.ts +84 -0
  39. package/package.json +57 -0
  40. package/pkg/client_sdk_wasm.d.ts +120 -0
  41. package/pkg/client_sdk_wasm.js +765 -0
  42. package/pkg/client_sdk_wasm_bg.wasm +0 -0
  43. package/pkg/client_sdk_wasm_bg.wasm.d.ts +21 -0
@@ -0,0 +1,765 @@
1
+ /* @ts-self-types="./client_sdk_wasm.d.ts" */
2
+
3
+ /**
4
+ * Merkle root, path, and coin field strings for the first withdraw leg (JSON → JSON).
5
+ * @param {string} coin_json
6
+ * @param {string} state_json
7
+ * @returns {string}
8
+ */
9
+ export function buildWithdrawMerkleWitness(coin_json, state_json) {
10
+ let deferred4_0;
11
+ let deferred4_1;
12
+ try {
13
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
14
+ const ptr0 = passStringToWasm0(coin_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
15
+ const len0 = WASM_VECTOR_LEN;
16
+ const ptr1 = passStringToWasm0(state_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
17
+ const len1 = WASM_VECTOR_LEN;
18
+ wasm.buildWithdrawMerkleWitness(retptr, ptr0, len0, ptr1, len1);
19
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
20
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
21
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
22
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
23
+ var ptr3 = r0;
24
+ var len3 = r1;
25
+ if (r3) {
26
+ ptr3 = 0; len3 = 0;
27
+ throw takeObject(r2);
28
+ }
29
+ deferred4_0 = ptr3;
30
+ deferred4_1 = len3;
31
+ return getStringFromWasm0(ptr3, len3);
32
+ } finally {
33
+ wasm.__wbindgen_add_to_stack_pointer(16);
34
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Calculate owner-bound nullifier hash from nullifier and spend-scalar decimal strings.
40
+ * Returns hex string (0x...)
41
+ * @param {string} nullifier_decimal
42
+ * @param {string} priv_key_scalar_decimal
43
+ * @returns {string}
44
+ */
45
+ export function calculateNullifierHash(nullifier_decimal, priv_key_scalar_decimal) {
46
+ let deferred4_0;
47
+ let deferred4_1;
48
+ try {
49
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
50
+ const ptr0 = passStringToWasm0(nullifier_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
51
+ const len0 = WASM_VECTOR_LEN;
52
+ const ptr1 = passStringToWasm0(priv_key_scalar_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
53
+ const len1 = WASM_VECTOR_LEN;
54
+ wasm.calculateNullifierHash(retptr, ptr0, len0, ptr1, len1);
55
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
56
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
57
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
58
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
59
+ var ptr3 = r0;
60
+ var len3 = r1;
61
+ if (r3) {
62
+ ptr3 = 0; len3 = 0;
63
+ throw takeObject(r2);
64
+ }
65
+ deferred4_0 = ptr3;
66
+ deferred4_1 = len3;
67
+ return getStringFromWasm0(ptr3, len3);
68
+ } finally {
69
+ wasm.__wbindgen_add_to_stack_pointer(16);
70
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
71
+ }
72
+ }
73
+
74
+ /**
75
+ * `R = Poseidon255(2)(hi, lo)`; `scalar` is the raw Poseidon hash when it is
76
+ * already in `(0, BabyJub subgroup order)`. Out-of-range hashes fail so the
77
+ * caller can rejection-sample a new nonce.
78
+ * @param {string} nonce_decimal
79
+ * @param {string} recipient_hi_decimal
80
+ * @param {string} recipient_lo_decimal
81
+ * @returns {any}
82
+ */
83
+ export function derivedEscrowKey(nonce_decimal, recipient_hi_decimal, recipient_lo_decimal) {
84
+ try {
85
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
86
+ const ptr0 = passStringToWasm0(nonce_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
87
+ const len0 = WASM_VECTOR_LEN;
88
+ const ptr1 = passStringToWasm0(recipient_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
89
+ const len1 = WASM_VECTOR_LEN;
90
+ const ptr2 = passStringToWasm0(recipient_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
91
+ const len2 = WASM_VECTOR_LEN;
92
+ wasm.derivedEscrowKey(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
93
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
94
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
95
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
96
+ if (r2) {
97
+ throw takeObject(r1);
98
+ }
99
+ return takeObject(r0);
100
+ } finally {
101
+ wasm.__wbindgen_add_to_stack_pointer(16);
102
+ }
103
+ }
104
+
105
+ /**
106
+ * UTF-8 seed → `SHA256` → scalar → BabyJubJub `BASE8 * r` (circom `ECDHEphemeralKey`).
107
+ * `x` and `y` are lowercase hex (no `0x`). Bech32 / stealth string: TypeScript `encodeStealthAddress`.
108
+ * @param {string} seed
109
+ * @returns {any}
110
+ */
111
+ export function ecdhEphemeralPublicKey(seed) {
112
+ try {
113
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
114
+ const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_export, wasm.__wbindgen_export2);
115
+ const len0 = WASM_VECTOR_LEN;
116
+ wasm.ecdhEphemeralPublicKey(retptr, ptr0, len0);
117
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
118
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
119
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
120
+ if (r2) {
121
+ throw takeObject(r1);
122
+ }
123
+ return takeObject(r0);
124
+ } finally {
125
+ wasm.__wbindgen_add_to_stack_pointer(16);
126
+ }
127
+ }
128
+
129
+ /**
130
+ * 32-byte scalar as 64 hex chars (optional `0x`) → `ecdh_ephemeral_public_key` (no UTF-8 seed hash).
131
+ * @param {string} scalar_hex
132
+ * @returns {any}
133
+ */
134
+ export function ecdhEphemeralPublicKeyFromScalarHex(scalar_hex) {
135
+ try {
136
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
137
+ const ptr0 = passStringToWasm0(scalar_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
138
+ const len0 = WASM_VECTOR_LEN;
139
+ wasm.ecdhEphemeralPublicKeyFromScalarHex(retptr, ptr0, len0);
140
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
141
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
142
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
143
+ if (r2) {
144
+ throw takeObject(r1);
145
+ }
146
+ return takeObject(r0);
147
+ } finally {
148
+ wasm.__wbindgen_add_to_stack_pointer(16);
149
+ }
150
+ }
151
+
152
+ /**
153
+ * Circuit `ECDH`: `priv * (pub_x, pub_y)` → shared key (`key[0], key[1]` hex).
154
+ * @param {string} priv_hex
155
+ * @param {string} pub_x_hex
156
+ * @param {string} pub_y_hex
157
+ * @returns {any}
158
+ */
159
+ export function ecdhSharedKey(priv_hex, pub_x_hex, pub_y_hex) {
160
+ try {
161
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
162
+ const ptr0 = passStringToWasm0(priv_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
163
+ const len0 = WASM_VECTOR_LEN;
164
+ const ptr1 = passStringToWasm0(pub_x_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
165
+ const len1 = WASM_VECTOR_LEN;
166
+ const ptr2 = passStringToWasm0(pub_y_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
167
+ const len2 = WASM_VECTOR_LEN;
168
+ wasm.ecdhSharedKey(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
169
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
170
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
171
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
172
+ if (r2) {
173
+ throw takeObject(r1);
174
+ }
175
+ return takeObject(r0);
176
+ } finally {
177
+ wasm.__wbindgen_add_to_stack_pointer(16);
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Generate a new coin with random nullifier, secret, and owner public-key field elements.
183
+ * `amount_decimal` is an arbitrary-precision decimal field element (never JS `number`).
184
+ * `asset_hi_decimal` / `asset_lo_decimal` are decimal Fr strings for the Stellar asset contract id (two limbs).
185
+ * Returns JSON: { coin: { value, nullifier, secret, commitment, asset_hi, asset_lo }, commitment_hex, precommitement_hex }
186
+ * @param {string} amount_decimal
187
+ * @param {string} asset_hi_decimal
188
+ * @param {string} asset_lo_decimal
189
+ * @param {string} application_id_decimal
190
+ * @returns {any}
191
+ */
192
+ export function generateCoin(amount_decimal, asset_hi_decimal, asset_lo_decimal, application_id_decimal) {
193
+ try {
194
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
195
+ const ptr0 = passStringToWasm0(amount_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
196
+ const len0 = WASM_VECTOR_LEN;
197
+ const ptr1 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
198
+ const len1 = WASM_VECTOR_LEN;
199
+ const ptr2 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
200
+ const len2 = WASM_VECTOR_LEN;
201
+ const ptr3 = passStringToWasm0(application_id_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
202
+ const len3 = WASM_VECTOR_LEN;
203
+ wasm.generateCoin(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
204
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
205
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
206
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
207
+ if (r2) {
208
+ throw takeObject(r1);
209
+ }
210
+ return takeObject(r0);
211
+ } finally {
212
+ wasm.__wbindgen_add_to_stack_pointer(16);
213
+ }
214
+ }
215
+
216
+ /**
217
+ * `Poseidon₁(scalar)` secret + recipient owner public key (hex), matching an aligned deposit witness.
218
+ * @param {string} scalar_hex
219
+ * @param {string} owner_x_hex
220
+ * @param {string} owner_y_hex
221
+ * @param {string} amount_decimal
222
+ * @param {string} asset_hi_decimal
223
+ * @param {string} asset_lo_decimal
224
+ * @param {string} application_id_decimal
225
+ * @returns {any}
226
+ */
227
+ export function generateCoinForDepositWithOwnerPubHex(scalar_hex, owner_x_hex, owner_y_hex, amount_decimal, asset_hi_decimal, asset_lo_decimal, application_id_decimal) {
228
+ try {
229
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
230
+ const ptr0 = passStringToWasm0(scalar_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
231
+ const len0 = WASM_VECTOR_LEN;
232
+ const ptr1 = passStringToWasm0(owner_x_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
233
+ const len1 = WASM_VECTOR_LEN;
234
+ const ptr2 = passStringToWasm0(owner_y_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
235
+ const len2 = WASM_VECTOR_LEN;
236
+ const ptr3 = passStringToWasm0(amount_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
237
+ const len3 = WASM_VECTOR_LEN;
238
+ const ptr4 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
239
+ const len4 = WASM_VECTOR_LEN;
240
+ const ptr5 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
241
+ const len5 = WASM_VECTOR_LEN;
242
+ const ptr6 = passStringToWasm0(application_id_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
243
+ const len6 = WASM_VECTOR_LEN;
244
+ wasm.generateCoinForDepositWithOwnerPubHex(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
245
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
246
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
247
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
248
+ if (r2) {
249
+ throw takeObject(r1);
250
+ }
251
+ return takeObject(r0);
252
+ } finally {
253
+ wasm.__wbindgen_add_to_stack_pointer(16);
254
+ }
255
+ }
256
+
257
+ /**
258
+ * `secret` in coin = `Poseidon255(1)(scalar)` per `deposit.circom`; scalar is 32-byte hex (64 chars, optional `0x`).
259
+ * @param {string} scalar_hex
260
+ * @param {string} amount_decimal
261
+ * @param {string} asset_hi_decimal
262
+ * @param {string} asset_lo_decimal
263
+ * @param {string} application_id_decimal
264
+ * @returns {any}
265
+ */
266
+ export function generateCoinFromDepositEphemeralScalarHex(scalar_hex, amount_decimal, asset_hi_decimal, asset_lo_decimal, application_id_decimal) {
267
+ try {
268
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
269
+ const ptr0 = passStringToWasm0(scalar_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
270
+ const len0 = WASM_VECTOR_LEN;
271
+ const ptr1 = passStringToWasm0(amount_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
272
+ const len1 = WASM_VECTOR_LEN;
273
+ const ptr2 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
274
+ const len2 = WASM_VECTOR_LEN;
275
+ const ptr3 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
276
+ const len3 = WASM_VECTOR_LEN;
277
+ const ptr4 = passStringToWasm0(application_id_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
278
+ const len4 = WASM_VECTOR_LEN;
279
+ wasm.generateCoinFromDepositEphemeralScalarHex(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
280
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
281
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
282
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
283
+ if (r2) {
284
+ throw takeObject(r1);
285
+ }
286
+ return takeObject(r0);
287
+ } finally {
288
+ wasm.__wbindgen_add_to_stack_pointer(16);
289
+ }
290
+ }
291
+
292
+ /**
293
+ * Same as `generateCoin`, but commitment uses the given owner public key (64-char hex coords).
294
+ * @param {string} owner_x_hex
295
+ * @param {string} owner_y_hex
296
+ * @param {string} amount_decimal
297
+ * @param {string} asset_hi_decimal
298
+ * @param {string} asset_lo_decimal
299
+ * @param {string} application_id_decimal
300
+ * @returns {any}
301
+ */
302
+ export function generateCoinWithOwnerPubHex(owner_x_hex, owner_y_hex, amount_decimal, asset_hi_decimal, asset_lo_decimal, application_id_decimal) {
303
+ try {
304
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
305
+ const ptr0 = passStringToWasm0(owner_x_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
306
+ const len0 = WASM_VECTOR_LEN;
307
+ const ptr1 = passStringToWasm0(owner_y_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
308
+ const len1 = WASM_VECTOR_LEN;
309
+ const ptr2 = passStringToWasm0(amount_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
310
+ const len2 = WASM_VECTOR_LEN;
311
+ const ptr3 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
312
+ const len3 = WASM_VECTOR_LEN;
313
+ const ptr4 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
314
+ const len4 = WASM_VECTOR_LEN;
315
+ const ptr5 = passStringToWasm0(application_id_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
316
+ const len5 = WASM_VECTOR_LEN;
317
+ wasm.generateCoinWithOwnerPubHex(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
318
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
319
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
320
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
321
+ if (r2) {
322
+ throw takeObject(r1);
323
+ }
324
+ return takeObject(r0);
325
+ } finally {
326
+ wasm.__wbindgen_add_to_stack_pointer(16);
327
+ }
328
+ }
329
+
330
+ /**
331
+ * Convert snarkjs proof JSON to hex bytes for Soroban contract.
332
+ * @param {string} proof_json
333
+ * @returns {string}
334
+ */
335
+ export function proofToHex(proof_json) {
336
+ let deferred2_0;
337
+ let deferred2_1;
338
+ try {
339
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
340
+ const ptr0 = passStringToWasm0(proof_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
341
+ const len0 = WASM_VECTOR_LEN;
342
+ wasm.proofToHex(retptr, ptr0, len0);
343
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
344
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
345
+ deferred2_0 = r0;
346
+ deferred2_1 = r1;
347
+ return getStringFromWasm0(r0, r1);
348
+ } finally {
349
+ wasm.__wbindgen_add_to_stack_pointer(16);
350
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
351
+ }
352
+ }
353
+
354
+ /**
355
+ * Graph witness + arkworks Groth16 prove. Returns `{ proof_hex, public_hex }`.
356
+ * @param {Uint8Array} graph
357
+ * @param {Uint8Array} proving_key
358
+ * @param {Uint8Array} r1cs
359
+ * @param {string} inputs_json
360
+ * @returns {any}
361
+ */
362
+ export function proveGroth16(graph, proving_key, r1cs, inputs_json) {
363
+ try {
364
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
365
+ const ptr0 = passArray8ToWasm0(graph, wasm.__wbindgen_export);
366
+ const len0 = WASM_VECTOR_LEN;
367
+ const ptr1 = passArray8ToWasm0(proving_key, wasm.__wbindgen_export);
368
+ const len1 = WASM_VECTOR_LEN;
369
+ const ptr2 = passArray8ToWasm0(r1cs, wasm.__wbindgen_export);
370
+ const len2 = WASM_VECTOR_LEN;
371
+ const ptr3 = passStringToWasm0(inputs_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
372
+ const len3 = WASM_VECTOR_LEN;
373
+ wasm.proveGroth16(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
374
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
375
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
376
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
377
+ if (r2) {
378
+ throw takeObject(r1);
379
+ }
380
+ return takeObject(r0);
381
+ } finally {
382
+ wasm.__wbindgen_add_to_stack_pointer(16);
383
+ }
384
+ }
385
+
386
+ /**
387
+ * Convert snarkjs public signals JSON to hex bytes for Soroban contract.
388
+ * @param {string} public_json
389
+ * @returns {string}
390
+ */
391
+ export function publicToHex(public_json) {
392
+ let deferred2_0;
393
+ let deferred2_1;
394
+ try {
395
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
396
+ const ptr0 = passStringToWasm0(public_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
397
+ const len0 = WASM_VECTOR_LEN;
398
+ wasm.publicToHex(retptr, ptr0, len0);
399
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
400
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
401
+ deferred2_0 = r0;
402
+ deferred2_1 = r1;
403
+ return getStringFromWasm0(r0, r1);
404
+ } finally {
405
+ wasm.__wbindgen_add_to_stack_pointer(16);
406
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
407
+ }
408
+ }
409
+
410
+ function __wbg_get_imports() {
411
+ const import0 = {
412
+ __proto__: null,
413
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
414
+ const ret = String(getObject(arg1));
415
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
416
+ const len1 = WASM_VECTOR_LEN;
417
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
418
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
419
+ },
420
+ __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
421
+ const ret = typeof(getObject(arg0)) === 'function';
422
+ return ret;
423
+ },
424
+ __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
425
+ const val = getObject(arg0);
426
+ const ret = typeof(val) === 'object' && val !== null;
427
+ return ret;
428
+ },
429
+ __wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
430
+ const ret = typeof(getObject(arg0)) === 'string';
431
+ return ret;
432
+ },
433
+ __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
434
+ const ret = getObject(arg0) === undefined;
435
+ return ret;
436
+ },
437
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
438
+ throw new Error(getStringFromWasm0(arg0, arg1));
439
+ },
440
+ __wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
441
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
442
+ return addHeapObject(ret);
443
+ }, arguments); },
444
+ __wbg_crypto_38df2bab126b63dc: function(arg0) {
445
+ const ret = getObject(arg0).crypto;
446
+ return addHeapObject(ret);
447
+ },
448
+ __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
449
+ getObject(arg0).getRandomValues(getObject(arg1));
450
+ }, arguments); },
451
+ __wbg_length_ea16607d7b61445b: function(arg0) {
452
+ const ret = getObject(arg0).length;
453
+ return ret;
454
+ },
455
+ __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
456
+ const ret = getObject(arg0).msCrypto;
457
+ return addHeapObject(ret);
458
+ },
459
+ __wbg_new_ab79df5bd7c26067: function() {
460
+ const ret = new Object();
461
+ return addHeapObject(ret);
462
+ },
463
+ __wbg_new_with_length_825018a1616e9e55: function(arg0) {
464
+ const ret = new Uint8Array(arg0 >>> 0);
465
+ return addHeapObject(ret);
466
+ },
467
+ __wbg_node_84ea875411254db1: function(arg0) {
468
+ const ret = getObject(arg0).node;
469
+ return addHeapObject(ret);
470
+ },
471
+ __wbg_process_44c7a14e11e9f69e: function(arg0) {
472
+ const ret = getObject(arg0).process;
473
+ return addHeapObject(ret);
474
+ },
475
+ __wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
476
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
477
+ },
478
+ __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
479
+ getObject(arg0).randomFillSync(takeObject(arg1));
480
+ }, arguments); },
481
+ __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
482
+ const ret = module.require;
483
+ return addHeapObject(ret);
484
+ }, arguments); },
485
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
486
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
487
+ },
488
+ __wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
489
+ const ret = typeof global === 'undefined' ? null : global;
490
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
491
+ },
492
+ __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
493
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
494
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
495
+ },
496
+ __wbg_static_accessor_SELF_f207c857566db248: function() {
497
+ const ret = typeof self === 'undefined' ? null : self;
498
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
499
+ },
500
+ __wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
501
+ const ret = typeof window === 'undefined' ? null : window;
502
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
503
+ },
504
+ __wbg_subarray_a068d24e39478a8a: function(arg0, arg1, arg2) {
505
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
506
+ return addHeapObject(ret);
507
+ },
508
+ __wbg_versions_276b2795b1c6a219: function(arg0) {
509
+ const ret = getObject(arg0).versions;
510
+ return addHeapObject(ret);
511
+ },
512
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
513
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
514
+ const ret = getArrayU8FromWasm0(arg0, arg1);
515
+ return addHeapObject(ret);
516
+ },
517
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
518
+ // Cast intrinsic for `Ref(String) -> Externref`.
519
+ const ret = getStringFromWasm0(arg0, arg1);
520
+ return addHeapObject(ret);
521
+ },
522
+ __wbindgen_object_clone_ref: function(arg0) {
523
+ const ret = getObject(arg0);
524
+ return addHeapObject(ret);
525
+ },
526
+ __wbindgen_object_drop_ref: function(arg0) {
527
+ takeObject(arg0);
528
+ },
529
+ };
530
+ return {
531
+ __proto__: null,
532
+ "./client_sdk_wasm_bg.js": import0,
533
+ };
534
+ }
535
+
536
+ function addHeapObject(obj) {
537
+ if (heap_next === heap.length) heap.push(heap.length + 1);
538
+ const idx = heap_next;
539
+ heap_next = heap[idx];
540
+
541
+ heap[idx] = obj;
542
+ return idx;
543
+ }
544
+
545
+ function dropObject(idx) {
546
+ if (idx < 1028) return;
547
+ heap[idx] = heap_next;
548
+ heap_next = idx;
549
+ }
550
+
551
+ function getArrayU8FromWasm0(ptr, len) {
552
+ ptr = ptr >>> 0;
553
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
554
+ }
555
+
556
+ let cachedDataViewMemory0 = null;
557
+ function getDataViewMemory0() {
558
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
559
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
560
+ }
561
+ return cachedDataViewMemory0;
562
+ }
563
+
564
+ function getStringFromWasm0(ptr, len) {
565
+ ptr = ptr >>> 0;
566
+ return decodeText(ptr, len);
567
+ }
568
+
569
+ let cachedUint8ArrayMemory0 = null;
570
+ function getUint8ArrayMemory0() {
571
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
572
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
573
+ }
574
+ return cachedUint8ArrayMemory0;
575
+ }
576
+
577
+ function getObject(idx) { return heap[idx]; }
578
+
579
+ function handleError(f, args) {
580
+ try {
581
+ return f.apply(this, args);
582
+ } catch (e) {
583
+ wasm.__wbindgen_export3(addHeapObject(e));
584
+ }
585
+ }
586
+
587
+ let heap = new Array(1024).fill(undefined);
588
+ heap.push(undefined, null, true, false);
589
+
590
+ let heap_next = heap.length;
591
+
592
+ function isLikeNone(x) {
593
+ return x === undefined || x === null;
594
+ }
595
+
596
+ function passArray8ToWasm0(arg, malloc) {
597
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
598
+ getUint8ArrayMemory0().set(arg, ptr / 1);
599
+ WASM_VECTOR_LEN = arg.length;
600
+ return ptr;
601
+ }
602
+
603
+ function passStringToWasm0(arg, malloc, realloc) {
604
+ if (realloc === undefined) {
605
+ const buf = cachedTextEncoder.encode(arg);
606
+ const ptr = malloc(buf.length, 1) >>> 0;
607
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
608
+ WASM_VECTOR_LEN = buf.length;
609
+ return ptr;
610
+ }
611
+
612
+ let len = arg.length;
613
+ let ptr = malloc(len, 1) >>> 0;
614
+
615
+ const mem = getUint8ArrayMemory0();
616
+
617
+ let offset = 0;
618
+
619
+ for (; offset < len; offset++) {
620
+ const code = arg.charCodeAt(offset);
621
+ if (code > 0x7F) break;
622
+ mem[ptr + offset] = code;
623
+ }
624
+ if (offset !== len) {
625
+ if (offset !== 0) {
626
+ arg = arg.slice(offset);
627
+ }
628
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
629
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
630
+ const ret = cachedTextEncoder.encodeInto(arg, view);
631
+
632
+ offset += ret.written;
633
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
634
+ }
635
+
636
+ WASM_VECTOR_LEN = offset;
637
+ return ptr;
638
+ }
639
+
640
+ function takeObject(idx) {
641
+ const ret = getObject(idx);
642
+ dropObject(idx);
643
+ return ret;
644
+ }
645
+
646
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
647
+ cachedTextDecoder.decode();
648
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
649
+ let numBytesDecoded = 0;
650
+ function decodeText(ptr, len) {
651
+ numBytesDecoded += len;
652
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
653
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
654
+ cachedTextDecoder.decode();
655
+ numBytesDecoded = len;
656
+ }
657
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
658
+ }
659
+
660
+ const cachedTextEncoder = new TextEncoder();
661
+
662
+ if (!('encodeInto' in cachedTextEncoder)) {
663
+ cachedTextEncoder.encodeInto = function (arg, view) {
664
+ const buf = cachedTextEncoder.encode(arg);
665
+ view.set(buf);
666
+ return {
667
+ read: arg.length,
668
+ written: buf.length
669
+ };
670
+ };
671
+ }
672
+
673
+ let WASM_VECTOR_LEN = 0;
674
+
675
+ let wasmModule, wasm;
676
+ function __wbg_finalize_init(instance, module) {
677
+ wasm = instance.exports;
678
+ wasmModule = module;
679
+ cachedDataViewMemory0 = null;
680
+ cachedUint8ArrayMemory0 = null;
681
+ return wasm;
682
+ }
683
+
684
+ async function __wbg_load(module, imports) {
685
+ if (typeof Response === 'function' && module instanceof Response) {
686
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
687
+ try {
688
+ return await WebAssembly.instantiateStreaming(module, imports);
689
+ } catch (e) {
690
+ const validResponse = module.ok && expectedResponseType(module.type);
691
+
692
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
693
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
694
+
695
+ } else { throw e; }
696
+ }
697
+ }
698
+
699
+ const bytes = await module.arrayBuffer();
700
+ return await WebAssembly.instantiate(bytes, imports);
701
+ } else {
702
+ const instance = await WebAssembly.instantiate(module, imports);
703
+
704
+ if (instance instanceof WebAssembly.Instance) {
705
+ return { instance, module };
706
+ } else {
707
+ return instance;
708
+ }
709
+ }
710
+
711
+ function expectedResponseType(type) {
712
+ switch (type) {
713
+ case 'basic': case 'cors': case 'default': return true;
714
+ }
715
+ return false;
716
+ }
717
+ }
718
+
719
+ function initSync(module) {
720
+ if (wasm !== undefined) return wasm;
721
+
722
+
723
+ if (module !== undefined) {
724
+ if (Object.getPrototypeOf(module) === Object.prototype) {
725
+ ({module} = module)
726
+ } else {
727
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
728
+ }
729
+ }
730
+
731
+ const imports = __wbg_get_imports();
732
+ if (!(module instanceof WebAssembly.Module)) {
733
+ module = new WebAssembly.Module(module);
734
+ }
735
+ const instance = new WebAssembly.Instance(module, imports);
736
+ return __wbg_finalize_init(instance, module);
737
+ }
738
+
739
+ async function __wbg_init(module_or_path) {
740
+ if (wasm !== undefined) return wasm;
741
+
742
+
743
+ if (module_or_path !== undefined) {
744
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
745
+ ({module_or_path} = module_or_path)
746
+ } else {
747
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
748
+ }
749
+ }
750
+
751
+ if (module_or_path === undefined) {
752
+ module_or_path = new URL('client_sdk_wasm_bg.wasm', import.meta.url);
753
+ }
754
+ const imports = __wbg_get_imports();
755
+
756
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
757
+ module_or_path = fetch(module_or_path);
758
+ }
759
+
760
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
761
+
762
+ return __wbg_finalize_init(instance, module);
763
+ }
764
+
765
+ export { initSync, __wbg_init as default };