@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.
@@ -1,7 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export function runRayonThread(receiver: number): void;
4
- export function initThreadPool(url: URL, num_threads: number): Promise<void>;
5
4
  /**
6
5
  * Set the WASM log level from JS. Called automatically by the SDK's
7
6
  * `setLogLevel(level)` to keep TS and WASM logging in sync.
@@ -9,20 +8,19 @@ export function initThreadPool(url: URL, num_threads: number): Promise<void>;
9
8
  * Values above 4 are clamped to debug.
10
9
  */
11
10
  export function setWasmLogLevel(level: number): void;
11
+ export function initThreadPool(url: URL, num_threads: number): Promise<void>;
12
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.
13
+ * Verify a SNARK proof against a verifying key and public inputs.
16
14
  *
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
15
+ * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
16
+ * It directly invokes the Varuna proof verification from snarkVM.
17
+ *
18
+ * @param {VerifyingKey} verifying_key The verifying key for the circuit
19
+ * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
20
+ * @param {Proof} proof The proof to verify
21
+ * @returns {boolean} True if the proof is valid, false otherwise
24
22
  */
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;
23
+ export function snarkVerify(verifying_key: VerifyingKey, inputs: Array<any>, proof: Proof): boolean;
26
24
  /**
27
25
  * Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
28
26
  *
@@ -36,17 +34,31 @@ export function verifyFunctionExecution(execution: Execution, verifying_key: Ver
36
34
  */
37
35
  export function snarkVerifyBatch(verifying_keys: Array<any>, inputs: Array<any>, proof: Proof): boolean;
38
36
  /**
39
- * Verify a SNARK proof against a verifying key and public inputs.
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
40
  *
41
- * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
42
- * It directly invokes the Varuna proof verification from snarkVM.
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;
50
+ /**
51
+ * Returns the maximum number of imports allowed in a program by the
52
+ * snarkVM network implementation this SDK was built against.
43
53
  *
44
- * @param {VerifyingKey} verifying_key The verifying key for the circuit
45
- * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
46
- * @param {Proof} proof The proof to verify
47
- * @returns {boolean} True if the proof is valid, false otherwise
54
+ * @returns {number} The maximum number of program imports.
55
+ *
56
+ * @example
57
+ * import { getMaxProgramImports } from '@provablehq/sdk';
58
+ *
59
+ * const maxImports = getMaxProgramImports();
48
60
  */
49
- export function snarkVerify(verifying_key: VerifyingKey, inputs: Array<any>, proof: Proof): boolean;
61
+ export function getMaxProgramImports(): number;
50
62
  export function stringToField(string: string): Field;
51
63
  /**
52
64
  * Set test consensus version heights for testing.
Binary file
@@ -292,16 +292,6 @@ function runRayonThread(receiver) {
292
292
  wasm$1.runRayonThread(receiver);
293
293
  }
294
294
 
295
- /**
296
- * @param {URL} url
297
- * @param {number} num_threads
298
- * @returns {Promise<void>}
299
- */
300
- function initThreadPool(url, num_threads) {
301
- const ret = wasm$1.initThreadPool(addHeapObject(url), num_threads);
302
- return takeObject(ret);
303
- }
304
-
305
295
  /**
306
296
  * Set the WASM log level from JS. Called automatically by the SDK's
307
297
  * `setLogLevel(level)` to keep TS and WASM logging in sync.
@@ -313,6 +303,16 @@ function setWasmLogLevel(level) {
313
303
  wasm$1.setWasmLogLevel(level);
314
304
  }
315
305
 
306
+ /**
307
+ * @param {URL} url
308
+ * @param {number} num_threads
309
+ * @returns {Promise<void>}
310
+ */
311
+ function initThreadPool(url, num_threads) {
312
+ const ret = wasm$1.initThreadPool(addHeapObject(url), num_threads);
313
+ return takeObject(ret);
314
+ }
315
+
316
316
  let stack_pointer = 128;
317
317
 
318
318
  function addBorrowedObject(obj) {
@@ -321,41 +321,26 @@ function addBorrowedObject(obj) {
321
321
  return stack_pointer;
322
322
  }
323
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.
324
+ * Verify a SNARK proof against a verifying key and public inputs.
327
325
  *
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
326
+ * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
327
+ * It directly invokes the Varuna proof verification from snarkVM.
328
+ *
329
+ * @param {VerifyingKey} verifying_key The verifying key for the circuit
330
+ * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
331
+ * @param {Proof} proof The proof to verify
332
+ * @returns {boolean} True if the proof is valid, false otherwise
336
333
  * @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]
334
+ * @param {Array<any>} inputs
335
+ * @param {Proof} proof
343
336
  * @returns {boolean}
344
337
  */
345
- function verifyFunctionExecution(execution, verifying_key, program, function_id, imports, imported_verifying_keys, block_height, program_imports) {
338
+ function snarkVerify(verifying_key, inputs, proof) {
346
339
  try {
347
340
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
348
- _assertClass(execution, Execution);
349
341
  _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);
342
+ _assertClass(proof, Proof);
343
+ wasm$1.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
359
344
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
360
345
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
361
346
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -401,26 +386,41 @@ function snarkVerifyBatch(verifying_keys, inputs, proof) {
401
386
  }
402
387
 
403
388
  /**
404
- * Verify a SNARK proof against a verifying key and public inputs.
405
- *
406
- * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
407
- * It directly invokes the Varuna proof verification from snarkVM.
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.
408
392
  *
409
- * @param {VerifyingKey} verifying_key The verifying key for the circuit
410
- * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
411
- * @param {Proof} proof The proof to verify
412
- * @returns {boolean} True if the proof is valid, false otherwise
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
413
401
  * @param {VerifyingKey} verifying_key
414
- * @param {Array<any>} inputs
415
- * @param {Proof} proof
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]
416
408
  * @returns {boolean}
417
409
  */
418
- function snarkVerify(verifying_key, inputs, proof) {
410
+ function verifyFunctionExecution(execution, verifying_key, program, function_id, imports, imported_verifying_keys, block_height, program_imports) {
419
411
  try {
420
412
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
413
+ _assertClass(execution, Execution);
421
414
  _assertClass(verifying_key, VerifyingKey);
422
- _assertClass(proof, Proof);
423
- wasm$1.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
415
+ _assertClass(program, Program);
416
+ const ptr0 = passStringToWasm0(function_id, wasm$1.__wbindgen_export, wasm$1.__wbindgen_export2);
417
+ const len0 = WASM_VECTOR_LEN;
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);
424
424
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
425
425
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
426
426
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -433,6 +433,23 @@ function snarkVerify(verifying_key, inputs, proof) {
433
433
  }
434
434
  }
435
435
 
436
+ /**
437
+ * Returns the maximum number of imports allowed in a program by the
438
+ * snarkVM network implementation this SDK was built against.
439
+ *
440
+ * @returns {number} The maximum number of program imports.
441
+ *
442
+ * @example
443
+ * import { getMaxProgramImports } from '@provablehq/sdk';
444
+ *
445
+ * const maxImports = getMaxProgramImports();
446
+ * @returns {number}
447
+ */
448
+ function getMaxProgramImports() {
449
+ const ret = wasm$1.getMaxProgramImports();
450
+ return ret >>> 0;
451
+ }
452
+
436
453
  /**
437
454
  * @param {string} string
438
455
  * @returns {Field}
@@ -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_7393(arg0, arg1) {
515
+ wasm$1.__wasm_bindgen_func_elem_7393(arg0, arg1);
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_8766(arg0, arg1, arg2) {
519
+ wasm$1.__wasm_bindgen_func_elem_8766(arg0, arg1, addHeapObject(arg2));
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_7666(arg0, arg1, arg2, arg3) {
523
+ wasm$1.__wasm_bindgen_func_elem_7666(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_a530da429f854235 = 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_7666(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_ad641c7b32ebd520 = 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
  };
@@ -19597,12 +19614,12 @@ function __wbg_get_imports(memory) {
19597
19614
  };
19598
19615
  imports.wbg.__wbindgen_cast_4a64cbb5b17898c9 = function(arg0, arg1) {
19599
19616
  // 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);
19617
+ const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7392, __wasm_bindgen_func_elem_8766);
19601
19618
  return addHeapObject(ret);
19602
19619
  };
19603
19620
  imports.wbg.__wbindgen_cast_65bbaf572cb463ed = function(arg0, arg1) {
19604
19621
  // 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);
19622
+ const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7392, __wasm_bindgen_func_elem_8766);
19606
19623
  return addHeapObject(ret);
19607
19624
  };
19608
19625
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
@@ -19612,7 +19629,7 @@ function __wbg_get_imports(memory) {
19612
19629
  };
19613
19630
  imports.wbg.__wbindgen_cast_aca65e91b5ef2a91 = function(arg0, arg1) {
19614
19631
  // 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);
19632
+ const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7392, __wasm_bindgen_func_elem_7393);
19616
19633
  return addHeapObject(ret);
19617
19634
  };
19618
19635
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(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,