@provablehq/wasm 0.11.3 → 0.11.4

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,18 +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 a SNARK proof against a verifying key and public inputs.
14
- *
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
22
- */
23
- export function snarkVerify(verifying_key: VerifyingKey, inputs: Array<any>, proof: Proof): boolean;
24
12
  /**
25
13
  * Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
26
14
  *
@@ -33,6 +21,18 @@ export function snarkVerify(verifying_key: VerifyingKey, inputs: Array<any>, pro
33
21
  * @returns {boolean} True if the batch proof is valid, false otherwise
34
22
  */
35
23
  export function snarkVerifyBatch(verifying_keys: Array<any>, inputs: Array<any>, proof: Proof): boolean;
24
+ /**
25
+ * Verify a SNARK proof against a verifying key and public inputs.
26
+ *
27
+ * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
28
+ * It directly invokes the Varuna proof verification from snarkVM.
29
+ *
30
+ * @param {VerifyingKey} verifying_key The verifying key for the circuit
31
+ * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
32
+ * @param {Proof} proof The proof to verify
33
+ * @returns {boolean} True if the proof is valid, false otherwise
34
+ */
35
+ export function snarkVerify(verifying_key: VerifyingKey, inputs: Array<any>, proof: Proof): boolean;
36
36
  /**
37
37
  * Verify an execution. Executions with multiple transitions must have the program source code and
38
38
  * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
@@ -56,7 +56,7 @@ export function verifyFunctionExecution(execution: Execution, verifying_key: Ver
56
56
  * import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
57
57
  *
58
58
  * Set the consensus version heights.
59
- * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14");
59
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
60
60
  */
61
61
  export function getOrInitConsensusVersionTestHeights(heights?: string | null): Array<any>;
62
62
  export function stringToField(string: string): Field;
@@ -2894,6 +2894,20 @@ export class Program {
2894
2894
  * console.log(credits_functions === expected_functions); // Output should be "true"
2895
2895
  */
2896
2896
  getFunctions(): Array<any>;
2897
+ /**
2898
+ * Get the program's name (without the `.aleo` suffix) encoded as a field element.
2899
+ *
2900
+ * This is the same value as casting the program name identifier to a field on-chain
2901
+ * (e.g. `my_program.aleo` -> `Identifier("my_program") as field`), which is used as
2902
+ * the program id in dynamic dispatch calls such as `IARC20@(token_id)`.
2903
+ *
2904
+ * @example
2905
+ * const program = aleo_wasm.Program.getCreditsProgram();
2906
+ * const field = program.nameToField(); // Field encoding of "credits"
2907
+ *
2908
+ * @returns {Field} The program name as a field element
2909
+ */
2910
+ nameToField(): Field;
2897
2911
  /**
2898
2912
  * Get the external call graph reachable from a specific entry function.
2899
2913
  *
@@ -3042,6 +3056,39 @@ export class Program {
3042
3056
  * @returns {Address} The address of the program
3043
3057
  */
3044
3058
  address(): Address;
3059
+ /**
3060
+ * Determine if the program implements the ARC-20 fungible token interface (IARC20).
3061
+ *
3062
+ * This checks that the program defines a `Token` record with an `amount: u128` entry
3063
+ * (additional entries are permitted, per the interface's open record definition) and
3064
+ * that every function and view function required by ARC-20 is present with the exact
3065
+ * input and output signature defined by the standard.
3066
+ *
3067
+ * @see https://github.com/ProvableHQ/ARCs/blob/master/arc-0020/README.md
3068
+ *
3069
+ * @returns {boolean} True if the program implements the ARC-20 token interface
3070
+ */
3071
+ isArc20(): boolean;
3072
+ /**
3073
+ * Determine if the program implements the ARC-22 compliant token interface (IARC22).
3074
+ *
3075
+ * This checks that the program defines `Token` and `ComplianceRecord` records with the
3076
+ * entries required by the standard (additional entries are permitted, per the
3077
+ * interface's open record definitions), and that every function and view function
3078
+ * required by ARC-22 is present with the exact input and output signature defined by
3079
+ * the standard. The `MerkleProof` struct used by the private transfer functions may be
3080
+ * declared locally (in which case its shape must match the standard exactly) or
3081
+ * imported from another program such as a freeze list registry.
3082
+ *
3083
+ * Note: this checks the token interface (IARC22) only. The freeze list registry
3084
+ * interface (IARC22Freezelist) is typically implemented by a separate program and is
3085
+ * not required for a token program to be considered ARC-22 compliant.
3086
+ *
3087
+ * @see https://github.com/ProvableHQ/ARCs/blob/master/arc-0022/README.md
3088
+ *
3089
+ * @returns {boolean} True if the program implements the ARC-22 token interface
3090
+ */
3091
+ isArc22(): boolean;
3045
3092
  /**
3046
3093
  * Determine equality with another program
3047
3094
  *
Binary file
@@ -321,26 +321,25 @@ function addBorrowedObject(obj) {
321
321
  return stack_pointer;
322
322
  }
323
323
  /**
324
- * Verify a SNARK proof against a verifying key and public inputs.
324
+ * Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
325
325
  *
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.
326
+ * This function verifies a batch proof produced by Aleo programs that may not be deployed on chain.
327
+ * Each verifying key is paired with one or more sets of public inputs (instances).
328
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
333
- * @param {VerifyingKey} verifying_key
329
+ * @param {Array<string>} verifying_keys Array of verifying key strings, one per circuit
330
+ * @param {Array<Array<Array<string>>>} inputs 3D array of field element strings [circuit_idx][instance_idx][field_idx]
331
+ * @param {Proof} proof The batch proof to verify
332
+ * @returns {boolean} True if the batch proof is valid, false otherwise
333
+ * @param {Array<any>} verifying_keys
334
334
  * @param {Array<any>} inputs
335
335
  * @param {Proof} proof
336
336
  * @returns {boolean}
337
337
  */
338
- function snarkVerify(verifying_key, inputs, proof) {
338
+ function snarkVerifyBatch(verifying_keys, inputs, proof) {
339
339
  try {
340
340
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
341
- _assertClass(verifying_key, VerifyingKey);
342
341
  _assertClass(proof, Proof);
343
- wasm$1.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
342
+ wasm$1.snarkVerifyBatch(retptr, addHeapObject(verifying_keys), addHeapObject(inputs), proof.__wbg_ptr);
344
343
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
345
344
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
346
345
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -354,25 +353,26 @@ function snarkVerify(verifying_key, inputs, proof) {
354
353
  }
355
354
 
356
355
  /**
357
- * Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
356
+ * Verify a SNARK proof against a verifying key and public inputs.
358
357
  *
359
- * This function verifies a batch proof produced by Aleo programs that may not be deployed on chain.
360
- * Each verifying key is paired with one or more sets of public inputs (instances).
358
+ * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
359
+ * It directly invokes the Varuna proof verification from snarkVM.
361
360
  *
362
- * @param {Array<string>} verifying_keys Array of verifying key strings, one per circuit
363
- * @param {Array<Array<Array<string>>>} inputs 3D array of field element strings [circuit_idx][instance_idx][field_idx]
364
- * @param {Proof} proof The batch proof to verify
365
- * @returns {boolean} True if the batch proof is valid, false otherwise
366
- * @param {Array<any>} verifying_keys
361
+ * @param {VerifyingKey} verifying_key The verifying key for the circuit
362
+ * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
363
+ * @param {Proof} proof The proof to verify
364
+ * @returns {boolean} True if the proof is valid, false otherwise
365
+ * @param {VerifyingKey} verifying_key
367
366
  * @param {Array<any>} inputs
368
367
  * @param {Proof} proof
369
368
  * @returns {boolean}
370
369
  */
371
- function snarkVerifyBatch(verifying_keys, inputs, proof) {
370
+ function snarkVerify(verifying_key, inputs, proof) {
372
371
  try {
373
372
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
373
+ _assertClass(verifying_key, VerifyingKey);
374
374
  _assertClass(proof, Proof);
375
- wasm$1.snarkVerifyBatch(retptr, addHeapObject(verifying_keys), addHeapObject(inputs), proof.__wbg_ptr);
375
+ wasm$1.snarkVerify(retptr, verifying_key.__wbg_ptr, addHeapObject(inputs), proof.__wbg_ptr);
376
376
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
377
377
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
378
378
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -442,7 +442,7 @@ function verifyFunctionExecution(execution, verifying_key, program, function_id,
442
442
  * import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
443
443
  *
444
444
  * Set the consensus version heights.
445
- * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14");
445
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
446
446
  * @param {string | null} [heights]
447
447
  * @returns {Array<any>}
448
448
  */
@@ -494,16 +494,16 @@ function getArrayJsValueFromWasm0(ptr, len) {
494
494
  }
495
495
  return result;
496
496
  }
497
- function __wasm_bindgen_func_elem_7384(arg0, arg1) {
498
- wasm$1.__wasm_bindgen_func_elem_7384(arg0, arg1);
497
+ function __wasm_bindgen_func_elem_7392(arg0, arg1) {
498
+ wasm$1.__wasm_bindgen_func_elem_7392(arg0, arg1);
499
499
  }
500
500
 
501
- function __wasm_bindgen_func_elem_8758(arg0, arg1, arg2) {
502
- wasm$1.__wasm_bindgen_func_elem_8758(arg0, arg1, addHeapObject(arg2));
501
+ function __wasm_bindgen_func_elem_8765(arg0, arg1, arg2) {
502
+ wasm$1.__wasm_bindgen_func_elem_8765(arg0, arg1, addHeapObject(arg2));
503
503
  }
504
504
 
505
- function __wasm_bindgen_func_elem_7657(arg0, arg1, arg2, arg3) {
506
- wasm$1.__wasm_bindgen_func_elem_7657(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
505
+ function __wasm_bindgen_func_elem_7664(arg0, arg1, arg2, arg3) {
506
+ wasm$1.__wasm_bindgen_func_elem_7664(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
507
507
  }
508
508
 
509
509
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -10020,6 +10020,35 @@ class Program {
10020
10020
  const ret = wasm$1.program_getFunctions(this.__wbg_ptr);
10021
10021
  return takeObject(ret);
10022
10022
  }
10023
+ /**
10024
+ * Get the program's name (without the `.aleo` suffix) encoded as a field element.
10025
+ *
10026
+ * This is the same value as casting the program name identifier to a field on-chain
10027
+ * (e.g. `my_program.aleo` -> `Identifier("my_program") as field`), which is used as
10028
+ * the program id in dynamic dispatch calls such as `IARC20@(token_id)`.
10029
+ *
10030
+ * @example
10031
+ * const program = aleo_wasm.Program.getCreditsProgram();
10032
+ * const field = program.nameToField(); // Field encoding of "credits"
10033
+ *
10034
+ * @returns {Field} The program name as a field element
10035
+ * @returns {Field}
10036
+ */
10037
+ nameToField() {
10038
+ try {
10039
+ const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
10040
+ wasm$1.program_nameToField(retptr, this.__wbg_ptr);
10041
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
10042
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
10043
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
10044
+ if (r2) {
10045
+ throw takeObject(r1);
10046
+ }
10047
+ return Field.__wrap(r0);
10048
+ } finally {
10049
+ wasm$1.__wbindgen_add_to_stack_pointer(16);
10050
+ }
10051
+ }
10023
10052
  /**
10024
10053
  * Get the external call graph reachable from a specific entry function.
10025
10054
  *
@@ -10275,6 +10304,47 @@ class Program {
10275
10304
  wasm$1.__wbindgen_add_to_stack_pointer(16);
10276
10305
  }
10277
10306
  }
10307
+ /**
10308
+ * Determine if the program implements the ARC-20 fungible token interface (IARC20).
10309
+ *
10310
+ * This checks that the program defines a `Token` record with an `amount: u128` entry
10311
+ * (additional entries are permitted, per the interface's open record definition) and
10312
+ * that every function and view function required by ARC-20 is present with the exact
10313
+ * input and output signature defined by the standard.
10314
+ *
10315
+ * @see https://github.com/ProvableHQ/ARCs/blob/master/arc-0020/README.md
10316
+ *
10317
+ * @returns {boolean} True if the program implements the ARC-20 token interface
10318
+ * @returns {boolean}
10319
+ */
10320
+ isArc20() {
10321
+ const ret = wasm$1.program_isArc20(this.__wbg_ptr);
10322
+ return ret !== 0;
10323
+ }
10324
+ /**
10325
+ * Determine if the program implements the ARC-22 compliant token interface (IARC22).
10326
+ *
10327
+ * This checks that the program defines `Token` and `ComplianceRecord` records with the
10328
+ * entries required by the standard (additional entries are permitted, per the
10329
+ * interface's open record definitions), and that every function and view function
10330
+ * required by ARC-22 is present with the exact input and output signature defined by
10331
+ * the standard. The `MerkleProof` struct used by the private transfer functions may be
10332
+ * declared locally (in which case its shape must match the standard exactly) or
10333
+ * imported from another program such as a freeze list registry.
10334
+ *
10335
+ * Note: this checks the token interface (IARC22) only. The freeze list registry
10336
+ * interface (IARC22Freezelist) is typically implemented by a separate program and is
10337
+ * not required for a token program to be considered ARC-22 compliant.
10338
+ *
10339
+ * @see https://github.com/ProvableHQ/ARCs/blob/master/arc-0022/README.md
10340
+ *
10341
+ * @returns {boolean} True if the program implements the ARC-22 token interface
10342
+ * @returns {boolean}
10343
+ */
10344
+ isArc22() {
10345
+ const ret = wasm$1.program_isArc22(this.__wbg_ptr);
10346
+ return ret !== 0;
10347
+ }
10278
10348
  /**
10279
10349
  * Determine equality with another program
10280
10350
  *
@@ -19238,7 +19308,7 @@ function __wbg_get_imports(memory) {
19238
19308
  const ret = getObject(arg0).length;
19239
19309
  return ret;
19240
19310
  };
19241
- imports.wbg.__wbg_log_0eaae399732a802e = function(arg0, arg1) {
19311
+ imports.wbg.__wbg_log_4507b73801c06872 = function(arg0, arg1) {
19242
19312
  console.log(getStringFromWasm0(arg0, arg1));
19243
19313
  };
19244
19314
  imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
@@ -19256,7 +19326,7 @@ function __wbg_get_imports(memory) {
19256
19326
  const a = state0.a;
19257
19327
  state0.a = 0;
19258
19328
  try {
19259
- return __wasm_bindgen_func_elem_7657(a, state0.b, arg0, arg1);
19329
+ return __wasm_bindgen_func_elem_7664(a, state0.b, arg0, arg1);
19260
19330
  } finally {
19261
19331
  state0.a = a;
19262
19332
  }
@@ -19428,7 +19498,7 @@ function __wbg_get_imports(memory) {
19428
19498
  const ret = Signature.__wrap(arg0);
19429
19499
  return addHeapObject(ret);
19430
19500
  };
19431
- imports.wbg.__wbg_spawnWorker_3f95ae6c0630b765 = function(arg0, arg1, arg2, arg3) {
19501
+ imports.wbg.__wbg_spawnWorker_6197e35077a8baba = function(arg0, arg1, arg2, arg3) {
19432
19502
  const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
19433
19503
  return addHeapObject(ret);
19434
19504
  };
@@ -19512,7 +19582,7 @@ function __wbg_get_imports(memory) {
19512
19582
  };
19513
19583
  imports.wbg.__wbindgen_cast_073ddd2b87fab8ab = function(arg0, arg1) {
19514
19584
  // Cast intrinsic for `Closure(Closure { dtor_idx: 360, function: Function { arguments: [], shim_idx: 467, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19515
- const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7383, __wasm_bindgen_func_elem_7384);
19585
+ const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7391, __wasm_bindgen_func_elem_7392);
19516
19586
  return addHeapObject(ret);
19517
19587
  };
19518
19588
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
@@ -19522,7 +19592,7 @@ function __wbg_get_imports(memory) {
19522
19592
  };
19523
19593
  imports.wbg.__wbindgen_cast_263b62405be3c669 = function(arg0, arg1) {
19524
19594
  // Cast intrinsic for `Closure(Closure { dtor_idx: 360, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 361, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19525
- const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7383, __wasm_bindgen_func_elem_8758);
19595
+ const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7391, __wasm_bindgen_func_elem_8765);
19526
19596
  return addHeapObject(ret);
19527
19597
  };
19528
19598
  imports.wbg.__wbindgen_cast_2ddd8a25ff58642a = function(arg0, arg1) {
@@ -19537,7 +19607,7 @@ function __wbg_get_imports(memory) {
19537
19607
  };
19538
19608
  imports.wbg.__wbindgen_cast_5cd376b701f56c0e = function(arg0, arg1) {
19539
19609
  // Cast intrinsic for `Closure(Closure { dtor_idx: 360, function: Function { arguments: [Externref], shim_idx: 361, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
19540
- const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7383, __wasm_bindgen_func_elem_8758);
19610
+ const ret = makeMutClosure(arg0, arg1, wasm$1.__wasm_bindgen_func_elem_7391, __wasm_bindgen_func_elem_8765);
19541
19611
  return addHeapObject(ret);
19542
19612
  };
19543
19613
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {