@aztec/noir-acvm_js 0.0.1-commit.d431d1c → 0.0.1-commit.db765a8

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