@noir-lang/acvm_js 0.42.0 → 0.43.0-0adeb08.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.
- package/nodejs/acvm_js.d.ts +121 -70
- package/nodejs/acvm_js.js +426 -292
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +21 -15
- package/package.json +2 -4
- package/web/acvm_js.d.ts +142 -85
- package/web/acvm_js.js +366 -238
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +21 -15
package/nodejs/acvm_js.d.ts
CHANGED
|
@@ -1,89 +1,85 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param {
|
|
7
|
-
* @
|
|
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}
|
|
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
|
|
19
8
|
*/
|
|
20
|
-
export function
|
|
9
|
+
export function compressWitness(witness_map: WitnessMap): Uint8Array;
|
|
21
10
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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.
|
|
25
16
|
*/
|
|
26
|
-
export function
|
|
17
|
+
export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
|
|
27
18
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
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
|
|
31
23
|
*/
|
|
32
|
-
export function
|
|
24
|
+
export function compressWitnessStack(witness_stack: WitnessStack): Uint8Array;
|
|
33
25
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
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.
|
|
37
30
|
*/
|
|
38
|
-
export function
|
|
31
|
+
export function decompressWitnessStack(compressed_witness: Uint8Array): WitnessStack;
|
|
39
32
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {string} lhs
|
|
42
|
-
* @param {string} rhs
|
|
43
|
-
* @returns {string}
|
|
33
|
+
* @returns {Promise<WasmBlackBoxFunctionSolver>}
|
|
44
34
|
*/
|
|
45
|
-
export function
|
|
35
|
+
export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
|
|
46
36
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @param {
|
|
50
|
-
* @
|
|
37
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
38
|
+
*
|
|
39
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
40
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
41
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
42
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
51
43
|
*/
|
|
52
|
-
export function
|
|
44
|
+
export function executeCircuit(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
|
|
53
45
|
/**
|
|
54
46
|
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
47
|
+
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
55
48
|
*
|
|
56
49
|
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
57
50
|
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
58
51
|
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
59
52
|
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
60
|
-
* @returns {
|
|
53
|
+
* @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.
|
|
61
54
|
*/
|
|
62
|
-
export function
|
|
55
|
+
export function executeCircuitWithReturnWitness(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<SolvedAndReturnWitness>;
|
|
63
56
|
/**
|
|
64
57
|
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
65
58
|
*
|
|
59
|
+
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
66
60
|
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
67
61
|
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
68
62
|
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
69
63
|
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
70
64
|
*/
|
|
71
|
-
export function
|
|
65
|
+
export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
|
|
72
66
|
/**
|
|
73
|
-
* @returns {Promise<WasmBlackBoxFunctionSolver>}
|
|
74
67
|
*/
|
|
75
|
-
export function
|
|
68
|
+
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
76
69
|
/**
|
|
77
|
-
|
|
70
|
+
*/
|
|
71
|
+
export function executeProgramWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, program: Uint8Array, initial_witness: WitnessMap, foreign_call_executor: ForeignCallHandler): Promise<WitnessStack>;
|
|
72
|
+
/**
|
|
73
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
78
74
|
*
|
|
79
75
|
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
80
76
|
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
81
|
-
* @returns {WitnessMap} A witness map containing the circuit's
|
|
77
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
82
78
|
* @param {Uint8Array} program
|
|
83
|
-
* @param {WitnessMap}
|
|
79
|
+
* @param {WitnessMap} witness_map
|
|
84
80
|
* @returns {WitnessMap}
|
|
85
81
|
*/
|
|
86
|
-
export function
|
|
82
|
+
export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
|
|
87
83
|
/**
|
|
88
84
|
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
89
85
|
*
|
|
@@ -96,50 +92,99 @@ export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap
|
|
|
96
92
|
*/
|
|
97
93
|
export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
98
94
|
/**
|
|
99
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's
|
|
95
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
100
96
|
*
|
|
101
97
|
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
102
98
|
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
103
|
-
* @returns {WitnessMap} A witness map containing the circuit's
|
|
99
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
104
100
|
* @param {Uint8Array} program
|
|
105
|
-
* @param {WitnessMap}
|
|
101
|
+
* @param {WitnessMap} solved_witness
|
|
106
102
|
* @returns {WitnessMap}
|
|
107
103
|
*/
|
|
108
|
-
export function
|
|
104
|
+
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
109
105
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* @param {
|
|
106
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
107
|
+
* @param {string} lhs
|
|
108
|
+
* @param {string} rhs
|
|
109
|
+
* @returns {string}
|
|
113
110
|
*/
|
|
114
|
-
export function
|
|
111
|
+
export function and(lhs: string, rhs: string): string;
|
|
115
112
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* @param {
|
|
119
|
-
* @returns {
|
|
113
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
114
|
+
* @param {string} lhs
|
|
115
|
+
* @param {string} rhs
|
|
116
|
+
* @returns {string}
|
|
120
117
|
*/
|
|
121
|
-
export function
|
|
118
|
+
export function xor(lhs: string, rhs: string): string;
|
|
122
119
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @
|
|
126
|
-
* @returns {WitnessMap} A compressed witness map
|
|
120
|
+
* Calculates the SHA256 hash of the input bytes
|
|
121
|
+
* @param {Uint8Array} inputs
|
|
122
|
+
* @returns {Uint8Array}
|
|
127
123
|
*/
|
|
128
|
-
export function
|
|
124
|
+
export function sha256(inputs: Uint8Array): Uint8Array;
|
|
125
|
+
/**
|
|
126
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
127
|
+
* @param {Uint8Array} inputs
|
|
128
|
+
* @returns {Uint8Array}
|
|
129
|
+
*/
|
|
130
|
+
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
131
|
+
/**
|
|
132
|
+
* Calculates the Keccak256 hash of the input bytes
|
|
133
|
+
* @param {Uint8Array} inputs
|
|
134
|
+
* @returns {Uint8Array}
|
|
135
|
+
*/
|
|
136
|
+
export function keccak256(inputs: Uint8Array): Uint8Array;
|
|
137
|
+
/**
|
|
138
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
139
|
+
* @param {Uint8Array} hashed_msg
|
|
140
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
141
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
142
|
+
* @param {Uint8Array} signature
|
|
143
|
+
* @returns {boolean}
|
|
144
|
+
*/
|
|
145
|
+
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
148
|
+
* @param {Uint8Array} hashed_msg
|
|
149
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
150
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
151
|
+
* @param {Uint8Array} signature
|
|
152
|
+
* @returns {boolean}
|
|
153
|
+
*/
|
|
154
|
+
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
129
155
|
/**
|
|
130
156
|
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
131
157
|
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
132
158
|
*/
|
|
133
159
|
export function buildInfo(): BuildInfo;
|
|
160
|
+
/**
|
|
161
|
+
* Sets the package's logging level.
|
|
162
|
+
*
|
|
163
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
164
|
+
*/
|
|
165
|
+
export function initLogLevel(filter: string): void;
|
|
134
166
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
167
|
+
// Map from witness index to hex string value of witness.
|
|
168
|
+
export type WitnessMap = Map<number, string>;
|
|
138
169
|
|
|
170
|
+
/**
|
|
171
|
+
* An execution result containing two witnesses.
|
|
172
|
+
* 1. The full solved witness of the execution.
|
|
173
|
+
* 2. The return witness which contains the given public return values within the full witness.
|
|
174
|
+
*/
|
|
175
|
+
export type SolvedAndReturnWitness = {
|
|
176
|
+
solvedWitness: WitnessMap;
|
|
177
|
+
returnWitness: WitnessMap;
|
|
178
|
+
}
|
|
139
179
|
|
|
140
180
|
|
|
141
|
-
|
|
142
|
-
export type
|
|
181
|
+
|
|
182
|
+
export type StackItem = {
|
|
183
|
+
index: number;
|
|
184
|
+
witness: WitnessMap;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export type WitnessStack = Array<StackItem>;
|
|
143
188
|
|
|
144
189
|
|
|
145
190
|
|
|
@@ -170,6 +215,12 @@ export type BuildInfo = {
|
|
|
170
215
|
}
|
|
171
216
|
|
|
172
217
|
|
|
218
|
+
|
|
219
|
+
export type ExecutionError = Error & {
|
|
220
|
+
callStack?: string[];
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
|
|
173
224
|
/**
|
|
174
225
|
*/
|
|
175
226
|
export class WasmBlackBoxFunctionSolver {
|