@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,93 @@
1
+ type InputValue = number | string | bigint;
2
+ interface ProofTimings {
3
+ parseMs: number;
4
+ generateMs: number;
5
+ compileMs: number;
6
+ witnessMs: number;
7
+ proofMs: number;
8
+ verifyMs: number;
9
+ totalMs: number;
10
+ }
11
+ interface ProofResult {
12
+ proof: Uint8Array;
13
+ publicInputs: string[];
14
+ verified: boolean;
15
+ noirCode: string;
16
+ timings: ProofTimings;
17
+ }
18
+ type CircuitFunction = (publicArgs: InputValue[], privateArgs: InputValue[]) => void;
19
+ interface ProofData {
20
+ proof: Uint8Array;
21
+ publicInputs: string[];
22
+ }
23
+ interface ProverOptions {
24
+ threads?: number;
25
+ verbose?: boolean;
26
+ }
27
+ interface VerifierOptions {
28
+ verbose?: boolean;
29
+ }
30
+ /**
31
+ * Verifying key data for on-chain verification.
32
+ * Stored on the IziNoir instance after prove() is called.
33
+ */
34
+ interface VerifyingKeyData {
35
+ /** Base64-encoded VK in gnark format */
36
+ base64: string;
37
+ /** Raw VK bytes */
38
+ bytes: Uint8Array;
39
+ /** Number of public inputs for this circuit */
40
+ nrPublicInputs: number;
41
+ }
42
+ /**
43
+ * Data ready for Solana on-chain verification.
44
+ *
45
+ * Contains everything needed to:
46
+ * 1. Initialize a VK account (`verifyingKey`)
47
+ * 2. Verify a proof on-chain (`proof` + `publicInputs`)
48
+ *
49
+ * All data is pre-formatted for direct use with the IZI-NOIR Solana program,
50
+ * eliminating the need for manual copy-paste from the frontend.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const izi = await IziNoir.init({ provider: Provider.Arkworks, chain: Chain.Solana });
55
+ * await izi.compile(noirCode);
56
+ * const solanaProof = await izi.prove(inputs);
57
+ *
58
+ * // Use directly in tests or transactions:
59
+ * await program.methods.initVkFromBytes(
60
+ * solanaProof.verifyingKey.nrPublicInputs,
61
+ * Buffer.from(solanaProof.verifyingKey.bytes)
62
+ * ).rpc();
63
+ *
64
+ * await program.methods.verifyProof(
65
+ * Buffer.from(solanaProof.proof.bytes),
66
+ * solanaProof.publicInputs.bytes.map(b => Array.from(b))
67
+ * ).rpc();
68
+ * ```
69
+ */
70
+ interface SolanaProofData {
71
+ /** Verifying key for init_vk instruction */
72
+ verifyingKey: VerifyingKeyData;
73
+ /** Groth16 proof for verify_proof instruction */
74
+ proof: {
75
+ /** Base64-encoded proof (256 bytes) */
76
+ base64: string;
77
+ /** Raw proof bytes */
78
+ bytes: Uint8Array;
79
+ };
80
+ /** Public inputs for the proof */
81
+ publicInputs: {
82
+ /** Hex-encoded inputs (0x prefixed) */
83
+ hex: string[];
84
+ /** 32-byte arrays for each input */
85
+ bytes: Uint8Array[];
86
+ };
87
+ /** Estimated VK account size in bytes */
88
+ accountSize: number;
89
+ /** Estimated rent in lamports for the VK account */
90
+ estimatedRent: number;
91
+ }
92
+
93
+ export type { CircuitFunction as C, InputValue as I, ProofData as P, SolanaProofData as S, VerifyingKeyData as V, ProofResult as a, ProofTimings as b, ProverOptions as c, VerifierOptions as d };
@@ -0,0 +1,448 @@
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
+ 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
+ exports.acir_to_r1cs_info = acir_to_r1cs_info;
18
+
19
+ function init_panic_hook() {
20
+ wasm.init_panic_hook();
21
+ }
22
+ exports.init_panic_hook = init_panic_hook;
23
+
24
+ /**
25
+ * Generate a Groth16 proof
26
+ *
27
+ * # Arguments
28
+ * * `proving_key_b64` - Base64-encoded proving key from setup
29
+ * * `acir_json` - JSON string of the ACIR program
30
+ * * `witness_json` - JSON object mapping witness indices to hex values
31
+ *
32
+ * # Returns
33
+ * * `JsProofResult` with proof and public inputs
34
+ * @param {string} proving_key_b64
35
+ * @param {string} acir_json
36
+ * @param {string} witness_json
37
+ * @returns {any}
38
+ */
39
+ function prove(proving_key_b64, acir_json, witness_json) {
40
+ const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
+ const len0 = WASM_VECTOR_LEN;
42
+ const ptr1 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
43
+ const len1 = WASM_VECTOR_LEN;
44
+ const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
45
+ const len2 = WASM_VECTOR_LEN;
46
+ const ret = wasm.prove(ptr0, len0, ptr1, len1, ptr2, len2);
47
+ if (ret[2]) {
48
+ throw takeFromExternrefTable0(ret[1]);
49
+ }
50
+ return takeFromExternrefTable0(ret[0]);
51
+ }
52
+ exports.prove = prove;
53
+
54
+ /**
55
+ * Perform trusted setup for a circuit
56
+ *
57
+ * # Arguments
58
+ * * `acir_json` - JSON string of the ACIR program from Noir compiler
59
+ *
60
+ * # Returns
61
+ * * `JsSetupResult` with base64-encoded proving and verifying keys
62
+ * @param {string} acir_json
63
+ * @returns {any}
64
+ */
65
+ function setup(acir_json) {
66
+ const ptr0 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
67
+ const len0 = WASM_VECTOR_LEN;
68
+ const ret = wasm.setup(ptr0, len0);
69
+ if (ret[2]) {
70
+ throw takeFromExternrefTable0(ret[1]);
71
+ }
72
+ return takeFromExternrefTable0(ret[0]);
73
+ }
74
+ exports.setup = setup;
75
+
76
+ /**
77
+ * Verify a Groth16 proof
78
+ *
79
+ * # Arguments
80
+ * * `verifying_key_b64` - Base64-encoded verifying key from setup
81
+ * * `proof_b64` - Base64-encoded proof (arkworks format)
82
+ * * `public_inputs_json` - JSON array of public inputs as hex strings
83
+ *
84
+ * # Returns
85
+ * * `true` if proof is valid, `false` otherwise
86
+ * @param {string} verifying_key_b64
87
+ * @param {string} proof_b64
88
+ * @param {string} public_inputs_json
89
+ * @returns {boolean}
90
+ */
91
+ function verify(verifying_key_b64, proof_b64, public_inputs_json) {
92
+ const ptr0 = passStringToWasm0(verifying_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
93
+ const len0 = WASM_VECTOR_LEN;
94
+ const ptr1 = passStringToWasm0(proof_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
95
+ const len1 = WASM_VECTOR_LEN;
96
+ const ptr2 = passStringToWasm0(public_inputs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
97
+ const len2 = WASM_VECTOR_LEN;
98
+ const ret = wasm.verify(ptr0, len0, ptr1, len1, ptr2, len2);
99
+ if (ret[2]) {
100
+ throw takeFromExternrefTable0(ret[1]);
101
+ }
102
+ return ret[0] !== 0;
103
+ }
104
+ exports.verify = verify;
105
+
106
+ /**
107
+ * Verify a Groth16 proof in gnark format
108
+ *
109
+ * # Arguments
110
+ * * `verifying_key_gnark_b64` - Base64-encoded verifying key (gnark format)
111
+ * * `proof_gnark_b64` - Base64-encoded proof (gnark format, 256 bytes)
112
+ * * `public_inputs_gnark_b64` - Base64-encoded public inputs (gnark format)
113
+ * * `num_public_inputs` - Number of public inputs
114
+ *
115
+ * # Returns
116
+ * * `true` if proof is valid, `false` otherwise
117
+ * @param {string} verifying_key_gnark_b64
118
+ * @param {string} proof_gnark_b64
119
+ * @param {string} public_inputs_gnark_b64
120
+ * @param {number} num_public_inputs
121
+ * @returns {boolean}
122
+ */
123
+ function verify_gnark(verifying_key_gnark_b64, proof_gnark_b64, public_inputs_gnark_b64, num_public_inputs) {
124
+ const ptr0 = passStringToWasm0(verifying_key_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
125
+ const len0 = WASM_VECTOR_LEN;
126
+ const ptr1 = passStringToWasm0(proof_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
127
+ const len1 = WASM_VECTOR_LEN;
128
+ const ptr2 = passStringToWasm0(public_inputs_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
129
+ const len2 = WASM_VECTOR_LEN;
130
+ const ret = wasm.verify_gnark(ptr0, len0, ptr1, len1, ptr2, len2, num_public_inputs);
131
+ if (ret[2]) {
132
+ throw takeFromExternrefTable0(ret[1]);
133
+ }
134
+ return ret[0] !== 0;
135
+ }
136
+ exports.verify_gnark = verify_gnark;
137
+
138
+ /**
139
+ * Get library version
140
+ * @returns {string}
141
+ */
142
+ function version() {
143
+ let deferred1_0;
144
+ let deferred1_1;
145
+ try {
146
+ const ret = wasm.version();
147
+ deferred1_0 = ret[0];
148
+ deferred1_1 = ret[1];
149
+ return getStringFromWasm0(ret[0], ret[1]);
150
+ } finally {
151
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
152
+ }
153
+ }
154
+ exports.version = version;
155
+
156
+ function __wbg_get_imports() {
157
+ const import0 = {
158
+ __proto__: null,
159
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
160
+ const ret = Error(getStringFromWasm0(arg0, arg1));
161
+ return ret;
162
+ },
163
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
164
+ const ret = String(arg1);
165
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
166
+ const len1 = WASM_VECTOR_LEN;
167
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
168
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
169
+ },
170
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
171
+ const ret = typeof(arg0) === 'function';
172
+ return ret;
173
+ },
174
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
175
+ const val = arg0;
176
+ const ret = typeof(val) === 'object' && val !== null;
177
+ return ret;
178
+ },
179
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
180
+ const ret = typeof(arg0) === 'string';
181
+ return ret;
182
+ },
183
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
184
+ const ret = arg0 === undefined;
185
+ return ret;
186
+ },
187
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
188
+ throw new Error(getStringFromWasm0(arg0, arg1));
189
+ },
190
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
191
+ const ret = arg0.call(arg1);
192
+ return ret;
193
+ }, arguments); },
194
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
195
+ const ret = arg0.call(arg1, arg2);
196
+ return ret;
197
+ }, arguments); },
198
+ __wbg_crypto_86f2631e91b51511: function(arg0) {
199
+ const ret = arg0.crypto;
200
+ return ret;
201
+ },
202
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
203
+ let deferred0_0;
204
+ let deferred0_1;
205
+ try {
206
+ deferred0_0 = arg0;
207
+ deferred0_1 = arg1;
208
+ console.error(getStringFromWasm0(arg0, arg1));
209
+ } finally {
210
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
211
+ }
212
+ },
213
+ __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
214
+ arg0.getRandomValues(arg1);
215
+ }, arguments); },
216
+ __wbg_length_32ed9a279acd054c: function(arg0) {
217
+ const ret = arg0.length;
218
+ return ret;
219
+ },
220
+ __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
221
+ const ret = arg0.msCrypto;
222
+ return ret;
223
+ },
224
+ __wbg_new_361308b2356cecd0: function() {
225
+ const ret = new Object();
226
+ return ret;
227
+ },
228
+ __wbg_new_3eb36ae241fe6f44: function() {
229
+ const ret = new Array();
230
+ return ret;
231
+ },
232
+ __wbg_new_8a6f238a6ece86ea: function() {
233
+ const ret = new Error();
234
+ return ret;
235
+ },
236
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
237
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
238
+ return ret;
239
+ },
240
+ __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
241
+ const ret = new Uint8Array(arg0 >>> 0);
242
+ return ret;
243
+ },
244
+ __wbg_node_e1f24f89a7336c2e: function(arg0) {
245
+ const ret = arg0.node;
246
+ return ret;
247
+ },
248
+ __wbg_process_3975fd6c72f520aa: function(arg0) {
249
+ const ret = arg0.process;
250
+ return ret;
251
+ },
252
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
253
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
254
+ },
255
+ __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
256
+ arg0.randomFillSync(arg1);
257
+ }, arguments); },
258
+ __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
259
+ const ret = module.require;
260
+ return ret;
261
+ }, arguments); },
262
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
263
+ arg0[arg1] = arg2;
264
+ },
265
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
266
+ arg0[arg1 >>> 0] = arg2;
267
+ },
268
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
269
+ const ret = arg1.stack;
270
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
271
+ const len1 = WASM_VECTOR_LEN;
272
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
273
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
274
+ },
275
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
276
+ const ret = typeof global === 'undefined' ? null : global;
277
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
278
+ },
279
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
280
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
281
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
282
+ },
283
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
284
+ const ret = typeof self === 'undefined' ? null : self;
285
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
286
+ },
287
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
288
+ const ret = typeof window === 'undefined' ? null : window;
289
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
290
+ },
291
+ __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
292
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
293
+ return ret;
294
+ },
295
+ __wbg_versions_4e31226f5e8dc909: function(arg0) {
296
+ const ret = arg0.versions;
297
+ return ret;
298
+ },
299
+ __wbindgen_cast_0000000000000001: function(arg0) {
300
+ // Cast intrinsic for `F64 -> Externref`.
301
+ const ret = arg0;
302
+ return ret;
303
+ },
304
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
305
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
306
+ const ret = getArrayU8FromWasm0(arg0, arg1);
307
+ return ret;
308
+ },
309
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
310
+ // Cast intrinsic for `Ref(String) -> Externref`.
311
+ const ret = getStringFromWasm0(arg0, arg1);
312
+ return ret;
313
+ },
314
+ __wbindgen_cast_0000000000000004: function(arg0) {
315
+ // Cast intrinsic for `U64 -> Externref`.
316
+ const ret = BigInt.asUintN(64, arg0);
317
+ return ret;
318
+ },
319
+ __wbindgen_init_externref_table: function() {
320
+ const table = wasm.__wbindgen_externrefs;
321
+ const offset = table.grow(4);
322
+ table.set(0, undefined);
323
+ table.set(offset + 0, undefined);
324
+ table.set(offset + 1, null);
325
+ table.set(offset + 2, true);
326
+ table.set(offset + 3, false);
327
+ },
328
+ };
329
+ return {
330
+ __proto__: null,
331
+ "./arkworks_groth16_wasm_bg.js": import0,
332
+ };
333
+ }
334
+
335
+ function addToExternrefTable0(obj) {
336
+ const idx = wasm.__externref_table_alloc();
337
+ wasm.__wbindgen_externrefs.set(idx, obj);
338
+ return idx;
339
+ }
340
+
341
+ function getArrayU8FromWasm0(ptr, len) {
342
+ ptr = ptr >>> 0;
343
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
344
+ }
345
+
346
+ let cachedDataViewMemory0 = null;
347
+ function getDataViewMemory0() {
348
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
349
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
350
+ }
351
+ return cachedDataViewMemory0;
352
+ }
353
+
354
+ function getStringFromWasm0(ptr, len) {
355
+ ptr = ptr >>> 0;
356
+ return decodeText(ptr, len);
357
+ }
358
+
359
+ let cachedUint8ArrayMemory0 = null;
360
+ function getUint8ArrayMemory0() {
361
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
362
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
363
+ }
364
+ return cachedUint8ArrayMemory0;
365
+ }
366
+
367
+ function handleError(f, args) {
368
+ try {
369
+ return f.apply(this, args);
370
+ } catch (e) {
371
+ const idx = addToExternrefTable0(e);
372
+ wasm.__wbindgen_exn_store(idx);
373
+ }
374
+ }
375
+
376
+ function isLikeNone(x) {
377
+ return x === undefined || x === null;
378
+ }
379
+
380
+ function passStringToWasm0(arg, malloc, realloc) {
381
+ if (realloc === undefined) {
382
+ const buf = cachedTextEncoder.encode(arg);
383
+ const ptr = malloc(buf.length, 1) >>> 0;
384
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
385
+ WASM_VECTOR_LEN = buf.length;
386
+ return ptr;
387
+ }
388
+
389
+ let len = arg.length;
390
+ let ptr = malloc(len, 1) >>> 0;
391
+
392
+ const mem = getUint8ArrayMemory0();
393
+
394
+ let offset = 0;
395
+
396
+ for (; offset < len; offset++) {
397
+ const code = arg.charCodeAt(offset);
398
+ if (code > 0x7F) break;
399
+ mem[ptr + offset] = code;
400
+ }
401
+ if (offset !== len) {
402
+ if (offset !== 0) {
403
+ arg = arg.slice(offset);
404
+ }
405
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
406
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
407
+ const ret = cachedTextEncoder.encodeInto(arg, view);
408
+
409
+ offset += ret.written;
410
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
411
+ }
412
+
413
+ WASM_VECTOR_LEN = offset;
414
+ return ptr;
415
+ }
416
+
417
+ function takeFromExternrefTable0(idx) {
418
+ const value = wasm.__wbindgen_externrefs.get(idx);
419
+ wasm.__externref_table_dealloc(idx);
420
+ return value;
421
+ }
422
+
423
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
424
+ cachedTextDecoder.decode();
425
+ function decodeText(ptr, len) {
426
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
427
+ }
428
+
429
+ const cachedTextEncoder = new TextEncoder();
430
+
431
+ if (!('encodeInto' in cachedTextEncoder)) {
432
+ cachedTextEncoder.encodeInto = function (arg, view) {
433
+ const buf = cachedTextEncoder.encode(arg);
434
+ view.set(buf);
435
+ return {
436
+ read: arg.length,
437
+ written: buf.length
438
+ };
439
+ };
440
+ }
441
+
442
+ let WASM_VECTOR_LEN = 0;
443
+
444
+ const wasmPath = `${__dirname}/arkworks_groth16_wasm_bg.wasm`;
445
+ const wasmBytes = require('fs').readFileSync(wasmPath);
446
+ const wasmModule = new WebAssembly.Module(wasmBytes);
447
+ const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
448
+ wasm.__wbindgen_start();