@noir-lang/acvm_js 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -1,24 +1,28 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
5
- export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
6
- export function keccak256(a: number, b: number, c: number): void;
7
- export function blake2s256(a: number, b: number, c: number): void;
8
- export function sha256(a: number, b: number, c: number): void;
9
- export function xor(a: number, b: number): number;
10
- export function and(a: number, b: number): number;
11
- export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;
12
- export function executeCircuit(a: number, b: number, c: number, d: number): number;
13
- export function createBlackBoxSolver(): number;
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;
14
8
  export function __wbg_wasmblackboxfunctionsolver_free(a: number): void;
15
- export function getPublicWitness(a: number, b: number, c: number, d: number): void;
16
- export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
9
+ export function createBlackBoxSolver(): number;
10
+ export function executeCircuit(a: number, b: number, c: number, d: number): number;
11
+ export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;
12
+ export function executeProgram(a: number, b: number, c: number, d: number): number;
13
+ export function executeProgramWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;
17
14
  export function getReturnWitness(a: number, b: number, c: number, d: number): void;
18
- export function initLogLevel(a: number, b: number, c: number): void;
19
- export function decompressWitness(a: number, b: number, c: number): void;
20
- export function compressWitness(a: number, b: number): void;
15
+ export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
16
+ export function getPublicWitness(a: number, b: number, c: number, d: number): void;
17
+ export function and(a: number, b: number): number;
18
+ export function xor(a: number, b: number): number;
19
+ export function sha256(a: number, b: number, c: number): void;
20
+ export function blake2s256(a: number, b: number, c: number): void;
21
+ export function keccak256(a: number, b: number, c: number): void;
22
+ export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
23
+ export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
21
24
  export function buildInfo(): number;
25
+ export function initLogLevel(a: number, b: number, c: number): void;
22
26
  export function __wbg_trap_free(a: number): void;
23
27
  export function trap___wbg_wasmer_trap(): void;
24
28
  export function __wbindgen_malloc(a: number): number;
@@ -28,4 +32,5 @@ export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen
28
32
  export function __wbindgen_add_to_stack_pointer(a: number): number;
29
33
  export function __wbindgen_free(a: number, b: number): void;
30
34
  export function __wbindgen_exn_store(a: number): void;
35
+ export function wasm_bindgen__convert__closures__invoke3_mut__h28a07b2d2a2056af(a: number, b: number, c: number, d: number, e: number): void;
31
36
  export function wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15(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.42.0",
3
+ "version": "0.43.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,9 +34,7 @@
34
34
  "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0",
35
35
  "publish": "echo 📡 publishing `$npm_package_name` && yarn npm publish",
36
36
  "nightly:version": "jq --arg new_version \"-$(git rev-parse --short HEAD)$1\" '.version = .version + $new_version' package.json > package-tmp.json && mv package-tmp.json package.json",
37
- "clean": "chmod u+w web nodejs || true && rm -rf web nodejs",
38
- "build:nix": "nix build -L .#acvm_js",
39
- "install:from:nix": "yarn clean && yarn build:nix && cp -rL ./result/acvm_js/nodejs ./ && cp -rL ./result/acvm_js/web ./"
37
+ "clean": "chmod u+w web nodejs || true && rm -rf web nodejs"
40
38
  },
41
39
  "devDependencies": {
42
40
  "@esm-bundle/chai": "^4.3.4-fix.0",
package/web/acvm_js.d.ts CHANGED
@@ -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,41 +81,91 @@ 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
- * Sets the package's logging level.
111
- *
112
- * @param {LogLevel} level - The maximum level of logging to be emitted.
95
+ * Performs a bitwise AND operation between `lhs` and `rhs`
96
+ * @param {string} lhs
97
+ * @param {string} rhs
98
+ * @returns {string}
113
99
  */
114
- export function initLogLevel(filter: string): void;
100
+ export function and(lhs: string, rhs: string): string;
115
101
  /**
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.
102
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
103
+ * @param {string} lhs
104
+ * @param {string} rhs
105
+ * @returns {string}
120
106
  */
121
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
107
+ export function xor(lhs: string, rhs: string): string;
122
108
  /**
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
109
+ * Calculates the SHA256 hash of the input bytes
110
+ * @param {Uint8Array} inputs
111
+ * @returns {Uint8Array}
127
112
  */
128
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
113
+ export function sha256(inputs: Uint8Array): Uint8Array;
114
+ /**
115
+ * Calculates the Blake2s256 hash of the input bytes
116
+ * @param {Uint8Array} inputs
117
+ * @returns {Uint8Array}
118
+ */
119
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
120
+ /**
121
+ * Calculates the Keccak256 hash of the input bytes
122
+ * @param {Uint8Array} inputs
123
+ * @returns {Uint8Array}
124
+ */
125
+ export function keccak256(inputs: Uint8Array): Uint8Array;
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}
133
+ */
134
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
135
+ /**
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}
142
+ */
143
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
129
144
  /**
130
145
  * Returns the `BuildInfo` object containing information about how the installed package was built.
131
146
  * @returns {BuildInfo} - Information on how the installed package was built.
132
147
  */
133
148
  export function buildInfo(): BuildInfo;
149
+ /**
150
+ * Sets the package's logging level.
151
+ *
152
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
153
+ */
154
+ export function initLogLevel(filter: string): void;
155
+
156
+ export type ForeignCallInput = string[]
157
+ export type ForeignCallOutput = string | string[]
158
+
159
+ /**
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
+ */
166
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
167
+
168
+
134
169
 
135
170
  export type ExecutionError = Error & {
136
171
  callStack?: string[];
@@ -143,17 +178,12 @@ export type WitnessMap = Map<number, string>;
143
178
 
144
179
 
145
180
 
146
- export type ForeignCallInput = string[]
147
- export type ForeignCallOutput = string | string[]
181
+ export type StackItem = {
182
+ index: number;
183
+ witness: WitnessMap;
184
+ }
148
185
 
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[]>;
186
+ export type WitnessStack = Array<StackItem>;
157
187
 
158
188
 
159
189
 
@@ -180,24 +210,28 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
180
210
 
181
211
  export interface InitOutput {
182
212
  readonly memory: WebAssembly.Memory;
183
- readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
184
- readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
185
- readonly keccak256: (a: number, b: number, c: number) => void;
186
- readonly blake2s256: (a: number, b: number, c: number) => void;
187
- readonly sha256: (a: number, b: number, c: number) => void;
188
- readonly xor: (a: number, b: number) => number;
189
- readonly and: (a: number, b: number) => number;
190
- readonly executeCircuitWithBlackBoxSolver: (a: number, b: number, c: number, d: number, e: number) => number;
191
- readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
192
- readonly createBlackBoxSolver: () => number;
213
+ readonly compressWitness: (a: number, b: number) => void;
214
+ readonly decompressWitness: (a: number, b: number, c: number) => void;
215
+ readonly compressWitnessStack: (a: number, b: number) => void;
216
+ readonly decompressWitnessStack: (a: number, b: number, c: number) => void;
193
217
  readonly __wbg_wasmblackboxfunctionsolver_free: (a: number) => void;
194
- readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
195
- readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
218
+ readonly createBlackBoxSolver: () => number;
219
+ readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
220
+ readonly executeCircuitWithBlackBoxSolver: (a: number, b: number, c: number, d: number, e: number) => number;
221
+ readonly executeProgram: (a: number, b: number, c: number, d: number) => number;
222
+ readonly executeProgramWithBlackBoxSolver: (a: number, b: number, c: number, d: number, e: number) => number;
196
223
  readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
197
- readonly initLogLevel: (a: number, b: number, c: number) => void;
198
- readonly decompressWitness: (a: number, b: number, c: number) => void;
199
- readonly compressWitness: (a: number, b: number) => void;
224
+ readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
225
+ readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
226
+ readonly and: (a: number, b: number) => number;
227
+ readonly xor: (a: number, b: number) => number;
228
+ readonly sha256: (a: number, b: number, c: number) => void;
229
+ readonly blake2s256: (a: number, b: number, c: number) => void;
230
+ readonly keccak256: (a: number, b: number, c: number) => void;
231
+ readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
232
+ readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
200
233
  readonly buildInfo: () => number;
234
+ readonly initLogLevel: (a: number, b: number, c: number) => void;
201
235
  readonly __wbg_trap_free: (a: number) => void;
202
236
  readonly trap___wbg_wasmer_trap: () => void;
203
237
  readonly __wbindgen_malloc: (a: number) => number;
@@ -207,6 +241,7 @@ export interface InitOutput {
207
241
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
208
242
  readonly __wbindgen_free: (a: number, b: number) => void;
209
243
  readonly __wbindgen_exn_store: (a: number) => void;
244
+ readonly wasm_bindgen__convert__closures__invoke3_mut__h28a07b2d2a2056af: (a: number, b: number, c: number, d: number, e: number) => void;
210
245
  readonly wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15: (a: number, b: number, c: number, d: number) => void;
211
246
  }
212
247