@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.
@@ -9,20 +9,6 @@ export function initThreadPool(url: URL, num_threads: number): Promise<void>;
9
9
  * Values above 4 are clamped to debug.
10
10
  */
11
11
  export function setWasmLogLevel(level: number): void;
12
- /**
13
- * Verify an execution. Executions with multiple transitions must have the program source code and
14
- * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
15
- * not verify that the state root of the execution is included in the Aleo Network ledger.
16
- *
17
- * @param {Execution} execution The function execution to verify
18
- * @param {VerifyingKey} verifying_key The verifying key for the function
19
- * @param {Program} program The program that the function execution belongs to
20
- * @param {String} function_id The name of the function that was executed
21
- * @param {Object} imports The imports for the program in the form of { "program_id.aleo":"source code", ... }
22
- * @param {Object} import_verifying_keys The verifying keys for the imports in the form of { "program_id.aleo": [["function, "verifying_key"], ...], ...}
23
- * @returns {boolean} True if the execution is valid, false otherwise
24
- */
25
- export function verifyFunctionExecution(execution: Execution, verifying_key: VerifyingKey, program: Program, function_id: string, imports: object | null | undefined, imported_verifying_keys: object | null | undefined, block_height: number, program_imports?: ProgramImports | null): boolean;
26
12
  /**
27
13
  * Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
28
14
  *
@@ -47,7 +33,20 @@ export function snarkVerifyBatch(verifying_keys: Array<any>, inputs: Array<any>,
47
33
  * @returns {boolean} True if the proof is valid, false otherwise
48
34
  */
49
35
  export function snarkVerify(verifying_key: VerifyingKey, inputs: Array<any>, proof: Proof): boolean;
50
- export function stringToField(string: string): Field;
36
+ /**
37
+ * Verify an execution. Executions with multiple transitions must have the program source code and
38
+ * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
39
+ * not verify that the state root of the execution is included in the Aleo Network ledger.
40
+ *
41
+ * @param {Execution} execution The function execution to verify
42
+ * @param {VerifyingKey} verifying_key The verifying key for the function
43
+ * @param {Program} program The program that the function execution belongs to
44
+ * @param {String} function_id The name of the function that was executed
45
+ * @param {Object} imports The imports for the program in the form of { "program_id.aleo":"source code", ... }
46
+ * @param {Object} import_verifying_keys The verifying keys for the imports in the form of { "program_id.aleo": [["function, "verifying_key"], ...], ...}
47
+ * @returns {boolean} True if the execution is valid, false otherwise
48
+ */
49
+ export function verifyFunctionExecution(execution: Execution, verifying_key: VerifyingKey, program: Program, function_id: string, imports: object | null | undefined, imported_verifying_keys: object | null | undefined, block_height: number, program_imports?: ProgramImports | null): boolean;
51
50
  /**
52
51
  * Set test consensus version heights for testing.
53
52
  *
@@ -57,9 +56,22 @@ export function stringToField(string: string): Field;
57
56
  * import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
58
57
  *
59
58
  * Set the consensus version heights.
60
- * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
59
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17");
61
60
  */
62
61
  export function getOrInitConsensusVersionTestHeights(heights?: string | null): Array<any>;
62
+ /**
63
+ * Returns the maximum number of imports allowed in a program by the
64
+ * snarkVM network implementation this SDK was built against.
65
+ *
66
+ * @returns {number} The maximum number of program imports.
67
+ *
68
+ * @example
69
+ * import { getMaxProgramImports } from '@provablehq/sdk';
70
+ *
71
+ * const maxImports = getMaxProgramImports();
72
+ */
73
+ export function getMaxProgramImports(): number;
74
+ export function stringToField(string: string): Field;
63
75
  /**
64
76
  * Public address of an Aleo account
65
77
  */
Binary file
@@ -320,54 +320,6 @@ function addBorrowedObject(obj) {
320
320
  heap[--stack_pointer] = obj;
321
321
  return stack_pointer;
322
322
  }
323
- /**
324
- * Verify an execution. Executions with multiple transitions must have the program source code and
325
- * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
326
- * not verify that the state root of the execution is included in the Aleo Network ledger.
327
- *
328
- * @param {Execution} execution The function execution to verify
329
- * @param {VerifyingKey} verifying_key The verifying key for the function
330
- * @param {Program} program The program that the function execution belongs to
331
- * @param {String} function_id The name of the function that was executed
332
- * @param {Object} imports The imports for the program in the form of { "program_id.aleo":"source code", ... }
333
- * @param {Object} import_verifying_keys The verifying keys for the imports in the form of { "program_id.aleo": [["function, "verifying_key"], ...], ...}
334
- * @returns {boolean} True if the execution is valid, false otherwise
335
- * @param {Execution} execution
336
- * @param {VerifyingKey} verifying_key
337
- * @param {Program} program
338
- * @param {string} function_id
339
- * @param {object | null | undefined} imports
340
- * @param {object | null | undefined} imported_verifying_keys
341
- * @param {number} block_height
342
- * @param {ProgramImports | null} [program_imports]
343
- * @returns {boolean}
344
- */
345
- function verifyFunctionExecution(execution, verifying_key, program, function_id, imports, imported_verifying_keys, block_height, program_imports) {
346
- try {
347
- const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
348
- _assertClass(execution, Execution);
349
- _assertClass(verifying_key, VerifyingKey);
350
- _assertClass(program, Program);
351
- const ptr0 = passStringToWasm0(function_id, wasm$1.__wbindgen_export, wasm$1.__wbindgen_export2);
352
- const len0 = WASM_VECTOR_LEN;
353
- let ptr1 = 0;
354
- if (!isLikeNone(program_imports)) {
355
- _assertClass(program_imports, ProgramImports);
356
- ptr1 = program_imports.__destroy_into_raw();
357
- }
358
- wasm$1.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);
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$1.__wbindgen_add_to_stack_pointer(16);
368
- }
369
- }
370
-
371
323
  /**
372
324
  * Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
373
325
  *
@@ -434,22 +386,48 @@ function snarkVerify(verifying_key, inputs, proof) {
434
386
  }
435
387
 
436
388
  /**
437
- * @param {string} string
438
- * @returns {Field}
389
+ * Verify an execution. Executions with multiple transitions must have the program source code and
390
+ * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
391
+ * not verify that the state root of the execution is included in the Aleo Network ledger.
392
+ *
393
+ * @param {Execution} execution The function execution to verify
394
+ * @param {VerifyingKey} verifying_key The verifying key for the function
395
+ * @param {Program} program The program that the function execution belongs to
396
+ * @param {String} function_id The name of the function that was executed
397
+ * @param {Object} imports The imports for the program in the form of { "program_id.aleo":"source code", ... }
398
+ * @param {Object} import_verifying_keys The verifying keys for the imports in the form of { "program_id.aleo": [["function, "verifying_key"], ...], ...}
399
+ * @returns {boolean} True if the execution is valid, false otherwise
400
+ * @param {Execution} execution
401
+ * @param {VerifyingKey} verifying_key
402
+ * @param {Program} program
403
+ * @param {string} function_id
404
+ * @param {object | null | undefined} imports
405
+ * @param {object | null | undefined} imported_verifying_keys
406
+ * @param {number} block_height
407
+ * @param {ProgramImports | null} [program_imports]
408
+ * @returns {boolean}
439
409
  */
440
- function stringToField(string) {
410
+ function verifyFunctionExecution(execution, verifying_key, program, function_id, imports, imported_verifying_keys, block_height, program_imports) {
441
411
  try {
442
412
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
443
- const ptr0 = passStringToWasm0(string, wasm$1.__wbindgen_export, wasm$1.__wbindgen_export2);
413
+ _assertClass(execution, Execution);
414
+ _assertClass(verifying_key, VerifyingKey);
415
+ _assertClass(program, Program);
416
+ const ptr0 = passStringToWasm0(function_id, wasm$1.__wbindgen_export, wasm$1.__wbindgen_export2);
444
417
  const len0 = WASM_VECTOR_LEN;
445
- wasm$1.stringToField(retptr, ptr0, len0);
418
+ let ptr1 = 0;
419
+ if (!isLikeNone(program_imports)) {
420
+ _assertClass(program_imports, ProgramImports);
421
+ ptr1 = program_imports.__destroy_into_raw();
422
+ }
423
+ wasm$1.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);
446
424
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
447
425
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
448
426
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
449
427
  if (r2) {
450
428
  throw takeObject(r1);
451
429
  }
452
- return Field.__wrap(r0);
430
+ return r0 !== 0;
453
431
  } finally {
454
432
  wasm$1.__wbindgen_add_to_stack_pointer(16);
455
433
  }
@@ -464,7 +442,7 @@ function stringToField(string) {
464
442
  * import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
465
443
  *
466
444
  * Set the consensus version heights.
467
- * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
445
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17");
468
446
  * @param {string | null} [heights]
469
447
  * @returns {Array<any>}
470
448
  */
@@ -475,6 +453,45 @@ function getOrInitConsensusVersionTestHeights(heights) {
475
453
  return takeObject(ret);
476
454
  }
477
455
 
456
+ /**
457
+ * Returns the maximum number of imports allowed in a program by the
458
+ * snarkVM network implementation this SDK was built against.
459
+ *
460
+ * @returns {number} The maximum number of program imports.
461
+ *
462
+ * @example
463
+ * import { getMaxProgramImports } from '@provablehq/sdk';
464
+ *
465
+ * const maxImports = getMaxProgramImports();
466
+ * @returns {number}
467
+ */
468
+ function getMaxProgramImports() {
469
+ const ret = wasm$1.getMaxProgramImports();
470
+ return ret >>> 0;
471
+ }
472
+
473
+ /**
474
+ * @param {string} string
475
+ * @returns {Field}
476
+ */
477
+ function stringToField(string) {
478
+ try {
479
+ const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
480
+ const ptr0 = passStringToWasm0(string, wasm$1.__wbindgen_export, wasm$1.__wbindgen_export2);
481
+ const len0 = WASM_VECTOR_LEN;
482
+ wasm$1.stringToField(retptr, ptr0, len0);
483
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
484
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
485
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
486
+ if (r2) {
487
+ throw takeObject(r1);
488
+ }
489
+ return Field.__wrap(r0);
490
+ } finally {
491
+ wasm$1.__wbindgen_add_to_stack_pointer(16);
492
+ }
493
+ }
494
+
478
495
  function passArrayJsValueToWasm0(array, malloc) {
479
496
  const ptr = malloc(array.length * 4, 4) >>> 0;
480
497
  const mem = getDataViewMemory0();
@@ -494,16 +511,16 @@ function getArrayJsValueFromWasm0(ptr, len) {
494
511
  }
495
512
  return result;
496
513
  }
497
- function __wasm_bindgen_func_elem_8765(arg0, arg1, arg2) {
498
- wasm$1.__wasm_bindgen_func_elem_8765(arg0, arg1, addHeapObject(arg2));
514
+ function __wasm_bindgen_func_elem_8910(arg0, arg1, arg2) {
515
+ wasm$1.__wasm_bindgen_func_elem_8910(arg0, arg1, addHeapObject(arg2));
499
516
  }
500
517
 
501
- function __wasm_bindgen_func_elem_7397(arg0, arg1) {
502
- wasm$1.__wasm_bindgen_func_elem_7397(arg0, arg1);
518
+ function __wasm_bindgen_func_elem_7471(arg0, arg1) {
519
+ wasm$1.__wasm_bindgen_func_elem_7471(arg0, arg1);
503
520
  }
504
521
 
505
- function __wasm_bindgen_func_elem_7669(arg0, arg1, arg2, arg3) {
506
- wasm$1.__wasm_bindgen_func_elem_7669(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
522
+ function __wasm_bindgen_func_elem_7743(arg0, arg1, arg2, arg3) {
523
+ wasm$1.__wasm_bindgen_func_elem_7743(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
507
524
  }
508
525
 
509
526
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -19308,7 +19325,7 @@ function __wbg_get_imports(memory) {
19308
19325
  const ret = getObject(arg0).length;
19309
19326
  return ret;
19310
19327
  };
19311
- imports.wbg.__wbg_log_4507b73801c06872 = function(arg0, arg1) {
19328
+ imports.wbg.__wbg_log_27d73c032446232d = function(arg0, arg1) {
19312
19329
  console.log(getStringFromWasm0(arg0, arg1));
19313
19330
  };
19314
19331
  imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
@@ -19326,7 +19343,7 @@ function __wbg_get_imports(memory) {
19326
19343
  const a = state0.a;
19327
19344
  state0.a = 0;
19328
19345
  try {
19329
- return __wasm_bindgen_func_elem_7669(a, state0.b, arg0, arg1);
19346
+ return __wasm_bindgen_func_elem_7743(a, state0.b, arg0, arg1);
19330
19347
  } finally {
19331
19348
  state0.a = a;
19332
19349
  }
@@ -19498,7 +19515,7 @@ function __wbg_get_imports(memory) {
19498
19515
  const ret = Signature.__wrap(arg0);
19499
19516
  return addHeapObject(ret);
19500
19517
  };
19501
- imports.wbg.__wbg_spawnWorker_6197e35077a8baba = function(arg0, arg1, arg2, arg3) {
19518
+ imports.wbg.__wbg_spawnWorker_e00cacfddf7ee0c0 = function(arg0, arg1, arg2, arg3) {
19502
19519
  const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
19503
19520
  return addHeapObject(ret);
19504
19521
  };
@@ -19580,6 +19597,16 @@ function __wbg_get_imports(memory) {
19580
19597
  const ret = Atomics.waitAsync(getObject(arg0), arg1 >>> 0, arg2);
19581
19598
  return addHeapObject(ret);
19582
19599
  };
19600
+ imports.wbg.__wbindgen_cast_01d4af51d575cfe0 = function(arg0, arg1) {
19601
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 388, function: Function { arguments: [], shim_idx: 495, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19602
+ const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7470, __wasm_bindgen_func_elem_7471);
19603
+ return addHeapObject(ret);
19604
+ };
19605
+ imports.wbg.__wbindgen_cast_13f76f7c228ed64d = function(arg0, arg1) {
19606
+ // 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`.
19607
+ const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7470, __wasm_bindgen_func_elem_8910);
19608
+ return addHeapObject(ret);
19609
+ };
19583
19610
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
19584
19611
  // Cast intrinsic for `Ref(String) -> Externref`.
19585
19612
  const ret = getStringFromWasm0(arg0, arg1);
@@ -19590,31 +19617,21 @@ function __wbg_get_imports(memory) {
19590
19617
  const ret = (BigInt.asUintN(64, arg0) | (arg1 << BigInt(64)));
19591
19618
  return addHeapObject(ret);
19592
19619
  };
19620
+ imports.wbg.__wbindgen_cast_42ef79217ed4073d = function(arg0, arg1) {
19621
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 388, function: Function { arguments: [Externref], shim_idx: 389, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19622
+ const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7470, __wasm_bindgen_func_elem_8910);
19623
+ return addHeapObject(ret);
19624
+ };
19593
19625
  imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
19594
19626
  // Cast intrinsic for `U64 -> Externref`.
19595
19627
  const ret = BigInt.asUintN(64, arg0);
19596
19628
  return addHeapObject(ret);
19597
19629
  };
19598
- imports.wbg.__wbindgen_cast_4a64cbb5b17898c9 = function(arg0, arg1) {
19599
- // Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [Externref], shim_idx: 359, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19600
- const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7396, __wasm_bindgen_func_elem_8765);
19601
- return addHeapObject(ret);
19602
- };
19603
- imports.wbg.__wbindgen_cast_65bbaf572cb463ed = function(arg0, arg1) {
19604
- // 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`.
19605
- const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7396, __wasm_bindgen_func_elem_8765);
19606
- return addHeapObject(ret);
19607
- };
19608
19630
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
19609
19631
  // Cast intrinsic for `I64 -> Externref`.
19610
19632
  const ret = arg0;
19611
19633
  return addHeapObject(ret);
19612
19634
  };
19613
- imports.wbg.__wbindgen_cast_aca65e91b5ef2a91 = function(arg0, arg1) {
19614
- // Cast intrinsic for `Closure(Closure { dtor_idx: 358, function: Function { arguments: [], shim_idx: 467, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19615
- const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7396, __wasm_bindgen_func_elem_7397);
19616
- return addHeapObject(ret);
19617
- };
19618
19635
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
19619
19636
  // Cast intrinsic for `F64 -> Externref`.
19620
19637
  const ret = arg0;
@@ -19767,6 +19784,7 @@ var exports$1$1 = /*#__PURE__*/Object.freeze({
19767
19784
  VerifyingKey: VerifyingKey,
19768
19785
  ViewKey: ViewKey,
19769
19786
  default: __wbg_init,
19787
+ getMaxProgramImports: getMaxProgramImports,
19770
19788
  getOrInitConsensusVersionTestHeights: getOrInitConsensusVersionTestHeights,
19771
19789
  initSync: initSync$1,
19772
19790
  initThreadPool: initThreadPool,