@noir-lang/acvm_js 0.42.0 → 0.43.0-90ee479.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,89 +1,74 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Verifies a ECDSA signature over the secp256r1 curve.
5
- * @param {Uint8Array} hashed_msg
6
- * @param {Uint8Array} public_key_x_bytes
7
- * @param {Uint8Array} public_key_y_bytes
8
- * @param {Uint8Array} signature
9
- * @returns {boolean}
10
- */
11
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
12
- /**
13
- * Verifies a ECDSA signature over the secp256k1 curve.
14
- * @param {Uint8Array} hashed_msg
15
- * @param {Uint8Array} public_key_x_bytes
16
- * @param {Uint8Array} public_key_y_bytes
17
- * @param {Uint8Array} signature
18
- * @returns {boolean}
19
- */
20
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
21
- /**
22
- * Calculates the Keccak256 hash of the input bytes
23
- * @param {Uint8Array} inputs
24
- * @returns {Uint8Array}
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
25
8
  */
26
- export function keccak256(inputs: Uint8Array): Uint8Array;
9
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
27
10
  /**
28
- * Calculates the Blake2s256 hash of the input bytes
29
- * @param {Uint8Array} inputs
30
- * @returns {Uint8Array}
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.
31
16
  */
32
- export function blake2s256(inputs: Uint8Array): Uint8Array;
17
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
33
18
  /**
34
- * Calculates the SHA256 hash of the input bytes
35
- * @param {Uint8Array} inputs
36
- * @returns {Uint8Array}
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
37
23
  */
38
- export function sha256(inputs: Uint8Array): Uint8Array;
24
+ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
39
25
  /**
40
- * Performs a bitwise XOR operation between `lhs` and `rhs`
41
- * @param {string} lhs
42
- * @param {string} rhs
43
- * @returns {string}
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.
44
30
  */
45
- export function xor(lhs: string, rhs: string): string;
31
+ export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
46
32
  /**
47
- * Performs a bitwise AND operation between `lhs` and `rhs`
48
- * @param {string} lhs
49
- * @param {string} rhs
50
- * @returns {string}
33
+ * @returns {Promise<WasmBlackBoxFunctionSolver>}
51
34
  */
52
- export function and(lhs: string, rhs: string): string;
35
+ export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
53
36
  /**
54
37
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
55
38
  *
56
- * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
57
39
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
58
40
  * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
59
41
  * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
60
42
  * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
61
43
  */
62
- export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
44
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
63
45
  /**
64
46
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
65
47
  *
48
+ * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
66
49
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
67
50
  * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
68
51
  * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
69
52
  * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
70
53
  */
71
- export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
54
+ export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
72
55
  /**
73
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
74
56
  */
75
- export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
57
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
76
58
  /**
77
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
59
+ */
60
+ export function executeProgramWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_executor: ForeignCallHandler): Promise<WitnessStack>;
61
+ /**
62
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
78
63
  *
79
64
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
80
65
  * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
81
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
66
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
82
67
  * @param {Uint8Array} program
83
- * @param {WitnessMap} solved_witness
68
+ * @param {WitnessMap} witness_map
84
69
  * @returns {WitnessMap}
85
70
  */
86
- export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
71
+ export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
87
72
  /**
88
73
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
89
74
  *
@@ -96,16 +81,16 @@ export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap
96
81
  */
97
82
  export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
98
83
  /**
99
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
84
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
100
85
  *
101
86
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
102
87
  * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
103
- * @returns {WitnessMap} A witness map containing the circuit's return values.
88
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
104
89
  * @param {Uint8Array} program
105
- * @param {WitnessMap} witness_map
90
+ * @param {WitnessMap} solved_witness
106
91
  * @returns {WitnessMap}
107
92
  */
108
- export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
93
+ export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
109
94
  /**
110
95
  * Sets the package's logging level.
111
96
  *
@@ -113,19 +98,55 @@ export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap):
113
98
  */
114
99
  export function initLogLevel(filter: string): void;
115
100
  /**
116
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
117
- *
118
- * @param {Uint8Array} compressed_witness - A compressed witness.
119
- * @returns {WitnessMap} The decompressed witness map.
101
+ * Performs a bitwise AND operation between `lhs` and `rhs`
102
+ * @param {string} lhs
103
+ * @param {string} rhs
104
+ * @returns {string}
120
105
  */
121
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
106
+ export function and(lhs: string, rhs: string): string;
122
107
  /**
123
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
124
- *
125
- * @param {Uint8Array} compressed_witness - A witness map.
126
- * @returns {WitnessMap} A compressed witness map
108
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
109
+ * @param {string} lhs
110
+ * @param {string} rhs
111
+ * @returns {string}
127
112
  */
128
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
113
+ export function xor(lhs: string, rhs: string): string;
114
+ /**
115
+ * Calculates the SHA256 hash of the input bytes
116
+ * @param {Uint8Array} inputs
117
+ * @returns {Uint8Array}
118
+ */
119
+ export function sha256(inputs: Uint8Array): Uint8Array;
120
+ /**
121
+ * Calculates the Blake2s256 hash of the input bytes
122
+ * @param {Uint8Array} inputs
123
+ * @returns {Uint8Array}
124
+ */
125
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
126
+ /**
127
+ * Calculates the Keccak256 hash of the input bytes
128
+ * @param {Uint8Array} inputs
129
+ * @returns {Uint8Array}
130
+ */
131
+ export function keccak256(inputs: Uint8Array): Uint8Array;
132
+ /**
133
+ * Verifies a ECDSA signature over the secp256k1 curve.
134
+ * @param {Uint8Array} hashed_msg
135
+ * @param {Uint8Array} public_key_x_bytes
136
+ * @param {Uint8Array} public_key_y_bytes
137
+ * @param {Uint8Array} signature
138
+ * @returns {boolean}
139
+ */
140
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
141
+ /**
142
+ * Verifies a ECDSA signature over the secp256r1 curve.
143
+ * @param {Uint8Array} hashed_msg
144
+ * @param {Uint8Array} public_key_x_bytes
145
+ * @param {Uint8Array} public_key_y_bytes
146
+ * @param {Uint8Array} signature
147
+ * @returns {boolean}
148
+ */
149
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
129
150
  /**
130
151
  * Returns the `BuildInfo` object containing information about how the installed package was built.
131
152
  * @returns {BuildInfo} - Information on how the installed package was built.
@@ -143,17 +164,12 @@ export type WitnessMap = Map<number, string>;
143
164
 
144
165
 
145
166
 
146
- export type ForeignCallInput = string[]
147
- export type ForeignCallOutput = string | string[]
167
+ export type StackItem = {
168
+ index: number;
169
+ witness: WitnessMap;
170
+ }
148
171
 
149
- /**
150
- * A callback which performs an foreign call and returns the response.
151
- * @callback ForeignCallHandler
152
- * @param {string} name - The identifier for the type of foreign call being performed.
153
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
154
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
155
- */
156
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
172
+ export type WitnessStack = Array<StackItem>;
157
173
 
158
174
 
159
175
 
@@ -170,6 +186,20 @@ export type BuildInfo = {
170
186
  }
171
187
 
172
188
 
189
+
190
+ export type ForeignCallInput = string[]
191
+ export type ForeignCallOutput = string | string[]
192
+
193
+ /**
194
+ * A callback which performs an foreign call and returns the response.
195
+ * @callback ForeignCallHandler
196
+ * @param {string} name - The identifier for the type of foreign call being performed.
197
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
198
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
199
+ */
200
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
201
+
202
+
173
203
  /**
174
204
  */
175
205
  export class WasmBlackBoxFunctionSolver {