@noir-lang/acvm_js 0.43.0 → 0.44.0
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 +124 -103
- package/nodejs/acvm_js.js +271 -252
- package/nodejs/acvm_js_bg.wasm +0 -0
- package/nodejs/acvm_js_bg.wasm.d.ts +16 -15
- package/package.json +1 -1
- package/web/acvm_js.d.ts +140 -118
- package/web/acvm_js.js +265 -246
- package/web/acvm_js_bg.wasm +0 -0
- package/web/acvm_js_bg.wasm.d.ts +16 -15
package/nodejs/acvm_js.js
CHANGED
|
@@ -226,36 +226,29 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
|
|
226
226
|
return real;
|
|
227
227
|
}
|
|
228
228
|
function __wbg_adapter_52(arg0, arg1, arg2) {
|
|
229
|
-
wasm.
|
|
229
|
+
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hc5258430255de068(arg0, arg1, addHeapObject(arg2));
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
233
|
-
ptr = ptr >>> 0;
|
|
234
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
235
|
-
}
|
|
236
232
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* @param {
|
|
240
|
-
* @returns {
|
|
233
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
234
|
+
* @param {string} lhs
|
|
235
|
+
* @param {string} rhs
|
|
236
|
+
* @returns {string}
|
|
241
237
|
*/
|
|
242
|
-
module.exports.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
} finally {
|
|
257
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
258
|
-
}
|
|
238
|
+
module.exports.and = function(lhs, rhs) {
|
|
239
|
+
const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
|
|
240
|
+
return takeObject(ret);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
245
|
+
* @param {string} lhs
|
|
246
|
+
* @param {string} rhs
|
|
247
|
+
* @returns {string}
|
|
248
|
+
*/
|
|
249
|
+
module.exports.xor = function(lhs, rhs) {
|
|
250
|
+
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
|
|
251
|
+
return takeObject(ret);
|
|
259
252
|
};
|
|
260
253
|
|
|
261
254
|
function passArray8ToWasm0(arg, malloc) {
|
|
@@ -264,142 +257,122 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
264
257
|
WASM_VECTOR_LEN = arg.length;
|
|
265
258
|
return ptr;
|
|
266
259
|
}
|
|
260
|
+
|
|
261
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
262
|
+
ptr = ptr >>> 0;
|
|
263
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
264
|
+
}
|
|
267
265
|
/**
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
272
|
-
* @returns {WitnessMap} The decompressed witness map.
|
|
266
|
+
* Calculates the SHA256 hash of the input bytes
|
|
267
|
+
* @param {Uint8Array} inputs
|
|
268
|
+
* @returns {Uint8Array}
|
|
273
269
|
*/
|
|
274
|
-
module.exports.
|
|
270
|
+
module.exports.sha256 = function(inputs) {
|
|
275
271
|
try {
|
|
276
272
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
277
|
-
const ptr0 = passArray8ToWasm0(
|
|
273
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
278
274
|
const len0 = WASM_VECTOR_LEN;
|
|
279
|
-
wasm.
|
|
275
|
+
wasm.sha256(retptr, ptr0, len0);
|
|
280
276
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
281
277
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
282
|
-
var
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
return takeObject(r0);
|
|
278
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
279
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
280
|
+
return v2;
|
|
287
281
|
} finally {
|
|
288
282
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
289
283
|
}
|
|
290
284
|
};
|
|
291
285
|
|
|
292
286
|
/**
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* @
|
|
296
|
-
* @returns {Uint8Array} A compressed witness stack
|
|
287
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
288
|
+
* @param {Uint8Array} inputs
|
|
289
|
+
* @returns {Uint8Array}
|
|
297
290
|
*/
|
|
298
|
-
module.exports.
|
|
291
|
+
module.exports.blake2s256 = function(inputs) {
|
|
299
292
|
try {
|
|
300
293
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
301
|
-
|
|
294
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
295
|
+
const len0 = WASM_VECTOR_LEN;
|
|
296
|
+
wasm.blake2s256(retptr, ptr0, len0);
|
|
302
297
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
303
298
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
304
|
-
var
|
|
305
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
306
|
-
if (r3) {
|
|
307
|
-
throw takeObject(r2);
|
|
308
|
-
}
|
|
309
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
299
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
310
300
|
wasm.__wbindgen_free(r0, r1 * 1);
|
|
311
|
-
return
|
|
301
|
+
return v2;
|
|
312
302
|
} finally {
|
|
313
303
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
314
304
|
}
|
|
315
305
|
};
|
|
316
306
|
|
|
317
307
|
/**
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
* @
|
|
321
|
-
* @returns {WitnessStack} The decompressed witness stack.
|
|
308
|
+
* Calculates the Keccak256 hash of the input bytes
|
|
309
|
+
* @param {Uint8Array} inputs
|
|
310
|
+
* @returns {Uint8Array}
|
|
322
311
|
*/
|
|
323
|
-
module.exports.
|
|
312
|
+
module.exports.keccak256 = function(inputs) {
|
|
324
313
|
try {
|
|
325
314
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
326
|
-
const ptr0 = passArray8ToWasm0(
|
|
315
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
327
316
|
const len0 = WASM_VECTOR_LEN;
|
|
328
|
-
wasm.
|
|
317
|
+
wasm.keccak256(retptr, ptr0, len0);
|
|
329
318
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
330
319
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
331
|
-
var
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
return takeObject(r0);
|
|
320
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
321
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
322
|
+
return v2;
|
|
336
323
|
} finally {
|
|
337
324
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
338
325
|
}
|
|
339
326
|
};
|
|
340
327
|
|
|
341
328
|
/**
|
|
342
|
-
*
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
351
|
-
*
|
|
352
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
353
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
354
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
355
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
356
|
-
*/
|
|
357
|
-
module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
|
|
358
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
359
|
-
const len0 = WASM_VECTOR_LEN;
|
|
360
|
-
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
361
|
-
return takeObject(ret);
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
function _assertClass(instance, klass) {
|
|
365
|
-
if (!(instance instanceof klass)) {
|
|
366
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
367
|
-
}
|
|
368
|
-
return instance.ptr;
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
372
|
-
*
|
|
373
|
-
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
374
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
375
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
376
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
377
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
329
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
330
|
+
* @param {Uint8Array} hashed_msg
|
|
331
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
332
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
333
|
+
* @param {Uint8Array} signature
|
|
334
|
+
* @returns {boolean}
|
|
378
335
|
*/
|
|
379
|
-
module.exports.
|
|
380
|
-
|
|
381
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
336
|
+
module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
337
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
382
338
|
const len0 = WASM_VECTOR_LEN;
|
|
383
|
-
const
|
|
384
|
-
|
|
339
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
340
|
+
const len1 = WASM_VECTOR_LEN;
|
|
341
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
342
|
+
const len2 = WASM_VECTOR_LEN;
|
|
343
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
344
|
+
const len3 = WASM_VECTOR_LEN;
|
|
345
|
+
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
346
|
+
return ret !== 0;
|
|
385
347
|
};
|
|
386
348
|
|
|
387
349
|
/**
|
|
350
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
351
|
+
* @param {Uint8Array} hashed_msg
|
|
352
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
353
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
354
|
+
* @param {Uint8Array} signature
|
|
355
|
+
* @returns {boolean}
|
|
388
356
|
*/
|
|
389
|
-
module.exports.
|
|
390
|
-
const ptr0 = passArray8ToWasm0(
|
|
357
|
+
module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
358
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
391
359
|
const len0 = WASM_VECTOR_LEN;
|
|
392
|
-
const
|
|
393
|
-
|
|
360
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
361
|
+
const len1 = WASM_VECTOR_LEN;
|
|
362
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
363
|
+
const len2 = WASM_VECTOR_LEN;
|
|
364
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
365
|
+
const len3 = WASM_VECTOR_LEN;
|
|
366
|
+
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
367
|
+
return ret !== 0;
|
|
394
368
|
};
|
|
395
369
|
|
|
396
370
|
/**
|
|
371
|
+
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
372
|
+
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
397
373
|
*/
|
|
398
|
-
module.exports.
|
|
399
|
-
|
|
400
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
401
|
-
const len0 = WASM_VECTOR_LEN;
|
|
402
|
-
const ret = wasm.executeProgramWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor));
|
|
374
|
+
module.exports.buildInfo = function() {
|
|
375
|
+
const ret = wasm.buildInfo();
|
|
403
376
|
return takeObject(ret);
|
|
404
377
|
};
|
|
405
378
|
|
|
@@ -488,160 +461,206 @@ module.exports.getPublicWitness = function(program, solved_witness) {
|
|
|
488
461
|
};
|
|
489
462
|
|
|
490
463
|
/**
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
* @param {
|
|
494
|
-
* @returns {string}
|
|
464
|
+
* Sets the package's logging level.
|
|
465
|
+
*
|
|
466
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
495
467
|
*/
|
|
496
|
-
module.exports.
|
|
497
|
-
|
|
498
|
-
|
|
468
|
+
module.exports.initLogLevel = function(filter) {
|
|
469
|
+
try {
|
|
470
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
471
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
472
|
+
const len0 = WASM_VECTOR_LEN;
|
|
473
|
+
wasm.initLogLevel(retptr, ptr0, len0);
|
|
474
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
475
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
476
|
+
if (r1) {
|
|
477
|
+
throw takeObject(r0);
|
|
478
|
+
}
|
|
479
|
+
} finally {
|
|
480
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
481
|
+
}
|
|
499
482
|
};
|
|
500
483
|
|
|
501
484
|
/**
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
* @param {
|
|
505
|
-
* @returns {
|
|
485
|
+
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
486
|
+
*
|
|
487
|
+
* @param {WitnessMap} witness_map - A witness map.
|
|
488
|
+
* @returns {Uint8Array} A compressed witness map
|
|
506
489
|
*/
|
|
507
|
-
module.exports.
|
|
508
|
-
|
|
509
|
-
|
|
490
|
+
module.exports.compressWitness = function(witness_map) {
|
|
491
|
+
try {
|
|
492
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
493
|
+
wasm.compressWitness(retptr, addHeapObject(witness_map));
|
|
494
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
495
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
496
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
497
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
498
|
+
if (r3) {
|
|
499
|
+
throw takeObject(r2);
|
|
500
|
+
}
|
|
501
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
502
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
503
|
+
return v1;
|
|
504
|
+
} finally {
|
|
505
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
506
|
+
}
|
|
510
507
|
};
|
|
511
508
|
|
|
512
509
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
510
|
+
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
511
|
+
* This should be used to only fetch the witness map for the main function.
|
|
512
|
+
*
|
|
513
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
514
|
+
* @returns {WitnessMap} The decompressed witness map.
|
|
516
515
|
*/
|
|
517
|
-
module.exports.
|
|
516
|
+
module.exports.decompressWitness = function(compressed_witness) {
|
|
518
517
|
try {
|
|
519
518
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
520
|
-
const ptr0 = passArray8ToWasm0(
|
|
519
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
521
520
|
const len0 = WASM_VECTOR_LEN;
|
|
522
|
-
wasm.
|
|
521
|
+
wasm.decompressWitness(retptr, ptr0, len0);
|
|
523
522
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
524
523
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
525
|
-
var
|
|
526
|
-
|
|
527
|
-
|
|
524
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
525
|
+
if (r2) {
|
|
526
|
+
throw takeObject(r1);
|
|
527
|
+
}
|
|
528
|
+
return takeObject(r0);
|
|
528
529
|
} finally {
|
|
529
530
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
530
531
|
}
|
|
531
532
|
};
|
|
532
533
|
|
|
533
534
|
/**
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
* @
|
|
535
|
+
* Compresses a `WitnessStack` into the binary format outputted by Nargo.
|
|
536
|
+
*
|
|
537
|
+
* @param {WitnessStack} witness_stack - A witness stack.
|
|
538
|
+
* @returns {Uint8Array} A compressed witness stack
|
|
537
539
|
*/
|
|
538
|
-
module.exports.
|
|
540
|
+
module.exports.compressWitnessStack = function(witness_stack) {
|
|
539
541
|
try {
|
|
540
542
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
541
|
-
|
|
542
|
-
const len0 = WASM_VECTOR_LEN;
|
|
543
|
-
wasm.blake2s256(retptr, ptr0, len0);
|
|
543
|
+
wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
|
|
544
544
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
545
545
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
546
|
-
var
|
|
546
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
547
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
548
|
+
if (r3) {
|
|
549
|
+
throw takeObject(r2);
|
|
550
|
+
}
|
|
551
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
547
552
|
wasm.__wbindgen_free(r0, r1 * 1);
|
|
548
|
-
return
|
|
553
|
+
return v1;
|
|
549
554
|
} finally {
|
|
550
555
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
551
556
|
}
|
|
552
557
|
};
|
|
553
558
|
|
|
554
559
|
/**
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
* @
|
|
560
|
+
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
|
|
561
|
+
*
|
|
562
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
563
|
+
* @returns {WitnessStack} The decompressed witness stack.
|
|
558
564
|
*/
|
|
559
|
-
module.exports.
|
|
565
|
+
module.exports.decompressWitnessStack = function(compressed_witness) {
|
|
560
566
|
try {
|
|
561
567
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
562
|
-
const ptr0 = passArray8ToWasm0(
|
|
568
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
563
569
|
const len0 = WASM_VECTOR_LEN;
|
|
564
|
-
wasm.
|
|
570
|
+
wasm.decompressWitnessStack(retptr, ptr0, len0);
|
|
565
571
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
566
572
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
567
|
-
var
|
|
568
|
-
|
|
569
|
-
|
|
573
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
574
|
+
if (r2) {
|
|
575
|
+
throw takeObject(r1);
|
|
576
|
+
}
|
|
577
|
+
return takeObject(r0);
|
|
570
578
|
} finally {
|
|
571
579
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
572
580
|
}
|
|
573
581
|
};
|
|
574
582
|
|
|
575
583
|
/**
|
|
576
|
-
*
|
|
577
|
-
* @param {Uint8Array} hashed_msg
|
|
578
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
579
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
580
|
-
* @param {Uint8Array} signature
|
|
581
|
-
* @returns {boolean}
|
|
584
|
+
* @returns {Promise<WasmBlackBoxFunctionSolver>}
|
|
582
585
|
*/
|
|
583
|
-
module.exports.
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
587
|
-
const len1 = WASM_VECTOR_LEN;
|
|
588
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
589
|
-
const len2 = WASM_VECTOR_LEN;
|
|
590
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
591
|
-
const len3 = WASM_VECTOR_LEN;
|
|
592
|
-
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
593
|
-
return ret !== 0;
|
|
586
|
+
module.exports.createBlackBoxSolver = function() {
|
|
587
|
+
const ret = wasm.createBlackBoxSolver();
|
|
588
|
+
return takeObject(ret);
|
|
594
589
|
};
|
|
595
590
|
|
|
596
591
|
/**
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
* @param {Uint8Array}
|
|
600
|
-
* @param {
|
|
601
|
-
* @param {
|
|
602
|
-
* @returns {
|
|
592
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
593
|
+
*
|
|
594
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
595
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
596
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
597
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
603
598
|
*/
|
|
604
|
-
module.exports.
|
|
605
|
-
const ptr0 = passArray8ToWasm0(
|
|
599
|
+
module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
|
|
600
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
606
601
|
const len0 = WASM_VECTOR_LEN;
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
610
|
-
const len2 = WASM_VECTOR_LEN;
|
|
611
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
612
|
-
const len3 = WASM_VECTOR_LEN;
|
|
613
|
-
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
614
|
-
return ret !== 0;
|
|
602
|
+
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
603
|
+
return takeObject(ret);
|
|
615
604
|
};
|
|
616
605
|
|
|
606
|
+
function _assertClass(instance, klass) {
|
|
607
|
+
if (!(instance instanceof klass)) {
|
|
608
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
609
|
+
}
|
|
610
|
+
return instance.ptr;
|
|
611
|
+
}
|
|
617
612
|
/**
|
|
618
|
-
*
|
|
619
|
-
*
|
|
613
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
614
|
+
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
615
|
+
*
|
|
616
|
+
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
617
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
618
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
619
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
620
|
+
* @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.
|
|
620
621
|
*/
|
|
621
|
-
module.exports.
|
|
622
|
-
|
|
622
|
+
module.exports.executeCircuitWithReturnWitness = function(solver, program, initial_witness, foreign_call_handler) {
|
|
623
|
+
_assertClass(solver, WasmBlackBoxFunctionSolver);
|
|
624
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
625
|
+
const len0 = WASM_VECTOR_LEN;
|
|
626
|
+
const ret = wasm.executeCircuitWithReturnWitness(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
623
627
|
return takeObject(ret);
|
|
624
628
|
};
|
|
625
629
|
|
|
626
630
|
/**
|
|
627
|
-
*
|
|
631
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
628
632
|
*
|
|
629
|
-
* @param {
|
|
633
|
+
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
634
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
635
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
636
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
637
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
630
638
|
*/
|
|
631
|
-
module.exports.
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
639
|
+
module.exports.executeCircuitWithBlackBoxSolver = function(solver, program, initial_witness, foreign_call_handler) {
|
|
640
|
+
_assertClass(solver, WasmBlackBoxFunctionSolver);
|
|
641
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
642
|
+
const len0 = WASM_VECTOR_LEN;
|
|
643
|
+
const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
644
|
+
return takeObject(ret);
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
*/
|
|
649
|
+
module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
|
|
650
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
651
|
+
const len0 = WASM_VECTOR_LEN;
|
|
652
|
+
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
653
|
+
return takeObject(ret);
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
*/
|
|
658
|
+
module.exports.executeProgramWithBlackBoxSolver = function(solver, program, initial_witness, foreign_call_executor) {
|
|
659
|
+
_assertClass(solver, WasmBlackBoxFunctionSolver);
|
|
660
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
661
|
+
const len0 = WASM_VECTOR_LEN;
|
|
662
|
+
const ret = wasm.executeProgramWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor));
|
|
663
|
+
return takeObject(ret);
|
|
645
664
|
};
|
|
646
665
|
|
|
647
666
|
function handleError(f, args) {
|
|
@@ -651,12 +670,12 @@ function handleError(f, args) {
|
|
|
651
670
|
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
652
671
|
}
|
|
653
672
|
}
|
|
654
|
-
function
|
|
655
|
-
wasm.
|
|
673
|
+
function __wbg_adapter_134(arg0, arg1, arg2, arg3, arg4) {
|
|
674
|
+
wasm.wasm_bindgen__convert__closures__invoke3_mut__h1e7d8ac96c74bd35(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
|
|
656
675
|
}
|
|
657
676
|
|
|
658
|
-
function
|
|
659
|
-
wasm.
|
|
677
|
+
function __wbg_adapter_171(arg0, arg1, arg2, arg3) {
|
|
678
|
+
wasm.wasm_bindgen__convert__closures__invoke2_mut__h188e918906ff9a40(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
660
679
|
}
|
|
661
680
|
|
|
662
681
|
/**
|
|
@@ -714,16 +733,6 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
714
733
|
takeObject(arg0);
|
|
715
734
|
};
|
|
716
735
|
|
|
717
|
-
module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
|
|
718
|
-
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
|
|
719
|
-
return addHeapObject(ret);
|
|
720
|
-
};
|
|
721
|
-
|
|
722
|
-
module.exports.__wbindgen_is_array = function(arg0) {
|
|
723
|
-
const ret = Array.isArray(getObject(arg0));
|
|
724
|
-
return ret;
|
|
725
|
-
};
|
|
726
|
-
|
|
727
736
|
module.exports.__wbindgen_number_get = function(arg0, arg1) {
|
|
728
737
|
const obj = getObject(arg1);
|
|
729
738
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
@@ -741,36 +750,22 @@ module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
|
741
750
|
return ret;
|
|
742
751
|
};
|
|
743
752
|
|
|
744
|
-
module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
745
|
-
const ret = getObject(arg0);
|
|
746
|
-
return addHeapObject(ret);
|
|
747
|
-
};
|
|
748
|
-
|
|
749
753
|
module.exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
750
754
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
751
755
|
return addHeapObject(ret);
|
|
752
756
|
};
|
|
753
757
|
|
|
754
|
-
module.exports.
|
|
755
|
-
const ret =
|
|
756
|
-
return ret;
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
760
|
-
const obj = getObject(arg1);
|
|
761
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
762
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
763
|
-
var len1 = WASM_VECTOR_LEN;
|
|
764
|
-
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
765
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
758
|
+
module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
759
|
+
const ret = getObject(arg0);
|
|
760
|
+
return addHeapObject(ret);
|
|
766
761
|
};
|
|
767
762
|
|
|
768
|
-
module.exports.
|
|
763
|
+
module.exports.__wbg_constructor_3d9f06adce00cc63 = function(arg0) {
|
|
769
764
|
const ret = new Error(takeObject(arg0));
|
|
770
765
|
return addHeapObject(ret);
|
|
771
766
|
};
|
|
772
767
|
|
|
773
|
-
module.exports.
|
|
768
|
+
module.exports.__wbg_new_e572a122c033be0c = function() {
|
|
774
769
|
const ret = new Map();
|
|
775
770
|
return addHeapObject(ret);
|
|
776
771
|
};
|
|
@@ -780,8 +775,17 @@ module.exports.__wbindgen_number_new = function(arg0) {
|
|
|
780
775
|
return addHeapObject(ret);
|
|
781
776
|
};
|
|
782
777
|
|
|
783
|
-
module.exports.
|
|
784
|
-
const
|
|
778
|
+
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
779
|
+
const obj = getObject(arg1);
|
|
780
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
781
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
782
|
+
var len1 = WASM_VECTOR_LEN;
|
|
783
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
784
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
|
|
788
|
+
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
|
|
785
789
|
return addHeapObject(ret);
|
|
786
790
|
};
|
|
787
791
|
|
|
@@ -795,6 +799,21 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
795
799
|
return ret;
|
|
796
800
|
};
|
|
797
801
|
|
|
802
|
+
module.exports.__wbg_new_ecd8c47cc271426e = function() {
|
|
803
|
+
const ret = new Array();
|
|
804
|
+
return addHeapObject(ret);
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
module.exports.__wbindgen_is_array = function(arg0) {
|
|
808
|
+
const ret = Array.isArray(getObject(arg0));
|
|
809
|
+
return ret;
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
module.exports.__wbindgen_is_string = function(arg0) {
|
|
813
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
814
|
+
return ret;
|
|
815
|
+
};
|
|
816
|
+
|
|
798
817
|
module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
799
818
|
const ret = new Error();
|
|
800
819
|
return addHeapObject(ret);
|
|
@@ -939,14 +958,14 @@ module.exports.__wbg_require_8f08ceecec0f4fee = function() { return handleError(
|
|
|
939
958
|
return addHeapObject(ret);
|
|
940
959
|
}, arguments) };
|
|
941
960
|
|
|
942
|
-
module.exports.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) {
|
|
943
|
-
getObject(arg0).getRandomValues(getObject(arg1));
|
|
944
|
-
}, arguments) };
|
|
945
|
-
|
|
946
961
|
module.exports.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) {
|
|
947
962
|
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
948
963
|
}, arguments) };
|
|
949
964
|
|
|
965
|
+
module.exports.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) {
|
|
966
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
967
|
+
}, arguments) };
|
|
968
|
+
|
|
950
969
|
module.exports.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) {
|
|
951
970
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
952
971
|
return addHeapObject(ret);
|
|
@@ -1033,7 +1052,7 @@ module.exports.__wbg_forEach_5ae261259d7517c8 = function(arg0, arg1, arg2) {
|
|
|
1033
1052
|
const a = state0.a;
|
|
1034
1053
|
state0.a = 0;
|
|
1035
1054
|
try {
|
|
1036
|
-
return
|
|
1055
|
+
return __wbg_adapter_134(a, state0.b, arg0, arg1, arg2);
|
|
1037
1056
|
} finally {
|
|
1038
1057
|
state0.a = a;
|
|
1039
1058
|
}
|
|
@@ -1130,7 +1149,7 @@ module.exports.__wbg_forEach_942772130a8d06a6 = function(arg0, arg1, arg2) {
|
|
|
1130
1149
|
const a = state0.a;
|
|
1131
1150
|
state0.a = 0;
|
|
1132
1151
|
try {
|
|
1133
|
-
return
|
|
1152
|
+
return __wbg_adapter_171(a, state0.b, arg0, arg1);
|
|
1134
1153
|
} finally {
|
|
1135
1154
|
state0.a = a;
|
|
1136
1155
|
}
|
|
@@ -1184,7 +1203,7 @@ module.exports.__wbg_new_2b55e405e4af4986 = function(arg0, arg1) {
|
|
|
1184
1203
|
const a = state0.a;
|
|
1185
1204
|
state0.a = 0;
|
|
1186
1205
|
try {
|
|
1187
|
-
return
|
|
1206
|
+
return __wbg_adapter_171(a, state0.b, arg0, arg1);
|
|
1188
1207
|
} finally {
|
|
1189
1208
|
state0.a = a;
|
|
1190
1209
|
}
|
|
@@ -1346,8 +1365,8 @@ module.exports.__wbindgen_function_table = function() {
|
|
|
1346
1365
|
return addHeapObject(ret);
|
|
1347
1366
|
};
|
|
1348
1367
|
|
|
1349
|
-
module.exports.
|
|
1350
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1368
|
+
module.exports.__wbindgen_closure_wrapper2097 = function(arg0, arg1, arg2) {
|
|
1369
|
+
const ret = makeMutClosure(arg0, arg1, 698, __wbg_adapter_52);
|
|
1351
1370
|
return addHeapObject(ret);
|
|
1352
1371
|
};
|
|
1353
1372
|
|