@noir-lang/acvm_js 0.45.0 → 0.46.0-2e543b4.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.
Binary file
@@ -1,6 +1,17 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export function compressWitness(a: number, b: number): void;
5
+ export function decompressWitness(a: number, b: number, c: number): void;
6
+ export function compressWitnessStack(a: number, b: number): void;
7
+ export function decompressWitnessStack(a: number, b: number, c: number): void;
8
+ export function getReturnWitness(a: number, b: number, c: number, d: number): void;
9
+ export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
10
+ export function getPublicWitness(a: number, b: number, c: number, d: number): void;
11
+ export function executeCircuit(a: number, b: number, c: number, d: number): number;
12
+ export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
13
+ export function executeProgram(a: number, b: number, c: number, d: number): number;
14
+ export function initLogLevel(a: number, b: number, c: number): void;
4
15
  export function and(a: number, b: number): number;
5
16
  export function xor(a: number, b: number): number;
6
17
  export function sha256(a: number, b: number, c: number): void;
@@ -9,29 +20,12 @@ export function keccak256(a: number, b: number, c: number): void;
9
20
  export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
10
21
  export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
11
22
  export function buildInfo(): number;
12
- export function getReturnWitness(a: number, b: number, c: number, d: number): void;
13
- export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
14
- export function getPublicWitness(a: number, b: number, c: number, d: number): void;
15
- export function initLogLevel(a: number, b: number, c: number): void;
16
- export function compressWitness(a: number, b: number): void;
17
- export function decompressWitness(a: number, b: number, c: number): void;
18
- export function compressWitnessStack(a: number, b: number): void;
19
- export function decompressWitnessStack(a: number, b: number, c: number): void;
20
- export function __wbg_wasmblackboxfunctionsolver_free(a: number): void;
21
- export function createBlackBoxSolver(): number;
22
- export function executeCircuit(a: number, b: number, c: number, d: number): number;
23
- export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number, e: number): number;
24
- export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;
25
- export function executeProgram(a: number, b: number, c: number, d: number): number;
26
- export function executeProgramWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;
27
- export function __wbg_trap_free(a: number): void;
28
- export function trap___wbg_wasmer_trap(): void;
29
23
  export function __wbindgen_malloc(a: number): number;
30
24
  export function __wbindgen_realloc(a: number, b: number, c: number): number;
31
25
  export const __wbindgen_export_2: WebAssembly.Table;
32
- export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hc5258430255de068(a: number, b: number, c: number): void;
26
+ export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h36bac5ff3ea3c380(a: number, b: number, c: number): void;
33
27
  export function __wbindgen_add_to_stack_pointer(a: number): number;
34
28
  export function __wbindgen_free(a: number, b: number): void;
29
+ export function wasm_bindgen__convert__closures__invoke3_mut__h629417323d5efbaa(a: number, b: number, c: number, d: number, e: number): void;
35
30
  export function __wbindgen_exn_store(a: number): void;
36
- export function wasm_bindgen__convert__closures__invoke3_mut__h1e7d8ac96c74bd35(a: number, b: number, c: number, d: number, e: number): void;
37
- export function wasm_bindgen__convert__closures__invoke2_mut__h188e918906ff9a40(a: number, b: number, c: number, d: number): void;
31
+ export function wasm_bindgen__convert__closures__invoke2_mut__h4efdd1050cfb3ea7(a: number, b: number, c: number, d: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noir-lang/acvm_js",
3
- "version": "0.45.0",
3
+ "version": "0.46.0-2e543b4.nightly",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/web/acvm_js.d.ts CHANGED
@@ -1,60 +1,34 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Performs a bitwise AND operation between `lhs` and `rhs`
5
- * @param {string} lhs
6
- * @param {string} rhs
7
- * @returns {string}
8
- */
9
- export function and(lhs: string, rhs: string): string;
10
- /**
11
- * Performs a bitwise XOR operation between `lhs` and `rhs`
12
- * @param {string} lhs
13
- * @param {string} rhs
14
- * @returns {string}
15
- */
16
- export function xor(lhs: string, rhs: string): string;
17
- /**
18
- * Calculates the SHA256 hash of the input bytes
19
- * @param {Uint8Array} inputs
20
- * @returns {Uint8Array}
21
- */
22
- export function sha256(inputs: Uint8Array): Uint8Array;
23
- /**
24
- * Calculates the Blake2s256 hash of the input bytes
25
- * @param {Uint8Array} inputs
26
- * @returns {Uint8Array}
27
- */
28
- export function blake2s256(inputs: Uint8Array): Uint8Array;
29
- /**
30
- * Calculates the Keccak256 hash of the input bytes
31
- * @param {Uint8Array} inputs
32
- * @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
33
8
  */
34
- export function keccak256(inputs: Uint8Array): Uint8Array;
9
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
35
10
  /**
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}
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.
42
16
  */
43
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
17
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
44
18
  /**
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}
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
51
23
  */
52
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
24
+ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
53
25
  /**
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.
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.
56
30
  */
57
- export function buildInfo(): BuildInfo;
31
+ export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
58
32
  /**
59
33
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
60
34
  *
@@ -89,45 +63,6 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
89
63
  */
90
64
  export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
91
65
  /**
92
- * Sets the package's logging level.
93
- *
94
- * @param {LogLevel} level - The maximum level of logging to be emitted.
95
- */
96
- export function initLogLevel(filter: string): void;
97
- /**
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
102
- */
103
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
104
- /**
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.
110
- */
111
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
112
- /**
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
117
- */
118
- export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
119
- /**
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
- */
125
- export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
126
- /**
127
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
128
- */
129
- export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
130
- /**
131
66
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
132
67
  *
133
68
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
@@ -140,36 +75,108 @@ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap,
140
75
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
141
76
  * This method also extracts the public return values from the solved witness into its own return witness.
142
77
  *
143
- * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
144
78
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
145
79
  * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
146
80
  * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
147
81
  * @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.
148
82
  */
149
- export function executeCircuitWithReturnWitness(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
83
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
150
84
  /**
151
85
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
152
86
  *
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.
87
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
88
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
89
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
90
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
158
91
  */
159
- export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
92
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
160
93
  /**
94
+ * Sets the package's logging level.
95
+ *
96
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
161
97
  */
162
- export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
98
+ export function initLogLevel(filter: string): void;
99
+ /**
100
+ * Performs a bitwise AND operation between `lhs` and `rhs`
101
+ * @param {string} lhs
102
+ * @param {string} rhs
103
+ * @returns {string}
104
+ */
105
+ export function and(lhs: string, rhs: string): string;
106
+ /**
107
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
108
+ * @param {string} lhs
109
+ * @param {string} rhs
110
+ * @returns {string}
111
+ */
112
+ export function xor(lhs: string, rhs: string): string;
113
+ /**
114
+ * Calculates the SHA256 hash of the input bytes
115
+ * @param {Uint8Array} inputs
116
+ * @returns {Uint8Array}
117
+ */
118
+ export function sha256(inputs: Uint8Array): Uint8Array;
119
+ /**
120
+ * Calculates the Blake2s256 hash of the input bytes
121
+ * @param {Uint8Array} inputs
122
+ * @returns {Uint8Array}
123
+ */
124
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
125
+ /**
126
+ * Calculates the Keccak256 hash of the input bytes
127
+ * @param {Uint8Array} inputs
128
+ * @returns {Uint8Array}
129
+ */
130
+ export function keccak256(inputs: Uint8Array): Uint8Array;
131
+ /**
132
+ * Verifies a ECDSA signature over the secp256k1 curve.
133
+ * @param {Uint8Array} hashed_msg
134
+ * @param {Uint8Array} public_key_x_bytes
135
+ * @param {Uint8Array} public_key_y_bytes
136
+ * @param {Uint8Array} signature
137
+ * @returns {boolean}
138
+ */
139
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
140
+ /**
141
+ * Verifies a ECDSA signature over the secp256r1 curve.
142
+ * @param {Uint8Array} hashed_msg
143
+ * @param {Uint8Array} public_key_x_bytes
144
+ * @param {Uint8Array} public_key_y_bytes
145
+ * @param {Uint8Array} signature
146
+ * @returns {boolean}
147
+ */
148
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
163
149
  /**
150
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
151
+ * @returns {BuildInfo} - Information on how the installed package was built.
164
152
  */
165
- export function executeProgramWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_executor: ForeignCallHandler): Promise<WitnessStack>;
153
+ export function buildInfo(): BuildInfo;
166
154
 
155
+ export type RawAssertionPayload = {
156
+ selector: string;
157
+ data: string[];
158
+ };
167
159
  export type ExecutionError = Error & {
168
160
  callStack?: string[];
161
+ rawAssertionPayload?: RawAssertionPayload;
169
162
  };
170
163
 
171
164
 
172
165
 
166
+ export type ForeignCallInput = string[]
167
+ export type ForeignCallOutput = string | string[]
168
+
169
+ /**
170
+ * A callback which performs an foreign call and returns the response.
171
+ * @callback ForeignCallHandler
172
+ * @param {string} name - The identifier for the type of foreign call being performed.
173
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
174
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
175
+ */
176
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
177
+
178
+
179
+
173
180
  // Map from witness index to hex string value of witness.
174
181
  export type WitnessMap = Map<number, string>;
175
182
 
@@ -185,6 +192,15 @@ export type SolvedAndReturnWitness = {
185
192
 
186
193
 
187
194
 
195
+ export type StackItem = {
196
+ index: number;
197
+ witness: WitnessMap;
198
+ }
199
+
200
+ export type WitnessStack = Array<StackItem>;
201
+
202
+
203
+
188
204
  /**
189
205
  * @typedef {Object} BuildInfo - Information about how the installed package was built
190
206
  * @property {string} gitHash - The hash of the git commit from which the package was built.
@@ -199,38 +215,21 @@ export type BuildInfo = {
199
215
 
200
216
 
201
217
 
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
-
224
- /**
225
- */
226
- export class WasmBlackBoxFunctionSolver {
227
- free(): void;
228
- }
229
-
230
218
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
231
219
 
232
220
  export interface InitOutput {
233
221
  readonly memory: WebAssembly.Memory;
222
+ readonly compressWitness: (a: number, b: number) => void;
223
+ readonly decompressWitness: (a: number, b: number, c: number) => void;
224
+ readonly compressWitnessStack: (a: number, b: number) => void;
225
+ readonly decompressWitnessStack: (a: number, b: number, c: number) => void;
226
+ readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
227
+ readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
228
+ readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
229
+ readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
230
+ readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number) => number;
231
+ readonly executeProgram: (a: number, b: number, c: number, d: number) => number;
232
+ readonly initLogLevel: (a: number, b: number, c: number) => void;
234
233
  readonly and: (a: number, b: number) => number;
235
234
  readonly xor: (a: number, b: number) => number;
236
235
  readonly sha256: (a: number, b: number, c: number) => void;
@@ -239,32 +238,15 @@ export interface InitOutput {
239
238
  readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
240
239
  readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
241
240
  readonly buildInfo: () => number;
242
- readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
243
- readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
244
- readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
245
- readonly initLogLevel: (a: number, b: number, c: number) => void;
246
- readonly compressWitness: (a: number, b: number) => void;
247
- readonly decompressWitness: (a: number, b: number, c: number) => void;
248
- readonly compressWitnessStack: (a: number, b: number) => void;
249
- readonly decompressWitnessStack: (a: number, b: number, c: number) => void;
250
- readonly __wbg_wasmblackboxfunctionsolver_free: (a: number) => void;
251
- readonly createBlackBoxSolver: () => number;
252
- readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
253
- readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number, e: number) => number;
254
- readonly executeCircuitWithBlackBoxSolver: (a: number, b: number, c: number, d: number, e: number) => number;
255
- readonly executeProgram: (a: number, b: number, c: number, d: number) => number;
256
- readonly executeProgramWithBlackBoxSolver: (a: number, b: number, c: number, d: number, e: number) => number;
257
- readonly __wbg_trap_free: (a: number) => void;
258
- readonly trap___wbg_wasmer_trap: () => void;
259
241
  readonly __wbindgen_malloc: (a: number) => number;
260
242
  readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
261
243
  readonly __wbindgen_export_2: WebAssembly.Table;
262
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hc5258430255de068: (a: number, b: number, c: number) => void;
244
+ readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h36bac5ff3ea3c380: (a: number, b: number, c: number) => void;
263
245
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
264
246
  readonly __wbindgen_free: (a: number, b: number) => void;
247
+ readonly wasm_bindgen__convert__closures__invoke3_mut__h629417323d5efbaa: (a: number, b: number, c: number, d: number, e: number) => void;
265
248
  readonly __wbindgen_exn_store: (a: number) => void;
266
- readonly wasm_bindgen__convert__closures__invoke3_mut__h1e7d8ac96c74bd35: (a: number, b: number, c: number, d: number, e: number) => void;
267
- readonly wasm_bindgen__convert__closures__invoke2_mut__h188e918906ff9a40: (a: number, b: number, c: number, d: number) => void;
249
+ readonly wasm_bindgen__convert__closures__invoke2_mut__h4efdd1050cfb3ea7: (a: number, b: number, c: number, d: number) => void;
268
250
  }
269
251
 
270
252
  export type SyncInitInput = BufferSource | WebAssembly.Module;