@noir-lang/acvm_js 1.0.0-beta.2-44c35dc.nightly → 1.0.0-beta.20

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.
@@ -1,151 +1,19 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+
3
4
  /**
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
- * Returns the `BuildInfo` object containing information about how the installed package was built.
33
- * @returns {BuildInfo} - Information on how the installed package was built.
34
- */
35
- export function buildInfo(): BuildInfo;
36
- /**
37
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
38
- *
39
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
40
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
41
- * @returns {WitnessMap} A witness map containing the circuit's return values.
42
- * @param {Uint8Array} program
43
- * @param {WitnessMap} witness_map
44
- * @returns {WitnessMap}
45
- */
46
- export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
47
- /**
48
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
49
- *
50
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
51
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
52
- * @returns {WitnessMap} A witness map containing the circuit's public parameters.
53
- * @param {Uint8Array} program
54
- * @param {WitnessMap} solved_witness
55
- * @returns {WitnessMap}
56
- */
57
- export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
58
- /**
59
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
60
- *
61
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
62
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
63
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
64
- * @param {Uint8Array} program
65
- * @param {WitnessMap} solved_witness
66
- * @returns {WitnessMap}
67
- */
68
- export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
69
- /**
70
- * Performs a bitwise AND operation between `lhs` and `rhs`
71
- * @param {string} lhs
72
- * @param {string} rhs
73
- * @returns {string}
74
- */
75
- export function and(lhs: string, rhs: string): string;
76
- /**
77
- * Performs a bitwise XOR operation between `lhs` and `rhs`
78
- * @param {string} lhs
79
- * @param {string} rhs
80
- * @returns {string}
81
- */
82
- export function xor(lhs: string, rhs: string): string;
83
- /**
84
- * Sha256 compression function
85
- * @param {Uint32Array} inputs
86
- * @param {Uint32Array} state
87
- * @returns {Uint32Array}
88
- */
89
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
90
- /**
91
- * Calculates the Blake2s256 hash of the input bytes
92
- * @param {Uint8Array} inputs
93
- * @returns {Uint8Array}
94
- */
95
- export function blake2s256(inputs: Uint8Array): Uint8Array;
96
- /**
97
- * Verifies a ECDSA signature over the secp256k1 curve.
98
- * @param {Uint8Array} hashed_msg
99
- * @param {Uint8Array} public_key_x_bytes
100
- * @param {Uint8Array} public_key_y_bytes
101
- * @param {Uint8Array} signature
102
- * @returns {boolean}
103
- */
104
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
105
- /**
106
- * Verifies a ECDSA signature over the secp256r1 curve.
107
- * @param {Uint8Array} hashed_msg
108
- * @param {Uint8Array} public_key_x_bytes
109
- * @param {Uint8Array} public_key_y_bytes
110
- * @param {Uint8Array} signature
111
- * @returns {boolean}
112
- */
113
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
114
- /**
115
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
116
- *
117
- * @param {WitnessMap} witness_map - A witness map.
118
- * @returns {Uint8Array} A compressed witness map
119
- */
120
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
121
- /**
122
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
123
- * This should be used to only fetch the witness map for the main function.
124
- *
125
- * @param {Uint8Array} compressed_witness - A compressed witness.
126
- * @returns {WitnessMap} The decompressed witness map.
127
- */
128
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
129
- /**
130
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
131
- *
132
- * @param {WitnessStack} witness_stack - A witness stack.
133
- * @returns {Uint8Array} A compressed witness stack
134
- */
135
- export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
136
- /**
137
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
138
- *
139
- * @param {Uint8Array} compressed_witness - A compressed witness.
140
- * @returns {WitnessStack} The decompressed witness stack.
141
- */
142
- export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
143
- /**
144
- * Sets the package's logging level.
145
- *
146
- * @param {LogLevel} level - The maximum level of logging to be emitted.
147
- */
148
- export function initLogLevel(filter: string): void;
5
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
6
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
7
+ * @property {string} version - The version of the package at the built git commit.
8
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
9
+ */
10
+ export type BuildInfo = {
11
+ gitHash: string;
12
+ version: string;
13
+ dirty: string;
14
+ }
15
+
16
+
149
17
 
150
18
  // Map from witness index to hex string value of witness.
151
19
  export type WitnessMap = Map<number, string>;
@@ -162,17 +30,17 @@ export type SolvedAndReturnWitness = {
162
30
 
163
31
 
164
32
 
33
+ export type ForeignCallInput = string[]
34
+ export type ForeignCallOutput = string | string[]
35
+
165
36
  /**
166
- * @typedef {Object} BuildInfo - Information about how the installed package was built
167
- * @property {string} gitHash - The hash of the git commit from which the package was built.
168
- * @property {string} version - The version of the package at the built git commit.
169
- * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
37
+ * A callback which performs an foreign call and returns the response.
38
+ * @callback ForeignCallHandler
39
+ * @param {string} name - The identifier for the type of foreign call being performed.
40
+ * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
41
+ * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
170
42
  */
171
- export type BuildInfo = {
172
- gitHash: string;
173
- version: string;
174
- dirty: string;
175
- }
43
+ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
176
44
 
177
45
 
178
46
 
@@ -184,6 +52,7 @@ export type RawAssertionPayload = {
184
52
  export type ExecutionError = Error & {
185
53
  callStack?: string[];
186
54
  rawAssertionPayload?: RawAssertionPayload;
55
+ acirFunctionId?: number;
187
56
  brilligFunctionId?: number;
188
57
  };
189
58
 
@@ -198,16 +67,136 @@ export type WitnessStack = Array<StackItem>;
198
67
 
199
68
 
200
69
 
201
- export type ForeignCallInput = string[]
202
- export type ForeignCallOutput = string | string[]
70
+ /**
71
+ * Performs a bitwise AND operation between `lhs` and `rhs`
72
+ */
73
+ export function and(lhs: string, rhs: string): string;
203
74
 
204
75
  /**
205
- * A callback which performs an foreign call and returns the response.
206
- * @callback ForeignCallHandler
207
- * @param {string} name - The identifier for the type of foreign call being performed.
208
- * @param {string[][]} inputs - An array of hex encoded inputs to the foreign call.
209
- * @returns {Promise<string[]>} outputs - An array of hex encoded outputs containing the results of the foreign call.
210
- */
211
- export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
76
+ * Calculates the Blake2s256 hash of the input bytes
77
+ */
78
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
212
79
 
80
+ /**
81
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
82
+ * @returns {BuildInfo} - Information on how the installed package was built.
83
+ */
84
+ export function buildInfo(): BuildInfo;
213
85
 
86
+ /**
87
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
88
+ *
89
+ * @param {WitnessMap} witness_map - A witness map.
90
+ * @returns {Uint8Array} A compressed witness map
91
+ */
92
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
93
+
94
+ /**
95
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
96
+ *
97
+ * @param {WitnessStack} witness_stack - A witness stack.
98
+ * @returns {Uint8Array} A compressed witness stack
99
+ */
100
+ export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
101
+
102
+ /**
103
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
104
+ * This should be used to only fetch the witness map for the main function.
105
+ *
106
+ * @param {Uint8Array} compressed_witness - A compressed witness.
107
+ * @returns {WitnessMap} The decompressed witness map.
108
+ */
109
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
110
+
111
+ /**
112
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
113
+ *
114
+ * @param {Uint8Array} compressed_witness - A compressed witness.
115
+ * @returns {WitnessStack} The decompressed witness stack.
116
+ */
117
+ export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
118
+
119
+ /**
120
+ * Verifies a ECDSA signature over the secp256k1 curve.
121
+ */
122
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
123
+
124
+ /**
125
+ * Verifies a ECDSA signature over the secp256r1 curve.
126
+ */
127
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
128
+
129
+ /**
130
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
131
+ *
132
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
133
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
134
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
135
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
136
+ */
137
+ export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
138
+
139
+ /**
140
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
141
+ * This method also extracts the public return values from the solved witness into its own return witness.
142
+ *
143
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
144
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
145
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
146
+ * @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.
147
+ */
148
+ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
149
+
150
+ /**
151
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
152
+ *
153
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
154
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
155
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
156
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
157
+ */
158
+ export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
159
+
160
+ /**
161
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
162
+ *
163
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
164
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
165
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
166
+ */
167
+ export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
168
+
169
+ /**
170
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
171
+ *
172
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
173
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
174
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
175
+ */
176
+ export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
177
+
178
+ /**
179
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
180
+ *
181
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
182
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
183
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
184
+ */
185
+ export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
186
+
187
+ /**
188
+ * Sets the package's logging level.
189
+ *
190
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
191
+ */
192
+ export function initLogLevel(filter: string): void;
193
+
194
+ /**
195
+ * Sha256 compression function
196
+ */
197
+ export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
198
+
199
+ /**
200
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
201
+ */
202
+ export function xor(lhs: string, rhs: string): string;