@aztec/noir-acvm_js 0.75.0-commit.8a71f57856e217a77b6e50cbc8833c1cd5395b96

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.
@@ -0,0 +1,931 @@
1
+ let imports = {};
2
+ imports['__wbindgen_placeholder__'] = module.exports;
3
+ let wasm;
4
+ const { TextDecoder, TextEncoder } = require(`util`);
5
+
6
+ const heap = new Array(128).fill(undefined);
7
+
8
+ heap.push(undefined, null, true, false);
9
+
10
+ function getObject(idx) { return heap[idx]; }
11
+
12
+ let heap_next = heap.length;
13
+
14
+ function dropObject(idx) {
15
+ if (idx < 132) return;
16
+ heap[idx] = heap_next;
17
+ heap_next = idx;
18
+ }
19
+
20
+ function takeObject(idx) {
21
+ const ret = getObject(idx);
22
+ dropObject(idx);
23
+ return ret;
24
+ }
25
+
26
+ function addHeapObject(obj) {
27
+ if (heap_next === heap.length) heap.push(heap.length + 1);
28
+ const idx = heap_next;
29
+ heap_next = heap[idx];
30
+
31
+ heap[idx] = obj;
32
+ return idx;
33
+ }
34
+
35
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
36
+
37
+ cachedTextDecoder.decode();
38
+
39
+ let cachedUint8Memory0 = null;
40
+
41
+ function getUint8Memory0() {
42
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
43
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
44
+ }
45
+ return cachedUint8Memory0;
46
+ }
47
+
48
+ function getStringFromWasm0(ptr, len) {
49
+ ptr = ptr >>> 0;
50
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
51
+ }
52
+
53
+ let WASM_VECTOR_LEN = 0;
54
+
55
+ let cachedTextEncoder = new TextEncoder('utf-8');
56
+
57
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
58
+ ? function (arg, view) {
59
+ return cachedTextEncoder.encodeInto(arg, view);
60
+ }
61
+ : function (arg, view) {
62
+ const buf = cachedTextEncoder.encode(arg);
63
+ view.set(buf);
64
+ return {
65
+ read: arg.length,
66
+ written: buf.length
67
+ };
68
+ });
69
+
70
+ function passStringToWasm0(arg, malloc, realloc) {
71
+
72
+ if (realloc === undefined) {
73
+ const buf = cachedTextEncoder.encode(arg);
74
+ const ptr = malloc(buf.length) >>> 0;
75
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
76
+ WASM_VECTOR_LEN = buf.length;
77
+ return ptr;
78
+ }
79
+
80
+ let len = arg.length;
81
+ let ptr = malloc(len) >>> 0;
82
+
83
+ const mem = getUint8Memory0();
84
+
85
+ let offset = 0;
86
+
87
+ for (; offset < len; offset++) {
88
+ const code = arg.charCodeAt(offset);
89
+ if (code > 0x7F) break;
90
+ mem[ptr + offset] = code;
91
+ }
92
+
93
+ if (offset !== len) {
94
+ if (offset !== 0) {
95
+ arg = arg.slice(offset);
96
+ }
97
+ ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
98
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
99
+ const ret = encodeString(arg, view);
100
+
101
+ offset += ret.written;
102
+ }
103
+
104
+ WASM_VECTOR_LEN = offset;
105
+ return ptr;
106
+ }
107
+
108
+ function isLikeNone(x) {
109
+ return x === undefined || x === null;
110
+ }
111
+
112
+ let cachedInt32Memory0 = null;
113
+
114
+ function getInt32Memory0() {
115
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
116
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
117
+ }
118
+ return cachedInt32Memory0;
119
+ }
120
+
121
+ let cachedFloat64Memory0 = null;
122
+
123
+ function getFloat64Memory0() {
124
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
125
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
126
+ }
127
+ return cachedFloat64Memory0;
128
+ }
129
+
130
+ function debugString(val) {
131
+ // primitive types
132
+ const type = typeof val;
133
+ if (type == 'number' || type == 'boolean' || val == null) {
134
+ return `${val}`;
135
+ }
136
+ if (type == 'string') {
137
+ return `"${val}"`;
138
+ }
139
+ if (type == 'symbol') {
140
+ const description = val.description;
141
+ if (description == null) {
142
+ return 'Symbol';
143
+ } else {
144
+ return `Symbol(${description})`;
145
+ }
146
+ }
147
+ if (type == 'function') {
148
+ const name = val.name;
149
+ if (typeof name == 'string' && name.length > 0) {
150
+ return `Function(${name})`;
151
+ } else {
152
+ return 'Function';
153
+ }
154
+ }
155
+ // objects
156
+ if (Array.isArray(val)) {
157
+ const length = val.length;
158
+ let debug = '[';
159
+ if (length > 0) {
160
+ debug += debugString(val[0]);
161
+ }
162
+ for(let i = 1; i < length; i++) {
163
+ debug += ', ' + debugString(val[i]);
164
+ }
165
+ debug += ']';
166
+ return debug;
167
+ }
168
+ // Test for built-in
169
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
170
+ let className;
171
+ if (builtInMatches.length > 1) {
172
+ className = builtInMatches[1];
173
+ } else {
174
+ // Failed to match the standard '[object ClassName]'
175
+ return toString.call(val);
176
+ }
177
+ if (className == 'Object') {
178
+ // we're a user defined class or Object
179
+ // JSON.stringify avoids problems with cycles, and is generally much
180
+ // easier than looping through ownProperties of `val`.
181
+ try {
182
+ return 'Object(' + JSON.stringify(val) + ')';
183
+ } catch (_) {
184
+ return 'Object';
185
+ }
186
+ }
187
+ // errors
188
+ if (val instanceof Error) {
189
+ return `${val.name}: ${val.message}\n${val.stack}`;
190
+ }
191
+ // TODO we could test for more things here, like `Set`s and `Map`s.
192
+ return className;
193
+ }
194
+
195
+ function makeMutClosure(arg0, arg1, dtor, f) {
196
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
197
+ const real = (...args) => {
198
+ // First up with a closure we increment the internal reference
199
+ // count. This ensures that the Rust closure environment won't
200
+ // be deallocated while we're invoking it.
201
+ state.cnt++;
202
+ const a = state.a;
203
+ state.a = 0;
204
+ try {
205
+ return f(a, state.b, ...args);
206
+ } finally {
207
+ if (--state.cnt === 0) {
208
+ wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
209
+
210
+ } else {
211
+ state.a = a;
212
+ }
213
+ }
214
+ };
215
+ real.original = state;
216
+
217
+ return real;
218
+ }
219
+ function __wbg_adapter_22(arg0, arg1, arg2) {
220
+ wasm.wasm_bindgen__convert__closures__invoke1_mut__h88a56384c96b757b(arg0, arg1, addHeapObject(arg2));
221
+ }
222
+
223
+ function passArray8ToWasm0(arg, malloc) {
224
+ const ptr = malloc(arg.length * 1) >>> 0;
225
+ getUint8Memory0().set(arg, ptr / 1);
226
+ WASM_VECTOR_LEN = arg.length;
227
+ return ptr;
228
+ }
229
+ /**
230
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
231
+ *
232
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
233
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
234
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
235
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
236
+ */
237
+ module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
238
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
239
+ const len0 = WASM_VECTOR_LEN;
240
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
241
+ return takeObject(ret);
242
+ };
243
+
244
+ /**
245
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
246
+ * This method also extracts the public return values from the solved witness into its own return witness.
247
+ *
248
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
249
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
250
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
251
+ * @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
252
+ */
253
+ module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
254
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
255
+ const len0 = WASM_VECTOR_LEN;
256
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
257
+ return takeObject(ret);
258
+ };
259
+
260
+ /**
261
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
262
+ *
263
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
264
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
265
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
266
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
267
+ */
268
+ module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
269
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
270
+ const len0 = WASM_VECTOR_LEN;
271
+ const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
272
+ return takeObject(ret);
273
+ };
274
+
275
+ /**
276
+ * Sets the package's logging level.
277
+ *
278
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
279
+ */
280
+ module.exports.initLogLevel = function(filter) {
281
+ try {
282
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
283
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
284
+ const len0 = WASM_VECTOR_LEN;
285
+ wasm.initLogLevel(retptr, ptr0, len0);
286
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
287
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
288
+ if (r1) {
289
+ throw takeObject(r0);
290
+ }
291
+ } finally {
292
+ wasm.__wbindgen_add_to_stack_pointer(16);
293
+ }
294
+ };
295
+
296
+ function getArrayU8FromWasm0(ptr, len) {
297
+ ptr = ptr >>> 0;
298
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
299
+ }
300
+ /**
301
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
302
+ *
303
+ * @param {WitnessMap} witness_map - A witness map.
304
+ * @returns {Uint8Array} A compressed witness map
305
+ */
306
+ module.exports.compressWitness = function(witness_map) {
307
+ try {
308
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
309
+ wasm.compressWitness(retptr, addHeapObject(witness_map));
310
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
311
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
312
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
313
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
314
+ if (r3) {
315
+ throw takeObject(r2);
316
+ }
317
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
318
+ wasm.__wbindgen_free(r0, r1 * 1);
319
+ return v1;
320
+ } finally {
321
+ wasm.__wbindgen_add_to_stack_pointer(16);
322
+ }
323
+ };
324
+
325
+ /**
326
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
327
+ * This should be used to only fetch the witness map for the main function.
328
+ *
329
+ * @param {Uint8Array} compressed_witness - A compressed witness.
330
+ * @returns {WitnessMap} The decompressed witness map.
331
+ */
332
+ module.exports.decompressWitness = function(compressed_witness) {
333
+ try {
334
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
335
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
336
+ const len0 = WASM_VECTOR_LEN;
337
+ wasm.decompressWitness(retptr, ptr0, len0);
338
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
339
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
340
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
341
+ if (r2) {
342
+ throw takeObject(r1);
343
+ }
344
+ return takeObject(r0);
345
+ } finally {
346
+ wasm.__wbindgen_add_to_stack_pointer(16);
347
+ }
348
+ };
349
+
350
+ /**
351
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
352
+ *
353
+ * @param {WitnessStack} witness_stack - A witness stack.
354
+ * @returns {Uint8Array} A compressed witness stack
355
+ */
356
+ module.exports.compressWitnessStack = function(witness_stack) {
357
+ try {
358
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
359
+ wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
360
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
361
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
362
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
363
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
364
+ if (r3) {
365
+ throw takeObject(r2);
366
+ }
367
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
368
+ wasm.__wbindgen_free(r0, r1 * 1);
369
+ return v1;
370
+ } finally {
371
+ wasm.__wbindgen_add_to_stack_pointer(16);
372
+ }
373
+ };
374
+
375
+ /**
376
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
377
+ *
378
+ * @param {Uint8Array} compressed_witness - A compressed witness.
379
+ * @returns {WitnessStack} The decompressed witness stack.
380
+ */
381
+ module.exports.decompressWitnessStack = function(compressed_witness) {
382
+ try {
383
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
384
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
385
+ const len0 = WASM_VECTOR_LEN;
386
+ wasm.decompressWitnessStack(retptr, ptr0, len0);
387
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
388
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
389
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
390
+ if (r2) {
391
+ throw takeObject(r1);
392
+ }
393
+ return takeObject(r0);
394
+ } finally {
395
+ wasm.__wbindgen_add_to_stack_pointer(16);
396
+ }
397
+ };
398
+
399
+ /**
400
+ * Performs a bitwise AND operation between `lhs` and `rhs`
401
+ * @param {string} lhs
402
+ * @param {string} rhs
403
+ * @returns {string}
404
+ */
405
+ module.exports.and = function(lhs, rhs) {
406
+ const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
407
+ return takeObject(ret);
408
+ };
409
+
410
+ /**
411
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
412
+ * @param {string} lhs
413
+ * @param {string} rhs
414
+ * @returns {string}
415
+ */
416
+ module.exports.xor = function(lhs, rhs) {
417
+ const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
418
+ return takeObject(ret);
419
+ };
420
+
421
+ let cachedUint32Memory0 = null;
422
+
423
+ function getUint32Memory0() {
424
+ if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
425
+ cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
426
+ }
427
+ return cachedUint32Memory0;
428
+ }
429
+
430
+ function passArray32ToWasm0(arg, malloc) {
431
+ const ptr = malloc(arg.length * 4) >>> 0;
432
+ getUint32Memory0().set(arg, ptr / 4);
433
+ WASM_VECTOR_LEN = arg.length;
434
+ return ptr;
435
+ }
436
+
437
+ function getArrayU32FromWasm0(ptr, len) {
438
+ ptr = ptr >>> 0;
439
+ return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
440
+ }
441
+ /**
442
+ * Sha256 compression function
443
+ * @param {Uint32Array} inputs
444
+ * @param {Uint32Array} state
445
+ * @returns {Uint32Array}
446
+ */
447
+ module.exports.sha256_compression = function(inputs, state) {
448
+ try {
449
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
450
+ const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
451
+ const len0 = WASM_VECTOR_LEN;
452
+ const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
453
+ const len1 = WASM_VECTOR_LEN;
454
+ wasm.sha256_compression(retptr, ptr0, len0, ptr1, len1);
455
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
456
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
457
+ var v3 = getArrayU32FromWasm0(r0, r1).slice();
458
+ wasm.__wbindgen_free(r0, r1 * 4);
459
+ return v3;
460
+ } finally {
461
+ wasm.__wbindgen_add_to_stack_pointer(16);
462
+ }
463
+ };
464
+
465
+ /**
466
+ * Calculates the Blake2s256 hash of the input bytes
467
+ * @param {Uint8Array} inputs
468
+ * @returns {Uint8Array}
469
+ */
470
+ module.exports.blake2s256 = function(inputs) {
471
+ try {
472
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
473
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
474
+ const len0 = WASM_VECTOR_LEN;
475
+ wasm.blake2s256(retptr, ptr0, len0);
476
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
477
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
478
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
479
+ wasm.__wbindgen_free(r0, r1 * 1);
480
+ return v2;
481
+ } finally {
482
+ wasm.__wbindgen_add_to_stack_pointer(16);
483
+ }
484
+ };
485
+
486
+ /**
487
+ * Verifies a ECDSA signature over the secp256k1 curve.
488
+ * @param {Uint8Array} hashed_msg
489
+ * @param {Uint8Array} public_key_x_bytes
490
+ * @param {Uint8Array} public_key_y_bytes
491
+ * @param {Uint8Array} signature
492
+ * @returns {boolean}
493
+ */
494
+ module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
495
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
496
+ const len0 = WASM_VECTOR_LEN;
497
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
498
+ const len1 = WASM_VECTOR_LEN;
499
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
500
+ const len2 = WASM_VECTOR_LEN;
501
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
502
+ const len3 = WASM_VECTOR_LEN;
503
+ const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
504
+ return ret !== 0;
505
+ };
506
+
507
+ /**
508
+ * Verifies a ECDSA signature over the secp256r1 curve.
509
+ * @param {Uint8Array} hashed_msg
510
+ * @param {Uint8Array} public_key_x_bytes
511
+ * @param {Uint8Array} public_key_y_bytes
512
+ * @param {Uint8Array} signature
513
+ * @returns {boolean}
514
+ */
515
+ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
516
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
517
+ const len0 = WASM_VECTOR_LEN;
518
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
519
+ const len1 = WASM_VECTOR_LEN;
520
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
521
+ const len2 = WASM_VECTOR_LEN;
522
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
523
+ const len3 = WASM_VECTOR_LEN;
524
+ const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
525
+ return ret !== 0;
526
+ };
527
+
528
+ /**
529
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
530
+ * @returns {BuildInfo} - Information on how the installed package was built.
531
+ */
532
+ module.exports.buildInfo = function() {
533
+ const ret = wasm.buildInfo();
534
+ return takeObject(ret);
535
+ };
536
+
537
+ /**
538
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
539
+ *
540
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
541
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
542
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
543
+ * @param {Uint8Array} program
544
+ * @param {WitnessMap} witness_map
545
+ * @returns {WitnessMap}
546
+ */
547
+ module.exports.getReturnWitness = function(program, witness_map) {
548
+ try {
549
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
550
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
551
+ const len0 = WASM_VECTOR_LEN;
552
+ wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
553
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
554
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
555
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
556
+ if (r2) {
557
+ throw takeObject(r1);
558
+ }
559
+ return takeObject(r0);
560
+ } finally {
561
+ wasm.__wbindgen_add_to_stack_pointer(16);
562
+ }
563
+ };
564
+
565
+ /**
566
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
567
+ *
568
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
569
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
570
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
571
+ * @param {Uint8Array} program
572
+ * @param {WitnessMap} solved_witness
573
+ * @returns {WitnessMap}
574
+ */
575
+ module.exports.getPublicParametersWitness = function(program, solved_witness) {
576
+ try {
577
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
578
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
579
+ const len0 = WASM_VECTOR_LEN;
580
+ wasm.getPublicParametersWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
581
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
582
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
583
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
584
+ if (r2) {
585
+ throw takeObject(r1);
586
+ }
587
+ return takeObject(r0);
588
+ } finally {
589
+ wasm.__wbindgen_add_to_stack_pointer(16);
590
+ }
591
+ };
592
+
593
+ /**
594
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
595
+ *
596
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
597
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
598
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
599
+ * @param {Uint8Array} program
600
+ * @param {WitnessMap} solved_witness
601
+ * @returns {WitnessMap}
602
+ */
603
+ module.exports.getPublicWitness = function(program, solved_witness) {
604
+ try {
605
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
606
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
607
+ const len0 = WASM_VECTOR_LEN;
608
+ wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
609
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
610
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
611
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
612
+ if (r2) {
613
+ throw takeObject(r1);
614
+ }
615
+ return takeObject(r0);
616
+ } finally {
617
+ wasm.__wbindgen_add_to_stack_pointer(16);
618
+ }
619
+ };
620
+
621
+ function __wbg_adapter_75(arg0, arg1, arg2, arg3, arg4) {
622
+ wasm.wasm_bindgen__convert__closures__invoke3_mut__h24d1dd0bd469df82(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
623
+ }
624
+
625
+ function handleError(f, args) {
626
+ try {
627
+ return f.apply(this, args);
628
+ } catch (e) {
629
+ wasm.__wbindgen_exn_store(addHeapObject(e));
630
+ }
631
+ }
632
+ function __wbg_adapter_92(arg0, arg1, arg2, arg3) {
633
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h57a2220e5f1e0a1e(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
634
+ }
635
+
636
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
637
+ takeObject(arg0);
638
+ };
639
+
640
+ module.exports.__wbindgen_is_array = function(arg0) {
641
+ const ret = Array.isArray(getObject(arg0));
642
+ return ret;
643
+ };
644
+
645
+ module.exports.__wbg_constructor_a10f2b77c63b8d5e = function(arg0) {
646
+ const ret = new Error(takeObject(arg0));
647
+ return addHeapObject(ret);
648
+ };
649
+
650
+ module.exports.__wbg_new_d86d15722f6b14a4 = function() {
651
+ const ret = new Map();
652
+ return addHeapObject(ret);
653
+ };
654
+
655
+ module.exports.__wbindgen_number_new = function(arg0) {
656
+ const ret = arg0;
657
+ return addHeapObject(ret);
658
+ };
659
+
660
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
661
+ const ret = getStringFromWasm0(arg0, arg1);
662
+ return addHeapObject(ret);
663
+ };
664
+
665
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
666
+ const obj = getObject(arg1);
667
+ const ret = typeof(obj) === 'string' ? obj : undefined;
668
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
669
+ var len1 = WASM_VECTOR_LEN;
670
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
671
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
672
+ };
673
+
674
+ module.exports.__wbindgen_cb_drop = function(arg0) {
675
+ const obj = takeObject(arg0).original;
676
+ if (obj.cnt-- == 1) {
677
+ obj.a = 0;
678
+ return true;
679
+ }
680
+ const ret = false;
681
+ return ret;
682
+ };
683
+
684
+ module.exports.__wbindgen_is_string = function(arg0) {
685
+ const ret = typeof(getObject(arg0)) === 'string';
686
+ return ret;
687
+ };
688
+
689
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
690
+ const obj = getObject(arg1);
691
+ const ret = typeof(obj) === 'number' ? obj : undefined;
692
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
693
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
694
+ };
695
+
696
+ module.exports.__wbg_new_a16954212d33afab = function() {
697
+ const ret = new Array();
698
+ return addHeapObject(ret);
699
+ };
700
+
701
+ module.exports.__wbg_new_abda76e883ba8a5f = function() {
702
+ const ret = new Error();
703
+ return addHeapObject(ret);
704
+ };
705
+
706
+ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
707
+ const ret = getObject(arg1).stack;
708
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
709
+ const len1 = WASM_VECTOR_LEN;
710
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
711
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
712
+ };
713
+
714
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
715
+ let deferred0_0;
716
+ let deferred0_1;
717
+ try {
718
+ deferred0_0 = arg0;
719
+ deferred0_1 = arg1;
720
+ console.error(getStringFromWasm0(arg0, arg1));
721
+ } finally {
722
+ wasm.__wbindgen_free(deferred0_0, deferred0_1);
723
+ }
724
+ };
725
+
726
+ module.exports.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
727
+ console.debug(getObject(arg0));
728
+ };
729
+
730
+ module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
731
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
732
+ };
733
+
734
+ module.exports.__wbg_error_a7e23606158b68b9 = function(arg0) {
735
+ console.error(getObject(arg0));
736
+ };
737
+
738
+ module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
739
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
740
+ };
741
+
742
+ module.exports.__wbg_info_05db236d79f1b785 = function(arg0) {
743
+ console.info(getObject(arg0));
744
+ };
745
+
746
+ module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
747
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
748
+ };
749
+
750
+ module.exports.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
751
+ console.warn(getObject(arg0));
752
+ };
753
+
754
+ module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
755
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
756
+ };
757
+
758
+ module.exports.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) {
759
+ const ret = getObject(arg0)[arg1 >>> 0];
760
+ return addHeapObject(ret);
761
+ };
762
+
763
+ module.exports.__wbg_length_820c786973abdd8a = function(arg0) {
764
+ const ret = getObject(arg0).length;
765
+ return ret;
766
+ };
767
+
768
+ module.exports.__wbg_new_0394642eae39db16 = function() {
769
+ const ret = new Array();
770
+ return addHeapObject(ret);
771
+ };
772
+
773
+ module.exports.__wbg_new_0f2b71ca2f2a6029 = function() {
774
+ const ret = new Map();
775
+ return addHeapObject(ret);
776
+ };
777
+
778
+ module.exports.__wbg_from_6bc98a09a0b58bb1 = function(arg0) {
779
+ const ret = Array.from(getObject(arg0));
780
+ return addHeapObject(ret);
781
+ };
782
+
783
+ module.exports.__wbg_forEach_5ae261259d7517c8 = function(arg0, arg1, arg2) {
784
+ try {
785
+ var state0 = {a: arg1, b: arg2};
786
+ var cb0 = (arg0, arg1, arg2) => {
787
+ const a = state0.a;
788
+ state0.a = 0;
789
+ try {
790
+ return __wbg_adapter_75(a, state0.b, arg0, arg1, arg2);
791
+ } finally {
792
+ state0.a = a;
793
+ }
794
+ };
795
+ getObject(arg0).forEach(cb0);
796
+ } finally {
797
+ state0.a = state0.b = 0;
798
+ }
799
+ };
800
+
801
+ module.exports.__wbg_push_109cfc26d02582dd = function(arg0, arg1) {
802
+ const ret = getObject(arg0).push(getObject(arg1));
803
+ return ret;
804
+ };
805
+
806
+ module.exports.__wbg_reverse_a322332d916e2705 = function(arg0) {
807
+ const ret = getObject(arg0).reverse();
808
+ return addHeapObject(ret);
809
+ };
810
+
811
+ module.exports.__wbg_new_87297f22973157c8 = function(arg0, arg1) {
812
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
813
+ return addHeapObject(ret);
814
+ };
815
+
816
+ module.exports.__wbg_setcause_394738aae0ce9341 = function(arg0, arg1) {
817
+ getObject(arg0).cause = getObject(arg1);
818
+ };
819
+
820
+ module.exports.__wbg_call_587b30eea3e09332 = function() { return handleError(function (arg0, arg1, arg2) {
821
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
822
+ return addHeapObject(ret);
823
+ }, arguments) };
824
+
825
+ module.exports.__wbg_call_4c73e4aecced6a7d = function() { return handleError(function (arg0, arg1, arg2, arg3) {
826
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3));
827
+ return addHeapObject(ret);
828
+ }, arguments) };
829
+
830
+ module.exports.__wbg_forEach_942772130a8d06a6 = function(arg0, arg1, arg2) {
831
+ try {
832
+ var state0 = {a: arg1, b: arg2};
833
+ var cb0 = (arg0, arg1) => {
834
+ const a = state0.a;
835
+ state0.a = 0;
836
+ try {
837
+ return __wbg_adapter_92(a, state0.b, arg0, arg1);
838
+ } finally {
839
+ state0.a = a;
840
+ }
841
+ };
842
+ getObject(arg0).forEach(cb0);
843
+ } finally {
844
+ state0.a = state0.b = 0;
845
+ }
846
+ };
847
+
848
+ module.exports.__wbg_set_da7be7bf0e037b14 = function(arg0, arg1, arg2) {
849
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
850
+ return addHeapObject(ret);
851
+ };
852
+
853
+ module.exports.__wbg_fromEntries_d1b310956d20d858 = function() { return handleError(function (arg0) {
854
+ const ret = Object.fromEntries(getObject(arg0));
855
+ return addHeapObject(ret);
856
+ }, arguments) };
857
+
858
+ module.exports.__wbg_values_099fd000c271c313 = function(arg0) {
859
+ const ret = Object.values(getObject(arg0));
860
+ return addHeapObject(ret);
861
+ };
862
+
863
+ module.exports.__wbg_new_2b55e405e4af4986 = function(arg0, arg1) {
864
+ try {
865
+ var state0 = {a: arg0, b: arg1};
866
+ var cb0 = (arg0, arg1) => {
867
+ const a = state0.a;
868
+ state0.a = 0;
869
+ try {
870
+ return __wbg_adapter_92(a, state0.b, arg0, arg1);
871
+ } finally {
872
+ state0.a = a;
873
+ }
874
+ };
875
+ const ret = new Promise(cb0);
876
+ return addHeapObject(ret);
877
+ } finally {
878
+ state0.a = state0.b = 0;
879
+ }
880
+ };
881
+
882
+ module.exports.__wbg_resolve_ae38ad63c43ff98b = function(arg0) {
883
+ const ret = Promise.resolve(getObject(arg0));
884
+ return addHeapObject(ret);
885
+ };
886
+
887
+ module.exports.__wbg_then_8df675b8bb5d5e3c = function(arg0, arg1) {
888
+ const ret = getObject(arg0).then(getObject(arg1));
889
+ return addHeapObject(ret);
890
+ };
891
+
892
+ module.exports.__wbg_then_835b073a479138e5 = function(arg0, arg1, arg2) {
893
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
894
+ return addHeapObject(ret);
895
+ };
896
+
897
+ module.exports.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
898
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
899
+ return addHeapObject(ret);
900
+ }, arguments) };
901
+
902
+ module.exports.__wbg_set_07da13cc24b69217 = function() { return handleError(function (arg0, arg1, arg2) {
903
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
904
+ return ret;
905
+ }, arguments) };
906
+
907
+ module.exports.__wbindgen_debug_string = function(arg0, arg1) {
908
+ const ret = debugString(getObject(arg1));
909
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
910
+ const len1 = WASM_VECTOR_LEN;
911
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
912
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
913
+ };
914
+
915
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
916
+ throw new Error(getStringFromWasm0(arg0, arg1));
917
+ };
918
+
919
+ module.exports.__wbindgen_closure_wrapper767 = function(arg0, arg1, arg2) {
920
+ const ret = makeMutClosure(arg0, arg1, 301, __wbg_adapter_22);
921
+ return addHeapObject(ret);
922
+ };
923
+
924
+ const path = require('path').join(__dirname, 'acvm_js_bg.wasm');
925
+ const bytes = require('fs').readFileSync(path);
926
+
927
+ const wasmModule = new WebAssembly.Module(bytes);
928
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
929
+ wasm = wasmInstance.exports;
930
+ module.exports.__wasm = wasm;
931
+