@provablehq/wasm 0.11.4 → 0.11.5

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.
@@ -286,16 +286,6 @@ function runRayonThread(receiver) {
286
286
  wasm.runRayonThread(receiver);
287
287
  }
288
288
 
289
- /**
290
- * @param {URL} url
291
- * @param {number} num_threads
292
- * @returns {Promise<void>}
293
- */
294
- function initThreadPool(url, num_threads) {
295
- const ret = wasm.initThreadPool(addHeapObject(url), num_threads);
296
- return takeObject(ret);
297
- }
298
-
299
289
  /**
300
290
  * Set the WASM log level from JS. Called automatically by the SDK's
301
291
  * `setLogLevel(level)` to keep TS and WASM logging in sync.
@@ -307,6 +297,16 @@ function setWasmLogLevel(level) {
307
297
  wasm.setWasmLogLevel(level);
308
298
  }
309
299
 
300
+ /**
301
+ * @param {URL} url
302
+ * @param {number} num_threads
303
+ * @returns {Promise<void>}
304
+ */
305
+ function initThreadPool(url, num_threads) {
306
+ const ret = wasm.initThreadPool(addHeapObject(url), num_threads);
307
+ return takeObject(ret);
308
+ }
309
+
310
310
  let stack_pointer = 128;
311
311
 
312
312
  function addBorrowedObject(obj) {
@@ -315,41 +315,26 @@ function addBorrowedObject(obj) {
315
315
  return stack_pointer;
316
316
  }
317
317
  /**
318
- * Verify an execution. Executions with multiple transitions must have the program source code and
319
- * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
320
- * not verify that the state root of the execution is included in the Aleo Network ledger.
318
+ * Verify a SNARK proof against a verifying key and public inputs.
321
319
  *
322
- * @param {Execution} execution The function execution to verify
323
- * @param {VerifyingKey} verifying_key The verifying key for the function
324
- * @param {Program} program The program that the function execution belongs to
325
- * @param {String} function_id The name of the function that was executed
326
- * @param {Object} imports The imports for the program in the form of { "program_id.aleo":"source code", ... }
327
- * @param {Object} import_verifying_keys The verifying keys for the imports in the form of { "program_id.aleo": [["function, "verifying_key"], ...], ...}
328
- * @returns {boolean} True if the execution is valid, false otherwise
329
- * @param {Execution} execution
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
330
327
  * @param {VerifyingKey} verifying_key
331
- * @param {Program} program
332
- * @param {string} function_id
333
- * @param {object | null | undefined} imports
334
- * @param {object | null | undefined} imported_verifying_keys
335
- * @param {number} block_height
336
- * @param {ProgramImports | null} [program_imports]
328
+ * @param {Array<any>} inputs
329
+ * @param {Proof} proof
337
330
  * @returns {boolean}
338
331
  */
339
- function verifyFunctionExecution(execution, verifying_key, program, function_id, imports, imported_verifying_keys, block_height, program_imports) {
332
+ function snarkVerify(verifying_key, inputs, proof) {
340
333
  try {
341
334
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
342
- _assertClass(execution, Execution);
343
335
  _assertClass(verifying_key, VerifyingKey);
344
- _assertClass(program, Program);
345
- const ptr0 = passStringToWasm0(function_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
346
- const len0 = WASM_VECTOR_LEN;
347
- let ptr1 = 0;
348
- if (!isLikeNone(program_imports)) {
349
- _assertClass(program_imports, ProgramImports);
350
- ptr1 = program_imports.__destroy_into_raw();
351
- }
352
- wasm.verifyFunctionExecution(retptr, execution.__wbg_ptr, verifying_key.__wbg_ptr, program.__wbg_ptr, ptr0, len0, isLikeNone(imports) ? 0 : addHeapObject(imports), isLikeNone(imported_verifying_keys) ? 0 : addHeapObject(imported_verifying_keys), block_height, ptr1);
336
+ _assertClass(proof, Proof);
337
+ wasm.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
353
338
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
354
339
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
355
340
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -395,26 +380,41 @@ function snarkVerifyBatch(verifying_keys, inputs, proof) {
395
380
  }
396
381
 
397
382
  /**
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.
383
+ * Verify an execution. Executions with multiple transitions must have the program source code and
384
+ * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
385
+ * not verify that the state root of the execution is included in the Aleo Network ledger.
402
386
  *
403
- * @param {VerifyingKey} verifying_key The verifying key for the circuit
404
- * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
405
- * @param {Proof} proof The proof to verify
406
- * @returns {boolean} True if the proof is valid, false otherwise
387
+ * @param {Execution} execution The function execution to verify
388
+ * @param {VerifyingKey} verifying_key The verifying key for the function
389
+ * @param {Program} program The program that the function execution belongs to
390
+ * @param {String} function_id The name of the function that was executed
391
+ * @param {Object} imports The imports for the program in the form of { "program_id.aleo":"source code", ... }
392
+ * @param {Object} import_verifying_keys The verifying keys for the imports in the form of { "program_id.aleo": [["function, "verifying_key"], ...], ...}
393
+ * @returns {boolean} True if the execution is valid, false otherwise
394
+ * @param {Execution} execution
407
395
  * @param {VerifyingKey} verifying_key
408
- * @param {Array<any>} inputs
409
- * @param {Proof} proof
396
+ * @param {Program} program
397
+ * @param {string} function_id
398
+ * @param {object | null | undefined} imports
399
+ * @param {object | null | undefined} imported_verifying_keys
400
+ * @param {number} block_height
401
+ * @param {ProgramImports | null} [program_imports]
410
402
  * @returns {boolean}
411
403
  */
412
- function snarkVerify(verifying_key, inputs, proof) {
404
+ function verifyFunctionExecution(execution, verifying_key, program, function_id, imports, imported_verifying_keys, block_height, program_imports) {
413
405
  try {
414
406
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
407
+ _assertClass(execution, Execution);
415
408
  _assertClass(verifying_key, VerifyingKey);
416
- _assertClass(proof, Proof);
417
- wasm.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
409
+ _assertClass(program, Program);
410
+ const ptr0 = passStringToWasm0(function_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
411
+ const len0 = WASM_VECTOR_LEN;
412
+ let ptr1 = 0;
413
+ if (!isLikeNone(program_imports)) {
414
+ _assertClass(program_imports, ProgramImports);
415
+ ptr1 = program_imports.__destroy_into_raw();
416
+ }
417
+ wasm.verifyFunctionExecution(retptr, execution.__wbg_ptr, verifying_key.__wbg_ptr, program.__wbg_ptr, ptr0, len0, isLikeNone(imports) ? 0 : addHeapObject(imports), isLikeNone(imported_verifying_keys) ? 0 : addHeapObject(imported_verifying_keys), block_height, ptr1);
418
418
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
419
419
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
420
420
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -427,6 +427,23 @@ function snarkVerify(verifying_key, inputs, proof) {
427
427
  }
428
428
  }
429
429
 
430
+ /**
431
+ * Returns the maximum number of imports allowed in a program by the
432
+ * snarkVM network implementation this SDK was built against.
433
+ *
434
+ * @returns {number} The maximum number of program imports.
435
+ *
436
+ * @example
437
+ * import { getMaxProgramImports } from '@provablehq/sdk';
438
+ *
439
+ * const maxImports = getMaxProgramImports();
440
+ * @returns {number}
441
+ */
442
+ function getMaxProgramImports() {
443
+ const ret = wasm.getMaxProgramImports();
444
+ return ret >>> 0;
445
+ }
446
+
430
447
  /**
431
448
  * @param {string} string
432
449
  * @returns {Field}
@@ -488,16 +505,16 @@ function getArrayJsValueFromWasm0(ptr, len) {
488
505
  }
489
506
  return result;
490
507
  }
491
- function __wasm_bindgen_func_elem_8765(arg0, arg1, arg2) {
492
- wasm.__wasm_bindgen_func_elem_8765(arg0, arg1, addHeapObject(arg2));
508
+ function __wasm_bindgen_func_elem_7393(arg0, arg1) {
509
+ wasm.__wasm_bindgen_func_elem_7393(arg0, arg1);
493
510
  }
494
511
 
495
- function __wasm_bindgen_func_elem_7397(arg0, arg1) {
496
- wasm.__wasm_bindgen_func_elem_7397(arg0, arg1);
512
+ function __wasm_bindgen_func_elem_8766(arg0, arg1, arg2) {
513
+ wasm.__wasm_bindgen_func_elem_8766(arg0, arg1, addHeapObject(arg2));
497
514
  }
498
515
 
499
- function __wasm_bindgen_func_elem_7669(arg0, arg1, arg2, arg3) {
500
- wasm.__wasm_bindgen_func_elem_7669(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
516
+ function __wasm_bindgen_func_elem_7666(arg0, arg1, arg2, arg3) {
517
+ wasm.__wasm_bindgen_func_elem_7666(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
501
518
  }
502
519
 
503
520
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -19302,7 +19319,7 @@ function __wbg_get_imports(memory) {
19302
19319
  const ret = getObject(arg0).length;
19303
19320
  return ret;
19304
19321
  };
19305
- imports.wbg.__wbg_log_4507b73801c06872 = function(arg0, arg1) {
19322
+ imports.wbg.__wbg_log_a530da429f854235 = function(arg0, arg1) {
19306
19323
  console.log(getStringFromWasm0(arg0, arg1));
19307
19324
  };
19308
19325
  imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
@@ -19320,7 +19337,7 @@ function __wbg_get_imports(memory) {
19320
19337
  const a = state0.a;
19321
19338
  state0.a = 0;
19322
19339
  try {
19323
- return __wasm_bindgen_func_elem_7669(a, state0.b, arg0, arg1);
19340
+ return __wasm_bindgen_func_elem_7666(a, state0.b, arg0, arg1);
19324
19341
  } finally {
19325
19342
  state0.a = a;
19326
19343
  }
@@ -19492,7 +19509,7 @@ function __wbg_get_imports(memory) {
19492
19509
  const ret = Signature.__wrap(arg0);
19493
19510
  return addHeapObject(ret);
19494
19511
  };
19495
- imports.wbg.__wbg_spawnWorker_6197e35077a8baba = function(arg0, arg1, arg2, arg3) {
19512
+ imports.wbg.__wbg_spawnWorker_ad641c7b32ebd520 = function(arg0, arg1, arg2, arg3) {
19496
19513
  const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
19497
19514
  return addHeapObject(ret);
19498
19515
  };
@@ -19591,12 +19608,12 @@ function __wbg_get_imports(memory) {
19591
19608
  };
19592
19609
  imports.wbg.__wbindgen_cast_4a64cbb5b17898c9 = function(arg0, arg1) {
19593
19610
  // Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [Externref], shim_idx: 359, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19594
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7396, __wasm_bindgen_func_elem_8765);
19611
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7392, __wasm_bindgen_func_elem_8766);
19595
19612
  return addHeapObject(ret);
19596
19613
  };
19597
19614
  imports.wbg.__wbindgen_cast_65bbaf572cb463ed = function(arg0, arg1) {
19598
19615
  // 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`.
19599
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7396, __wasm_bindgen_func_elem_8765);
19616
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7392, __wasm_bindgen_func_elem_8766);
19600
19617
  return addHeapObject(ret);
19601
19618
  };
19602
19619
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
@@ -19606,7 +19623,7 @@ function __wbg_get_imports(memory) {
19606
19623
  };
19607
19624
  imports.wbg.__wbindgen_cast_aca65e91b5ef2a91 = function(arg0, arg1) {
19608
19625
  // Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [], shim_idx: 467, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19609
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7396, __wasm_bindgen_func_elem_7397);
19626
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7392, __wasm_bindgen_func_elem_7393);
19610
19627
  return addHeapObject(ret);
19611
19628
  };
19612
19629
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
@@ -19761,6 +19778,7 @@ var exports$1 = /*#__PURE__*/Object.freeze({
19761
19778
  VerifyingKey: VerifyingKey,
19762
19779
  ViewKey: ViewKey,
19763
19780
  default: __wbg_init,
19781
+ getMaxProgramImports: getMaxProgramImports,
19764
19782
  getOrInitConsensusVersionTestHeights: getOrInitConsensusVersionTestHeights,
19765
19783
  initSync: initSync,
19766
19784
  initThreadPool: initThreadPool,