@provablehq/wasm 0.11.4 → 0.11.6

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,54 +314,6 @@ function addBorrowedObject(obj) {
314
314
  heap[--stack_pointer] = obj;
315
315
  return stack_pointer;
316
316
  }
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.
321
- *
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
330
- * @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]
337
- * @returns {boolean}
338
- */
339
- function verifyFunctionExecution(execution, verifying_key, program, function_id, imports, imported_verifying_keys, block_height, program_imports) {
340
- try {
341
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
342
- _assertClass(execution, Execution);
343
- _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);
353
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
354
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
355
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
356
- if (r2) {
357
- throw takeObject(r1);
358
- }
359
- return r0 !== 0;
360
- } finally {
361
- wasm.__wbindgen_add_to_stack_pointer(16);
362
- }
363
- }
364
-
365
317
  /**
366
318
  * Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
367
319
  *
@@ -428,22 +380,48 @@ function snarkVerify(verifying_key, inputs, proof) {
428
380
  }
429
381
 
430
382
  /**
431
- * @param {string} string
432
- * @returns {Field}
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.
386
+ *
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
395
+ * @param {VerifyingKey} verifying_key
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]
402
+ * @returns {boolean}
433
403
  */
434
- function stringToField(string) {
404
+ function verifyFunctionExecution(execution, verifying_key, program, function_id, imports, imported_verifying_keys, block_height, program_imports) {
435
405
  try {
436
406
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
437
- const ptr0 = passStringToWasm0(string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
407
+ _assertClass(execution, Execution);
408
+ _assertClass(verifying_key, VerifyingKey);
409
+ _assertClass(program, Program);
410
+ const ptr0 = passStringToWasm0(function_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
438
411
  const len0 = WASM_VECTOR_LEN;
439
- wasm.stringToField(retptr, ptr0, len0);
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);
440
418
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
441
419
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
442
420
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
443
421
  if (r2) {
444
422
  throw takeObject(r1);
445
423
  }
446
- return Field.__wrap(r0);
424
+ return r0 !== 0;
447
425
  } finally {
448
426
  wasm.__wbindgen_add_to_stack_pointer(16);
449
427
  }
@@ -458,7 +436,7 @@ function stringToField(string) {
458
436
  * import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
459
437
  *
460
438
  * Set the consensus version heights.
461
- * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
439
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17");
462
440
  * @param {string | null} [heights]
463
441
  * @returns {Array<any>}
464
442
  */
@@ -469,6 +447,45 @@ function getOrInitConsensusVersionTestHeights(heights) {
469
447
  return takeObject(ret);
470
448
  }
471
449
 
450
+ /**
451
+ * Returns the maximum number of imports allowed in a program by the
452
+ * snarkVM network implementation this SDK was built against.
453
+ *
454
+ * @returns {number} The maximum number of program imports.
455
+ *
456
+ * @example
457
+ * import { getMaxProgramImports } from '@provablehq/sdk';
458
+ *
459
+ * const maxImports = getMaxProgramImports();
460
+ * @returns {number}
461
+ */
462
+ function getMaxProgramImports() {
463
+ const ret = wasm.getMaxProgramImports();
464
+ return ret >>> 0;
465
+ }
466
+
467
+ /**
468
+ * @param {string} string
469
+ * @returns {Field}
470
+ */
471
+ function stringToField(string) {
472
+ try {
473
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
474
+ const ptr0 = passStringToWasm0(string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
475
+ const len0 = WASM_VECTOR_LEN;
476
+ wasm.stringToField(retptr, ptr0, len0);
477
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
478
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
479
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
480
+ if (r2) {
481
+ throw takeObject(r1);
482
+ }
483
+ return Field.__wrap(r0);
484
+ } finally {
485
+ wasm.__wbindgen_add_to_stack_pointer(16);
486
+ }
487
+ }
488
+
472
489
  function passArrayJsValueToWasm0(array, malloc) {
473
490
  const ptr = malloc(array.length * 4, 4) >>> 0;
474
491
  const mem = getDataViewMemory0();
@@ -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_8910(arg0, arg1, arg2) {
509
+ wasm.__wasm_bindgen_func_elem_8910(arg0, arg1, addHeapObject(arg2));
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_7471(arg0, arg1) {
513
+ wasm.__wasm_bindgen_func_elem_7471(arg0, arg1);
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_7743(arg0, arg1, arg2, arg3) {
517
+ wasm.__wasm_bindgen_func_elem_7743(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_27d73c032446232d = 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_7743(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_e00cacfddf7ee0c0 = 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
  };
@@ -19574,6 +19591,16 @@ function __wbg_get_imports(memory) {
19574
19591
  const ret = Atomics.waitAsync(getObject(arg0), arg1 >>> 0, arg2);
19575
19592
  return addHeapObject(ret);
19576
19593
  };
19594
+ imports.wbg.__wbindgen_cast_01d4af51d575cfe0 = function(arg0, arg1) {
19595
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 388, function: Function { arguments: [], shim_idx: 495, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19596
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7470, __wasm_bindgen_func_elem_7471);
19597
+ return addHeapObject(ret);
19598
+ };
19599
+ imports.wbg.__wbindgen_cast_13f76f7c228ed64d = function(arg0, arg1) {
19600
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 388, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 389, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19601
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7470, __wasm_bindgen_func_elem_8910);
19602
+ return addHeapObject(ret);
19603
+ };
19577
19604
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
19578
19605
  // Cast intrinsic for `Ref(String) -> Externref`.
19579
19606
  const ret = getStringFromWasm0(arg0, arg1);
@@ -19584,31 +19611,21 @@ function __wbg_get_imports(memory) {
19584
19611
  const ret = (BigInt.asUintN(64, arg0) | (arg1 << BigInt(64)));
19585
19612
  return addHeapObject(ret);
19586
19613
  };
19614
+ imports.wbg.__wbindgen_cast_42ef79217ed4073d = function(arg0, arg1) {
19615
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 388, function: Function { arguments: [Externref], shim_idx: 389, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19616
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7470, __wasm_bindgen_func_elem_8910);
19617
+ return addHeapObject(ret);
19618
+ };
19587
19619
  imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
19588
19620
  // Cast intrinsic for `U64 -> Externref`.
19589
19621
  const ret = BigInt.asUintN(64, arg0);
19590
19622
  return addHeapObject(ret);
19591
19623
  };
19592
- imports.wbg.__wbindgen_cast_4a64cbb5b17898c9 = function(arg0, arg1) {
19593
- // 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);
19595
- return addHeapObject(ret);
19596
- };
19597
- imports.wbg.__wbindgen_cast_65bbaf572cb463ed = function(arg0, arg1) {
19598
- // 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);
19600
- return addHeapObject(ret);
19601
- };
19602
19624
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
19603
19625
  // Cast intrinsic for `I64 -> Externref`.
19604
19626
  const ret = arg0;
19605
19627
  return addHeapObject(ret);
19606
19628
  };
19607
- imports.wbg.__wbindgen_cast_aca65e91b5ef2a91 = function(arg0, arg1) {
19608
- // 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);
19610
- return addHeapObject(ret);
19611
- };
19612
19629
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
19613
19630
  // Cast intrinsic for `F64 -> Externref`.
19614
19631
  const ret = arg0;
@@ -19717,5 +19734,5 @@ async function initThreadPool(threads) {
19717
19734
  await initThreadPool$1(new URL("worker.js", import.meta.url), threads);
19718
19735
  }
19719
19736
 
19720
- export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, CallbackQuery, Ciphertext, ComputeKey, DynamicRecord, EncryptionToolkit, Execution, ExecutionRequest, ExecutionResponse, Field, GraphKey, Group, I128, I16, I32, I64, I8, KeyPair, Metadata, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramImports, ProgramManager, Proof, ProvingKey, ProvingRequest, QueryOption, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, Value, VerifyingKey, ViewKey, getOrInitConsensusVersionTestHeights, initSync, initThreadPool, runRayonThread, setWasmLogLevel, snarkVerify, snarkVerifyBatch, stringToField, verifyFunctionExecution };
19737
+ export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, CallbackQuery, Ciphertext, ComputeKey, DynamicRecord, EncryptionToolkit, Execution, ExecutionRequest, ExecutionResponse, Field, GraphKey, Group, I128, I16, I32, I64, I8, KeyPair, Metadata, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramImports, ProgramManager, Proof, ProvingKey, ProvingRequest, QueryOption, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, Value, VerifyingKey, ViewKey, getMaxProgramImports, getOrInitConsensusVersionTestHeights, initSync, initThreadPool, runRayonThread, setWasmLogLevel, snarkVerify, snarkVerifyBatch, stringToField, verifyFunctionExecution };
19721
19738
  //# sourceMappingURL=index.js.map