@provablehq/wasm 0.10.2 → 0.10.3

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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Initializes a thread pool of Workers. This enables multi-threading, which significantly improves performance.
3
+ *
4
+ * @param {number | undefined} threads Number of threads to spawn. If not specified, uses the number of available cores.
5
+ */
6
+ export function initThreadPool(threads?: number): Promise<void>;
7
+
8
+ export * from "./aleo_wasm.js";
@@ -335,39 +335,6 @@ function snarkVerifyBatch(verifying_keys, inputs, proof) {
335
335
  }
336
336
  }
337
337
 
338
- /**
339
- * Verify a SNARK proof against a verifying key and public inputs.
340
- *
341
- * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
342
- * It directly invokes the Varuna proof verification from snarkVM.
343
- *
344
- * @param {VerifyingKey} verifying_key The verifying key for the circuit
345
- * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
346
- * @param {Proof} proof The proof to verify
347
- * @returns {boolean} True if the proof is valid, false otherwise
348
- * @param {VerifyingKey} verifying_key
349
- * @param {Array<any>} inputs
350
- * @param {Proof} proof
351
- * @returns {boolean}
352
- */
353
- function snarkVerify(verifying_key, inputs, proof) {
354
- try {
355
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
356
- _assertClass(verifying_key, VerifyingKey);
357
- _assertClass(proof, Proof);
358
- wasm.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
359
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
360
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
361
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
362
- if (r2) {
363
- throw takeObject(r1);
364
- }
365
- return r0 !== 0;
366
- } finally {
367
- wasm.__wbindgen_add_to_stack_pointer(16);
368
- }
369
- }
370
-
371
338
  /**
372
339
  * Verify an execution. Executions with multiple transitions must have the program source code and
373
340
  * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
@@ -411,23 +378,36 @@ function verifyFunctionExecution(execution, verifying_key, program, function_id,
411
378
  }
412
379
 
413
380
  /**
414
- * Set test consensus version heights for testing.
415
- *
416
- * @param {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
381
+ * Verify a SNARK proof against a verifying key and public inputs.
417
382
  *
418
- * @example
419
- * import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
383
+ * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
384
+ * It directly invokes the Varuna proof verification from snarkVM.
420
385
  *
421
- * Set the consensus version heights.
422
- * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
423
- * @param {string | null} [heights]
424
- * @returns {Array<any>}
386
+ * @param {VerifyingKey} verifying_key The verifying key for the circuit
387
+ * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
388
+ * @param {Proof} proof The proof to verify
389
+ * @returns {boolean} True if the proof is valid, false otherwise
390
+ * @param {VerifyingKey} verifying_key
391
+ * @param {Array<any>} inputs
392
+ * @param {Proof} proof
393
+ * @returns {boolean}
425
394
  */
426
- function getOrInitConsensusVersionTestHeights(heights) {
427
- var ptr0 = isLikeNone(heights) ? 0 : passStringToWasm0(heights, wasm.__wbindgen_export, wasm.__wbindgen_export2);
428
- var len0 = WASM_VECTOR_LEN;
429
- const ret = wasm.getOrInitConsensusVersionTestHeights(ptr0, len0);
430
- return takeObject(ret);
395
+ function snarkVerify(verifying_key, inputs, proof) {
396
+ try {
397
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
398
+ _assertClass(verifying_key, VerifyingKey);
399
+ _assertClass(proof, Proof);
400
+ wasm.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
401
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
402
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
403
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
404
+ if (r2) {
405
+ throw takeObject(r1);
406
+ }
407
+ return r0 !== 0;
408
+ } finally {
409
+ wasm.__wbindgen_add_to_stack_pointer(16);
410
+ }
431
411
  }
432
412
 
433
413
  /**
@@ -452,6 +432,26 @@ function stringToField(string) {
452
432
  }
453
433
  }
454
434
 
435
+ /**
436
+ * Set test consensus version heights for testing.
437
+ *
438
+ * @param {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
439
+ *
440
+ * @example
441
+ * import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
442
+ *
443
+ * Set the consensus version heights.
444
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
445
+ * @param {string | null} [heights]
446
+ * @returns {Array<any>}
447
+ */
448
+ function getOrInitConsensusVersionTestHeights(heights) {
449
+ var ptr0 = isLikeNone(heights) ? 0 : passStringToWasm0(heights, wasm.__wbindgen_export, wasm.__wbindgen_export2);
450
+ var len0 = WASM_VECTOR_LEN;
451
+ const ret = wasm.getOrInitConsensusVersionTestHeights(ptr0, len0);
452
+ return takeObject(ret);
453
+ }
454
+
455
455
  function passArrayJsValueToWasm0(array, malloc) {
456
456
  const ptr = malloc(array.length * 4, 4) >>> 0;
457
457
  const mem = getDataViewMemory0();
@@ -471,16 +471,16 @@ function getArrayJsValueFromWasm0(ptr, len) {
471
471
  }
472
472
  return result;
473
473
  }
474
- function __wasm_bindgen_func_elem_7170(arg0, arg1) {
475
- wasm.__wasm_bindgen_func_elem_7170(arg0, arg1);
476
- }
477
-
478
474
  function __wasm_bindgen_func_elem_8534(arg0, arg1, arg2) {
479
475
  wasm.__wasm_bindgen_func_elem_8534(arg0, arg1, addHeapObject(arg2));
480
476
  }
481
477
 
482
- function __wasm_bindgen_func_elem_7443(arg0, arg1, arg2, arg3) {
483
- wasm.__wasm_bindgen_func_elem_7443(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
478
+ function __wasm_bindgen_func_elem_7173(arg0, arg1) {
479
+ wasm.__wasm_bindgen_func_elem_7173(arg0, arg1);
480
+ }
481
+
482
+ function __wasm_bindgen_func_elem_7446(arg0, arg1, arg2, arg3) {
483
+ wasm.__wasm_bindgen_func_elem_7446(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
484
484
  }
485
485
 
486
486
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -18336,7 +18336,7 @@ function __wbg_get_imports(memory) {
18336
18336
  const ret = getObject(arg0).length;
18337
18337
  return ret;
18338
18338
  };
18339
- imports.wbg.__wbg_log_8439fc9fbc2e093e = function(arg0, arg1) {
18339
+ imports.wbg.__wbg_log_0b9e82a3d425c505 = function(arg0, arg1) {
18340
18340
  console.log(getStringFromWasm0(arg0, arg1));
18341
18341
  };
18342
18342
  imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
@@ -18358,7 +18358,7 @@ function __wbg_get_imports(memory) {
18358
18358
  const a = state0.a;
18359
18359
  state0.a = 0;
18360
18360
  try {
18361
- return __wasm_bindgen_func_elem_7443(a, state0.b, arg0, arg1);
18361
+ return __wasm_bindgen_func_elem_7446(a, state0.b, arg0, arg1);
18362
18362
  } finally {
18363
18363
  state0.a = a;
18364
18364
  }
@@ -18545,7 +18545,7 @@ function __wbg_get_imports(memory) {
18545
18545
  const ret = Signature.__wrap(arg0);
18546
18546
  return addHeapObject(ret);
18547
18547
  };
18548
- imports.wbg.__wbg_spawnWorker_e4acc8b34866a9bd = function(arg0, arg1, arg2, arg3) {
18548
+ imports.wbg.__wbg_spawnWorker_fd8a412decad8341 = function(arg0, arg1, arg2, arg3) {
18549
18549
  const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
18550
18550
  return addHeapObject(ret);
18551
18551
  };
@@ -18637,7 +18637,7 @@ function __wbg_get_imports(memory) {
18637
18637
  };
18638
18638
  imports.wbg.__wbindgen_cast_0eb37dec5f5def71 = function(arg0, arg1) {
18639
18639
  // Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [], shim_idx: 465, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
18640
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7169, __wasm_bindgen_func_elem_7170);
18640
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7172, __wasm_bindgen_func_elem_7173);
18641
18641
  return addHeapObject(ret);
18642
18642
  };
18643
18643
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
@@ -18657,12 +18657,12 @@ function __wbg_get_imports(memory) {
18657
18657
  };
18658
18658
  imports.wbg.__wbindgen_cast_4a64cbb5b17898c9 = function(arg0, arg1) {
18659
18659
  // Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [Externref], shim_idx: 359, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
18660
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7169, __wasm_bindgen_func_elem_8534);
18660
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7172, __wasm_bindgen_func_elem_8534);
18661
18661
  return addHeapObject(ret);
18662
18662
  };
18663
18663
  imports.wbg.__wbindgen_cast_65bbaf572cb463ed = function(arg0, arg1) {
18664
18664
  // Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 359, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
18665
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7169, __wasm_bindgen_func_elem_8534);
18665
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7172, __wasm_bindgen_func_elem_8534);
18666
18666
  return addHeapObject(ret);
18667
18667
  };
18668
18668
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {