@provablehq/wasm 0.11.10 → 0.12.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.
@@ -314,39 +314,6 @@ function addBorrowedObject(obj) {
314
314
  heap[--stack_pointer] = obj;
315
315
  return stack_pointer;
316
316
  }
317
- /**
318
- * Verify a SNARK proof against a verifying key and public inputs.
319
- *
320
- * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
321
- * It directly invokes the Varuna proof verification from snarkVM.
322
- *
323
- * @param {VerifyingKey} verifying_key The verifying key for the circuit
324
- * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
325
- * @param {Proof} proof The proof to verify
326
- * @returns {boolean} True if the proof is valid, false otherwise
327
- * @param {VerifyingKey} verifying_key
328
- * @param {Array<any>} inputs
329
- * @param {Proof} proof
330
- * @returns {boolean}
331
- */
332
- function snarkVerify(verifying_key, inputs, proof) {
333
- try {
334
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
335
- _assertClass(verifying_key, VerifyingKey);
336
- _assertClass(proof, Proof);
337
- wasm.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
338
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
339
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
340
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
341
- if (r2) {
342
- throw takeObject(r1);
343
- }
344
- return r0 !== 0;
345
- } finally {
346
- wasm.__wbindgen_add_to_stack_pointer(16);
347
- }
348
- }
349
-
350
317
  /**
351
318
  * Verify an execution. Executions with multiple transitions must have the program source code and
352
319
  * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
@@ -428,22 +395,35 @@ function snarkVerifyBatch(verifying_keys, inputs, proof) {
428
395
  }
429
396
 
430
397
  /**
431
- * @param {string} string
432
- * @returns {Field}
398
+ * Verify a SNARK proof against a verifying key and public inputs.
399
+ *
400
+ * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
401
+ * It directly invokes the Varuna proof verification from snarkVM, using the Varuna version required
402
+ * by the latest consensus version (Varuna V3 as of `ConsensusVersion::V21`). Proofs generated with
403
+ * an older Varuna version will fail verification.
404
+ *
405
+ * @param {VerifyingKey} verifying_key The verifying key for the circuit
406
+ * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
407
+ * @param {Proof} proof The proof to verify
408
+ * @returns {boolean} True if the proof is valid, false otherwise
409
+ * @param {VerifyingKey} verifying_key
410
+ * @param {Array<any>} inputs
411
+ * @param {Proof} proof
412
+ * @returns {boolean}
433
413
  */
434
- function stringToField(string) {
414
+ function snarkVerify(verifying_key, inputs, proof) {
435
415
  try {
436
416
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
437
- const ptr0 = passStringToWasm0(string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
438
- const len0 = WASM_VECTOR_LEN;
439
- wasm.stringToField(retptr, ptr0, len0);
417
+ _assertClass(verifying_key, VerifyingKey);
418
+ _assertClass(proof, Proof);
419
+ wasm.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
440
420
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
441
421
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
442
422
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
443
423
  if (r2) {
444
424
  throw takeObject(r1);
445
425
  }
446
- return Field.__wrap(r0);
426
+ return r0 !== 0;
447
427
  } finally {
448
428
  wasm.__wbindgen_add_to_stack_pointer(16);
449
429
  }
@@ -458,7 +438,7 @@ function stringToField(string) {
458
438
  * import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
459
439
  *
460
440
  * Set the consensus version heights.
461
- * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18");
441
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21");
462
442
  * @param {string | null} [heights]
463
443
  * @returns {Array<any>}
464
444
  */
@@ -486,6 +466,28 @@ function getMaxProgramImports() {
486
466
  return ret >>> 0;
487
467
  }
488
468
 
469
+ /**
470
+ * @param {string} string
471
+ * @returns {Field}
472
+ */
473
+ function stringToField(string) {
474
+ try {
475
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
476
+ const ptr0 = passStringToWasm0(string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
477
+ const len0 = WASM_VECTOR_LEN;
478
+ wasm.stringToField(retptr, ptr0, len0);
479
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
480
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
481
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
482
+ if (r2) {
483
+ throw takeObject(r1);
484
+ }
485
+ return Field.__wrap(r0);
486
+ } finally {
487
+ wasm.__wbindgen_add_to_stack_pointer(16);
488
+ }
489
+ }
490
+
489
491
  function passArrayJsValueToWasm0(array, malloc) {
490
492
  const ptr = malloc(array.length * 4, 4) >>> 0;
491
493
  const mem = getDataViewMemory0();
@@ -505,16 +507,16 @@ function getArrayJsValueFromWasm0(ptr, len) {
505
507
  }
506
508
  return result;
507
509
  }
508
- function __wasm_bindgen_func_elem_8946(arg0, arg1, arg2) {
509
- wasm.__wasm_bindgen_func_elem_8946(arg0, arg1, addHeapObject(arg2));
510
+ function __wasm_bindgen_func_elem_9005(arg0, arg1, arg2) {
511
+ wasm.__wasm_bindgen_func_elem_9005(arg0, arg1, addHeapObject(arg2));
510
512
  }
511
513
 
512
- function __wasm_bindgen_func_elem_7504(arg0, arg1) {
513
- wasm.__wasm_bindgen_func_elem_7504(arg0, arg1);
514
+ function __wasm_bindgen_func_elem_7568(arg0, arg1) {
515
+ wasm.__wasm_bindgen_func_elem_7568(arg0, arg1);
514
516
  }
515
517
 
516
- function __wasm_bindgen_func_elem_7777(arg0, arg1, arg2, arg3) {
517
- wasm.__wasm_bindgen_func_elem_7777(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
518
+ function __wasm_bindgen_func_elem_7840(arg0, arg1, arg2, arg3) {
519
+ wasm.__wasm_bindgen_func_elem_7840(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
518
520
  }
519
521
 
520
522
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -19319,7 +19321,7 @@ function __wbg_get_imports(memory) {
19319
19321
  const ret = getObject(arg0).length;
19320
19322
  return ret;
19321
19323
  };
19322
- imports.wbg.__wbg_log_6a7c7e39dc2b85ff = function(arg0, arg1) {
19324
+ imports.wbg.__wbg_log_c2eca570a6157825 = function(arg0, arg1) {
19323
19325
  console.log(getStringFromWasm0(arg0, arg1));
19324
19326
  };
19325
19327
  imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
@@ -19337,7 +19339,7 @@ function __wbg_get_imports(memory) {
19337
19339
  const a = state0.a;
19338
19340
  state0.a = 0;
19339
19341
  try {
19340
- return __wasm_bindgen_func_elem_7777(a, state0.b, arg0, arg1);
19342
+ return __wasm_bindgen_func_elem_7840(a, state0.b, arg0, arg1);
19341
19343
  } finally {
19342
19344
  state0.a = a;
19343
19345
  }
@@ -19509,7 +19511,7 @@ function __wbg_get_imports(memory) {
19509
19511
  const ret = Signature.__wrap(arg0);
19510
19512
  return addHeapObject(ret);
19511
19513
  };
19512
- imports.wbg.__wbg_spawnWorker_ea93f1cb9997e793 = function(arg0, arg1, arg2, arg3) {
19514
+ imports.wbg.__wbg_spawnWorker_0d7c58b5ba9ab046 = function(arg0, arg1, arg2, arg3) {
19513
19515
  const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
19514
19516
  return addHeapObject(ret);
19515
19517
  };
@@ -19591,16 +19593,16 @@ function __wbg_get_imports(memory) {
19591
19593
  const ret = Atomics.waitAsync(getObject(arg0), arg1 >>> 0, arg2);
19592
19594
  return addHeapObject(ret);
19593
19595
  };
19596
+ imports.wbg.__wbindgen_cast_201f5d8c51d6c49f = function(arg0, arg1) {
19597
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 396, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 397, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19598
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7567, __wasm_bindgen_func_elem_9005);
19599
+ return addHeapObject(ret);
19600
+ };
19594
19601
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
19595
19602
  // Cast intrinsic for `Ref(String) -> Externref`.
19596
19603
  const ret = getStringFromWasm0(arg0, arg1);
19597
19604
  return addHeapObject(ret);
19598
19605
  };
19599
- imports.wbg.__wbindgen_cast_2adca60326a83a78 = function(arg0, arg1) {
19600
- // Cast intrinsic for `Closure(Closure { dtor_idx: 395, function: Function { arguments: [], shim_idx: 528, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19601
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7503, __wasm_bindgen_func_elem_7504);
19602
- return addHeapObject(ret);
19603
- };
19604
19606
  imports.wbg.__wbindgen_cast_2ddd8a25ff58642a = function(arg0, arg1) {
19605
19607
  // Cast intrinsic for `I128 -> Externref`.
19606
19608
  const ret = (BigInt.asUintN(64, arg0) | (arg1 << BigInt(64)));
@@ -19611,9 +19613,9 @@ function __wbg_get_imports(memory) {
19611
19613
  const ret = BigInt.asUintN(64, arg0);
19612
19614
  return addHeapObject(ret);
19613
19615
  };
19614
- imports.wbg.__wbindgen_cast_805ada4c4be963fc = function(arg0, arg1) {
19615
- // Cast intrinsic for `Closure(Closure { dtor_idx: 395, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 396, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19616
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7503, __wasm_bindgen_func_elem_8946);
19616
+ imports.wbg.__wbindgen_cast_81f27860ba10fea8 = function(arg0, arg1) {
19617
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 396, function: Function { arguments: [Externref], shim_idx: 397, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19618
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7567, __wasm_bindgen_func_elem_9005);
19617
19619
  return addHeapObject(ret);
19618
19620
  };
19619
19621
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
@@ -19621,16 +19623,16 @@ function __wbg_get_imports(memory) {
19621
19623
  const ret = arg0;
19622
19624
  return addHeapObject(ret);
19623
19625
  };
19624
- imports.wbg.__wbindgen_cast_c048d24de4cf58bb = function(arg0, arg1) {
19625
- // Cast intrinsic for `Closure(Closure { dtor_idx: 395, function: Function { arguments: [Externref], shim_idx: 396, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19626
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7503, __wasm_bindgen_func_elem_8946);
19627
- return addHeapObject(ret);
19628
- };
19629
19626
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
19630
19627
  // Cast intrinsic for `F64 -> Externref`.
19631
19628
  const ret = arg0;
19632
19629
  return addHeapObject(ret);
19633
19630
  };
19631
+ imports.wbg.__wbindgen_cast_df4137fc329f9ddc = function(arg0, arg1) {
19632
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 396, function: Function { arguments: [], shim_idx: 533, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19633
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7567, __wasm_bindgen_func_elem_7568);
19634
+ return addHeapObject(ret);
19635
+ };
19634
19636
  imports.wbg.__wbindgen_cast_e7b45dd881f38ce3 = function(arg0, arg1) {
19635
19637
  // Cast intrinsic for `U128 -> Externref`.
19636
19638
  const ret = (BigInt.asUintN(64, arg0) | (BigInt.asUintN(64, arg1) << BigInt(64)));