@noir-lang/acvm_js 1.0.0-beta.15-b34828f.nightly → 1.0.0-beta.15-1fce7ca.nightly

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