@aztec/noir-acvm_js 0.0.1-commit.7d4e6cd → 0.0.1-commit.8afd444

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,11 +1,63 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Sets the package's logging level.
4
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
5
+ * @returns {BuildInfo} - Information on how the installed package was built.
6
+ */
7
+ export function buildInfo(): BuildInfo;
8
+ /**
9
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
5
10
  *
6
- * @param {LogLevel} level - The maximum level of logging to be emitted.
11
+ * @param {WitnessMap} witness_map - A witness map.
12
+ * @returns {Uint8Array} A compressed witness map
7
13
  */
8
- export function initLogLevel(filter: string): void;
14
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
15
+ /**
16
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
17
+ * This should be used to only fetch the witness map for the main function.
18
+ *
19
+ * @param {Uint8Array} compressed_witness - A compressed witness.
20
+ * @returns {WitnessMap} The decompressed witness map.
21
+ */
22
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
23
+ /**
24
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
25
+ *
26
+ * @param {WitnessStack} witness_stack - A witness stack.
27
+ * @returns {Uint8Array} A compressed witness stack
28
+ */
29
+ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
30
+ /**
31
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
32
+ *
33
+ * @param {Uint8Array} compressed_witness - A compressed witness.
34
+ * @returns {WitnessStack} The decompressed witness stack.
35
+ */
36
+ export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
37
+ /**
38
+ * Performs a bitwise AND operation between `lhs` and `rhs`
39
+ */
40
+ export function and(lhs: string, rhs: string): string;
41
+ /**
42
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
43
+ */
44
+ export function xor(lhs: string, rhs: string): string;
45
+ /**
46
+ * Sha256 compression function
47
+ */
48
+ export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
49
+ /**
50
+ * Calculates the Blake2s256 hash of the input bytes
51
+ */
52
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
53
+ /**
54
+ * Verifies a ECDSA signature over the secp256k1 curve.
55
+ */
56
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
57
+ /**
58
+ * Verifies a ECDSA signature over the secp256r1 curve.
59
+ */
60
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
9
61
  /**
10
62
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
11
63
  *
@@ -34,6 +86,12 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
34
86
  * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
35
87
  */
36
88
  export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
89
+ /**
90
+ * Sets the package's logging level.
91
+ *
92
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
93
+ */
94
+ export function initLogLevel(filter: string): void;
37
95
  /**
38
96
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
39
97
  *
@@ -58,90 +116,26 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
58
116
  * @returns {WitnessMap} A witness map containing the circuit's public inputs.
59
117
  */
60
118
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
61
- /**
62
- * Performs a bitwise AND operation between `lhs` and `rhs`
63
- */
64
- export function and(lhs: string, rhs: string): string;
65
- /**
66
- * Performs a bitwise XOR operation between `lhs` and `rhs`
67
- */
68
- export function xor(lhs: string, rhs: string): string;
69
- /**
70
- * Sha256 compression function
71
- */
72
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
73
- /**
74
- * Calculates the Blake2s256 hash of the input bytes
75
- */
76
- export function blake2s256(inputs: Uint8Array): Uint8Array;
77
- /**
78
- * Verifies a ECDSA signature over the secp256k1 curve.
79
- */
80
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
81
- /**
82
- * Verifies a ECDSA signature over the secp256r1 curve.
83
- */
84
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
85
- /**
86
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
87
- *
88
- * @param {WitnessMap} witness_map - A witness map.
89
- * @returns {Uint8Array} A compressed witness map
90
- */
91
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
92
- /**
93
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
94
- * This should be used to only fetch the witness map for the main function.
95
- *
96
- * @param {Uint8Array} compressed_witness - A compressed witness.
97
- * @returns {WitnessMap} The decompressed witness map.
98
- */
99
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
100
- /**
101
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
102
- *
103
- * @param {WitnessStack} witness_stack - A witness stack.
104
- * @returns {Uint8Array} A compressed witness stack
105
- */
106
- export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
107
- /**
108
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
109
- *
110
- * @param {Uint8Array} compressed_witness - A compressed witness.
111
- * @returns {WitnessStack} The decompressed witness stack.
112
- */
113
- export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
114
- /**
115
- * Returns the `BuildInfo` object containing information about how the installed package was built.
116
- * @returns {BuildInfo} - Information on how the installed package was built.
117
- */
118
- export function buildInfo(): BuildInfo;
119
-
120
- export type RawAssertionPayload = {
121
- selector: string;
122
- data: string[];
123
- };
124
119
 
125
- export type ExecutionError = Error & {
126
- callStack?: string[];
127
- rawAssertionPayload?: RawAssertionPayload;
128
- acirFunctionId?: number;
129
- brilligFunctionId?: number;
130
- };
120
+ export type StackItem = {
121
+ index: number;
122
+ witness: WitnessMap;
123
+ }
131
124
 
125
+ export type WitnessStack = Array<StackItem>;
132
126
 
133
127
 
134
- // Map from witness index to hex string value of witness.
135
- export type WitnessMap = Map<number, string>;
136
128
 
137
129
  /**
138
- * An execution result containing two witnesses.
139
- * 1. The full solved witness of the execution.
140
- * 2. The return witness which contains the given public return values within the full witness.
130
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
131
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
132
+ * @property {string} version - The version of the package at the built git commit.
133
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
141
134
  */
142
- export type SolvedAndReturnWitness = {
143
- solvedWitness: WitnessMap;
144
- returnWitness: WitnessMap;
135
+ export type BuildInfo = {
136
+ gitHash: string;
137
+ version: string;
138
+ dirty: string;
145
139
  }
146
140
 
147
141
 
@@ -160,25 +154,31 @@ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => P
160
154
 
161
155
 
162
156
 
163
- export type StackItem = {
164
- index: number;
165
- witness: WitnessMap;
166
- }
157
+ export type RawAssertionPayload = {
158
+ selector: string;
159
+ data: string[];
160
+ };
167
161
 
168
- export type WitnessStack = Array<StackItem>;
162
+ export type ExecutionError = Error & {
163
+ callStack?: string[];
164
+ rawAssertionPayload?: RawAssertionPayload;
165
+ acirFunctionId?: number;
166
+ brilligFunctionId?: number;
167
+ };
169
168
 
170
169
 
171
170
 
171
+ // Map from witness index to hex string value of witness.
172
+ export type WitnessMap = Map<number, string>;
173
+
172
174
  /**
173
- * @typedef {Object} BuildInfo - Information about how the installed package was built
174
- * @property {string} gitHash - The hash of the git commit from which the package was built.
175
- * @property {string} version - The version of the package at the built git commit.
176
- * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
175
+ * An execution result containing two witnesses.
176
+ * 1. The full solved witness of the execution.
177
+ * 2. The return witness which contains the given public return values within the full witness.
177
178
  */
178
- export type BuildInfo = {
179
- gitHash: string;
180
- version: string;
181
- dirty: string;
179
+ export type SolvedAndReturnWitness = {
180
+ solvedWitness: WitnessMap;
181
+ returnWitness: WitnessMap;
182
182
  }
183
183
 
184
184
 
package/nodejs/acvm_js.js CHANGED
@@ -201,24 +201,39 @@ function debugString(val) {
201
201
  // TODO we could test for more things here, like `Set`s and `Map`s.
202
202
  return className;
203
203
  }
204
+ /**
205
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
206
+ * @returns {BuildInfo} - Information on how the installed package was built.
207
+ */
208
+ module.exports.buildInfo = function() {
209
+ const ret = wasm.buildInfo();
210
+ return ret;
211
+ };
204
212
 
205
213
  function takeFromExternrefTable0(idx) {
206
214
  const value = wasm.__wbindgen_export_2.get(idx);
207
215
  wasm.__externref_table_dealloc(idx);
208
216
  return value;
209
217
  }
218
+
219
+ function getArrayU8FromWasm0(ptr, len) {
220
+ ptr = ptr >>> 0;
221
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
222
+ }
210
223
  /**
211
- * Sets the package's logging level.
224
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
212
225
  *
213
- * @param {LogLevel} level - The maximum level of logging to be emitted.
226
+ * @param {WitnessMap} witness_map - A witness map.
227
+ * @returns {Uint8Array} A compressed witness map
214
228
  */
215
- module.exports.initLogLevel = function(filter) {
216
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
217
- const len0 = WASM_VECTOR_LEN;
218
- const ret = wasm.initLogLevel(ptr0, len0);
219
- if (ret[1]) {
220
- throw takeFromExternrefTable0(ret[0]);
229
+ module.exports.compressWitness = function(witness_map) {
230
+ const ret = wasm.compressWitness(witness_map);
231
+ if (ret[3]) {
232
+ throw takeFromExternrefTable0(ret[2]);
221
233
  }
234
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
235
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
236
+ return v1;
222
237
  };
223
238
 
224
239
  function passArray8ToWasm0(arg, malloc) {
@@ -228,65 +243,16 @@ function passArray8ToWasm0(arg, malloc) {
228
243
  return ptr;
229
244
  }
230
245
  /**
231
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
232
- *
233
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
234
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
235
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
236
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
237
- */
238
- module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
239
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
240
- const len0 = WASM_VECTOR_LEN;
241
- const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
242
- return ret;
243
- };
244
-
245
- /**
246
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
247
- * This method also extracts the public return values from the solved witness into its own return witness.
248
- *
249
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
250
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
251
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
252
- * @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.
253
- */
254
- module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
255
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
256
- const len0 = WASM_VECTOR_LEN;
257
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
258
- return ret;
259
- };
260
-
261
- /**
262
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
263
- *
264
- * @param {Uint8Array} program - A serialized representation of an ACIR program
265
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
266
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
267
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
268
- */
269
- module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
270
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
271
- const len0 = WASM_VECTOR_LEN;
272
- const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
273
- return ret;
274
- };
275
-
276
- /**
277
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
246
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
247
+ * This should be used to only fetch the witness map for the main function.
278
248
  *
279
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
280
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
281
- * @returns {WitnessMap} A witness map containing the circuit's return values.
282
- * @param {Uint8Array} program
283
- * @param {WitnessMap} witness_map
284
- * @returns {WitnessMap}
249
+ * @param {Uint8Array} compressed_witness - A compressed witness.
250
+ * @returns {WitnessMap} The decompressed witness map.
285
251
  */
286
- module.exports.getReturnWitness = function(program, witness_map) {
287
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
252
+ module.exports.decompressWitness = function(compressed_witness) {
253
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
288
254
  const len0 = WASM_VECTOR_LEN;
289
- const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
255
+ const ret = wasm.decompressWitness(ptr0, len0);
290
256
  if (ret[2]) {
291
257
  throw takeFromExternrefTable0(ret[1]);
292
258
  }
@@ -294,39 +260,31 @@ module.exports.getReturnWitness = function(program, witness_map) {
294
260
  };
295
261
 
296
262
  /**
297
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
263
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
298
264
  *
299
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
300
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
301
- * @returns {WitnessMap} A witness map containing the circuit's public parameters.
302
- * @param {Uint8Array} program
303
- * @param {WitnessMap} solved_witness
304
- * @returns {WitnessMap}
265
+ * @param {WitnessStack} witness_stack - A witness stack.
266
+ * @returns {Uint8Array} A compressed witness stack
305
267
  */
306
- module.exports.getPublicParametersWitness = function(program, solved_witness) {
307
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
308
- const len0 = WASM_VECTOR_LEN;
309
- const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
310
- if (ret[2]) {
311
- throw takeFromExternrefTable0(ret[1]);
268
+ module.exports.compressWitnessStack = function(witness_stack) {
269
+ const ret = wasm.compressWitnessStack(witness_stack);
270
+ if (ret[3]) {
271
+ throw takeFromExternrefTable0(ret[2]);
312
272
  }
313
- return takeFromExternrefTable0(ret[0]);
273
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
274
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
275
+ return v1;
314
276
  };
315
277
 
316
278
  /**
317
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
279
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
318
280
  *
319
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
320
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
321
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
322
- * @param {Uint8Array} program
323
- * @param {WitnessMap} solved_witness
324
- * @returns {WitnessMap}
281
+ * @param {Uint8Array} compressed_witness - A compressed witness.
282
+ * @returns {WitnessStack} The decompressed witness stack.
325
283
  */
326
- module.exports.getPublicWitness = function(program, solved_witness) {
327
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
284
+ module.exports.decompressWitnessStack = function(compressed_witness) {
285
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
328
286
  const len0 = WASM_VECTOR_LEN;
329
- const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
287
+ const ret = wasm.decompressWitnessStack(ptr0, len0);
330
288
  if (ret[2]) {
331
289
  throw takeFromExternrefTable0(ret[1]);
332
290
  }
@@ -392,10 +350,6 @@ module.exports.sha256_compression = function(inputs, state) {
392
350
  return v3;
393
351
  };
394
352
 
395
- function getArrayU8FromWasm0(ptr, len) {
396
- ptr = ptr >>> 0;
397
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
398
- }
399
353
  /**
400
354
  * Calculates the Blake2s256 hash of the input bytes
401
355
  * @param {Uint8Array} inputs
@@ -453,64 +407,99 @@ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes,
453
407
  };
454
408
 
455
409
  /**
456
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
410
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
457
411
  *
458
- * @param {WitnessMap} witness_map - A witness map.
459
- * @returns {Uint8Array} A compressed witness map
412
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
413
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
414
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
415
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
460
416
  */
461
- module.exports.compressWitness = function(witness_map) {
462
- const ret = wasm.compressWitness(witness_map);
463
- if (ret[3]) {
464
- throw takeFromExternrefTable0(ret[2]);
465
- }
466
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
467
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
468
- return v1;
417
+ module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
418
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
419
+ const len0 = WASM_VECTOR_LEN;
420
+ const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
421
+ return ret;
469
422
  };
470
423
 
471
424
  /**
472
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
473
- * This should be used to only fetch the witness map for the main function.
425
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
426
+ * This method also extracts the public return values from the solved witness into its own return witness.
474
427
  *
475
- * @param {Uint8Array} compressed_witness - A compressed witness.
476
- * @returns {WitnessMap} The decompressed witness map.
428
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
429
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
430
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
431
+ * @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.
477
432
  */
478
- module.exports.decompressWitness = function(compressed_witness) {
479
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
433
+ module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
434
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
480
435
  const len0 = WASM_VECTOR_LEN;
481
- const ret = wasm.decompressWitness(ptr0, len0);
482
- if (ret[2]) {
483
- throw takeFromExternrefTable0(ret[1]);
436
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
437
+ return ret;
438
+ };
439
+
440
+ /**
441
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
442
+ *
443
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
444
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
445
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
446
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
447
+ */
448
+ module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
449
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
450
+ const len0 = WASM_VECTOR_LEN;
451
+ const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
452
+ return ret;
453
+ };
454
+
455
+ /**
456
+ * Sets the package's logging level.
457
+ *
458
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
459
+ */
460
+ module.exports.initLogLevel = function(filter) {
461
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
462
+ const len0 = WASM_VECTOR_LEN;
463
+ const ret = wasm.initLogLevel(ptr0, len0);
464
+ if (ret[1]) {
465
+ throw takeFromExternrefTable0(ret[0]);
484
466
  }
485
- return takeFromExternrefTable0(ret[0]);
486
467
  };
487
468
 
488
469
  /**
489
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
470
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
490
471
  *
491
- * @param {WitnessStack} witness_stack - A witness stack.
492
- * @returns {Uint8Array} A compressed witness stack
472
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
473
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
474
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
475
+ * @param {Uint8Array} program
476
+ * @param {WitnessMap} witness_map
477
+ * @returns {WitnessMap}
493
478
  */
494
- module.exports.compressWitnessStack = function(witness_stack) {
495
- const ret = wasm.compressWitnessStack(witness_stack);
496
- if (ret[3]) {
497
- throw takeFromExternrefTable0(ret[2]);
479
+ module.exports.getReturnWitness = function(program, witness_map) {
480
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
481
+ const len0 = WASM_VECTOR_LEN;
482
+ const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
483
+ if (ret[2]) {
484
+ throw takeFromExternrefTable0(ret[1]);
498
485
  }
499
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
500
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
501
- return v1;
486
+ return takeFromExternrefTable0(ret[0]);
502
487
  };
503
488
 
504
489
  /**
505
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
490
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
506
491
  *
507
- * @param {Uint8Array} compressed_witness - A compressed witness.
508
- * @returns {WitnessStack} The decompressed witness stack.
492
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
493
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
494
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
495
+ * @param {Uint8Array} program
496
+ * @param {WitnessMap} solved_witness
497
+ * @returns {WitnessMap}
509
498
  */
510
- module.exports.decompressWitnessStack = function(compressed_witness) {
511
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
499
+ module.exports.getPublicParametersWitness = function(program, solved_witness) {
500
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
512
501
  const len0 = WASM_VECTOR_LEN;
513
- const ret = wasm.decompressWitnessStack(ptr0, len0);
502
+ const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
514
503
  if (ret[2]) {
515
504
  throw takeFromExternrefTable0(ret[1]);
516
505
  }
@@ -518,24 +507,35 @@ module.exports.decompressWitnessStack = function(compressed_witness) {
518
507
  };
519
508
 
520
509
  /**
521
- * Returns the `BuildInfo` object containing information about how the installed package was built.
522
- * @returns {BuildInfo} - Information on how the installed package was built.
510
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
511
+ *
512
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
513
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
514
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
515
+ * @param {Uint8Array} program
516
+ * @param {WitnessMap} solved_witness
517
+ * @returns {WitnessMap}
523
518
  */
524
- module.exports.buildInfo = function() {
525
- const ret = wasm.buildInfo();
526
- return ret;
519
+ module.exports.getPublicWitness = function(program, solved_witness) {
520
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
521
+ const len0 = WASM_VECTOR_LEN;
522
+ const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
523
+ if (ret[2]) {
524
+ throw takeFromExternrefTable0(ret[1]);
525
+ }
526
+ return takeFromExternrefTable0(ret[0]);
527
527
  };
528
528
 
529
529
  function __wbg_adapter_30(arg0, arg1, arg2) {
530
- wasm.closure490_externref_shim(arg0, arg1, arg2);
530
+ wasm.closure448_externref_shim(arg0, arg1, arg2);
531
531
  }
532
532
 
533
533
  function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
534
- wasm.closure996_externref_shim(arg0, arg1, arg2, arg3, arg4);
534
+ wasm.closure933_externref_shim(arg0, arg1, arg2, arg3, arg4);
535
535
  }
536
536
 
537
537
  function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
538
- wasm.closure1000_externref_shim(arg0, arg1, arg2, arg3);
538
+ wasm.closure937_externref_shim(arg0, arg1, arg2, arg3);
539
539
  }
540
540
 
541
541
  module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
@@ -813,8 +813,8 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
813
813
  return ret;
814
814
  };
815
815
 
816
- module.exports.__wbindgen_closure_wrapper1603 = function(arg0, arg1, arg2) {
817
- const ret = makeMutClosure(arg0, arg1, 491, __wbg_adapter_30);
816
+ module.exports.__wbindgen_closure_wrapper1445 = function(arg0, arg1, arg2) {
817
+ const ret = makeMutClosure(arg0, arg1, 449, __wbg_adapter_30);
818
818
  return ret;
819
819
  };
820
820
 
Binary file
@@ -1,24 +1,24 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const initLogLevel: (a: number, b: number) => [number, number];
5
- export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
6
- export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
7
- export const executeProgram: (a: number, b: number, c: any, d: any) => any;
8
- export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
9
- export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
10
- export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
4
+ export const buildInfo: () => any;
5
+ export const compressWitness: (a: any) => [number, number, number, number];
6
+ export const decompressWitness: (a: number, b: number) => [number, number, number];
7
+ export const compressWitnessStack: (a: any) => [number, number, number, number];
8
+ export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
11
9
  export const and: (a: any, b: any) => any;
12
10
  export const xor: (a: any, b: any) => any;
13
11
  export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
14
12
  export const blake2s256: (a: number, b: number) => [number, number];
15
13
  export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
16
14
  export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
17
- export const compressWitness: (a: any) => [number, number, number, number];
18
- export const decompressWitness: (a: number, b: number) => [number, number, number];
19
- export const compressWitnessStack: (a: any) => [number, number, number, number];
20
- export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
21
- export const buildInfo: () => any;
15
+ export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
16
+ export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
17
+ export const executeProgram: (a: number, b: number, c: any, d: any) => any;
18
+ export const initLogLevel: (a: number, b: number) => [number, number];
19
+ export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
20
+ export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
21
+ export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
22
22
  export const __wbindgen_exn_store: (a: number) => void;
23
23
  export const __externref_table_alloc: () => number;
24
24
  export const __wbindgen_export_2: WebAssembly.Table;
@@ -27,7 +27,7 @@ export const __wbindgen_malloc: (a: number, b: number) => number;
27
27
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
28
  export const __wbindgen_export_6: WebAssembly.Table;
29
29
  export const __externref_table_dealloc: (a: number) => void;
30
- export const closure490_externref_shim: (a: number, b: number, c: any) => void;
31
- export const closure996_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
- export const closure1000_externref_shim: (a: number, b: number, c: any, d: any) => void;
30
+ export const closure448_externref_shim: (a: number, b: number, c: any) => void;
31
+ export const closure933_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
+ export const closure937_externref_shim: (a: number, b: number, c: any, d: any) => void;
33
33
  export const __wbindgen_start: () => void;