@noir-lang/acvm_js 0.47.0-d8b9870.nightly → 0.47.0-e59ff8c.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.
@@ -7,34 +7,6 @@
7
7
  */
8
8
  export function initLogLevel(filter: string): void;
9
9
  /**
10
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
11
- *
12
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
13
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
14
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
15
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
16
- */
17
- export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
18
- /**
19
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
20
- * This method also extracts the public return values from the solved witness into its own return witness.
21
- *
22
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
23
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
24
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
25
- * @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.
26
- */
27
- export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
28
- /**
29
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
30
- *
31
- * @param {Uint8Array} program - A serialized representation of an ACIR program
32
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
33
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
34
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
35
- */
36
- export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
37
- /**
38
10
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
39
11
  *
40
12
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
@@ -118,6 +90,34 @@ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_byte
118
90
  */
119
91
  export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
120
92
  /**
93
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
94
+ *
95
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
96
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
97
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
98
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
99
+ */
100
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
101
+ /**
102
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
103
+ * This method also extracts the public return values from the solved witness into its own return witness.
104
+ *
105
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
106
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
107
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
108
+ * @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.
109
+ */
110
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
111
+ /**
112
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
113
+ *
114
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
115
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
116
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
117
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
118
+ */
119
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
120
+ /**
121
121
  * Returns the `BuildInfo` object containing information about how the installed package was built.
122
122
  * @returns {BuildInfo} - Information on how the installed package was built.
123
123
  */
@@ -152,6 +152,20 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
152
152
  */
153
153
  export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
154
154
 
155
+ /**
156
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
157
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
158
+ * @property {string} version - The version of the package at the built git commit.
159
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
160
+ */
161
+ export type BuildInfo = {
162
+ gitHash: string;
163
+ version: string;
164
+ dirty: string;
165
+ }
166
+
167
+
168
+
155
169
  export type ForeignCallInput = string[]
156
170
  export type ForeignCallOutput = string | string[]
157
171
 
@@ -166,12 +180,18 @@ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => P
166
180
 
167
181
 
168
182
 
169
- export type StackItem = {
170
- index: number;
171
- witness: WitnessMap;
172
- }
183
+ // Map from witness index to hex string value of witness.
184
+ export type WitnessMap = Map<number, string>;
173
185
 
174
- export type WitnessStack = Array<StackItem>;
186
+ /**
187
+ * An execution result containing two witnesses.
188
+ * 1. The full solved witness of the execution.
189
+ * 2. The return witness which contains the given public return values within the full witness.
190
+ */
191
+ export type SolvedAndReturnWitness = {
192
+ solvedWitness: WitnessMap;
193
+ returnWitness: WitnessMap;
194
+ }
175
195
 
176
196
 
177
197
 
@@ -186,31 +206,11 @@ export type ExecutionError = Error & {
186
206
 
187
207
 
188
208
 
189
- // Map from witness index to hex string value of witness.
190
- export type WitnessMap = Map<number, string>;
191
-
192
- /**
193
- * An execution result containing two witnesses.
194
- * 1. The full solved witness of the execution.
195
- * 2. The return witness which contains the given public return values within the full witness.
196
- */
197
- export type SolvedAndReturnWitness = {
198
- solvedWitness: WitnessMap;
199
- returnWitness: WitnessMap;
209
+ export type StackItem = {
210
+ index: number;
211
+ witness: WitnessMap;
200
212
  }
201
213
 
202
-
203
-
204
- /**
205
- * @typedef {Object} BuildInfo - Information about how the installed package was built
206
- * @property {string} gitHash - The hash of the git commit from which the package was built.
207
- * @property {string} version - The version of the package at the built git commit.
208
- * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
209
- */
210
- export type BuildInfo = {
211
- gitHash: string;
212
- version: string;
213
- dirty: string;
214
- }
214
+ export type WitnessStack = Array<StackItem>;
215
215
 
216
216
 
package/nodejs/acvm_js.js CHANGED
@@ -23,6 +23,28 @@ function takeObject(idx) {
23
23
  return ret;
24
24
  }
25
25
 
26
+ function isLikeNone(x) {
27
+ return x === undefined || x === null;
28
+ }
29
+
30
+ let cachedFloat64Memory0 = null;
31
+
32
+ function getFloat64Memory0() {
33
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
34
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
35
+ }
36
+ return cachedFloat64Memory0;
37
+ }
38
+
39
+ let cachedInt32Memory0 = null;
40
+
41
+ function getInt32Memory0() {
42
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
43
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
44
+ }
45
+ return cachedInt32Memory0;
46
+ }
47
+
26
48
  function addHeapObject(obj) {
27
49
  if (heap_next === heap.length) heap.push(heap.length + 1);
28
50
  const idx = heap_next;
@@ -105,28 +127,6 @@ function passStringToWasm0(arg, malloc, realloc) {
105
127
  return ptr;
106
128
  }
107
129
 
108
- function isLikeNone(x) {
109
- return x === undefined || x === null;
110
- }
111
-
112
- let cachedInt32Memory0 = null;
113
-
114
- function getInt32Memory0() {
115
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
116
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
117
- }
118
- return cachedInt32Memory0;
119
- }
120
-
121
- let cachedFloat64Memory0 = null;
122
-
123
- function getFloat64Memory0() {
124
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
125
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
126
- }
127
- return cachedFloat64Memory0;
128
- }
129
-
130
130
  function debugString(val) {
131
131
  // primitive types
132
132
  const type = typeof val;
@@ -247,52 +247,6 @@ function passArray8ToWasm0(arg, malloc) {
247
247
  WASM_VECTOR_LEN = arg.length;
248
248
  return ptr;
249
249
  }
250
- /**
251
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
252
- *
253
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
254
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
255
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
256
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
257
- */
258
- module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
259
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
260
- const len0 = WASM_VECTOR_LEN;
261
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
262
- return takeObject(ret);
263
- };
264
-
265
- /**
266
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
267
- * This method also extracts the public return values from the solved witness into its own return witness.
268
- *
269
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
270
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
271
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
272
- * @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.
273
- */
274
- module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
275
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
276
- const len0 = WASM_VECTOR_LEN;
277
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
278
- return takeObject(ret);
279
- };
280
-
281
- /**
282
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
283
- *
284
- * @param {Uint8Array} program - A serialized representation of an ACIR program
285
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
286
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
287
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
288
- */
289
- module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
290
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
291
- const len0 = WASM_VECTOR_LEN;
292
- const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
293
- return takeObject(ret);
294
- };
295
-
296
250
  /**
297
251
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
298
252
  *
@@ -508,6 +462,52 @@ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes,
508
462
  return ret !== 0;
509
463
  };
510
464
 
465
+ /**
466
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
467
+ *
468
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
469
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
470
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
471
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
472
+ */
473
+ module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
474
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
475
+ const len0 = WASM_VECTOR_LEN;
476
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
477
+ return takeObject(ret);
478
+ };
479
+
480
+ /**
481
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
482
+ * This method also extracts the public return values from the solved witness into its own return witness.
483
+ *
484
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
485
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
486
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
487
+ * @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.
488
+ */
489
+ module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
490
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
491
+ const len0 = WASM_VECTOR_LEN;
492
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
493
+ return takeObject(ret);
494
+ };
495
+
496
+ /**
497
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
498
+ *
499
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
500
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
501
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
502
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
503
+ */
504
+ module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
505
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
506
+ const len0 = WASM_VECTOR_LEN;
507
+ const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
508
+ return takeObject(ret);
509
+ };
510
+
511
511
  /**
512
512
  * Returns the `BuildInfo` object containing information about how the installed package was built.
513
513
  * @returns {BuildInfo} - Information on how the installed package was built.
@@ -631,10 +631,6 @@ function __wbg_adapter_93(arg0, arg1, arg2, arg3) {
631
631
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h4efdd1050cfb3ea7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
632
632
  }
633
633
 
634
- module.exports.__wbindgen_object_drop_ref = function(arg0) {
635
- takeObject(arg0);
636
- };
637
-
638
634
  module.exports.__wbindgen_cb_drop = function(arg0) {
639
635
  const obj = takeObject(arg0).original;
640
636
  if (obj.cnt-- == 1) {
@@ -645,19 +641,15 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
645
641
  return ret;
646
642
  };
647
643
 
648
- module.exports.__wbg_new_f139361aad331bd0 = function() {
649
- const ret = new Array();
650
- return addHeapObject(ret);
651
- };
652
-
653
- module.exports.__wbindgen_number_new = function(arg0) {
654
- const ret = arg0;
655
- return addHeapObject(ret);
644
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
645
+ takeObject(arg0);
656
646
  };
657
647
 
658
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
659
- const ret = getStringFromWasm0(arg0, arg1);
660
- return addHeapObject(ret);
648
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
649
+ const obj = getObject(arg1);
650
+ const ret = typeof(obj) === 'number' ? obj : undefined;
651
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
652
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
661
653
  };
662
654
 
663
655
  module.exports.__wbg_constructor_971e67e66cc5bd6a = function(arg0) {
@@ -675,6 +667,16 @@ module.exports.__wbg_new_193bac1dd2be232d = function() {
675
667
  return addHeapObject(ret);
676
668
  };
677
669
 
670
+ module.exports.__wbindgen_number_new = function(arg0) {
671
+ const ret = arg0;
672
+ return addHeapObject(ret);
673
+ };
674
+
675
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
676
+ const ret = getStringFromWasm0(arg0, arg1);
677
+ return addHeapObject(ret);
678
+ };
679
+
678
680
  module.exports.__wbindgen_string_get = function(arg0, arg1) {
679
681
  const obj = getObject(arg1);
680
682
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -684,18 +686,16 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
684
686
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
685
687
  };
686
688
 
687
- module.exports.__wbindgen_number_get = function(arg0, arg1) {
688
- const obj = getObject(arg1);
689
- const ret = typeof(obj) === 'number' ? obj : undefined;
690
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
691
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
692
- };
693
-
694
689
  module.exports.__wbindgen_is_string = function(arg0) {
695
690
  const ret = typeof(getObject(arg0)) === 'string';
696
691
  return ret;
697
692
  };
698
693
 
694
+ module.exports.__wbg_new_f139361aad331bd0 = function() {
695
+ const ret = new Array();
696
+ return addHeapObject(ret);
697
+ };
698
+
699
699
  module.exports.__wbg_new_abda76e883ba8a5f = function() {
700
700
  const ret = new Error();
701
701
  return addHeapObject(ret);
@@ -914,8 +914,8 @@ module.exports.__wbindgen_throw = function(arg0, arg1) {
914
914
  throw new Error(getStringFromWasm0(arg0, arg1));
915
915
  };
916
916
 
917
- module.exports.__wbindgen_closure_wrapper743 = function(arg0, arg1, arg2) {
918
- const ret = makeMutClosure(arg0, arg1, 241, __wbg_adapter_22);
917
+ module.exports.__wbindgen_closure_wrapper760 = function(arg0, arg1, arg2) {
918
+ const ret = makeMutClosure(arg0, arg1, 256, __wbg_adapter_22);
919
919
  return addHeapObject(ret);
920
920
  };
921
921
 
Binary file
@@ -2,9 +2,6 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export function initLogLevel(a: number, b: number, c: number): void;
5
- export function executeCircuit(a: number, b: number, c: number, d: number): number;
6
- export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
7
- export function executeProgram(a: number, b: number, c: number, d: number): number;
8
5
  export function getReturnWitness(a: number, b: number, c: number, d: number): void;
9
6
  export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
10
7
  export function getPublicWitness(a: number, b: number, c: number, d: number): void;
@@ -15,6 +12,9 @@ export function blake2s256(a: number, b: number, c: number): void;
15
12
  export function keccak256(a: number, b: number, c: number): void;
16
13
  export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
17
14
  export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
15
+ export function executeCircuit(a: number, b: number, c: number, d: number): number;
16
+ export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
17
+ export function executeProgram(a: number, b: number, c: number, d: number): number;
18
18
  export function buildInfo(): number;
19
19
  export function compressWitness(a: number, b: number): void;
20
20
  export function decompressWitness(a: number, b: number, c: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noir-lang/acvm_js",
3
- "version": "0.47.0-d8b9870.nightly",
3
+ "version": "0.47.0-e59ff8c.nightly",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/web/acvm_js.d.ts CHANGED
@@ -7,34 +7,6 @@
7
7
  */
8
8
  export function initLogLevel(filter: string): void;
9
9
  /**
10
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
11
- *
12
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
13
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
14
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
15
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
16
- */
17
- export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
18
- /**
19
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
20
- * This method also extracts the public return values from the solved witness into its own return witness.
21
- *
22
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
23
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
24
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
25
- * @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.
26
- */
27
- export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
28
- /**
29
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
30
- *
31
- * @param {Uint8Array} program - A serialized representation of an ACIR program
32
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
33
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
34
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
35
- */
36
- export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
37
- /**
38
10
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
39
11
  *
40
12
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
@@ -118,6 +90,34 @@ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_byte
118
90
  */
119
91
  export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
120
92
  /**
93
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
94
+ *
95
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
96
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
97
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
98
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
99
+ */
100
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
101
+ /**
102
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
103
+ * This method also extracts the public return values from the solved witness into its own return witness.
104
+ *
105
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
106
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
107
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
108
+ * @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.
109
+ */
110
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
111
+ /**
112
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
113
+ *
114
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
115
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
116
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
117
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
118
+ */
119
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
120
+ /**
121
121
  * Returns the `BuildInfo` object containing information about how the installed package was built.
122
122
  * @returns {BuildInfo} - Information on how the installed package was built.
123
123
  */
@@ -152,6 +152,20 @@ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
152
152
  */
153
153
  export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
154
154
 
155
+ /**
156
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
157
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
158
+ * @property {string} version - The version of the package at the built git commit.
159
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
160
+ */
161
+ export type BuildInfo = {
162
+ gitHash: string;
163
+ version: string;
164
+ dirty: string;
165
+ }
166
+
167
+
168
+
155
169
  export type ForeignCallInput = string[]
156
170
  export type ForeignCallOutput = string | string[]
157
171
 
@@ -166,12 +180,18 @@ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => P
166
180
 
167
181
 
168
182
 
169
- export type StackItem = {
170
- index: number;
171
- witness: WitnessMap;
172
- }
183
+ // Map from witness index to hex string value of witness.
184
+ export type WitnessMap = Map<number, string>;
173
185
 
174
- export type WitnessStack = Array<StackItem>;
186
+ /**
187
+ * An execution result containing two witnesses.
188
+ * 1. The full solved witness of the execution.
189
+ * 2. The return witness which contains the given public return values within the full witness.
190
+ */
191
+ export type SolvedAndReturnWitness = {
192
+ solvedWitness: WitnessMap;
193
+ returnWitness: WitnessMap;
194
+ }
175
195
 
176
196
 
177
197
 
@@ -186,32 +206,12 @@ export type ExecutionError = Error & {
186
206
 
187
207
 
188
208
 
189
- // Map from witness index to hex string value of witness.
190
- export type WitnessMap = Map<number, string>;
191
-
192
- /**
193
- * An execution result containing two witnesses.
194
- * 1. The full solved witness of the execution.
195
- * 2. The return witness which contains the given public return values within the full witness.
196
- */
197
- export type SolvedAndReturnWitness = {
198
- solvedWitness: WitnessMap;
199
- returnWitness: WitnessMap;
209
+ export type StackItem = {
210
+ index: number;
211
+ witness: WitnessMap;
200
212
  }
201
213
 
202
-
203
-
204
- /**
205
- * @typedef {Object} BuildInfo - Information about how the installed package was built
206
- * @property {string} gitHash - The hash of the git commit from which the package was built.
207
- * @property {string} version - The version of the package at the built git commit.
208
- * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
209
- */
210
- export type BuildInfo = {
211
- gitHash: string;
212
- version: string;
213
- dirty: string;
214
- }
214
+ export type WitnessStack = Array<StackItem>;
215
215
 
216
216
 
217
217
 
@@ -220,9 +220,6 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
220
220
  export interface InitOutput {
221
221
  readonly memory: WebAssembly.Memory;
222
222
  readonly initLogLevel: (a: number, b: number, c: number) => void;
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;
226
223
  readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
227
224
  readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
228
225
  readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
@@ -233,6 +230,9 @@ export interface InitOutput {
233
230
  readonly keccak256: (a: number, b: number, c: number) => void;
234
231
  readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
235
232
  readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
233
+ readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
234
+ readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number) => number;
235
+ readonly executeProgram: (a: number, b: number, c: number, d: number) => number;
236
236
  readonly buildInfo: () => number;
237
237
  readonly compressWitness: (a: number, b: number) => void;
238
238
  readonly decompressWitness: (a: number, b: number, c: number) => void;
package/web/acvm_js.js CHANGED
@@ -20,6 +20,28 @@ function takeObject(idx) {
20
20
  return ret;
21
21
  }
22
22
 
23
+ function isLikeNone(x) {
24
+ return x === undefined || x === null;
25
+ }
26
+
27
+ let cachedFloat64Memory0 = null;
28
+
29
+ function getFloat64Memory0() {
30
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
31
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
32
+ }
33
+ return cachedFloat64Memory0;
34
+ }
35
+
36
+ let cachedInt32Memory0 = null;
37
+
38
+ function getInt32Memory0() {
39
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
40
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
41
+ }
42
+ return cachedInt32Memory0;
43
+ }
44
+
23
45
  function addHeapObject(obj) {
24
46
  if (heap_next === heap.length) heap.push(heap.length + 1);
25
47
  const idx = heap_next;
@@ -102,28 +124,6 @@ function passStringToWasm0(arg, malloc, realloc) {
102
124
  return ptr;
103
125
  }
104
126
 
105
- function isLikeNone(x) {
106
- return x === undefined || x === null;
107
- }
108
-
109
- let cachedInt32Memory0 = null;
110
-
111
- function getInt32Memory0() {
112
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
113
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
114
- }
115
- return cachedInt32Memory0;
116
- }
117
-
118
- let cachedFloat64Memory0 = null;
119
-
120
- function getFloat64Memory0() {
121
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
122
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
123
- }
124
- return cachedFloat64Memory0;
125
- }
126
-
127
127
  function debugString(val) {
128
128
  // primitive types
129
129
  const type = typeof val;
@@ -244,52 +244,6 @@ function passArray8ToWasm0(arg, malloc) {
244
244
  WASM_VECTOR_LEN = arg.length;
245
245
  return ptr;
246
246
  }
247
- /**
248
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
249
- *
250
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
251
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
252
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
253
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
254
- */
255
- export function executeCircuit(program, initial_witness, foreign_call_handler) {
256
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
257
- const len0 = WASM_VECTOR_LEN;
258
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
259
- return takeObject(ret);
260
- }
261
-
262
- /**
263
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
264
- * This method also extracts the public return values from the solved witness into its own return witness.
265
- *
266
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
267
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
268
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
269
- * @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.
270
- */
271
- export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
272
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
273
- const len0 = WASM_VECTOR_LEN;
274
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
275
- return takeObject(ret);
276
- }
277
-
278
- /**
279
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
280
- *
281
- * @param {Uint8Array} program - A serialized representation of an ACIR program
282
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
283
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
284
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
285
- */
286
- export function executeProgram(program, initial_witness, foreign_call_handler) {
287
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
288
- const len0 = WASM_VECTOR_LEN;
289
- const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
290
- return takeObject(ret);
291
- }
292
-
293
247
  /**
294
248
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
295
249
  *
@@ -505,6 +459,52 @@ export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_ke
505
459
  return ret !== 0;
506
460
  }
507
461
 
462
+ /**
463
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
464
+ *
465
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
466
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
467
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
468
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
469
+ */
470
+ export function executeCircuit(program, initial_witness, foreign_call_handler) {
471
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
472
+ const len0 = WASM_VECTOR_LEN;
473
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
474
+ return takeObject(ret);
475
+ }
476
+
477
+ /**
478
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
479
+ * This method also extracts the public return values from the solved witness into its own return witness.
480
+ *
481
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
482
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
483
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
484
+ * @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.
485
+ */
486
+ export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
487
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
488
+ const len0 = WASM_VECTOR_LEN;
489
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
490
+ return takeObject(ret);
491
+ }
492
+
493
+ /**
494
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
495
+ *
496
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
497
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
498
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
499
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
500
+ */
501
+ export function executeProgram(program, initial_witness, foreign_call_handler) {
502
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
503
+ const len0 = WASM_VECTOR_LEN;
504
+ const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
505
+ return takeObject(ret);
506
+ }
507
+
508
508
  /**
509
509
  * Returns the `BuildInfo` object containing information about how the installed package was built.
510
510
  * @returns {BuildInfo} - Information on how the installed package was built.
@@ -662,9 +662,6 @@ async function __wbg_load(module, imports) {
662
662
  function __wbg_get_imports() {
663
663
  const imports = {};
664
664
  imports.wbg = {};
665
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
666
- takeObject(arg0);
667
- };
668
665
  imports.wbg.__wbindgen_cb_drop = function(arg0) {
669
666
  const obj = takeObject(arg0).original;
670
667
  if (obj.cnt-- == 1) {
@@ -674,17 +671,14 @@ function __wbg_get_imports() {
674
671
  const ret = false;
675
672
  return ret;
676
673
  };
677
- imports.wbg.__wbg_new_f139361aad331bd0 = function() {
678
- const ret = new Array();
679
- return addHeapObject(ret);
680
- };
681
- imports.wbg.__wbindgen_number_new = function(arg0) {
682
- const ret = arg0;
683
- return addHeapObject(ret);
674
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
675
+ takeObject(arg0);
684
676
  };
685
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
686
- const ret = getStringFromWasm0(arg0, arg1);
687
- return addHeapObject(ret);
677
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
678
+ const obj = getObject(arg1);
679
+ const ret = typeof(obj) === 'number' ? obj : undefined;
680
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
681
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
688
682
  };
689
683
  imports.wbg.__wbg_constructor_971e67e66cc5bd6a = function(arg0) {
690
684
  const ret = new Error(takeObject(arg0));
@@ -698,6 +692,14 @@ function __wbg_get_imports() {
698
692
  const ret = new Map();
699
693
  return addHeapObject(ret);
700
694
  };
695
+ imports.wbg.__wbindgen_number_new = function(arg0) {
696
+ const ret = arg0;
697
+ return addHeapObject(ret);
698
+ };
699
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
700
+ const ret = getStringFromWasm0(arg0, arg1);
701
+ return addHeapObject(ret);
702
+ };
701
703
  imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
702
704
  const obj = getObject(arg1);
703
705
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -706,16 +708,14 @@ function __wbg_get_imports() {
706
708
  getInt32Memory0()[arg0 / 4 + 1] = len1;
707
709
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
708
710
  };
709
- imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
710
- const obj = getObject(arg1);
711
- const ret = typeof(obj) === 'number' ? obj : undefined;
712
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
713
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
714
- };
715
711
  imports.wbg.__wbindgen_is_string = function(arg0) {
716
712
  const ret = typeof(getObject(arg0)) === 'string';
717
713
  return ret;
718
714
  };
715
+ imports.wbg.__wbg_new_f139361aad331bd0 = function() {
716
+ const ret = new Array();
717
+ return addHeapObject(ret);
718
+ };
719
719
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
720
720
  const ret = new Error();
721
721
  return addHeapObject(ret);
@@ -899,8 +899,8 @@ function __wbg_get_imports() {
899
899
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
900
900
  throw new Error(getStringFromWasm0(arg0, arg1));
901
901
  };
902
- imports.wbg.__wbindgen_closure_wrapper743 = function(arg0, arg1, arg2) {
903
- const ret = makeMutClosure(arg0, arg1, 241, __wbg_adapter_22);
902
+ imports.wbg.__wbindgen_closure_wrapper760 = function(arg0, arg1, arg2) {
903
+ const ret = makeMutClosure(arg0, arg1, 256, __wbg_adapter_22);
904
904
  return addHeapObject(ret);
905
905
  };
906
906
 
Binary file
@@ -2,9 +2,6 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export function initLogLevel(a: number, b: number, c: number): void;
5
- export function executeCircuit(a: number, b: number, c: number, d: number): number;
6
- export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
7
- export function executeProgram(a: number, b: number, c: number, d: number): number;
8
5
  export function getReturnWitness(a: number, b: number, c: number, d: number): void;
9
6
  export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
10
7
  export function getPublicWitness(a: number, b: number, c: number, d: number): void;
@@ -15,6 +12,9 @@ export function blake2s256(a: number, b: number, c: number): void;
15
12
  export function keccak256(a: number, b: number, c: number): void;
16
13
  export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
17
14
  export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
15
+ export function executeCircuit(a: number, b: number, c: number, d: number): number;
16
+ export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
17
+ export function executeProgram(a: number, b: number, c: number, d: number): number;
18
18
  export function buildInfo(): number;
19
19
  export function compressWitness(a: number, b: number): void;
20
20
  export function decompressWitness(a: number, b: number, c: number): void;