@noir-lang/acvm_js 0.26.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.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # acvm_js
2
+
3
+ The `acvm_js` package enables users to execute an ACIR program, i.e. generating an initial witness from a set of inputs and calculating a partial witness. This partial witness can then be used to create a proof of execution using an ACVM backend.
4
+
5
+ ## Dependencies
6
+
7
+ In order to build the wasm package, the following must be installed:
8
+
9
+ - [jq](https://github.com/stedolan/jq)
10
+
11
+ ## Build
12
+
13
+ The wasm package can be built using the command below:
14
+
15
+ ```bash
16
+ ./build.sh
17
+ ```
@@ -0,0 +1,141 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
5
+ * @returns {BuildInfo} - Information on how the installed package was built.
6
+ */
7
+ export function buildInfo(): BuildInfo;
8
+ /**
9
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
10
+ *
11
+ * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
12
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
13
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
14
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
15
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
16
+ */
17
+ export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
18
+ /**
19
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
20
+ *
21
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
22
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
23
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
24
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
25
+ */
26
+ export function executeCircuit(circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
27
+ /**
28
+ * @returns {Promise<WasmBlackBoxFunctionSolver>}
29
+ */
30
+ export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
31
+ /**
32
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
33
+ *
34
+ * @param {Uint8Array} compressed_witness - A compressed witness.
35
+ * @returns {WitnessMap} The decompressed witness map.
36
+ */
37
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
38
+ /**
39
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
40
+ *
41
+ * @param {Uint8Array} compressed_witness - A witness map.
42
+ * @returns {WitnessMap} A compressed witness map
43
+ */
44
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
45
+ /**
46
+ * Sets the package's logging level.
47
+ *
48
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
49
+ */
50
+ export function initLogLevel(level: LogLevel): void;
51
+ /**
52
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
53
+ *
54
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
55
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
56
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
57
+ * @param {Uint8Array} circuit
58
+ * @param {WitnessMap} solved_witness
59
+ * @returns {WitnessMap}
60
+ */
61
+ export function getPublicWitness(circuit: Uint8Array, solved_witness: WitnessMap): WitnessMap;
62
+ /**
63
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
64
+ *
65
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
66
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
67
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
68
+ * @param {Uint8Array} circuit
69
+ * @param {WitnessMap} solved_witness
70
+ * @returns {WitnessMap}
71
+ */
72
+ export function getPublicParametersWitness(circuit: Uint8Array, solved_witness: WitnessMap): WitnessMap;
73
+ /**
74
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
75
+ *
76
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
77
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
78
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
79
+ * @param {Uint8Array} circuit
80
+ * @param {WitnessMap} witness_map
81
+ * @returns {WitnessMap}
82
+ */
83
+ export function getReturnWitness(circuit: Uint8Array, witness_map: WitnessMap): WitnessMap;
84
+
85
+ export type ForeignCallInput = string[]
86
+ export type ForeignCallOutput = string | string[]
87
+
88
+ /**
89
+ * A callback which performs an foreign call and returns the response.
90
+ * @callback ForeignCallHandler
91
+ * @param {string} name - The identifier for the type of foreign call being performed.
92
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
93
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
94
+ */
95
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
96
+
97
+
98
+
99
+ /**
100
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
101
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
102
+ * @property {string} version - The version of the package at the built git commit.
103
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
104
+ */
105
+ export type BuildInfo = {
106
+ gitHash: string;
107
+ version: string;
108
+ dirty: string;
109
+ }
110
+
111
+
112
+
113
+ export type ExecutionError = Error & {
114
+ callStack?: string[];
115
+ };
116
+
117
+
118
+
119
+ export type LogLevel = "OFF" | "ERROR" | "WARN" | "INFO" | "DEBUG" | "TRACE";
120
+
121
+
122
+
123
+ // Map from witness index to hex string value of witness.
124
+ export type WitnessMap = Map<number, string>;
125
+
126
+
127
+ /**
128
+ * A struct representing a Trap
129
+ */
130
+ export class Trap {
131
+ free(): void;
132
+ /**
133
+ * @returns {Symbol}
134
+ */
135
+ static __wbgd_downcast_token(): Symbol;
136
+ }
137
+ /**
138
+ */
139
+ export class WasmBlackBoxFunctionSolver {
140
+ free(): void;
141
+ }