@noir-lang/acvm_js 0.54.0-b65a63d.nightly → 0.55.0

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.
@@ -30,10 +30,33 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
30
30
  */
31
31
  export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
32
32
  /**
33
- * Returns the `BuildInfo` object containing information about how the installed package was built.
34
- * @returns {BuildInfo} - Information on how the installed package was built.
33
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
34
+ *
35
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
36
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
37
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
38
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
35
39
  */
36
- export function buildInfo(): BuildInfo;
40
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
41
+ /**
42
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
43
+ * This method also extracts the public return values from the solved witness into its own return witness.
44
+ *
45
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
46
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
47
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
48
+ * @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.
49
+ */
50
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
51
+ /**
52
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
53
+ *
54
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
55
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
56
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
57
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
58
+ */
59
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
37
60
  /**
38
61
  * Performs a bitwise AND operation between `lhs` and `rhs`
39
62
  * @param {string} lhs
@@ -80,6 +103,11 @@ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_byte
80
103
  */
81
104
  export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
82
105
  /**
106
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
107
+ * @returns {BuildInfo} - Information on how the installed package was built.
108
+ */
109
+ export function buildInfo(): BuildInfo;
110
+ /**
83
111
  * Sets the package's logging level.
84
112
  *
85
113
  * @param {LogLevel} level - The maximum level of logging to be emitted.
@@ -118,34 +146,29 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
118
146
  * @returns {WitnessMap}
119
147
  */
120
148
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
149
+
150
+ export type ForeignCallInput = string[]
151
+ export type ForeignCallOutput = string | string[]
152
+
121
153
  /**
122
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
123
- *
124
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
125
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
126
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
127
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
128
- */
129
- export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
130
- /**
131
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
132
- * This method also extracts the public return values from the solved witness into its own return witness.
133
- *
134
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
135
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
136
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
137
- * @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.
138
- */
139
- export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
140
- /**
141
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
142
- *
143
- * @param {Uint8Array} program - A serialized representation of an ACIR program
144
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
145
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
146
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
154
+ * A callback which performs an foreign call and returns the response.
155
+ * @callback ForeignCallHandler
156
+ * @param {string} name - The identifier for the type of foreign call being performed.
157
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
158
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
147
159
  */
148
- export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
160
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
161
+
162
+
163
+
164
+ export type StackItem = {
165
+ index: number;
166
+ witness: WitnessMap;
167
+ }
168
+
169
+ export type WitnessStack = Array<StackItem>;
170
+
171
+
149
172
 
150
173
  /**
151
174
  * @typedef {Object} BuildInfo - Information about how the installed package was built
@@ -161,20 +184,6 @@ export type BuildInfo = {
161
184
 
162
185
 
163
186
 
164
- export type ForeignCallInput = string[]
165
- export type ForeignCallOutput = string | string[]
166
-
167
- /**
168
- * A callback which performs an foreign call and returns the response.
169
- * @callback ForeignCallHandler
170
- * @param {string} name - The identifier for the type of foreign call being performed.
171
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
172
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
173
- */
174
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
175
-
176
-
177
-
178
187
  export type RawAssertionPayload = {
179
188
  selector: string;
180
189
  data: string[];
@@ -188,15 +197,6 @@ export type ExecutionError = Error & {
188
197
 
189
198
 
190
199
 
191
- export type StackItem = {
192
- index: number;
193
- witness: WitnessMap;
194
- }
195
-
196
- export type WitnessStack = Array<StackItem>;
197
-
198
-
199
-
200
200
  // Map from witness index to hex string value of witness.
201
201
  export type WitnessMap = Map<number, string>;
202
202
 
package/nodejs/acvm_js.js CHANGED
@@ -45,6 +45,15 @@ function getInt32Memory0() {
45
45
  return cachedInt32Memory0;
46
46
  }
47
47
 
48
+ function addHeapObject(obj) {
49
+ if (heap_next === heap.length) heap.push(heap.length + 1);
50
+ const idx = heap_next;
51
+ heap_next = heap[idx];
52
+
53
+ heap[idx] = obj;
54
+ return idx;
55
+ }
56
+
48
57
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
49
58
 
50
59
  cachedTextDecoder.decode();
@@ -63,15 +72,6 @@ function getStringFromWasm0(ptr, len) {
63
72
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
64
73
  }
65
74
 
66
- function addHeapObject(obj) {
67
- if (heap_next === heap.length) heap.push(heap.length + 1);
68
- const idx = heap_next;
69
- heap_next = heap[idx];
70
-
71
- heap[idx] = obj;
72
- return idx;
73
- }
74
-
75
75
  let WASM_VECTOR_LEN = 0;
76
76
 
77
77
  let cachedTextEncoder = new TextEncoder('utf-8');
@@ -330,11 +330,48 @@ module.exports.decompressWitnessStack = function(compressed_witness) {
330
330
  };
331
331
 
332
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.
333
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
334
+ *
335
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
336
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
337
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
338
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
335
339
  */
336
- module.exports.buildInfo = function() {
337
- const ret = wasm.buildInfo();
340
+ module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
341
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
342
+ const len0 = WASM_VECTOR_LEN;
343
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
344
+ return takeObject(ret);
345
+ };
346
+
347
+ /**
348
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
349
+ * This method also extracts the public return values from the solved witness into its own return witness.
350
+ *
351
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
352
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
353
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
354
+ * @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.
355
+ */
356
+ module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
357
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
358
+ const len0 = WASM_VECTOR_LEN;
359
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
360
+ return takeObject(ret);
361
+ };
362
+
363
+ /**
364
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
365
+ *
366
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
367
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
368
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
369
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
370
+ */
371
+ module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
372
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
373
+ const len0 = WASM_VECTOR_LEN;
374
+ const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
338
375
  return takeObject(ret);
339
376
  };
340
377
 
@@ -467,6 +504,15 @@ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes,
467
504
  return ret !== 0;
468
505
  };
469
506
 
507
+ /**
508
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
509
+ * @returns {BuildInfo} - Information on how the installed package was built.
510
+ */
511
+ module.exports.buildInfo = function() {
512
+ const ret = wasm.buildInfo();
513
+ return takeObject(ret);
514
+ };
515
+
470
516
  /**
471
517
  * Sets the package's logging level.
472
518
  *
@@ -572,52 +618,6 @@ module.exports.getPublicWitness = function(program, solved_witness) {
572
618
  }
573
619
  };
574
620
 
575
- /**
576
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
577
- *
578
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
579
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
580
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
581
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
582
- */
583
- module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
584
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
585
- const len0 = WASM_VECTOR_LEN;
586
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
587
- return takeObject(ret);
588
- };
589
-
590
- /**
591
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
592
- * This method also extracts the public return values from the solved witness into its own return witness.
593
- *
594
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
595
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
596
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
597
- * @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.
598
- */
599
- module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
600
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
601
- const len0 = WASM_VECTOR_LEN;
602
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
603
- return takeObject(ret);
604
- };
605
-
606
- /**
607
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
608
- *
609
- * @param {Uint8Array} program - A serialized representation of an ACIR program
610
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
611
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
612
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
613
- */
614
- module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
615
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
616
- const len0 = WASM_VECTOR_LEN;
617
- const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
618
- return takeObject(ret);
619
- };
620
-
621
621
  function __wbg_adapter_75(arg0, arg1, arg2, arg3, arg4) {
622
622
  wasm.wasm_bindgen__convert__closures__invoke3_mut__h45040feada3ebb25(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
623
623
  }
@@ -637,23 +637,6 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
637
637
  takeObject(arg0);
638
638
  };
639
639
 
640
- module.exports.__wbindgen_number_get = function(arg0, arg1) {
641
- const obj = getObject(arg1);
642
- const ret = typeof(obj) === 'number' ? obj : undefined;
643
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
644
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
645
- };
646
-
647
- module.exports.__wbindgen_is_string = function(arg0) {
648
- const ret = typeof(getObject(arg0)) === 'string';
649
- return ret;
650
- };
651
-
652
- module.exports.__wbindgen_is_array = function(arg0) {
653
- const ret = Array.isArray(getObject(arg0));
654
- return ret;
655
- };
656
-
657
640
  module.exports.__wbindgen_cb_drop = function(arg0) {
658
641
  const obj = takeObject(arg0).original;
659
642
  if (obj.cnt-- == 1) {
@@ -664,17 +647,19 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
664
647
  return ret;
665
648
  };
666
649
 
667
- module.exports.__wbg_constructor_79bab16c42849d1b = function(arg0) {
668
- const ret = new Error(takeObject(arg0));
669
- return addHeapObject(ret);
650
+ module.exports.__wbindgen_is_array = function(arg0) {
651
+ const ret = Array.isArray(getObject(arg0));
652
+ return ret;
670
653
  };
671
654
 
672
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
673
- const ret = getStringFromWasm0(arg0, arg1);
674
- return addHeapObject(ret);
655
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
656
+ const obj = getObject(arg1);
657
+ const ret = typeof(obj) === 'number' ? obj : undefined;
658
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
659
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
675
660
  };
676
661
 
677
- module.exports.__wbg_new_610492d70b2d4e55 = function() {
662
+ module.exports.__wbg_new_f4a2f4980eb0a66e = function() {
678
663
  const ret = new Array();
679
664
  return addHeapObject(ret);
680
665
  };
@@ -684,7 +669,22 @@ module.exports.__wbindgen_number_new = function(arg0) {
684
669
  return addHeapObject(ret);
685
670
  };
686
671
 
687
- module.exports.__wbg_new_7b5514a697f386eb = function() {
672
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
673
+ const ret = getStringFromWasm0(arg0, arg1);
674
+ return addHeapObject(ret);
675
+ };
676
+
677
+ module.exports.__wbg_constructor_bb18ee055059e54b = function(arg0) {
678
+ const ret = new Error(takeObject(arg0));
679
+ return addHeapObject(ret);
680
+ };
681
+
682
+ module.exports.__wbindgen_is_string = function(arg0) {
683
+ const ret = typeof(getObject(arg0)) === 'string';
684
+ return ret;
685
+ };
686
+
687
+ module.exports.__wbg_new_e0a89522928fc0a3 = function() {
688
688
  const ret = new Map();
689
689
  return addHeapObject(ret);
690
690
  };
@@ -916,7 +916,7 @@ module.exports.__wbindgen_throw = function(arg0, arg1) {
916
916
  throw new Error(getStringFromWasm0(arg0, arg1));
917
917
  };
918
918
 
919
- module.exports.__wbindgen_closure_wrapper737 = function(arg0, arg1, arg2) {
919
+ module.exports.__wbindgen_closure_wrapper726 = function(arg0, arg1, arg2) {
920
920
  const ret = makeMutClosure(arg0, arg1, 265, __wbg_adapter_22);
921
921
  return addHeapObject(ret);
922
922
  };
Binary file
@@ -5,20 +5,20 @@ export function compressWitness(a: number, b: number): void;
5
5
  export function decompressWitness(a: number, b: number, c: number): void;
6
6
  export function compressWitnessStack(a: number, b: number): void;
7
7
  export function decompressWitnessStack(a: number, b: number, c: number): void;
8
- export function buildInfo(): number;
8
+ export function executeCircuit(a: number, b: number, c: number, d: number): number;
9
+ export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
10
+ export function executeProgram(a: number, b: number, c: number, d: number): number;
9
11
  export function and(a: number, b: number): number;
10
12
  export function xor(a: number, b: number): number;
11
13
  export function sha256_compression(a: number, b: number, c: number, d: number, e: number): void;
12
14
  export function blake2s256(a: number, b: number, c: number): void;
13
15
  export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
14
16
  export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
17
+ export function buildInfo(): number;
15
18
  export function initLogLevel(a: number, b: number, c: number): void;
16
19
  export function getReturnWitness(a: number, b: number, c: number, d: number): void;
17
20
  export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
18
21
  export function getPublicWitness(a: number, b: number, c: number, d: number): void;
19
- export function executeCircuit(a: number, b: number, c: number, d: number): number;
20
- export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
21
- export function executeProgram(a: number, b: number, c: number, d: number): number;
22
22
  export function __wbindgen_malloc(a: number): number;
23
23
  export function __wbindgen_realloc(a: number, b: number, c: number): number;
24
24
  export const __wbindgen_export_2: WebAssembly.Table;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noir-lang/acvm_js",
3
- "version": "0.54.0-b65a63d.nightly",
3
+ "version": "0.55.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/web/acvm_js.d.ts CHANGED
@@ -30,10 +30,33 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
30
30
  */
31
31
  export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
32
32
  /**
33
- * Returns the `BuildInfo` object containing information about how the installed package was built.
34
- * @returns {BuildInfo} - Information on how the installed package was built.
33
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
34
+ *
35
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
36
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
37
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
38
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
35
39
  */
36
- export function buildInfo(): BuildInfo;
40
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
41
+ /**
42
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
43
+ * This method also extracts the public return values from the solved witness into its own return witness.
44
+ *
45
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
46
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
47
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
48
+ * @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.
49
+ */
50
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
51
+ /**
52
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
53
+ *
54
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
55
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
56
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
57
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
58
+ */
59
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
37
60
  /**
38
61
  * Performs a bitwise AND operation between `lhs` and `rhs`
39
62
  * @param {string} lhs
@@ -80,6 +103,11 @@ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_byte
80
103
  */
81
104
  export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
82
105
  /**
106
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
107
+ * @returns {BuildInfo} - Information on how the installed package was built.
108
+ */
109
+ export function buildInfo(): BuildInfo;
110
+ /**
83
111
  * Sets the package's logging level.
84
112
  *
85
113
  * @param {LogLevel} level - The maximum level of logging to be emitted.
@@ -118,34 +146,29 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
118
146
  * @returns {WitnessMap}
119
147
  */
120
148
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
149
+
150
+ export type ForeignCallInput = string[]
151
+ export type ForeignCallOutput = string | string[]
152
+
121
153
  /**
122
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
123
- *
124
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
125
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
126
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
127
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
128
- */
129
- export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
130
- /**
131
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
132
- * This method also extracts the public return values from the solved witness into its own return witness.
133
- *
134
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
135
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
136
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
137
- * @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.
138
- */
139
- export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
140
- /**
141
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
142
- *
143
- * @param {Uint8Array} program - A serialized representation of an ACIR program
144
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
145
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
146
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
154
+ * A callback which performs an foreign call and returns the response.
155
+ * @callback ForeignCallHandler
156
+ * @param {string} name - The identifier for the type of foreign call being performed.
157
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
158
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
147
159
  */
148
- export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
160
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
161
+
162
+
163
+
164
+ export type StackItem = {
165
+ index: number;
166
+ witness: WitnessMap;
167
+ }
168
+
169
+ export type WitnessStack = Array<StackItem>;
170
+
171
+
149
172
 
150
173
  /**
151
174
  * @typedef {Object} BuildInfo - Information about how the installed package was built
@@ -161,20 +184,6 @@ export type BuildInfo = {
161
184
 
162
185
 
163
186
 
164
- export type ForeignCallInput = string[]
165
- export type ForeignCallOutput = string | string[]
166
-
167
- /**
168
- * A callback which performs an foreign call and returns the response.
169
- * @callback ForeignCallHandler
170
- * @param {string} name - The identifier for the type of foreign call being performed.
171
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
172
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
173
- */
174
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
175
-
176
-
177
-
178
187
  export type RawAssertionPayload = {
179
188
  selector: string;
180
189
  data: string[];
@@ -188,15 +197,6 @@ export type ExecutionError = Error & {
188
197
 
189
198
 
190
199
 
191
- export type StackItem = {
192
- index: number;
193
- witness: WitnessMap;
194
- }
195
-
196
- export type WitnessStack = Array<StackItem>;
197
-
198
-
199
-
200
200
  // Map from witness index to hex string value of witness.
201
201
  export type WitnessMap = Map<number, string>;
202
202
 
@@ -220,20 +220,20 @@ export interface InitOutput {
220
220
  readonly decompressWitness: (a: number, b: number, c: number) => void;
221
221
  readonly compressWitnessStack: (a: number, b: number) => void;
222
222
  readonly decompressWitnessStack: (a: number, b: number, c: number) => void;
223
- readonly buildInfo: () => number;
223
+ readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
224
+ readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number) => number;
225
+ readonly executeProgram: (a: number, b: number, c: number, d: number) => number;
224
226
  readonly and: (a: number, b: number) => number;
225
227
  readonly xor: (a: number, b: number) => number;
226
228
  readonly sha256_compression: (a: number, b: number, c: number, d: number, e: number) => void;
227
229
  readonly blake2s256: (a: number, b: number, c: number) => void;
228
230
  readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
229
231
  readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
232
+ readonly buildInfo: () => number;
230
233
  readonly initLogLevel: (a: number, b: number, c: number) => void;
231
234
  readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
232
235
  readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
233
236
  readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
234
- readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
235
- readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number) => number;
236
- readonly executeProgram: (a: number, b: number, c: number, d: number) => number;
237
237
  readonly __wbindgen_malloc: (a: number) => number;
238
238
  readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
239
239
  readonly __wbindgen_export_2: WebAssembly.Table;
package/web/acvm_js.js CHANGED
@@ -42,6 +42,15 @@ function getInt32Memory0() {
42
42
  return cachedInt32Memory0;
43
43
  }
44
44
 
45
+ function addHeapObject(obj) {
46
+ if (heap_next === heap.length) heap.push(heap.length + 1);
47
+ const idx = heap_next;
48
+ heap_next = heap[idx];
49
+
50
+ heap[idx] = obj;
51
+ return idx;
52
+ }
53
+
45
54
  const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
46
55
 
47
56
  if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
@@ -60,15 +69,6 @@ function getStringFromWasm0(ptr, len) {
60
69
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
61
70
  }
62
71
 
63
- function addHeapObject(obj) {
64
- if (heap_next === heap.length) heap.push(heap.length + 1);
65
- const idx = heap_next;
66
- heap_next = heap[idx];
67
-
68
- heap[idx] = obj;
69
- return idx;
70
- }
71
-
72
72
  let WASM_VECTOR_LEN = 0;
73
73
 
74
74
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
@@ -327,11 +327,48 @@ export function decompressWitnessStack(compressed_witness) {
327
327
  }
328
328
 
329
329
  /**
330
- * Returns the `BuildInfo` object containing information about how the installed package was built.
331
- * @returns {BuildInfo} - Information on how the installed package was built.
330
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
331
+ *
332
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
333
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
334
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
335
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
332
336
  */
333
- export function buildInfo() {
334
- const ret = wasm.buildInfo();
337
+ export function executeCircuit(program, initial_witness, foreign_call_handler) {
338
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
339
+ const len0 = WASM_VECTOR_LEN;
340
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
341
+ return takeObject(ret);
342
+ }
343
+
344
+ /**
345
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
346
+ * This method also extracts the public return values from the solved witness into its own return witness.
347
+ *
348
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
349
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
350
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
351
+ * @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.
352
+ */
353
+ export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
354
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
355
+ const len0 = WASM_VECTOR_LEN;
356
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
357
+ return takeObject(ret);
358
+ }
359
+
360
+ /**
361
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
362
+ *
363
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
364
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
365
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
366
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
367
+ */
368
+ export function executeProgram(program, initial_witness, foreign_call_handler) {
369
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
370
+ const len0 = WASM_VECTOR_LEN;
371
+ const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
335
372
  return takeObject(ret);
336
373
  }
337
374
 
@@ -464,6 +501,15 @@ export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_ke
464
501
  return ret !== 0;
465
502
  }
466
503
 
504
+ /**
505
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
506
+ * @returns {BuildInfo} - Information on how the installed package was built.
507
+ */
508
+ export function buildInfo() {
509
+ const ret = wasm.buildInfo();
510
+ return takeObject(ret);
511
+ }
512
+
467
513
  /**
468
514
  * Sets the package's logging level.
469
515
  *
@@ -569,52 +615,6 @@ export function getPublicWitness(program, solved_witness) {
569
615
  }
570
616
  }
571
617
 
572
- /**
573
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
574
- *
575
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
576
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
577
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
578
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
579
- */
580
- export function executeCircuit(program, initial_witness, foreign_call_handler) {
581
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
582
- const len0 = WASM_VECTOR_LEN;
583
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
584
- return takeObject(ret);
585
- }
586
-
587
- /**
588
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
589
- * This method also extracts the public return values from the solved witness into its own return witness.
590
- *
591
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
592
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
593
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
594
- * @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.
595
- */
596
- export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
597
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
598
- const len0 = WASM_VECTOR_LEN;
599
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
600
- return takeObject(ret);
601
- }
602
-
603
- /**
604
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
605
- *
606
- * @param {Uint8Array} program - A serialized representation of an ACIR program
607
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
608
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
609
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
610
- */
611
- export function executeProgram(program, initial_witness, foreign_call_handler) {
612
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
613
- const len0 = WASM_VECTOR_LEN;
614
- const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
615
- return takeObject(ret);
616
- }
617
-
618
618
  function __wbg_adapter_75(arg0, arg1, arg2, arg3, arg4) {
619
619
  wasm.wasm_bindgen__convert__closures__invoke3_mut__h45040feada3ebb25(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
620
620
  }
@@ -667,20 +667,6 @@ function __wbg_get_imports() {
667
667
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
668
668
  takeObject(arg0);
669
669
  };
670
- imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
671
- const obj = getObject(arg1);
672
- const ret = typeof(obj) === 'number' ? obj : undefined;
673
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
674
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
675
- };
676
- imports.wbg.__wbindgen_is_string = function(arg0) {
677
- const ret = typeof(getObject(arg0)) === 'string';
678
- return ret;
679
- };
680
- imports.wbg.__wbindgen_is_array = function(arg0) {
681
- const ret = Array.isArray(getObject(arg0));
682
- return ret;
683
- };
684
670
  imports.wbg.__wbindgen_cb_drop = function(arg0) {
685
671
  const obj = takeObject(arg0).original;
686
672
  if (obj.cnt-- == 1) {
@@ -690,15 +676,17 @@ function __wbg_get_imports() {
690
676
  const ret = false;
691
677
  return ret;
692
678
  };
693
- imports.wbg.__wbg_constructor_79bab16c42849d1b = function(arg0) {
694
- const ret = new Error(takeObject(arg0));
695
- return addHeapObject(ret);
679
+ imports.wbg.__wbindgen_is_array = function(arg0) {
680
+ const ret = Array.isArray(getObject(arg0));
681
+ return ret;
696
682
  };
697
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
698
- const ret = getStringFromWasm0(arg0, arg1);
699
- return addHeapObject(ret);
683
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
684
+ const obj = getObject(arg1);
685
+ const ret = typeof(obj) === 'number' ? obj : undefined;
686
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
687
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
700
688
  };
701
- imports.wbg.__wbg_new_610492d70b2d4e55 = function() {
689
+ imports.wbg.__wbg_new_f4a2f4980eb0a66e = function() {
702
690
  const ret = new Array();
703
691
  return addHeapObject(ret);
704
692
  };
@@ -706,7 +694,19 @@ function __wbg_get_imports() {
706
694
  const ret = arg0;
707
695
  return addHeapObject(ret);
708
696
  };
709
- imports.wbg.__wbg_new_7b5514a697f386eb = function() {
697
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
698
+ const ret = getStringFromWasm0(arg0, arg1);
699
+ return addHeapObject(ret);
700
+ };
701
+ imports.wbg.__wbg_constructor_bb18ee055059e54b = function(arg0) {
702
+ const ret = new Error(takeObject(arg0));
703
+ return addHeapObject(ret);
704
+ };
705
+ imports.wbg.__wbindgen_is_string = function(arg0) {
706
+ const ret = typeof(getObject(arg0)) === 'string';
707
+ return ret;
708
+ };
709
+ imports.wbg.__wbg_new_e0a89522928fc0a3 = function() {
710
710
  const ret = new Map();
711
711
  return addHeapObject(ret);
712
712
  };
@@ -901,7 +901,7 @@ function __wbg_get_imports() {
901
901
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
902
902
  throw new Error(getStringFromWasm0(arg0, arg1));
903
903
  };
904
- imports.wbg.__wbindgen_closure_wrapper737 = function(arg0, arg1, arg2) {
904
+ imports.wbg.__wbindgen_closure_wrapper726 = function(arg0, arg1, arg2) {
905
905
  const ret = makeMutClosure(arg0, arg1, 265, __wbg_adapter_22);
906
906
  return addHeapObject(ret);
907
907
  };
Binary file
@@ -5,20 +5,20 @@ export function compressWitness(a: number, b: number): void;
5
5
  export function decompressWitness(a: number, b: number, c: number): void;
6
6
  export function compressWitnessStack(a: number, b: number): void;
7
7
  export function decompressWitnessStack(a: number, b: number, c: number): void;
8
- export function buildInfo(): number;
8
+ export function executeCircuit(a: number, b: number, c: number, d: number): number;
9
+ export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
10
+ export function executeProgram(a: number, b: number, c: number, d: number): number;
9
11
  export function and(a: number, b: number): number;
10
12
  export function xor(a: number, b: number): number;
11
13
  export function sha256_compression(a: number, b: number, c: number, d: number, e: number): void;
12
14
  export function blake2s256(a: number, b: number, c: number): void;
13
15
  export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
14
16
  export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
17
+ export function buildInfo(): number;
15
18
  export function initLogLevel(a: number, b: number, c: number): void;
16
19
  export function getReturnWitness(a: number, b: number, c: number, d: number): void;
17
20
  export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
18
21
  export function getPublicWitness(a: number, b: number, c: number, d: number): void;
19
- export function executeCircuit(a: number, b: number, c: number, d: number): number;
20
- export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
21
- export function executeProgram(a: number, b: number, c: number, d: number): number;
22
22
  export function __wbindgen_malloc(a: number): number;
23
23
  export function __wbindgen_realloc(a: number, b: number, c: number): number;
24
24
  export const __wbindgen_export_2: WebAssembly.Table;