@provablehq/wasm 0.7.2 → 0.8.0

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,21 +87,155 @@ 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 {
85
202
  free(): void;
86
203
  /**
87
204
  * Returns the string representation of the execution.
205
+ *
206
+ * @returns {string} The string representation of the execution.
88
207
  * @returns {string}
89
208
  */
90
209
  toString(): string;
91
210
  /**
92
211
  * Creates an execution object from a string representation of an execution.
212
+ *
213
+ * @returns {Execution | Error} The wasm representation of an execution object.
93
214
  * @param {string} execution
94
215
  * @returns {Execution}
95
216
  */
96
217
  static fromString(execution: string): Execution;
218
+ /**
219
+ * Returns the global state root of the execution.
220
+ *
221
+ * @returns {Execution | Error} The global state root used in the execution.
222
+ * @returns {string}
223
+ */
224
+ globalStateRoot(): string;
225
+ /**
226
+ * Returns the proof of the execution.
227
+ *
228
+ * @returns {string} The execution proof.
229
+ * @returns {string}
230
+ */
231
+ proof(): string;
232
+ /**
233
+ * Returns the transitions present in the execution.
234
+ *
235
+ * @returns Array<Transition> the array of transitions present in the execution.
236
+ * @returns {Array<any>}
237
+ */
238
+ transitions(): Array<any>;
97
239
  }
98
240
  /**
99
241
  * Webassembly Representation of an Aleo function execution response
@@ -150,18 +292,199 @@ export class ExecutionResponse {
150
292
  getProgram(): Program;
151
293
  }
152
294
  /**
295
+ * Field element.
153
296
  */
154
297
  export class Field {
155
298
  free(): void;
156
299
  /**
300
+ * Creates a field object from a string representation of a field.
301
+ * @param {string} field
302
+ * @returns {Field}
303
+ */
304
+ static fromString(field: string): Field;
305
+ /**
306
+ * Create a plaintext element from a group element.
307
+ * @returns {Plaintext}
308
+ */
309
+ toPlaintext(): Plaintext;
310
+ /**
311
+ * Returns the string representation of the field.
157
312
  * @returns {string}
158
313
  */
159
314
  toString(): string;
160
315
  /**
161
- * @param {string} field
316
+ * Generate a random field element.
162
317
  * @returns {Field}
163
318
  */
164
- static fromString(field: string): Field;
319
+ static random(): Field;
320
+ /**
321
+ * Add two field elements.
322
+ * @param {Field} other
323
+ * @returns {Field}
324
+ */
325
+ add(other: Field): Field;
326
+ /**
327
+ * Subtract two field elements.
328
+ * @param {Field} other
329
+ * @returns {Field}
330
+ */
331
+ subtract(other: Field): Field;
332
+ /**
333
+ * Multiply two field elements.
334
+ * @param {Field} other
335
+ * @returns {Field}
336
+ */
337
+ multiply(other: Field): Field;
338
+ /**
339
+ * Divide two field elements.
340
+ * @param {Field} other
341
+ * @returns {Field}
342
+ */
343
+ divide(other: Field): Field;
344
+ /**
345
+ * Power of a field element.
346
+ * @param {Field} other
347
+ * @returns {Field}
348
+ */
349
+ pow(other: Field): Field;
350
+ /**
351
+ * Invert the field element.
352
+ * @returns {Field}
353
+ */
354
+ inverse(): Field;
355
+ /**
356
+ * Get the zero element of the field.
357
+ * @returns {Field}
358
+ */
359
+ static zero(): Field;
360
+ /**
361
+ * Get the one element of the field.
362
+ * @returns {Field}
363
+ */
364
+ static one(): Field;
365
+ /**
366
+ * Double the field element.
367
+ * @returns {Field}
368
+ */
369
+ double(): Field;
370
+ /**
371
+ * Check if one field element equals another.
372
+ * @param {Field} other
373
+ * @returns {boolean}
374
+ */
375
+ equals(other: Field): boolean;
376
+ }
377
+ /**
378
+ */
379
+ export class GraphKey {
380
+ free(): void;
381
+ /**
382
+ * Create a new graph key from a view key.
383
+ *
384
+ * @param {ViewKey} view_key View key
385
+ * @returns {GraphKey} Graph key
386
+ * @param {ViewKey} view_key
387
+ * @returns {GraphKey}
388
+ */
389
+ static from_view_key(view_key: ViewKey): GraphKey;
390
+ /**
391
+ * Create a new graph key from a string representation of a graph key
392
+ *
393
+ * @param {string} graph_key String representation of a graph key
394
+ * @returns {GraphKey} Graph key
395
+ * @param {string} graph_key
396
+ * @returns {GraphKey}
397
+ */
398
+ static from_string(graph_key: string): GraphKey;
399
+ /**
400
+ * Get a string representation of a graph key
401
+ *
402
+ * @returns {string} String representation of a graph key
403
+ * @returns {string}
404
+ */
405
+ to_string(): string;
406
+ /**
407
+ * Get the sk_tag of the graph key. Used to determine ownership of records.
408
+ * @returns {Field}
409
+ */
410
+ sk_tag(): Field;
411
+ }
412
+ /**
413
+ * Elliptic curve element.
414
+ */
415
+ export class Group {
416
+ free(): void;
417
+ /**
418
+ * Creates a group object from a string representation of a group.
419
+ * @param {string} group
420
+ * @returns {Group}
421
+ */
422
+ static fromString(group: string): Group;
423
+ /**
424
+ * Returns the string representation of the group.
425
+ * @returns {string}
426
+ */
427
+ toString(): string;
428
+ /**
429
+ * Get the x-coordinate of the group element.
430
+ * @returns {Field}
431
+ */
432
+ toXCoordinate(): Field;
433
+ /**
434
+ * Create a plaintext element from a group element.
435
+ * @returns {Plaintext}
436
+ */
437
+ toPlaintext(): Plaintext;
438
+ /**
439
+ * Generate a random group element.
440
+ * @returns {Group}
441
+ */
442
+ static random(): Group;
443
+ /**
444
+ * Add two group elements.
445
+ * @param {Group} other
446
+ * @returns {Group}
447
+ */
448
+ add(other: Group): Group;
449
+ /**
450
+ * Subtract two group elements (equivalently: add the inverse of an element).
451
+ * @param {Group} other
452
+ * @returns {Group}
453
+ */
454
+ subtract(other: Group): Group;
455
+ /**
456
+ * Multiply a group element by a scalar element.
457
+ * @param {Scalar} scalar
458
+ * @returns {Group}
459
+ */
460
+ scalarMultiply(scalar: Scalar): Group;
461
+ /**
462
+ * Double the group element.
463
+ * @returns {Group}
464
+ */
465
+ double(): Group;
466
+ /**
467
+ * Get the inverse of the group element. This is the reflection of the point about the axis
468
+ * of symmetry i.e. (x,y) -> (x, -y).
469
+ * @returns {Group}
470
+ */
471
+ inverse(): Group;
472
+ /**
473
+ * Check if one group element equals another.
474
+ * @param {Group} other
475
+ * @returns {boolean}
476
+ */
477
+ equals(other: Group): boolean;
478
+ /**
479
+ * Get the group identity element under the group operation (i.e. the point at infinity.)
480
+ * @returns {Group}
481
+ */
482
+ static zero(): Group;
483
+ /**
484
+ * Get the generator of the group.
485
+ * @returns {Group}
486
+ */
487
+ static generator(): Group;
165
488
  }
166
489
  /**
167
490
  * Key pair object containing both the function proving and verifying keys
@@ -316,6 +639,101 @@ export class OfflineQuery {
316
639
  static fromString(s: string): OfflineQuery;
317
640
  }
318
641
  /**
642
+ * SnarkVM Plaintext object. Plaintext is a fundamental monadic type used to represent Aleo
643
+ * primitive types (boolean, field, group, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128,
644
+ * scalar, and signature), struct types, and array types.
645
+ *
646
+ * In the context of a web or NodeJS application, this type is useful for turning an Aleo type into
647
+ * a JS value, object, or array that might be necessary for performing computations within the
648
+ * application.
649
+ *
650
+ * @example
651
+ * // Get the bond state of an existing address.
652
+ * const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
653
+ * // Convert the bond state to a Plaintext object.
654
+ * const bondStatePlaintext = Plaintext.fromString(bond_state);
655
+ * // Convert the Plaintext object to a JS object.
656
+ * const bondStateObject = bond_state_plaintext.toObject();
657
+ * // Check if the bond state matches the expected object.
658
+ * const expectedObject = { validator: "aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f", microcredits: 100000000u64 };
659
+ * assert( JSON.stringify(bondStateObject) === JSON.stringify(expectedObject) );
660
+ */
661
+ export class Plaintext {
662
+ free(): void;
663
+ /**
664
+ * Find plaintext member if the plaintext is a struct. Returns `null` if the plaintext is not
665
+ * a struct or the member does not exist.
666
+ *
667
+ * @param {string} name The name of the plaintext member to find.
668
+ *
669
+ * @returns {Plaintext} The plaintext member.
670
+ * @param {string} name
671
+ * @returns {Plaintext}
672
+ */
673
+ find(name: string): Plaintext;
674
+ /**
675
+ * Encrypt a plaintext with an address and randomizer.
676
+ * @param {Address} address
677
+ * @param {Scalar} randomizer
678
+ * @returns {Ciphertext}
679
+ */
680
+ encrypt(address: Address, randomizer: Scalar): Ciphertext;
681
+ /**
682
+ * Encrypt a plaintext with a transition view key.
683
+ * @param {Field} transition_view_key
684
+ * @returns {Ciphertext}
685
+ */
686
+ encryptSymmetric(transition_view_key: Field): Ciphertext;
687
+ /**
688
+ * Creates a plaintext object from a string representation of a plaintext.
689
+ *
690
+ * @param {string} plaintext The string representation of the plaintext.
691
+ *
692
+ * @returns {Plaintext} The plaintext object.
693
+ * @param {string} plaintext
694
+ * @returns {Plaintext}
695
+ */
696
+ static fromString(plaintext: string): Plaintext;
697
+ /**
698
+ * Get a plaintext object from a series of bytes.
699
+ *
700
+ * @param {Uint8Array} bytes A left endian byte array representing the plaintext.
701
+ *
702
+ * @returns {Plaintext} The plaintext object.
703
+ * @param {Uint8Array} bytes
704
+ * @returns {Plaintext}
705
+ */
706
+ static fromBytesLe(bytes: Uint8Array): Plaintext;
707
+ /**
708
+ * Generate a random plaintext element from a series of bytes.
709
+ *
710
+ * @param {Uint8Array} bytes A left endian byte array representing the plaintext.
711
+ * @returns {Uint8Array}
712
+ */
713
+ toBytesLe(): Uint8Array;
714
+ /**
715
+ * Returns the string representation of the plaintext.
716
+ *
717
+ * @returns {string} The string representation of the plaintext.
718
+ * @returns {string}
719
+ */
720
+ toString(): string;
721
+ /**
722
+ * Gives the type of the plaintext.
723
+ *
724
+ * @returns {string} The type of the plaintext.
725
+ * @returns {string}
726
+ */
727
+ plaintextType(): string;
728
+ /**
729
+ * Attempt to convert the plaintext to a JS object.
730
+ *
731
+ * @returns {Object} The JS object representation of the plaintext.
732
+ * @returns {any}
733
+ */
734
+ toObject(): any;
735
+ }
736
+ /**
319
737
  * Private key of an Aleo account
320
738
  */
321
739
  export class PrivateKey {
@@ -1238,6 +1656,18 @@ export class RecordCiphertext {
1238
1656
  * @returns {boolean}
1239
1657
  */
1240
1658
  isOwner(view_key: ViewKey): boolean;
1659
+ /**
1660
+ * Get the tag of the record using the graph key.
1661
+ *
1662
+ * @param {GraphKey} graph key of the account associatd with the record.
1663
+ * @param {Field} commitment of the record.
1664
+ *
1665
+ * @returns {Field} tag of the record.
1666
+ * @param {GraphKey} graph_key
1667
+ * @param {Field} commitment
1668
+ * @returns {Field}
1669
+ */
1670
+ static tag(graph_key: GraphKey, commitment: Field): Field;
1241
1671
  }
1242
1672
  /**
1243
1673
  * Plaintext representation of an Aleo record
@@ -1260,6 +1690,69 @@ export class RecordPlaintext {
1260
1690
  */
1261
1691
  static fromString(record: string): RecordPlaintext;
1262
1692
  /**
1693
+ * @param {string} input
1694
+ * @returns {Plaintext}
1695
+ */
1696
+ getMember(input: string): Plaintext;
1697
+ /**
1698
+ * Get the owner of the record.
1699
+ * @returns {Address}
1700
+ */
1701
+ owner(): Address;
1702
+ /**
1703
+ * Get a representation of a record as a javascript object for usage in client side
1704
+ * computations. Note that this is not a reversible operation and exists for the convenience
1705
+ * of discovering and using properties of the record.
1706
+ *
1707
+ * The conversion guide is as follows:
1708
+ * - u8, u16, u32, i8, i16 i32 --> Number
1709
+ * - u64, u128, i64, i128 --> BigInt
1710
+ * - Address, Field, Group, Scalar --> String.
1711
+ *
1712
+ * Address, Field, Group, and Scalar will all be converted to their bech32 string
1713
+ * representation. These string representations can be converted back to their respective wasm
1714
+ * types using the fromString method on the Address, Field, Group, and Scalar objects in this
1715
+ * library.
1716
+ *
1717
+ * @example
1718
+ * # Create a wasm record from a record string.
1719
+ * let record_plaintext_wasm = RecordPlainext.from_string("{
1720
+ * owner: aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48.private,
1721
+ * metadata: {
1722
+ * player1: aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48.private,
1723
+ * player2: aleo1dreuxnmg9cny8ee9v2u0wr4v4affnwm09u2pytfwz0f2en2shgqsdsfjn6.private,
1724
+ * nonce: 660310649780728486489183263981322848354071976582883879926426319832534836534field.private
1725
+ * },
1726
+ * id: 1953278585719525811355617404139099418855053112960441725284031425961000152405field.private,
1727
+ * positions: 50794271u64.private,
1728
+ * attempts: 0u64.private,
1729
+ * hits: 0u64.private,
1730
+ * _nonce: 5668100912391182624073500093436664635767788874314097667746354181784048204413group.public
1731
+ * }");
1732
+ *
1733
+ * let expected_object = {
1734
+ * owner: "aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48",
1735
+ * metadata: {
1736
+ * player1: "aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48",
1737
+ * player2: "aleo1dreuxnmg9cny8ee9v2u0wr4v4affnwm09u2pytfwz0f2en2shgqsdsfjn6",
1738
+ * nonce: "660310649780728486489183263981322848354071976582883879926426319832534836534field"
1739
+ * },
1740
+ * id: "1953278585719525811355617404139099418855053112960441725284031425961000152405field",
1741
+ * positions: 50794271,
1742
+ * attempts: 0,
1743
+ * hits: 0,
1744
+ * _nonce: "5668100912391182624073500093436664635767788874314097667746354181784048204413group"
1745
+ * };
1746
+ *
1747
+ * # Create the expected object
1748
+ * let record_plaintext_object = record_plaintext_wasm.to_js_object();
1749
+ * assert(JSON.stringify(record_plaintext_object) == JSON.stringify(expected_object));
1750
+ *
1751
+ * @returns {Object} Javascript object representation of the record
1752
+ * @returns {object}
1753
+ */
1754
+ toJsObject(): object;
1755
+ /**
1263
1756
  * Returns the record plaintext string
1264
1757
  *
1265
1758
  * @returns {string} String representation of the record plaintext
@@ -1286,6 +1779,7 @@ export class RecordPlaintext {
1286
1779
  * @param {PrivateKey} private_key Private key of the account that owns the record
1287
1780
  * @param {string} program_id Program ID of the program that the record is associated with
1288
1781
  * @param {string} record_name Name of the record
1782
+ *
1289
1783
  * @returns {string} Serial number of the record
1290
1784
  * @param {PrivateKey} private_key
1291
1785
  * @param {string} program_id
@@ -1293,6 +1787,96 @@ export class RecordPlaintext {
1293
1787
  * @returns {string}
1294
1788
  */
1295
1789
  serialNumberString(private_key: PrivateKey, program_id: string, record_name: string): string;
1790
+ /**
1791
+ * Get the tag of the record using the graph key.
1792
+ * @param {GraphKey} graph_key
1793
+ * @param {Field} commitment
1794
+ * @returns {Field}
1795
+ */
1796
+ tag(graph_key: GraphKey, commitment: Field): Field;
1797
+ }
1798
+ /**
1799
+ * Scalar field element.
1800
+ */
1801
+ export class Scalar {
1802
+ free(): void;
1803
+ /**
1804
+ * Returns the string representation of the group.
1805
+ * @returns {string}
1806
+ */
1807
+ toString(): string;
1808
+ /**
1809
+ * Create a plaintext element from a group element.
1810
+ * @returns {Plaintext}
1811
+ */
1812
+ toPlaintext(): Plaintext;
1813
+ /**
1814
+ * Creates a group object from a string representation of a group.
1815
+ * @param {string} group
1816
+ * @returns {Scalar}
1817
+ */
1818
+ static fromString(group: string): Scalar;
1819
+ /**
1820
+ * Generate a random group element.
1821
+ * @returns {Scalar}
1822
+ */
1823
+ static random(): Scalar;
1824
+ /**
1825
+ * Add two scalar elements.
1826
+ * @param {Scalar} other
1827
+ * @returns {Scalar}
1828
+ */
1829
+ add(other: Scalar): Scalar;
1830
+ /**
1831
+ * Subtract two scalar elements.
1832
+ * @param {Scalar} other
1833
+ * @returns {Scalar}
1834
+ */
1835
+ subtract(other: Scalar): Scalar;
1836
+ /**
1837
+ * Multiply two scalar elements.
1838
+ * @param {Scalar} other
1839
+ * @returns {Scalar}
1840
+ */
1841
+ multiply(other: Scalar): Scalar;
1842
+ /**
1843
+ * Divide two scalar elements.
1844
+ * @param {Scalar} other
1845
+ * @returns {Scalar}
1846
+ */
1847
+ divide(other: Scalar): Scalar;
1848
+ /**
1849
+ * Double the scalar element.
1850
+ * @returns {Scalar}
1851
+ */
1852
+ double(): Scalar;
1853
+ /**
1854
+ * Power of a scalar element.
1855
+ * @param {Scalar} other
1856
+ * @returns {Scalar}
1857
+ */
1858
+ pow(other: Scalar): Scalar;
1859
+ /**
1860
+ * Invert the scalar element.
1861
+ * @returns {Scalar}
1862
+ */
1863
+ inverse(): Scalar;
1864
+ /**
1865
+ * Creates a one valued element of the scalar field.
1866
+ * @returns {Scalar}
1867
+ */
1868
+ static one(): Scalar;
1869
+ /**
1870
+ * Creates a zero valued element of the scalar field
1871
+ * @returns {Scalar}
1872
+ */
1873
+ static zero(): Scalar;
1874
+ /**
1875
+ * Check if one scalar element equals another.
1876
+ * @param {Scalar} other
1877
+ * @returns {boolean}
1878
+ */
1879
+ equals(other: Scalar): boolean;
1296
1880
  }
1297
1881
  /**
1298
1882
  * Cryptographic signature of a message signed by an Aleo account
@@ -1311,6 +1895,23 @@ export class Signature {
1311
1895
  */
1312
1896
  static sign(private_key: PrivateKey, message: Uint8Array): Signature;
1313
1897
  /**
1898
+ * Get an address from a signature.
1899
+ *
1900
+ * @returns {Address} Address object
1901
+ * @returns {Address}
1902
+ */
1903
+ to_address(): Address;
1904
+ /**
1905
+ * Get the challenge of a signature.
1906
+ * @returns {Scalar}
1907
+ */
1908
+ challenge(): Scalar;
1909
+ /**
1910
+ * Get the response of a signature.
1911
+ * @returns {Scalar}
1912
+ */
1913
+ response(): Scalar;
1914
+ /**
1314
1915
  * Verify a signature of a message with an address
1315
1916
  *
1316
1917
  * @param {Address} address The address to verify the signature with
@@ -1356,6 +1957,15 @@ export class Transaction {
1356
1957
  */
1357
1958
  static fromString(transaction: string): Transaction;
1358
1959
  /**
1960
+ * Create a transaction from a Uint8Array of left endian bytes.
1961
+ *
1962
+ * @param {Uint8Array} Uint8Array of left endian bytes encoding a Transaction.
1963
+ * @returns {Transaction}
1964
+ * @param {Uint8Array} bytes
1965
+ * @returns {Transaction}
1966
+ */
1967
+ static fromBytesLe(bytes: Uint8Array): Transaction;
1968
+ /**
1359
1969
  * Get the transaction as a string. If you want to submit this transaction to the Aleo Network
1360
1970
  * this function will create the string that should be submitted in the `POST` data.
1361
1971
  *
@@ -1364,23 +1974,287 @@ export class Transaction {
1364
1974
  */
1365
1975
  toString(): string;
1366
1976
  /**
1977
+ * Get the transaction as a Uint8Array of left endian bytes.
1978
+ *
1979
+ * @returns {Uint8Array} Uint8Array representation of the transaction
1980
+ * @returns {Uint8Array}
1981
+ */
1982
+ toBytesLe(): Uint8Array;
1983
+ /**
1984
+ * Returns true if the transaction contains the given serial number.
1985
+ *
1986
+ * @param {boolean} True if the transaction contains the given serial number.
1987
+ * @param {Field} serial_number
1988
+ * @returns {boolean}
1989
+ */
1990
+ constainsSerialNumber(serial_number: Field): boolean;
1991
+ /**
1992
+ * Returns true if the transaction contains the given commitment.
1993
+ *
1994
+ * @param {boolean} True if the transaction contains the given commitment.
1995
+ * @param {Field} commitment
1996
+ * @returns {boolean}
1997
+ */
1998
+ constainsCommitment(commitment: Field): boolean;
1999
+ /**
2000
+ * Find a record in the transaction by the record's commitment.
2001
+ * @param {Field} commitment
2002
+ * @returns {RecordCiphertext | undefined}
2003
+ */
2004
+ findRecord(commitment: Field): RecordCiphertext | undefined;
2005
+ /**
2006
+ * Returns the transaction's base fee.
2007
+ * @returns {bigint}
2008
+ */
2009
+ baseFeeAmount(): bigint;
2010
+ /**
2011
+ * Returns the transaction's total fee.
2012
+ * @returns {bigint}
2013
+ */
2014
+ feeAmount(): bigint;
2015
+ /**
2016
+ * Returns the transaction's priority fee.
2017
+ *
2018
+ * returns {bigint} The transaction's priority fee.
2019
+ * @returns {bigint}
2020
+ */
2021
+ priorityFeeAmount(): bigint;
2022
+ /**
2023
+ * Returns true if the transaction is a deployment transaction.
2024
+ *
2025
+ * @returns {boolean} True if the transaction is a deployment transaction
2026
+ * @returns {boolean}
2027
+ */
2028
+ isDeploy(): boolean;
2029
+ /**
2030
+ * Returns true if the transaction is an execution transaction.
2031
+ *
2032
+ * @returns {boolean} True if the transaction is an execution transaction
2033
+ * @returns {boolean}
2034
+ */
2035
+ isExecute(): boolean;
2036
+ /**
2037
+ * Returns true if the transaction is a fee transaction.
2038
+ *
2039
+ * @returns {boolean} True if the transaction is a fee transaction
2040
+ * @returns {boolean}
2041
+ */
2042
+ isFee(): boolean;
2043
+ /**
2044
+ * Returns the program deployed within the transaction if the transaction is a deployment
2045
+ * transaction.
2046
+ *
2047
+ * @returns {Program | undefined} The program deployed within the transaction.
2048
+ * @returns {Program | undefined}
2049
+ */
2050
+ deployedProgram(): Program | undefined;
2051
+ /**
2052
+ * Returns the execution within the transaction (if present).
2053
+ *
2054
+ * @returns {Execution | undefined} The execution within the transaction.
2055
+ * @returns {Execution | undefined}
2056
+ */
2057
+ execution(): Execution | undefined;
2058
+ /**
2059
+ * Get the record plaintext present in a transaction owned by a specific view key.
2060
+ *
2061
+ * @param {ViewKey} view_key View key used to decrypt the ciphertext
2062
+ *
2063
+ * @returns {Array<RecordPlaintext>} Array of record plaintext objects
2064
+ * @param {ViewKey} view_key
2065
+ * @returns {Array<any>}
2066
+ */
2067
+ ownedRecords(view_key: ViewKey): Array<any>;
2068
+ /**
2069
+ * Get the records present in a transaction and their commitments.
2070
+ *
2071
+ * @returns {Array<{commitment: Field, record: RecordCiphertext}>} Array of record ciphertext objects
2072
+ * @returns {Array<any>}
2073
+ */
2074
+ records(): Array<any>;
2075
+ /**
2076
+ * Get a summary of the transaction within a javascript object.
2077
+ *
2078
+ * If the transaction is an execution transaction, this function will return a list of the
2079
+ * transitions and their inputs and outputs.
2080
+ *
2081
+ * If the transaction is a deployment transaction, this function will return the program id and
2082
+ * a list of the functions and their verifying keys, constraint, and variable counts.
2083
+ *
2084
+ * @param {boolean} convert_to_js If true the inputs and outputs will be converted to JS objects,
2085
+ * if false the inputs and outputs will be in wasm format.
2086
+ *
2087
+ * @returns {Object} Transaction summary
2088
+ * @param {boolean} convert_to_js
2089
+ * @returns {object}
2090
+ */
2091
+ summary(convert_to_js: boolean): object;
2092
+ /**
1367
2093
  * Get the id of the transaction. This is the merkle root of the transaction's inclusion proof.
1368
2094
  *
1369
2095
  * This value can be used to query the status of the transaction on the Aleo Network to see
1370
2096
  * if it was successful. If successful, the transaction will be included in a block and this
1371
2097
  * value can be used to lookup the transaction data on-chain.
1372
2098
  *
1373
- * @returns {string} Transaction id
2099
+ * @returns {string} TransactionId
1374
2100
  * @returns {string}
1375
2101
  */
1376
- transactionId(): string;
2102
+ id(): string;
1377
2103
  /**
2104
+ * Get the
1378
2105
  * Get the type of the transaction (will return "deploy" or "execute")
1379
2106
  *
1380
2107
  * @returns {string} Transaction type
1381
2108
  * @returns {string}
1382
2109
  */
1383
2110
  transactionType(): string;
2111
+ /**
2112
+ * Get the transitions in a transaction.
2113
+ *
2114
+ * @returns {Array<Transition>} Array of transition objects
2115
+ * @returns {Array<any>}
2116
+ */
2117
+ transitions(): Array<any>;
2118
+ /**
2119
+ * Get the verifying keys in a transaction.
2120
+ *
2121
+ * @returns {Array<Object>} Array of verifying keys.
2122
+ * @returns {Array<any>}
2123
+ */
2124
+ verifyingKeys(): Array<any>;
2125
+ }
2126
+ /**
2127
+ */
2128
+ export class Transition {
2129
+ free(): void;
2130
+ /**
2131
+ * Get the transition ID
2132
+ *
2133
+ * @returns {string} The transition ID
2134
+ * @returns {string}
2135
+ */
2136
+ id(): string;
2137
+ /**
2138
+ * Create a transition from a string
2139
+ *
2140
+ * @param {string} transition String representation of a transition
2141
+ * @returns {Transition}
2142
+ * @param {string} transition
2143
+ * @returns {Transition}
2144
+ */
2145
+ static fromString(transition: string): Transition;
2146
+ /**
2147
+ * Create a transition from a Uint8Array of left endian bytes.
2148
+ *
2149
+ * @param {Uint8Array} Uint8Array of left endian bytes encoding a Transition.
2150
+ * @returns {Transition}
2151
+ * @param {Uint8Array} bytes
2152
+ * @returns {Transition}
2153
+ */
2154
+ static fromBytesLe(bytes: Uint8Array): Transition;
2155
+ /**
2156
+ * Get the transition as a string. If you want to submit this transition to the Aleo Network
2157
+ * this function will create the string that should be submitted in the `POST` data.
2158
+ *
2159
+ * @returns {string} String representation of the transition
2160
+ * @returns {string}
2161
+ */
2162
+ toString(): string;
2163
+ /**
2164
+ * Get the transition as a Uint8Array of left endian bytes.
2165
+ *
2166
+ * @returns {Uint8Array} Uint8Array representation of the transition
2167
+ * @returns {Uint8Array}
2168
+ */
2169
+ toBytesLe(): Uint8Array;
2170
+ /**
2171
+ * Get the program ID of the transition.
2172
+ * @returns {string}
2173
+ */
2174
+ programId(): string;
2175
+ /**
2176
+ * Get the function name of the transition.
2177
+ * @returns {string}
2178
+ */
2179
+ functionName(): string;
2180
+ /**
2181
+ * Returns true if the transition contains the given commitment.
2182
+ *
2183
+ * @param {boolean} True if the transition contains the given commitment.
2184
+ * @param {Field} commitment
2185
+ * @returns {boolean}
2186
+ */
2187
+ containsCommitment(commitment: Field): boolean;
2188
+ /**
2189
+ * Check if the transition contains a serial number.
2190
+ *
2191
+ * @param {Field} serial_number The serial number to check for
2192
+ *
2193
+ * @returns {bool} True if the transition contains a serial number, false otherwise
2194
+ * @param {Field} serial_number
2195
+ * @returns {boolean}
2196
+ */
2197
+ containsSerialNumber(serial_number: Field): boolean;
2198
+ /**
2199
+ * Find a record in the transition by the record's commitment.
2200
+ * @param {Field} commitment
2201
+ * @returns {RecordCiphertext | undefined}
2202
+ */
2203
+ findRecord(commitment: Field): RecordCiphertext | undefined;
2204
+ /**
2205
+ * Get the record plaintext present in a transition owned by a specific view key.
2206
+ *
2207
+ * @param {ViewKey} view_key The view key of the record owner.
2208
+ *
2209
+ * @returns {Array<RecordPlaintext>} Array of record plaintext objects
2210
+ * @param {ViewKey} view_key
2211
+ * @returns {Array<any>}
2212
+ */
2213
+ ownedRecords(view_key: ViewKey): Array<any>;
2214
+ /**
2215
+ * Get the records present in a transition and their commitments.
2216
+ *
2217
+ * @returns {Array<{commitment: Field, record: RecordCiphertext}>} Array of record ciphertext objects
2218
+ * @returns {Array<any>}
2219
+ */
2220
+ records(): Array<any>;
2221
+ /**
2222
+ * Get the inputs of the transition.
2223
+ *
2224
+ * @param {bool} convert_to_js If true the inputs will be converted to JS objects, if false
2225
+ * the inputs will be in wasm format.
2226
+ *
2227
+ * @returns {Array} Array of inputs
2228
+ * @param {boolean} convert_to_js
2229
+ * @returns {Array<any>}
2230
+ */
2231
+ inputs(convert_to_js: boolean): Array<any>;
2232
+ /**
2233
+ * Get the outputs of the transition.
2234
+ *
2235
+ * @param {bool} convert_to_js If true the outputs will be converted to JS objects, if false
2236
+ * the outputs will be in wasm format.
2237
+ *
2238
+ * @returns {Array} Array of outputs
2239
+ * @param {boolean} convert_to_js
2240
+ * @returns {Array<any>}
2241
+ */
2242
+ outputs(convert_to_js: boolean): Array<any>;
2243
+ /**
2244
+ * Get the transition public key of the transition.
2245
+ * @returns {Group}
2246
+ */
2247
+ tpk(): Group;
2248
+ /**
2249
+ * Get the transition commitment of the transition.
2250
+ * @returns {Field}
2251
+ */
2252
+ tcm(): Field;
2253
+ /**
2254
+ * Get the transition signer commitment of the transition.
2255
+ * @returns {Field}
2256
+ */
2257
+ scm(): Field;
1384
2258
  }
1385
2259
  /**
1386
2260
  * Verifying key for a function within an Aleo program
@@ -1681,6 +2555,11 @@ export class ViewKey {
1681
2555
  */
1682
2556
  to_address(): Address;
1683
2557
  /**
2558
+ * Get the underlying scalar of a view key.
2559
+ * @returns {Scalar}
2560
+ */
2561
+ to_scalar(): Scalar;
2562
+ /**
1684
2563
  * Decrypt a record ciphertext with a view key
1685
2564
  *
1686
2565
  * @param {string} ciphertext String representation of a record ciphertext