@noir-lang/acvm_js 0.46.0-e4eb5f5.nightly → 0.46.0-e73cdbb.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 +82 -99
- package/nodejs/acvm_js.js +249 -318
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +9 -13
- package/package.json +1 -1
- package/web/acvm_js.d.ts +91 -112
- package/web/acvm_js.js +246 -313
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +9 -13
package/web/acvm_js.js
CHANGED
|
@@ -20,28 +20,6 @@ function takeObject(idx) {
|
|
|
20
20
|
return ret;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
function isLikeNone(x) {
|
|
24
|
-
return x === undefined || x === null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let cachedFloat64Memory0 = null;
|
|
28
|
-
|
|
29
|
-
function getFloat64Memory0() {
|
|
30
|
-
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
|
|
31
|
-
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
|
|
32
|
-
}
|
|
33
|
-
return cachedFloat64Memory0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let cachedInt32Memory0 = null;
|
|
37
|
-
|
|
38
|
-
function getInt32Memory0() {
|
|
39
|
-
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
40
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
41
|
-
}
|
|
42
|
-
return cachedInt32Memory0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
23
|
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
46
24
|
|
|
47
25
|
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
@@ -69,6 +47,28 @@ function addHeapObject(obj) {
|
|
|
69
47
|
return idx;
|
|
70
48
|
}
|
|
71
49
|
|
|
50
|
+
function isLikeNone(x) {
|
|
51
|
+
return x === undefined || x === null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let cachedFloat64Memory0 = null;
|
|
55
|
+
|
|
56
|
+
function getFloat64Memory0() {
|
|
57
|
+
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
|
|
58
|
+
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
|
|
59
|
+
}
|
|
60
|
+
return cachedFloat64Memory0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let cachedInt32Memory0 = null;
|
|
64
|
+
|
|
65
|
+
function getInt32Memory0() {
|
|
66
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
67
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
68
|
+
}
|
|
69
|
+
return cachedInt32Memory0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
72
|
let WASM_VECTOR_LEN = 0;
|
|
73
73
|
|
|
74
74
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
@@ -217,6 +217,199 @@ function __wbg_adapter_22(arg0, arg1, arg2) {
|
|
|
217
217
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h36bac5ff3ea3c380(arg0, arg1, addHeapObject(arg2));
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
221
|
+
ptr = ptr >>> 0;
|
|
222
|
+
return getUint8Memory0().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
|
+
try {
|
|
232
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
233
|
+
wasm.compressWitness(retptr, addHeapObject(witness_map));
|
|
234
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
235
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
236
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
237
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
238
|
+
if (r3) {
|
|
239
|
+
throw takeObject(r2);
|
|
240
|
+
}
|
|
241
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
242
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
243
|
+
return v1;
|
|
244
|
+
} finally {
|
|
245
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
250
|
+
const ptr = malloc(arg.length * 1) >>> 0;
|
|
251
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
252
|
+
WASM_VECTOR_LEN = arg.length;
|
|
253
|
+
return ptr;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
257
|
+
* This should be used to only fetch the witness map for the main function.
|
|
258
|
+
*
|
|
259
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
260
|
+
* @returns {WitnessMap} The decompressed witness map.
|
|
261
|
+
*/
|
|
262
|
+
export function decompressWitness(compressed_witness) {
|
|
263
|
+
try {
|
|
264
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
265
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
266
|
+
const len0 = WASM_VECTOR_LEN;
|
|
267
|
+
wasm.decompressWitness(retptr, ptr0, len0);
|
|
268
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
269
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
270
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
271
|
+
if (r2) {
|
|
272
|
+
throw takeObject(r1);
|
|
273
|
+
}
|
|
274
|
+
return takeObject(r0);
|
|
275
|
+
} finally {
|
|
276
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Compresses a `WitnessStack` into the binary format outputted by Nargo.
|
|
282
|
+
*
|
|
283
|
+
* @param {WitnessStack} witness_stack - A witness stack.
|
|
284
|
+
* @returns {Uint8Array} A compressed witness stack
|
|
285
|
+
*/
|
|
286
|
+
export function compressWitnessStack(witness_stack) {
|
|
287
|
+
try {
|
|
288
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
289
|
+
wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
|
|
290
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
291
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
292
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
293
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
294
|
+
if (r3) {
|
|
295
|
+
throw takeObject(r2);
|
|
296
|
+
}
|
|
297
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
298
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
299
|
+
return v1;
|
|
300
|
+
} finally {
|
|
301
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
|
|
307
|
+
*
|
|
308
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
309
|
+
* @returns {WitnessStack} The decompressed witness stack.
|
|
310
|
+
*/
|
|
311
|
+
export function decompressWitnessStack(compressed_witness) {
|
|
312
|
+
try {
|
|
313
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
314
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
315
|
+
const len0 = WASM_VECTOR_LEN;
|
|
316
|
+
wasm.decompressWitnessStack(retptr, ptr0, len0);
|
|
317
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
318
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
319
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
320
|
+
if (r2) {
|
|
321
|
+
throw takeObject(r1);
|
|
322
|
+
}
|
|
323
|
+
return takeObject(r0);
|
|
324
|
+
} finally {
|
|
325
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
331
|
+
*
|
|
332
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
333
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
334
|
+
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
335
|
+
* @param {Uint8Array} program
|
|
336
|
+
* @param {WitnessMap} witness_map
|
|
337
|
+
* @returns {WitnessMap}
|
|
338
|
+
*/
|
|
339
|
+
export function getReturnWitness(program, witness_map) {
|
|
340
|
+
try {
|
|
341
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
342
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
343
|
+
const len0 = WASM_VECTOR_LEN;
|
|
344
|
+
wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
|
|
345
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
346
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
347
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
348
|
+
if (r2) {
|
|
349
|
+
throw takeObject(r1);
|
|
350
|
+
}
|
|
351
|
+
return takeObject(r0);
|
|
352
|
+
} finally {
|
|
353
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
359
|
+
*
|
|
360
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
361
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
362
|
+
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
363
|
+
* @param {Uint8Array} program
|
|
364
|
+
* @param {WitnessMap} solved_witness
|
|
365
|
+
* @returns {WitnessMap}
|
|
366
|
+
*/
|
|
367
|
+
export function getPublicParametersWitness(program, solved_witness) {
|
|
368
|
+
try {
|
|
369
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
370
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
371
|
+
const len0 = WASM_VECTOR_LEN;
|
|
372
|
+
wasm.getPublicParametersWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
|
|
373
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
374
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
375
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
376
|
+
if (r2) {
|
|
377
|
+
throw takeObject(r1);
|
|
378
|
+
}
|
|
379
|
+
return takeObject(r0);
|
|
380
|
+
} finally {
|
|
381
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
387
|
+
*
|
|
388
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
389
|
+
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
390
|
+
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
391
|
+
* @param {Uint8Array} program
|
|
392
|
+
* @param {WitnessMap} solved_witness
|
|
393
|
+
* @returns {WitnessMap}
|
|
394
|
+
*/
|
|
395
|
+
export function getPublicWitness(program, solved_witness) {
|
|
396
|
+
try {
|
|
397
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
398
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
399
|
+
const len0 = WASM_VECTOR_LEN;
|
|
400
|
+
wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
|
|
401
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
402
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
403
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
404
|
+
if (r2) {
|
|
405
|
+
throw takeObject(r1);
|
|
406
|
+
}
|
|
407
|
+
return takeObject(r0);
|
|
408
|
+
} finally {
|
|
409
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
220
413
|
/**
|
|
221
414
|
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
222
415
|
* @param {string} lhs
|
|
@@ -239,17 +432,6 @@ export function xor(lhs, rhs) {
|
|
|
239
432
|
return takeObject(ret);
|
|
240
433
|
}
|
|
241
434
|
|
|
242
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
243
|
-
const ptr = malloc(arg.length * 1) >>> 0;
|
|
244
|
-
getUint8Memory0().set(arg, ptr / 1);
|
|
245
|
-
WASM_VECTOR_LEN = arg.length;
|
|
246
|
-
return ptr;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
250
|
-
ptr = ptr >>> 0;
|
|
251
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
252
|
-
}
|
|
253
435
|
/**
|
|
254
436
|
* Calculates the SHA256 hash of the input bytes
|
|
255
437
|
* @param {Uint8Array} inputs
|
|
@@ -356,10 +538,11 @@ export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_ke
|
|
|
356
538
|
}
|
|
357
539
|
|
|
358
540
|
/**
|
|
359
|
-
*
|
|
541
|
+
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
542
|
+
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
360
543
|
*/
|
|
361
|
-
export function
|
|
362
|
-
const ret = wasm.
|
|
544
|
+
export function buildInfo() {
|
|
545
|
+
const ret = wasm.buildInfo();
|
|
363
546
|
return takeObject(ret);
|
|
364
547
|
}
|
|
365
548
|
|
|
@@ -378,48 +561,29 @@ export function executeCircuit(program, initial_witness, foreign_call_handler) {
|
|
|
378
561
|
return takeObject(ret);
|
|
379
562
|
}
|
|
380
563
|
|
|
381
|
-
function _assertClass(instance, klass) {
|
|
382
|
-
if (!(instance instanceof klass)) {
|
|
383
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
384
|
-
}
|
|
385
|
-
return instance.ptr;
|
|
386
|
-
}
|
|
387
564
|
/**
|
|
388
565
|
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
389
566
|
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
390
567
|
*
|
|
391
|
-
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
392
568
|
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
393
569
|
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
394
570
|
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
395
571
|
* @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.
|
|
396
572
|
*/
|
|
397
|
-
export function executeCircuitWithReturnWitness(
|
|
398
|
-
_assertClass(_solver, WasmBlackBoxFunctionSolver);
|
|
573
|
+
export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
|
|
399
574
|
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
400
575
|
const len0 = WASM_VECTOR_LEN;
|
|
401
|
-
const ret = wasm.executeCircuitWithReturnWitness(
|
|
576
|
+
const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
402
577
|
return takeObject(ret);
|
|
403
578
|
}
|
|
404
579
|
|
|
405
580
|
/**
|
|
406
581
|
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
407
582
|
*
|
|
408
|
-
* @param {
|
|
409
|
-
* @param {
|
|
410
|
-
* @param {
|
|
411
|
-
* @
|
|
412
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
413
|
-
*/
|
|
414
|
-
export function executeCircuitWithBlackBoxSolver(_solver, program, initial_witness, foreign_call_handler) {
|
|
415
|
-
_assertClass(_solver, WasmBlackBoxFunctionSolver);
|
|
416
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
417
|
-
const len0 = WASM_VECTOR_LEN;
|
|
418
|
-
const ret = wasm.executeCircuitWithBlackBoxSolver(_solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
419
|
-
return takeObject(ret);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
583
|
+
* @param {Uint8Array} program - A serialized representation of an ACIR program
|
|
584
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
|
|
585
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
|
|
586
|
+
* @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
|
|
423
587
|
*/
|
|
424
588
|
export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
425
589
|
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
@@ -428,16 +592,6 @@ export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
|
428
592
|
return takeObject(ret);
|
|
429
593
|
}
|
|
430
594
|
|
|
431
|
-
/**
|
|
432
|
-
*/
|
|
433
|
-
export function executeProgramWithBlackBoxSolver(_solver, program, initial_witness, foreign_call_executor) {
|
|
434
|
-
_assertClass(_solver, WasmBlackBoxFunctionSolver);
|
|
435
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
436
|
-
const len0 = WASM_VECTOR_LEN;
|
|
437
|
-
const ret = wasm.executeProgramWithBlackBoxSolver(_solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor));
|
|
438
|
-
return takeObject(ret);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
595
|
/**
|
|
442
596
|
* Sets the package's logging level.
|
|
443
597
|
*
|
|
@@ -459,199 +613,7 @@ export function initLogLevel(filter) {
|
|
|
459
613
|
}
|
|
460
614
|
}
|
|
461
615
|
|
|
462
|
-
|
|
463
|
-
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
464
|
-
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
465
|
-
*/
|
|
466
|
-
export function buildInfo() {
|
|
467
|
-
const ret = wasm.buildInfo();
|
|
468
|
-
return takeObject(ret);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
473
|
-
*
|
|
474
|
-
* @param {WitnessMap} witness_map - A witness map.
|
|
475
|
-
* @returns {Uint8Array} A compressed witness map
|
|
476
|
-
*/
|
|
477
|
-
export function compressWitness(witness_map) {
|
|
478
|
-
try {
|
|
479
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
480
|
-
wasm.compressWitness(retptr, addHeapObject(witness_map));
|
|
481
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
482
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
483
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
484
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
485
|
-
if (r3) {
|
|
486
|
-
throw takeObject(r2);
|
|
487
|
-
}
|
|
488
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
489
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
490
|
-
return v1;
|
|
491
|
-
} finally {
|
|
492
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
498
|
-
* This should be used to only fetch the witness map for the main function.
|
|
499
|
-
*
|
|
500
|
-
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
501
|
-
* @returns {WitnessMap} The decompressed witness map.
|
|
502
|
-
*/
|
|
503
|
-
export function decompressWitness(compressed_witness) {
|
|
504
|
-
try {
|
|
505
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
506
|
-
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
507
|
-
const len0 = WASM_VECTOR_LEN;
|
|
508
|
-
wasm.decompressWitness(retptr, ptr0, len0);
|
|
509
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
510
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
511
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
512
|
-
if (r2) {
|
|
513
|
-
throw takeObject(r1);
|
|
514
|
-
}
|
|
515
|
-
return takeObject(r0);
|
|
516
|
-
} finally {
|
|
517
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Compresses a `WitnessStack` into the binary format outputted by Nargo.
|
|
523
|
-
*
|
|
524
|
-
* @param {WitnessStack} witness_stack - A witness stack.
|
|
525
|
-
* @returns {Uint8Array} A compressed witness stack
|
|
526
|
-
*/
|
|
527
|
-
export function compressWitnessStack(witness_stack) {
|
|
528
|
-
try {
|
|
529
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
530
|
-
wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
|
|
531
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
532
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
533
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
534
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
535
|
-
if (r3) {
|
|
536
|
-
throw takeObject(r2);
|
|
537
|
-
}
|
|
538
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
539
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
540
|
-
return v1;
|
|
541
|
-
} finally {
|
|
542
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
|
|
548
|
-
*
|
|
549
|
-
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
550
|
-
* @returns {WitnessStack} The decompressed witness stack.
|
|
551
|
-
*/
|
|
552
|
-
export function decompressWitnessStack(compressed_witness) {
|
|
553
|
-
try {
|
|
554
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
555
|
-
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
556
|
-
const len0 = WASM_VECTOR_LEN;
|
|
557
|
-
wasm.decompressWitnessStack(retptr, ptr0, len0);
|
|
558
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
559
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
560
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
561
|
-
if (r2) {
|
|
562
|
-
throw takeObject(r1);
|
|
563
|
-
}
|
|
564
|
-
return takeObject(r0);
|
|
565
|
-
} finally {
|
|
566
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
|
|
572
|
-
*
|
|
573
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
574
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
575
|
-
* @returns {WitnessMap} A witness map containing the circuit's return values.
|
|
576
|
-
* @param {Uint8Array} program
|
|
577
|
-
* @param {WitnessMap} witness_map
|
|
578
|
-
* @returns {WitnessMap}
|
|
579
|
-
*/
|
|
580
|
-
export function getReturnWitness(program, witness_map) {
|
|
581
|
-
try {
|
|
582
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
583
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
584
|
-
const len0 = WASM_VECTOR_LEN;
|
|
585
|
-
wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
|
|
586
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
587
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
588
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
589
|
-
if (r2) {
|
|
590
|
-
throw takeObject(r1);
|
|
591
|
-
}
|
|
592
|
-
return takeObject(r0);
|
|
593
|
-
} finally {
|
|
594
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
|
|
600
|
-
*
|
|
601
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
602
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
603
|
-
* @returns {WitnessMap} A witness map containing the circuit's public parameters.
|
|
604
|
-
* @param {Uint8Array} program
|
|
605
|
-
* @param {WitnessMap} solved_witness
|
|
606
|
-
* @returns {WitnessMap}
|
|
607
|
-
*/
|
|
608
|
-
export function getPublicParametersWitness(program, solved_witness) {
|
|
609
|
-
try {
|
|
610
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
611
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
612
|
-
const len0 = WASM_VECTOR_LEN;
|
|
613
|
-
wasm.getPublicParametersWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
|
|
614
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
615
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
616
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
617
|
-
if (r2) {
|
|
618
|
-
throw takeObject(r1);
|
|
619
|
-
}
|
|
620
|
-
return takeObject(r0);
|
|
621
|
-
} finally {
|
|
622
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
|
|
628
|
-
*
|
|
629
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
630
|
-
* @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
|
|
631
|
-
* @returns {WitnessMap} A witness map containing the circuit's public inputs.
|
|
632
|
-
* @param {Uint8Array} program
|
|
633
|
-
* @param {WitnessMap} solved_witness
|
|
634
|
-
* @returns {WitnessMap}
|
|
635
|
-
*/
|
|
636
|
-
export function getPublicWitness(program, solved_witness) {
|
|
637
|
-
try {
|
|
638
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
639
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
640
|
-
const len0 = WASM_VECTOR_LEN;
|
|
641
|
-
wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
|
|
642
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
643
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
644
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
645
|
-
if (r2) {
|
|
646
|
-
throw takeObject(r1);
|
|
647
|
-
}
|
|
648
|
-
return takeObject(r0);
|
|
649
|
-
} finally {
|
|
650
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
function __wbg_adapter_81(arg0, arg1, arg2, arg3, arg4) {
|
|
616
|
+
function __wbg_adapter_76(arg0, arg1, arg2, arg3, arg4) {
|
|
655
617
|
wasm.wasm_bindgen__convert__closures__invoke3_mut__h629417323d5efbaa(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
|
|
656
618
|
}
|
|
657
619
|
|
|
@@ -662,35 +624,10 @@ function handleError(f, args) {
|
|
|
662
624
|
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
663
625
|
}
|
|
664
626
|
}
|
|
665
|
-
function
|
|
627
|
+
function __wbg_adapter_93(arg0, arg1, arg2, arg3) {
|
|
666
628
|
wasm.wasm_bindgen__convert__closures__invoke2_mut__h4efdd1050cfb3ea7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
667
629
|
}
|
|
668
630
|
|
|
669
|
-
/**
|
|
670
|
-
*/
|
|
671
|
-
export class WasmBlackBoxFunctionSolver {
|
|
672
|
-
|
|
673
|
-
static __wrap(ptr) {
|
|
674
|
-
ptr = ptr >>> 0;
|
|
675
|
-
const obj = Object.create(WasmBlackBoxFunctionSolver.prototype);
|
|
676
|
-
obj.__wbg_ptr = ptr;
|
|
677
|
-
|
|
678
|
-
return obj;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
__destroy_into_raw() {
|
|
682
|
-
const ptr = this.__wbg_ptr;
|
|
683
|
-
this.__wbg_ptr = 0;
|
|
684
|
-
|
|
685
|
-
return ptr;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
free() {
|
|
689
|
-
const ptr = this.__destroy_into_raw();
|
|
690
|
-
wasm.__wbg_wasmblackboxfunctionsolver_free(ptr);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
|
|
694
631
|
async function __wbg_load(module, imports) {
|
|
695
632
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
696
633
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
@@ -728,16 +665,6 @@ function __wbg_get_imports() {
|
|
|
728
665
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
729
666
|
takeObject(arg0);
|
|
730
667
|
};
|
|
731
|
-
imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
|
|
732
|
-
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
|
|
733
|
-
return addHeapObject(ret);
|
|
734
|
-
};
|
|
735
|
-
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
736
|
-
const obj = getObject(arg1);
|
|
737
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
738
|
-
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
|
739
|
-
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
740
|
-
};
|
|
741
668
|
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
|
742
669
|
const obj = takeObject(arg0).original;
|
|
743
670
|
if (obj.cnt-- == 1) {
|
|
@@ -747,14 +674,6 @@ function __wbg_get_imports() {
|
|
|
747
674
|
const ret = false;
|
|
748
675
|
return ret;
|
|
749
676
|
};
|
|
750
|
-
imports.wbg.__wbindgen_is_array = function(arg0) {
|
|
751
|
-
const ret = Array.isArray(getObject(arg0));
|
|
752
|
-
return ret;
|
|
753
|
-
};
|
|
754
|
-
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
755
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
756
|
-
return ret;
|
|
757
|
-
};
|
|
758
677
|
imports.wbg.__wbg_constructor_81b34c49dcbdd2af = function(arg0) {
|
|
759
678
|
const ret = new Error(takeObject(arg0));
|
|
760
679
|
return addHeapObject(ret);
|
|
@@ -763,6 +682,16 @@ function __wbg_get_imports() {
|
|
|
763
682
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
764
683
|
return addHeapObject(ret);
|
|
765
684
|
};
|
|
685
|
+
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
686
|
+
const obj = getObject(arg1);
|
|
687
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
688
|
+
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
|
689
|
+
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
690
|
+
};
|
|
691
|
+
imports.wbg.__wbindgen_is_array = function(arg0) {
|
|
692
|
+
const ret = Array.isArray(getObject(arg0));
|
|
693
|
+
return ret;
|
|
694
|
+
};
|
|
766
695
|
imports.wbg.__wbg_new_6f6c75f9324b78e8 = function() {
|
|
767
696
|
const ret = new Map();
|
|
768
697
|
return addHeapObject(ret);
|
|
@@ -783,6 +712,10 @@ function __wbg_get_imports() {
|
|
|
783
712
|
const ret = new Array();
|
|
784
713
|
return addHeapObject(ret);
|
|
785
714
|
};
|
|
715
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
716
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
717
|
+
return ret;
|
|
718
|
+
};
|
|
786
719
|
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
787
720
|
const ret = new Error();
|
|
788
721
|
return addHeapObject(ret);
|
|
@@ -856,7 +789,7 @@ function __wbg_get_imports() {
|
|
|
856
789
|
const a = state0.a;
|
|
857
790
|
state0.a = 0;
|
|
858
791
|
try {
|
|
859
|
-
return
|
|
792
|
+
return __wbg_adapter_76(a, state0.b, arg0, arg1, arg2);
|
|
860
793
|
} finally {
|
|
861
794
|
state0.a = a;
|
|
862
795
|
}
|
|
@@ -896,7 +829,7 @@ function __wbg_get_imports() {
|
|
|
896
829
|
const a = state0.a;
|
|
897
830
|
state0.a = 0;
|
|
898
831
|
try {
|
|
899
|
-
return
|
|
832
|
+
return __wbg_adapter_93(a, state0.b, arg0, arg1);
|
|
900
833
|
} finally {
|
|
901
834
|
state0.a = a;
|
|
902
835
|
}
|
|
@@ -925,7 +858,7 @@ function __wbg_get_imports() {
|
|
|
925
858
|
const a = state0.a;
|
|
926
859
|
state0.a = 0;
|
|
927
860
|
try {
|
|
928
|
-
return
|
|
861
|
+
return __wbg_adapter_93(a, state0.b, arg0, arg1);
|
|
929
862
|
} finally {
|
|
930
863
|
state0.a = a;
|
|
931
864
|
}
|
|
@@ -966,8 +899,8 @@ function __wbg_get_imports() {
|
|
|
966
899
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
967
900
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
968
901
|
};
|
|
969
|
-
imports.wbg.
|
|
970
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
902
|
+
imports.wbg.__wbindgen_closure_wrapper742 = function(arg0, arg1, arg2) {
|
|
903
|
+
const ret = makeMutClosure(arg0, arg1, 239, __wbg_adapter_22);
|
|
971
904
|
return addHeapObject(ret);
|
|
972
905
|
};
|
|
973
906
|
|
package/web/acvm_js_bg.wasm
CHANGED
|
Binary file
|