@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.
Binary file
@@ -1,23 +1,27 @@
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;
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;
18
17
  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;
18
+ export function and(a: number, b: number): number;
19
+ export function xor(a: number, b: number): number;
20
+ export function sha256(a: number, b: number, c: number): void;
21
+ export function blake2s256(a: number, b: number, c: number): void;
22
+ export function keccak256(a: number, b: number, c: number): void;
23
+ export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
24
+ export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
21
25
  export function buildInfo(): number;
22
26
  export function __wbg_trap_free(a: number): void;
23
27
  export function trap___wbg_wasmer_trap(): void;
@@ -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-90ee479.nightly",
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,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 {
@@ -180,23 +210,27 @@ 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;
224
+ readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
225
+ readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
197
226
  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;
227
+ readonly and: (a: number, b: number) => number;
228
+ readonly xor: (a: number, b: number) => number;
229
+ readonly sha256: (a: number, b: number, c: number) => void;
230
+ readonly blake2s256: (a: number, b: number, c: number) => void;
231
+ readonly keccak256: (a: number, b: number, c: number) => void;
232
+ readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
233
+ readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
200
234
  readonly buildInfo: () => number;
201
235
  readonly __wbg_trap_free: (a: number) => void;
202
236
  readonly trap___wbg_wasmer_trap: () => void;
@@ -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