@noir-lang/acvm_js 0.46.0-ff7bb72.nightly → 0.47.0-03e25b4.nightly

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.
@@ -1,34 +1,39 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
4
+ * Sets the package's logging level.
5
5
  *
6
- * @param {WitnessMap} witness_map - A witness map.
7
- * @returns {Uint8Array} A compressed witness map
6
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
8
7
  */
9
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
8
+ export function initLogLevel(filter: string): void;
10
9
  /**
11
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
12
- * This should be used to only fetch the witness map for the main function.
10
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
13
11
  *
14
- * @param {Uint8Array} compressed_witness - A compressed witness.
15
- * @returns {WitnessMap} The decompressed witness map.
12
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
13
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
14
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
15
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
16
16
  */
17
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
17
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
18
18
  /**
19
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
19
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
20
+ * This method also extracts the public return values from the solved witness into its own return witness.
20
21
  *
21
- * @param {WitnessStack} witness_stack - A witness stack.
22
- * @returns {Uint8Array} A compressed witness stack
22
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
23
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
24
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
25
+ * @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.
23
26
  */
24
- export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
27
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
25
28
  /**
26
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
29
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
27
30
  *
28
- * @param {Uint8Array} compressed_witness - A compressed witness.
29
- * @returns {WitnessStack} The decompressed witness stack.
31
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
32
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
33
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
34
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
30
35
  */
31
- export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
36
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
32
37
  /**
33
38
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
34
39
  *
@@ -63,40 +68,6 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
63
68
  */
64
69
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
65
70
  /**
66
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
67
- *
68
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
69
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
70
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
71
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
72
- */
73
- export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
74
- /**
75
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
76
- * This method also extracts the public return values from the solved witness into its own return witness.
77
- *
78
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
79
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
80
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
81
- * @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.
82
- */
83
- export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
84
- /**
85
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
86
- *
87
- * @param {Uint8Array} program - A serialized representation of an ACIR program
88
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
89
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
90
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
91
- */
92
- export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
93
- /**
94
- * Sets the package's logging level.
95
- *
96
- * @param {LogLevel} level - The maximum level of logging to be emitted.
97
- */
98
- export function initLogLevel(filter: string): void;
99
- /**
100
71
  * Performs a bitwise AND operation between `lhs` and `rhs`
101
72
  * @param {string} lhs
102
73
  * @param {string} rhs
@@ -151,17 +122,35 @@ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_byte
151
122
  * @returns {BuildInfo} - Information on how the installed package was built.
152
123
  */
153
124
  export function buildInfo(): BuildInfo;
154
-
155
- export type RawAssertionPayload = {
156
- selector: string;
157
- data: string[];
158
- };
159
- export type ExecutionError = Error & {
160
- callStack?: string[];
161
- rawAssertionPayload?: RawAssertionPayload;
162
- };
163
-
164
-
125
+ /**
126
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
127
+ *
128
+ * @param {WitnessMap} witness_map - A witness map.
129
+ * @returns {Uint8Array} A compressed witness map
130
+ */
131
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
132
+ /**
133
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
134
+ * This should be used to only fetch the witness map for the main function.
135
+ *
136
+ * @param {Uint8Array} compressed_witness - A compressed witness.
137
+ * @returns {WitnessMap} The decompressed witness map.
138
+ */
139
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
140
+ /**
141
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
142
+ *
143
+ * @param {WitnessStack} witness_stack - A witness stack.
144
+ * @returns {Uint8Array} A compressed witness stack
145
+ */
146
+ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
147
+ /**
148
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
149
+ *
150
+ * @param {Uint8Array} compressed_witness - A compressed witness.
151
+ * @returns {WitnessStack} The decompressed witness stack.
152
+ */
153
+ export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
165
154
 
166
155
  export type ForeignCallInput = string[]
167
156
  export type ForeignCallOutput = string | string[]
@@ -177,6 +166,26 @@ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => P
177
166
 
178
167
 
179
168
 
169
+ export type StackItem = {
170
+ index: number;
171
+ witness: WitnessMap;
172
+ }
173
+
174
+ export type WitnessStack = Array<StackItem>;
175
+
176
+
177
+
178
+ export type RawAssertionPayload = {
179
+ selector: string;
180
+ data: string[];
181
+ };
182
+ export type ExecutionError = Error & {
183
+ callStack?: string[];
184
+ rawAssertionPayload?: RawAssertionPayload;
185
+ };
186
+
187
+
188
+
180
189
  // Map from witness index to hex string value of witness.
181
190
  export type WitnessMap = Map<number, string>;
182
191
 
@@ -192,15 +201,6 @@ export type SolvedAndReturnWitness = {
192
201
 
193
202
 
194
203
 
195
- export type StackItem = {
196
- index: number;
197
- witness: WitnessMap;
198
- }
199
-
200
- export type WitnessStack = Array<StackItem>;
201
-
202
-
203
-
204
204
  /**
205
205
  * @typedef {Object} BuildInfo - Information about how the installed package was built
206
206
  * @property {string} gitHash - The hash of the git commit from which the package was built.
package/nodejs/acvm_js.js CHANGED
@@ -23,6 +23,15 @@ function takeObject(idx) {
23
23
  return ret;
24
24
  }
25
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
+
26
35
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
27
36
 
28
37
  cachedTextDecoder.decode();
@@ -41,15 +50,6 @@ function getStringFromWasm0(ptr, len) {
41
50
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
42
51
  }
43
52
 
44
- function addHeapObject(obj) {
45
- if (heap_next === heap.length) heap.push(heap.length + 1);
46
- const idx = heap_next;
47
- heap_next = heap[idx];
48
-
49
- heap[idx] = obj;
50
- return idx;
51
- }
52
-
53
53
  let WASM_VECTOR_LEN = 0;
54
54
 
55
55
  let cachedTextEncoder = new TextEncoder('utf-8');
@@ -220,30 +220,22 @@ function __wbg_adapter_22(arg0, arg1, arg2) {
220
220
  wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h36bac5ff3ea3c380(arg0, arg1, addHeapObject(arg2));
221
221
  }
222
222
 
223
- function getArrayU8FromWasm0(ptr, len) {
224
- ptr = ptr >>> 0;
225
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
226
- }
227
223
  /**
228
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
224
+ * Sets the package's logging level.
229
225
  *
230
- * @param {WitnessMap} witness_map - A witness map.
231
- * @returns {Uint8Array} A compressed witness map
226
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
232
227
  */
233
- module.exports.compressWitness = function(witness_map) {
228
+ module.exports.initLogLevel = function(filter) {
234
229
  try {
235
230
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
236
- wasm.compressWitness(retptr, addHeapObject(witness_map));
231
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
232
+ const len0 = WASM_VECTOR_LEN;
233
+ wasm.initLogLevel(retptr, ptr0, len0);
237
234
  var r0 = getInt32Memory0()[retptr / 4 + 0];
238
235
  var r1 = getInt32Memory0()[retptr / 4 + 1];
239
- var r2 = getInt32Memory0()[retptr / 4 + 2];
240
- var r3 = getInt32Memory0()[retptr / 4 + 3];
241
- if (r3) {
242
- throw takeObject(r2);
236
+ if (r1) {
237
+ throw takeObject(r0);
243
238
  }
244
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
245
- wasm.__wbindgen_free(r0, r1 * 1);
246
- return v1;
247
239
  } finally {
248
240
  wasm.__wbindgen_add_to_stack_pointer(16);
249
241
  }
@@ -256,77 +248,49 @@ function passArray8ToWasm0(arg, malloc) {
256
248
  return ptr;
257
249
  }
258
250
  /**
259
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
260
- * This should be used to only fetch the witness map for the main function.
251
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
261
252
  *
262
- * @param {Uint8Array} compressed_witness - A compressed witness.
263
- * @returns {WitnessMap} The decompressed witness map.
253
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
254
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
255
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
256
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
264
257
  */
265
- module.exports.decompressWitness = function(compressed_witness) {
266
- try {
267
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
268
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
269
- const len0 = WASM_VECTOR_LEN;
270
- wasm.decompressWitness(retptr, ptr0, len0);
271
- var r0 = getInt32Memory0()[retptr / 4 + 0];
272
- var r1 = getInt32Memory0()[retptr / 4 + 1];
273
- var r2 = getInt32Memory0()[retptr / 4 + 2];
274
- if (r2) {
275
- throw takeObject(r1);
276
- }
277
- return takeObject(r0);
278
- } finally {
279
- wasm.__wbindgen_add_to_stack_pointer(16);
280
- }
258
+ module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
259
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
260
+ const len0 = WASM_VECTOR_LEN;
261
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
262
+ return takeObject(ret);
281
263
  };
282
264
 
283
265
  /**
284
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
266
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
267
+ * This method also extracts the public return values from the solved witness into its own return witness.
285
268
  *
286
- * @param {WitnessStack} witness_stack - A witness stack.
287
- * @returns {Uint8Array} A compressed witness stack
269
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
270
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
271
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
272
+ * @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.
288
273
  */
289
- module.exports.compressWitnessStack = function(witness_stack) {
290
- try {
291
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
292
- wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
293
- var r0 = getInt32Memory0()[retptr / 4 + 0];
294
- var r1 = getInt32Memory0()[retptr / 4 + 1];
295
- var r2 = getInt32Memory0()[retptr / 4 + 2];
296
- var r3 = getInt32Memory0()[retptr / 4 + 3];
297
- if (r3) {
298
- throw takeObject(r2);
299
- }
300
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
301
- wasm.__wbindgen_free(r0, r1 * 1);
302
- return v1;
303
- } finally {
304
- wasm.__wbindgen_add_to_stack_pointer(16);
305
- }
274
+ module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
275
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
276
+ const len0 = WASM_VECTOR_LEN;
277
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
278
+ return takeObject(ret);
306
279
  };
307
280
 
308
281
  /**
309
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
282
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
310
283
  *
311
- * @param {Uint8Array} compressed_witness - A compressed witness.
312
- * @returns {WitnessStack} The decompressed witness stack.
284
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
285
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
286
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
287
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
313
288
  */
314
- module.exports.decompressWitnessStack = function(compressed_witness) {
315
- try {
316
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
317
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
318
- const len0 = WASM_VECTOR_LEN;
319
- wasm.decompressWitnessStack(retptr, ptr0, len0);
320
- var r0 = getInt32Memory0()[retptr / 4 + 0];
321
- var r1 = getInt32Memory0()[retptr / 4 + 1];
322
- var r2 = getInt32Memory0()[retptr / 4 + 2];
323
- if (r2) {
324
- throw takeObject(r1);
325
- }
326
- return takeObject(r0);
327
- } finally {
328
- wasm.__wbindgen_add_to_stack_pointer(16);
329
- }
289
+ module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
290
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
291
+ const len0 = WASM_VECTOR_LEN;
292
+ const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
293
+ return takeObject(ret);
330
294
  };
331
295
 
332
296
  /**
@@ -413,73 +377,6 @@ module.exports.getPublicWitness = function(program, solved_witness) {
413
377
  }
414
378
  };
415
379
 
416
- /**
417
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
418
- *
419
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
420
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
421
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
422
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
423
- */
424
- module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
425
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
426
- const len0 = WASM_VECTOR_LEN;
427
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
428
- return takeObject(ret);
429
- };
430
-
431
- /**
432
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
433
- * This method also extracts the public return values from the solved witness into its own return witness.
434
- *
435
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
436
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
437
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
438
- * @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.
439
- */
440
- module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
441
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
442
- const len0 = WASM_VECTOR_LEN;
443
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
444
- return takeObject(ret);
445
- };
446
-
447
- /**
448
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
449
- *
450
- * @param {Uint8Array} program - A serialized representation of an ACIR program
451
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
452
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
453
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
454
- */
455
- module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
456
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
457
- const len0 = WASM_VECTOR_LEN;
458
- const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
459
- return takeObject(ret);
460
- };
461
-
462
- /**
463
- * Sets the package's logging level.
464
- *
465
- * @param {LogLevel} level - The maximum level of logging to be emitted.
466
- */
467
- module.exports.initLogLevel = function(filter) {
468
- try {
469
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
470
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
471
- const len0 = WASM_VECTOR_LEN;
472
- wasm.initLogLevel(retptr, ptr0, len0);
473
- var r0 = getInt32Memory0()[retptr / 4 + 0];
474
- var r1 = getInt32Memory0()[retptr / 4 + 1];
475
- if (r1) {
476
- throw takeObject(r0);
477
- }
478
- } finally {
479
- wasm.__wbindgen_add_to_stack_pointer(16);
480
- }
481
- };
482
-
483
380
  /**
484
381
  * Performs a bitwise AND operation between `lhs` and `rhs`
485
382
  * @param {string} lhs
@@ -502,6 +399,10 @@ module.exports.xor = function(lhs, rhs) {
502
399
  return takeObject(ret);
503
400
  };
504
401
 
402
+ function getArrayU8FromWasm0(ptr, len) {
403
+ ptr = ptr >>> 0;
404
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
405
+ }
505
406
  /**
506
407
  * Calculates the SHA256 hash of the input bytes
507
408
  * @param {Uint8Array} inputs
@@ -616,6 +517,105 @@ module.exports.buildInfo = function() {
616
517
  return takeObject(ret);
617
518
  };
618
519
 
520
+ /**
521
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
522
+ *
523
+ * @param {WitnessMap} witness_map - A witness map.
524
+ * @returns {Uint8Array} A compressed witness map
525
+ */
526
+ module.exports.compressWitness = function(witness_map) {
527
+ try {
528
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
529
+ wasm.compressWitness(retptr, addHeapObject(witness_map));
530
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
531
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
532
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
533
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
534
+ if (r3) {
535
+ throw takeObject(r2);
536
+ }
537
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
538
+ wasm.__wbindgen_free(r0, r1 * 1);
539
+ return v1;
540
+ } finally {
541
+ wasm.__wbindgen_add_to_stack_pointer(16);
542
+ }
543
+ };
544
+
545
+ /**
546
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
547
+ * This should be used to only fetch the witness map for the main function.
548
+ *
549
+ * @param {Uint8Array} compressed_witness - A compressed witness.
550
+ * @returns {WitnessMap} The decompressed witness map.
551
+ */
552
+ module.exports.decompressWitness = function(compressed_witness) {
553
+ try {
554
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
555
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
556
+ const len0 = WASM_VECTOR_LEN;
557
+ wasm.decompressWitness(retptr, ptr0, len0);
558
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
559
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
560
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
561
+ if (r2) {
562
+ throw takeObject(r1);
563
+ }
564
+ return takeObject(r0);
565
+ } finally {
566
+ wasm.__wbindgen_add_to_stack_pointer(16);
567
+ }
568
+ };
569
+
570
+ /**
571
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
572
+ *
573
+ * @param {WitnessStack} witness_stack - A witness stack.
574
+ * @returns {Uint8Array} A compressed witness stack
575
+ */
576
+ module.exports.compressWitnessStack = function(witness_stack) {
577
+ try {
578
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
579
+ wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
580
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
581
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
582
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
583
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
584
+ if (r3) {
585
+ throw takeObject(r2);
586
+ }
587
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
588
+ wasm.__wbindgen_free(r0, r1 * 1);
589
+ return v1;
590
+ } finally {
591
+ wasm.__wbindgen_add_to_stack_pointer(16);
592
+ }
593
+ };
594
+
595
+ /**
596
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
597
+ *
598
+ * @param {Uint8Array} compressed_witness - A compressed witness.
599
+ * @returns {WitnessStack} The decompressed witness stack.
600
+ */
601
+ module.exports.decompressWitnessStack = function(compressed_witness) {
602
+ try {
603
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
604
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
605
+ const len0 = WASM_VECTOR_LEN;
606
+ wasm.decompressWitnessStack(retptr, ptr0, len0);
607
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
608
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
609
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
610
+ if (r2) {
611
+ throw takeObject(r1);
612
+ }
613
+ return takeObject(r0);
614
+ } finally {
615
+ wasm.__wbindgen_add_to_stack_pointer(16);
616
+ }
617
+ };
618
+
619
619
  function __wbg_adapter_76(arg0, arg1, arg2, arg3, arg4) {
620
620
  wasm.wasm_bindgen__convert__closures__invoke3_mut__h629417323d5efbaa(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
621
621
  }
@@ -635,16 +635,6 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
635
635
  takeObject(arg0);
636
636
  };
637
637
 
638
- module.exports.__wbg_constructor_81b34c49dcbdd2af = function(arg0) {
639
- const ret = new Error(takeObject(arg0));
640
- return addHeapObject(ret);
641
- };
642
-
643
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
644
- const ret = getStringFromWasm0(arg0, arg1);
645
- return addHeapObject(ret);
646
- };
647
-
648
638
  module.exports.__wbindgen_cb_drop = function(arg0) {
649
639
  const obj = takeObject(arg0).original;
650
640
  if (obj.cnt-- == 1) {
@@ -655,21 +645,36 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
655
645
  return ret;
656
646
  };
657
647
 
648
+ module.exports.__wbg_new_f139361aad331bd0 = function() {
649
+ const ret = new Array();
650
+ return addHeapObject(ret);
651
+ };
652
+
653
+ module.exports.__wbindgen_number_new = function(arg0) {
654
+ const ret = arg0;
655
+ return addHeapObject(ret);
656
+ };
657
+
658
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
659
+ const ret = getStringFromWasm0(arg0, arg1);
660
+ return addHeapObject(ret);
661
+ };
662
+
663
+ module.exports.__wbg_constructor_971e67e66cc5bd6a = function(arg0) {
664
+ const ret = new Error(takeObject(arg0));
665
+ return addHeapObject(ret);
666
+ };
667
+
658
668
  module.exports.__wbindgen_is_array = function(arg0) {
659
669
  const ret = Array.isArray(getObject(arg0));
660
670
  return ret;
661
671
  };
662
672
 
663
- module.exports.__wbg_new_6f6c75f9324b78e8 = function() {
673
+ module.exports.__wbg_new_193bac1dd2be232d = function() {
664
674
  const ret = new Map();
665
675
  return addHeapObject(ret);
666
676
  };
667
677
 
668
- module.exports.__wbindgen_number_new = function(arg0) {
669
- const ret = arg0;
670
- return addHeapObject(ret);
671
- };
672
-
673
678
  module.exports.__wbindgen_string_get = function(arg0, arg1) {
674
679
  const obj = getObject(arg1);
675
680
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -686,11 +691,6 @@ module.exports.__wbindgen_number_get = function(arg0, arg1) {
686
691
  getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
687
692
  };
688
693
 
689
- module.exports.__wbg_new_ee5ac63ff3b0fa4d = function() {
690
- const ret = new Array();
691
- return addHeapObject(ret);
692
- };
693
-
694
694
  module.exports.__wbindgen_is_string = function(arg0) {
695
695
  const ret = typeof(getObject(arg0)) === 'string';
696
696
  return ret;
@@ -914,8 +914,8 @@ module.exports.__wbindgen_throw = function(arg0, arg1) {
914
914
  throw new Error(getStringFromWasm0(arg0, arg1));
915
915
  };
916
916
 
917
- module.exports.__wbindgen_closure_wrapper739 = function(arg0, arg1, arg2) {
918
- const ret = makeMutClosure(arg0, arg1, 240, __wbg_adapter_22);
917
+ module.exports.__wbindgen_closure_wrapper743 = function(arg0, arg1, arg2) {
918
+ const ret = makeMutClosure(arg0, arg1, 241, __wbg_adapter_22);
919
919
  return addHeapObject(ret);
920
920
  };
921
921
 
Binary file
@@ -1,17 +1,13 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function compressWitness(a: number, b: number): void;
5
- export function decompressWitness(a: number, b: number, c: number): void;
6
- export function compressWitnessStack(a: number, b: number): void;
7
- export function decompressWitnessStack(a: number, b: number, c: number): void;
8
- export function getReturnWitness(a: number, b: number, c: number, d: number): void;
9
- export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
10
- export function getPublicWitness(a: number, b: number, c: number, d: number): void;
4
+ export function initLogLevel(a: number, b: number, c: number): void;
11
5
  export function executeCircuit(a: number, b: number, c: number, d: number): number;
12
6
  export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
13
7
  export function executeProgram(a: number, b: number, c: number, d: number): number;
14
- export function initLogLevel(a: number, b: number, c: number): void;
8
+ export function getReturnWitness(a: number, b: number, c: number, d: number): void;
9
+ export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
10
+ export function getPublicWitness(a: number, b: number, c: number, d: number): void;
15
11
  export function and(a: number, b: number): number;
16
12
  export function xor(a: number, b: number): number;
17
13
  export function sha256(a: number, b: number, c: number): void;
@@ -20,6 +16,10 @@ export function keccak256(a: number, b: number, c: number): void;
20
16
  export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
21
17
  export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
22
18
  export function buildInfo(): number;
19
+ export function compressWitness(a: number, b: number): void;
20
+ export function decompressWitness(a: number, b: number, c: number): void;
21
+ export function compressWitnessStack(a: number, b: number): void;
22
+ export function decompressWitnessStack(a: number, b: number, c: number): void;
23
23
  export function __wbindgen_malloc(a: number): number;
24
24
  export function __wbindgen_realloc(a: number, b: number, c: number): number;
25
25
  export const __wbindgen_export_2: WebAssembly.Table;