@izi-noir/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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +458 -0
  3. package/dist/IProvingSystem-D9TnEig0.d.ts +140 -0
  4. package/dist/IProvingSystem-TKNofoo8.d.cts +140 -0
  5. package/dist/index.cjs +2793 -0
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/index.d.cts +1196 -0
  8. package/dist/index.d.ts +1196 -0
  9. package/dist/index.js +2730 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/providers/arkworks.cjs +824 -0
  12. package/dist/providers/arkworks.cjs.map +1 -0
  13. package/dist/providers/arkworks.d.cts +121 -0
  14. package/dist/providers/arkworks.d.ts +121 -0
  15. package/dist/providers/arkworks.js +791 -0
  16. package/dist/providers/arkworks.js.map +1 -0
  17. package/dist/providers/barretenberg.cjs +822 -0
  18. package/dist/providers/barretenberg.cjs.map +1 -0
  19. package/dist/providers/barretenberg.d.cts +18 -0
  20. package/dist/providers/barretenberg.d.ts +18 -0
  21. package/dist/providers/barretenberg.js +790 -0
  22. package/dist/providers/barretenberg.js.map +1 -0
  23. package/dist/providers/solana.cjs +262 -0
  24. package/dist/providers/solana.cjs.map +1 -0
  25. package/dist/providers/solana.d.cts +223 -0
  26. package/dist/providers/solana.d.ts +223 -0
  27. package/dist/providers/solana.js +222 -0
  28. package/dist/providers/solana.js.map +1 -0
  29. package/dist/providers/sunspot.cjs +475 -0
  30. package/dist/providers/sunspot.cjs.map +1 -0
  31. package/dist/providers/sunspot.d.cts +210 -0
  32. package/dist/providers/sunspot.d.ts +210 -0
  33. package/dist/providers/sunspot.js +443 -0
  34. package/dist/providers/sunspot.js.map +1 -0
  35. package/dist/types-CaaigonG.d.cts +93 -0
  36. package/dist/types-CaaigonG.d.ts +93 -0
  37. package/dist/wasm/nodejs/arkworks_groth16_wasm.js +448 -0
  38. package/dist/wasm/nodejs/arkworks_groth16_wasm_bg.wasm +0 -0
  39. package/dist/wasm/web/arkworks_groth16_wasm.js +536 -0
  40. package/dist/wasm/web/arkworks_groth16_wasm_bg.wasm +0 -0
  41. package/dist/wasmInit-KV6DTj4J.d.ts +282 -0
  42. package/dist/wasmInit-iEYiiB8M.d.cts +282 -0
  43. package/package.json +87 -0
@@ -0,0 +1,536 @@
1
+ /* @ts-self-types="./arkworks_groth16_wasm.d.ts" */
2
+
3
+ /**
4
+ * Convert ACIR JSON to R1CS information (for debugging)
5
+ * @param {string} acir_json
6
+ * @returns {any}
7
+ */
8
+ export function acir_to_r1cs_info(acir_json) {
9
+ const ptr0 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
10
+ const len0 = WASM_VECTOR_LEN;
11
+ const ret = wasm.acir_to_r1cs_info(ptr0, len0);
12
+ if (ret[2]) {
13
+ throw takeFromExternrefTable0(ret[1]);
14
+ }
15
+ return takeFromExternrefTable0(ret[0]);
16
+ }
17
+
18
+ export function init_panic_hook() {
19
+ wasm.init_panic_hook();
20
+ }
21
+
22
+ /**
23
+ * Generate a Groth16 proof
24
+ *
25
+ * # Arguments
26
+ * * `proving_key_b64` - Base64-encoded proving key from setup
27
+ * * `acir_json` - JSON string of the ACIR program
28
+ * * `witness_json` - JSON object mapping witness indices to hex values
29
+ *
30
+ * # Returns
31
+ * * `JsProofResult` with proof and public inputs
32
+ * @param {string} proving_key_b64
33
+ * @param {string} acir_json
34
+ * @param {string} witness_json
35
+ * @returns {any}
36
+ */
37
+ export function prove(proving_key_b64, acir_json, witness_json) {
38
+ const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
39
+ const len0 = WASM_VECTOR_LEN;
40
+ const ptr1 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
+ const len1 = WASM_VECTOR_LEN;
42
+ const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
43
+ const len2 = WASM_VECTOR_LEN;
44
+ const ret = wasm.prove(ptr0, len0, ptr1, len1, ptr2, len2);
45
+ if (ret[2]) {
46
+ throw takeFromExternrefTable0(ret[1]);
47
+ }
48
+ return takeFromExternrefTable0(ret[0]);
49
+ }
50
+
51
+ /**
52
+ * Perform trusted setup for a circuit
53
+ *
54
+ * # Arguments
55
+ * * `acir_json` - JSON string of the ACIR program from Noir compiler
56
+ *
57
+ * # Returns
58
+ * * `JsSetupResult` with base64-encoded proving and verifying keys
59
+ * @param {string} acir_json
60
+ * @returns {any}
61
+ */
62
+ export function setup(acir_json) {
63
+ const ptr0 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
64
+ const len0 = WASM_VECTOR_LEN;
65
+ const ret = wasm.setup(ptr0, len0);
66
+ if (ret[2]) {
67
+ throw takeFromExternrefTable0(ret[1]);
68
+ }
69
+ return takeFromExternrefTable0(ret[0]);
70
+ }
71
+
72
+ /**
73
+ * Verify a Groth16 proof
74
+ *
75
+ * # Arguments
76
+ * * `verifying_key_b64` - Base64-encoded verifying key from setup
77
+ * * `proof_b64` - Base64-encoded proof (arkworks format)
78
+ * * `public_inputs_json` - JSON array of public inputs as hex strings
79
+ *
80
+ * # Returns
81
+ * * `true` if proof is valid, `false` otherwise
82
+ * @param {string} verifying_key_b64
83
+ * @param {string} proof_b64
84
+ * @param {string} public_inputs_json
85
+ * @returns {boolean}
86
+ */
87
+ export function verify(verifying_key_b64, proof_b64, public_inputs_json) {
88
+ const ptr0 = passStringToWasm0(verifying_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
89
+ const len0 = WASM_VECTOR_LEN;
90
+ const ptr1 = passStringToWasm0(proof_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
+ const len1 = WASM_VECTOR_LEN;
92
+ const ptr2 = passStringToWasm0(public_inputs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
93
+ const len2 = WASM_VECTOR_LEN;
94
+ const ret = wasm.verify(ptr0, len0, ptr1, len1, ptr2, len2);
95
+ if (ret[2]) {
96
+ throw takeFromExternrefTable0(ret[1]);
97
+ }
98
+ return ret[0] !== 0;
99
+ }
100
+
101
+ /**
102
+ * Verify a Groth16 proof in gnark format
103
+ *
104
+ * # Arguments
105
+ * * `verifying_key_gnark_b64` - Base64-encoded verifying key (gnark format)
106
+ * * `proof_gnark_b64` - Base64-encoded proof (gnark format, 256 bytes)
107
+ * * `public_inputs_gnark_b64` - Base64-encoded public inputs (gnark format)
108
+ * * `num_public_inputs` - Number of public inputs
109
+ *
110
+ * # Returns
111
+ * * `true` if proof is valid, `false` otherwise
112
+ * @param {string} verifying_key_gnark_b64
113
+ * @param {string} proof_gnark_b64
114
+ * @param {string} public_inputs_gnark_b64
115
+ * @param {number} num_public_inputs
116
+ * @returns {boolean}
117
+ */
118
+ export function verify_gnark(verifying_key_gnark_b64, proof_gnark_b64, public_inputs_gnark_b64, num_public_inputs) {
119
+ const ptr0 = passStringToWasm0(verifying_key_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
120
+ const len0 = WASM_VECTOR_LEN;
121
+ const ptr1 = passStringToWasm0(proof_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
122
+ const len1 = WASM_VECTOR_LEN;
123
+ const ptr2 = passStringToWasm0(public_inputs_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
124
+ const len2 = WASM_VECTOR_LEN;
125
+ const ret = wasm.verify_gnark(ptr0, len0, ptr1, len1, ptr2, len2, num_public_inputs);
126
+ if (ret[2]) {
127
+ throw takeFromExternrefTable0(ret[1]);
128
+ }
129
+ return ret[0] !== 0;
130
+ }
131
+
132
+ /**
133
+ * Get library version
134
+ * @returns {string}
135
+ */
136
+ export function version() {
137
+ let deferred1_0;
138
+ let deferred1_1;
139
+ try {
140
+ const ret = wasm.version();
141
+ deferred1_0 = ret[0];
142
+ deferred1_1 = ret[1];
143
+ return getStringFromWasm0(ret[0], ret[1]);
144
+ } finally {
145
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
146
+ }
147
+ }
148
+
149
+ function __wbg_get_imports() {
150
+ const import0 = {
151
+ __proto__: null,
152
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
153
+ const ret = Error(getStringFromWasm0(arg0, arg1));
154
+ return ret;
155
+ },
156
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
157
+ const ret = String(arg1);
158
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len1 = WASM_VECTOR_LEN;
160
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
161
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
162
+ },
163
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
164
+ const ret = typeof(arg0) === 'function';
165
+ return ret;
166
+ },
167
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
168
+ const val = arg0;
169
+ const ret = typeof(val) === 'object' && val !== null;
170
+ return ret;
171
+ },
172
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
173
+ const ret = typeof(arg0) === 'string';
174
+ return ret;
175
+ },
176
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
177
+ const ret = arg0 === undefined;
178
+ return ret;
179
+ },
180
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
181
+ throw new Error(getStringFromWasm0(arg0, arg1));
182
+ },
183
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
184
+ const ret = arg0.call(arg1);
185
+ return ret;
186
+ }, arguments); },
187
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
188
+ const ret = arg0.call(arg1, arg2);
189
+ return ret;
190
+ }, arguments); },
191
+ __wbg_crypto_86f2631e91b51511: function(arg0) {
192
+ const ret = arg0.crypto;
193
+ return ret;
194
+ },
195
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
196
+ let deferred0_0;
197
+ let deferred0_1;
198
+ try {
199
+ deferred0_0 = arg0;
200
+ deferred0_1 = arg1;
201
+ console.error(getStringFromWasm0(arg0, arg1));
202
+ } finally {
203
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
204
+ }
205
+ },
206
+ __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
207
+ arg0.getRandomValues(arg1);
208
+ }, arguments); },
209
+ __wbg_length_32ed9a279acd054c: function(arg0) {
210
+ const ret = arg0.length;
211
+ return ret;
212
+ },
213
+ __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
214
+ const ret = arg0.msCrypto;
215
+ return ret;
216
+ },
217
+ __wbg_new_361308b2356cecd0: function() {
218
+ const ret = new Object();
219
+ return ret;
220
+ },
221
+ __wbg_new_3eb36ae241fe6f44: function() {
222
+ const ret = new Array();
223
+ return ret;
224
+ },
225
+ __wbg_new_8a6f238a6ece86ea: function() {
226
+ const ret = new Error();
227
+ return ret;
228
+ },
229
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
230
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
231
+ return ret;
232
+ },
233
+ __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
234
+ const ret = new Uint8Array(arg0 >>> 0);
235
+ return ret;
236
+ },
237
+ __wbg_node_e1f24f89a7336c2e: function(arg0) {
238
+ const ret = arg0.node;
239
+ return ret;
240
+ },
241
+ __wbg_process_3975fd6c72f520aa: function(arg0) {
242
+ const ret = arg0.process;
243
+ return ret;
244
+ },
245
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
246
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
247
+ },
248
+ __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
249
+ arg0.randomFillSync(arg1);
250
+ }, arguments); },
251
+ __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
252
+ const ret = module.require;
253
+ return ret;
254
+ }, arguments); },
255
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
256
+ arg0[arg1] = arg2;
257
+ },
258
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
259
+ arg0[arg1 >>> 0] = arg2;
260
+ },
261
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
262
+ const ret = arg1.stack;
263
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
264
+ const len1 = WASM_VECTOR_LEN;
265
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
266
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
267
+ },
268
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
269
+ const ret = typeof global === 'undefined' ? null : global;
270
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
271
+ },
272
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
273
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
274
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
275
+ },
276
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
277
+ const ret = typeof self === 'undefined' ? null : self;
278
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
279
+ },
280
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
281
+ const ret = typeof window === 'undefined' ? null : window;
282
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
283
+ },
284
+ __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
285
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
286
+ return ret;
287
+ },
288
+ __wbg_versions_4e31226f5e8dc909: function(arg0) {
289
+ const ret = arg0.versions;
290
+ return ret;
291
+ },
292
+ __wbindgen_cast_0000000000000001: function(arg0) {
293
+ // Cast intrinsic for `F64 -> Externref`.
294
+ const ret = arg0;
295
+ return ret;
296
+ },
297
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
298
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
299
+ const ret = getArrayU8FromWasm0(arg0, arg1);
300
+ return ret;
301
+ },
302
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
303
+ // Cast intrinsic for `Ref(String) -> Externref`.
304
+ const ret = getStringFromWasm0(arg0, arg1);
305
+ return ret;
306
+ },
307
+ __wbindgen_cast_0000000000000004: function(arg0) {
308
+ // Cast intrinsic for `U64 -> Externref`.
309
+ const ret = BigInt.asUintN(64, arg0);
310
+ return ret;
311
+ },
312
+ __wbindgen_init_externref_table: function() {
313
+ const table = wasm.__wbindgen_externrefs;
314
+ const offset = table.grow(4);
315
+ table.set(0, undefined);
316
+ table.set(offset + 0, undefined);
317
+ table.set(offset + 1, null);
318
+ table.set(offset + 2, true);
319
+ table.set(offset + 3, false);
320
+ },
321
+ };
322
+ return {
323
+ __proto__: null,
324
+ "./arkworks_groth16_wasm_bg.js": import0,
325
+ };
326
+ }
327
+
328
+ function addToExternrefTable0(obj) {
329
+ const idx = wasm.__externref_table_alloc();
330
+ wasm.__wbindgen_externrefs.set(idx, obj);
331
+ return idx;
332
+ }
333
+
334
+ function getArrayU8FromWasm0(ptr, len) {
335
+ ptr = ptr >>> 0;
336
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
337
+ }
338
+
339
+ let cachedDataViewMemory0 = null;
340
+ function getDataViewMemory0() {
341
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
342
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
343
+ }
344
+ return cachedDataViewMemory0;
345
+ }
346
+
347
+ function getStringFromWasm0(ptr, len) {
348
+ ptr = ptr >>> 0;
349
+ return decodeText(ptr, len);
350
+ }
351
+
352
+ let cachedUint8ArrayMemory0 = null;
353
+ function getUint8ArrayMemory0() {
354
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
355
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
356
+ }
357
+ return cachedUint8ArrayMemory0;
358
+ }
359
+
360
+ function handleError(f, args) {
361
+ try {
362
+ return f.apply(this, args);
363
+ } catch (e) {
364
+ const idx = addToExternrefTable0(e);
365
+ wasm.__wbindgen_exn_store(idx);
366
+ }
367
+ }
368
+
369
+ function isLikeNone(x) {
370
+ return x === undefined || x === null;
371
+ }
372
+
373
+ function passStringToWasm0(arg, malloc, realloc) {
374
+ if (realloc === undefined) {
375
+ const buf = cachedTextEncoder.encode(arg);
376
+ const ptr = malloc(buf.length, 1) >>> 0;
377
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
378
+ WASM_VECTOR_LEN = buf.length;
379
+ return ptr;
380
+ }
381
+
382
+ let len = arg.length;
383
+ let ptr = malloc(len, 1) >>> 0;
384
+
385
+ const mem = getUint8ArrayMemory0();
386
+
387
+ let offset = 0;
388
+
389
+ for (; offset < len; offset++) {
390
+ const code = arg.charCodeAt(offset);
391
+ if (code > 0x7F) break;
392
+ mem[ptr + offset] = code;
393
+ }
394
+ if (offset !== len) {
395
+ if (offset !== 0) {
396
+ arg = arg.slice(offset);
397
+ }
398
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
399
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
400
+ const ret = cachedTextEncoder.encodeInto(arg, view);
401
+
402
+ offset += ret.written;
403
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
404
+ }
405
+
406
+ WASM_VECTOR_LEN = offset;
407
+ return ptr;
408
+ }
409
+
410
+ function takeFromExternrefTable0(idx) {
411
+ const value = wasm.__wbindgen_externrefs.get(idx);
412
+ wasm.__externref_table_dealloc(idx);
413
+ return value;
414
+ }
415
+
416
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
417
+ cachedTextDecoder.decode();
418
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
419
+ let numBytesDecoded = 0;
420
+ function decodeText(ptr, len) {
421
+ numBytesDecoded += len;
422
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
423
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
424
+ cachedTextDecoder.decode();
425
+ numBytesDecoded = len;
426
+ }
427
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
428
+ }
429
+
430
+ const cachedTextEncoder = new TextEncoder();
431
+
432
+ if (!('encodeInto' in cachedTextEncoder)) {
433
+ cachedTextEncoder.encodeInto = function (arg, view) {
434
+ const buf = cachedTextEncoder.encode(arg);
435
+ view.set(buf);
436
+ return {
437
+ read: arg.length,
438
+ written: buf.length
439
+ };
440
+ };
441
+ }
442
+
443
+ let WASM_VECTOR_LEN = 0;
444
+
445
+ let wasmModule, wasm;
446
+ function __wbg_finalize_init(instance, module) {
447
+ wasm = instance.exports;
448
+ wasmModule = module;
449
+ cachedDataViewMemory0 = null;
450
+ cachedUint8ArrayMemory0 = null;
451
+ wasm.__wbindgen_start();
452
+ return wasm;
453
+ }
454
+
455
+ async function __wbg_load(module, imports) {
456
+ if (typeof Response === 'function' && module instanceof Response) {
457
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
458
+ try {
459
+ return await WebAssembly.instantiateStreaming(module, imports);
460
+ } catch (e) {
461
+ const validResponse = module.ok && expectedResponseType(module.type);
462
+
463
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
464
+ 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);
465
+
466
+ } else { throw e; }
467
+ }
468
+ }
469
+
470
+ const bytes = await module.arrayBuffer();
471
+ return await WebAssembly.instantiate(bytes, imports);
472
+ } else {
473
+ const instance = await WebAssembly.instantiate(module, imports);
474
+
475
+ if (instance instanceof WebAssembly.Instance) {
476
+ return { instance, module };
477
+ } else {
478
+ return instance;
479
+ }
480
+ }
481
+
482
+ function expectedResponseType(type) {
483
+ switch (type) {
484
+ case 'basic': case 'cors': case 'default': return true;
485
+ }
486
+ return false;
487
+ }
488
+ }
489
+
490
+ function initSync(module) {
491
+ if (wasm !== undefined) return wasm;
492
+
493
+
494
+ if (module !== undefined) {
495
+ if (Object.getPrototypeOf(module) === Object.prototype) {
496
+ ({module} = module)
497
+ } else {
498
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
499
+ }
500
+ }
501
+
502
+ const imports = __wbg_get_imports();
503
+ if (!(module instanceof WebAssembly.Module)) {
504
+ module = new WebAssembly.Module(module);
505
+ }
506
+ const instance = new WebAssembly.Instance(module, imports);
507
+ return __wbg_finalize_init(instance, module);
508
+ }
509
+
510
+ async function __wbg_init(module_or_path) {
511
+ if (wasm !== undefined) return wasm;
512
+
513
+
514
+ if (module_or_path !== undefined) {
515
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
516
+ ({module_or_path} = module_or_path)
517
+ } else {
518
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
519
+ }
520
+ }
521
+
522
+ if (module_or_path === undefined) {
523
+ module_or_path = new URL('arkworks_groth16_wasm_bg.wasm', import.meta.url);
524
+ }
525
+ const imports = __wbg_get_imports();
526
+
527
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
528
+ module_or_path = fetch(module_or_path);
529
+ }
530
+
531
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
532
+
533
+ return __wbg_finalize_init(instance, module);
534
+ }
535
+
536
+ export { initSync, __wbg_init as default };