@aztec/noir-acvm_js 0.0.1-commit.d431d1c → 0.0.1-commit.e2b2873ed

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.
@@ -6,33 +6,35 @@
6
6
  */
7
7
  export function buildInfo(): BuildInfo;
8
8
  /**
9
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
9
+ * Sets the package's logging level.
10
10
  *
11
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
12
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
13
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
14
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
11
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
15
12
  */
16
- export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
13
+ export function initLogLevel(filter: string): void;
17
14
  /**
18
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
19
- * This method also extracts the public return values from the solved witness into its own return witness.
20
- *
21
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
22
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
23
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
24
- * @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.
15
+ * Performs a bitwise AND operation between `lhs` and `rhs`
25
16
  */
26
- export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
17
+ export function and(lhs: string, rhs: string): string;
27
18
  /**
28
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
29
- *
30
- * @param {Uint8Array} program - A serialized representation of an ACIR program
31
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
32
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
33
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
19
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
34
20
  */
35
- export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
21
+ export function xor(lhs: string, rhs: string): string;
22
+ /**
23
+ * Sha256 compression function
24
+ */
25
+ export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
26
+ /**
27
+ * Calculates the Blake2s256 hash of the input bytes
28
+ */
29
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
30
+ /**
31
+ * Verifies a ECDSA signature over the secp256k1 curve.
32
+ */
33
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
34
+ /**
35
+ * Verifies a ECDSA signature over the secp256r1 curve.
36
+ */
37
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
36
38
  /**
37
39
  * Compresses a `WitnessMap` into the binary format outputted by Nargo.
38
40
  *
@@ -63,35 +65,33 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
63
65
  */
64
66
  export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
65
67
  /**
66
- * Performs a bitwise AND operation between `lhs` and `rhs`
67
- */
68
- export function and(lhs: string, rhs: string): string;
69
- /**
70
- * Performs a bitwise XOR operation between `lhs` and `rhs`
71
- */
72
- export function xor(lhs: string, rhs: string): string;
73
- /**
74
- * Sha256 compression function
75
- */
76
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
77
- /**
78
- * Calculates the Blake2s256 hash of the input bytes
79
- */
80
- export function blake2s256(inputs: Uint8Array): Uint8Array;
81
- /**
82
- * Verifies a ECDSA signature over the secp256k1 curve.
68
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
69
+ *
70
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
71
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
72
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
73
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
83
74
  */
84
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
75
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
85
76
  /**
86
- * Verifies a ECDSA signature over the secp256r1 curve.
77
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
78
+ * This method also extracts the public return values from the solved witness into its own return witness.
79
+ *
80
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
81
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
82
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
83
+ * @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.
87
84
  */
88
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
85
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
89
86
  /**
90
- * Sets the package's logging level.
87
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
91
88
  *
92
- * @param {LogLevel} level - The maximum level of logging to be emitted.
89
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
90
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
91
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
92
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
93
93
  */
94
- export function initLogLevel(filter: string): void;
94
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
95
95
  /**
96
96
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
97
97
  *
@@ -117,12 +117,17 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
117
117
  */
118
118
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
119
119
 
120
- export type StackItem = {
121
- index: number;
122
- witness: WitnessMap;
123
- }
120
+ export type ForeignCallInput = string[]
121
+ export type ForeignCallOutput = string | string[]
124
122
 
125
- export type WitnessStack = Array<StackItem>;
123
+ /**
124
+ * A callback which performs an foreign call and returns the response.
125
+ * @callback ForeignCallHandler
126
+ * @param {string} name - The identifier for the type of foreign call being performed.
127
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
128
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
129
+ */
130
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
126
131
 
127
132
 
128
133
 
@@ -140,20 +145,6 @@ export type BuildInfo = {
140
145
 
141
146
 
142
147
 
143
- export type RawAssertionPayload = {
144
- selector: string;
145
- data: string[];
146
- };
147
-
148
- export type ExecutionError = Error & {
149
- callStack?: string[];
150
- rawAssertionPayload?: RawAssertionPayload;
151
- acirFunctionId?: number;
152
- brilligFunctionId?: number;
153
- };
154
-
155
-
156
-
157
148
  // Map from witness index to hex string value of witness.
158
149
  export type WitnessMap = Map<number, string>;
159
150
 
@@ -169,16 +160,25 @@ export type SolvedAndReturnWitness = {
169
160
 
170
161
 
171
162
 
172
- export type ForeignCallInput = string[]
173
- export type ForeignCallOutput = string | string[]
163
+ export type StackItem = {
164
+ index: number;
165
+ witness: WitnessMap;
166
+ }
174
167
 
175
- /**
176
- * A callback which performs an foreign call and returns the response.
177
- * @callback ForeignCallHandler
178
- * @param {string} name - The identifier for the type of foreign call being performed.
179
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
180
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
181
- */
182
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
168
+ export type WitnessStack = Array<StackItem>;
169
+
170
+
171
+
172
+ export type RawAssertionPayload = {
173
+ selector: string;
174
+ data: string[];
175
+ };
176
+
177
+ export type ExecutionError = Error & {
178
+ callStack?: string[];
179
+ rawAssertionPayload?: RawAssertionPayload;
180
+ acirFunctionId?: number;
181
+ brilligFunctionId?: number;
182
+ };
183
183
 
184
184
 
package/nodejs/acvm_js.js CHANGED
@@ -210,131 +210,23 @@ module.exports.buildInfo = function() {
210
210
  return ret;
211
211
  };
212
212
 
213
- function passArray8ToWasm0(arg, malloc) {
214
- const ptr = malloc(arg.length * 1, 1) >>> 0;
215
- getUint8ArrayMemory0().set(arg, ptr / 1);
216
- WASM_VECTOR_LEN = arg.length;
217
- return ptr;
218
- }
219
- /**
220
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
221
- *
222
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
223
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
224
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
225
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
226
- */
227
- module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
228
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
229
- const len0 = WASM_VECTOR_LEN;
230
- const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
231
- return ret;
232
- };
233
-
234
- /**
235
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
236
- * This method also extracts the public return values from the solved witness into its own return witness.
237
- *
238
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
239
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
240
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
241
- * @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.
242
- */
243
- module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
244
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
245
- const len0 = WASM_VECTOR_LEN;
246
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
247
- return ret;
248
- };
249
-
250
- /**
251
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
252
- *
253
- * @param {Uint8Array} program - A serialized representation of an ACIR program
254
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
255
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
256
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
257
- */
258
- module.exports.executeProgram = 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.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
262
- return ret;
263
- };
264
-
265
213
  function takeFromExternrefTable0(idx) {
266
214
  const value = wasm.__wbindgen_export_2.get(idx);
267
215
  wasm.__externref_table_dealloc(idx);
268
216
  return value;
269
217
  }
270
-
271
- function getArrayU8FromWasm0(ptr, len) {
272
- ptr = ptr >>> 0;
273
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
274
- }
275
- /**
276
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
277
- *
278
- * @param {WitnessMap} witness_map - A witness map.
279
- * @returns {Uint8Array} A compressed witness map
280
- */
281
- module.exports.compressWitness = function(witness_map) {
282
- const ret = wasm.compressWitness(witness_map);
283
- if (ret[3]) {
284
- throw takeFromExternrefTable0(ret[2]);
285
- }
286
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
287
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
288
- return v1;
289
- };
290
-
291
218
  /**
292
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
293
- * This should be used to only fetch the witness map for the main function.
294
- *
295
- * @param {Uint8Array} compressed_witness - A compressed witness.
296
- * @returns {WitnessMap} The decompressed witness map.
297
- */
298
- module.exports.decompressWitness = function(compressed_witness) {
299
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
300
- const len0 = WASM_VECTOR_LEN;
301
- const ret = wasm.decompressWitness(ptr0, len0);
302
- if (ret[2]) {
303
- throw takeFromExternrefTable0(ret[1]);
304
- }
305
- return takeFromExternrefTable0(ret[0]);
306
- };
307
-
308
- /**
309
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
310
- *
311
- * @param {WitnessStack} witness_stack - A witness stack.
312
- * @returns {Uint8Array} A compressed witness stack
313
- */
314
- module.exports.compressWitnessStack = function(witness_stack) {
315
- const ret = wasm.compressWitnessStack(witness_stack);
316
- if (ret[3]) {
317
- throw takeFromExternrefTable0(ret[2]);
318
- }
319
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
320
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
321
- return v1;
322
- };
323
-
324
- /**
325
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
219
+ * Sets the package's logging level.
326
220
  *
327
- * @param {Uint8Array} compressed_witness - A compressed witness.
328
- * @returns {WitnessStack} The decompressed witness stack.
221
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
329
222
  */
330
- module.exports.decompressWitnessStack = function(compressed_witness) {
331
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
223
+ module.exports.initLogLevel = function(filter) {
224
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
332
225
  const len0 = WASM_VECTOR_LEN;
333
- const ret = wasm.decompressWitnessStack(ptr0, len0);
334
- if (ret[2]) {
335
- throw takeFromExternrefTable0(ret[1]);
226
+ const ret = wasm.initLogLevel(ptr0, len0);
227
+ if (ret[1]) {
228
+ throw takeFromExternrefTable0(ret[0]);
336
229
  }
337
- return takeFromExternrefTable0(ret[0]);
338
230
  };
339
231
 
340
232
  /**
@@ -396,6 +288,17 @@ module.exports.sha256_compression = function(inputs, state) {
396
288
  return v3;
397
289
  };
398
290
 
291
+ function passArray8ToWasm0(arg, malloc) {
292
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
293
+ getUint8ArrayMemory0().set(arg, ptr / 1);
294
+ WASM_VECTOR_LEN = arg.length;
295
+ return ptr;
296
+ }
297
+
298
+ function getArrayU8FromWasm0(ptr, len) {
299
+ ptr = ptr >>> 0;
300
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
301
+ }
399
302
  /**
400
303
  * Calculates the Blake2s256 hash of the input bytes
401
304
  * @param {Uint8Array} inputs
@@ -453,17 +356,114 @@ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes,
453
356
  };
454
357
 
455
358
  /**
456
- * Sets the package's logging level.
359
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
457
360
  *
458
- * @param {LogLevel} level - The maximum level of logging to be emitted.
361
+ * @param {WitnessMap} witness_map - A witness map.
362
+ * @returns {Uint8Array} A compressed witness map
459
363
  */
460
- module.exports.initLogLevel = function(filter) {
461
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
364
+ module.exports.compressWitness = function(witness_map) {
365
+ const ret = wasm.compressWitness(witness_map);
366
+ if (ret[3]) {
367
+ throw takeFromExternrefTable0(ret[2]);
368
+ }
369
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
370
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
371
+ return v1;
372
+ };
373
+
374
+ /**
375
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
376
+ * This should be used to only fetch the witness map for the main function.
377
+ *
378
+ * @param {Uint8Array} compressed_witness - A compressed witness.
379
+ * @returns {WitnessMap} The decompressed witness map.
380
+ */
381
+ module.exports.decompressWitness = function(compressed_witness) {
382
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
462
383
  const len0 = WASM_VECTOR_LEN;
463
- const ret = wasm.initLogLevel(ptr0, len0);
464
- if (ret[1]) {
465
- throw takeFromExternrefTable0(ret[0]);
384
+ const ret = wasm.decompressWitness(ptr0, len0);
385
+ if (ret[2]) {
386
+ throw takeFromExternrefTable0(ret[1]);
387
+ }
388
+ return takeFromExternrefTable0(ret[0]);
389
+ };
390
+
391
+ /**
392
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
393
+ *
394
+ * @param {WitnessStack} witness_stack - A witness stack.
395
+ * @returns {Uint8Array} A compressed witness stack
396
+ */
397
+ module.exports.compressWitnessStack = function(witness_stack) {
398
+ const ret = wasm.compressWitnessStack(witness_stack);
399
+ if (ret[3]) {
400
+ throw takeFromExternrefTable0(ret[2]);
401
+ }
402
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
403
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
404
+ return v1;
405
+ };
406
+
407
+ /**
408
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
409
+ *
410
+ * @param {Uint8Array} compressed_witness - A compressed witness.
411
+ * @returns {WitnessStack} The decompressed witness stack.
412
+ */
413
+ module.exports.decompressWitnessStack = function(compressed_witness) {
414
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
415
+ const len0 = WASM_VECTOR_LEN;
416
+ const ret = wasm.decompressWitnessStack(ptr0, len0);
417
+ if (ret[2]) {
418
+ throw takeFromExternrefTable0(ret[1]);
466
419
  }
420
+ return takeFromExternrefTable0(ret[0]);
421
+ };
422
+
423
+ /**
424
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
425
+ *
426
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
427
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
428
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
429
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
430
+ */
431
+ module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
432
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
433
+ const len0 = WASM_VECTOR_LEN;
434
+ const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
435
+ return ret;
436
+ };
437
+
438
+ /**
439
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
440
+ * This method also extracts the public return values from the solved witness into its own return witness.
441
+ *
442
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
443
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
444
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
445
+ * @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.
446
+ */
447
+ module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
448
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
449
+ const len0 = WASM_VECTOR_LEN;
450
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
451
+ return ret;
452
+ };
453
+
454
+ /**
455
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
456
+ *
457
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
458
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
459
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
460
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
461
+ */
462
+ module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
463
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
464
+ const len0 = WASM_VECTOR_LEN;
465
+ const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
466
+ return ret;
467
467
  };
468
468
 
469
469
  /**
@@ -527,15 +527,15 @@ module.exports.getPublicWitness = function(program, solved_witness) {
527
527
  };
528
528
 
529
529
  function __wbg_adapter_30(arg0, arg1, arg2) {
530
- wasm.closure447_externref_shim(arg0, arg1, arg2);
530
+ wasm.closure445_externref_shim(arg0, arg1, arg2);
531
531
  }
532
532
 
533
533
  function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
534
- wasm.closure932_externref_shim(arg0, arg1, arg2, arg3, arg4);
534
+ wasm.closure921_externref_shim(arg0, arg1, arg2, arg3, arg4);
535
535
  }
536
536
 
537
537
  function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
538
- wasm.closure936_externref_shim(arg0, arg1, arg2, arg3);
538
+ wasm.closure925_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_wrapper1443 = function(arg0, arg1, arg2) {
817
- const ret = makeMutClosure(arg0, arg1, 448, __wbg_adapter_30);
816
+ module.exports.__wbindgen_closure_wrapper1365 = function(arg0, arg1, arg2) {
817
+ const ret = makeMutClosure(arg0, arg1, 446, __wbg_adapter_30);
818
818
  return ret;
819
819
  };
820
820
 
Binary file
@@ -2,20 +2,20 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const buildInfo: () => any;
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 compressWitness: (a: any) => [number, number, number, number];
9
- export const decompressWitness: (a: number, b: number) => [number, number, number];
10
- export const compressWitnessStack: (a: any) => [number, number, number, number];
11
- export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
5
+ export const initLogLevel: (a: number, b: number) => [number, number];
12
6
  export const and: (a: any, b: any) => any;
13
7
  export const xor: (a: any, b: any) => any;
14
8
  export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
15
9
  export const blake2s256: (a: number, b: number) => [number, number];
16
10
  export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
17
11
  export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
18
- export const initLogLevel: (a: number, b: number) => [number, number];
12
+ export const compressWitness: (a: any) => [number, number, number, number];
13
+ export const decompressWitness: (a: number, b: number) => [number, number, number];
14
+ export const compressWitnessStack: (a: any) => [number, number, number, number];
15
+ export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
16
+ export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
17
+ export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
18
+ export const executeProgram: (a: number, b: number, c: any, d: any) => any;
19
19
  export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
20
20
  export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
21
21
  export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
@@ -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 closure447_externref_shim: (a: number, b: number, c: any) => void;
31
- export const closure932_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
- export const closure936_externref_shim: (a: number, b: number, c: any, d: any) => void;
30
+ export const closure445_externref_shim: (a: number, b: number, c: any) => void;
31
+ export const closure921_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
+ export const closure925_externref_shim: (a: number, b: number, c: any, d: any) => void;
33
33
  export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/noir-acvm_js",
3
- "version": "0.0.1-commit.d431d1c",
3
+ "version": "0.0.1-commit.e2b2873ed",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -43,9 +43,9 @@
43
43
  "@web/test-runner-playwright": "^0.11.1",
44
44
  "chai": "^6.2.2",
45
45
  "eslint": "^9.39.2",
46
- "eslint-plugin-prettier": "^5.5.4",
46
+ "eslint-plugin-prettier": "^5.5.5",
47
47
  "mocha": "^11.7.5",
48
- "prettier": "3.7.4",
48
+ "prettier": "3.8.1",
49
49
  "ts-node": "^10.9.2",
50
50
  "typescript": "^5.8.3"
51
51
  }
package/web/acvm_js.d.ts CHANGED
@@ -6,33 +6,35 @@
6
6
  */
7
7
  export function buildInfo(): BuildInfo;
8
8
  /**
9
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
9
+ * Sets the package's logging level.
10
10
  *
11
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
12
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
13
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
14
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
11
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
15
12
  */
16
- export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
13
+ export function initLogLevel(filter: string): void;
17
14
  /**
18
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
19
- * This method also extracts the public return values from the solved witness into its own return witness.
20
- *
21
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
22
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
23
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
24
- * @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.
15
+ * Performs a bitwise AND operation between `lhs` and `rhs`
25
16
  */
26
- export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
17
+ export function and(lhs: string, rhs: string): string;
27
18
  /**
28
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
29
- *
30
- * @param {Uint8Array} program - A serialized representation of an ACIR program
31
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
32
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
33
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
19
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
34
20
  */
35
- export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
21
+ export function xor(lhs: string, rhs: string): string;
22
+ /**
23
+ * Sha256 compression function
24
+ */
25
+ export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
26
+ /**
27
+ * Calculates the Blake2s256 hash of the input bytes
28
+ */
29
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
30
+ /**
31
+ * Verifies a ECDSA signature over the secp256k1 curve.
32
+ */
33
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
34
+ /**
35
+ * Verifies a ECDSA signature over the secp256r1 curve.
36
+ */
37
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
36
38
  /**
37
39
  * Compresses a `WitnessMap` into the binary format outputted by Nargo.
38
40
  *
@@ -63,35 +65,33 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
63
65
  */
64
66
  export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
65
67
  /**
66
- * Performs a bitwise AND operation between `lhs` and `rhs`
67
- */
68
- export function and(lhs: string, rhs: string): string;
69
- /**
70
- * Performs a bitwise XOR operation between `lhs` and `rhs`
71
- */
72
- export function xor(lhs: string, rhs: string): string;
73
- /**
74
- * Sha256 compression function
75
- */
76
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
77
- /**
78
- * Calculates the Blake2s256 hash of the input bytes
79
- */
80
- export function blake2s256(inputs: Uint8Array): Uint8Array;
81
- /**
82
- * Verifies a ECDSA signature over the secp256k1 curve.
68
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
69
+ *
70
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
71
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
72
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
73
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
83
74
  */
84
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
75
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
85
76
  /**
86
- * Verifies a ECDSA signature over the secp256r1 curve.
77
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
78
+ * This method also extracts the public return values from the solved witness into its own return witness.
79
+ *
80
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
81
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
82
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
83
+ * @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.
87
84
  */
88
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
85
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
89
86
  /**
90
- * Sets the package's logging level.
87
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
91
88
  *
92
- * @param {LogLevel} level - The maximum level of logging to be emitted.
89
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
90
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
91
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
92
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
93
93
  */
94
- export function initLogLevel(filter: string): void;
94
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
95
95
  /**
96
96
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
97
97
  *
@@ -117,12 +117,17 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
117
117
  */
118
118
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
119
119
 
120
- export type StackItem = {
121
- index: number;
122
- witness: WitnessMap;
123
- }
120
+ export type ForeignCallInput = string[]
121
+ export type ForeignCallOutput = string | string[]
124
122
 
125
- export type WitnessStack = Array<StackItem>;
123
+ /**
124
+ * A callback which performs an foreign call and returns the response.
125
+ * @callback ForeignCallHandler
126
+ * @param {string} name - The identifier for the type of foreign call being performed.
127
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
128
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
129
+ */
130
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
126
131
 
127
132
 
128
133
 
@@ -140,20 +145,6 @@ export type BuildInfo = {
140
145
 
141
146
 
142
147
 
143
- export type RawAssertionPayload = {
144
- selector: string;
145
- data: string[];
146
- };
147
-
148
- export type ExecutionError = Error & {
149
- callStack?: string[];
150
- rawAssertionPayload?: RawAssertionPayload;
151
- acirFunctionId?: number;
152
- brilligFunctionId?: number;
153
- };
154
-
155
-
156
-
157
148
  // Map from witness index to hex string value of witness.
158
149
  export type WitnessMap = Map<number, string>;
159
150
 
@@ -169,17 +160,26 @@ export type SolvedAndReturnWitness = {
169
160
 
170
161
 
171
162
 
172
- export type ForeignCallInput = string[]
173
- export type ForeignCallOutput = string | string[]
163
+ export type StackItem = {
164
+ index: number;
165
+ witness: WitnessMap;
166
+ }
174
167
 
175
- /**
176
- * A callback which performs an foreign call and returns the response.
177
- * @callback ForeignCallHandler
178
- * @param {string} name - The identifier for the type of foreign call being performed.
179
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
180
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
181
- */
182
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
168
+ export type WitnessStack = Array<StackItem>;
169
+
170
+
171
+
172
+ export type RawAssertionPayload = {
173
+ selector: string;
174
+ data: string[];
175
+ };
176
+
177
+ export type ExecutionError = Error & {
178
+ callStack?: string[];
179
+ rawAssertionPayload?: RawAssertionPayload;
180
+ acirFunctionId?: number;
181
+ brilligFunctionId?: number;
182
+ };
183
183
 
184
184
 
185
185
 
@@ -188,20 +188,20 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
188
188
  export interface InitOutput {
189
189
  readonly memory: WebAssembly.Memory;
190
190
  readonly buildInfo: () => any;
191
- readonly executeCircuit: (a: number, b: number, c: any, d: any) => any;
192
- readonly executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
193
- readonly executeProgram: (a: number, b: number, c: any, d: any) => any;
194
- readonly compressWitness: (a: any) => [number, number, number, number];
195
- readonly decompressWitness: (a: number, b: number) => [number, number, number];
196
- readonly compressWitnessStack: (a: any) => [number, number, number, number];
197
- readonly decompressWitnessStack: (a: number, b: number) => [number, number, number];
191
+ readonly initLogLevel: (a: number, b: number) => [number, number];
198
192
  readonly and: (a: any, b: any) => any;
199
193
  readonly xor: (a: any, b: any) => any;
200
194
  readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
201
195
  readonly blake2s256: (a: number, b: number) => [number, number];
202
196
  readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
203
197
  readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
204
- readonly initLogLevel: (a: number, b: number) => [number, number];
198
+ readonly compressWitness: (a: any) => [number, number, number, number];
199
+ readonly decompressWitness: (a: number, b: number) => [number, number, number];
200
+ readonly compressWitnessStack: (a: any) => [number, number, number, number];
201
+ readonly decompressWitnessStack: (a: number, b: number) => [number, number, number];
202
+ readonly executeCircuit: (a: number, b: number, c: any, d: any) => any;
203
+ readonly executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
204
+ readonly executeProgram: (a: number, b: number, c: any, d: any) => any;
205
205
  readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
206
206
  readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
207
207
  readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
@@ -213,9 +213,9 @@ export interface InitOutput {
213
213
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
214
214
  readonly __wbindgen_export_6: WebAssembly.Table;
215
215
  readonly __externref_table_dealloc: (a: number) => void;
216
- readonly closure447_externref_shim: (a: number, b: number, c: any) => void;
217
- readonly closure932_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
218
- readonly closure936_externref_shim: (a: number, b: number, c: any, d: any) => void;
216
+ readonly closure445_externref_shim: (a: number, b: number, c: any) => void;
217
+ readonly closure921_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
218
+ readonly closure925_externref_shim: (a: number, b: number, c: any, d: any) => void;
219
219
  readonly __wbindgen_start: () => void;
220
220
  }
221
221
 
package/web/acvm_js.js CHANGED
@@ -206,131 +206,23 @@ export function buildInfo() {
206
206
  return ret;
207
207
  }
208
208
 
209
- function passArray8ToWasm0(arg, malloc) {
210
- const ptr = malloc(arg.length * 1, 1) >>> 0;
211
- getUint8ArrayMemory0().set(arg, ptr / 1);
212
- WASM_VECTOR_LEN = arg.length;
213
- return ptr;
214
- }
215
- /**
216
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
217
- *
218
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
219
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
220
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
221
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
222
- */
223
- export function executeCircuit(program, initial_witness, foreign_call_handler) {
224
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
225
- const len0 = WASM_VECTOR_LEN;
226
- const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
227
- return ret;
228
- }
229
-
230
- /**
231
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
232
- * This method also extracts the public return values from the solved witness into its own return witness.
233
- *
234
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
235
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
236
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
237
- * @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.
238
- */
239
- export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
240
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
241
- const len0 = WASM_VECTOR_LEN;
242
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
243
- return ret;
244
- }
245
-
246
- /**
247
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
248
- *
249
- * @param {Uint8Array} program - A serialized representation of an ACIR program
250
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
251
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
252
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
253
- */
254
- export function executeProgram(program, initial_witness, foreign_call_handler) {
255
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
256
- const len0 = WASM_VECTOR_LEN;
257
- const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
258
- return ret;
259
- }
260
-
261
209
  function takeFromExternrefTable0(idx) {
262
210
  const value = wasm.__wbindgen_export_2.get(idx);
263
211
  wasm.__externref_table_dealloc(idx);
264
212
  return value;
265
213
  }
266
-
267
- function getArrayU8FromWasm0(ptr, len) {
268
- ptr = ptr >>> 0;
269
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
270
- }
271
- /**
272
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
273
- *
274
- * @param {WitnessMap} witness_map - A witness map.
275
- * @returns {Uint8Array} A compressed witness map
276
- */
277
- export function compressWitness(witness_map) {
278
- const ret = wasm.compressWitness(witness_map);
279
- if (ret[3]) {
280
- throw takeFromExternrefTable0(ret[2]);
281
- }
282
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
283
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
284
- return v1;
285
- }
286
-
287
214
  /**
288
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
289
- * This should be used to only fetch the witness map for the main function.
290
- *
291
- * @param {Uint8Array} compressed_witness - A compressed witness.
292
- * @returns {WitnessMap} The decompressed witness map.
293
- */
294
- export function decompressWitness(compressed_witness) {
295
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
296
- const len0 = WASM_VECTOR_LEN;
297
- const ret = wasm.decompressWitness(ptr0, len0);
298
- if (ret[2]) {
299
- throw takeFromExternrefTable0(ret[1]);
300
- }
301
- return takeFromExternrefTable0(ret[0]);
302
- }
303
-
304
- /**
305
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
306
- *
307
- * @param {WitnessStack} witness_stack - A witness stack.
308
- * @returns {Uint8Array} A compressed witness stack
309
- */
310
- export function compressWitnessStack(witness_stack) {
311
- const ret = wasm.compressWitnessStack(witness_stack);
312
- if (ret[3]) {
313
- throw takeFromExternrefTable0(ret[2]);
314
- }
315
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
316
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
317
- return v1;
318
- }
319
-
320
- /**
321
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
215
+ * Sets the package's logging level.
322
216
  *
323
- * @param {Uint8Array} compressed_witness - A compressed witness.
324
- * @returns {WitnessStack} The decompressed witness stack.
217
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
325
218
  */
326
- export function decompressWitnessStack(compressed_witness) {
327
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
219
+ export function initLogLevel(filter) {
220
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
328
221
  const len0 = WASM_VECTOR_LEN;
329
- const ret = wasm.decompressWitnessStack(ptr0, len0);
330
- if (ret[2]) {
331
- throw takeFromExternrefTable0(ret[1]);
222
+ const ret = wasm.initLogLevel(ptr0, len0);
223
+ if (ret[1]) {
224
+ throw takeFromExternrefTable0(ret[0]);
332
225
  }
333
- return takeFromExternrefTable0(ret[0]);
334
226
  }
335
227
 
336
228
  /**
@@ -392,6 +284,17 @@ export function sha256_compression(inputs, state) {
392
284
  return v3;
393
285
  }
394
286
 
287
+ function passArray8ToWasm0(arg, malloc) {
288
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
289
+ getUint8ArrayMemory0().set(arg, ptr / 1);
290
+ WASM_VECTOR_LEN = arg.length;
291
+ return ptr;
292
+ }
293
+
294
+ function getArrayU8FromWasm0(ptr, len) {
295
+ ptr = ptr >>> 0;
296
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
297
+ }
395
298
  /**
396
299
  * Calculates the Blake2s256 hash of the input bytes
397
300
  * @param {Uint8Array} inputs
@@ -449,17 +352,114 @@ export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_ke
449
352
  }
450
353
 
451
354
  /**
452
- * Sets the package's logging level.
355
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
453
356
  *
454
- * @param {LogLevel} level - The maximum level of logging to be emitted.
357
+ * @param {WitnessMap} witness_map - A witness map.
358
+ * @returns {Uint8Array} A compressed witness map
455
359
  */
456
- export function initLogLevel(filter) {
457
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
360
+ export function compressWitness(witness_map) {
361
+ const ret = wasm.compressWitness(witness_map);
362
+ if (ret[3]) {
363
+ throw takeFromExternrefTable0(ret[2]);
364
+ }
365
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
366
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
367
+ return v1;
368
+ }
369
+
370
+ /**
371
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
372
+ * This should be used to only fetch the witness map for the main function.
373
+ *
374
+ * @param {Uint8Array} compressed_witness - A compressed witness.
375
+ * @returns {WitnessMap} The decompressed witness map.
376
+ */
377
+ export function decompressWitness(compressed_witness) {
378
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
458
379
  const len0 = WASM_VECTOR_LEN;
459
- const ret = wasm.initLogLevel(ptr0, len0);
460
- if (ret[1]) {
461
- throw takeFromExternrefTable0(ret[0]);
380
+ const ret = wasm.decompressWitness(ptr0, len0);
381
+ if (ret[2]) {
382
+ throw takeFromExternrefTable0(ret[1]);
383
+ }
384
+ return takeFromExternrefTable0(ret[0]);
385
+ }
386
+
387
+ /**
388
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
389
+ *
390
+ * @param {WitnessStack} witness_stack - A witness stack.
391
+ * @returns {Uint8Array} A compressed witness stack
392
+ */
393
+ export function compressWitnessStack(witness_stack) {
394
+ const ret = wasm.compressWitnessStack(witness_stack);
395
+ if (ret[3]) {
396
+ throw takeFromExternrefTable0(ret[2]);
397
+ }
398
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
399
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
400
+ return v1;
401
+ }
402
+
403
+ /**
404
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
405
+ *
406
+ * @param {Uint8Array} compressed_witness - A compressed witness.
407
+ * @returns {WitnessStack} The decompressed witness stack.
408
+ */
409
+ export function decompressWitnessStack(compressed_witness) {
410
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
411
+ const len0 = WASM_VECTOR_LEN;
412
+ const ret = wasm.decompressWitnessStack(ptr0, len0);
413
+ if (ret[2]) {
414
+ throw takeFromExternrefTable0(ret[1]);
462
415
  }
416
+ return takeFromExternrefTable0(ret[0]);
417
+ }
418
+
419
+ /**
420
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
421
+ *
422
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
423
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
424
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
425
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
426
+ */
427
+ export function executeCircuit(program, initial_witness, foreign_call_handler) {
428
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
429
+ const len0 = WASM_VECTOR_LEN;
430
+ const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
431
+ return ret;
432
+ }
433
+
434
+ /**
435
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
436
+ * This method also extracts the public return values from the solved witness into its own return witness.
437
+ *
438
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
439
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
440
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
441
+ * @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.
442
+ */
443
+ export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
444
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
445
+ const len0 = WASM_VECTOR_LEN;
446
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
447
+ return ret;
448
+ }
449
+
450
+ /**
451
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
452
+ *
453
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
454
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
455
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
456
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
457
+ */
458
+ export function executeProgram(program, initial_witness, foreign_call_handler) {
459
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
460
+ const len0 = WASM_VECTOR_LEN;
461
+ const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
462
+ return ret;
463
463
  }
464
464
 
465
465
  /**
@@ -523,15 +523,15 @@ export function getPublicWitness(program, solved_witness) {
523
523
  }
524
524
 
525
525
  function __wbg_adapter_30(arg0, arg1, arg2) {
526
- wasm.closure447_externref_shim(arg0, arg1, arg2);
526
+ wasm.closure445_externref_shim(arg0, arg1, arg2);
527
527
  }
528
528
 
529
529
  function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
530
- wasm.closure932_externref_shim(arg0, arg1, arg2, arg3, arg4);
530
+ wasm.closure921_externref_shim(arg0, arg1, arg2, arg3, arg4);
531
531
  }
532
532
 
533
533
  function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
534
- wasm.closure936_externref_shim(arg0, arg1, arg2, arg3);
534
+ wasm.closure925_externref_shim(arg0, arg1, arg2, arg3);
535
535
  }
536
536
 
537
537
  async function __wbg_load(module, imports) {
@@ -797,8 +797,8 @@ function __wbg_get_imports() {
797
797
  const ret = false;
798
798
  return ret;
799
799
  };
800
- imports.wbg.__wbindgen_closure_wrapper1443 = function(arg0, arg1, arg2) {
801
- const ret = makeMutClosure(arg0, arg1, 448, __wbg_adapter_30);
800
+ imports.wbg.__wbindgen_closure_wrapper1365 = function(arg0, arg1, arg2) {
801
+ const ret = makeMutClosure(arg0, arg1, 446, __wbg_adapter_30);
802
802
  return ret;
803
803
  };
804
804
  imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
Binary file
@@ -2,20 +2,20 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const buildInfo: () => any;
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 compressWitness: (a: any) => [number, number, number, number];
9
- export const decompressWitness: (a: number, b: number) => [number, number, number];
10
- export const compressWitnessStack: (a: any) => [number, number, number, number];
11
- export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
5
+ export const initLogLevel: (a: number, b: number) => [number, number];
12
6
  export const and: (a: any, b: any) => any;
13
7
  export const xor: (a: any, b: any) => any;
14
8
  export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
15
9
  export const blake2s256: (a: number, b: number) => [number, number];
16
10
  export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
17
11
  export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
18
- export const initLogLevel: (a: number, b: number) => [number, number];
12
+ export const compressWitness: (a: any) => [number, number, number, number];
13
+ export const decompressWitness: (a: number, b: number) => [number, number, number];
14
+ export const compressWitnessStack: (a: any) => [number, number, number, number];
15
+ export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
16
+ export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
17
+ export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
18
+ export const executeProgram: (a: number, b: number, c: any, d: any) => any;
19
19
  export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
20
20
  export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
21
21
  export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
@@ -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 closure447_externref_shim: (a: number, b: number, c: any) => void;
31
- export const closure932_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
- export const closure936_externref_shim: (a: number, b: number, c: any, d: any) => void;
30
+ export const closure445_externref_shim: (a: number, b: number, c: any) => void;
31
+ export const closure921_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
+ export const closure925_externref_shim: (a: number, b: number, c: any, d: any) => void;
33
33
  export const __wbindgen_start: () => void;