@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/web/acvm_js.js
CHANGED
|
@@ -223,36 +223,29 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
|
|
223
223
|
return real;
|
|
224
224
|
}
|
|
225
225
|
function __wbg_adapter_52(arg0, arg1, arg2) {
|
|
226
|
-
wasm.
|
|
226
|
+
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hc5258430255de068(arg0, arg1, addHeapObject(arg2));
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Performs a bitwise AND operation between `lhs` and `rhs`
|
|
231
|
+
* @param {string} lhs
|
|
232
|
+
* @param {string} rhs
|
|
233
|
+
* @returns {string}
|
|
234
|
+
*/
|
|
235
|
+
export function and(lhs, rhs) {
|
|
236
|
+
const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
|
|
237
|
+
return takeObject(ret);
|
|
232
238
|
}
|
|
239
|
+
|
|
233
240
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* @param {
|
|
237
|
-
* @returns {
|
|
241
|
+
* Performs a bitwise XOR operation between `lhs` and `rhs`
|
|
242
|
+
* @param {string} lhs
|
|
243
|
+
* @param {string} rhs
|
|
244
|
+
* @returns {string}
|
|
238
245
|
*/
|
|
239
|
-
export function
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
wasm.compressWitness(retptr, addHeapObject(witness_map));
|
|
243
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
244
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
245
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
246
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
247
|
-
if (r3) {
|
|
248
|
-
throw takeObject(r2);
|
|
249
|
-
}
|
|
250
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
251
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
252
|
-
return v1;
|
|
253
|
-
} finally {
|
|
254
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
255
|
-
}
|
|
246
|
+
export function xor(lhs, rhs) {
|
|
247
|
+
const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
|
|
248
|
+
return takeObject(ret);
|
|
256
249
|
}
|
|
257
250
|
|
|
258
251
|
function passArray8ToWasm0(arg, malloc) {
|
|
@@ -261,142 +254,122 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
261
254
|
WASM_VECTOR_LEN = arg.length;
|
|
262
255
|
return ptr;
|
|
263
256
|
}
|
|
257
|
+
|
|
258
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
259
|
+
ptr = ptr >>> 0;
|
|
260
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
261
|
+
}
|
|
264
262
|
/**
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
269
|
-
* @returns {WitnessMap} The decompressed witness map.
|
|
263
|
+
* Calculates the SHA256 hash of the input bytes
|
|
264
|
+
* @param {Uint8Array} inputs
|
|
265
|
+
* @returns {Uint8Array}
|
|
270
266
|
*/
|
|
271
|
-
export function
|
|
267
|
+
export function sha256(inputs) {
|
|
272
268
|
try {
|
|
273
269
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
274
|
-
const ptr0 = passArray8ToWasm0(
|
|
270
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
275
271
|
const len0 = WASM_VECTOR_LEN;
|
|
276
|
-
wasm.
|
|
272
|
+
wasm.sha256(retptr, ptr0, len0);
|
|
277
273
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
278
274
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
279
|
-
var
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
return takeObject(r0);
|
|
275
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
276
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
277
|
+
return v2;
|
|
284
278
|
} finally {
|
|
285
279
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
286
280
|
}
|
|
287
281
|
}
|
|
288
282
|
|
|
289
283
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* @
|
|
293
|
-
* @returns {Uint8Array} A compressed witness stack
|
|
284
|
+
* Calculates the Blake2s256 hash of the input bytes
|
|
285
|
+
* @param {Uint8Array} inputs
|
|
286
|
+
* @returns {Uint8Array}
|
|
294
287
|
*/
|
|
295
|
-
export function
|
|
288
|
+
export function blake2s256(inputs) {
|
|
296
289
|
try {
|
|
297
290
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
298
|
-
|
|
291
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
292
|
+
const len0 = WASM_VECTOR_LEN;
|
|
293
|
+
wasm.blake2s256(retptr, ptr0, len0);
|
|
299
294
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
300
295
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
301
|
-
var
|
|
302
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
303
|
-
if (r3) {
|
|
304
|
-
throw takeObject(r2);
|
|
305
|
-
}
|
|
306
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
296
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
307
297
|
wasm.__wbindgen_free(r0, r1 * 1);
|
|
308
|
-
return
|
|
298
|
+
return v2;
|
|
309
299
|
} finally {
|
|
310
300
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
311
301
|
}
|
|
312
302
|
}
|
|
313
303
|
|
|
314
304
|
/**
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
* @
|
|
318
|
-
* @returns {WitnessStack} The decompressed witness stack.
|
|
305
|
+
* Calculates the Keccak256 hash of the input bytes
|
|
306
|
+
* @param {Uint8Array} inputs
|
|
307
|
+
* @returns {Uint8Array}
|
|
319
308
|
*/
|
|
320
|
-
export function
|
|
309
|
+
export function keccak256(inputs) {
|
|
321
310
|
try {
|
|
322
311
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
323
|
-
const ptr0 = passArray8ToWasm0(
|
|
312
|
+
const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
|
|
324
313
|
const len0 = WASM_VECTOR_LEN;
|
|
325
|
-
wasm.
|
|
314
|
+
wasm.keccak256(retptr, ptr0, len0);
|
|
326
315
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
327
316
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
return takeObject(r0);
|
|
317
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
318
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
319
|
+
return v2;
|
|
333
320
|
} finally {
|
|
334
321
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
335
322
|
}
|
|
336
323
|
}
|
|
337
324
|
|
|
338
325
|
/**
|
|
339
|
-
*
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
348
|
-
*
|
|
349
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
350
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
351
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
352
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
353
|
-
*/
|
|
354
|
-
export function executeCircuit(program, initial_witness, foreign_call_handler) {
|
|
355
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
356
|
-
const len0 = WASM_VECTOR_LEN;
|
|
357
|
-
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
358
|
-
return takeObject(ret);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function _assertClass(instance, klass) {
|
|
362
|
-
if (!(instance instanceof klass)) {
|
|
363
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
364
|
-
}
|
|
365
|
-
return instance.ptr;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
369
|
-
*
|
|
370
|
-
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
371
|
-
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
372
|
-
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
373
|
-
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
374
|
-
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
326
|
+
* Verifies a ECDSA signature over the secp256k1 curve.
|
|
327
|
+
* @param {Uint8Array} hashed_msg
|
|
328
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
329
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
330
|
+
* @param {Uint8Array} signature
|
|
331
|
+
* @returns {boolean}
|
|
375
332
|
*/
|
|
376
|
-
export function
|
|
377
|
-
|
|
378
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
333
|
+
export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
334
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
379
335
|
const len0 = WASM_VECTOR_LEN;
|
|
380
|
-
const
|
|
381
|
-
|
|
336
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
337
|
+
const len1 = WASM_VECTOR_LEN;
|
|
338
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
339
|
+
const len2 = WASM_VECTOR_LEN;
|
|
340
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
341
|
+
const len3 = WASM_VECTOR_LEN;
|
|
342
|
+
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
343
|
+
return ret !== 0;
|
|
382
344
|
}
|
|
383
345
|
|
|
384
346
|
/**
|
|
347
|
+
* Verifies a ECDSA signature over the secp256r1 curve.
|
|
348
|
+
* @param {Uint8Array} hashed_msg
|
|
349
|
+
* @param {Uint8Array} public_key_x_bytes
|
|
350
|
+
* @param {Uint8Array} public_key_y_bytes
|
|
351
|
+
* @param {Uint8Array} signature
|
|
352
|
+
* @returns {boolean}
|
|
385
353
|
*/
|
|
386
|
-
export function
|
|
387
|
-
const ptr0 = passArray8ToWasm0(
|
|
354
|
+
export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
|
|
355
|
+
const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
|
|
388
356
|
const len0 = WASM_VECTOR_LEN;
|
|
389
|
-
const
|
|
390
|
-
|
|
357
|
+
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
358
|
+
const len1 = WASM_VECTOR_LEN;
|
|
359
|
+
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
360
|
+
const len2 = WASM_VECTOR_LEN;
|
|
361
|
+
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
362
|
+
const len3 = WASM_VECTOR_LEN;
|
|
363
|
+
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
364
|
+
return ret !== 0;
|
|
391
365
|
}
|
|
392
366
|
|
|
393
367
|
/**
|
|
368
|
+
* Returns the `BuildInfo` object containing information about how the installed package was built.
|
|
369
|
+
* @returns {BuildInfo} - Information on how the installed package was built.
|
|
394
370
|
*/
|
|
395
|
-
export function
|
|
396
|
-
|
|
397
|
-
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
398
|
-
const len0 = WASM_VECTOR_LEN;
|
|
399
|
-
const ret = wasm.executeProgramWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor));
|
|
371
|
+
export function buildInfo() {
|
|
372
|
+
const ret = wasm.buildInfo();
|
|
400
373
|
return takeObject(ret);
|
|
401
374
|
}
|
|
402
375
|
|
|
@@ -485,160 +458,206 @@ export function getPublicWitness(program, solved_witness) {
|
|
|
485
458
|
}
|
|
486
459
|
|
|
487
460
|
/**
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
* @param {
|
|
491
|
-
* @returns {string}
|
|
461
|
+
* Sets the package's logging level.
|
|
462
|
+
*
|
|
463
|
+
* @param {LogLevel} level - The maximum level of logging to be emitted.
|
|
492
464
|
*/
|
|
493
|
-
export function
|
|
494
|
-
|
|
495
|
-
|
|
465
|
+
export function initLogLevel(filter) {
|
|
466
|
+
try {
|
|
467
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
468
|
+
const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
469
|
+
const len0 = WASM_VECTOR_LEN;
|
|
470
|
+
wasm.initLogLevel(retptr, ptr0, len0);
|
|
471
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
472
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
473
|
+
if (r1) {
|
|
474
|
+
throw takeObject(r0);
|
|
475
|
+
}
|
|
476
|
+
} finally {
|
|
477
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
478
|
+
}
|
|
496
479
|
}
|
|
497
480
|
|
|
498
481
|
/**
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
* @param {
|
|
502
|
-
* @returns {
|
|
482
|
+
* Compresses a `WitnessMap` into the binary format outputted by Nargo.
|
|
483
|
+
*
|
|
484
|
+
* @param {WitnessMap} witness_map - A witness map.
|
|
485
|
+
* @returns {Uint8Array} A compressed witness map
|
|
503
486
|
*/
|
|
504
|
-
export function
|
|
505
|
-
|
|
506
|
-
|
|
487
|
+
export function compressWitness(witness_map) {
|
|
488
|
+
try {
|
|
489
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
490
|
+
wasm.compressWitness(retptr, addHeapObject(witness_map));
|
|
491
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
492
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
493
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
494
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
495
|
+
if (r3) {
|
|
496
|
+
throw takeObject(r2);
|
|
497
|
+
}
|
|
498
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
499
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
500
|
+
return v1;
|
|
501
|
+
} finally {
|
|
502
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
503
|
+
}
|
|
507
504
|
}
|
|
508
505
|
|
|
509
506
|
/**
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
507
|
+
* Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
|
|
508
|
+
* This should be used to only fetch the witness map for the main function.
|
|
509
|
+
*
|
|
510
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
511
|
+
* @returns {WitnessMap} The decompressed witness map.
|
|
513
512
|
*/
|
|
514
|
-
export function
|
|
513
|
+
export function decompressWitness(compressed_witness) {
|
|
515
514
|
try {
|
|
516
515
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
517
|
-
const ptr0 = passArray8ToWasm0(
|
|
516
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
518
517
|
const len0 = WASM_VECTOR_LEN;
|
|
519
|
-
wasm.
|
|
518
|
+
wasm.decompressWitness(retptr, ptr0, len0);
|
|
520
519
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
521
520
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
522
|
-
var
|
|
523
|
-
|
|
524
|
-
|
|
521
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
522
|
+
if (r2) {
|
|
523
|
+
throw takeObject(r1);
|
|
524
|
+
}
|
|
525
|
+
return takeObject(r0);
|
|
525
526
|
} finally {
|
|
526
527
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
527
528
|
}
|
|
528
529
|
}
|
|
529
530
|
|
|
530
531
|
/**
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
* @
|
|
532
|
+
* Compresses a `WitnessStack` into the binary format outputted by Nargo.
|
|
533
|
+
*
|
|
534
|
+
* @param {WitnessStack} witness_stack - A witness stack.
|
|
535
|
+
* @returns {Uint8Array} A compressed witness stack
|
|
534
536
|
*/
|
|
535
|
-
export function
|
|
537
|
+
export function compressWitnessStack(witness_stack) {
|
|
536
538
|
try {
|
|
537
539
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
538
|
-
|
|
539
|
-
const len0 = WASM_VECTOR_LEN;
|
|
540
|
-
wasm.blake2s256(retptr, ptr0, len0);
|
|
540
|
+
wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
|
|
541
541
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
542
542
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
543
|
-
var
|
|
543
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
544
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
545
|
+
if (r3) {
|
|
546
|
+
throw takeObject(r2);
|
|
547
|
+
}
|
|
548
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
544
549
|
wasm.__wbindgen_free(r0, r1 * 1);
|
|
545
|
-
return
|
|
550
|
+
return v1;
|
|
546
551
|
} finally {
|
|
547
552
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
548
553
|
}
|
|
549
554
|
}
|
|
550
555
|
|
|
551
556
|
/**
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
* @
|
|
557
|
+
* Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
|
|
558
|
+
*
|
|
559
|
+
* @param {Uint8Array} compressed_witness - A compressed witness.
|
|
560
|
+
* @returns {WitnessStack} The decompressed witness stack.
|
|
555
561
|
*/
|
|
556
|
-
export function
|
|
562
|
+
export function decompressWitnessStack(compressed_witness) {
|
|
557
563
|
try {
|
|
558
564
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
559
|
-
const ptr0 = passArray8ToWasm0(
|
|
565
|
+
const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
|
|
560
566
|
const len0 = WASM_VECTOR_LEN;
|
|
561
|
-
wasm.
|
|
567
|
+
wasm.decompressWitnessStack(retptr, ptr0, len0);
|
|
562
568
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
563
569
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
564
|
-
var
|
|
565
|
-
|
|
566
|
-
|
|
570
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
571
|
+
if (r2) {
|
|
572
|
+
throw takeObject(r1);
|
|
573
|
+
}
|
|
574
|
+
return takeObject(r0);
|
|
567
575
|
} finally {
|
|
568
576
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
569
577
|
}
|
|
570
578
|
}
|
|
571
579
|
|
|
572
580
|
/**
|
|
573
|
-
*
|
|
574
|
-
* @param {Uint8Array} hashed_msg
|
|
575
|
-
* @param {Uint8Array} public_key_x_bytes
|
|
576
|
-
* @param {Uint8Array} public_key_y_bytes
|
|
577
|
-
* @param {Uint8Array} signature
|
|
578
|
-
* @returns {boolean}
|
|
581
|
+
* @returns {Promise<WasmBlackBoxFunctionSolver>}
|
|
579
582
|
*/
|
|
580
|
-
export function
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
|
|
584
|
-
const len1 = WASM_VECTOR_LEN;
|
|
585
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
586
|
-
const len2 = WASM_VECTOR_LEN;
|
|
587
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
588
|
-
const len3 = WASM_VECTOR_LEN;
|
|
589
|
-
const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
590
|
-
return ret !== 0;
|
|
583
|
+
export function createBlackBoxSolver() {
|
|
584
|
+
const ret = wasm.createBlackBoxSolver();
|
|
585
|
+
return takeObject(ret);
|
|
591
586
|
}
|
|
592
587
|
|
|
593
588
|
/**
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
* @param {Uint8Array}
|
|
597
|
-
* @param {
|
|
598
|
-
* @param {
|
|
599
|
-
* @returns {
|
|
589
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
590
|
+
*
|
|
591
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
592
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
593
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
594
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
600
595
|
*/
|
|
601
|
-
export function
|
|
602
|
-
const ptr0 = passArray8ToWasm0(
|
|
596
|
+
export function executeCircuit(program, initial_witness, foreign_call_handler) {
|
|
597
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
603
598
|
const len0 = WASM_VECTOR_LEN;
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
|
|
607
|
-
const len2 = WASM_VECTOR_LEN;
|
|
608
|
-
const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
609
|
-
const len3 = WASM_VECTOR_LEN;
|
|
610
|
-
const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
611
|
-
return ret !== 0;
|
|
599
|
+
const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
600
|
+
return takeObject(ret);
|
|
612
601
|
}
|
|
613
602
|
|
|
603
|
+
function _assertClass(instance, klass) {
|
|
604
|
+
if (!(instance instanceof klass)) {
|
|
605
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
606
|
+
}
|
|
607
|
+
return instance.ptr;
|
|
608
|
+
}
|
|
614
609
|
/**
|
|
615
|
-
*
|
|
616
|
-
*
|
|
610
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
611
|
+
* This method also extracts the public return values from the solved witness into its own return witness.
|
|
612
|
+
*
|
|
613
|
+
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
614
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
615
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
616
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
617
|
+
* @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.
|
|
617
618
|
*/
|
|
618
|
-
export function
|
|
619
|
-
|
|
619
|
+
export function executeCircuitWithReturnWitness(solver, program, initial_witness, foreign_call_handler) {
|
|
620
|
+
_assertClass(solver, WasmBlackBoxFunctionSolver);
|
|
621
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
622
|
+
const len0 = WASM_VECTOR_LEN;
|
|
623
|
+
const ret = wasm.executeCircuitWithReturnWitness(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
620
624
|
return takeObject(ret);
|
|
621
625
|
}
|
|
622
626
|
|
|
623
627
|
/**
|
|
624
|
-
*
|
|
628
|
+
* Executes an ACIR circuit to generate the solved witness from the initial witness.
|
|
625
629
|
*
|
|
626
|
-
* @param {
|
|
630
|
+
* @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
|
|
631
|
+
* @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
|
|
632
|
+
* @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
|
|
633
|
+
* @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
|
|
634
|
+
* @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
|
|
627
635
|
*/
|
|
628
|
-
export function
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
636
|
+
export function executeCircuitWithBlackBoxSolver(solver, program, initial_witness, foreign_call_handler) {
|
|
637
|
+
_assertClass(solver, WasmBlackBoxFunctionSolver);
|
|
638
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
639
|
+
const len0 = WASM_VECTOR_LEN;
|
|
640
|
+
const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
641
|
+
return takeObject(ret);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
*/
|
|
646
|
+
export function executeProgram(program, initial_witness, foreign_call_handler) {
|
|
647
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
648
|
+
const len0 = WASM_VECTOR_LEN;
|
|
649
|
+
const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
|
|
650
|
+
return takeObject(ret);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
*/
|
|
655
|
+
export function executeProgramWithBlackBoxSolver(solver, program, initial_witness, foreign_call_executor) {
|
|
656
|
+
_assertClass(solver, WasmBlackBoxFunctionSolver);
|
|
657
|
+
const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
|
|
658
|
+
const len0 = WASM_VECTOR_LEN;
|
|
659
|
+
const ret = wasm.executeProgramWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor));
|
|
660
|
+
return takeObject(ret);
|
|
642
661
|
}
|
|
643
662
|
|
|
644
663
|
function handleError(f, args) {
|
|
@@ -648,12 +667,12 @@ function handleError(f, args) {
|
|
|
648
667
|
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
649
668
|
}
|
|
650
669
|
}
|
|
651
|
-
function
|
|
652
|
-
wasm.
|
|
670
|
+
function __wbg_adapter_134(arg0, arg1, arg2, arg3, arg4) {
|
|
671
|
+
wasm.wasm_bindgen__convert__closures__invoke3_mut__h1e7d8ac96c74bd35(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
|
|
653
672
|
}
|
|
654
673
|
|
|
655
|
-
function
|
|
656
|
-
wasm.
|
|
674
|
+
function __wbg_adapter_171(arg0, arg1, arg2, arg3) {
|
|
675
|
+
wasm.wasm_bindgen__convert__closures__invoke2_mut__h188e918906ff9a40(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
657
676
|
}
|
|
658
677
|
|
|
659
678
|
/**
|
|
@@ -742,14 +761,6 @@ function __wbg_get_imports() {
|
|
|
742
761
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
743
762
|
takeObject(arg0);
|
|
744
763
|
};
|
|
745
|
-
imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
|
|
746
|
-
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
|
|
747
|
-
return addHeapObject(ret);
|
|
748
|
-
};
|
|
749
|
-
imports.wbg.__wbindgen_is_array = function(arg0) {
|
|
750
|
-
const ret = Array.isArray(getObject(arg0));
|
|
751
|
-
return ret;
|
|
752
|
-
};
|
|
753
764
|
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
754
765
|
const obj = getObject(arg1);
|
|
755
766
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
@@ -764,31 +775,19 @@ function __wbg_get_imports() {
|
|
|
764
775
|
const ret = getObject(arg0) === undefined;
|
|
765
776
|
return ret;
|
|
766
777
|
};
|
|
767
|
-
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
768
|
-
const ret = getObject(arg0);
|
|
769
|
-
return addHeapObject(ret);
|
|
770
|
-
};
|
|
771
778
|
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
772
779
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
773
780
|
return addHeapObject(ret);
|
|
774
781
|
};
|
|
775
|
-
imports.wbg.
|
|
776
|
-
const ret =
|
|
777
|
-
return ret;
|
|
778
|
-
};
|
|
779
|
-
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
780
|
-
const obj = getObject(arg1);
|
|
781
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
782
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
783
|
-
var len1 = WASM_VECTOR_LEN;
|
|
784
|
-
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
785
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
782
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
783
|
+
const ret = getObject(arg0);
|
|
784
|
+
return addHeapObject(ret);
|
|
786
785
|
};
|
|
787
|
-
imports.wbg.
|
|
786
|
+
imports.wbg.__wbg_constructor_3d9f06adce00cc63 = function(arg0) {
|
|
788
787
|
const ret = new Error(takeObject(arg0));
|
|
789
788
|
return addHeapObject(ret);
|
|
790
789
|
};
|
|
791
|
-
imports.wbg.
|
|
790
|
+
imports.wbg.__wbg_new_e572a122c033be0c = function() {
|
|
792
791
|
const ret = new Map();
|
|
793
792
|
return addHeapObject(ret);
|
|
794
793
|
};
|
|
@@ -796,8 +795,16 @@ function __wbg_get_imports() {
|
|
|
796
795
|
const ret = arg0;
|
|
797
796
|
return addHeapObject(ret);
|
|
798
797
|
};
|
|
799
|
-
imports.wbg.
|
|
800
|
-
const
|
|
798
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
799
|
+
const obj = getObject(arg1);
|
|
800
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
801
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
802
|
+
var len1 = WASM_VECTOR_LEN;
|
|
803
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
804
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
805
|
+
};
|
|
806
|
+
imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
|
|
807
|
+
const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
|
|
801
808
|
return addHeapObject(ret);
|
|
802
809
|
};
|
|
803
810
|
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
|
@@ -809,6 +816,18 @@ function __wbg_get_imports() {
|
|
|
809
816
|
const ret = false;
|
|
810
817
|
return ret;
|
|
811
818
|
};
|
|
819
|
+
imports.wbg.__wbg_new_ecd8c47cc271426e = function() {
|
|
820
|
+
const ret = new Array();
|
|
821
|
+
return addHeapObject(ret);
|
|
822
|
+
};
|
|
823
|
+
imports.wbg.__wbindgen_is_array = function(arg0) {
|
|
824
|
+
const ret = Array.isArray(getObject(arg0));
|
|
825
|
+
return ret;
|
|
826
|
+
};
|
|
827
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
828
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
829
|
+
return ret;
|
|
830
|
+
};
|
|
812
831
|
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
813
832
|
const ret = new Error();
|
|
814
833
|
return addHeapObject(ret);
|
|
@@ -926,12 +945,12 @@ function __wbg_get_imports() {
|
|
|
926
945
|
const ret = module.require;
|
|
927
946
|
return addHeapObject(ret);
|
|
928
947
|
}, arguments) };
|
|
929
|
-
imports.wbg.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) {
|
|
930
|
-
getObject(arg0).getRandomValues(getObject(arg1));
|
|
931
|
-
}, arguments) };
|
|
932
948
|
imports.wbg.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) {
|
|
933
949
|
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
934
950
|
}, arguments) };
|
|
951
|
+
imports.wbg.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) {
|
|
952
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
953
|
+
}, arguments) };
|
|
935
954
|
imports.wbg.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) {
|
|
936
955
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
937
956
|
return addHeapObject(ret);
|
|
@@ -1002,7 +1021,7 @@ function __wbg_get_imports() {
|
|
|
1002
1021
|
const a = state0.a;
|
|
1003
1022
|
state0.a = 0;
|
|
1004
1023
|
try {
|
|
1005
|
-
return
|
|
1024
|
+
return __wbg_adapter_134(a, state0.b, arg0, arg1, arg2);
|
|
1006
1025
|
} finally {
|
|
1007
1026
|
state0.a = a;
|
|
1008
1027
|
}
|
|
@@ -1085,7 +1104,7 @@ function __wbg_get_imports() {
|
|
|
1085
1104
|
const a = state0.a;
|
|
1086
1105
|
state0.a = 0;
|
|
1087
1106
|
try {
|
|
1088
|
-
return
|
|
1107
|
+
return __wbg_adapter_171(a, state0.b, arg0, arg1);
|
|
1089
1108
|
} finally {
|
|
1090
1109
|
state0.a = a;
|
|
1091
1110
|
}
|
|
@@ -1132,7 +1151,7 @@ function __wbg_get_imports() {
|
|
|
1132
1151
|
const a = state0.a;
|
|
1133
1152
|
state0.a = 0;
|
|
1134
1153
|
try {
|
|
1135
|
-
return
|
|
1154
|
+
return __wbg_adapter_171(a, state0.b, arg0, arg1);
|
|
1136
1155
|
} finally {
|
|
1137
1156
|
state0.a = a;
|
|
1138
1157
|
}
|
|
@@ -1266,8 +1285,8 @@ function __wbg_get_imports() {
|
|
|
1266
1285
|
const ret = wasm.__wbindgen_export_2;
|
|
1267
1286
|
return addHeapObject(ret);
|
|
1268
1287
|
};
|
|
1269
|
-
imports.wbg.
|
|
1270
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1288
|
+
imports.wbg.__wbindgen_closure_wrapper2097 = function(arg0, arg1, arg2) {
|
|
1289
|
+
const ret = makeMutClosure(arg0, arg1, 698, __wbg_adapter_52);
|
|
1271
1290
|
return addHeapObject(ret);
|
|
1272
1291
|
};
|
|
1273
1292
|
|