@provablehq/wasm 0.10.0 → 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,18 +2,6 @@
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;
17
5
  /**
18
6
  * Verify a SNARK proof against a verifying key and public inputs.
19
7
  *
@@ -40,6 +28,19 @@ export function snarkVerify(verifying_key: VerifyingKey, inputs: Array<any>, pro
40
28
  * @returns {boolean} True if the execution is valid, false otherwise
41
29
  */
42
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 batch SNARK proof against multiple verifying keys and their corresponding public inputs.
33
+ *
34
+ * This function verifies a batch proof produced by Aleo programs that may not be deployed on chain.
35
+ * Each verifying key is paired with one or more sets of public inputs (instances).
36
+ *
37
+ * @param {Array<string>} verifying_keys Array of verifying key strings, one per circuit
38
+ * @param {Array<Array<Array<string>>>} inputs 3D array of field element strings [circuit_idx][instance_idx][field_idx]
39
+ * @param {Proof} proof The batch proof to verify
40
+ * @returns {boolean} True if the batch proof is valid, false otherwise
41
+ */
42
+ export function snarkVerifyBatch(verifying_keys: Array<any>, inputs: Array<any>, proof: Proof): boolean;
43
+ export function stringToField(string: string): Field;
43
44
  /**
44
45
  * Set test consensus version heights for testing.
45
46
  *
@@ -52,7 +53,6 @@ export function verifyFunctionExecution(execution: Execution, verifying_key: Ver
52
53
  * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
53
54
  */
54
55
  export function getOrInitConsensusVersionTestHeights(heights?: string | null): Array<any>;
55
- export function stringToField(string: string): Field;
56
56
  /**
57
57
  * Public address of an Aleo account
58
58
  */
@@ -92,6 +92,14 @@ export class Address {
92
92
  * Get the left endian byte array representation of the address.
93
93
  */
94
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;
95
103
  /**
96
104
  * Get an address from a series of bits represented as a boolean array.
97
105
  *
@@ -100,6 +108,18 @@ export class Address {
100
108
  * @returns {Address} The address object.
101
109
  */
102
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;
103
123
  /**
104
124
  * Get the plaintext representation of the address.
105
125
  */
@@ -110,6 +130,18 @@ export class Address {
110
130
  * @returns {string} String representation of the address
111
131
  */
112
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;
113
145
  /**
114
146
  * Get an address from a series of bytes.
115
147
  *
@@ -125,6 +157,14 @@ export class Address {
125
157
  * @returns {Address} Address corresponding to the view key
126
158
  */
127
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;
128
168
  /**
129
169
  * Get the address of a program based on the program ID.
130
170
  *
@@ -132,6 +172,10 @@ export class Address {
132
172
  * @returns {Address} The address corresponding to the program ID.
133
173
  */
134
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;
135
179
  /**
136
180
  * Derive an Aleo address from a compute key.
137
181
  *
@@ -145,6 +189,10 @@ export class Address {
145
189
  * @returns {Address} Address corresponding to the private key
146
190
  */
147
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;
148
196
  /**
149
197
  * Verify a signature for a message signed by the address
150
198
  *
@@ -161,6 +209,10 @@ export class Address {
161
209
  * @returns {boolean} True if the input is a valid address, false otherwise.
162
210
  */
163
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;
164
216
  /**
165
217
  * Get the group representation of the address object.
166
218
  */
@@ -383,6 +435,10 @@ export class BHP768 {
383
435
  export class Boolean {
384
436
  free(): void;
385
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;
386
442
  /**
387
443
  * Get the left endian boolean array representation of the boolean element.
388
444
  */
@@ -407,6 +463,15 @@ export class Boolean {
407
463
  * Create a boolean element from a Uint8Array of left endian bytes.
408
464
  */
409
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;
410
475
  /**
411
476
  * Logical OR.
412
477
  */
@@ -439,6 +504,14 @@ export class Boolean {
439
504
  * Clone the boolean element.
440
505
  */
441
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;
442
515
  /**
443
516
  * Check if one boolean element equals another.
444
517
  */
@@ -447,6 +520,51 @@ export class Boolean {
447
520
  * Generate a random boolean element.
448
521
  */
449
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;
450
568
  /**
451
569
  * Returns the string representation of the boolean element.
452
570
  */
@@ -1029,10 +1147,20 @@ export class Field {
1029
1147
  private constructor();
1030
1148
  free(): void;
1031
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;
1032
1155
  /**
1033
1156
  * Get the left endian boolean array representation of the field element.
1034
1157
  */
1035
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;
1036
1164
  /**
1037
1165
  * Creates a field object from a string representation of a field element.
1038
1166
  */
@@ -1041,18 +1169,78 @@ export class Field {
1041
1169
  * Encode the field element as a Uint8Array of left endian bytes.
1042
1170
  */
1043
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;
1044
1180
  /**
1045
1181
  * Reconstruct a field element from a boolean array representation.
1046
1182
  */
1047
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;
1048
1196
  /**
1049
1197
  * Create a plaintext from the field element.
1050
1198
  */
1051
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;
1052
1212
  /**
1053
1213
  * Create a field element from a Uint8Array of left endian bytes.
1054
1214
  */
1055
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;
1056
1244
  /**
1057
1245
  * Initializes a new field as a domain separator.
1058
1246
  */
@@ -1105,6 +1293,13 @@ export class Field {
1105
1293
  * Subtract two field elements.
1106
1294
  */
1107
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;
1108
1303
  /**
1109
1304
  * Returns the string representation of the field element.
1110
1305
  */
@@ -1156,6 +1351,10 @@ export class Group {
1156
1351
  * Generate the group element from the x coordinate of the group.
1157
1352
  */
1158
1353
  static fromField(field: Field): Group;
1354
+ /**
1355
+ * Cast the group element to an Address (lossless — Address wraps Group).
1356
+ */
1357
+ toAddress(): Address;
1159
1358
  /**
1160
1359
  * Get the left endian boolean array representation of the group element.
1161
1360
  */
@@ -1168,26 +1367,74 @@ export class Group {
1168
1367
  * Encode the group element as a Uint8Array of left endian bytes.
1169
1368
  */
1170
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;
1171
1378
  /**
1172
1379
  * Reconstruct a group element from a boolean array representation.
1173
1380
  */
1174
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;
1175
1394
  /**
1176
1395
  * Create a plaintext element from a group element.
1177
1396
  */
1178
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;
1179
1410
  /**
1180
1411
  * Create a group element from a Uint8Array of left endian bytes.
1181
1412
  */
1182
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;
1183
1422
  /**
1184
1423
  * Multiply a group element by a scalar element.
1185
1424
  */
1186
1425
  scalarMultiply(scalar: Scalar): Group;
1426
+ /**
1427
+ * Cast the group element to a Scalar with lossy truncation (via x-coordinate).
1428
+ */
1429
+ toScalarLossy(): Scalar;
1187
1430
  /**
1188
1431
  * Get the x-coordinate of the group element.
1189
1432
  */
1190
1433
  toXCoordinate(): Field;
1434
+ /**
1435
+ * Cast the group element to a Boolean with lossy truncation (LSB of x-coordinate).
1436
+ */
1437
+ toBooleanLossy(): Boolean;
1191
1438
  /**
1192
1439
  * Generate the group element from a string representation of the x coordinate of the group.
1193
1440
  */
@@ -1225,6 +1472,11 @@ export class Group {
1225
1472
  * Subtract two group elements (equivalently: add the inverse of an element).
1226
1473
  */
1227
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;
1228
1480
  /**
1229
1481
  * Get the generator of the group.
1230
1482
  */
@@ -1290,18 +1542,66 @@ export class I128 {
1290
1542
  * Construct an integer from a byte array representation.
1291
1543
  */
1292
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;
1293
1553
  /**
1294
1554
  * Construct an integer from a boolean array representation.
1295
1555
  */
1296
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;
1297
1569
  /**
1298
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.
1299
1571
  */
1300
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;
1301
1585
  /**
1302
1586
  * Get the byte array representation of the integer.
1303
1587
  */
1304
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;
1305
1605
  /**
1306
1606
  * Negate the integer (e.g., 5 → -5).
1307
1607
  */
@@ -1330,6 +1630,10 @@ export class I128 {
1330
1630
  * Exponentiate the integer with a u32 exponent.
1331
1631
  */
1332
1632
  powU32(exponent: U32): I128;
1633
+ /**
1634
+ * Convert the integer to a Field element (lossless).
1635
+ */
1636
+ toField(): Field;
1333
1637
  /**
1334
1638
  * Convert the integer to a Scalar value.
1335
1639
  */
@@ -1391,18 +1695,66 @@ export class I16 {
1391
1695
  * Construct an integer from a byte array representation.
1392
1696
  */
1393
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;
1394
1706
  /**
1395
1707
  * Construct an integer from a boolean array representation.
1396
1708
  */
1397
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;
1398
1722
  /**
1399
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.
1400
1724
  */
1401
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;
1402
1738
  /**
1403
1739
  * Get the byte array representation of the integer.
1404
1740
  */
1405
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;
1406
1758
  /**
1407
1759
  * Negate the integer (e.g., 5 → -5).
1408
1760
  */
@@ -1431,6 +1783,10 @@ export class I16 {
1431
1783
  * Exponentiate the integer with a u32 exponent.
1432
1784
  */
1433
1785
  powU32(exponent: U32): I16;
1786
+ /**
1787
+ * Convert the integer to a Field element (lossless).
1788
+ */
1789
+ toField(): Field;
1434
1790
  /**
1435
1791
  * Convert the integer to a Scalar value.
1436
1792
  */
@@ -1492,18 +1848,66 @@ export class I32 {
1492
1848
  * Construct an integer from a byte array representation.
1493
1849
  */
1494
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;
1495
1859
  /**
1496
1860
  * Construct an integer from a boolean array representation.
1497
1861
  */
1498
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;
1499
1875
  /**
1500
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.
1501
1877
  */
1502
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;
1503
1891
  /**
1504
1892
  * Get the byte array representation of the integer.
1505
1893
  */
1506
1894
  static fromBytesLe(bytes: Uint8Array): I32;
1895
+ /**
1896
+ * Cast to I128 with lossy truncation.
1897
+ */
1898
+ toI128Lossy(): I128;
1899
+ /**
1900
+ * Cast to U128 with lossy truncation.
1901
+ */
1902
+ toU128Lossy(): U128;
1903
+ /**
1904
+ * Construct an integer from a field element with lossy truncation.
1905
+ */
1906
+ static fromFieldLossy(field: Field): I32;
1907
+ /**
1908
+ * Cast the integer to a Boolean with lossy truncation (extracts least-significant bit).
1909
+ */
1910
+ toBooleanLossy(): Boolean;
1507
1911
  /**
1508
1912
  * Negate the integer (e.g., 5 → -5).
1509
1913
  */
@@ -1532,6 +1936,10 @@ export class I32 {
1532
1936
  * Exponentiate the integer with a u32 exponent.
1533
1937
  */
1534
1938
  powU32(exponent: U32): I32;
1939
+ /**
1940
+ * Convert the integer to a Field element (lossless).
1941
+ */
1942
+ toField(): Field;
1535
1943
  /**
1536
1944
  * Convert the integer to a Scalar value.
1537
1945
  */
@@ -1593,18 +2001,66 @@ export class I64 {
1593
2001
  * Construct an integer from a byte array representation.
1594
2002
  */
1595
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;
1596
2012
  /**
1597
2013
  * Construct an integer from a boolean array representation.
1598
2014
  */
1599
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;
1600
2028
  /**
1601
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.
1602
2030
  */
1603
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;
1604
2044
  /**
1605
2045
  * Get the byte array representation of the integer.
1606
2046
  */
1607
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;
1608
2064
  /**
1609
2065
  * Negate the integer (e.g., 5 → -5).
1610
2066
  */
@@ -1633,6 +2089,10 @@ export class I64 {
1633
2089
  * Exponentiate the integer with a u32 exponent.
1634
2090
  */
1635
2091
  powU32(exponent: U32): I64;
2092
+ /**
2093
+ * Convert the integer to a Field element (lossless).
2094
+ */
2095
+ toField(): Field;
1636
2096
  /**
1637
2097
  * Convert the integer to a Scalar value.
1638
2098
  */
@@ -1694,18 +2154,66 @@ export class I8 {
1694
2154
  * Construct an integer from a byte array representation.
1695
2155
  */
1696
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;
1697
2165
  /**
1698
2166
  * Construct an integer from a boolean array representation.
1699
2167
  */
1700
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;
1701
2181
  /**
1702
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.
1703
2183
  */
1704
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;
1705
2197
  /**
1706
2198
  * Get the byte array representation of the integer.
1707
2199
  */
1708
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;
1709
2217
  /**
1710
2218
  * Negate the integer (e.g., 5 → -5).
1711
2219
  */
@@ -1734,6 +2242,10 @@ export class I8 {
1734
2242
  * Exponentiate the integer with a u32 exponent.
1735
2243
  */
1736
2244
  powU32(exponent: U32): I8;
2245
+ /**
2246
+ * Convert the integer to a Field element (lossless).
2247
+ */
2248
+ toField(): Field;
1737
2249
  /**
1738
2250
  * Convert the integer to a Scalar value.
1739
2251
  */
@@ -3427,10 +3939,20 @@ export class Scalar {
3427
3939
  private constructor();
3428
3940
  free(): void;
3429
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;
3430
3947
  /**
3431
3948
  * Get the left endian boolean array representation of the scalar element.
3432
3949
  */
3433
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;
3434
3956
  /**
3435
3957
  * Creates a scalar object from a string representation of a scalar element.
3436
3958
  */
@@ -3439,18 +3961,70 @@ export class Scalar {
3439
3961
  * Encode the scalar element as a Uint8Array of left endian bytes.
3440
3962
  */
3441
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;
3442
3972
  /**
3443
3973
  * Reconstruct a scalar element from a boolean array representation.
3444
3974
  */
3445
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;
3446
3988
  /**
3447
3989
  * Create a plaintext element from a scalar element.
3448
3990
  */
3449
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;
4000
+ /**
4001
+ * Cast the scalar to a U64 with lossy truncation.
4002
+ */
4003
+ toU64Lossy(): U64;
3450
4004
  /**
3451
4005
  * Create a scalar element from a Uint8Array of left endian bytes.
3452
4006
  */
3453
4007
  static fromBytesLe(bytes: Uint8Array): Scalar;
4008
+ /**
4009
+ * Cast the scalar to an I128 with lossy truncation.
4010
+ */
4011
+ toI128Lossy(): I128;
4012
+ /**
4013
+ * Cast the scalar to a U128 with lossy truncation.
4014
+ */
4015
+ toU128Lossy(): U128;
4016
+ /**
4017
+ * Cast the scalar to a Group element with lossy conversion (via Field, Elligator-2 fallback).
4018
+ */
4019
+ toGroupLossy(): Group;
4020
+ /**
4021
+ * Cast the scalar to an Address with lossy conversion (via Group, Elligator-2 fallback).
4022
+ */
4023
+ toAddressLossy(): Address;
4024
+ /**
4025
+ * Cast the scalar to a Boolean with lossy truncation (extracts least-significant bit).
4026
+ */
4027
+ toBooleanLossy(): Boolean;
3454
4028
  /**
3455
4029
  * Add two scalar elements.
3456
4030
  */
@@ -3503,6 +4077,11 @@ export class Scalar {
3503
4077
  * Cast the scalar element to a field element.
3504
4078
  */
3505
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;
3506
4085
  /**
3507
4086
  * Returns the string representation of the scalar element.
3508
4087
  */
@@ -3951,18 +4530,66 @@ export class U128 {
3951
4530
  * Construct an integer from a byte array representation.
3952
4531
  */
3953
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;
3954
4541
  /**
3955
4542
  * Construct an integer from a boolean array representation.
3956
4543
  */
3957
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;
3958
4557
  /**
3959
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.
3960
4559
  */
3961
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;
3962
4573
  /**
3963
4574
  * Get the byte array representation of the integer.
3964
4575
  */
3965
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;
3966
4593
  /**
3967
4594
  * Negate the integer (e.g., 5 → -5).
3968
4595
  */
@@ -3991,6 +4618,10 @@ export class U128 {
3991
4618
  * Exponentiate the integer with a u32 exponent.
3992
4619
  */
3993
4620
  powU32(exponent: U32): U128;
4621
+ /**
4622
+ * Convert the integer to a Field element (lossless).
4623
+ */
4624
+ toField(): Field;
3994
4625
  /**
3995
4626
  * Convert the integer to a Scalar value.
3996
4627
  */
@@ -4052,18 +4683,66 @@ export class U16 {
4052
4683
  * Construct an integer from a byte array representation.
4053
4684
  */
4054
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;
4055
4694
  /**
4056
4695
  * Construct an integer from a boolean array representation.
4057
4696
  */
4058
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;
4059
4710
  /**
4060
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.
4061
4712
  */
4062
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;
4063
4726
  /**
4064
4727
  * Get the byte array representation of the integer.
4065
4728
  */
4066
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;
4067
4746
  /**
4068
4747
  * Negate the integer (e.g., 5 → -5).
4069
4748
  */
@@ -4092,6 +4771,10 @@ export class U16 {
4092
4771
  * Exponentiate the integer with a u32 exponent.
4093
4772
  */
4094
4773
  powU32(exponent: U32): U16;
4774
+ /**
4775
+ * Convert the integer to a Field element (lossless).
4776
+ */
4777
+ toField(): Field;
4095
4778
  /**
4096
4779
  * Convert the integer to a Scalar value.
4097
4780
  */
@@ -4153,18 +4836,66 @@ export class U32 {
4153
4836
  * Construct an integer from a byte array representation.
4154
4837
  */
4155
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;
4156
4847
  /**
4157
4848
  * Construct an integer from a boolean array representation.
4158
4849
  */
4159
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;
4160
4863
  /**
4161
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.
4162
4865
  */
4163
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;
4164
4879
  /**
4165
4880
  * Get the byte array representation of the integer.
4166
4881
  */
4167
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;
4168
4899
  /**
4169
4900
  * Negate the integer (e.g., 5 → -5).
4170
4901
  */
@@ -4193,6 +4924,10 @@ export class U32 {
4193
4924
  * Exponentiate the integer with a u32 exponent.
4194
4925
  */
4195
4926
  powU32(exponent: U32): U32;
4927
+ /**
4928
+ * Convert the integer to a Field element (lossless).
4929
+ */
4930
+ toField(): Field;
4196
4931
  /**
4197
4932
  * Convert the integer to a Scalar value.
4198
4933
  */
@@ -4254,18 +4989,66 @@ export class U64 {
4254
4989
  * Construct an integer from a byte array representation.
4255
4990
  */
4256
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;
4257
5000
  /**
4258
5001
  * Construct an integer from a boolean array representation.
4259
5002
  */
4260
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;
4261
5016
  /**
4262
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.
4263
5018
  */
4264
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;
4265
5032
  /**
4266
5033
  * Get the byte array representation of the integer.
4267
5034
  */
4268
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;
4269
5052
  /**
4270
5053
  * Negate the integer (e.g., 5 → -5).
4271
5054
  */
@@ -4294,6 +5077,10 @@ export class U64 {
4294
5077
  * Exponentiate the integer with a u32 exponent.
4295
5078
  */
4296
5079
  powU32(exponent: U32): U64;
5080
+ /**
5081
+ * Convert the integer to a Field element (lossless).
5082
+ */
5083
+ toField(): Field;
4297
5084
  /**
4298
5085
  * Convert the integer to a Scalar value.
4299
5086
  */
@@ -4355,18 +5142,66 @@ export class U8 {
4355
5142
  * Construct an integer from a byte array representation.
4356
5143
  */
4357
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;
4358
5153
  /**
4359
5154
  * Construct an integer from a boolean array representation.
4360
5155
  */
4361
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;
4362
5169
  /**
4363
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.
4364
5171
  */
4365
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;
4366
5185
  /**
4367
5186
  * Get the byte array representation of the integer.
4368
5187
  */
4369
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;
4370
5205
  /**
4371
5206
  * Negate the integer (e.g., 5 → -5).
4372
5207
  */
@@ -4395,6 +5230,10 @@ export class U8 {
4395
5230
  * Exponentiate the integer with a u32 exponent.
4396
5231
  */
4397
5232
  powU32(exponent: U32): U8;
5233
+ /**
5234
+ * Convert the integer to a Field element (lossless).
5235
+ */
5236
+ toField(): Field;
4398
5237
  /**
4399
5238
  * Convert the integer to a Scalar value.
4400
5239
  */