@noir-lang/acvm_js 1.0.0-beta.15-881acee.nightly → 1.0.0-beta.15-9dbad18.nightly

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
5
- *
6
- * @param {WitnessMap} witness_map - A witness map.
7
- * @returns {Uint8Array} A compressed witness map
8
- */
9
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
10
- /**
11
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
12
- * This should be used to only fetch the witness map for the main function.
13
- *
14
- * @param {Uint8Array} compressed_witness - A compressed witness.
15
- * @returns {WitnessMap} The decompressed witness map.
16
- */
17
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
18
- /**
19
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
20
- *
21
- * @param {WitnessStack} witness_stack - A witness stack.
22
- * @returns {Uint8Array} A compressed witness stack
23
- */
24
- export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
25
- /**
26
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
27
- *
28
- * @param {Uint8Array} compressed_witness - A compressed witness.
29
- * @returns {WitnessStack} The decompressed witness stack.
30
- */
31
- export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
32
3
  /**
33
4
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
34
5
  *
@@ -58,10 +29,35 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
58
29
  */
59
30
  export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
60
31
  /**
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.
32
+ * Performs a bitwise AND operation between `lhs` and `rhs`
63
33
  */
64
- export function buildInfo(): BuildInfo;
34
+ export function and(lhs: string, rhs: string): string;
35
+ /**
36
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
37
+ */
38
+ export function xor(lhs: string, rhs: string): string;
39
+ /**
40
+ * Sha256 compression function
41
+ */
42
+ export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
43
+ /**
44
+ * Calculates the Blake2s256 hash of the input bytes
45
+ */
46
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
47
+ /**
48
+ * Verifies a ECDSA signature over the secp256k1 curve.
49
+ */
50
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
51
+ /**
52
+ * Verifies a ECDSA signature over the secp256r1 curve.
53
+ */
54
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
55
+ /**
56
+ * Sets the package's logging level.
57
+ *
58
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
59
+ */
60
+ export function initLogLevel(filter: string): void;
65
61
  /**
66
62
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
67
63
  *
@@ -87,61 +83,60 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
87
83
  */
88
84
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
89
85
  /**
90
- * Performs a bitwise AND operation between `lhs` and `rhs`
91
- */
92
- export function and(lhs: string, rhs: string): string;
93
- /**
94
- * Performs a bitwise XOR operation between `lhs` and `rhs`
95
- */
96
- export function xor(lhs: string, rhs: string): string;
97
- /**
98
- * Sha256 compression function
86
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
87
+ * @returns {BuildInfo} - Information on how the installed package was built.
99
88
  */
100
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
89
+ export function buildInfo(): BuildInfo;
101
90
  /**
102
- * Calculates the Blake2s256 hash of the input bytes
91
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
92
+ *
93
+ * @param {WitnessMap} witness_map - A witness map.
94
+ * @returns {Uint8Array} A compressed witness map
103
95
  */
104
- export function blake2s256(inputs: Uint8Array): Uint8Array;
96
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
105
97
  /**
106
- * Verifies a ECDSA signature over the secp256k1 curve.
98
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
99
+ * This should be used to only fetch the witness map for the main function.
100
+ *
101
+ * @param {Uint8Array} compressed_witness - A compressed witness.
102
+ * @returns {WitnessMap} The decompressed witness map.
107
103
  */
108
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
104
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
109
105
  /**
110
- * Verifies a ECDSA signature over the secp256r1 curve.
106
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
107
+ *
108
+ * @param {WitnessStack} witness_stack - A witness stack.
109
+ * @returns {Uint8Array} A compressed witness stack
111
110
  */
112
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
111
+ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
113
112
  /**
114
- * Sets the package's logging level.
113
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
115
114
  *
116
- * @param {LogLevel} level - The maximum level of logging to be emitted.
115
+ * @param {Uint8Array} compressed_witness - A compressed witness.
116
+ * @returns {WitnessStack} The decompressed witness stack.
117
117
  */
118
- export function initLogLevel(filter: string): void;
118
+ export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
119
+
120
+ export type ForeignCallInput = string[]
121
+ export type ForeignCallOutput = string | string[]
119
122
 
120
123
  /**
121
- * @typedef {Object} BuildInfo - Information about how the installed package was built
122
- * @property {string} gitHash - The hash of the git commit from which the package was built.
123
- * @property {string} version - The version of the package at the built git commit.
124
- * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
125
- */
126
- export type BuildInfo = {
127
- gitHash: string;
128
- version: string;
129
- dirty: string;
130
- }
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[]>;
131
131
 
132
132
 
133
133
 
134
- export type RawAssertionPayload = {
135
- selector: string;
136
- data: string[];
137
- };
134
+ export type StackItem = {
135
+ index: number;
136
+ witness: WitnessMap;
137
+ }
138
138
 
139
- export type ExecutionError = Error & {
140
- callStack?: string[];
141
- rawAssertionPayload?: RawAssertionPayload;
142
- acirFunctionId?: number;
143
- brilligFunctionId?: number;
144
- };
139
+ export type WitnessStack = Array<StackItem>;
145
140
 
146
141
 
147
142
 
@@ -160,25 +155,30 @@ export type SolvedAndReturnWitness = {
160
155
 
161
156
 
162
157
 
163
- export type ForeignCallInput = string[]
164
- export type ForeignCallOutput = string | string[]
158
+ export type RawAssertionPayload = {
159
+ selector: string;
160
+ data: string[];
161
+ };
165
162
 
166
- /**
167
- * A callback which performs an foreign call and returns the response.
168
- * @callback ForeignCallHandler
169
- * @param {string} name - The identifier for the type of foreign call being performed.
170
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
171
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
172
- */
173
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
163
+ export type ExecutionError = Error & {
164
+ callStack?: string[];
165
+ rawAssertionPayload?: RawAssertionPayload;
166
+ acirFunctionId?: number;
167
+ brilligFunctionId?: number;
168
+ };
174
169
 
175
170
 
176
171
 
177
- export type StackItem = {
178
- index: number;
179
- witness: WitnessMap;
172
+ /**
173
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
174
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
175
+ * @property {string} version - The version of the package at the built git commit.
176
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
177
+ */
178
+ export type BuildInfo = {
179
+ gitHash: string;
180
+ version: string;
181
+ dirty: string;
180
182
  }
181
183
 
182
- export type WitnessStack = Array<StackItem>;
183
-
184
184
 
package/nodejs/acvm_js.js CHANGED
@@ -202,87 +202,12 @@ function debugString(val) {
202
202
  return className;
203
203
  }
204
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
205
  function passArray8ToWasm0(arg, malloc) {
232
206
  const ptr = malloc(arg.length * 1, 1) >>> 0;
233
207
  getUint8ArrayMemory0().set(arg, ptr / 1);
234
208
  WASM_VECTOR_LEN = arg.length;
235
209
  return ptr;
236
210
  }
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
211
  /**
287
212
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
288
213
  *
@@ -329,75 +254,6 @@ module.exports.executeProgram = function(program, initial_witness, foreign_call_
329
254
  return ret;
330
255
  };
331
256
 
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
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
343
- *
344
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
345
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
346
- * @returns {WitnessMap} A witness map containing the circuit's return values.
347
- * @param {Uint8Array} program
348
- * @param {WitnessMap} witness_map
349
- * @returns {WitnessMap}
350
- */
351
- module.exports.getReturnWitness = function(program, witness_map) {
352
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
353
- const len0 = WASM_VECTOR_LEN;
354
- const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
355
- if (ret[2]) {
356
- throw takeFromExternrefTable0(ret[1]);
357
- }
358
- return takeFromExternrefTable0(ret[0]);
359
- };
360
-
361
- /**
362
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
363
- *
364
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
365
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
366
- * @returns {WitnessMap} A witness map containing the circuit's public parameters.
367
- * @param {Uint8Array} program
368
- * @param {WitnessMap} solved_witness
369
- * @returns {WitnessMap}
370
- */
371
- module.exports.getPublicParametersWitness = function(program, solved_witness) {
372
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
373
- const len0 = WASM_VECTOR_LEN;
374
- const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
375
- if (ret[2]) {
376
- throw takeFromExternrefTable0(ret[1]);
377
- }
378
- return takeFromExternrefTable0(ret[0]);
379
- };
380
-
381
- /**
382
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
383
- *
384
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
385
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
386
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
387
- * @param {Uint8Array} program
388
- * @param {WitnessMap} solved_witness
389
- * @returns {WitnessMap}
390
- */
391
- module.exports.getPublicWitness = function(program, solved_witness) {
392
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
393
- const len0 = WASM_VECTOR_LEN;
394
- const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
395
- if (ret[2]) {
396
- throw takeFromExternrefTable0(ret[1]);
397
- }
398
- return takeFromExternrefTable0(ret[0]);
399
- };
400
-
401
257
  /**
402
258
  * Performs a bitwise AND operation between `lhs` and `rhs`
403
259
  * @param {string} lhs
@@ -457,6 +313,10 @@ module.exports.sha256_compression = function(inputs, state) {
457
313
  return v3;
458
314
  };
459
315
 
316
+ function getArrayU8FromWasm0(ptr, len) {
317
+ ptr = ptr >>> 0;
318
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
319
+ }
460
320
  /**
461
321
  * Calculates the Blake2s256 hash of the input bytes
462
322
  * @param {Uint8Array} inputs
@@ -513,6 +373,11 @@ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes,
513
373
  return ret !== 0;
514
374
  };
515
375
 
376
+ function takeFromExternrefTable0(idx) {
377
+ const value = wasm.__wbindgen_export_2.get(idx);
378
+ wasm.__externref_table_dealloc(idx);
379
+ return value;
380
+ }
516
381
  /**
517
382
  * Sets the package's logging level.
518
383
  *
@@ -527,16 +392,150 @@ module.exports.initLogLevel = function(filter) {
527
392
  }
528
393
  };
529
394
 
395
+ /**
396
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
397
+ *
398
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
399
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
400
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
401
+ * @param {Uint8Array} program
402
+ * @param {WitnessMap} witness_map
403
+ * @returns {WitnessMap}
404
+ */
405
+ module.exports.getReturnWitness = function(program, witness_map) {
406
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
407
+ const len0 = WASM_VECTOR_LEN;
408
+ const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
409
+ if (ret[2]) {
410
+ throw takeFromExternrefTable0(ret[1]);
411
+ }
412
+ return takeFromExternrefTable0(ret[0]);
413
+ };
414
+
415
+ /**
416
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
417
+ *
418
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
419
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
420
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
421
+ * @param {Uint8Array} program
422
+ * @param {WitnessMap} solved_witness
423
+ * @returns {WitnessMap}
424
+ */
425
+ module.exports.getPublicParametersWitness = function(program, solved_witness) {
426
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
427
+ const len0 = WASM_VECTOR_LEN;
428
+ const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
429
+ if (ret[2]) {
430
+ throw takeFromExternrefTable0(ret[1]);
431
+ }
432
+ return takeFromExternrefTable0(ret[0]);
433
+ };
434
+
435
+ /**
436
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
437
+ *
438
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
439
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
440
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
441
+ * @param {Uint8Array} program
442
+ * @param {WitnessMap} solved_witness
443
+ * @returns {WitnessMap}
444
+ */
445
+ module.exports.getPublicWitness = function(program, solved_witness) {
446
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
447
+ const len0 = WASM_VECTOR_LEN;
448
+ const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
449
+ if (ret[2]) {
450
+ throw takeFromExternrefTable0(ret[1]);
451
+ }
452
+ return takeFromExternrefTable0(ret[0]);
453
+ };
454
+
455
+ /**
456
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
457
+ * @returns {BuildInfo} - Information on how the installed package was built.
458
+ */
459
+ module.exports.buildInfo = function() {
460
+ const ret = wasm.buildInfo();
461
+ return ret;
462
+ };
463
+
464
+ /**
465
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
466
+ *
467
+ * @param {WitnessMap} witness_map - A witness map.
468
+ * @returns {Uint8Array} A compressed witness map
469
+ */
470
+ module.exports.compressWitness = function(witness_map) {
471
+ const ret = wasm.compressWitness(witness_map);
472
+ if (ret[3]) {
473
+ throw takeFromExternrefTable0(ret[2]);
474
+ }
475
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
476
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
477
+ return v1;
478
+ };
479
+
480
+ /**
481
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
482
+ * This should be used to only fetch the witness map for the main function.
483
+ *
484
+ * @param {Uint8Array} compressed_witness - A compressed witness.
485
+ * @returns {WitnessMap} The decompressed witness map.
486
+ */
487
+ module.exports.decompressWitness = function(compressed_witness) {
488
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
489
+ const len0 = WASM_VECTOR_LEN;
490
+ const ret = wasm.decompressWitness(ptr0, len0);
491
+ if (ret[2]) {
492
+ throw takeFromExternrefTable0(ret[1]);
493
+ }
494
+ return takeFromExternrefTable0(ret[0]);
495
+ };
496
+
497
+ /**
498
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
499
+ *
500
+ * @param {WitnessStack} witness_stack - A witness stack.
501
+ * @returns {Uint8Array} A compressed witness stack
502
+ */
503
+ module.exports.compressWitnessStack = function(witness_stack) {
504
+ const ret = wasm.compressWitnessStack(witness_stack);
505
+ if (ret[3]) {
506
+ throw takeFromExternrefTable0(ret[2]);
507
+ }
508
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
509
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
510
+ return v1;
511
+ };
512
+
513
+ /**
514
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
515
+ *
516
+ * @param {Uint8Array} compressed_witness - A compressed witness.
517
+ * @returns {WitnessStack} The decompressed witness stack.
518
+ */
519
+ module.exports.decompressWitnessStack = function(compressed_witness) {
520
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
521
+ const len0 = WASM_VECTOR_LEN;
522
+ const ret = wasm.decompressWitnessStack(ptr0, len0);
523
+ if (ret[2]) {
524
+ throw takeFromExternrefTable0(ret[1]);
525
+ }
526
+ return takeFromExternrefTable0(ret[0]);
527
+ };
528
+
530
529
  function __wbg_adapter_30(arg0, arg1, arg2) {
531
- wasm.closure577_externref_shim(arg0, arg1, arg2);
530
+ wasm.closure573_externref_shim(arg0, arg1, arg2);
532
531
  }
533
532
 
534
533
  function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
535
- wasm.closure1172_externref_shim(arg0, arg1, arg2, arg3, arg4);
534
+ wasm.closure1168_externref_shim(arg0, arg1, arg2, arg3, arg4);
536
535
  }
537
536
 
538
537
  function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
539
- wasm.closure1176_externref_shim(arg0, arg1, arg2, arg3);
538
+ wasm.closure1172_externref_shim(arg0, arg1, arg2, arg3);
540
539
  }
541
540
 
542
541
  module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
@@ -814,8 +813,8 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
814
813
  return ret;
815
814
  };
816
815
 
817
- module.exports.__wbindgen_closure_wrapper1979 = function(arg0, arg1, arg2) {
818
- const ret = makeMutClosure(arg0, arg1, 578, __wbg_adapter_30);
816
+ module.exports.__wbindgen_closure_wrapper1977 = function(arg0, arg1, arg2) {
817
+ const ret = makeMutClosure(arg0, arg1, 574, __wbg_adapter_30);
819
818
  return ret;
820
819
  };
821
820
 
Binary file
@@ -1,17 +1,9 @@
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
4
  export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
9
5
  export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
10
6
  export const executeProgram: (a: number, b: number, c: any, d: any) => any;
11
- export const buildInfo: () => any;
12
- export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
13
- export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
14
- export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
15
7
  export const and: (a: any, b: any) => any;
16
8
  export const xor: (a: any, b: any) => any;
17
9
  export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
@@ -19,6 +11,14 @@ export const blake2s256: (a: number, b: number) => [number, number];
19
11
  export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
20
12
  export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
21
13
  export const initLogLevel: (a: number, b: number) => [number, number];
14
+ export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
15
+ export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
16
+ export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
17
+ export const buildInfo: () => any;
18
+ export const compressWitness: (a: any) => [number, number, number, number];
19
+ export const decompressWitness: (a: number, b: number) => [number, number, number];
20
+ export const compressWitnessStack: (a: any) => [number, number, number, number];
21
+ export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
22
22
  export const __wbindgen_exn_store: (a: number) => void;
23
23
  export const __externref_table_alloc: () => number;
24
24
  export const __wbindgen_export_2: WebAssembly.Table;
@@ -27,7 +27,7 @@ export const __wbindgen_malloc: (a: number, b: number) => number;
27
27
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
28
  export const __wbindgen_export_6: WebAssembly.Table;
29
29
  export const __externref_table_dealloc: (a: number) => void;
30
- export const closure577_externref_shim: (a: number, b: number, c: any) => void;
31
- export const closure1172_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
- export const closure1176_externref_shim: (a: number, b: number, c: any, d: any) => void;
30
+ export const closure573_externref_shim: (a: number, b: number, c: any) => void;
31
+ export const closure1168_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
+ export const closure1172_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-881acee.nightly",
3
+ "version": "1.0.0-beta.15-9dbad18.nightly",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/web/acvm_js.d.ts CHANGED
@@ -1,34 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
5
- *
6
- * @param {WitnessMap} witness_map - A witness map.
7
- * @returns {Uint8Array} A compressed witness map
8
- */
9
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
10
- /**
11
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
12
- * This should be used to only fetch the witness map for the main function.
13
- *
14
- * @param {Uint8Array} compressed_witness - A compressed witness.
15
- * @returns {WitnessMap} The decompressed witness map.
16
- */
17
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
18
- /**
19
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
20
- *
21
- * @param {WitnessStack} witness_stack - A witness stack.
22
- * @returns {Uint8Array} A compressed witness stack
23
- */
24
- export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
25
- /**
26
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
27
- *
28
- * @param {Uint8Array} compressed_witness - A compressed witness.
29
- * @returns {WitnessStack} The decompressed witness stack.
30
- */
31
- export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
32
3
  /**
33
4
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
34
5
  *
@@ -58,10 +29,35 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
58
29
  */
59
30
  export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
60
31
  /**
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.
32
+ * Performs a bitwise AND operation between `lhs` and `rhs`
63
33
  */
64
- export function buildInfo(): BuildInfo;
34
+ export function and(lhs: string, rhs: string): string;
35
+ /**
36
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
37
+ */
38
+ export function xor(lhs: string, rhs: string): string;
39
+ /**
40
+ * Sha256 compression function
41
+ */
42
+ export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
43
+ /**
44
+ * Calculates the Blake2s256 hash of the input bytes
45
+ */
46
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
47
+ /**
48
+ * Verifies a ECDSA signature over the secp256k1 curve.
49
+ */
50
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
51
+ /**
52
+ * Verifies a ECDSA signature over the secp256r1 curve.
53
+ */
54
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
55
+ /**
56
+ * Sets the package's logging level.
57
+ *
58
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
59
+ */
60
+ export function initLogLevel(filter: string): void;
65
61
  /**
66
62
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
67
63
  *
@@ -87,61 +83,60 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
87
83
  */
88
84
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
89
85
  /**
90
- * Performs a bitwise AND operation between `lhs` and `rhs`
91
- */
92
- export function and(lhs: string, rhs: string): string;
93
- /**
94
- * Performs a bitwise XOR operation between `lhs` and `rhs`
95
- */
96
- export function xor(lhs: string, rhs: string): string;
97
- /**
98
- * Sha256 compression function
86
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
87
+ * @returns {BuildInfo} - Information on how the installed package was built.
99
88
  */
100
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
89
+ export function buildInfo(): BuildInfo;
101
90
  /**
102
- * Calculates the Blake2s256 hash of the input bytes
91
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
92
+ *
93
+ * @param {WitnessMap} witness_map - A witness map.
94
+ * @returns {Uint8Array} A compressed witness map
103
95
  */
104
- export function blake2s256(inputs: Uint8Array): Uint8Array;
96
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
105
97
  /**
106
- * Verifies a ECDSA signature over the secp256k1 curve.
98
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
99
+ * This should be used to only fetch the witness map for the main function.
100
+ *
101
+ * @param {Uint8Array} compressed_witness - A compressed witness.
102
+ * @returns {WitnessMap} The decompressed witness map.
107
103
  */
108
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
104
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
109
105
  /**
110
- * Verifies a ECDSA signature over the secp256r1 curve.
106
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
107
+ *
108
+ * @param {WitnessStack} witness_stack - A witness stack.
109
+ * @returns {Uint8Array} A compressed witness stack
111
110
  */
112
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
111
+ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
113
112
  /**
114
- * Sets the package's logging level.
113
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
115
114
  *
116
- * @param {LogLevel} level - The maximum level of logging to be emitted.
115
+ * @param {Uint8Array} compressed_witness - A compressed witness.
116
+ * @returns {WitnessStack} The decompressed witness stack.
117
117
  */
118
- export function initLogLevel(filter: string): void;
118
+ export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
119
+
120
+ export type ForeignCallInput = string[]
121
+ export type ForeignCallOutput = string | string[]
119
122
 
120
123
  /**
121
- * @typedef {Object} BuildInfo - Information about how the installed package was built
122
- * @property {string} gitHash - The hash of the git commit from which the package was built.
123
- * @property {string} version - The version of the package at the built git commit.
124
- * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
125
- */
126
- export type BuildInfo = {
127
- gitHash: string;
128
- version: string;
129
- dirty: string;
130
- }
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[]>;
131
131
 
132
132
 
133
133
 
134
- export type RawAssertionPayload = {
135
- selector: string;
136
- data: string[];
137
- };
134
+ export type StackItem = {
135
+ index: number;
136
+ witness: WitnessMap;
137
+ }
138
138
 
139
- export type ExecutionError = Error & {
140
- callStack?: string[];
141
- rawAssertionPayload?: RawAssertionPayload;
142
- acirFunctionId?: number;
143
- brilligFunctionId?: number;
144
- };
139
+ export type WitnessStack = Array<StackItem>;
145
140
 
146
141
 
147
142
 
@@ -160,44 +155,41 @@ export type SolvedAndReturnWitness = {
160
155
 
161
156
 
162
157
 
163
- export type ForeignCallInput = string[]
164
- export type ForeignCallOutput = string | string[]
158
+ export type RawAssertionPayload = {
159
+ selector: string;
160
+ data: string[];
161
+ };
165
162
 
166
- /**
167
- * A callback which performs an foreign call and returns the response.
168
- * @callback ForeignCallHandler
169
- * @param {string} name - The identifier for the type of foreign call being performed.
170
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
171
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
172
- */
173
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
163
+ export type ExecutionError = Error & {
164
+ callStack?: string[];
165
+ rawAssertionPayload?: RawAssertionPayload;
166
+ acirFunctionId?: number;
167
+ brilligFunctionId?: number;
168
+ };
174
169
 
175
170
 
176
171
 
177
- export type StackItem = {
178
- index: number;
179
- witness: WitnessMap;
172
+ /**
173
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
174
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
175
+ * @property {string} version - The version of the package at the built git commit.
176
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
177
+ */
178
+ export type BuildInfo = {
179
+ gitHash: string;
180
+ version: string;
181
+ dirty: string;
180
182
  }
181
183
 
182
- export type WitnessStack = Array<StackItem>;
183
-
184
184
 
185
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
190
  readonly executeCircuit: (a: number, b: number, c: any, d: any) => any;
195
191
  readonly executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
196
192
  readonly executeProgram: (a: number, b: number, c: any, d: any) => any;
197
- readonly buildInfo: () => any;
198
- readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
199
- readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
200
- readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
201
193
  readonly and: (a: any, b: any) => any;
202
194
  readonly xor: (a: any, b: any) => any;
203
195
  readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
@@ -205,6 +197,14 @@ export interface InitOutput {
205
197
  readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
206
198
  readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
207
199
  readonly initLogLevel: (a: number, b: number) => [number, number];
200
+ readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
201
+ readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
202
+ readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
203
+ readonly buildInfo: () => any;
204
+ readonly compressWitness: (a: any) => [number, number, number, number];
205
+ readonly decompressWitness: (a: number, b: number) => [number, number, number];
206
+ readonly compressWitnessStack: (a: any) => [number, number, number, number];
207
+ readonly decompressWitnessStack: (a: number, b: number) => [number, number, number];
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 closure577_externref_shim: (a: number, b: number, c: any) => void;
217
- readonly closure1172_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
218
- readonly closure1176_externref_shim: (a: number, b: number, c: any, d: any) => void;
216
+ readonly closure573_externref_shim: (a: number, b: number, c: any) => void;
217
+ readonly closure1168_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
218
+ readonly closure1172_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
@@ -198,87 +198,12 @@ function debugString(val) {
198
198
  return className;
199
199
  }
200
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
201
  function passArray8ToWasm0(arg, malloc) {
228
202
  const ptr = malloc(arg.length * 1, 1) >>> 0;
229
203
  getUint8ArrayMemory0().set(arg, ptr / 1);
230
204
  WASM_VECTOR_LEN = arg.length;
231
205
  return ptr;
232
206
  }
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
207
  /**
283
208
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
284
209
  *
@@ -325,75 +250,6 @@ export function executeProgram(program, initial_witness, foreign_call_handler) {
325
250
  return ret;
326
251
  }
327
252
 
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
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
339
- *
340
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
341
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
342
- * @returns {WitnessMap} A witness map containing the circuit's return values.
343
- * @param {Uint8Array} program
344
- * @param {WitnessMap} witness_map
345
- * @returns {WitnessMap}
346
- */
347
- export function getReturnWitness(program, witness_map) {
348
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
349
- const len0 = WASM_VECTOR_LEN;
350
- const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
351
- if (ret[2]) {
352
- throw takeFromExternrefTable0(ret[1]);
353
- }
354
- return takeFromExternrefTable0(ret[0]);
355
- }
356
-
357
- /**
358
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
359
- *
360
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
361
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
362
- * @returns {WitnessMap} A witness map containing the circuit's public parameters.
363
- * @param {Uint8Array} program
364
- * @param {WitnessMap} solved_witness
365
- * @returns {WitnessMap}
366
- */
367
- export function getPublicParametersWitness(program, solved_witness) {
368
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
369
- const len0 = WASM_VECTOR_LEN;
370
- const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
371
- if (ret[2]) {
372
- throw takeFromExternrefTable0(ret[1]);
373
- }
374
- return takeFromExternrefTable0(ret[0]);
375
- }
376
-
377
- /**
378
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
379
- *
380
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
381
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
382
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
383
- * @param {Uint8Array} program
384
- * @param {WitnessMap} solved_witness
385
- * @returns {WitnessMap}
386
- */
387
- export function getPublicWitness(program, solved_witness) {
388
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
389
- const len0 = WASM_VECTOR_LEN;
390
- const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
391
- if (ret[2]) {
392
- throw takeFromExternrefTable0(ret[1]);
393
- }
394
- return takeFromExternrefTable0(ret[0]);
395
- }
396
-
397
253
  /**
398
254
  * Performs a bitwise AND operation between `lhs` and `rhs`
399
255
  * @param {string} lhs
@@ -453,6 +309,10 @@ export function sha256_compression(inputs, state) {
453
309
  return v3;
454
310
  }
455
311
 
312
+ function getArrayU8FromWasm0(ptr, len) {
313
+ ptr = ptr >>> 0;
314
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
315
+ }
456
316
  /**
457
317
  * Calculates the Blake2s256 hash of the input bytes
458
318
  * @param {Uint8Array} inputs
@@ -509,6 +369,11 @@ export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_ke
509
369
  return ret !== 0;
510
370
  }
511
371
 
372
+ function takeFromExternrefTable0(idx) {
373
+ const value = wasm.__wbindgen_export_2.get(idx);
374
+ wasm.__externref_table_dealloc(idx);
375
+ return value;
376
+ }
512
377
  /**
513
378
  * Sets the package's logging level.
514
379
  *
@@ -523,16 +388,150 @@ export function initLogLevel(filter) {
523
388
  }
524
389
  }
525
390
 
391
+ /**
392
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
393
+ *
394
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
395
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
396
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
397
+ * @param {Uint8Array} program
398
+ * @param {WitnessMap} witness_map
399
+ * @returns {WitnessMap}
400
+ */
401
+ export function getReturnWitness(program, witness_map) {
402
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
403
+ const len0 = WASM_VECTOR_LEN;
404
+ const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
405
+ if (ret[2]) {
406
+ throw takeFromExternrefTable0(ret[1]);
407
+ }
408
+ return takeFromExternrefTable0(ret[0]);
409
+ }
410
+
411
+ /**
412
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
413
+ *
414
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
415
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
416
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
417
+ * @param {Uint8Array} program
418
+ * @param {WitnessMap} solved_witness
419
+ * @returns {WitnessMap}
420
+ */
421
+ export function getPublicParametersWitness(program, solved_witness) {
422
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
423
+ const len0 = WASM_VECTOR_LEN;
424
+ const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
425
+ if (ret[2]) {
426
+ throw takeFromExternrefTable0(ret[1]);
427
+ }
428
+ return takeFromExternrefTable0(ret[0]);
429
+ }
430
+
431
+ /**
432
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
433
+ *
434
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
435
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
436
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
437
+ * @param {Uint8Array} program
438
+ * @param {WitnessMap} solved_witness
439
+ * @returns {WitnessMap}
440
+ */
441
+ export function getPublicWitness(program, solved_witness) {
442
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
443
+ const len0 = WASM_VECTOR_LEN;
444
+ const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
445
+ if (ret[2]) {
446
+ throw takeFromExternrefTable0(ret[1]);
447
+ }
448
+ return takeFromExternrefTable0(ret[0]);
449
+ }
450
+
451
+ /**
452
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
453
+ * @returns {BuildInfo} - Information on how the installed package was built.
454
+ */
455
+ export function buildInfo() {
456
+ const ret = wasm.buildInfo();
457
+ return ret;
458
+ }
459
+
460
+ /**
461
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
462
+ *
463
+ * @param {WitnessMap} witness_map - A witness map.
464
+ * @returns {Uint8Array} A compressed witness map
465
+ */
466
+ export function compressWitness(witness_map) {
467
+ const ret = wasm.compressWitness(witness_map);
468
+ if (ret[3]) {
469
+ throw takeFromExternrefTable0(ret[2]);
470
+ }
471
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
472
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
473
+ return v1;
474
+ }
475
+
476
+ /**
477
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
478
+ * This should be used to only fetch the witness map for the main function.
479
+ *
480
+ * @param {Uint8Array} compressed_witness - A compressed witness.
481
+ * @returns {WitnessMap} The decompressed witness map.
482
+ */
483
+ export function decompressWitness(compressed_witness) {
484
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
485
+ const len0 = WASM_VECTOR_LEN;
486
+ const ret = wasm.decompressWitness(ptr0, len0);
487
+ if (ret[2]) {
488
+ throw takeFromExternrefTable0(ret[1]);
489
+ }
490
+ return takeFromExternrefTable0(ret[0]);
491
+ }
492
+
493
+ /**
494
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
495
+ *
496
+ * @param {WitnessStack} witness_stack - A witness stack.
497
+ * @returns {Uint8Array} A compressed witness stack
498
+ */
499
+ export function compressWitnessStack(witness_stack) {
500
+ const ret = wasm.compressWitnessStack(witness_stack);
501
+ if (ret[3]) {
502
+ throw takeFromExternrefTable0(ret[2]);
503
+ }
504
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
505
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
506
+ return v1;
507
+ }
508
+
509
+ /**
510
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
511
+ *
512
+ * @param {Uint8Array} compressed_witness - A compressed witness.
513
+ * @returns {WitnessStack} The decompressed witness stack.
514
+ */
515
+ export function decompressWitnessStack(compressed_witness) {
516
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
517
+ const len0 = WASM_VECTOR_LEN;
518
+ const ret = wasm.decompressWitnessStack(ptr0, len0);
519
+ if (ret[2]) {
520
+ throw takeFromExternrefTable0(ret[1]);
521
+ }
522
+ return takeFromExternrefTable0(ret[0]);
523
+ }
524
+
526
525
  function __wbg_adapter_30(arg0, arg1, arg2) {
527
- wasm.closure577_externref_shim(arg0, arg1, arg2);
526
+ wasm.closure573_externref_shim(arg0, arg1, arg2);
528
527
  }
529
528
 
530
529
  function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
531
- wasm.closure1172_externref_shim(arg0, arg1, arg2, arg3, arg4);
530
+ wasm.closure1168_externref_shim(arg0, arg1, arg2, arg3, arg4);
532
531
  }
533
532
 
534
533
  function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
535
- wasm.closure1176_externref_shim(arg0, arg1, arg2, arg3);
534
+ wasm.closure1172_externref_shim(arg0, arg1, arg2, arg3);
536
535
  }
537
536
 
538
537
  async function __wbg_load(module, imports) {
@@ -798,8 +797,8 @@ function __wbg_get_imports() {
798
797
  const ret = false;
799
798
  return ret;
800
799
  };
801
- imports.wbg.__wbindgen_closure_wrapper1979 = function(arg0, arg1, arg2) {
802
- const ret = makeMutClosure(arg0, arg1, 578, __wbg_adapter_30);
800
+ imports.wbg.__wbindgen_closure_wrapper1977 = function(arg0, arg1, arg2) {
801
+ const ret = makeMutClosure(arg0, arg1, 574, __wbg_adapter_30);
803
802
  return ret;
804
803
  };
805
804
  imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
Binary file
@@ -1,17 +1,9 @@
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
4
  export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
9
5
  export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
10
6
  export const executeProgram: (a: number, b: number, c: any, d: any) => any;
11
- export const buildInfo: () => any;
12
- export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
13
- export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
14
- export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
15
7
  export const and: (a: any, b: any) => any;
16
8
  export const xor: (a: any, b: any) => any;
17
9
  export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
@@ -19,6 +11,14 @@ export const blake2s256: (a: number, b: number) => [number, number];
19
11
  export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
20
12
  export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
21
13
  export const initLogLevel: (a: number, b: number) => [number, number];
14
+ export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
15
+ export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
16
+ export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
17
+ export const buildInfo: () => any;
18
+ export const compressWitness: (a: any) => [number, number, number, number];
19
+ export const decompressWitness: (a: number, b: number) => [number, number, number];
20
+ export const compressWitnessStack: (a: any) => [number, number, number, number];
21
+ export const decompressWitnessStack: (a: number, b: number) => [number, number, number];
22
22
  export const __wbindgen_exn_store: (a: number) => void;
23
23
  export const __externref_table_alloc: () => number;
24
24
  export const __wbindgen_export_2: WebAssembly.Table;
@@ -27,7 +27,7 @@ export const __wbindgen_malloc: (a: number, b: number) => number;
27
27
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
28
  export const __wbindgen_export_6: WebAssembly.Table;
29
29
  export const __externref_table_dealloc: (a: number) => void;
30
- export const closure577_externref_shim: (a: number, b: number, c: any) => void;
31
- export const closure1172_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
- export const closure1176_externref_shim: (a: number, b: number, c: any, d: any) => void;
30
+ export const closure573_externref_shim: (a: number, b: number, c: any) => void;
31
+ export const closure1168_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
+ export const closure1172_externref_shim: (a: number, b: number, c: any, d: any) => void;
33
33
  export const __wbindgen_start: () => void;