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