@noir-lang/acvm_js 0.43.0 → 0.44.0-7dd2c5e.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,63 +1,60 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
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.
4
+ * Performs a bitwise AND operation between `lhs` and `rhs`
5
+ * @param {string} lhs
6
+ * @param {string} rhs
7
+ * @returns {string}
16
8
  */
17
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
9
+ export function and(lhs: string, rhs: string): string;
18
10
  /**
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
11
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
12
+ * @param {string} lhs
13
+ * @param {string} rhs
14
+ * @returns {string}
23
15
  */
24
- export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
16
+ export function xor(lhs: string, rhs: string): string;
25
17
  /**
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.
18
+ * Calculates the SHA256 hash of the input bytes
19
+ * @param {Uint8Array} inputs
20
+ * @returns {Uint8Array}
30
21
  */
31
- export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
22
+ export function sha256(inputs: Uint8Array): Uint8Array;
32
23
  /**
33
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
24
+ * Calculates the Blake2s256 hash of the input bytes
25
+ * @param {Uint8Array} inputs
26
+ * @returns {Uint8Array}
34
27
  */
35
- export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
28
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
36
29
  /**
37
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
38
- *
39
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
40
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
41
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
42
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
30
+ * Calculates the Keccak256 hash of the input bytes
31
+ * @param {Uint8Array} inputs
32
+ * @returns {Uint8Array}
43
33
  */
44
- export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
34
+ export function keccak256(inputs: Uint8Array): Uint8Array;
45
35
  /**
46
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
47
- *
48
- * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
49
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
50
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
51
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
52
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
36
+ * Verifies a ECDSA signature over the secp256k1 curve.
37
+ * @param {Uint8Array} hashed_msg
38
+ * @param {Uint8Array} public_key_x_bytes
39
+ * @param {Uint8Array} public_key_y_bytes
40
+ * @param {Uint8Array} signature
41
+ * @returns {boolean}
53
42
  */
54
- export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
43
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
55
44
  /**
45
+ * Verifies a ECDSA signature over the secp256r1 curve.
46
+ * @param {Uint8Array} hashed_msg
47
+ * @param {Uint8Array} public_key_x_bytes
48
+ * @param {Uint8Array} public_key_y_bytes
49
+ * @param {Uint8Array} signature
50
+ * @returns {boolean}
56
51
  */
57
- export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
52
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
58
53
  /**
54
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
55
+ * @returns {BuildInfo} - Information on how the installed package was built.
59
56
  */
60
- export function executeProgramWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_executor: ForeignCallHandler): Promise<WitnessStack>;
57
+ export function buildInfo(): BuildInfo;
61
58
  /**
62
59
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
63
60
  *
@@ -92,80 +89,80 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
92
89
  */
93
90
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
94
91
  /**
95
- * Performs a bitwise AND operation between `lhs` and `rhs`
96
- * @param {string} lhs
97
- * @param {string} rhs
98
- * @returns {string}
92
+ * Sets the package's logging level.
93
+ *
94
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
99
95
  */
100
- export function and(lhs: string, rhs: string): string;
96
+ export function initLogLevel(filter: string): void;
101
97
  /**
102
- * Performs a bitwise XOR operation between `lhs` and `rhs`
103
- * @param {string} lhs
104
- * @param {string} rhs
105
- * @returns {string}
98
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
99
+ *
100
+ * @param {WitnessMap} witness_map - A witness map.
101
+ * @returns {Uint8Array} A compressed witness map
106
102
  */
107
- export function xor(lhs: string, rhs: string): string;
103
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
108
104
  /**
109
- * Calculates the SHA256 hash of the input bytes
110
- * @param {Uint8Array} inputs
111
- * @returns {Uint8Array}
105
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
106
+ * This should be used to only fetch the witness map for the main function.
107
+ *
108
+ * @param {Uint8Array} compressed_witness - A compressed witness.
109
+ * @returns {WitnessMap} The decompressed witness map.
112
110
  */
113
- export function sha256(inputs: Uint8Array): Uint8Array;
111
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
114
112
  /**
115
- * Calculates the Blake2s256 hash of the input bytes
116
- * @param {Uint8Array} inputs
117
- * @returns {Uint8Array}
113
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
114
+ *
115
+ * @param {WitnessStack} witness_stack - A witness stack.
116
+ * @returns {Uint8Array} A compressed witness stack
118
117
  */
119
- export function blake2s256(inputs: Uint8Array): Uint8Array;
118
+ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
120
119
  /**
121
- * Calculates the Keccak256 hash of the input bytes
122
- * @param {Uint8Array} inputs
123
- * @returns {Uint8Array}
120
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
121
+ *
122
+ * @param {Uint8Array} compressed_witness - A compressed witness.
123
+ * @returns {WitnessStack} The decompressed witness stack.
124
124
  */
125
- export function keccak256(inputs: Uint8Array): Uint8Array;
125
+ export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
126
126
  /**
127
- * Verifies a ECDSA signature over the secp256k1 curve.
128
- * @param {Uint8Array} hashed_msg
129
- * @param {Uint8Array} public_key_x_bytes
130
- * @param {Uint8Array} public_key_y_bytes
131
- * @param {Uint8Array} signature
132
- * @returns {boolean}
127
+ * @returns {Promise<WasmBlackBoxFunctionSolver>}
133
128
  */
134
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
129
+ export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
135
130
  /**
136
- * Verifies a ECDSA signature over the secp256r1 curve.
137
- * @param {Uint8Array} hashed_msg
138
- * @param {Uint8Array} public_key_x_bytes
139
- * @param {Uint8Array} public_key_y_bytes
140
- * @param {Uint8Array} signature
141
- * @returns {boolean}
131
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
132
+ *
133
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
134
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
135
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
136
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
142
137
  */
143
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
138
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
144
139
  /**
145
- * Returns the `BuildInfo` object containing information about how the installed package was built.
146
- * @returns {BuildInfo} - Information on how the installed package was built.
140
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
141
+ * This method also extracts the public return values from the solved witness into its own return witness.
142
+ *
143
+ * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
144
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
145
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
146
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
147
+ * @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.
147
148
  */
148
- export function buildInfo(): BuildInfo;
149
+ export function executeCircuitWithReturnWitness(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
149
150
  /**
150
- * Sets the package's logging level.
151
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
151
152
  *
152
- * @param {LogLevel} level - The maximum level of logging to be emitted.
153
+ * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
154
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
155
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
156
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
157
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
153
158
  */
154
- export function initLogLevel(filter: string): void;
155
-
156
- export type ForeignCallInput = string[]
157
- export type ForeignCallOutput = string | string[]
158
-
159
+ export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
159
160
  /**
160
- * A callback which performs an foreign call and returns the response.
161
- * @callback ForeignCallHandler
162
- * @param {string} name - The identifier for the type of foreign call being performed.
163
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
164
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
165
161
  */
166
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
167
-
168
-
162
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
163
+ /**
164
+ */
165
+ export function executeProgramWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_executor: ForeignCallHandler): Promise<WitnessStack>;
169
166
 
170
167
  export type ExecutionError = Error & {
171
168
  callStack?: string[];
@@ -176,15 +173,16 @@ export type ExecutionError = Error & {
176
173
  // Map from witness index to hex string value of witness.
177
174
  export type WitnessMap = Map<number, string>;
178
175
 
179
-
180
-
181
- export type StackItem = {
182
- index: number;
183
- witness: WitnessMap;
176
+ /**
177
+ * An execution result containing two witnesses.
178
+ * 1. The full solved witness of the execution.
179
+ * 2. The return witness which contains the given public return values within the full witness.
180
+ */
181
+ export type SolvedAndReturnWitness = {
182
+ solvedWitness: WitnessMap;
183
+ returnWitness: WitnessMap;
184
184
  }
185
185
 
186
- export type WitnessStack = Array<StackItem>;
187
-
188
186
 
189
187
 
190
188
  /**
@@ -200,6 +198,29 @@ export type BuildInfo = {
200
198
  }
201
199
 
202
200
 
201
+
202
+ export type ForeignCallInput = string[]
203
+ export type ForeignCallOutput = string | string[]
204
+
205
+ /**
206
+ * A callback which performs an foreign call and returns the response.
207
+ * @callback ForeignCallHandler
208
+ * @param {string} name - The identifier for the type of foreign call being performed.
209
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
210
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
211
+ */
212
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
213
+
214
+
215
+
216
+ export type StackItem = {
217
+ index: number;
218
+ witness: WitnessMap;
219
+ }
220
+
221
+ export type WitnessStack = Array<StackItem>;
222
+
223
+
203
224
  /**
204
225
  */
205
226
  export class WasmBlackBoxFunctionSolver {