@aztec/noir-acvm_js 0.75.0-commit.8a71f57856e217a77b6e50cbc8833c1cd5395b96

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
@@ -0,0 +1,30 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function executeCircuit(a: number, b: number, c: number, d: number): number;
5
+ export function executeCircuitWithReturnWitness(a: number, b: number, c: number, d: number): number;
6
+ export function executeProgram(a: number, b: number, c: number, d: number): number;
7
+ export function initLogLevel(a: number, b: number, c: number): void;
8
+ export function compressWitness(a: number, b: number): void;
9
+ export function decompressWitness(a: number, b: number, c: number): void;
10
+ export function compressWitnessStack(a: number, b: number): void;
11
+ export function decompressWitnessStack(a: number, b: number, c: number): void;
12
+ export function and(a: number, b: number): number;
13
+ export function xor(a: number, b: number): number;
14
+ export function sha256_compression(a: number, b: number, c: number, d: number, e: number): void;
15
+ export function blake2s256(a: number, b: number, c: number): void;
16
+ export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
17
+ export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
18
+ export function buildInfo(): number;
19
+ export function getReturnWitness(a: number, b: number, c: number, d: number): void;
20
+ export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
21
+ export function getPublicWitness(a: number, b: number, c: number, d: number): void;
22
+ export function __wbindgen_malloc(a: number): number;
23
+ export function __wbindgen_realloc(a: number, b: number, c: number): number;
24
+ export const __wbindgen_export_2: WebAssembly.Table;
25
+ export function wasm_bindgen__convert__closures__invoke1_mut__h88a56384c96b757b(a: number, b: number, c: number): void;
26
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
27
+ export function __wbindgen_free(a: number, b: number): void;
28
+ export function wasm_bindgen__convert__closures__invoke3_mut__h24d1dd0bd469df82(a: number, b: number, c: number, d: number, e: number): void;
29
+ export function __wbindgen_exn_store(a: number): void;
30
+ export function wasm_bindgen__convert__closures__invoke2_mut__h57a2220e5f1e0a1e(a: number, b: number, c: number, d: number): void;
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@aztec/noir-acvm_js",
3
+ "version": "0.75.0-commit.8a71f57856e217a77b6e50cbc8833c1cd5395b96",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "contributors": [
8
+ "The Noir Team <team@noir-lang.org>"
9
+ ],
10
+ "homepage": "https://noir-lang.org/",
11
+ "repository": {
12
+ "url": "https://github.com/noir-lang/noir.git",
13
+ "directory": "acvm_repo/acvm_js",
14
+ "type": "git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/noir-lang/noir/issues"
18
+ },
19
+ "license": "MIT",
20
+ "main": "./nodejs/acvm_js.js",
21
+ "types": "./web/acvm_js.d.ts",
22
+ "module": "./web/acvm_js.js",
23
+ "files": [
24
+ "nodejs",
25
+ "web",
26
+ "package.json"
27
+ ],
28
+ "sideEffects": false,
29
+ "packageManager": "yarn@3.5.1",
30
+ "scripts": {
31
+ "build": "bash ./build.sh",
32
+ "test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
33
+ "test:browser": "web-test-runner",
34
+ "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0",
35
+ "publish": "echo 📡 publishing `$npm_package_name` && yarn npm publish",
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
+ },
39
+ "devDependencies": {
40
+ "@esm-bundle/chai": "^4.3.4-fix.0",
41
+ "@web/dev-server-esbuild": "^0.3.6",
42
+ "@web/test-runner": "^0.18.1",
43
+ "@web/test-runner-playwright": "^0.11.0",
44
+ "chai": "^4.4.1",
45
+ "eslint": "^8.57.0",
46
+ "eslint-plugin-prettier": "^5.1.3",
47
+ "mocha": "^10.2.0",
48
+ "prettier": "3.2.5",
49
+ "ts-node": "^10.9.1",
50
+ "typescript": "^5.4.2"
51
+ }
52
+ }
@@ -0,0 +1,267 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
5
+ *
6
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
7
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
8
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
9
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
10
+ */
11
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
12
+ /**
13
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
14
+ * This method also extracts the public return values from the solved witness into its own return witness.
15
+ *
16
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
17
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
18
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
19
+ * @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.
20
+ */
21
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
22
+ /**
23
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
24
+ *
25
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
26
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
27
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
28
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
29
+ */
30
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
31
+ /**
32
+ * Sets the package's logging level.
33
+ *
34
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
35
+ */
36
+ export function initLogLevel(filter: string): void;
37
+ /**
38
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
39
+ *
40
+ * @param {WitnessMap} witness_map - A witness map.
41
+ * @returns {Uint8Array} A compressed witness map
42
+ */
43
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
44
+ /**
45
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
46
+ * This should be used to only fetch the witness map for the main function.
47
+ *
48
+ * @param {Uint8Array} compressed_witness - A compressed witness.
49
+ * @returns {WitnessMap} The decompressed witness map.
50
+ */
51
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
52
+ /**
53
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
54
+ *
55
+ * @param {WitnessStack} witness_stack - A witness stack.
56
+ * @returns {Uint8Array} A compressed witness stack
57
+ */
58
+ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
59
+ /**
60
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
61
+ *
62
+ * @param {Uint8Array} compressed_witness - A compressed witness.
63
+ * @returns {WitnessStack} The decompressed witness stack.
64
+ */
65
+ export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
66
+ /**
67
+ * Performs a bitwise AND operation between `lhs` and `rhs`
68
+ * @param {string} lhs
69
+ * @param {string} rhs
70
+ * @returns {string}
71
+ */
72
+ export function and(lhs: string, rhs: string): string;
73
+ /**
74
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
75
+ * @param {string} lhs
76
+ * @param {string} rhs
77
+ * @returns {string}
78
+ */
79
+ export function xor(lhs: string, rhs: string): string;
80
+ /**
81
+ * Sha256 compression function
82
+ * @param {Uint32Array} inputs
83
+ * @param {Uint32Array} state
84
+ * @returns {Uint32Array}
85
+ */
86
+ export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
87
+ /**
88
+ * Calculates the Blake2s256 hash of the input bytes
89
+ * @param {Uint8Array} inputs
90
+ * @returns {Uint8Array}
91
+ */
92
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
93
+ /**
94
+ * Verifies a ECDSA signature over the secp256k1 curve.
95
+ * @param {Uint8Array} hashed_msg
96
+ * @param {Uint8Array} public_key_x_bytes
97
+ * @param {Uint8Array} public_key_y_bytes
98
+ * @param {Uint8Array} signature
99
+ * @returns {boolean}
100
+ */
101
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
102
+ /**
103
+ * Verifies a ECDSA signature over the secp256r1 curve.
104
+ * @param {Uint8Array} hashed_msg
105
+ * @param {Uint8Array} public_key_x_bytes
106
+ * @param {Uint8Array} public_key_y_bytes
107
+ * @param {Uint8Array} signature
108
+ * @returns {boolean}
109
+ */
110
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
111
+ /**
112
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
113
+ * @returns {BuildInfo} - Information on how the installed package was built.
114
+ */
115
+ export function buildInfo(): BuildInfo;
116
+ /**
117
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
118
+ *
119
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
120
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
121
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
122
+ * @param {Uint8Array} program
123
+ * @param {WitnessMap} witness_map
124
+ * @returns {WitnessMap}
125
+ */
126
+ export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
127
+ /**
128
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
129
+ *
130
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
131
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
132
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
133
+ * @param {Uint8Array} program
134
+ * @param {WitnessMap} solved_witness
135
+ * @returns {WitnessMap}
136
+ */
137
+ export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
138
+ /**
139
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
140
+ *
141
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
142
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
143
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
144
+ * @param {Uint8Array} program
145
+ * @param {WitnessMap} solved_witness
146
+ * @returns {WitnessMap}
147
+ */
148
+ export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
149
+
150
+ // Map from witness index to hex string value of witness.
151
+ export type WitnessMap = Map<number, string>;
152
+
153
+ /**
154
+ * An execution result containing two witnesses.
155
+ * 1. The full solved witness of the execution.
156
+ * 2. The return witness which contains the given public return values within the full witness.
157
+ */
158
+ export type SolvedAndReturnWitness = {
159
+ solvedWitness: WitnessMap;
160
+ returnWitness: WitnessMap;
161
+ }
162
+
163
+
164
+
165
+ export type ForeignCallInput = string[]
166
+ export type ForeignCallOutput = string | string[]
167
+
168
+ /**
169
+ * A callback which performs an foreign call and returns the response.
170
+ * @callback ForeignCallHandler
171
+ * @param {string} name - The identifier for the type of foreign call being performed.
172
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
173
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
174
+ */
175
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
176
+
177
+
178
+
179
+ /**
180
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
181
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
182
+ * @property {string} version - The version of the package at the built git commit.
183
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
184
+ */
185
+ export type BuildInfo = {
186
+ gitHash: string;
187
+ version: string;
188
+ dirty: string;
189
+ }
190
+
191
+
192
+
193
+ export type RawAssertionPayload = {
194
+ selector: string;
195
+ data: string[];
196
+ };
197
+
198
+ export type ExecutionError = Error & {
199
+ callStack?: string[];
200
+ rawAssertionPayload?: RawAssertionPayload;
201
+ brilligFunctionId?: number;
202
+ };
203
+
204
+
205
+
206
+ export type StackItem = {
207
+ index: number;
208
+ witness: WitnessMap;
209
+ }
210
+
211
+ export type WitnessStack = Array<StackItem>;
212
+
213
+
214
+
215
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
216
+
217
+ export interface InitOutput {
218
+ readonly memory: WebAssembly.Memory;
219
+ readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
220
+ readonly executeCircuitWithReturnWitness: (a: number, b: number, c: number, d: number) => number;
221
+ readonly executeProgram: (a: number, b: number, c: number, d: number) => number;
222
+ readonly initLogLevel: (a: number, b: number, c: number) => void;
223
+ readonly compressWitness: (a: number, b: number) => void;
224
+ readonly decompressWitness: (a: number, b: number, c: number) => void;
225
+ readonly compressWitnessStack: (a: number, b: number) => void;
226
+ readonly decompressWitnessStack: (a: number, b: number, c: number) => void;
227
+ readonly and: (a: number, b: number) => number;
228
+ readonly xor: (a: number, b: number) => number;
229
+ readonly sha256_compression: (a: number, b: number, c: number, d: number, e: number) => void;
230
+ readonly blake2s256: (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;
233
+ readonly buildInfo: () => number;
234
+ readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
235
+ readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
236
+ readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
237
+ readonly __wbindgen_malloc: (a: number) => number;
238
+ readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
239
+ readonly __wbindgen_export_2: WebAssembly.Table;
240
+ readonly wasm_bindgen__convert__closures__invoke1_mut__h88a56384c96b757b: (a: number, b: number, c: number) => void;
241
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
242
+ readonly __wbindgen_free: (a: number, b: number) => void;
243
+ readonly wasm_bindgen__convert__closures__invoke3_mut__h24d1dd0bd469df82: (a: number, b: number, c: number, d: number, e: number) => void;
244
+ readonly __wbindgen_exn_store: (a: number) => void;
245
+ readonly wasm_bindgen__convert__closures__invoke2_mut__h57a2220e5f1e0a1e: (a: number, b: number, c: number, d: number) => void;
246
+ }
247
+
248
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
249
+ /**
250
+ * Instantiates the given `module`, which can either be bytes or
251
+ * a precompiled `WebAssembly.Module`.
252
+ *
253
+ * @param {SyncInitInput} module
254
+ *
255
+ * @returns {InitOutput}
256
+ */
257
+ export function initSync(module: SyncInitInput): InitOutput;
258
+
259
+ /**
260
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
261
+ * for everything else, calls `WebAssembly.instantiate` directly.
262
+ *
263
+ * @param {InitInput | Promise<InitInput>} module_or_path
264
+ *
265
+ * @returns {Promise<InitOutput>}
266
+ */
267
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;