@provablehq/wasm 0.10.0-rc → 0.10.1

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.
@@ -2,6 +2,18 @@
2
2
  /* eslint-disable */
3
3
  export function runRayonThread(receiver: number): void;
4
4
  export function initThreadPool(url: URL, num_threads: number): Promise<void>;
5
+ /**
6
+ * Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
7
+ *
8
+ * This function verifies a batch proof produced by Aleo programs that may not be deployed on chain.
9
+ * Each verifying key is paired with one or more sets of public inputs (instances).
10
+ *
11
+ * @param {Array<string>} verifying_keys Array of verifying key strings, one per circuit
12
+ * @param {Array<Array<Array<string>>>} inputs 3D array of field element strings [circuit_idx][instance_idx][field_idx]
13
+ * @param {Proof} proof The batch proof to verify
14
+ * @returns {boolean} True if the batch proof is valid, false otherwise
15
+ */
16
+ export function snarkVerifyBatch(verifying_keys: Array<any>, inputs: Array<any>, proof: Proof): boolean;
5
17
  /**
6
18
  * Verify an execution. Executions with multiple transitions must have the program source code and
7
19
  * verifying keys of imported functions supplied from outside to correctly verify. Also, this does
@@ -16,12 +28,38 @@ export function initThreadPool(url: URL, num_threads: number): Promise<void>;
16
28
  * @returns {boolean} True if the execution is valid, false otherwise
17
29
  */
18
30
  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): boolean;
31
+ /**
32
+ * Verify a SNARK proof against a verifying key and public inputs.
33
+ *
34
+ * This function verifies a proof produced by an Aleo program that may not be deployed on chain.
35
+ * It directly invokes the Varuna proof verification from snarkVM.
36
+ *
37
+ * @param {VerifyingKey} verifying_key The verifying key for the circuit
38
+ * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
39
+ * @param {Proof} proof The proof to verify
40
+ * @returns {boolean} True if the proof is valid, false otherwise
41
+ */
42
+ export function snarkVerify(verifying_key: VerifyingKey, inputs: Array<any>, proof: Proof): boolean;
43
+ /**
44
+ * Set test consensus version heights for testing.
45
+ *
46
+ * @param {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
47
+ *
48
+ * @example
49
+ * import { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
50
+ *
51
+ * Set the consensus version heights.
52
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
53
+ */
54
+ export function getOrInitConsensusVersionTestHeights(heights?: string | null): Array<any>;
55
+ export function stringToField(string: string): Field;
19
56
  /**
20
57
  * Public address of an Aleo account
21
58
  */
22
59
  export class Address {
23
60
  private constructor();
24
61
  free(): void;
62
+ [Symbol.dispose](): void;
25
63
  /**
26
64
  * Get an address object from a group.
27
65
  *
@@ -43,9 +81,10 @@ export class Address {
43
81
  */
44
82
  static fromFields(fields: Array<any>): Address;
45
83
  /**
46
- * Create an aleo address object from a string representation of an address
84
+ * Create an aleo address object from a string representation of an address.
85
+ * The input is automatically lowercased before parsing.
47
86
  *
48
- * @param {string} address String representation of an addressm
87
+ * @param {string} address String representation of an address
49
88
  * @returns {Address} Address
50
89
  */
51
90
  static from_string(address: string): Address;
@@ -53,6 +92,14 @@ export class Address {
53
92
  * Get the left endian byte array representation of the address.
54
93
  */
55
94
  toBytesLe(): Uint8Array;
95
+ /**
96
+ * Cast the address to an I8 with lossy truncation.
97
+ */
98
+ toI8Lossy(): I8;
99
+ /**
100
+ * Cast the address to a U8 with lossy truncation.
101
+ */
102
+ toU8Lossy(): U8;
56
103
  /**
57
104
  * Get an address from a series of bits represented as a boolean array.
58
105
  *
@@ -61,10 +108,40 @@ export class Address {
61
108
  * @returns {Address} The address object.
62
109
  */
63
110
  static fromBitsLe(bits: Array<any>): Address;
111
+ /**
112
+ * Cast the address to an I16 with lossy truncation.
113
+ */
114
+ toI16Lossy(): I16;
115
+ /**
116
+ * Cast the address to an I32 with lossy truncation.
117
+ */
118
+ toI32Lossy(): I32;
119
+ /**
120
+ * Cast the address to an I64 with lossy truncation.
121
+ */
122
+ toI64Lossy(): I64;
64
123
  /**
65
124
  * Get the plaintext representation of the address.
66
125
  */
67
126
  toPlaintext(): Plaintext;
127
+ /**
128
+ * Get a string representation of an Aleo address object
129
+ *
130
+ * @returns {string} String representation of the address
131
+ */
132
+ toString(): string;
133
+ /**
134
+ * Cast the address to a U16 with lossy truncation.
135
+ */
136
+ toU16Lossy(): U16;
137
+ /**
138
+ * Cast the address to a U32 with lossy truncation.
139
+ */
140
+ toU32Lossy(): U32;
141
+ /**
142
+ * Cast the address to a U64 with lossy truncation.
143
+ */
144
+ toU64Lossy(): U64;
68
145
  /**
69
146
  * Get an address from a series of bytes.
70
147
  *
@@ -80,6 +157,25 @@ export class Address {
80
157
  * @returns {Address} Address corresponding to the view key
81
158
  */
82
159
  static from_view_key(view_key: ViewKey): Address;
160
+ /**
161
+ * Cast the address to an I128 with lossy truncation.
162
+ */
163
+ toI128Lossy(): I128;
164
+ /**
165
+ * Cast the address to a U128 with lossy truncation.
166
+ */
167
+ toU128Lossy(): U128;
168
+ /**
169
+ * Get the address of a program based on the program ID.
170
+ *
171
+ * @param {string} program_id The program ID string.
172
+ * @returns {Address} The address corresponding to the program ID.
173
+ */
174
+ static fromProgramId(program_id: string): Address;
175
+ /**
176
+ * Cast the address to a Scalar with lossy truncation (via x-coordinate).
177
+ */
178
+ toScalarLossy(): Scalar;
83
179
  /**
84
180
  * Derive an Aleo address from a compute key.
85
181
  *
@@ -93,6 +189,10 @@ export class Address {
93
189
  * @returns {Address} Address corresponding to the private key
94
190
  */
95
191
  static from_private_key(private_key: PrivateKey): Address;
192
+ /**
193
+ * Cast the address to a Boolean with lossy truncation (LSB of x-coordinate).
194
+ */
195
+ toBooleanLossy(): Boolean;
96
196
  /**
97
197
  * Verify a signature for a message signed by the address
98
198
  *
@@ -100,6 +200,19 @@ export class Address {
100
200
  * @returns {boolean} Boolean representing whether or not the signature is valid
101
201
  */
102
202
  verify(message: Uint8Array, signature: Signature): boolean;
203
+ /**
204
+ * Check if the input is a valid Aleo address.
205
+ * String addresses are automatically lowercased before validation.
206
+ *
207
+ * @param {string | Uint8Array} address - Either a string representation of an address
208
+ * or a Uint8Array of bytes in little-endian format.
209
+ * @returns {boolean} True if the input is a valid address, false otherwise.
210
+ */
211
+ static isValid(address: any): boolean;
212
+ /**
213
+ * Cast the address to a Field element (x-coordinate of the underlying group point).
214
+ */
215
+ toField(): Field;
103
216
  /**
104
217
  * Get the group representation of the address object.
105
218
  */
@@ -122,6 +235,7 @@ export class Address {
122
235
  export class Authorization {
123
236
  private constructor();
124
237
  free(): void;
238
+ [Symbol.dispose](): void;
125
239
  /**
126
240
  * Reconstructs an Authorization object from its string representation.
127
241
  *
@@ -144,6 +258,12 @@ export class Authorization {
144
258
  * @param {Uint8Array} bytes Left-endian bytes representing the Authorization.
145
259
  */
146
260
  static fromBytesLe(bytes: Uint8Array): Authorization;
261
+ /**
262
+ * Get the function name.
263
+ *
264
+ * @returns {string} The function name.
265
+ */
266
+ functionName(): string;
147
267
  /**
148
268
  * Returns `true` if the Authorization is for `credits.aleo/fee_public`.
149
269
  */
@@ -199,6 +319,7 @@ export class Authorization {
199
319
  }
200
320
  export class BHP1024 {
201
321
  free(): void;
322
+ [Symbol.dispose](): void;
202
323
  /**
203
324
  * Returns a BHP hash with an input hasher of 1024 bits.
204
325
  */
@@ -226,6 +347,7 @@ export class BHP1024 {
226
347
  }
227
348
  export class BHP256 {
228
349
  free(): void;
350
+ [Symbol.dispose](): void;
229
351
  /**
230
352
  * Returns a BHP hash with an input hasher of 256 bits.
231
353
  */
@@ -253,6 +375,7 @@ export class BHP256 {
253
375
  }
254
376
  export class BHP512 {
255
377
  free(): void;
378
+ [Symbol.dispose](): void;
256
379
  /**
257
380
  * Returns a BHP hash with an input hasher of 512 bits.
258
381
  */
@@ -280,6 +403,7 @@ export class BHP512 {
280
403
  }
281
404
  export class BHP768 {
282
405
  free(): void;
406
+ [Symbol.dispose](): void;
283
407
  /**
284
408
  * Returns a BHP hash with an input hasher of 768 bits.
285
409
  */
@@ -310,6 +434,11 @@ export class BHP768 {
310
434
  */
311
435
  export class Boolean {
312
436
  free(): void;
437
+ [Symbol.dispose](): void;
438
+ /**
439
+ * Cast the boolean to an Address (strict, via Group). Returns an error if conversion fails.
440
+ */
441
+ toAddress(): Address;
313
442
  /**
314
443
  * Get the left endian boolean array representation of the boolean element.
315
444
  */
@@ -334,6 +463,15 @@ export class Boolean {
334
463
  * Create a boolean element from a Uint8Array of left endian bytes.
335
464
  */
336
465
  static fromBytesLe(bytes: Uint8Array): Boolean;
466
+ /**
467
+ * Cast the boolean to a Group element (lossy, via Field with Elligator-2 fallback).
468
+ * This conversion never fails.
469
+ */
470
+ toGroupLossy(): Group;
471
+ /**
472
+ * Cast the boolean to an Address (lossy, via Group with Elligator-2 fallback).
473
+ */
474
+ toAddressLossy(): Address;
337
475
  /**
338
476
  * Logical OR.
339
477
  */
@@ -366,6 +504,14 @@ export class Boolean {
366
504
  * Clone the boolean element.
367
505
  */
368
506
  clone(): Boolean;
507
+ /**
508
+ * Cast the boolean to an I8 (false=0, true=1).
509
+ */
510
+ toI8(): I8;
511
+ /**
512
+ * Cast the boolean to a U8 (false=0, true=1).
513
+ */
514
+ toU8(): U8;
369
515
  /**
370
516
  * Check if one boolean element equals another.
371
517
  */
@@ -374,6 +520,51 @@ export class Boolean {
374
520
  * Generate a random boolean element.
375
521
  */
376
522
  static random(): Boolean;
523
+ /**
524
+ * Cast the boolean to an I16 (false=0, true=1).
525
+ */
526
+ toI16(): I16;
527
+ /**
528
+ * Cast the boolean to an I32 (false=0, true=1).
529
+ */
530
+ toI32(): I32;
531
+ /**
532
+ * Cast the boolean to an I64 (false=0, true=1).
533
+ */
534
+ toI64(): I64;
535
+ /**
536
+ * Cast the boolean to a U16 (false=0, true=1).
537
+ */
538
+ toU16(): U16;
539
+ /**
540
+ * Cast the boolean to a U32 (false=0, true=1).
541
+ */
542
+ toU32(): U32;
543
+ /**
544
+ * Cast the boolean to a U64 (false=0, true=1).
545
+ */
546
+ toU64(): U64;
547
+ /**
548
+ * Cast the boolean to an I128 (false=0, true=1).
549
+ */
550
+ toI128(): I128;
551
+ /**
552
+ * Cast the boolean to a U128 (false=0, true=1).
553
+ */
554
+ toU128(): U128;
555
+ /**
556
+ * Cast the boolean to a Field element (false=0, true=1). Lossless.
557
+ */
558
+ toField(): Field;
559
+ /**
560
+ * Cast the boolean to a Group element (strict, via Field x-coordinate recovery).
561
+ * Returns an error if the resulting field is not a valid x-coordinate.
562
+ */
563
+ toGroup(): Group;
564
+ /**
565
+ * Cast the boolean to a Scalar element (false=0, true=1). Lossless.
566
+ */
567
+ toScalar(): Scalar;
377
568
  /**
378
569
  * Returns the string representation of the boolean element.
379
570
  */
@@ -387,6 +578,7 @@ export class Boolean {
387
578
  export class Ciphertext {
388
579
  private constructor();
389
580
  free(): void;
581
+ [Symbol.dispose](): void;
390
582
  /**
391
583
  * Get the left endian boolean array representation of the bits of the ciphertext.
392
584
  */
@@ -488,6 +680,7 @@ export class Ciphertext {
488
680
  export class ComputeKey {
489
681
  private constructor();
490
682
  free(): void;
683
+ [Symbol.dispose](): void;
491
684
  /**
492
685
  * Create a new compute key from a private key.
493
686
  *
@@ -521,9 +714,72 @@ export class ComputeKey {
521
714
  */
522
715
  address(): Address;
523
716
  }
717
+ /**
718
+ * A fixed-size representation of an Aleo record. Like static records, a dynamic record
719
+ * contains an owner, nonce, and a version, but instead of storing the full data it only
720
+ * stores the Merkle root of the data, ensuring all dynamic records have a constant size.
721
+ */
722
+ export class DynamicRecord {
723
+ private constructor();
724
+ free(): void;
725
+ [Symbol.dispose](): void;
726
+ /**
727
+ * Returns the dynamic record as a little-endian bit array (JS Array of booleans).
728
+ */
729
+ toBitsLe(): Array<any>;
730
+ /**
731
+ * Creates a DynamicRecord from a RecordPlaintext.
732
+ */
733
+ static fromRecord(record: RecordPlaintext): DynamicRecord;
734
+ /**
735
+ * Creates a DynamicRecord from its string representation.
736
+ */
737
+ static fromString(s: string): DynamicRecord;
738
+ /**
739
+ * Serializes the dynamic record to a little-endian byte array (Uint8Array).
740
+ */
741
+ toBytesLe(): Uint8Array;
742
+ /**
743
+ * Deserializes a DynamicRecord from a little-endian byte array (Uint8Array).
744
+ */
745
+ static fromBytesLe(bytes: Uint8Array): DynamicRecord;
746
+ /**
747
+ * Returns the Merkle root of the record data as a Field.
748
+ */
749
+ root(): Field;
750
+ /**
751
+ * Returns the nonce of the record as a Group.
752
+ */
753
+ nonce(): Group;
754
+ /**
755
+ * Returns the owner address of the dynamic record.
756
+ */
757
+ owner(): Address;
758
+ /**
759
+ * Returns `true` if the dynamic record is a hiding variant (version != 0).
760
+ */
761
+ isHiding(): boolean;
762
+ /**
763
+ * Returns the dynamic record as an array of field elements.
764
+ */
765
+ toFields(): Array<any>;
766
+ /**
767
+ * Converts this DynamicRecord back to a RecordPlaintext.
768
+ * `owner_is_private` controls whether the owner field uses private or public visibility.
769
+ */
770
+ toRecord(owner_is_private: boolean): RecordPlaintext;
771
+ /**
772
+ * Returns the string representation of the dynamic record.
773
+ */
774
+ toString(): string;
775
+ }
776
+ /**
777
+ * EncryptionToolkit provides a set of functions for encrypting, decrypting, and generating individual view keys for records, transitions, and ciphertexts.
778
+ */
524
779
  export class EncryptionToolkit {
525
780
  private constructor();
526
781
  free(): void;
782
+ [Symbol.dispose](): void;
527
783
  /**
528
784
  * Generates a transition view key from the view key and the transition public key.
529
785
  *
@@ -533,6 +789,16 @@ export class EncryptionToolkit {
533
789
  * @returns {Field} The transition view key.
534
790
  */
535
791
  static generateTvk(view_key: ViewKey, tpk: Group): Field;
792
+ /**
793
+ * Decrypt the sender ciphertext associated with a record.
794
+ *
795
+ * @param {ViewKey} view_key View key associated with the record.
796
+ * @param {RecordPlaintext} record Record plaintext associated with a sender.
797
+ * @param {Field} sender_ciphertext Sender ciphertext associated with the record.
798
+ *
799
+ * @returns {Address} address of the sender.
800
+ */
801
+ static decryptSender(view_key: ViewKey, record: RecordPlaintext, sender_ciphertext: Field): Address;
536
802
  /**
537
803
  * Checks if a record ciphertext is owned by the given view key.
538
804
  *
@@ -551,6 +817,15 @@ export class EncryptionToolkit {
551
817
  * @returns {vec<RecordPlaintext>} The decrypted record plaintexts.
552
818
  */
553
819
  static decryptOwnedRecords(view_key: ViewKey, records: RecordCiphertext[]): RecordPlaintext[];
820
+ /**
821
+ * Decrypt the sender ciphertext associated with the record with the record view key.
822
+ *
823
+ * @param {Field} record_view_key Record view key associated with the record.
824
+ * @param {Field} sender_ciphertext Sender ciphertext associated with the record.
825
+ *
826
+ * @return {Address} the address of the sender.
827
+ */
828
+ static decryptSenderWithRvk(record_view_key: Field, sender_ciphertext: Field): Address;
554
829
  /**
555
830
  * Creates a record view key from the view key. This can be later be used to decrypt a
556
831
  *
@@ -587,6 +862,7 @@ export class EncryptionToolkit {
587
862
  export class Execution {
588
863
  private constructor();
589
864
  free(): void;
865
+ [Symbol.dispose](): void;
590
866
  /**
591
867
  * Creates an execution object from a string representation of an execution.
592
868
  *
@@ -621,6 +897,7 @@ export class Execution {
621
897
  export class ExecutionRequest {
622
898
  private constructor();
623
899
  free(): void;
900
+ [Symbol.dispose](): void;
624
901
  /**
625
902
  * Returns the network ID.
626
903
  */
@@ -639,6 +916,14 @@ export class ExecutionRequest {
639
916
  * Returns the bytes representation of the request.
640
917
  */
641
918
  toBytesLe(): Uint8Array;
919
+ /**
920
+ * Alias for `sk_tag` (camelCase).
921
+ */
922
+ skTag(): Field;
923
+ /**
924
+ * Alias for `to_tpk` (camelCase).
925
+ */
926
+ toTpk(): Group;
642
927
  /**
643
928
  * Creates an request object from a bytes representation of an request.
644
929
  */
@@ -647,6 +932,56 @@ export class ExecutionRequest {
647
932
  * Returns the function name.
648
933
  */
649
934
  function_name(): string;
935
+ /**
936
+ * Alias for `input_ids` (camelCase).
937
+ */
938
+ inputIds(): Array<any>;
939
+ /**
940
+ * Alias for `network_id` (camelCase).
941
+ */
942
+ networkId(): number;
943
+ /**
944
+ * Alias for `program_id` (camelCase).
945
+ */
946
+ programId(): string;
947
+ /**
948
+ * Alias for `function_name` (camelCase).
949
+ */
950
+ functionName(): string;
951
+ /**
952
+ * Builds a request from externally-signed data using externally-supplied record view keys.
953
+ *
954
+ * For record inputs, the caller provides `record_view_keys` and `gammas` directly.
955
+ * The method uses these to compute commitment, serial number, tag, and InputID for each record.
956
+ *
957
+ * @param {string} program_id The id of the program.
958
+ * @param {string} function_name The function name.
959
+ * @param {string[]} inputs The inputs to the function.
960
+ * @param {string[]} input_types The input types of the function.
961
+ * @param {Signature} signature The externally-computed signature.
962
+ * @param {Field} tvk The transition view key.
963
+ * @param {Address} signer The signer address.
964
+ * @param {Field} sk_tag The tag secret key.
965
+ * @param {Field[] | undefined} record_view_keys Pre-computed record view keys (required when there are record inputs).
966
+ * @param {Group[] | undefined} gammas An array of gammas (required when there are record inputs).
967
+ */
968
+ static fromExternallySignedData(program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, signature: Signature, tvk: Field, signer: Address, sk_tag: Field, record_view_keys?: Array<any> | null, gammas?: Array<any> | null): ExecutionRequest;
969
+ /**
970
+ * Computes the function ID and serialized input data for a program function call.
971
+ * This is a helper for external signing wallets and other applications that need to compute
972
+ * publicly computable inputs for the `Request::sign` function.
973
+ *
974
+ * @param {string} program_id The id of the program.
975
+ * @param {string} function_name The function name.
976
+ * @param {string[]} input_types The input types of the function as strings.
977
+ * @param {string[]} inputs The inputs to the function as strings.
978
+ * @param {boolean} is_root Flag to indicate if this is the top level function in the call graph.
979
+ * @param {Field | undefined} program_checksum The program checksum (required if the program has a constructor).
980
+ * @param {ViewKey | undefined} view_key The view key of the signer to compute a record's tag and h values.
981
+ *
982
+ * @returns {ExternalSigningInput}
983
+ */
984
+ static computeExternalSigningInputs(program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, is_root: boolean, program_checksum?: Field | null, view_key?: ViewKey | null): object;
650
985
  /**
651
986
  * Returns the signer commitment `scm`.
652
987
  */
@@ -659,6 +994,46 @@ export class ExecutionRequest {
659
994
  * Returns the transition view key `tvk`.
660
995
  */
661
996
  tvk(): Field;
997
+ /**
998
+ * Builds a request from externally-signed data using a view key to derive record view keys.
999
+ *
1000
+ * For record inputs, the method computes `record_view_key = (nonce * view_key).to_x_coordinate()`
1001
+ * for each record, then uses it with the supplied `gammas` to compute commitment, serial number,
1002
+ * tag, and InputID.
1003
+ *
1004
+ * @param {string} program_id The id of the program.
1005
+ * @param {string} function_name The function name.
1006
+ * @param {string[]} inputs The inputs to the function.
1007
+ * @param {string[]} input_types The input types of the function.
1008
+ * @param {Signature} signature The externally-computed signature.
1009
+ * @param {Field} tvk The transition view key.
1010
+ * @param {Address} signer The signer address.
1011
+ * @param {Field} sk_tag The tag secret key.
1012
+ * @param {ViewKey} view_key The view key of the signer.
1013
+ * @param {Group[] | undefined} gammas An array of gammas (required when there are record inputs).
1014
+ */
1015
+ static fromExternallySignedDataWithViewKey(program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, signature: Signature, tvk: Field, signer: Address, sk_tag: Field, view_key: ViewKey, gammas?: Array<any> | null): ExecutionRequest;
1016
+ /**
1017
+ * Builds a request from externally-signed data with pre-computed input IDs.
1018
+ *
1019
+ * Each element of `input_ids` is either:
1020
+ * - A `Field` for constant, public, or private inputs (the input hash).
1021
+ * - A JS Array `[Field, Group, Field, Field, Field]` for record inputs
1022
+ * (commitment, gamma, record_view_key, serial_number, tag).
1023
+ *
1024
+ * The `input_types` array is used to determine the InputID variant for scalar fields.
1025
+ *
1026
+ * @param {string} program_id The id of the program.
1027
+ * @param {string} function_name The function name.
1028
+ * @param {string[]} inputs The inputs to the function.
1029
+ * @param {string[]} input_types The input types of the function.
1030
+ * @param {Signature} signature The externally-computed signature.
1031
+ * @param {Field} tvk The transition view key.
1032
+ * @param {Address} signer The signer address.
1033
+ * @param {Field} sk_tag The tag secret key.
1034
+ * @param {(Field | [Field, Group, Field, Field, Field])[]} input_ids Pre-computed input IDs.
1035
+ */
1036
+ static fromExternallySignedDataWithInputIds(program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, signature: Signature, tvk: Field, signer: Address, sk_tag: Field, input_ids: Array<any>): ExecutionRequest;
662
1037
  /**
663
1038
  * Create a new request by signing over a program ID and set of inputs.
664
1039
  *
@@ -668,9 +1043,11 @@ export class ExecutionRequest {
668
1043
  * @param {string[]} inputs The inputs to the function.
669
1044
  * @param {string[]} input_types The input types of the function.
670
1045
  * @param {Field | undefined} root_tvk The tvk of the function at the top of the call graph. This is undefined if this request is built for the top-level call or if there is only one function in the call graph.
1046
+ * @param {Field | undefined} program_checksum The checksum of the program. This is undefined if the call is not dynamic.
671
1047
  * @param {boolean} is_root Flag to indicate if this is the top level function in the call graph.
1048
+ * @param {boolean} is_dynamic Flag to indicate if this is a dynamic call.
672
1049
  */
673
- static sign(private_key: PrivateKey, program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, root_tvk: Field | null | undefined, program_checksum: Field | null | undefined, is_root: boolean): ExecutionRequest;
1050
+ static sign(private_key: PrivateKey, program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, root_tvk: Field | null | undefined, program_checksum: Field | null | undefined, is_root: boolean, is_dynamic: boolean): ExecutionRequest;
674
1051
  /**
675
1052
  * Returns the function inputs as an array of strings.
676
1053
  */
@@ -690,12 +1067,17 @@ export class ExecutionRequest {
690
1067
  /**
691
1068
  * Verify the input types within a request.
692
1069
  *
693
- * @param {string[]} The input_types within the request.
694
- * @param {boolean} Flag to indicate whether this request is the first function in the call graph.
1070
+ * @param {string[]} input_types The input types within the request.
1071
+ * @param {boolean} is_root Flag to indicate whether this request is the first function in the call graph.
1072
+ * @param {Field | undefined} program_checksum The checksum of the program. This is undefined if the call is not dynamic.
695
1073
  */
696
1074
  verify(input_types: Array<any>, is_root: boolean, program_checksum?: Field | null): boolean;
697
1075
  /**
698
1076
  * Returns the input IDs for the transition.
1077
+ *
1078
+ * Each element is either a WASM `Field` (for constant/public/private/external_record inputs)
1079
+ * or a JS Array `[Field, Group, Field, Field, Field]` (for record inputs: commitment, gamma,
1080
+ * record_view_key, serial_number, tag).
699
1081
  */
700
1082
  input_ids(): Array<any>;
701
1083
  /**
@@ -718,6 +1100,7 @@ export class ExecutionRequest {
718
1100
  export class ExecutionResponse {
719
1101
  private constructor();
720
1102
  free(): void;
1103
+ [Symbol.dispose](): void;
721
1104
  /**
722
1105
  * Get the outputs of the executed function
723
1106
  *
@@ -763,10 +1146,21 @@ export class ExecutionResponse {
763
1146
  export class Field {
764
1147
  private constructor();
765
1148
  free(): void;
1149
+ [Symbol.dispose](): void;
1150
+ /**
1151
+ * Cast the field element to an Address (strict, via Group x-coordinate recovery).
1152
+ * Returns an error if the field is not a valid x-coordinate on the curve.
1153
+ */
1154
+ toAddress(): Address;
766
1155
  /**
767
1156
  * Get the left endian boolean array representation of the field element.
768
1157
  */
769
1158
  toBitsLe(): Array<any>;
1159
+ /**
1160
+ * Cast the field element to a Boolean (strict).
1161
+ * Returns an error if the field is not zero or one.
1162
+ */
1163
+ toBoolean(): Boolean;
770
1164
  /**
771
1165
  * Creates a field object from a string representation of a field element.
772
1166
  */
@@ -775,18 +1169,82 @@ export class Field {
775
1169
  * Encode the field element as a Uint8Array of left endian bytes.
776
1170
  */
777
1171
  toBytesLe(): Uint8Array;
1172
+ /**
1173
+ * Cast the field to an I8 with lossy truncation.
1174
+ */
1175
+ toI8Lossy(): I8;
1176
+ /**
1177
+ * Cast the field to a U8 with lossy truncation.
1178
+ */
1179
+ toU8Lossy(): U8;
778
1180
  /**
779
1181
  * Reconstruct a field element from a boolean array representation.
780
1182
  */
781
1183
  static fromBitsLe(bits: Array<any>): Field;
1184
+ /**
1185
+ * Cast the field to an I16 with lossy truncation.
1186
+ */
1187
+ toI16Lossy(): I16;
1188
+ /**
1189
+ * Cast the field to an I32 with lossy truncation.
1190
+ */
1191
+ toI32Lossy(): I32;
1192
+ /**
1193
+ * Cast the field to an I64 with lossy truncation.
1194
+ */
1195
+ toI64Lossy(): I64;
782
1196
  /**
783
1197
  * Create a plaintext from the field element.
784
1198
  */
785
1199
  toPlaintext(): Plaintext;
1200
+ /**
1201
+ * Cast the field to a U16 with lossy truncation.
1202
+ */
1203
+ toU16Lossy(): U16;
1204
+ /**
1205
+ * Cast the field to a U32 with lossy truncation.
1206
+ */
1207
+ toU32Lossy(): U32;
1208
+ /**
1209
+ * Cast the field to a U64 with lossy truncation.
1210
+ */
1211
+ toU64Lossy(): U64;
786
1212
  /**
787
1213
  * Create a field element from a Uint8Array of left endian bytes.
788
1214
  */
789
1215
  static fromBytesLe(bytes: Uint8Array): Field;
1216
+ /**
1217
+ * Cast the field to an I128 with lossy truncation.
1218
+ */
1219
+ toI128Lossy(): I128;
1220
+ /**
1221
+ * Cast the field to a U128 with lossy truncation.
1222
+ */
1223
+ toU128Lossy(): U128;
1224
+ /**
1225
+ * Cast the field element to a Group element with lossy conversion.
1226
+ *
1227
+ * Uses the snarkVM cast_lossy path: tries x-coordinate recovery first,
1228
+ * falls back to the generator for field == 1, and applies Elligator-2
1229
+ * otherwise. This conversion never fails.
1230
+ */
1231
+ toGroupLossy(): Group;
1232
+ /**
1233
+ * Cast the field element to a Scalar with lossy truncation.
1234
+ */
1235
+ toScalarLossy(): Scalar;
1236
+ /**
1237
+ * Cast the field element to an Address with lossy conversion (via Group, Elligator-2 fallback).
1238
+ */
1239
+ toAddressLossy(): Address;
1240
+ /**
1241
+ * Cast the field element to a Boolean with lossy truncation (extracts least-significant bit).
1242
+ */
1243
+ toBooleanLossy(): Boolean;
1244
+ /**
1245
+ * Initializes a new field as a domain separator.
1246
+ */
1247
+ static newDomainSeparator(domain: string): Field;
790
1248
  /**
791
1249
  * Add two field elements.
792
1250
  */
@@ -835,6 +1293,13 @@ export class Field {
835
1293
  * Subtract two field elements.
836
1294
  */
837
1295
  subtract(other: Field): Field;
1296
+ /**
1297
+ * Cast the field element to a Group element (strict).
1298
+ *
1299
+ * Attempts to recover the group element from the field as an x-coordinate.
1300
+ * Returns an error if the field is not a valid x-coordinate on the curve.
1301
+ */
1302
+ toGroup(): Group;
838
1303
  /**
839
1304
  * Returns the string representation of the field element.
840
1305
  */
@@ -843,6 +1308,7 @@ export class Field {
843
1308
  export class GraphKey {
844
1309
  private constructor();
845
1310
  free(): void;
1311
+ [Symbol.dispose](): void;
846
1312
  /**
847
1313
  * Create a new graph key from a string representation of a graph key
848
1314
  *
@@ -850,6 +1316,12 @@ export class GraphKey {
850
1316
  * @returns {GraphKey} Graph key
851
1317
  */
852
1318
  static from_string(graph_key: string): GraphKey;
1319
+ /**
1320
+ * Get a string representation of a graph key
1321
+ *
1322
+ * @returns {string} String representation of a graph key
1323
+ */
1324
+ toString(): string;
853
1325
  /**
854
1326
  * Create a new graph key from a view key.
855
1327
  *
@@ -874,6 +1346,15 @@ export class GraphKey {
874
1346
  export class Group {
875
1347
  private constructor();
876
1348
  free(): void;
1349
+ [Symbol.dispose](): void;
1350
+ /**
1351
+ * Generate the group element from the x coordinate of the group.
1352
+ */
1353
+ static fromField(field: Field): Group;
1354
+ /**
1355
+ * Cast the group element to an Address (lossless — Address wraps Group).
1356
+ */
1357
+ toAddress(): Address;
877
1358
  /**
878
1359
  * Get the left endian boolean array representation of the group element.
879
1360
  */
@@ -886,26 +1367,78 @@ export class Group {
886
1367
  * Encode the group element as a Uint8Array of left endian bytes.
887
1368
  */
888
1369
  toBytesLe(): Uint8Array;
1370
+ /**
1371
+ * Cast the group to an I8 with lossy truncation.
1372
+ */
1373
+ toI8Lossy(): I8;
1374
+ /**
1375
+ * Cast the group to a U8 with lossy truncation.
1376
+ */
1377
+ toU8Lossy(): U8;
889
1378
  /**
890
1379
  * Reconstruct a group element from a boolean array representation.
891
1380
  */
892
1381
  static fromBitsLe(bits: Array<any>): Group;
1382
+ /**
1383
+ * Cast the group to an I16 with lossy truncation.
1384
+ */
1385
+ toI16Lossy(): I16;
1386
+ /**
1387
+ * Cast the group to an I32 with lossy truncation.
1388
+ */
1389
+ toI32Lossy(): I32;
1390
+ /**
1391
+ * Cast the group to an I64 with lossy truncation.
1392
+ */
1393
+ toI64Lossy(): I64;
893
1394
  /**
894
1395
  * Create a plaintext element from a group element.
895
1396
  */
896
1397
  toPlaintext(): Plaintext;
1398
+ /**
1399
+ * Cast the group to a U16 with lossy truncation.
1400
+ */
1401
+ toU16Lossy(): U16;
1402
+ /**
1403
+ * Cast the group to a U32 with lossy truncation.
1404
+ */
1405
+ toU32Lossy(): U32;
1406
+ /**
1407
+ * Cast the group to a U64 with lossy truncation.
1408
+ */
1409
+ toU64Lossy(): U64;
897
1410
  /**
898
1411
  * Create a group element from a Uint8Array of left endian bytes.
899
1412
  */
900
1413
  static fromBytesLe(bytes: Uint8Array): Group;
1414
+ /**
1415
+ * Cast the group to an I128 with lossy truncation.
1416
+ */
1417
+ toI128Lossy(): I128;
1418
+ /**
1419
+ * Cast the group to a U128 with lossy truncation.
1420
+ */
1421
+ toU128Lossy(): U128;
901
1422
  /**
902
1423
  * Multiply a group element by a scalar element.
903
1424
  */
904
1425
  scalarMultiply(scalar: Scalar): Group;
1426
+ /**
1427
+ * Cast the group element to a Scalar with lossy truncation (via x-coordinate).
1428
+ */
1429
+ toScalarLossy(): Scalar;
905
1430
  /**
906
1431
  * Get the x-coordinate of the group element.
907
1432
  */
908
1433
  toXCoordinate(): Field;
1434
+ /**
1435
+ * Cast the group element to a Boolean with lossy truncation (LSB of x-coordinate).
1436
+ */
1437
+ toBooleanLossy(): Boolean;
1438
+ /**
1439
+ * Generate the group element from a string representation of the x coordinate of the group.
1440
+ */
1441
+ static fromFieldString(field: string): Group;
909
1442
  /**
910
1443
  * Add two group elements.
911
1444
  */
@@ -939,6 +1472,11 @@ export class Group {
939
1472
  * Subtract two group elements (equivalently: add the inverse of an element).
940
1473
  */
941
1474
  subtract(other: Group): Group;
1475
+ /**
1476
+ * Cast the group element to a Field (returns x-coordinate).
1477
+ * This is an alias for `toXCoordinate()`.
1478
+ */
1479
+ toField(): Field;
942
1480
  /**
943
1481
  * Get the generator of the group.
944
1482
  */
@@ -955,6 +1493,7 @@ export class Group {
955
1493
  export class I128 {
956
1494
  private constructor();
957
1495
  free(): void;
1496
+ [Symbol.dispose](): void;
958
1497
  /**
959
1498
  * Attempt to construct the integer from a field element.
960
1499
  */
@@ -1003,18 +1542,66 @@ export class I128 {
1003
1542
  * Construct an integer from a byte array representation.
1004
1543
  */
1005
1544
  toBytesLe(): Uint8Array;
1545
+ /**
1546
+ * Cast to I8 with lossy truncation.
1547
+ */
1548
+ toI8Lossy(): I8;
1549
+ /**
1550
+ * Cast to U8 with lossy truncation.
1551
+ */
1552
+ toU8Lossy(): U8;
1006
1553
  /**
1007
1554
  * Construct an integer from a boolean array representation.
1008
1555
  */
1009
1556
  static fromBitsLe(bits: Array<any>): I128;
1557
+ /**
1558
+ * Cast to I16 with lossy truncation.
1559
+ */
1560
+ toI16Lossy(): I16;
1561
+ /**
1562
+ * Cast to I32 with lossy truncation.
1563
+ */
1564
+ toI32Lossy(): I32;
1565
+ /**
1566
+ * Cast to I64 with lossy truncation.
1567
+ */
1568
+ toI64Lossy(): I64;
1010
1569
  /**
1011
1570
  * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
1012
1571
  */
1013
1572
  toPlaintext(): Plaintext;
1573
+ /**
1574
+ * Cast to U16 with lossy truncation.
1575
+ */
1576
+ toU16Lossy(): U16;
1577
+ /**
1578
+ * Cast to U32 with lossy truncation.
1579
+ */
1580
+ toU32Lossy(): U32;
1581
+ /**
1582
+ * Cast to U64 with lossy truncation.
1583
+ */
1584
+ toU64Lossy(): U64;
1014
1585
  /**
1015
1586
  * Get the byte array representation of the integer.
1016
1587
  */
1017
1588
  static fromBytesLe(bytes: Uint8Array): I128;
1589
+ /**
1590
+ * Cast to I128 with lossy truncation.
1591
+ */
1592
+ toI128Lossy(): I128;
1593
+ /**
1594
+ * Cast to U128 with lossy truncation.
1595
+ */
1596
+ toU128Lossy(): U128;
1597
+ /**
1598
+ * Construct an integer from a field element with lossy truncation.
1599
+ */
1600
+ static fromFieldLossy(field: Field): I128;
1601
+ /**
1602
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
1603
+ */
1604
+ toBooleanLossy(): Boolean;
1018
1605
  /**
1019
1606
  * Negate the integer (e.g., 5 → -5).
1020
1607
  */
@@ -1043,6 +1630,10 @@ export class I128 {
1043
1630
  * Exponentiate the integer with a u32 exponent.
1044
1631
  */
1045
1632
  powU32(exponent: U32): I128;
1633
+ /**
1634
+ * Convert the integer to a Field element (lossless).
1635
+ */
1636
+ toField(): Field;
1046
1637
  /**
1047
1638
  * Convert the integer to a Scalar value.
1048
1639
  */
@@ -1055,6 +1646,7 @@ export class I128 {
1055
1646
  export class I16 {
1056
1647
  private constructor();
1057
1648
  free(): void;
1649
+ [Symbol.dispose](): void;
1058
1650
  /**
1059
1651
  * Attempt to construct the integer from a field element.
1060
1652
  */
@@ -1103,18 +1695,66 @@ export class I16 {
1103
1695
  * Construct an integer from a byte array representation.
1104
1696
  */
1105
1697
  toBytesLe(): Uint8Array;
1698
+ /**
1699
+ * Cast to I8 with lossy truncation.
1700
+ */
1701
+ toI8Lossy(): I8;
1702
+ /**
1703
+ * Cast to U8 with lossy truncation.
1704
+ */
1705
+ toU8Lossy(): U8;
1106
1706
  /**
1107
1707
  * Construct an integer from a boolean array representation.
1108
1708
  */
1109
1709
  static fromBitsLe(bits: Array<any>): I16;
1710
+ /**
1711
+ * Cast to I16 with lossy truncation.
1712
+ */
1713
+ toI16Lossy(): I16;
1714
+ /**
1715
+ * Cast to I32 with lossy truncation.
1716
+ */
1717
+ toI32Lossy(): I32;
1718
+ /**
1719
+ * Cast to I64 with lossy truncation.
1720
+ */
1721
+ toI64Lossy(): I64;
1110
1722
  /**
1111
1723
  * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
1112
1724
  */
1113
1725
  toPlaintext(): Plaintext;
1726
+ /**
1727
+ * Cast to U16 with lossy truncation.
1728
+ */
1729
+ toU16Lossy(): U16;
1730
+ /**
1731
+ * Cast to U32 with lossy truncation.
1732
+ */
1733
+ toU32Lossy(): U32;
1734
+ /**
1735
+ * Cast to U64 with lossy truncation.
1736
+ */
1737
+ toU64Lossy(): U64;
1114
1738
  /**
1115
1739
  * Get the byte array representation of the integer.
1116
1740
  */
1117
1741
  static fromBytesLe(bytes: Uint8Array): I16;
1742
+ /**
1743
+ * Cast to I128 with lossy truncation.
1744
+ */
1745
+ toI128Lossy(): I128;
1746
+ /**
1747
+ * Cast to U128 with lossy truncation.
1748
+ */
1749
+ toU128Lossy(): U128;
1750
+ /**
1751
+ * Construct an integer from a field element with lossy truncation.
1752
+ */
1753
+ static fromFieldLossy(field: Field): I16;
1754
+ /**
1755
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
1756
+ */
1757
+ toBooleanLossy(): Boolean;
1118
1758
  /**
1119
1759
  * Negate the integer (e.g., 5 → -5).
1120
1760
  */
@@ -1143,6 +1783,10 @@ export class I16 {
1143
1783
  * Exponentiate the integer with a u32 exponent.
1144
1784
  */
1145
1785
  powU32(exponent: U32): I16;
1786
+ /**
1787
+ * Convert the integer to a Field element (lossless).
1788
+ */
1789
+ toField(): Field;
1146
1790
  /**
1147
1791
  * Convert the integer to a Scalar value.
1148
1792
  */
@@ -1155,6 +1799,7 @@ export class I16 {
1155
1799
  export class I32 {
1156
1800
  private constructor();
1157
1801
  free(): void;
1802
+ [Symbol.dispose](): void;
1158
1803
  /**
1159
1804
  * Attempt to construct the integer from a field element.
1160
1805
  */
@@ -1202,19 +1847,67 @@ export class I32 {
1202
1847
  /**
1203
1848
  * Construct an integer from a byte array representation.
1204
1849
  */
1205
- toBytesLe(): Uint8Array;
1850
+ toBytesLe(): Uint8Array;
1851
+ /**
1852
+ * Cast to I8 with lossy truncation.
1853
+ */
1854
+ toI8Lossy(): I8;
1855
+ /**
1856
+ * Cast to U8 with lossy truncation.
1857
+ */
1858
+ toU8Lossy(): U8;
1859
+ /**
1860
+ * Construct an integer from a boolean array representation.
1861
+ */
1862
+ static fromBitsLe(bits: Array<any>): I32;
1863
+ /**
1864
+ * Cast to I16 with lossy truncation.
1865
+ */
1866
+ toI16Lossy(): I16;
1867
+ /**
1868
+ * Cast to I32 with lossy truncation.
1869
+ */
1870
+ toI32Lossy(): I32;
1871
+ /**
1872
+ * Cast to I64 with lossy truncation.
1873
+ */
1874
+ toI64Lossy(): I64;
1875
+ /**
1876
+ * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
1877
+ */
1878
+ toPlaintext(): Plaintext;
1879
+ /**
1880
+ * Cast to U16 with lossy truncation.
1881
+ */
1882
+ toU16Lossy(): U16;
1883
+ /**
1884
+ * Cast to U32 with lossy truncation.
1885
+ */
1886
+ toU32Lossy(): U32;
1887
+ /**
1888
+ * Cast to U64 with lossy truncation.
1889
+ */
1890
+ toU64Lossy(): U64;
1891
+ /**
1892
+ * Get the byte array representation of the integer.
1893
+ */
1894
+ static fromBytesLe(bytes: Uint8Array): I32;
1895
+ /**
1896
+ * Cast to I128 with lossy truncation.
1897
+ */
1898
+ toI128Lossy(): I128;
1206
1899
  /**
1207
- * Construct an integer from a boolean array representation.
1900
+ * Cast to U128 with lossy truncation.
1208
1901
  */
1209
- static fromBitsLe(bits: Array<any>): I32;
1902
+ toU128Lossy(): U128;
1210
1903
  /**
1211
- * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
1904
+ * Construct an integer from a field element with lossy truncation.
1212
1905
  */
1213
- toPlaintext(): Plaintext;
1906
+ static fromFieldLossy(field: Field): I32;
1214
1907
  /**
1215
- * Get the byte array representation of the integer.
1908
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
1216
1909
  */
1217
- static fromBytesLe(bytes: Uint8Array): I32;
1910
+ toBooleanLossy(): Boolean;
1218
1911
  /**
1219
1912
  * Negate the integer (e.g., 5 → -5).
1220
1913
  */
@@ -1243,6 +1936,10 @@ export class I32 {
1243
1936
  * Exponentiate the integer with a u32 exponent.
1244
1937
  */
1245
1938
  powU32(exponent: U32): I32;
1939
+ /**
1940
+ * Convert the integer to a Field element (lossless).
1941
+ */
1942
+ toField(): Field;
1246
1943
  /**
1247
1944
  * Convert the integer to a Scalar value.
1248
1945
  */
@@ -1255,6 +1952,7 @@ export class I32 {
1255
1952
  export class I64 {
1256
1953
  private constructor();
1257
1954
  free(): void;
1955
+ [Symbol.dispose](): void;
1258
1956
  /**
1259
1957
  * Attempt to construct the integer from a field element.
1260
1958
  */
@@ -1303,18 +2001,66 @@ export class I64 {
1303
2001
  * Construct an integer from a byte array representation.
1304
2002
  */
1305
2003
  toBytesLe(): Uint8Array;
2004
+ /**
2005
+ * Cast to I8 with lossy truncation.
2006
+ */
2007
+ toI8Lossy(): I8;
2008
+ /**
2009
+ * Cast to U8 with lossy truncation.
2010
+ */
2011
+ toU8Lossy(): U8;
1306
2012
  /**
1307
2013
  * Construct an integer from a boolean array representation.
1308
2014
  */
1309
2015
  static fromBitsLe(bits: Array<any>): I64;
2016
+ /**
2017
+ * Cast to I16 with lossy truncation.
2018
+ */
2019
+ toI16Lossy(): I16;
2020
+ /**
2021
+ * Cast to I32 with lossy truncation.
2022
+ */
2023
+ toI32Lossy(): I32;
2024
+ /**
2025
+ * Cast to I64 with lossy truncation.
2026
+ */
2027
+ toI64Lossy(): I64;
1310
2028
  /**
1311
2029
  * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
1312
2030
  */
1313
2031
  toPlaintext(): Plaintext;
2032
+ /**
2033
+ * Cast to U16 with lossy truncation.
2034
+ */
2035
+ toU16Lossy(): U16;
2036
+ /**
2037
+ * Cast to U32 with lossy truncation.
2038
+ */
2039
+ toU32Lossy(): U32;
2040
+ /**
2041
+ * Cast to U64 with lossy truncation.
2042
+ */
2043
+ toU64Lossy(): U64;
1314
2044
  /**
1315
2045
  * Get the byte array representation of the integer.
1316
2046
  */
1317
2047
  static fromBytesLe(bytes: Uint8Array): I64;
2048
+ /**
2049
+ * Cast to I128 with lossy truncation.
2050
+ */
2051
+ toI128Lossy(): I128;
2052
+ /**
2053
+ * Cast to U128 with lossy truncation.
2054
+ */
2055
+ toU128Lossy(): U128;
2056
+ /**
2057
+ * Construct an integer from a field element with lossy truncation.
2058
+ */
2059
+ static fromFieldLossy(field: Field): I64;
2060
+ /**
2061
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
2062
+ */
2063
+ toBooleanLossy(): Boolean;
1318
2064
  /**
1319
2065
  * Negate the integer (e.g., 5 → -5).
1320
2066
  */
@@ -1343,6 +2089,10 @@ export class I64 {
1343
2089
  * Exponentiate the integer with a u32 exponent.
1344
2090
  */
1345
2091
  powU32(exponent: U32): I64;
2092
+ /**
2093
+ * Convert the integer to a Field element (lossless).
2094
+ */
2095
+ toField(): Field;
1346
2096
  /**
1347
2097
  * Convert the integer to a Scalar value.
1348
2098
  */
@@ -1355,6 +2105,7 @@ export class I64 {
1355
2105
  export class I8 {
1356
2106
  private constructor();
1357
2107
  free(): void;
2108
+ [Symbol.dispose](): void;
1358
2109
  /**
1359
2110
  * Attempt to construct the integer from a field element.
1360
2111
  */
@@ -1403,18 +2154,66 @@ export class I8 {
1403
2154
  * Construct an integer from a byte array representation.
1404
2155
  */
1405
2156
  toBytesLe(): Uint8Array;
2157
+ /**
2158
+ * Cast to I8 with lossy truncation.
2159
+ */
2160
+ toI8Lossy(): I8;
2161
+ /**
2162
+ * Cast to U8 with lossy truncation.
2163
+ */
2164
+ toU8Lossy(): U8;
1406
2165
  /**
1407
2166
  * Construct an integer from a boolean array representation.
1408
2167
  */
1409
2168
  static fromBitsLe(bits: Array<any>): I8;
2169
+ /**
2170
+ * Cast to I16 with lossy truncation.
2171
+ */
2172
+ toI16Lossy(): I16;
2173
+ /**
2174
+ * Cast to I32 with lossy truncation.
2175
+ */
2176
+ toI32Lossy(): I32;
2177
+ /**
2178
+ * Cast to I64 with lossy truncation.
2179
+ */
2180
+ toI64Lossy(): I64;
1410
2181
  /**
1411
2182
  * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
1412
2183
  */
1413
2184
  toPlaintext(): Plaintext;
2185
+ /**
2186
+ * Cast to U16 with lossy truncation.
2187
+ */
2188
+ toU16Lossy(): U16;
2189
+ /**
2190
+ * Cast to U32 with lossy truncation.
2191
+ */
2192
+ toU32Lossy(): U32;
2193
+ /**
2194
+ * Cast to U64 with lossy truncation.
2195
+ */
2196
+ toU64Lossy(): U64;
1414
2197
  /**
1415
2198
  * Get the byte array representation of the integer.
1416
2199
  */
1417
2200
  static fromBytesLe(bytes: Uint8Array): I8;
2201
+ /**
2202
+ * Cast to I128 with lossy truncation.
2203
+ */
2204
+ toI128Lossy(): I128;
2205
+ /**
2206
+ * Cast to U128 with lossy truncation.
2207
+ */
2208
+ toU128Lossy(): U128;
2209
+ /**
2210
+ * Construct an integer from a field element with lossy truncation.
2211
+ */
2212
+ static fromFieldLossy(field: Field): I8;
2213
+ /**
2214
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
2215
+ */
2216
+ toBooleanLossy(): Boolean;
1418
2217
  /**
1419
2218
  * Negate the integer (e.g., 5 → -5).
1420
2219
  */
@@ -1443,6 +2242,10 @@ export class I8 {
1443
2242
  * Exponentiate the integer with a u32 exponent.
1444
2243
  */
1445
2244
  powU32(exponent: U32): I8;
2245
+ /**
2246
+ * Convert the integer to a Field element (lossless).
2247
+ */
2248
+ toField(): Field;
1446
2249
  /**
1447
2250
  * Convert the integer to a Scalar value.
1448
2251
  */
@@ -1457,6 +2260,7 @@ export class I8 {
1457
2260
  */
1458
2261
  export class KeyPair {
1459
2262
  free(): void;
2263
+ [Symbol.dispose](): void;
1460
2264
  /**
1461
2265
  * Get the proving key. This method will remove the proving key from the key pair
1462
2266
  *
@@ -1481,6 +2285,7 @@ export class KeyPair {
1481
2285
  export class Metadata {
1482
2286
  private constructor();
1483
2287
  free(): void;
2288
+ [Symbol.dispose](): void;
1484
2289
  static fee_public(): Metadata;
1485
2290
  static bond_public(): Metadata;
1486
2291
  static fee_private(): Metadata;
@@ -1509,6 +2314,7 @@ export class Metadata {
1509
2314
  */
1510
2315
  export class OfflineQuery {
1511
2316
  free(): void;
2317
+ [Symbol.dispose](): void;
1512
2318
  /**
1513
2319
  * Create an offline query object from a json string representation.
1514
2320
  *
@@ -1546,6 +2352,7 @@ export class OfflineQuery {
1546
2352
  }
1547
2353
  export class Pedersen128 {
1548
2354
  free(): void;
2355
+ [Symbol.dispose](): void;
1549
2356
  /**
1550
2357
  * Returns a Pedersen commitment for the given (up to) 128-bit input and randomizer.
1551
2358
  */
@@ -1569,6 +2376,7 @@ export class Pedersen128 {
1569
2376
  }
1570
2377
  export class Pedersen64 {
1571
2378
  free(): void;
2379
+ [Symbol.dispose](): void;
1572
2380
  /**
1573
2381
  * Returns a Pedersen commitment for the given (up to) 64-bit input and randomizer.
1574
2382
  */
@@ -1601,7 +2409,7 @@ export class Pedersen64 {
1601
2409
  *
1602
2410
  * @example
1603
2411
  * // Get the bond state of an existing address.
1604
- * const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
2412
+ * const bondState = await fetch(https://api.provable.com/v2/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
1605
2413
  * // Convert the bond state to a Plaintext object.
1606
2414
  * const bondStatePlaintext = Plaintext.fromString(bond_state);
1607
2415
  * // Convert the Plaintext object to a JS object.
@@ -1613,10 +2421,11 @@ export class Pedersen64 {
1613
2421
  export class Plaintext {
1614
2422
  private constructor();
1615
2423
  free(): void;
2424
+ [Symbol.dispose](): void;
1616
2425
  /**
1617
- * Get the left endian boolean array representation of the bits of the plaintext.
2426
+ * Get the little endian boolean array representation of the bits of the plaintext.
1618
2427
  *
1619
- * @returns {Array} The left endian boolean array representation of the bits of the plaintext.
2428
+ * @returns {Array} The little endian boolean array representation of the bits of the plaintext.
1620
2429
  */
1621
2430
  toBitsLe(): Array<any>;
1622
2431
  /**
@@ -1636,15 +2445,15 @@ export class Plaintext {
1636
2445
  */
1637
2446
  static fromString(plaintext: string): Plaintext;
1638
2447
  /**
1639
- * Get the left endian byte array representation of the plaintext.
2448
+ * Get the little endian byte array representation of the plaintext.
1640
2449
  *
1641
- * @returns {Uint8Array} The left endian byte array representation of the plaintext.
2450
+ * @returns {Uint8Array} The little endian byte array representation of the plaintext.
1642
2451
  */
1643
2452
  toBytesLe(): Uint8Array;
1644
2453
  /**
1645
2454
  * Get a plaintext object from a series of bits represented as a boolean array.
1646
2455
  *
1647
- * @param {Array} bits A left endian boolean array representing the bits plaintext.
2456
+ * @param {Array} bits A little endian boolean array representing the bits plaintext.
1648
2457
  *
1649
2458
  * @returns {Plaintext} The plaintext object.
1650
2459
  */
@@ -1652,17 +2461,47 @@ export class Plaintext {
1652
2461
  /**
1653
2462
  * Get a plaintext object from a series of bytes.
1654
2463
  *
1655
- * @param {Uint8Array} bytes A left endian byte array representing the plaintext.
2464
+ * @param {Uint8Array} bytes A little endian byte array representing the plaintext.
1656
2465
  *
1657
2466
  * @returns {Plaintext} The plaintext object.
1658
2467
  */
1659
2468
  static fromBytesLe(bytes: Uint8Array): Plaintext;
2469
+ /**
2470
+ * Get the raw field array representation of the plaintext.
2471
+ *
2472
+ * @returns {Array} The raw field array representation of the plaintext.
2473
+ */
2474
+ toFieldsRaw(): Array<any>;
1660
2475
  /**
1661
2476
  * Gives the type of the plaintext.
1662
2477
  *
1663
2478
  * @returns {string} The type of the plaintext.
1664
2479
  */
1665
2480
  plaintextType(): string;
2481
+ /**
2482
+ * Get the raw big endian boolean array representation of the bits of the plaintext.
2483
+ *
2484
+ * @returns {Array} The raw big endian boolean array representation of the bits of the plaintext.
2485
+ */
2486
+ toBitsRawBe(): Array<any>;
2487
+ /**
2488
+ * Get the raw little endian boolean array representation of the bits of the plaintext.
2489
+ *
2490
+ * @returns {Array} The raw little endian boolean array representation of the bits of the plaintext.
2491
+ */
2492
+ toBitsRawLe(): Array<any>;
2493
+ /**
2494
+ * Get the raw big endian byte array representation of the plaintext.
2495
+ *
2496
+ * @returns {Uint8Array} The raw big endian byte array representation of the plaintext.
2497
+ */
2498
+ toBytesRawBe(): Uint8Array;
2499
+ /**
2500
+ * Get the raw little endian byte array representation of the plaintext.
2501
+ *
2502
+ * @returns {Uint8Array} The raw little endian byte array representation of the plaintext.
2503
+ */
2504
+ toBytesRawLe(): Uint8Array;
1666
2505
  /**
1667
2506
  * Encrypt a plaintext with a transition view key.
1668
2507
  *
@@ -1711,6 +2550,7 @@ export class Plaintext {
1711
2550
  }
1712
2551
  export class Poseidon2 {
1713
2552
  free(): void;
2553
+ [Symbol.dispose](): void;
1714
2554
  /**
1715
2555
  * Returns the Poseidon hash with an input rate of 2 on the affine curve.
1716
2556
  */
@@ -1738,6 +2578,7 @@ export class Poseidon2 {
1738
2578
  }
1739
2579
  export class Poseidon4 {
1740
2580
  free(): void;
2581
+ [Symbol.dispose](): void;
1741
2582
  /**
1742
2583
  * Returns the Poseidon hash with an input rate of 4 on the affine curve.
1743
2584
  */
@@ -1765,6 +2606,7 @@ export class Poseidon4 {
1765
2606
  }
1766
2607
  export class Poseidon8 {
1767
2608
  free(): void;
2609
+ [Symbol.dispose](): void;
1768
2610
  /**
1769
2611
  * Returns the Poseidon hash with an input rate of 8 on the affine curve.
1770
2612
  */
@@ -1795,6 +2637,14 @@ export class Poseidon8 {
1795
2637
  */
1796
2638
  export class PrivateKey {
1797
2639
  free(): void;
2640
+ [Symbol.dispose](): void;
2641
+ /**
2642
+ * Sign an instance of a valid Aleo data type or record.
2643
+ *
2644
+ * @param {String} message The string representation of the Aleo datatype or record to sign.
2645
+ * @returns {Signature} Signature of the message.
2646
+ */
2647
+ signValue(message: string): Signature;
1798
2648
  /**
1799
2649
  * Get the address corresponding to the private key
1800
2650
  *
@@ -1808,12 +2658,32 @@ export class PrivateKey {
1808
2658
  * @returns {PrivateKey}
1809
2659
  */
1810
2660
  static from_string(private_key: string): PrivateKey;
2661
+ /**
2662
+ * Get the byte representation of a private key
2663
+ *
2664
+ * @returns {Uint8Array} Byte representation of a private key
2665
+ */
2666
+ toBytesLe(): Uint8Array;
1811
2667
  /**
1812
2668
  * Get the view key corresponding to the private key
1813
2669
  *
1814
2670
  * @returns {ViewKey}
1815
2671
  */
1816
2672
  to_view_key(): ViewKey;
2673
+ /**
2674
+ * Get a string representation of the private key. This function should be used very carefully
2675
+ * as it exposes the private key plaintext
2676
+ *
2677
+ * @returns {string} String representation of a private key
2678
+ */
2679
+ toString(): string;
2680
+ /**
2681
+ * Get a private key from a byte representation
2682
+ *
2683
+ * @param {Uint8Array} bytes Byte representation of a private key
2684
+ * @returns {PrivateKey} Private key
2685
+ */
2686
+ static fromBytesLe(bytes: Uint8Array): PrivateKey;
1817
2687
  /**
1818
2688
  * Get a new randomly generated private key ciphertext using a secret. The secret is sensitive
1819
2689
  * and will be needed to decrypt the private key later, so it should be stored securely
@@ -1872,6 +2742,7 @@ export class PrivateKey {
1872
2742
  export class PrivateKeyCiphertext {
1873
2743
  private constructor();
1874
2744
  free(): void;
2745
+ [Symbol.dispose](): void;
1875
2746
  /**
1876
2747
  * Creates a PrivateKeyCiphertext from a string
1877
2748
  *
@@ -1909,6 +2780,7 @@ export class PrivateKeyCiphertext {
1909
2780
  export class Program {
1910
2781
  private constructor();
1911
2782
  free(): void;
2783
+ [Symbol.dispose](): void;
1912
2784
  /**
1913
2785
  * Create a program from a program string
1914
2786
  *
@@ -2143,15 +3015,17 @@ export class Program {
2143
3015
  export class ProgramManager {
2144
3016
  private constructor();
2145
3017
  free(): void;
3018
+ [Symbol.dispose](): void;
2146
3019
  /**
2147
3020
  * Synthesize proving and verifying keys for a program
2148
3021
  *
2149
- * @param program {string} The program source code of the program to synthesize keys for
2150
- * @param function_id {string} The function to synthesize keys for
2151
- * @param inputs {Array} The inputs to the function
2152
- * @param imports {Object | undefined} The imports for the program
3022
+ * @param {string} program The program source code of the program to synthesize keys for
3023
+ * @param {string} function_id The function to synthesize keys for
3024
+ * @param {Array} inputs The inputs to the function
3025
+ * @param {Object | undefined} imports The imports for the program
2153
3026
  */
2154
3027
  static synthesizeKeyPair(private_key: PrivateKey, program: string, function_id: string, inputs: Array<any>, imports?: object | null, edition?: number | null): Promise<KeyPair>;
3028
+ static loadInclusionProver(proving_key: ProvingKey): void;
2155
3029
  /**
2156
3030
  * Create a `ProvingRequest` object. This object creates authorizations for the top level
2157
3031
  * function and associated fee function. This object can be sent directly to a remote prover
@@ -2169,7 +3043,19 @@ export class ProgramManager {
2169
3043
  * @param broadcast (optional) Flag to indicate if the transaction should be broadcast
2170
3044
  * @returns {Authorization}
2171
3045
  */
2172
- static buildProvingRequest(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, base_fee_credits: number, priority_fee_credits: number, fee_record: RecordPlaintext | null | undefined, imports: object | null | undefined, broadcast: boolean, unchecked: boolean, edition?: number | null): Promise<ProvingRequest>;
3046
+ static buildProvingRequest(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, base_fee_credits: number, priority_fee_credits: number, fee_record: RecordPlaintext | null | undefined, imports: object | null | undefined, broadcast: boolean, unchecked: boolean, edition: number | null | undefined, use_fee_master: boolean): Promise<ProvingRequest>;
3047
+ /**
3048
+ * Build a proving request from a `Request` object. By default this method currently uses the feemaster.
3049
+ *
3050
+ * @param {ExecutionRequest} request The execution request to build the authorization from.
3051
+ * @param {string} program The program source code containing the function to authorize.
3052
+ * @param {boolean} unchecked Whether or not to generate an unchecked authorization.
3053
+ * @param {boolean} broadcast Whether or not to broadcast the transaction.
3054
+ * @param {number | undefined} edition The edition of the program.
3055
+ * @param {object | undefined} imports The imports to the program in the format {"programname.aleo":"aleo instructions source code"}.
3056
+ * @param {PrivateKey | undefined} [private_key] Optional private key of the signer. If not provided, functions which call other programs may not succeed.
3057
+ */
3058
+ static buildProvingRequestFromExecutionRequest(request: ExecutionRequest, program: string, unchecked: boolean, broadcast: boolean, edition?: number | null, imports?: object | null, private_key?: PrivateKey | null): Promise<ProvingRequest>;
2173
3059
  /**
2174
3060
  * Join two records together to create a new record with an amount of credits equal to the sum
2175
3061
  * of the credits of the two original records
@@ -2200,6 +3086,48 @@ export class ProgramManager {
2200
3086
  * @returns {Transaction} Transaction object
2201
3087
  */
2202
3088
  static buildSplitTransaction(private_key: PrivateKey, split_amount: number, amount_record: RecordPlaintext, url?: string | null, split_proving_key?: ProvingKey | null, split_verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null): Promise<Transaction>;
3089
+ /**
3090
+ * Deploy an Aleo program without synthesizing keys and generating certificates.
3091
+ * Intended for use with Leo Devnode.
3092
+ *
3093
+ * @param private_key The private key of the sender
3094
+ * @param program The source code of the program being deployed
3095
+ * @param imports A javascript object holding the source code of any imported programs in the
3096
+ * form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
3097
+ * Note that all imported programs must be deployed on chain before the main program in order
3098
+ * for the deployment to succeed
3099
+ * @param priority_fee_credits The optional priority fee to be paid for the transaction
3100
+ * @param fee_record The record to spend the fee from
3101
+ * @param url The url of the Aleo network node to send the transaction to
3102
+ * @param imports (optional) Provide a list of imports to use for the program deployment in the
3103
+ * form of a javascript object where the keys are a string of the program name and the values
3104
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
3105
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
3106
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
3107
+ * @returns {Transaction}
3108
+ */
3109
+ static buildDevnodeDeploymentTransaction(private_key: PrivateKey, program: string, priority_fee_credits: number, fee_record?: RecordPlaintext | null, url?: string | null, imports?: object | null): Promise<Transaction>;
3110
+ /**
3111
+ * Upgrade a deployed Aleo program without synthesizing keys and generating certificates.
3112
+ * Intended for use with Leo Devnode.
3113
+ *
3114
+ * @param private_key The private key of the sender
3115
+ * @param program The source code of the upgraded program
3116
+ * @param imports A javascript object holding the source code of any imported programs in the
3117
+ * form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
3118
+ * Note that all imported programs must be deployed on chain before the main program in order
3119
+ * for the deployment to succeed
3120
+ * @param priority_fee_credits The optional priority fee to be paid for the transaction
3121
+ * @param fee_record The record to spend the fee from
3122
+ * @param url The url of the Aleo network node to send the transaction to
3123
+ * @param imports (optional) Provide a list of imports to use for the program deployment in the
3124
+ * form of a javascript object where the keys are a string of the program name and the values
3125
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
3126
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
3127
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
3128
+ * @returns {Transaction}
3129
+ */
3130
+ static buildDevnodeUpgradeTransaction(private_key: PrivateKey, program: string, priority_fee_credits: number, fee_record?: RecordPlaintext | null, url?: string | null, imports?: object | null): Promise<Transaction>;
2203
3131
  /**
2204
3132
  * Estimate the component of the deployment cost which comes from the fee for the program name.
2205
3133
  * Note that this cost does not represent the entire cost of deployment. It is additional to
@@ -2243,6 +3171,51 @@ export class ProgramManager {
2243
3171
  * @returns {Transaction}
2244
3172
  */
2245
3173
  static buildDeploymentTransaction(private_key: PrivateKey, program: string, priority_fee_credits: number, fee_record?: RecordPlaintext | null, url?: string | null, imports?: object | null, fee_proving_key?: ProvingKey | null, fee_verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null): Promise<Transaction>;
3174
+ /**
3175
+ * Upgrade an Aleo program
3176
+ *
3177
+ * @param private_key The private key of the sender
3178
+ * @param program The source code of the program being upgraded
3179
+ * @param priority_fee_credits The optional priority fee to be paid for the transaction
3180
+ * @param fee_record The record to spend the fee from
3181
+ * @param url The url of the Aleo network node to send the transaction to
3182
+ * @param imports (optional) Provide a list of imports to use for the program deployment in the
3183
+ * form of a javascript object where the keys are a string of the program name and the values
3184
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
3185
+ * Note that all imported programs must be deployed on chain before the main program in order
3186
+ * for the deployment to succeed
3187
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
3188
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
3189
+ * @returns {Transaction}
3190
+ */
3191
+ static buildUpgradeTransaction(private_key: PrivateKey, program: string, priority_fee_credits: number, fee_record?: RecordPlaintext | null, url?: string | null, imports?: object | null, fee_proving_key?: ProvingKey | null, fee_verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null): Promise<Transaction>;
3192
+ /**
3193
+ * Generate an execution transaction without a proof.
3194
+ * Intended for use with the Leo devnode tool.
3195
+ *
3196
+ * @param private_key The private key of the sender
3197
+ * @param program The source code of the program being executed
3198
+ * @param function The name of the function to execute
3199
+ * @param inputs A javascript array of inputs to the function
3200
+ * @param priority_fee_credits The optional priority fee to be paid for the transaction
3201
+ * @param fee_record The record to spend the fee from
3202
+ * @param url The url of the Aleo network node to send the transaction to
3203
+ * If this is set to 'true' the keys synthesized (or passed in as optional parameters via the
3204
+ * `proving_key` and `verifying_key` arguments) will be stored in the ProgramManager's memory
3205
+ * and used for subsequent transactions. If this is set to 'false' the proving and verifying
3206
+ * keys will be deallocated from memory after the transaction is executed.
3207
+ * @param imports (optional) Provide a list of imports to use for the function execution in the
3208
+ * form of a javascript object where the keys are a string of the program name and the values
3209
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
3210
+ * @param proving_key (optional) Provide a verifying key to use for the function execution
3211
+ * @param verifying_key (optional) Provide a verifying key to use for the function execution
3212
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
3213
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
3214
+ * @param offline_query An offline query object to use if building a transaction without an internet connection.
3215
+ * @param edition The edition of the program to execute. Defaults to the latest found on the network, or 1 if the program does not exist on the network.
3216
+ * @returns {Transaction}
3217
+ */
3218
+ static buildDevnodeExecutionTransaction(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, priority_fee_credits: number, fee_record?: RecordPlaintext | null, url?: string | null, imports?: object | null, edition?: number | null): Promise<Transaction>;
2246
3219
  /**
2247
3220
  * Estimate the finalize fee component for executing a function. This fee is additional to the
2248
3221
  * size of the execution of the program in bytes. If the function does not have a finalize
@@ -2255,26 +3228,31 @@ export class ProgramManager {
2255
3228
  * @returns {u64} Fee in microcredits
2256
3229
  */
2257
3230
  static estimateFinalizeFee(program: string, _function: string): bigint;
3231
+ /**
3232
+ * Execute an authorization.
3233
+ *
3234
+ * @param authorization The authorization to execute.
3235
+ * @param fee_authorization The fee authorization to execute.
3236
+ * @param program The program authorized to be executed.
3237
+ * @param imports The imports of the program being executed.
3238
+ * @param url The url to get the inclusion proving information from.
3239
+ * @param offline_query Optional offline query object if building a Transaction offline.
3240
+ */
3241
+ static executeAuthorization(authorization: Authorization, fee_authorization: Authorization | null | undefined, program: string, proving_key?: ProvingKey | null, verifying_key?: VerifyingKey | null, fee_proving_key?: ProvingKey | null, fee_verifying_key?: VerifyingKey | null, imports?: object | null, url?: string | null, offline_query?: OfflineQuery | null): Promise<Transaction>;
2258
3242
  /**
2259
3243
  * Estimate Fee for Aleo function execution. Note if "cache" is set to true, the proving and
2260
3244
  * verifying keys will be stored in the ProgramManager's memory and used for subsequent
2261
3245
  * program executions.
2262
3246
  *
2263
- * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2264
- *
2265
- * @param private_key The private key of the sender
2266
- * @param program The source code of the program to estimate the execution fee for
2267
- * @param function The name of the function to execute
2268
- * @param inputs A javascript array of inputs to the function
2269
- * @param url The url of the Aleo network node to send the transaction to
3247
+ * @param program The source code of the program to estimate the execution fee for.
3248
+ * @param function The name of the function to estimate the execution fee for.
2270
3249
  * @param imports (optional) Provide a list of imports to use for the fee estimation in the
2271
3250
  * form of a javascript object where the keys are a string of the program name and the values
2272
3251
  * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2273
- * @param proving_key (optional) Provide a verifying key to use for the fee estimation
2274
- * @param verifying_key (optional) Provide a verifying key to use for the fee estimation
3252
+ * @param edition {
2275
3253
  * @returns {u64} Fee in microcredits
2276
3254
  */
2277
- static estimateExecutionFee(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, url?: string | null, imports?: object | null, proving_key?: ProvingKey | null, verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null, edition?: number | null): Promise<bigint>;
3255
+ static estimateExecutionFee(program: string, _function: string, imports?: object | null, edition?: number | null): bigint;
2278
3256
  /**
2279
3257
  * Execute an arbitrary function locally
2280
3258
  *
@@ -2296,6 +3274,20 @@ export class ProgramManager {
2296
3274
  * @param {VerifyingKey | undefined} verifying_key (optional) Provide a verifying key to use for the function execution
2297
3275
  */
2298
3276
  static executeFunctionOffline(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, prove_execution: boolean, cache: boolean, imports?: object | null, proving_key?: ProvingKey | null, verifying_key?: VerifyingKey | null, url?: string | null, offline_query?: OfflineQuery | null, edition?: number | null): Promise<ExecutionResponse>;
3277
+ /**
3278
+ * Estimate Fee for an Authorization.
3279
+ *
3280
+ * @param authorization Authorization to estimate the fee for.
3281
+ * @param program The program the Authorization is for.
3282
+ * @param imports Provide a list of imports to use for the fee estimation in the
3283
+ * form of a javascript object where the keys are a string of the program name and the values
3284
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
3285
+ * @param offline_query The offline query object used to insert the global state root and state paths needed to create
3286
+ * a valid inclusion proof offline.
3287
+ * @param edition: Optional edition to estimate the fee for.
3288
+ * @returns {u64} Fee in microcredits
3289
+ */
3290
+ static estimateFeeForAuthorization(authorization: Authorization, program: string, imports?: object | null, edition?: number | null): bigint;
2299
3291
  /**
2300
3292
  * Execute Aleo function and create an Aleo execution transaction
2301
3293
  *
@@ -2353,6 +3345,17 @@ export class ProgramManager {
2353
3345
  * @returns {Authorization}
2354
3346
  */
2355
3347
  static authorizeFee(private_key: PrivateKey, deployment_or_execution_id: string, base_fee_credits: number, priority_fee_credits: number, fee_record?: RecordPlaintext | null): Promise<Authorization>;
3348
+ /**
3349
+ * Build an authorization from a `Request` object.
3350
+ *
3351
+ * @param {ExecutionRequest} request The execution request to build the authorization from.
3352
+ * @param {string} program The program source code containing the function to authorize.
3353
+ * @param {boolean} unchecked Whether or not to generate an unchecked authorization.
3354
+ * @param {number | undefined} edition The edition of the program.
3355
+ * @param {object | undefined} imports The imports to the program in the format {"programname.aleo":"aleo instructions source code"}.
3356
+ * @param {PrivateKey | undefined} [private_key] Optional private key of the signer. If not provided, functions which call other programs may not succeed.
3357
+ */
3358
+ static buildAuthorizationFromExecutionRequest(request: ExecutionRequest, program: string, unchecked: boolean, edition?: number | null, imports?: object | null, private_key?: PrivateKey | null): Promise<Authorization>;
2356
3359
  /**
2357
3360
  * Create an execution `Authorization` without generating a circuit. Use this function when
2358
3361
  * fast delegated proving is needed.
@@ -2375,12 +3378,47 @@ export class ProgramManager {
2375
3378
  */
2376
3379
  static authorize(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, imports?: object | null, edition?: number | null): Promise<Authorization>;
2377
3380
  }
3381
+ /**
3382
+ * SNARK proof for verification of program execution
3383
+ */
3384
+ export class Proof {
3385
+ private constructor();
3386
+ free(): void;
3387
+ [Symbol.dispose](): void;
3388
+ /**
3389
+ * Construct a new proof from a byte array
3390
+ *
3391
+ * @param {Uint8Array} bytes Byte array representation of a proof
3392
+ * @returns {Proof}
3393
+ */
3394
+ static fromBytes(bytes: Uint8Array): Proof;
3395
+ /**
3396
+ * Create a proof from string
3397
+ *
3398
+ * @param {string} string String representation of the proof
3399
+ * @returns {Proof}
3400
+ */
3401
+ static fromString(string: string): Proof;
3402
+ /**
3403
+ * Return the byte representation of a proof
3404
+ *
3405
+ * @returns {Uint8Array} Byte array representation of a proof
3406
+ */
3407
+ toBytes(): Uint8Array;
3408
+ /**
3409
+ * Get a string representation of the proof
3410
+ *
3411
+ * @returns {string} String representation of the proof
3412
+ */
3413
+ toString(): string;
3414
+ }
2378
3415
  /**
2379
3416
  * Proving key for a function within an Aleo program
2380
3417
  */
2381
3418
  export class ProvingKey {
2382
3419
  private constructor();
2383
3420
  free(): void;
3421
+ [Symbol.dispose](): void;
2384
3422
  /**
2385
3423
  * Construct a new proving key from a byte array
2386
3424
  *
@@ -2575,6 +3613,7 @@ export class ProvingKey {
2575
3613
  export class ProvingRequest {
2576
3614
  private constructor();
2577
3615
  free(): void;
3616
+ [Symbol.dispose](): void;
2578
3617
  /**
2579
3618
  * Creates a ProvingRequest from a string representation.
2580
3619
  *
@@ -2626,6 +3665,7 @@ export class ProvingRequest {
2626
3665
  export class RecordCiphertext {
2627
3666
  private constructor();
2628
3667
  free(): void;
3668
+ [Symbol.dispose](): void;
2629
3669
  /**
2630
3670
  * Get the left endian boolean array representation of the record ciphertext bits.
2631
3671
  *
@@ -2725,6 +3765,7 @@ export class RecordCiphertext {
2725
3765
  export class RecordPlaintext {
2726
3766
  private constructor();
2727
3767
  free(): void;
3768
+ [Symbol.dispose](): void;
2728
3769
  commitment(program_id: string, record_name: string, record_view_key: string): Field;
2729
3770
  /**
2730
3771
  * Get the record entry matching a key.
@@ -2821,7 +3862,16 @@ export class RecordPlaintext {
2821
3862
  */
2822
3863
  static fromBytesLe(bytes: Uint8Array): RecordPlaintext;
2823
3864
  /**
2824
- * Generate the record view key. The record view key can only decrypt record if the
3865
+ * Decrypt the sender ciphertext associated with the record.
3866
+ *
3867
+ * @param {ViewKey} view_key View key associated with the record.
3868
+ * @param {Field} sender_ciphertext Sender ciphertext associated with the record.
3869
+ *
3870
+ * @returns {Address} address of the sender.
3871
+ */
3872
+ decryptSender(view_key: ViewKey, sender_ciphertext: Field): Address;
3873
+ /**
3874
+ * Generate the record view key. The record view key can only decrypt the record if the
2825
3875
  * supplied view key belongs to the record owner.
2826
3876
  *
2827
3877
  * @param {ViewKey} view_key View key used to generate the record view key
@@ -2850,6 +3900,15 @@ export class RecordPlaintext {
2850
3900
  * @returns {RecordPlaintext} A clone of the RecordPlaintext WASM object.
2851
3901
  */
2852
3902
  clone(): RecordPlaintext;
3903
+ /**
3904
+ * Compute the record's gamma value.
3905
+ *
3906
+ * @param {string} program_id The program id that produced the record.
3907
+ * @param {string} record_name The name of the record within the program.
3908
+ * @param {PrivateKey} private_key The private key that created the record.
3909
+ * @returns {Group} The computed value of gamma.
3910
+ */
3911
+ gamma(program_id: string, record_name: string, private_key: PrivateKey): Group;
2853
3912
  /**
2854
3913
  * Returns the nonce of the record. This can be used to uniquely identify a record.
2855
3914
  *
@@ -2879,30 +3938,93 @@ export class RecordPlaintext {
2879
3938
  export class Scalar {
2880
3939
  private constructor();
2881
3940
  free(): void;
3941
+ [Symbol.dispose](): void;
3942
+ /**
3943
+ * Cast the scalar to an Address (strict, via Field x-coordinate recovery).
3944
+ * Returns an error if the resulting field is not a valid x-coordinate on the curve.
3945
+ */
3946
+ toAddress(): Address;
3947
+ /**
3948
+ * Get the left endian boolean array representation of the scalar element.
3949
+ */
3950
+ toBitsLe(): Array<any>;
3951
+ /**
3952
+ * Cast the scalar to a Boolean (strict).
3953
+ * Returns an error if the scalar is not zero or one.
3954
+ */
3955
+ toBoolean(): Boolean;
3956
+ /**
3957
+ * Creates a scalar object from a string representation of a scalar element.
3958
+ */
3959
+ static fromString(group: string): Scalar;
3960
+ /**
3961
+ * Encode the scalar element as a Uint8Array of left endian bytes.
3962
+ */
3963
+ toBytesLe(): Uint8Array;
3964
+ /**
3965
+ * Cast the scalar to an I8 with lossy truncation.
3966
+ */
3967
+ toI8Lossy(): I8;
3968
+ /**
3969
+ * Cast the scalar to a U8 with lossy truncation.
3970
+ */
3971
+ toU8Lossy(): U8;
3972
+ /**
3973
+ * Reconstruct a scalar element from a boolean array representation.
3974
+ */
3975
+ static fromBitsLe(bits: Array<any>): Scalar;
3976
+ /**
3977
+ * Cast the scalar to an I16 with lossy truncation.
3978
+ */
3979
+ toI16Lossy(): I16;
3980
+ /**
3981
+ * Cast the scalar to an I32 with lossy truncation.
3982
+ */
3983
+ toI32Lossy(): I32;
3984
+ /**
3985
+ * Cast the scalar to an I64 with lossy truncation.
3986
+ */
3987
+ toI64Lossy(): I64;
3988
+ /**
3989
+ * Create a plaintext element from a scalar element.
3990
+ */
3991
+ toPlaintext(): Plaintext;
3992
+ /**
3993
+ * Cast the scalar to a U16 with lossy truncation.
3994
+ */
3995
+ toU16Lossy(): U16;
3996
+ /**
3997
+ * Cast the scalar to a U32 with lossy truncation.
3998
+ */
3999
+ toU32Lossy(): U32;
2882
4000
  /**
2883
- * Get the left endian boolean array representation of the scalar element.
4001
+ * Cast the scalar to a U64 with lossy truncation.
2884
4002
  */
2885
- toBitsLe(): Array<any>;
4003
+ toU64Lossy(): U64;
2886
4004
  /**
2887
- * Creates a scalar object from a string representation of a scalar element.
4005
+ * Create a scalar element from a Uint8Array of left endian bytes.
2888
4006
  */
2889
- static fromString(group: string): Scalar;
4007
+ static fromBytesLe(bytes: Uint8Array): Scalar;
2890
4008
  /**
2891
- * Encode the scalar element as a Uint8Array of left endian bytes.
4009
+ * Cast the scalar to an I128 with lossy truncation.
2892
4010
  */
2893
- toBytesLe(): Uint8Array;
4011
+ toI128Lossy(): I128;
2894
4012
  /**
2895
- * Reconstruct a scalar element from a boolean array representation.
4013
+ * Cast the scalar to a U128 with lossy truncation.
2896
4014
  */
2897
- static fromBitsLe(bits: Array<any>): Scalar;
4015
+ toU128Lossy(): U128;
2898
4016
  /**
2899
- * Create a plaintext element from a scalar element.
4017
+ * Cast the scalar to a Group element with lossy conversion (via Field, Elligator-2 fallback).
2900
4018
  */
2901
- toPlaintext(): Plaintext;
4019
+ toGroupLossy(): Group;
2902
4020
  /**
2903
- * Create a scalar element from a Uint8Array of left endian bytes.
4021
+ * Cast the scalar to an Address with lossy conversion (via Group, Elligator-2 fallback).
2904
4022
  */
2905
- static fromBytesLe(bytes: Uint8Array): Scalar;
4023
+ toAddressLossy(): Address;
4024
+ /**
4025
+ * Cast the scalar to a Boolean with lossy truncation (extracts least-significant bit).
4026
+ */
4027
+ toBooleanLossy(): Boolean;
2906
4028
  /**
2907
4029
  * Add two scalar elements.
2908
4030
  */
@@ -2955,6 +4077,11 @@ export class Scalar {
2955
4077
  * Cast the scalar element to a field element.
2956
4078
  */
2957
4079
  toField(): Field;
4080
+ /**
4081
+ * Cast the scalar to a Group element (strict, via Field x-coordinate recovery).
4082
+ * Returns an error if the resulting field is not a valid x-coordinate on the curve.
4083
+ */
4084
+ toGroup(): Group;
2958
4085
  /**
2959
4086
  * Returns the string representation of the scalar element.
2960
4087
  */
@@ -2966,6 +4093,15 @@ export class Scalar {
2966
4093
  export class Signature {
2967
4094
  private constructor();
2968
4095
  free(): void;
4096
+ [Symbol.dispose](): void;
4097
+ /**
4098
+ * Sign an instance of a valid Aleo data type or record.
4099
+ *
4100
+ * @param {PrivateKey} private_key The private key used to sign the message.
4101
+ * @param {String} message The string representation of the Aleo datatype or record to sign.
4102
+ * @returns {Signature} Signature of the message.
4103
+ */
4104
+ static signValue(private_key: PrivateKey, message: string): Signature;
2969
4105
  /**
2970
4106
  * Get an address from a signature.
2971
4107
  *
@@ -2999,6 +4135,20 @@ export class Signature {
2999
4135
  * Get the plaintext representation of the signature.
3000
4136
  */
3001
4137
  toPlaintext(): Plaintext;
4138
+ /**
4139
+ * Get a string representation of a signature
4140
+ *
4141
+ * @returns {string} String representation of a signature
4142
+ */
4143
+ toString(): string;
4144
+ /**
4145
+ * Verify a signature over an Aleo datatype or record by an address.
4146
+ *
4147
+ * @param {Address} address The address used to verify the signature.
4148
+ * @param {String} message The message to verify, which must be the string representation of a valid Aleo datatype or record.
4149
+ * @returns {boolean} True if the signature is valid, false otherwise.
4150
+ */
4151
+ verifyValue(address: Address, message: string): boolean;
3002
4152
  /**
3003
4153
  * Get a signature from a series of bytes.
3004
4154
  *
@@ -3051,6 +4201,7 @@ export class Signature {
3051
4201
  export class Transaction {
3052
4202
  private constructor();
3053
4203
  free(): void;
4204
+ [Symbol.dispose](): void;
3054
4205
  /**
3055
4206
  * Returns the transaction's total fee.
3056
4207
  */
@@ -3200,6 +4351,7 @@ export class Transaction {
3200
4351
  export class Transition {
3201
4352
  private constructor();
3202
4353
  free(): void;
4354
+ [Symbol.dispose](): void;
3203
4355
  /**
3204
4356
  * Get the program ID of the transition.
3205
4357
  */
@@ -3329,6 +4481,7 @@ export class Transition {
3329
4481
  export class U128 {
3330
4482
  private constructor();
3331
4483
  free(): void;
4484
+ [Symbol.dispose](): void;
3332
4485
  /**
3333
4486
  * Attempt to construct the integer from a field element.
3334
4487
  */
@@ -3377,18 +4530,66 @@ export class U128 {
3377
4530
  * Construct an integer from a byte array representation.
3378
4531
  */
3379
4532
  toBytesLe(): Uint8Array;
4533
+ /**
4534
+ * Cast to I8 with lossy truncation.
4535
+ */
4536
+ toI8Lossy(): I8;
4537
+ /**
4538
+ * Cast to U8 with lossy truncation.
4539
+ */
4540
+ toU8Lossy(): U8;
3380
4541
  /**
3381
4542
  * Construct an integer from a boolean array representation.
3382
4543
  */
3383
4544
  static fromBitsLe(bits: Array<any>): U128;
4545
+ /**
4546
+ * Cast to I16 with lossy truncation.
4547
+ */
4548
+ toI16Lossy(): I16;
4549
+ /**
4550
+ * Cast to I32 with lossy truncation.
4551
+ */
4552
+ toI32Lossy(): I32;
4553
+ /**
4554
+ * Cast to I64 with lossy truncation.
4555
+ */
4556
+ toI64Lossy(): I64;
3384
4557
  /**
3385
4558
  * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
3386
4559
  */
3387
4560
  toPlaintext(): Plaintext;
4561
+ /**
4562
+ * Cast to U16 with lossy truncation.
4563
+ */
4564
+ toU16Lossy(): U16;
4565
+ /**
4566
+ * Cast to U32 with lossy truncation.
4567
+ */
4568
+ toU32Lossy(): U32;
4569
+ /**
4570
+ * Cast to U64 with lossy truncation.
4571
+ */
4572
+ toU64Lossy(): U64;
3388
4573
  /**
3389
4574
  * Get the byte array representation of the integer.
3390
4575
  */
3391
4576
  static fromBytesLe(bytes: Uint8Array): U128;
4577
+ /**
4578
+ * Cast to I128 with lossy truncation.
4579
+ */
4580
+ toI128Lossy(): I128;
4581
+ /**
4582
+ * Cast to U128 with lossy truncation.
4583
+ */
4584
+ toU128Lossy(): U128;
4585
+ /**
4586
+ * Construct an integer from a field element with lossy truncation.
4587
+ */
4588
+ static fromFieldLossy(field: Field): U128;
4589
+ /**
4590
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
4591
+ */
4592
+ toBooleanLossy(): Boolean;
3392
4593
  /**
3393
4594
  * Negate the integer (e.g., 5 → -5).
3394
4595
  */
@@ -3417,6 +4618,10 @@ export class U128 {
3417
4618
  * Exponentiate the integer with a u32 exponent.
3418
4619
  */
3419
4620
  powU32(exponent: U32): U128;
4621
+ /**
4622
+ * Convert the integer to a Field element (lossless).
4623
+ */
4624
+ toField(): Field;
3420
4625
  /**
3421
4626
  * Convert the integer to a Scalar value.
3422
4627
  */
@@ -3429,6 +4634,7 @@ export class U128 {
3429
4634
  export class U16 {
3430
4635
  private constructor();
3431
4636
  free(): void;
4637
+ [Symbol.dispose](): void;
3432
4638
  /**
3433
4639
  * Attempt to construct the integer from a field element.
3434
4640
  */
@@ -3477,18 +4683,66 @@ export class U16 {
3477
4683
  * Construct an integer from a byte array representation.
3478
4684
  */
3479
4685
  toBytesLe(): Uint8Array;
4686
+ /**
4687
+ * Cast to I8 with lossy truncation.
4688
+ */
4689
+ toI8Lossy(): I8;
4690
+ /**
4691
+ * Cast to U8 with lossy truncation.
4692
+ */
4693
+ toU8Lossy(): U8;
3480
4694
  /**
3481
4695
  * Construct an integer from a boolean array representation.
3482
4696
  */
3483
4697
  static fromBitsLe(bits: Array<any>): U16;
4698
+ /**
4699
+ * Cast to I16 with lossy truncation.
4700
+ */
4701
+ toI16Lossy(): I16;
4702
+ /**
4703
+ * Cast to I32 with lossy truncation.
4704
+ */
4705
+ toI32Lossy(): I32;
4706
+ /**
4707
+ * Cast to I64 with lossy truncation.
4708
+ */
4709
+ toI64Lossy(): I64;
3484
4710
  /**
3485
4711
  * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
3486
4712
  */
3487
4713
  toPlaintext(): Plaintext;
4714
+ /**
4715
+ * Cast to U16 with lossy truncation.
4716
+ */
4717
+ toU16Lossy(): U16;
4718
+ /**
4719
+ * Cast to U32 with lossy truncation.
4720
+ */
4721
+ toU32Lossy(): U32;
4722
+ /**
4723
+ * Cast to U64 with lossy truncation.
4724
+ */
4725
+ toU64Lossy(): U64;
3488
4726
  /**
3489
4727
  * Get the byte array representation of the integer.
3490
4728
  */
3491
4729
  static fromBytesLe(bytes: Uint8Array): U16;
4730
+ /**
4731
+ * Cast to I128 with lossy truncation.
4732
+ */
4733
+ toI128Lossy(): I128;
4734
+ /**
4735
+ * Cast to U128 with lossy truncation.
4736
+ */
4737
+ toU128Lossy(): U128;
4738
+ /**
4739
+ * Construct an integer from a field element with lossy truncation.
4740
+ */
4741
+ static fromFieldLossy(field: Field): U16;
4742
+ /**
4743
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
4744
+ */
4745
+ toBooleanLossy(): Boolean;
3492
4746
  /**
3493
4747
  * Negate the integer (e.g., 5 → -5).
3494
4748
  */
@@ -3517,6 +4771,10 @@ export class U16 {
3517
4771
  * Exponentiate the integer with a u32 exponent.
3518
4772
  */
3519
4773
  powU32(exponent: U32): U16;
4774
+ /**
4775
+ * Convert the integer to a Field element (lossless).
4776
+ */
4777
+ toField(): Field;
3520
4778
  /**
3521
4779
  * Convert the integer to a Scalar value.
3522
4780
  */
@@ -3529,6 +4787,7 @@ export class U16 {
3529
4787
  export class U32 {
3530
4788
  private constructor();
3531
4789
  free(): void;
4790
+ [Symbol.dispose](): void;
3532
4791
  /**
3533
4792
  * Attempt to construct the integer from a field element.
3534
4793
  */
@@ -3577,18 +4836,66 @@ export class U32 {
3577
4836
  * Construct an integer from a byte array representation.
3578
4837
  */
3579
4838
  toBytesLe(): Uint8Array;
4839
+ /**
4840
+ * Cast to I8 with lossy truncation.
4841
+ */
4842
+ toI8Lossy(): I8;
4843
+ /**
4844
+ * Cast to U8 with lossy truncation.
4845
+ */
4846
+ toU8Lossy(): U8;
3580
4847
  /**
3581
4848
  * Construct an integer from a boolean array representation.
3582
4849
  */
3583
4850
  static fromBitsLe(bits: Array<any>): U32;
4851
+ /**
4852
+ * Cast to I16 with lossy truncation.
4853
+ */
4854
+ toI16Lossy(): I16;
4855
+ /**
4856
+ * Cast to I32 with lossy truncation.
4857
+ */
4858
+ toI32Lossy(): I32;
4859
+ /**
4860
+ * Cast to I64 with lossy truncation.
4861
+ */
4862
+ toI64Lossy(): I64;
3584
4863
  /**
3585
4864
  * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
3586
4865
  */
3587
4866
  toPlaintext(): Plaintext;
4867
+ /**
4868
+ * Cast to U16 with lossy truncation.
4869
+ */
4870
+ toU16Lossy(): U16;
4871
+ /**
4872
+ * Cast to U32 with lossy truncation.
4873
+ */
4874
+ toU32Lossy(): U32;
4875
+ /**
4876
+ * Cast to U64 with lossy truncation.
4877
+ */
4878
+ toU64Lossy(): U64;
3588
4879
  /**
3589
4880
  * Get the byte array representation of the integer.
3590
4881
  */
3591
4882
  static fromBytesLe(bytes: Uint8Array): U32;
4883
+ /**
4884
+ * Cast to I128 with lossy truncation.
4885
+ */
4886
+ toI128Lossy(): I128;
4887
+ /**
4888
+ * Cast to U128 with lossy truncation.
4889
+ */
4890
+ toU128Lossy(): U128;
4891
+ /**
4892
+ * Construct an integer from a field element with lossy truncation.
4893
+ */
4894
+ static fromFieldLossy(field: Field): U32;
4895
+ /**
4896
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
4897
+ */
4898
+ toBooleanLossy(): Boolean;
3592
4899
  /**
3593
4900
  * Negate the integer (e.g., 5 → -5).
3594
4901
  */
@@ -3617,6 +4924,10 @@ export class U32 {
3617
4924
  * Exponentiate the integer with a u32 exponent.
3618
4925
  */
3619
4926
  powU32(exponent: U32): U32;
4927
+ /**
4928
+ * Convert the integer to a Field element (lossless).
4929
+ */
4930
+ toField(): Field;
3620
4931
  /**
3621
4932
  * Convert the integer to a Scalar value.
3622
4933
  */
@@ -3629,6 +4940,7 @@ export class U32 {
3629
4940
  export class U64 {
3630
4941
  private constructor();
3631
4942
  free(): void;
4943
+ [Symbol.dispose](): void;
3632
4944
  /**
3633
4945
  * Attempt to construct the integer from a field element.
3634
4946
  */
@@ -3677,18 +4989,66 @@ export class U64 {
3677
4989
  * Construct an integer from a byte array representation.
3678
4990
  */
3679
4991
  toBytesLe(): Uint8Array;
4992
+ /**
4993
+ * Cast to I8 with lossy truncation.
4994
+ */
4995
+ toI8Lossy(): I8;
4996
+ /**
4997
+ * Cast to U8 with lossy truncation.
4998
+ */
4999
+ toU8Lossy(): U8;
3680
5000
  /**
3681
5001
  * Construct an integer from a boolean array representation.
3682
5002
  */
3683
5003
  static fromBitsLe(bits: Array<any>): U64;
5004
+ /**
5005
+ * Cast to I16 with lossy truncation.
5006
+ */
5007
+ toI16Lossy(): I16;
5008
+ /**
5009
+ * Cast to I32 with lossy truncation.
5010
+ */
5011
+ toI32Lossy(): I32;
5012
+ /**
5013
+ * Cast to I64 with lossy truncation.
5014
+ */
5015
+ toI64Lossy(): I64;
3684
5016
  /**
3685
5017
  * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
3686
5018
  */
3687
5019
  toPlaintext(): Plaintext;
5020
+ /**
5021
+ * Cast to U16 with lossy truncation.
5022
+ */
5023
+ toU16Lossy(): U16;
5024
+ /**
5025
+ * Cast to U32 with lossy truncation.
5026
+ */
5027
+ toU32Lossy(): U32;
5028
+ /**
5029
+ * Cast to U64 with lossy truncation.
5030
+ */
5031
+ toU64Lossy(): U64;
3688
5032
  /**
3689
5033
  * Get the byte array representation of the integer.
3690
5034
  */
3691
5035
  static fromBytesLe(bytes: Uint8Array): U64;
5036
+ /**
5037
+ * Cast to I128 with lossy truncation.
5038
+ */
5039
+ toI128Lossy(): I128;
5040
+ /**
5041
+ * Cast to U128 with lossy truncation.
5042
+ */
5043
+ toU128Lossy(): U128;
5044
+ /**
5045
+ * Construct an integer from a field element with lossy truncation.
5046
+ */
5047
+ static fromFieldLossy(field: Field): U64;
5048
+ /**
5049
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
5050
+ */
5051
+ toBooleanLossy(): Boolean;
3692
5052
  /**
3693
5053
  * Negate the integer (e.g., 5 → -5).
3694
5054
  */
@@ -3717,6 +5077,10 @@ export class U64 {
3717
5077
  * Exponentiate the integer with a u32 exponent.
3718
5078
  */
3719
5079
  powU32(exponent: U32): U64;
5080
+ /**
5081
+ * Convert the integer to a Field element (lossless).
5082
+ */
5083
+ toField(): Field;
3720
5084
  /**
3721
5085
  * Convert the integer to a Scalar value.
3722
5086
  */
@@ -3729,6 +5093,7 @@ export class U64 {
3729
5093
  export class U8 {
3730
5094
  private constructor();
3731
5095
  free(): void;
5096
+ [Symbol.dispose](): void;
3732
5097
  /**
3733
5098
  * Attempt to construct the integer from a field element.
3734
5099
  */
@@ -3777,18 +5142,66 @@ export class U8 {
3777
5142
  * Construct an integer from a byte array representation.
3778
5143
  */
3779
5144
  toBytesLe(): Uint8Array;
5145
+ /**
5146
+ * Cast to I8 with lossy truncation.
5147
+ */
5148
+ toI8Lossy(): I8;
5149
+ /**
5150
+ * Cast to U8 with lossy truncation.
5151
+ */
5152
+ toU8Lossy(): U8;
3780
5153
  /**
3781
5154
  * Construct an integer from a boolean array representation.
3782
5155
  */
3783
5156
  static fromBitsLe(bits: Array<any>): U8;
5157
+ /**
5158
+ * Cast to I16 with lossy truncation.
5159
+ */
5160
+ toI16Lossy(): I16;
5161
+ /**
5162
+ * Cast to I32 with lossy truncation.
5163
+ */
5164
+ toI32Lossy(): I32;
5165
+ /**
5166
+ * Cast to I64 with lossy truncation.
5167
+ */
5168
+ toI64Lossy(): I64;
3784
5169
  /**
3785
5170
  * Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
3786
5171
  */
3787
5172
  toPlaintext(): Plaintext;
5173
+ /**
5174
+ * Cast to U16 with lossy truncation.
5175
+ */
5176
+ toU16Lossy(): U16;
5177
+ /**
5178
+ * Cast to U32 with lossy truncation.
5179
+ */
5180
+ toU32Lossy(): U32;
5181
+ /**
5182
+ * Cast to U64 with lossy truncation.
5183
+ */
5184
+ toU64Lossy(): U64;
3788
5185
  /**
3789
5186
  * Get the byte array representation of the integer.
3790
5187
  */
3791
5188
  static fromBytesLe(bytes: Uint8Array): U8;
5189
+ /**
5190
+ * Cast to I128 with lossy truncation.
5191
+ */
5192
+ toI128Lossy(): I128;
5193
+ /**
5194
+ * Cast to U128 with lossy truncation.
5195
+ */
5196
+ toU128Lossy(): U128;
5197
+ /**
5198
+ * Construct an integer from a field element with lossy truncation.
5199
+ */
5200
+ static fromFieldLossy(field: Field): U8;
5201
+ /**
5202
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
5203
+ */
5204
+ toBooleanLossy(): Boolean;
3792
5205
  /**
3793
5206
  * Negate the integer (e.g., 5 → -5).
3794
5207
  */
@@ -3817,6 +5230,10 @@ export class U8 {
3817
5230
  * Exponentiate the integer with a u32 exponent.
3818
5231
  */
3819
5232
  powU32(exponent: U32): U8;
5233
+ /**
5234
+ * Convert the integer to a Field element (lossless).
5235
+ */
5236
+ toField(): Field;
3820
5237
  /**
3821
5238
  * Convert the integer to a Scalar value.
3822
5239
  */
@@ -3826,12 +5243,145 @@ export class U8 {
3826
5243
  */
3827
5244
  toString(): string;
3828
5245
  }
5246
+ /**
5247
+ * Aleo Value type. Value is the fundamental type representing program function inputs and outputs
5248
+ * in Aleo. It wraps three variants: Plaintext, Record, and Future.
5249
+ *
5250
+ * @example
5251
+ * // Parse a plaintext value from a string.
5252
+ * const value = Value.fromString("100u64");
5253
+ * console.log(value.valueType()); // "plaintext"
5254
+ * console.log(value.isPlaintext()); // true
5255
+ *
5256
+ * // Extract the inner Plaintext.
5257
+ * const plaintext = value.toPlaintext();
5258
+ * console.log(plaintext.toString()); // "100u64"
5259
+ */
5260
+ export class Value {
5261
+ private constructor();
5262
+ free(): void;
5263
+ [Symbol.dispose](): void;
5264
+ /**
5265
+ * Returns the little-endian boolean array representation of the bits.
5266
+ *
5267
+ * @returns {Array} Boolean array of bits in little-endian order.
5268
+ */
5269
+ toBitsLe(): Array<any>;
5270
+ /**
5271
+ * Returns the type of the value variant as a string.
5272
+ *
5273
+ * Possible values: "plaintext", "record", "future", "dynamic_record", or "dynamic_future".
5274
+ *
5275
+ * @returns {string} The variant type name.
5276
+ */
5277
+ valueType(): string;
5278
+ /**
5279
+ * Creates a Value from its string representation.
5280
+ *
5281
+ * @param {string} value The string representation of the value.
5282
+ * @returns {Value} The Value object.
5283
+ */
5284
+ static fromString(value: string): Value;
5285
+ /**
5286
+ * Returns the little-endian byte array representation of the value.
5287
+ *
5288
+ * @returns {Uint8Array} The little-endian byte array.
5289
+ */
5290
+ toBytesLe(): Uint8Array;
5291
+ /**
5292
+ * Returns true if the value is a Plaintext variant.
5293
+ *
5294
+ * @returns {boolean}
5295
+ */
5296
+ isPlaintext(): boolean;
5297
+ /**
5298
+ * Extracts the inner Plaintext from a Plaintext variant.
5299
+ *
5300
+ * @returns {Plaintext} The inner Plaintext value.
5301
+ * @throws If the value is not a Plaintext variant.
5302
+ */
5303
+ toPlaintext(): Plaintext;
5304
+ /**
5305
+ * Creates a Value from a little-endian byte array.
5306
+ *
5307
+ * @param {Uint8Array} bytes A little-endian byte array.
5308
+ * @returns {Value} The Value object.
5309
+ */
5310
+ static fromBytesLe(bytes: Uint8Array): Value;
5311
+ /**
5312
+ * Returns the raw field array representation of the value.
5313
+ *
5314
+ * @returns {Array} Array of raw Field elements.
5315
+ */
5316
+ toFieldsRaw(): Array<any>;
5317
+ /**
5318
+ * Creates a Value from a Plaintext object.
5319
+ *
5320
+ * @param {Plaintext} plaintext The Plaintext to wrap.
5321
+ * @returns {Value} A Value wrapping the Plaintext.
5322
+ */
5323
+ static fromPlaintext(plaintext: Plaintext): Value;
5324
+ /**
5325
+ * Returns the raw big-endian boolean array representation of the bits.
5326
+ *
5327
+ * @returns {Array} Raw boolean array of bits in big-endian order.
5328
+ */
5329
+ toBitsRawBe(): Array<any>;
5330
+ /**
5331
+ * Returns the raw little-endian boolean array representation of the bits.
5332
+ *
5333
+ * @returns {Array} Raw boolean array of bits in little-endian order.
5334
+ */
5335
+ toBitsRawLe(): Array<any>;
5336
+ /**
5337
+ * Extracts the inner Record from a Record variant as a RecordPlaintext.
5338
+ *
5339
+ * @returns {RecordPlaintext} The inner record.
5340
+ * @throws If the value is not a Record variant.
5341
+ */
5342
+ toRecordPlaintext(): RecordPlaintext;
5343
+ /**
5344
+ * Creates a Value from a RecordPlaintext object.
5345
+ *
5346
+ * @param {RecordPlaintext} record The RecordPlaintext to wrap.
5347
+ * @returns {Value} A Value wrapping the Record.
5348
+ */
5349
+ static fromRecordPlaintext(record: RecordPlaintext): Value;
5350
+ /**
5351
+ * Returns true if the value is a Future variant.
5352
+ *
5353
+ * Note: There is no `toFuture()` method because the Future type does not have a WASM wrapper.
5354
+ * Use `toString()` or `toBytesLe()` to serialize a Future value.
5355
+ *
5356
+ * @returns {boolean}
5357
+ */
5358
+ isFuture(): boolean;
5359
+ /**
5360
+ * Returns true if the value is a Record variant.
5361
+ *
5362
+ * @returns {boolean}
5363
+ */
5364
+ isRecord(): boolean;
5365
+ /**
5366
+ * Returns the field array representation of the value.
5367
+ *
5368
+ * @returns {Array} Array of Field elements.
5369
+ */
5370
+ toFields(): Array<any>;
5371
+ /**
5372
+ * Returns the string representation of the value.
5373
+ *
5374
+ * @returns {string} The string representation of the value.
5375
+ */
5376
+ toString(): string;
5377
+ }
3829
5378
  /**
3830
5379
  * Verifying key for a function within an Aleo program
3831
5380
  */
3832
5381
  export class VerifyingKey {
3833
5382
  private constructor();
3834
5383
  free(): void;
5384
+ [Symbol.dispose](): void;
3835
5385
  /**
3836
5386
  * Construct a new verifying key from a byte array
3837
5387
  *
@@ -3852,12 +5402,29 @@ export class VerifyingKey {
3852
5402
  * @returns {number} The number of constraints
3853
5403
  */
3854
5404
  numConstraints(): number;
5405
+ /**
5406
+ * Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
5407
+ *
5408
+ * @param {Array<string>} verifying_keys Array of verifying key strings, one per circuit
5409
+ * @param {Array<Array<Array<string>>>} inputs 3D array of field element strings [circuit_idx][instance_idx][field_idx]
5410
+ * @param {Proof} proof The batch proof to verify
5411
+ * @returns {boolean} True if the batch proof is valid, false otherwise
5412
+ */
5413
+ static verifyBatch(verifying_keys: Array<any>, inputs: Array<any>, proof: Proof): boolean;
3855
5414
  /**
3856
5415
  * Create a copy of the verifying key
3857
5416
  *
3858
5417
  * @returns {VerifyingKey} A copy of the verifying key
3859
5418
  */
3860
5419
  copy(): VerifyingKey;
5420
+ /**
5421
+ * Verify a SNARK proof against this verifying key and public inputs.
5422
+ *
5423
+ * @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
5424
+ * @param {Proof} proof The proof to verify
5425
+ * @returns {boolean} True if the proof is valid, false otherwise
5426
+ */
5427
+ verify(inputs: Array<any>, proof: Proof): boolean;
3861
5428
  /**
3862
5429
  * Get the checksum of the verifying key
3863
5430
  *
@@ -4060,6 +5627,7 @@ export class VerifyingKey {
4060
5627
  export class ViewKey {
4061
5628
  private constructor();
4062
5629
  free(): void;
5630
+ [Symbol.dispose](): void;
4063
5631
  /**
4064
5632
  * Get the address corresponding to a view key
4065
5633
  *
@@ -4073,6 +5641,26 @@ export class ViewKey {
4073
5641
  * @returns {ViewKey} View key
4074
5642
  */
4075
5643
  static from_string(view_key: string): ViewKey;
5644
+ /**
5645
+ * Get the underlying bytes of a view key.
5646
+ *
5647
+ * @returns {Uint8Array} Left endian byte array representation of the view key.
5648
+ */
5649
+ toBytesLe(): Uint8Array;
5650
+ /**
5651
+ * Get a string representation of a view key
5652
+ *
5653
+ * @returns {string} String representation of a view key
5654
+ */
5655
+ toString(): string;
5656
+ /**
5657
+ * Get a ViewKey from a series of bytes.
5658
+ *
5659
+ * @param {Uint8Array} bytes A left endian byte array representing the view key.
5660
+ *
5661
+ * @returns {ViewKey} The view key object.
5662
+ */
5663
+ static fromBytesLe(bytes: Uint8Array): ViewKey;
4076
5664
  /**
4077
5665
  * Create a new view key from a private key
4078
5666
  *