@provablehq/wasm 0.7.2 → 0.7.3

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.
@@ -51,6 +51,14 @@ export class Address {
51
51
  */
52
52
  static from_view_key(view_key: ViewKey): Address;
53
53
  /**
54
+ * Derive an Aleo address from a compute key.
55
+ *
56
+ * @param {ComputeKey} compute_key The compute key to derive the address from
57
+ * @param {ComputeKey} compute_key
58
+ * @returns {Address}
59
+ */
60
+ static from_compute_key(compute_key: ComputeKey): Address;
61
+ /**
54
62
  * Create an aleo address object from a string representation of an address
55
63
  *
56
64
  * @param {string} address String representation of an addressm
@@ -79,6 +87,115 @@ export class Address {
79
87
  verify(message: Uint8Array, signature: Signature): boolean;
80
88
  }
81
89
  /**
90
+ * SnarkVM Ciphertext object. A Ciphertext represents an symmetrically encrypted plaintext. This
91
+ * object provides decryption methods to recover the plaintext from the ciphertext (given the
92
+ * api consumer has the proper decryption materials).
93
+ *
94
+ * @example
95
+ */
96
+ export class Ciphertext {
97
+ free(): void;
98
+ /**
99
+ * Decrypt the ciphertext using the given view key.
100
+ *
101
+ * @param {ViewKey} The view key of the account that encrypted the ciphertext.
102
+ * @param {Group} The nonce used to encrypt the ciphertext.
103
+ *
104
+ * @returns {Plaintext} The decrypted plaintext.
105
+ * @param {ViewKey} view_key
106
+ * @param {Group} nonce
107
+ * @returns {Plaintext}
108
+ */
109
+ decrypt(view_key: ViewKey, nonce: Group): Plaintext;
110
+ /**
111
+ * Decrypts a ciphertext into plaintext using the given transition view key.
112
+ *
113
+ * @param {Field} transition_view_key The transition view key that was used to encrypt the ciphertext.
114
+ *
115
+ * @returns {Plaintext} The decrypted plaintext.
116
+ * @param {Field} transition_view_key
117
+ * @returns {Plaintext}
118
+ */
119
+ decryptSymmetric(transition_view_key: Field): Plaintext;
120
+ /**
121
+ * Deserialize a left endian byte array into a Ciphertext.
122
+ *
123
+ * @param {Uint8Array} bytes The byte array representing the Ciphertext.
124
+ *
125
+ * @returns {Ciphertext} The Ciphertext object.
126
+ * @param {Uint8Array} bytes
127
+ * @returns {Ciphertext}
128
+ */
129
+ static fromBytesLe(bytes: Uint8Array): Ciphertext;
130
+ /**
131
+ * Deserialize a Ciphertext string into a Ciphertext object.
132
+ *
133
+ * @param {string} ciphertext A string representation of the ciphertext.
134
+ *
135
+ * @returns {Ciphertext} The Ciphertext object.
136
+ * @param {string} ciphertext
137
+ * @returns {Ciphertext}
138
+ */
139
+ static fromString(ciphertext: string): Ciphertext;
140
+ /**
141
+ * Serialize a Ciphertext object into a byte array.
142
+ *
143
+ * @returns {Uint8Array} The serialized Ciphertext.
144
+ * @returns {Uint8Array}
145
+ */
146
+ toBytes(): Uint8Array;
147
+ /**
148
+ * Serialize a Ciphertext into a js string.
149
+ *
150
+ * @returns {string} The serialized Ciphertext.
151
+ * @returns {string}
152
+ */
153
+ toString(): string;
154
+ }
155
+ /**
156
+ */
157
+ export class ComputeKey {
158
+ free(): void;
159
+ /**
160
+ * Create a new compute key from a private key.
161
+ *
162
+ * @param {PrivateKey} private_key Private key
163
+ *
164
+ * @returns {ComputeKey} Compute key
165
+ * @param {PrivateKey} private_key
166
+ * @returns {ComputeKey}
167
+ */
168
+ static from_private_key(private_key: PrivateKey): ComputeKey;
169
+ /**
170
+ * Get the address from the compute key.
171
+ *
172
+ * @returns {Address}
173
+ * @returns {Address}
174
+ */
175
+ address(): Address;
176
+ /**
177
+ * Get the sk_prf of the compute key.
178
+ *
179
+ * @returns {Scalar} sk_prf
180
+ * @returns {Scalar}
181
+ */
182
+ sk_prf(): Scalar;
183
+ /**
184
+ * Get the pr_tag of the compute key.
185
+ *
186
+ * @returns {Group} pr_tag
187
+ * @returns {Group}
188
+ */
189
+ pk_sig(): Group;
190
+ /**
191
+ * Get the pr_sig of the compute key.
192
+ *
193
+ * @returns {Group} pr_sig
194
+ * @returns {Group}
195
+ */
196
+ pr_sig(): Group;
197
+ }
198
+ /**
82
199
  * Execution of an Aleo program.
83
200
  */
84
201
  export class Execution {
@@ -150,18 +267,199 @@ export class ExecutionResponse {
150
267
  getProgram(): Program;
151
268
  }
152
269
  /**
270
+ * Field element.
153
271
  */
154
272
  export class Field {
155
273
  free(): void;
156
274
  /**
275
+ * Creates a field object from a string representation of a field.
276
+ * @param {string} field
277
+ * @returns {Field}
278
+ */
279
+ static fromString(field: string): Field;
280
+ /**
281
+ * Create a plaintext element from a group element.
282
+ * @returns {Plaintext}
283
+ */
284
+ toPlaintext(): Plaintext;
285
+ /**
286
+ * Returns the string representation of the field.
157
287
  * @returns {string}
158
288
  */
159
289
  toString(): string;
160
290
  /**
161
- * @param {string} field
291
+ * Generate a random field element.
162
292
  * @returns {Field}
163
293
  */
164
- static fromString(field: string): Field;
294
+ static random(): Field;
295
+ /**
296
+ * Add two field elements.
297
+ * @param {Field} other
298
+ * @returns {Field}
299
+ */
300
+ add(other: Field): Field;
301
+ /**
302
+ * Subtract two field elements.
303
+ * @param {Field} other
304
+ * @returns {Field}
305
+ */
306
+ subtract(other: Field): Field;
307
+ /**
308
+ * Multiply two field elements.
309
+ * @param {Field} other
310
+ * @returns {Field}
311
+ */
312
+ multiply(other: Field): Field;
313
+ /**
314
+ * Divide two field elements.
315
+ * @param {Field} other
316
+ * @returns {Field}
317
+ */
318
+ divide(other: Field): Field;
319
+ /**
320
+ * Power of a field element.
321
+ * @param {Field} other
322
+ * @returns {Field}
323
+ */
324
+ pow(other: Field): Field;
325
+ /**
326
+ * Invert the field element.
327
+ * @returns {Field}
328
+ */
329
+ inverse(): Field;
330
+ /**
331
+ * Get the zero element of the field.
332
+ * @returns {Field}
333
+ */
334
+ static zero(): Field;
335
+ /**
336
+ * Get the one element of the field.
337
+ * @returns {Field}
338
+ */
339
+ static one(): Field;
340
+ /**
341
+ * Double the field element.
342
+ * @returns {Field}
343
+ */
344
+ double(): Field;
345
+ /**
346
+ * Check if one field element equals another.
347
+ * @param {Field} other
348
+ * @returns {boolean}
349
+ */
350
+ equals(other: Field): boolean;
351
+ }
352
+ /**
353
+ */
354
+ export class GraphKey {
355
+ free(): void;
356
+ /**
357
+ * Create a new graph key from a view key.
358
+ *
359
+ * @param {ViewKey} view_key View key
360
+ * @returns {GraphKey} Graph key
361
+ * @param {ViewKey} view_key
362
+ * @returns {GraphKey}
363
+ */
364
+ static from_view_key(view_key: ViewKey): GraphKey;
365
+ /**
366
+ * Create a new graph key from a string representation of a graph key
367
+ *
368
+ * @param {string} graph_key String representation of a graph key
369
+ * @returns {GraphKey} Graph key
370
+ * @param {string} graph_key
371
+ * @returns {GraphKey}
372
+ */
373
+ static from_string(graph_key: string): GraphKey;
374
+ /**
375
+ * Get a string representation of a graph key
376
+ *
377
+ * @returns {string} String representation of a graph key
378
+ * @returns {string}
379
+ */
380
+ to_string(): string;
381
+ /**
382
+ * Get the sk_tag of the graph key. Used to determine ownership of records.
383
+ * @returns {Field}
384
+ */
385
+ sk_tag(): Field;
386
+ }
387
+ /**
388
+ * Elliptic curve element.
389
+ */
390
+ export class Group {
391
+ free(): void;
392
+ /**
393
+ * Creates a group object from a string representation of a group.
394
+ * @param {string} group
395
+ * @returns {Group}
396
+ */
397
+ static fromString(group: string): Group;
398
+ /**
399
+ * Returns the string representation of the group.
400
+ * @returns {string}
401
+ */
402
+ toString(): string;
403
+ /**
404
+ * Get the x-coordinate of the group element.
405
+ * @returns {Field}
406
+ */
407
+ toXCoordinate(): Field;
408
+ /**
409
+ * Create a plaintext element from a group element.
410
+ * @returns {Plaintext}
411
+ */
412
+ toPlaintext(): Plaintext;
413
+ /**
414
+ * Generate a random group element.
415
+ * @returns {Group}
416
+ */
417
+ static random(): Group;
418
+ /**
419
+ * Add two group elements.
420
+ * @param {Group} other
421
+ * @returns {Group}
422
+ */
423
+ add(other: Group): Group;
424
+ /**
425
+ * Subtract two group elements (equivalently: add the inverse of an element).
426
+ * @param {Group} other
427
+ * @returns {Group}
428
+ */
429
+ subtract(other: Group): Group;
430
+ /**
431
+ * Multiply a group element by a scalar element.
432
+ * @param {Scalar} scalar
433
+ * @returns {Group}
434
+ */
435
+ scalarMultiply(scalar: Scalar): Group;
436
+ /**
437
+ * Double the group element.
438
+ * @returns {Group}
439
+ */
440
+ double(): Group;
441
+ /**
442
+ * Get the inverse of the group element. This is the reflection of the point about the axis
443
+ * of symmetry i.e. (x,y) -> (x, -y).
444
+ * @returns {Group}
445
+ */
446
+ inverse(): Group;
447
+ /**
448
+ * Check if one group element equals another.
449
+ * @param {Group} other
450
+ * @returns {boolean}
451
+ */
452
+ equals(other: Group): boolean;
453
+ /**
454
+ * Get the group identity element under the group operation (i.e. the point at infinity.)
455
+ * @returns {Group}
456
+ */
457
+ static zero(): Group;
458
+ /**
459
+ * Get the generator of the group.
460
+ * @returns {Group}
461
+ */
462
+ static generator(): Group;
165
463
  }
166
464
  /**
167
465
  * Key pair object containing both the function proving and verifying keys
@@ -316,6 +614,94 @@ export class OfflineQuery {
316
614
  static fromString(s: string): OfflineQuery;
317
615
  }
318
616
  /**
617
+ * SnarkVM Plaintext object. Plaintext is a fundamental monadic type used to represent Aleo
618
+ * primitive types (boolean, field, group, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128,
619
+ * scalar, and signature), struct types, and array types.
620
+ *
621
+ * In the context of a web or NodeJS application, this type is useful for turning an Aleo type into
622
+ * a JS value, object, or array that might be necessary for performing computations within the
623
+ * application.
624
+ *
625
+ * @example
626
+ * // Get the bond state of an existing address.
627
+ * const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
628
+ * // Convert the bond state to a Plaintext object.
629
+ * const bondStatePlaintext = Plaintext.fromString(bond_state);
630
+ * // Convert the Plaintext object to a JS object.
631
+ * const bondStateObject = bond_state_plaintext.toObject();
632
+ * // Check if the bond state matches the expected object.
633
+ * const expectedObject = { validator: "aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f", microcredits: 100000000u64 };
634
+ * assert( JSON.stringify(bondStateObject) === JSON.stringify(expectedObject) );
635
+ */
636
+ export class Plaintext {
637
+ free(): void;
638
+ /**
639
+ * Find plaintext member if the plaintext is a struct. Returns `null` if the plaintext is not
640
+ * a struct or the member does not exist.
641
+ *
642
+ * @param {string} name The name of the plaintext member to find.
643
+ *
644
+ * @returns {Plaintext | undefined} The plaintext member.
645
+ * @param {string} name
646
+ * @returns {Plaintext | undefined}
647
+ */
648
+ find(name: string): Plaintext | undefined;
649
+ /**
650
+ * Encrypt a plaintext with an address and randomizer.
651
+ * @param {Address} address
652
+ * @param {Scalar} randomizer
653
+ * @returns {Ciphertext}
654
+ */
655
+ encrypt(address: Address, randomizer: Scalar): Ciphertext;
656
+ /**
657
+ * Encrypt a plaintext with a transition view key.
658
+ * @param {Field} transition_view_key
659
+ * @returns {Ciphertext}
660
+ */
661
+ encryptSymmetric(transition_view_key: Field): Ciphertext;
662
+ /**
663
+ * Creates a plaintext object from a string representation of a plaintext.
664
+ *
665
+ * @param {string} plaintext The string representation of the plaintext.
666
+ *
667
+ * @returns {Plaintext} The plaintext object.
668
+ * @param {string} plaintext
669
+ * @returns {Plaintext}
670
+ */
671
+ static fromString(plaintext: string): Plaintext;
672
+ /**
673
+ * Get a plaintext object from a series of bytes.
674
+ *
675
+ * @param {Uint8Array} bytes A left endian byte array representing the plaintext.
676
+ *
677
+ * @returns {Plaintext} The plaintext object.
678
+ * @param {Uint8Array} bytes
679
+ * @returns {Plaintext}
680
+ */
681
+ static fromBytesLe(bytes: Uint8Array): Plaintext;
682
+ /**
683
+ * Generate a random plaintext element from a series of bytes.
684
+ *
685
+ * @param {Uint8Array} bytes A left endian byte array representing the plaintext.
686
+ * @returns {Uint8Array}
687
+ */
688
+ toBytesLe(): Uint8Array;
689
+ /**
690
+ * Returns the string representation of the plaintext.
691
+ *
692
+ * @returns {string} The string representation of the plaintext.
693
+ * @returns {string}
694
+ */
695
+ toString(): string;
696
+ /**
697
+ * Attempt to convert the plaintext to a JS object.
698
+ *
699
+ * @returns {Object} The JS object representation of the plaintext.
700
+ * @returns {any}
701
+ */
702
+ toObject(): any;
703
+ }
704
+ /**
319
705
  * Private key of an Aleo account
320
706
  */
321
707
  export class PrivateKey {
@@ -1238,6 +1624,18 @@ export class RecordCiphertext {
1238
1624
  * @returns {boolean}
1239
1625
  */
1240
1626
  isOwner(view_key: ViewKey): boolean;
1627
+ /**
1628
+ * Get the tag of the record using the graph key.
1629
+ *
1630
+ * @param {GraphKey} graph key of the account associatd with the record.
1631
+ * @param {Field} commitment of the record.
1632
+ *
1633
+ * @returns {Field} tag of the record.
1634
+ * @param {GraphKey} graph_key
1635
+ * @param {Field} commitment
1636
+ * @returns {Field}
1637
+ */
1638
+ static tag(graph_key: GraphKey, commitment: Field): Field;
1241
1639
  }
1242
1640
  /**
1243
1641
  * Plaintext representation of an Aleo record
@@ -1260,6 +1658,69 @@ export class RecordPlaintext {
1260
1658
  */
1261
1659
  static fromString(record: string): RecordPlaintext;
1262
1660
  /**
1661
+ * @param {string} input
1662
+ * @returns {Plaintext}
1663
+ */
1664
+ getMember(input: string): Plaintext;
1665
+ /**
1666
+ * Get the owner of the record.
1667
+ * @returns {Address}
1668
+ */
1669
+ owner(): Address;
1670
+ /**
1671
+ * Get a representation of a record as a javascript object for usage in client side
1672
+ * computations. Note that this is not a reversible operation and exists for the convenience
1673
+ * of discovering and using properties of the record.
1674
+ *
1675
+ * The conversion guide is as follows:
1676
+ * - u8, u16, u32, i8, i16 i32 --> Number
1677
+ * - u64, u128, i64, i128 --> BigInt
1678
+ * - Address, Field, Group, Scalar --> String.
1679
+ *
1680
+ * Address, Field, Group, and Scalar will all be converted to their bech32 string
1681
+ * representation. These string representations can be converted back to their respective wasm
1682
+ * types using the fromString method on the Address, Field, Group, and Scalar objects in this
1683
+ * library.
1684
+ *
1685
+ * @example
1686
+ * # Create a wasm record from a record string.
1687
+ * let record_plaintext_wasm = RecordPlainext.from_string("{
1688
+ * owner: aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48.private,
1689
+ * metadata: {
1690
+ * player1: aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48.private,
1691
+ * player2: aleo1dreuxnmg9cny8ee9v2u0wr4v4affnwm09u2pytfwz0f2en2shgqsdsfjn6.private,
1692
+ * nonce: 660310649780728486489183263981322848354071976582883879926426319832534836534field.private
1693
+ * },
1694
+ * id: 1953278585719525811355617404139099418855053112960441725284031425961000152405field.private,
1695
+ * positions: 50794271u64.private,
1696
+ * attempts: 0u64.private,
1697
+ * hits: 0u64.private,
1698
+ * _nonce: 5668100912391182624073500093436664635767788874314097667746354181784048204413group.public
1699
+ * }");
1700
+ *
1701
+ * let expected_object = {
1702
+ * owner: "aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48",
1703
+ * metadata: {
1704
+ * player1: "aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48",
1705
+ * player2: "aleo1dreuxnmg9cny8ee9v2u0wr4v4affnwm09u2pytfwz0f2en2shgqsdsfjn6",
1706
+ * nonce: "660310649780728486489183263981322848354071976582883879926426319832534836534field"
1707
+ * },
1708
+ * id: "1953278585719525811355617404139099418855053112960441725284031425961000152405field",
1709
+ * positions: 50794271,
1710
+ * attempts: 0,
1711
+ * hits: 0,
1712
+ * _nonce: "5668100912391182624073500093436664635767788874314097667746354181784048204413group"
1713
+ * };
1714
+ *
1715
+ * # Create the expected object
1716
+ * let record_plaintext_object = record_plaintext_wasm.to_js_object();
1717
+ * assert(JSON.stringify(record_plaintext_object) == JSON.stringify(expected_object));
1718
+ *
1719
+ * @returns {Object} Javascript object representation of the record
1720
+ * @returns {object}
1721
+ */
1722
+ toJsObject(): object;
1723
+ /**
1263
1724
  * Returns the record plaintext string
1264
1725
  *
1265
1726
  * @returns {string} String representation of the record plaintext
@@ -1286,6 +1747,7 @@ export class RecordPlaintext {
1286
1747
  * @param {PrivateKey} private_key Private key of the account that owns the record
1287
1748
  * @param {string} program_id Program ID of the program that the record is associated with
1288
1749
  * @param {string} record_name Name of the record
1750
+ *
1289
1751
  * @returns {string} Serial number of the record
1290
1752
  * @param {PrivateKey} private_key
1291
1753
  * @param {string} program_id
@@ -1293,6 +1755,96 @@ export class RecordPlaintext {
1293
1755
  * @returns {string}
1294
1756
  */
1295
1757
  serialNumberString(private_key: PrivateKey, program_id: string, record_name: string): string;
1758
+ /**
1759
+ * Get the tag of the record using the graph key.
1760
+ * @param {GraphKey} graph_key
1761
+ * @param {Field} commitment
1762
+ * @returns {Field}
1763
+ */
1764
+ tag(graph_key: GraphKey, commitment: Field): Field;
1765
+ }
1766
+ /**
1767
+ * Scalar field element.
1768
+ */
1769
+ export class Scalar {
1770
+ free(): void;
1771
+ /**
1772
+ * Returns the string representation of the group.
1773
+ * @returns {string}
1774
+ */
1775
+ toString(): string;
1776
+ /**
1777
+ * Create a plaintext element from a group element.
1778
+ * @returns {Plaintext}
1779
+ */
1780
+ toPlaintext(): Plaintext;
1781
+ /**
1782
+ * Creates a group object from a string representation of a group.
1783
+ * @param {string} group
1784
+ * @returns {Scalar}
1785
+ */
1786
+ static fromString(group: string): Scalar;
1787
+ /**
1788
+ * Generate a random group element.
1789
+ * @returns {Scalar}
1790
+ */
1791
+ static random(): Scalar;
1792
+ /**
1793
+ * Add two scalar elements.
1794
+ * @param {Scalar} other
1795
+ * @returns {Scalar}
1796
+ */
1797
+ add(other: Scalar): Scalar;
1798
+ /**
1799
+ * Subtract two scalar elements.
1800
+ * @param {Scalar} other
1801
+ * @returns {Scalar}
1802
+ */
1803
+ subtract(other: Scalar): Scalar;
1804
+ /**
1805
+ * Multiply two scalar elements.
1806
+ * @param {Scalar} other
1807
+ * @returns {Scalar}
1808
+ */
1809
+ multiply(other: Scalar): Scalar;
1810
+ /**
1811
+ * Divide two scalar elements.
1812
+ * @param {Scalar} other
1813
+ * @returns {Scalar}
1814
+ */
1815
+ divide(other: Scalar): Scalar;
1816
+ /**
1817
+ * Double the scalar element.
1818
+ * @returns {Scalar}
1819
+ */
1820
+ double(): Scalar;
1821
+ /**
1822
+ * Power of a scalar element.
1823
+ * @param {Scalar} other
1824
+ * @returns {Scalar}
1825
+ */
1826
+ pow(other: Scalar): Scalar;
1827
+ /**
1828
+ * Invert the scalar element.
1829
+ * @returns {Scalar}
1830
+ */
1831
+ inverse(): Scalar;
1832
+ /**
1833
+ * Creates a one valued element of the scalar field.
1834
+ * @returns {Scalar}
1835
+ */
1836
+ static one(): Scalar;
1837
+ /**
1838
+ * Creates a zero valued element of the scalar field
1839
+ * @returns {Scalar}
1840
+ */
1841
+ static zero(): Scalar;
1842
+ /**
1843
+ * Check if one scalar element equals another.
1844
+ * @param {Scalar} other
1845
+ * @returns {boolean}
1846
+ */
1847
+ equals(other: Scalar): boolean;
1296
1848
  }
1297
1849
  /**
1298
1850
  * Cryptographic signature of a message signed by an Aleo account
@@ -1311,6 +1863,23 @@ export class Signature {
1311
1863
  */
1312
1864
  static sign(private_key: PrivateKey, message: Uint8Array): Signature;
1313
1865
  /**
1866
+ * Get an address from a signature.
1867
+ *
1868
+ * @returns {Address} Address object
1869
+ * @returns {Address}
1870
+ */
1871
+ to_address(): Address;
1872
+ /**
1873
+ * Get the challenge of a signature.
1874
+ * @returns {Scalar}
1875
+ */
1876
+ challenge(): Scalar;
1877
+ /**
1878
+ * Get the response of a signature.
1879
+ * @returns {Scalar}
1880
+ */
1881
+ response(): Scalar;
1882
+ /**
1314
1883
  * Verify a signature of a message with an address
1315
1884
  *
1316
1885
  * @param {Address} address The address to verify the signature with
@@ -1356,6 +1925,15 @@ export class Transaction {
1356
1925
  */
1357
1926
  static fromString(transaction: string): Transaction;
1358
1927
  /**
1928
+ * Create a transaction from a Uint8Array of left endian bytes.
1929
+ *
1930
+ * @param {Uint8Array} Uint8Array of left endian bytes encoding a Transaction.
1931
+ * @returns {Transaction}
1932
+ * @param {Uint8Array} bytes
1933
+ * @returns {Transaction}
1934
+ */
1935
+ static fromBytesLe(bytes: Uint8Array): Transaction;
1936
+ /**
1359
1937
  * Get the transaction as a string. If you want to submit this transaction to the Aleo Network
1360
1938
  * this function will create the string that should be submitted in the `POST` data.
1361
1939
  *
@@ -1364,23 +1942,263 @@ export class Transaction {
1364
1942
  */
1365
1943
  toString(): string;
1366
1944
  /**
1945
+ * Get the transaction as a Uint8Array of left endian bytes.
1946
+ *
1947
+ * @returns {Uint8Array} Uint8Array representation of the transaction
1948
+ * @returns {Uint8Array}
1949
+ */
1950
+ toBytesLe(): Uint8Array;
1951
+ /**
1952
+ * Returns true if the transaction contains the given serial number.
1953
+ *
1954
+ * @param {boolean} True if the transaction contains the given serial number.
1955
+ * @param {Field} serial_number
1956
+ * @returns {boolean}
1957
+ */
1958
+ constainsSerialNumber(serial_number: Field): boolean;
1959
+ /**
1960
+ * Returns true if the transaction contains the given commitment.
1961
+ *
1962
+ * @param {boolean} True if the transaction contains the given commitment.
1963
+ * @param {Field} commitment
1964
+ * @returns {boolean}
1965
+ */
1966
+ constainsCommitment(commitment: Field): boolean;
1967
+ /**
1968
+ * Find a record in the transaction by the record's commitment.
1969
+ * @param {Field} commitment
1970
+ * @returns {RecordCiphertext | undefined}
1971
+ */
1972
+ findRecord(commitment: Field): RecordCiphertext | undefined;
1973
+ /**
1974
+ * Returns the transaction's base fee.
1975
+ * @returns {bigint}
1976
+ */
1977
+ baseFeeAmount(): bigint;
1978
+ /**
1979
+ * Returns the transaction's total fee.
1980
+ * @returns {bigint}
1981
+ */
1982
+ feeAmount(): bigint;
1983
+ /**
1984
+ * Returns the transaction's priority fee.
1985
+ *
1986
+ * returns {bigint} The transaction's priority fee.
1987
+ * @returns {bigint}
1988
+ */
1989
+ priorityFeeAmount(): bigint;
1990
+ /**
1991
+ * Returns true if the transaction is a deployment transaction.
1992
+ *
1993
+ * @returns {boolean} True if the transaction is a deployment transaction
1994
+ * @returns {boolean}
1995
+ */
1996
+ isDeploy(): boolean;
1997
+ /**
1998
+ * Returns true if the transaction is an execution transaction.
1999
+ *
2000
+ * @returns {boolean} True if the transaction is an execution transaction
2001
+ * @returns {boolean}
2002
+ */
2003
+ isExecute(): boolean;
2004
+ /**
2005
+ * Returns true if the transaction is a fee transaction.
2006
+ *
2007
+ * @returns {boolean} True if the transaction is a fee transaction
2008
+ * @returns {boolean}
2009
+ */
2010
+ isFee(): boolean;
2011
+ /**
2012
+ * Get the record plaintext present in a transaction owned by a specific view key.
2013
+ *
2014
+ * @param {ViewKey} view_key View key used to decrypt the ciphertext
2015
+ *
2016
+ * @returns {Array<RecordPlaintext>} Array of record plaintext objects
2017
+ * @param {ViewKey} view_key
2018
+ * @returns {Array<any>}
2019
+ */
2020
+ ownedRecords(view_key: ViewKey): Array<any>;
2021
+ /**
2022
+ * Get the records present in a transaction and their commitments.
2023
+ *
2024
+ * @returns {Array<{commitment: Field, record: RecordCiphertext}>} Array of record ciphertext objects
2025
+ * @returns {Array<any>}
2026
+ */
2027
+ records(): Array<any>;
2028
+ /**
2029
+ * Get a summary of the transaction within a javascript object.
2030
+ *
2031
+ * If the transaction is an execution transaction, this function will return a list of the
2032
+ * transitions and their inputs and outputs.
2033
+ *
2034
+ * If the transaction is a deployment transaction, this function will return the program id and
2035
+ * a list of the functions and their verifying keys, constraint, and variable counts.
2036
+ *
2037
+ * @param {boolean} convert_to_js If true the inputs and outputs will be converted to JS objects,
2038
+ * if false the inputs and outputs will be in wasm format.
2039
+ *
2040
+ * @returns {Object} Transaction summary
2041
+ * @param {boolean} convert_to_js
2042
+ * @returns {object}
2043
+ */
2044
+ summary(convert_to_js: boolean): object;
2045
+ /**
1367
2046
  * Get the id of the transaction. This is the merkle root of the transaction's inclusion proof.
1368
2047
  *
1369
2048
  * This value can be used to query the status of the transaction on the Aleo Network to see
1370
2049
  * if it was successful. If successful, the transaction will be included in a block and this
1371
2050
  * value can be used to lookup the transaction data on-chain.
1372
2051
  *
1373
- * @returns {string} Transaction id
2052
+ * @returns {string} TransactionId
1374
2053
  * @returns {string}
1375
2054
  */
1376
- transactionId(): string;
2055
+ id(): string;
1377
2056
  /**
2057
+ * Get the
1378
2058
  * Get the type of the transaction (will return "deploy" or "execute")
1379
2059
  *
1380
2060
  * @returns {string} Transaction type
1381
2061
  * @returns {string}
1382
2062
  */
1383
2063
  transactionType(): string;
2064
+ /**
2065
+ * Get the transitions in a transaction.
2066
+ * @returns {Array<any>}
2067
+ */
2068
+ transitions(): Array<any>;
2069
+ }
2070
+ /**
2071
+ */
2072
+ export class Transition {
2073
+ free(): void;
2074
+ /**
2075
+ * Get the transition ID
2076
+ *
2077
+ * @returns {string} The transition ID
2078
+ * @returns {string}
2079
+ */
2080
+ id(): string;
2081
+ /**
2082
+ * Create a transition from a string
2083
+ *
2084
+ * @param {string} transition String representation of a transition
2085
+ * @returns {Transition}
2086
+ * @param {string} transition
2087
+ * @returns {Transition}
2088
+ */
2089
+ static fromString(transition: string): Transition;
2090
+ /**
2091
+ * Create a transition from a Uint8Array of left endian bytes.
2092
+ *
2093
+ * @param {Uint8Array} Uint8Array of left endian bytes encoding a Transition.
2094
+ * @returns {Transition}
2095
+ * @param {Uint8Array} bytes
2096
+ * @returns {Transition}
2097
+ */
2098
+ static fromBytesLe(bytes: Uint8Array): Transition;
2099
+ /**
2100
+ * Get the transition as a string. If you want to submit this transition to the Aleo Network
2101
+ * this function will create the string that should be submitted in the `POST` data.
2102
+ *
2103
+ * @returns {string} String representation of the transition
2104
+ * @returns {string}
2105
+ */
2106
+ toString(): string;
2107
+ /**
2108
+ * Get the transition as a Uint8Array of left endian bytes.
2109
+ *
2110
+ * @returns {Uint8Array} Uint8Array representation of the transition
2111
+ * @returns {Uint8Array}
2112
+ */
2113
+ toBytesLe(): Uint8Array;
2114
+ /**
2115
+ * Get the program ID of the transition.
2116
+ * @returns {string}
2117
+ */
2118
+ programId(): string;
2119
+ /**
2120
+ * Get the function name of the transition.
2121
+ * @returns {string}
2122
+ */
2123
+ functionName(): string;
2124
+ /**
2125
+ * Returns true if the transition contains the given commitment.
2126
+ *
2127
+ * @param {boolean} True if the transition contains the given commitment.
2128
+ * @param {Field} commitment
2129
+ * @returns {boolean}
2130
+ */
2131
+ containsCommitment(commitment: Field): boolean;
2132
+ /**
2133
+ * Check if the transition contains a serial number.
2134
+ *
2135
+ * @param {Field} serial_number The serial number to check for
2136
+ *
2137
+ * @returns {bool} True if the transition contains a serial number, false otherwise
2138
+ * @param {Field} serial_number
2139
+ * @returns {boolean}
2140
+ */
2141
+ containsSerialNumber(serial_number: Field): boolean;
2142
+ /**
2143
+ * Find a record in the transition by the record's commitment.
2144
+ * @param {Field} commitment
2145
+ * @returns {RecordCiphertext | undefined}
2146
+ */
2147
+ findRecord(commitment: Field): RecordCiphertext | undefined;
2148
+ /**
2149
+ * Get the record plaintext present in a transition owned by a specific view key.
2150
+ *
2151
+ * @param {ViewKey} view_key The view key of the record owner.
2152
+ *
2153
+ * @returns {Array<RecordPlaintext>} Array of record plaintext objects
2154
+ * @param {ViewKey} view_key
2155
+ * @returns {Array<any>}
2156
+ */
2157
+ ownedRecords(view_key: ViewKey): Array<any>;
2158
+ /**
2159
+ * Get the records present in a transition and their commitments.
2160
+ *
2161
+ * @returns {Array<{commitment: Field, record: RecordCiphertext}>} Array of record ciphertext objects
2162
+ * @returns {Array<any>}
2163
+ */
2164
+ records(): Array<any>;
2165
+ /**
2166
+ * Get the inputs of the transition.
2167
+ *
2168
+ * @param {bool} convert_to_js If true the inputs will be converted to JS objects, if false
2169
+ * the inputs will be in wasm format.
2170
+ *
2171
+ * @returns {Array} Array of inputs
2172
+ * @param {boolean} convert_to_js
2173
+ * @returns {Array<any>}
2174
+ */
2175
+ inputs(convert_to_js: boolean): Array<any>;
2176
+ /**
2177
+ * Get the outputs of the transition.
2178
+ *
2179
+ * @param {bool} convert_to_js If true the outputs will be converted to JS objects, if false
2180
+ * the outputs will be in wasm format.
2181
+ *
2182
+ * @returns {Array} Array of outputs
2183
+ * @param {boolean} convert_to_js
2184
+ * @returns {Array<any>}
2185
+ */
2186
+ outputs(convert_to_js: boolean): Array<any>;
2187
+ /**
2188
+ * Get the transition public key of the transition.
2189
+ * @returns {Group}
2190
+ */
2191
+ tpk(): Group;
2192
+ /**
2193
+ * Get the transition commitment of the transition.
2194
+ * @returns {Field}
2195
+ */
2196
+ tcm(): Field;
2197
+ /**
2198
+ * Get the transition signer commitment of the transition.
2199
+ * @returns {Field}
2200
+ */
2201
+ scm(): Field;
1384
2202
  }
1385
2203
  /**
1386
2204
  * Verifying key for a function within an Aleo program
@@ -1681,6 +2499,11 @@ export class ViewKey {
1681
2499
  */
1682
2500
  to_address(): Address;
1683
2501
  /**
2502
+ * Get the underlying scalar of a view key.
2503
+ * @returns {Scalar}
2504
+ */
2505
+ to_scalar(): Scalar;
2506
+ /**
1684
2507
  * Decrypt a record ciphertext with a view key
1685
2508
  *
1686
2509
  * @param {string} ciphertext String representation of a record ciphertext