@aztec/noir-acvm_js 2.0.0-nightly.20250902 → 3.0.0-canary.a9708bd
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 +53 -53
- package/nodejs/acvm_js.js +146 -146
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +11 -11
- package/package.json +1 -1
- package/web/acvm_js.d.ts +64 -64
- package/web/acvm_js.js +146 -146
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +11 -11
package/nodejs/acvm_js.d.ts
CHANGED
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
9
|
-
*/
|
|
10
|
-
export function xor(lhs: string, rhs: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Sha256 compression function
|
|
13
|
-
*/
|
|
14
|
-
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
15
|
-
/**
|
|
16
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
17
|
-
*/
|
|
18
|
-
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
19
|
-
/**
|
|
20
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
21
|
-
*/
|
|
22
|
-
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
25
|
-
*/
|
|
26
|
-
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
29
|
-
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
4
|
+
* Sets the package's logging level.
|
|
5
|
+
*
|
|
6
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
30
7
|
*/
|
|
31
|
-
export function
|
|
8
|
+
export function initLogLevel(filter: string): void;
|
|
32
9
|
/**
|
|
33
10
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
34
11
|
*
|
|
@@ -86,6 +63,35 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
|
|
|
86
63
|
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
87
64
|
*/
|
|
88
65
|
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
66
|
+
/**
|
|
67
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
68
|
+
*/
|
|
69
|
+
export function and(lhs: string, rhs: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
72
|
+
*/
|
|
73
|
+
export function xor(lhs: string, rhs: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Sha256 compression function
|
|
76
|
+
*/
|
|
77
|
+
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
78
|
+
/**
|
|
79
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
80
|
+
*/
|
|
81
|
+
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
82
|
+
/**
|
|
83
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
84
|
+
*/
|
|
85
|
+
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
88
|
+
*/
|
|
89
|
+
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
92
|
+
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
93
|
+
*/
|
|
94
|
+
export function buildInfo(): BuildInfo;
|
|
89
95
|
/**
|
|
90
96
|
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
91
97
|
*
|
|
@@ -110,12 +116,6 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
|
|
|
110
116
|
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
111
117
|
*/
|
|
112
118
|
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
113
|
-
/**
|
|
114
|
-
* Sets the package's logging level.
|
|
115
|
-
*
|
|
116
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
117
|
-
*/
|
|
118
|
-
export function initLogLevel(filter: string): void;
|
|
119
119
|
|
|
120
120
|
export type StackItem = {
|
|
121
121
|
index: number;
|
|
@@ -140,17 +140,17 @@ export type BuildInfo = {
|
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
export type
|
|
144
|
-
|
|
143
|
+
export type RawAssertionPayload = {
|
|
144
|
+
selector: string;
|
|
145
|
+
data: string[];
|
|
146
|
+
};
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
*/
|
|
153
|
-
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
148
|
+
export type ExecutionError = Error & {
|
|
149
|
+
callStack?: string[];
|
|
150
|
+
rawAssertionPayload?: RawAssertionPayload;
|
|
151
|
+
acirFunctionId?: number;
|
|
152
|
+
brilligFunctionId?: number;
|
|
153
|
+
};
|
|
154
154
|
|
|
155
155
|
|
|
156
156
|
|
|
@@ -169,16 +169,16 @@ export type SolvedAndReturnWitness = {
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
|
|
172
|
-
export type
|
|
173
|
-
|
|
174
|
-
data: string[];
|
|
175
|
-
};
|
|
172
|
+
export type ForeignCallInput = string[]
|
|
173
|
+
export type ForeignCallOutput = string | string[]
|
|
176
174
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
175
|
+
/**
|
|
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
183
|
|
|
184
184
|
|
package/nodejs/acvm_js.js
CHANGED
|
@@ -201,6 +201,147 @@ function debugString(val) {
|
|
|
201
201
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
202
202
|
return className;
|
|
203
203
|
}
|
|
204
|
+
|
|
205
|
+
function takeFromExternrefTable0(idx) {
|
|
206
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
207
|
+
wasm.__externref_table_dealloc(idx);
|
|
208
|
+
return value;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Sets the package's logging level.
|
|
212
|
+
*
|
|
213
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
214
|
+
*/
|
|
215
|
+
module.exports.initLogLevel = function(filter) {
|
|
216
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
217
|
+
const len0 = WASM_VECTOR_LEN;
|
|
218
|
+
const ret = wasm.initLogLevel(ptr0, len0);
|
|
219
|
+
if (ret[1]) {
|
|
220
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
225
|
+
ptr = ptr >>> 0;
|
|
226
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
230
|
+
*
|
|
231
|
+
* @param {WitnessMap} witness_map - A witness map.
|
|
232
|
+
* @returns {Uint8Array} A compressed witness map
|
|
233
|
+
*/
|
|
234
|
+
module.exports.compressWitness = function(witness_map) {
|
|
235
|
+
const ret = wasm.compressWitness(witness_map);
|
|
236
|
+
if (ret[3]) {
|
|
237
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
238
|
+
}
|
|
239
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
240
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
241
|
+
return v1;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
245
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
246
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
247
|
+
WASM_VECTOR_LEN = arg.length;
|
|
248
|
+
return ptr;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
252
|
+
* This should be used to only fetch the witness map for the main function.
|
|
253
|
+
*
|
|
254
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
255
|
+
* @returns {WitnessMap} The decompressed witness map.
|
|
256
|
+
*/
|
|
257
|
+
module.exports.decompressWitness = function(compressed_witness) {
|
|
258
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
259
|
+
const len0 = WASM_VECTOR_LEN;
|
|
260
|
+
const ret = wasm.decompressWitness(ptr0, len0);
|
|
261
|
+
if (ret[2]) {
|
|
262
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
263
|
+
}
|
|
264
|
+
return takeFromExternrefTable0(ret[0]);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Compresses a `WitnessStack` into the binary format outputted by Nargo.
|
|
269
|
+
*
|
|
270
|
+
* @param {WitnessStack} witness_stack - A witness stack.
|
|
271
|
+
* @returns {Uint8Array} A compressed witness stack
|
|
272
|
+
*/
|
|
273
|
+
module.exports.compressWitnessStack = function(witness_stack) {
|
|
274
|
+
const ret = wasm.compressWitnessStack(witness_stack);
|
|
275
|
+
if (ret[3]) {
|
|
276
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
277
|
+
}
|
|
278
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
279
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
280
|
+
return v1;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
|
|
285
|
+
*
|
|
286
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
287
|
+
* @returns {WitnessStack} The decompressed witness stack.
|
|
288
|
+
*/
|
|
289
|
+
module.exports.decompressWitnessStack = function(compressed_witness) {
|
|
290
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
291
|
+
const len0 = WASM_VECTOR_LEN;
|
|
292
|
+
const ret = wasm.decompressWitnessStack(ptr0, len0);
|
|
293
|
+
if (ret[2]) {
|
|
294
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
295
|
+
}
|
|
296
|
+
return takeFromExternrefTable0(ret[0]);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
301
|
+
*
|
|
302
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
303
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
304
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
305
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
306
|
+
*/
|
|
307
|
+
module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
|
|
308
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
309
|
+
const len0 = WASM_VECTOR_LEN;
|
|
310
|
+
const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
|
|
311
|
+
return ret;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
316
|
+
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
317
|
+
*
|
|
318
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
319
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
320
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
321
|
+
* @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.
|
|
322
|
+
*/
|
|
323
|
+
module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
|
|
324
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
325
|
+
const len0 = WASM_VECTOR_LEN;
|
|
326
|
+
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
|
|
327
|
+
return ret;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
332
|
+
*
|
|
333
|
+
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
334
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
335
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
336
|
+
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
337
|
+
*/
|
|
338
|
+
module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
|
|
339
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
340
|
+
const len0 = WASM_VECTOR_LEN;
|
|
341
|
+
const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
|
|
342
|
+
return ret;
|
|
343
|
+
};
|
|
344
|
+
|
|
204
345
|
/**
|
|
205
346
|
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
206
347
|
* @param {string} lhs
|
|
@@ -260,17 +401,6 @@ module.exports.sha256_compression = function(inputs, state) {
|
|
|
260
401
|
return v3;
|
|
261
402
|
};
|
|
262
403
|
|
|
263
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
264
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
265
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
266
|
-
WASM_VECTOR_LEN = arg.length;
|
|
267
|
-
return ptr;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
271
|
-
ptr = ptr >>> 0;
|
|
272
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
273
|
-
}
|
|
274
404
|
/**
|
|
275
405
|
* Calculates the Blake2s256 hash of the input bytes
|
|
276
406
|
* @param {Uint8Array} inputs
|
|
@@ -336,122 +466,6 @@ module.exports.buildInfo = function() {
|
|
|
336
466
|
return ret;
|
|
337
467
|
};
|
|
338
468
|
|
|
339
|
-
function takeFromExternrefTable0(idx) {
|
|
340
|
-
const value = wasm.__wbindgen_export_2.get(idx);
|
|
341
|
-
wasm.__externref_table_dealloc(idx);
|
|
342
|
-
return value;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
346
|
-
*
|
|
347
|
-
* @param {WitnessMap} witness_map - A witness map.
|
|
348
|
-
* @returns {Uint8Array} A compressed witness map
|
|
349
|
-
*/
|
|
350
|
-
module.exports.compressWitness = function(witness_map) {
|
|
351
|
-
const ret = wasm.compressWitness(witness_map);
|
|
352
|
-
if (ret[3]) {
|
|
353
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
354
|
-
}
|
|
355
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
356
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
357
|
-
return v1;
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
362
|
-
* This should be used to only fetch the witness map for the main function.
|
|
363
|
-
*
|
|
364
|
-
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
365
|
-
* @returns {WitnessMap} The decompressed witness map.
|
|
366
|
-
*/
|
|
367
|
-
module.exports.decompressWitness = function(compressed_witness) {
|
|
368
|
-
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
369
|
-
const len0 = WASM_VECTOR_LEN;
|
|
370
|
-
const ret = wasm.decompressWitness(ptr0, len0);
|
|
371
|
-
if (ret[2]) {
|
|
372
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
373
|
-
}
|
|
374
|
-
return takeFromExternrefTable0(ret[0]);
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Compresses a `WitnessStack` into the binary format outputted by Nargo.
|
|
379
|
-
*
|
|
380
|
-
* @param {WitnessStack} witness_stack - A witness stack.
|
|
381
|
-
* @returns {Uint8Array} A compressed witness stack
|
|
382
|
-
*/
|
|
383
|
-
module.exports.compressWitnessStack = function(witness_stack) {
|
|
384
|
-
const ret = wasm.compressWitnessStack(witness_stack);
|
|
385
|
-
if (ret[3]) {
|
|
386
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
387
|
-
}
|
|
388
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
389
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
390
|
-
return v1;
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
|
|
395
|
-
*
|
|
396
|
-
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
397
|
-
* @returns {WitnessStack} The decompressed witness stack.
|
|
398
|
-
*/
|
|
399
|
-
module.exports.decompressWitnessStack = function(compressed_witness) {
|
|
400
|
-
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
401
|
-
const len0 = WASM_VECTOR_LEN;
|
|
402
|
-
const ret = wasm.decompressWitnessStack(ptr0, len0);
|
|
403
|
-
if (ret[2]) {
|
|
404
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
405
|
-
}
|
|
406
|
-
return takeFromExternrefTable0(ret[0]);
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
411
|
-
*
|
|
412
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
413
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
414
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
415
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
416
|
-
*/
|
|
417
|
-
module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
|
|
418
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
419
|
-
const len0 = WASM_VECTOR_LEN;
|
|
420
|
-
const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
|
|
421
|
-
return ret;
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
426
|
-
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
427
|
-
*
|
|
428
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
429
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
430
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
431
|
-
* @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.
|
|
432
|
-
*/
|
|
433
|
-
module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
|
|
434
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
435
|
-
const len0 = WASM_VECTOR_LEN;
|
|
436
|
-
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
|
|
437
|
-
return ret;
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
442
|
-
*
|
|
443
|
-
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
444
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
445
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
446
|
-
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
447
|
-
*/
|
|
448
|
-
module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
|
|
449
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
450
|
-
const len0 = WASM_VECTOR_LEN;
|
|
451
|
-
const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
|
|
452
|
-
return ret;
|
|
453
|
-
};
|
|
454
|
-
|
|
455
469
|
/**
|
|
456
470
|
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
457
471
|
*
|
|
@@ -512,30 +526,16 @@ module.exports.getPublicWitness = function(program, solved_witness) {
|
|
|
512
526
|
return takeFromExternrefTable0(ret[0]);
|
|
513
527
|
};
|
|
514
528
|
|
|
515
|
-
/**
|
|
516
|
-
* Sets the package's logging level.
|
|
517
|
-
*
|
|
518
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
519
|
-
*/
|
|
520
|
-
module.exports.initLogLevel = function(filter) {
|
|
521
|
-
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
522
|
-
const len0 = WASM_VECTOR_LEN;
|
|
523
|
-
const ret = wasm.initLogLevel(ptr0, len0);
|
|
524
|
-
if (ret[1]) {
|
|
525
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
|
|
529
529
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
|
530
|
-
wasm.
|
|
530
|
+
wasm.closure571_externref_shim(arg0, arg1, arg2);
|
|
531
531
|
}
|
|
532
532
|
|
|
533
533
|
function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
|
|
534
|
-
wasm.
|
|
534
|
+
wasm.closure1165_externref_shim(arg0, arg1, arg2, arg3, arg4);
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
|
|
538
|
-
wasm.
|
|
538
|
+
wasm.closure1169_externref_shim(arg0, arg1, arg2, arg3);
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
@@ -813,8 +813,8 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
813
813
|
return ret;
|
|
814
814
|
};
|
|
815
815
|
|
|
816
|
-
module.exports.
|
|
817
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
816
|
+
module.exports.__wbindgen_closure_wrapper1986 = function(arg0, arg1, arg2) {
|
|
817
|
+
const ret = makeMutClosure(arg0, arg1, 572, __wbg_adapter_30);
|
|
818
818
|
return ret;
|
|
819
819
|
};
|
|
820
820
|
|
package/nodejs/acvm_js_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const
|
|
5
|
-
export const xor: (a: any, b: any) => any;
|
|
6
|
-
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
7
|
-
export const blake2s256: (a: number, b: number) => [number, number];
|
|
8
|
-
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
9
|
-
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
10
|
-
export const buildInfo: () => any;
|
|
4
|
+
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
11
5
|
export const compressWitness: (a: any) => [number, number, number, number];
|
|
12
6
|
export const decompressWitness: (a: number, b: number) => [number, number, number];
|
|
13
7
|
export const compressWitnessStack: (a: any) => [number, number, number, number];
|
|
@@ -15,10 +9,16 @@ export const decompressWitnessStack: (a: number, b: number) => [number, number,
|
|
|
15
9
|
export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
16
10
|
export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
17
11
|
export const executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
12
|
+
export const and: (a: any, b: any) => any;
|
|
13
|
+
export const xor: (a: any, b: any) => any;
|
|
14
|
+
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
15
|
+
export const blake2s256: (a: number, b: number) => [number, number];
|
|
16
|
+
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
17
|
+
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
18
|
+
export const buildInfo: () => any;
|
|
18
19
|
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
19
20
|
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
20
21
|
export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
21
|
-
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
22
22
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
23
23
|
export const __externref_table_alloc: () => number;
|
|
24
24
|
export const __wbindgen_export_2: WebAssembly.Table;
|
|
@@ -27,7 +27,7 @@ export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
|
27
27
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
28
28
|
export const __wbindgen_export_6: WebAssembly.Table;
|
|
29
29
|
export const __externref_table_dealloc: (a: number) => void;
|
|
30
|
-
export const
|
|
31
|
-
export const
|
|
32
|
-
export const
|
|
30
|
+
export const closure571_externref_shim: (a: number, b: number, c: any) => void;
|
|
31
|
+
export const closure1165_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
|
|
32
|
+
export const closure1169_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
33
33
|
export const __wbindgen_start: () => void;
|
package/package.json
CHANGED
package/web/acvm_js.d.ts
CHANGED
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
9
|
-
*/
|
|
10
|
-
export function xor(lhs: string, rhs: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Sha256 compression function
|
|
13
|
-
*/
|
|
14
|
-
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
15
|
-
/**
|
|
16
|
-
* Calculates the Blake2s256 hash of the input bytes
|
|
17
|
-
*/
|
|
18
|
-
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
19
|
-
/**
|
|
20
|
-
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
21
|
-
*/
|
|
22
|
-
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
25
|
-
*/
|
|
26
|
-
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
29
|
-
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
4
|
+
* Sets the package's logging level.
|
|
5
|
+
*
|
|
6
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
30
7
|
*/
|
|
31
|
-
export function
|
|
8
|
+
export function initLogLevel(filter: string): void;
|
|
32
9
|
/**
|
|
33
10
|
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
34
11
|
*
|
|
@@ -86,6 +63,35 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
|
|
|
86
63
|
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
87
64
|
*/
|
|
88
65
|
export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
|
|
66
|
+
/**
|
|
67
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
68
|
+
*/
|
|
69
|
+
export function and(lhs: string, rhs: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
72
|
+
*/
|
|
73
|
+
export function xor(lhs: string, rhs: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Sha256 compression function
|
|
76
|
+
*/
|
|
77
|
+
export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
|
|
78
|
+
/**
|
|
79
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
80
|
+
*/
|
|
81
|
+
export function blake2s256(inputs: Uint8Array): Uint8Array;
|
|
82
|
+
/**
|
|
83
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
84
|
+
*/
|
|
85
|
+
export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
88
|
+
*/
|
|
89
|
+
export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
92
|
+
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
93
|
+
*/
|
|
94
|
+
export function buildInfo(): BuildInfo;
|
|
89
95
|
/**
|
|
90
96
|
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
91
97
|
*
|
|
@@ -110,12 +116,6 @@ export function getPublicParametersWitness(program: Uint8Array, solved_witness:
|
|
|
110
116
|
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
111
117
|
*/
|
|
112
118
|
export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
|
|
113
|
-
/**
|
|
114
|
-
* Sets the package's logging level.
|
|
115
|
-
*
|
|
116
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
117
|
-
*/
|
|
118
|
-
export function initLogLevel(filter: string): void;
|
|
119
119
|
|
|
120
120
|
export type StackItem = {
|
|
121
121
|
index: number;
|
|
@@ -140,17 +140,17 @@ export type BuildInfo = {
|
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
export type
|
|
144
|
-
|
|
143
|
+
export type RawAssertionPayload = {
|
|
144
|
+
selector: string;
|
|
145
|
+
data: string[];
|
|
146
|
+
};
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
*/
|
|
153
|
-
export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => Promise<ForeignCallOutput[]>;
|
|
148
|
+
export type ExecutionError = Error & {
|
|
149
|
+
callStack?: string[];
|
|
150
|
+
rawAssertionPayload?: RawAssertionPayload;
|
|
151
|
+
acirFunctionId?: number;
|
|
152
|
+
brilligFunctionId?: number;
|
|
153
|
+
};
|
|
154
154
|
|
|
155
155
|
|
|
156
156
|
|
|
@@ -169,17 +169,17 @@ export type SolvedAndReturnWitness = {
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
|
|
172
|
-
export type
|
|
173
|
-
|
|
174
|
-
data: string[];
|
|
175
|
-
};
|
|
172
|
+
export type ForeignCallInput = string[]
|
|
173
|
+
export type ForeignCallOutput = string | string[]
|
|
176
174
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
175
|
+
/**
|
|
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
183
|
|
|
184
184
|
|
|
185
185
|
|
|
@@ -187,13 +187,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
187
187
|
|
|
188
188
|
export interface InitOutput {
|
|
189
189
|
readonly memory: WebAssembly.Memory;
|
|
190
|
-
readonly
|
|
191
|
-
readonly xor: (a: any, b: any) => any;
|
|
192
|
-
readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
193
|
-
readonly blake2s256: (a: number, b: number) => [number, number];
|
|
194
|
-
readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
195
|
-
readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
196
|
-
readonly buildInfo: () => any;
|
|
190
|
+
readonly initLogLevel: (a: number, b: number) => [number, number];
|
|
197
191
|
readonly compressWitness: (a: any) => [number, number, number, number];
|
|
198
192
|
readonly decompressWitness: (a: number, b: number) => [number, number, number];
|
|
199
193
|
readonly compressWitnessStack: (a: any) => [number, number, number, number];
|
|
@@ -201,10 +195,16 @@ export interface InitOutput {
|
|
|
201
195
|
readonly executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
202
196
|
readonly executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
203
197
|
readonly executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
198
|
+
readonly and: (a: any, b: any) => any;
|
|
199
|
+
readonly xor: (a: any, b: any) => any;
|
|
200
|
+
readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
201
|
+
readonly blake2s256: (a: number, b: number) => [number, number];
|
|
202
|
+
readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
203
|
+
readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
204
|
+
readonly buildInfo: () => any;
|
|
204
205
|
readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
205
206
|
readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
206
207
|
readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
207
|
-
readonly initLogLevel: (a: number, b: number) => [number, number];
|
|
208
208
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
209
209
|
readonly __externref_table_alloc: () => number;
|
|
210
210
|
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
@@ -213,9 +213,9 @@ export interface InitOutput {
|
|
|
213
213
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
214
214
|
readonly __wbindgen_export_6: WebAssembly.Table;
|
|
215
215
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
216
|
-
readonly
|
|
217
|
-
readonly
|
|
218
|
-
readonly
|
|
216
|
+
readonly closure571_externref_shim: (a: number, b: number, c: any) => void;
|
|
217
|
+
readonly closure1165_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
|
|
218
|
+
readonly closure1169_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
219
219
|
readonly __wbindgen_start: () => void;
|
|
220
220
|
}
|
|
221
221
|
|
package/web/acvm_js.js
CHANGED
|
@@ -197,6 +197,147 @@ function debugString(val) {
|
|
|
197
197
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
198
198
|
return className;
|
|
199
199
|
}
|
|
200
|
+
|
|
201
|
+
function takeFromExternrefTable0(idx) {
|
|
202
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
203
|
+
wasm.__externref_table_dealloc(idx);
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Sets the package's logging level.
|
|
208
|
+
*
|
|
209
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
210
|
+
*/
|
|
211
|
+
export function initLogLevel(filter) {
|
|
212
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
213
|
+
const len0 = WASM_VECTOR_LEN;
|
|
214
|
+
const ret = wasm.initLogLevel(ptr0, len0);
|
|
215
|
+
if (ret[1]) {
|
|
216
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
221
|
+
ptr = ptr >>> 0;
|
|
222
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
226
|
+
*
|
|
227
|
+
* @param {WitnessMap} witness_map - A witness map.
|
|
228
|
+
* @returns {Uint8Array} A compressed witness map
|
|
229
|
+
*/
|
|
230
|
+
export function compressWitness(witness_map) {
|
|
231
|
+
const ret = wasm.compressWitness(witness_map);
|
|
232
|
+
if (ret[3]) {
|
|
233
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
234
|
+
}
|
|
235
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
236
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
237
|
+
return v1;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
241
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
242
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
243
|
+
WASM_VECTOR_LEN = arg.length;
|
|
244
|
+
return ptr;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
248
|
+
* This should be used to only fetch the witness map for the main function.
|
|
249
|
+
*
|
|
250
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
251
|
+
* @returns {WitnessMap} The decompressed witness map.
|
|
252
|
+
*/
|
|
253
|
+
export function decompressWitness(compressed_witness) {
|
|
254
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
255
|
+
const len0 = WASM_VECTOR_LEN;
|
|
256
|
+
const ret = wasm.decompressWitness(ptr0, len0);
|
|
257
|
+
if (ret[2]) {
|
|
258
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
259
|
+
}
|
|
260
|
+
return takeFromExternrefTable0(ret[0]);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Compresses a `WitnessStack` into the binary format outputted by Nargo.
|
|
265
|
+
*
|
|
266
|
+
* @param {WitnessStack} witness_stack - A witness stack.
|
|
267
|
+
* @returns {Uint8Array} A compressed witness stack
|
|
268
|
+
*/
|
|
269
|
+
export function compressWitnessStack(witness_stack) {
|
|
270
|
+
const ret = wasm.compressWitnessStack(witness_stack);
|
|
271
|
+
if (ret[3]) {
|
|
272
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
273
|
+
}
|
|
274
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
275
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
276
|
+
return v1;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
|
|
281
|
+
*
|
|
282
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
283
|
+
* @returns {WitnessStack} The decompressed witness stack.
|
|
284
|
+
*/
|
|
285
|
+
export function decompressWitnessStack(compressed_witness) {
|
|
286
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
287
|
+
const len0 = WASM_VECTOR_LEN;
|
|
288
|
+
const ret = wasm.decompressWitnessStack(ptr0, len0);
|
|
289
|
+
if (ret[2]) {
|
|
290
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
291
|
+
}
|
|
292
|
+
return takeFromExternrefTable0(ret[0]);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
297
|
+
*
|
|
298
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
299
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
300
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
301
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
302
|
+
*/
|
|
303
|
+
export function executeCircuit(program, initial_witness, foreign_call_handler) {
|
|
304
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
305
|
+
const len0 = WASM_VECTOR_LEN;
|
|
306
|
+
const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
|
|
307
|
+
return ret;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
312
|
+
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
313
|
+
*
|
|
314
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
315
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
316
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
317
|
+
* @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.
|
|
318
|
+
*/
|
|
319
|
+
export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
|
|
320
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
321
|
+
const len0 = WASM_VECTOR_LEN;
|
|
322
|
+
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
|
|
323
|
+
return ret;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
328
|
+
*
|
|
329
|
+
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
330
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
331
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
332
|
+
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
333
|
+
*/
|
|
334
|
+
export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
335
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
336
|
+
const len0 = WASM_VECTOR_LEN;
|
|
337
|
+
const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
|
|
338
|
+
return ret;
|
|
339
|
+
}
|
|
340
|
+
|
|
200
341
|
/**
|
|
201
342
|
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
202
343
|
* @param {string} lhs
|
|
@@ -256,17 +397,6 @@ export function sha256_compression(inputs, state) {
|
|
|
256
397
|
return v3;
|
|
257
398
|
}
|
|
258
399
|
|
|
259
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
260
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
261
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
262
|
-
WASM_VECTOR_LEN = arg.length;
|
|
263
|
-
return ptr;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
267
|
-
ptr = ptr >>> 0;
|
|
268
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
269
|
-
}
|
|
270
400
|
/**
|
|
271
401
|
* Calculates the Blake2s256 hash of the input bytes
|
|
272
402
|
* @param {Uint8Array} inputs
|
|
@@ -332,122 +462,6 @@ export function buildInfo() {
|
|
|
332
462
|
return ret;
|
|
333
463
|
}
|
|
334
464
|
|
|
335
|
-
function takeFromExternrefTable0(idx) {
|
|
336
|
-
const value = wasm.__wbindgen_export_2.get(idx);
|
|
337
|
-
wasm.__externref_table_dealloc(idx);
|
|
338
|
-
return value;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
342
|
-
*
|
|
343
|
-
* @param {WitnessMap} witness_map - A witness map.
|
|
344
|
-
* @returns {Uint8Array} A compressed witness map
|
|
345
|
-
*/
|
|
346
|
-
export function compressWitness(witness_map) {
|
|
347
|
-
const ret = wasm.compressWitness(witness_map);
|
|
348
|
-
if (ret[3]) {
|
|
349
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
350
|
-
}
|
|
351
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
352
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
353
|
-
return v1;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
358
|
-
* This should be used to only fetch the witness map for the main function.
|
|
359
|
-
*
|
|
360
|
-
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
361
|
-
* @returns {WitnessMap} The decompressed witness map.
|
|
362
|
-
*/
|
|
363
|
-
export function decompressWitness(compressed_witness) {
|
|
364
|
-
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
365
|
-
const len0 = WASM_VECTOR_LEN;
|
|
366
|
-
const ret = wasm.decompressWitness(ptr0, len0);
|
|
367
|
-
if (ret[2]) {
|
|
368
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
369
|
-
}
|
|
370
|
-
return takeFromExternrefTable0(ret[0]);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Compresses a `WitnessStack` into the binary format outputted by Nargo.
|
|
375
|
-
*
|
|
376
|
-
* @param {WitnessStack} witness_stack - A witness stack.
|
|
377
|
-
* @returns {Uint8Array} A compressed witness stack
|
|
378
|
-
*/
|
|
379
|
-
export function compressWitnessStack(witness_stack) {
|
|
380
|
-
const ret = wasm.compressWitnessStack(witness_stack);
|
|
381
|
-
if (ret[3]) {
|
|
382
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
383
|
-
}
|
|
384
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
385
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
386
|
-
return v1;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
|
|
391
|
-
*
|
|
392
|
-
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
393
|
-
* @returns {WitnessStack} The decompressed witness stack.
|
|
394
|
-
*/
|
|
395
|
-
export function decompressWitnessStack(compressed_witness) {
|
|
396
|
-
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
397
|
-
const len0 = WASM_VECTOR_LEN;
|
|
398
|
-
const ret = wasm.decompressWitnessStack(ptr0, len0);
|
|
399
|
-
if (ret[2]) {
|
|
400
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
401
|
-
}
|
|
402
|
-
return takeFromExternrefTable0(ret[0]);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
407
|
-
*
|
|
408
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
409
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
410
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
411
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
412
|
-
*/
|
|
413
|
-
export function executeCircuit(program, initial_witness, foreign_call_handler) {
|
|
414
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
415
|
-
const len0 = WASM_VECTOR_LEN;
|
|
416
|
-
const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
|
|
417
|
-
return ret;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
422
|
-
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
423
|
-
*
|
|
424
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
425
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
426
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
427
|
-
* @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.
|
|
428
|
-
*/
|
|
429
|
-
export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
|
|
430
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
431
|
-
const len0 = WASM_VECTOR_LEN;
|
|
432
|
-
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
|
|
433
|
-
return ret;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
438
|
-
*
|
|
439
|
-
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
440
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
441
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
442
|
-
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
443
|
-
*/
|
|
444
|
-
export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
445
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
446
|
-
const len0 = WASM_VECTOR_LEN;
|
|
447
|
-
const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
|
|
448
|
-
return ret;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
465
|
/**
|
|
452
466
|
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
453
467
|
*
|
|
@@ -508,30 +522,16 @@ export function getPublicWitness(program, solved_witness) {
|
|
|
508
522
|
return takeFromExternrefTable0(ret[0]);
|
|
509
523
|
}
|
|
510
524
|
|
|
511
|
-
/**
|
|
512
|
-
* Sets the package's logging level.
|
|
513
|
-
*
|
|
514
|
-
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
515
|
-
*/
|
|
516
|
-
export function initLogLevel(filter) {
|
|
517
|
-
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
518
|
-
const len0 = WASM_VECTOR_LEN;
|
|
519
|
-
const ret = wasm.initLogLevel(ptr0, len0);
|
|
520
|
-
if (ret[1]) {
|
|
521
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
525
|
function __wbg_adapter_30(arg0, arg1, arg2) {
|
|
526
|
-
wasm.
|
|
526
|
+
wasm.closure571_externref_shim(arg0, arg1, arg2);
|
|
527
527
|
}
|
|
528
528
|
|
|
529
529
|
function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
|
|
530
|
-
wasm.
|
|
530
|
+
wasm.closure1165_externref_shim(arg0, arg1, arg2, arg3, arg4);
|
|
531
531
|
}
|
|
532
532
|
|
|
533
533
|
function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
|
|
534
|
-
wasm.
|
|
534
|
+
wasm.closure1169_externref_shim(arg0, arg1, arg2, arg3);
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
async function __wbg_load(module, imports) {
|
|
@@ -797,8 +797,8 @@ function __wbg_get_imports() {
|
|
|
797
797
|
const ret = false;
|
|
798
798
|
return ret;
|
|
799
799
|
};
|
|
800
|
-
imports.wbg.
|
|
801
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
800
|
+
imports.wbg.__wbindgen_closure_wrapper1986 = function(arg0, arg1, arg2) {
|
|
801
|
+
const ret = makeMutClosure(arg0, arg1, 572, __wbg_adapter_30);
|
|
802
802
|
return ret;
|
|
803
803
|
};
|
|
804
804
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
package/web/acvm_js_bg.wasm
CHANGED
|
Binary file
|
package/web/acvm_js_bg.wasm.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const
|
|
5
|
-
export const xor: (a: any, b: any) => any;
|
|
6
|
-
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
7
|
-
export const blake2s256: (a: number, b: number) => [number, number];
|
|
8
|
-
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
9
|
-
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
10
|
-
export const buildInfo: () => any;
|
|
4
|
+
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
11
5
|
export const compressWitness: (a: any) => [number, number, number, number];
|
|
12
6
|
export const decompressWitness: (a: number, b: number) => [number, number, number];
|
|
13
7
|
export const compressWitnessStack: (a: any) => [number, number, number, number];
|
|
@@ -15,10 +9,16 @@ export const decompressWitnessStack: (a: number, b: number) => [number, number,
|
|
|
15
9
|
export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
|
|
16
10
|
export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
|
|
17
11
|
export const executeProgram: (a: number, b: number, c: any, d: any) => any;
|
|
12
|
+
export const and: (a: any, b: any) => any;
|
|
13
|
+
export const xor: (a: any, b: any) => any;
|
|
14
|
+
export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
|
|
15
|
+
export const blake2s256: (a: number, b: number) => [number, number];
|
|
16
|
+
export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
17
|
+
export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
18
|
+
export const buildInfo: () => any;
|
|
18
19
|
export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
19
20
|
export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
20
21
|
export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
|
|
21
|
-
export const initLogLevel: (a: number, b: number) => [number, number];
|
|
22
22
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
23
23
|
export const __externref_table_alloc: () => number;
|
|
24
24
|
export const __wbindgen_export_2: WebAssembly.Table;
|
|
@@ -27,7 +27,7 @@ export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
|
27
27
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
28
28
|
export const __wbindgen_export_6: WebAssembly.Table;
|
|
29
29
|
export const __externref_table_dealloc: (a: number) => void;
|
|
30
|
-
export const
|
|
31
|
-
export const
|
|
32
|
-
export const
|
|
30
|
+
export const closure571_externref_shim: (a: number, b: number, c: any) => void;
|
|
31
|
+
export const closure1165_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
|
|
32
|
+
export const closure1169_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
33
33
|
export const __wbindgen_start: () => void;
|