@provablehq/wasm 0.9.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@
13
13
  * @param {Object} import_verifying_keys The verifying keys for the imports in the form of { "program_id.aleo": [["function, "verifying_key"], ...], ...}
14
14
  * @returns {boolean} True if the execution is valid, false otherwise
15
15
  */
16
- export function verifyFunctionExecution(execution: Execution, verifying_key: VerifyingKey, program: Program, function_id: string, imports?: object | null, imported_verifying_keys?: object | null): boolean;
16
+ 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;
17
17
  export function runRayonThread(receiver: number): void;
18
18
  export function initThreadPool(url: URL, num_threads: number): Promise<void>;
19
19
  /**
@@ -116,6 +116,87 @@ export class Address {
116
116
  */
117
117
  verify(message: Uint8Array, signature: Signature): boolean;
118
118
  }
119
+ /**
120
+ * Authorization object containing the authorization for a transaction.
121
+ */
122
+ export class Authorization {
123
+ private constructor();
124
+ free(): void;
125
+ /**
126
+ * Create a new authorization from a request object.
127
+ *
128
+ * @param {ExecutionRequest} request The ExecutionRequest to build the authorization from.
129
+ */
130
+ static new(request: ExecutionRequest): Authorization;
131
+ /**
132
+ * Returns a new and independent replica of the Authorization.
133
+ */
134
+ replicate(): Authorization;
135
+ /**
136
+ * Returns the string representation of the Authorization.
137
+ */
138
+ toString(): string;
139
+ /**
140
+ * Reconstructs an Authorization object from its string representation.
141
+ *
142
+ * @param {String} authorization The string representation of the Authorization.
143
+ */
144
+ static fromString(authorization: string): Authorization;
145
+ /**
146
+ * Returns the left-endian byte representation of the Authorization.
147
+ */
148
+ toBytesLe(): Uint8Array;
149
+ /**
150
+ * Creates an authorization object from a left-endian byte representation of an Authorization.
151
+ *
152
+ * @param {Uint8Array} bytes Left-endian bytes representing the Authorization.
153
+ */
154
+ static fromBytesLe(bytes: Uint8Array): Authorization;
155
+ /**
156
+ * Check if an Authorization object is the same as another.
157
+ *
158
+ * @param {Authorization} other The Authorization object to determine equality with.
159
+ */
160
+ equals(other: Authorization): boolean;
161
+ /**
162
+ * Returns the number of `Request`s in the Authorization.
163
+ */
164
+ len(): number;
165
+ /**
166
+ * Return `true` if the Authorization is empty.
167
+ */
168
+ isEmpty(): boolean;
169
+ /**
170
+ * Returns `true` if the Authorization is for `credits.aleo/fee_private`.
171
+ */
172
+ isFeePrivate(): boolean;
173
+ /**
174
+ * Returns `true` if the Authorization is for `credits.aleo/fee_public`.
175
+ */
176
+ isFeePublic(): boolean;
177
+ /**
178
+ * Returns `true` if the Authorization is for `credits.aleo/split`.
179
+ */
180
+ isSplit(): boolean;
181
+ /**
182
+ * Insert a transition into the Authorization.
183
+ *
184
+ * @param {Transition} transition The transition object to insert into the Authorization.
185
+ */
186
+ insertTransition(transition: Transition): void;
187
+ /**
188
+ * Get the transitions in an Authorization.
189
+ *
190
+ * @returns {Array<Transition>} Array of transition objects
191
+ */
192
+ transitions(): Array<any>;
193
+ /**
194
+ * Returns the execution ID for the Authorization.
195
+ *
196
+ * @returns {Field} The execution ID for the Authorization, call toString() after this result to get the string representation.
197
+ */
198
+ toExecutionId(): Field;
199
+ }
119
200
  export class BHP1024 {
120
201
  free(): void;
121
202
  /**
@@ -224,12 +305,84 @@ export class BHP768 {
224
305
  */
225
306
  commitToGroup(input: Array<any>, randomizer: Scalar): Group;
226
307
  }
308
+ /**
309
+ * Boolean element.
310
+ */
311
+ export class Boolean {
312
+ free(): void;
313
+ /**
314
+ * Creates a Boolean from a native JS bool.
315
+ */
316
+ constructor(value: boolean);
317
+ /**
318
+ * Creates a boolean object from a string representation ("true"/"false").
319
+ */
320
+ static fromString(boolean: string): Boolean;
321
+ /**
322
+ * Returns the string representation of the boolean element.
323
+ */
324
+ toString(): string;
325
+ /**
326
+ * Create a boolean element from a Uint8Array of left endian bytes.
327
+ */
328
+ static fromBytesLe(bytes: Uint8Array): Boolean;
329
+ /**
330
+ * Encode the boolean element as a Uint8Array of left endian bytes.
331
+ */
332
+ toBytesLe(): Uint8Array;
333
+ /**
334
+ * Reconstruct a boolean element from a boolean array representation.
335
+ */
336
+ static fromBitsLe(bits: Array<any>): Boolean;
337
+ /**
338
+ * Get the left endian boolean array representation of the boolean element.
339
+ */
340
+ toBitsLe(): Array<any>;
341
+ /**
342
+ * Create a plaintext from the boolean element.
343
+ */
344
+ toPlaintext(): Plaintext;
345
+ /**
346
+ * Clone the boolean element.
347
+ */
348
+ clone(): Boolean;
349
+ /**
350
+ * Generate a random boolean element.
351
+ */
352
+ static random(): Boolean;
353
+ /**
354
+ * Logical NOT.
355
+ */
356
+ not(): Boolean;
357
+ /**
358
+ * Logical AND.
359
+ */
360
+ and(other: Boolean): Boolean;
361
+ /**
362
+ * Logical OR.
363
+ */
364
+ or(other: Boolean): Boolean;
365
+ /**
366
+ * Logical XOR.
367
+ */
368
+ xor(other: Boolean): Boolean;
369
+ /**
370
+ * Logical NAND.
371
+ */
372
+ nand(other: Boolean): Boolean;
373
+ /**
374
+ * Logical NOR.
375
+ */
376
+ nor(other: Boolean): Boolean;
377
+ /**
378
+ * Check if one boolean element equals another.
379
+ */
380
+ equals(other: Boolean): boolean;
381
+ }
227
382
  /**
228
383
  * SnarkVM Ciphertext object. A Ciphertext represents an symmetrically encrypted plaintext. This
229
384
  * object provides decryption methods to recover the plaintext from the ciphertext (given the
230
385
  * api consumer has the proper decryption materials).
231
- *
232
- * @example
233
386
  */
234
387
  export class Ciphertext {
235
388
  private constructor();
@@ -246,10 +399,25 @@ export class Ciphertext {
246
399
  /**
247
400
  * Decrypt a ciphertext using the view key of the transition signer, transition public key, and
248
401
  * (program, function, index) tuple.
402
+ *
403
+ * @param {ViewKey} view_key The view key of the transition signer.
404
+ * @param {Group} transition_public_key The transition public key used to encrypt the ciphertext.
405
+ * @param {string} program The program ID associated with the ciphertext.
406
+ * @param {string} function_name The name of the function associated with the encrypted inputs and outputs.
407
+ * @param {u16} index The index of the input or output parameter that was encrypted.
408
+ *
409
+ * @returns {Plaintext} The decrypted plaintext.
249
410
  */
250
411
  decryptWithTransitionInfo(view_key: ViewKey, transition_public_key: Group, program: string, function_name: string, index: number): Plaintext;
251
412
  /**
252
413
  * Decrypt a ciphertext using the transition view key and a (program, function, index) tuple.
414
+ *
415
+ * @param {Field} transition_view_key The transition view key that was used to encrypt the ciphertext.
416
+ * @param {string} program The program ID associated with the ciphertext.
417
+ * @param {string} function_name The name of the function associated with the encrypted inputs and outputs.
418
+ * @param {u16} index The index of the input or output parameter that was encrypted.
419
+ *
420
+ * @returns {Plaintext} The decrypted plaintext.
253
421
  */
254
422
  decryptWithTransitionViewKey(transition_view_key: Field, program: string, function_name: string, index: number): Plaintext;
255
423
  /**
@@ -353,6 +521,48 @@ export class ComputeKey {
353
521
  */
354
522
  pr_sig(): Group;
355
523
  }
524
+ export class EncryptionToolkit {
525
+ private constructor();
526
+ free(): void;
527
+ /**
528
+ * Generates a transition view key from the view key and the transition public key.
529
+ *
530
+ * @param {ViewKey} view_key The view key of the account that generated the transition.
531
+ * @param {Group} tpk The transition public key.
532
+ *
533
+ * @returns {Field} The transition view key.
534
+ */
535
+ static generateTvk(view_key: ViewKey, tpk: Group): Field;
536
+ /**
537
+ * Creates a record view key from the view key. This can be later be used to decrypt a
538
+ *
539
+ * @param {ViewKey} view_key The view key of the owner of the record.
540
+ * @param {RecordCiphertext} record_ciphertext The record ciphertext used to derive the record view key.
541
+ *
542
+ * @returns {Field} The record view key.
543
+ */
544
+ static generateRecordViewKey(view_key: ViewKey, record_ciphertext: RecordCiphertext): Field;
545
+ /**
546
+ * Decrypts a record ciphertext using the record view key. Decryption only succeeds
547
+ * if the record view key was generated from the view key of the record owner.
548
+ *
549
+ * @param {Field} record_vk The record view key.
550
+ * @param {RecordCiphertext} record_ciphertext The record ciphertext to decrypt.
551
+ *
552
+ * @returns {RecordPlaintext} The decrypted record plaintext.
553
+ */
554
+ static decryptRecordWithRVk(record_vk: Field, record_ciphertext: RecordCiphertext): RecordPlaintext;
555
+ /**
556
+ * Decrypts a transition using the transition view key. The ciphertext inputs and outputs
557
+ * can only be decrypted if the transition view key was generated by the transaction signer.
558
+ *
559
+ * @param {Transition} transition The transition to decrypt.
560
+ * @param {Field} transition_vk The transition view key.
561
+ *
562
+ * @returns {Transition} The decrypted transition.
563
+ */
564
+ static decryptTransitionWithVk(transition: Transition, transition_vk: Field): Transition;
565
+ }
356
566
  /**
357
567
  * Execution of an Aleo program.
358
568
  */
@@ -390,6 +600,97 @@ export class Execution {
390
600
  */
391
601
  transitions(): Array<any>;
392
602
  }
603
+ export class ExecutionRequest {
604
+ private constructor();
605
+ free(): void;
606
+ /**
607
+ * Returns the request as a string.
608
+ *
609
+ * @returns {string} String representation of the request.
610
+ */
611
+ toString(): string;
612
+ /**
613
+ * Builds a request object from a string representation of a request.
614
+ *
615
+ * @param {string} request String representation of the request.
616
+ */
617
+ static fromString(request: string): ExecutionRequest;
618
+ /**
619
+ * Returns the bytes representation of the request.
620
+ */
621
+ toBytesLe(): Uint8Array;
622
+ /**
623
+ * Creates an request object from a bytes representation of an request.
624
+ */
625
+ static fromBytesLe(bytes: Uint8Array): ExecutionRequest;
626
+ /**
627
+ * Returns the request signer.
628
+ */
629
+ signer(): Address;
630
+ /**
631
+ * Returns the network ID.
632
+ */
633
+ network_id(): number;
634
+ /**
635
+ * Returns the program ID.
636
+ */
637
+ program_id(): string;
638
+ /**
639
+ * Returns the function name.
640
+ */
641
+ function_name(): string;
642
+ /**
643
+ * Returns the input IDs for the transition.
644
+ */
645
+ input_ids(): Array<any>;
646
+ /**
647
+ * Returns the function inputs as an array of strings.
648
+ */
649
+ inputs(): Array<any>;
650
+ /**
651
+ * Returns the signature for the transition.
652
+ */
653
+ signature(): Signature;
654
+ /**
655
+ * Returns the tag secret key `sk_tag`.
656
+ */
657
+ sk_tag(): Field;
658
+ /**
659
+ * Returns the transition view key `tvk`.
660
+ */
661
+ tvk(): Field;
662
+ /**
663
+ * Returns the transition public key `tpk`.
664
+ */
665
+ to_tpk(): Group;
666
+ /**
667
+ * Returns the transition commitment `tcm`.
668
+ */
669
+ tcm(): Field;
670
+ /**
671
+ * Returns the signer commitment `scm`.
672
+ */
673
+ scm(): Field;
674
+ /**
675
+ * Create a new request by signing over a program ID and set of inputs.
676
+ *
677
+ * @param {PrivateKey} private_key The private key of the signer.
678
+ * @param {string} program_id The id of the program to create the signature for.
679
+ * @param {string} function_name The function name to create the signature for.
680
+ * @param {string[]} inputs The inputs to the function.
681
+ * @param {string[]} input_types The input types of the function.
682
+ * @param {Field | undefined} root_tvk The tvk of the function at the top of the call graph. This is undefined if this request is built for the top-level call or if there is only one function in the call graph.
683
+ * @param {boolean} is_root Flag to indicate if this is the top level function in the call graph.
684
+ */
685
+ static sign(private_key: PrivateKey, program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, root_tvk: Field | null | undefined, is_root: boolean): ExecutionRequest;
686
+ /**
687
+ * Verify the input types within a request.
688
+ *
689
+ * @param {string[]} The input_types within the request.
690
+ * @param {boolean} Flag to indicate whether this request is the first function in the call graph.
691
+ */
692
+ verify(input_types: Array<any>, is_root: boolean): boolean;
693
+ }
393
694
  /**
394
695
  * Webassembly Representation of an Aleo function execution response
395
696
  *
@@ -692,25 +993,36 @@ export class OfflineQuery {
692
993
  free(): void;
693
994
  /**
694
995
  * Creates a new offline query object. The state root is required to be passed in as a string
996
+ *
997
+ * @param {u32} block_height The block height.
998
+ * @param {string} state_root The state root of the current network.
999
+ *
1000
+ * @returns {OfflineQuery} The newly created offline query object.
695
1001
  */
696
1002
  constructor(block_height: number, state_root: string);
697
1003
  /**
698
1004
  * Add a new block height to the offline query object.
1005
+ *
1006
+ * @param {u32} block_height The block height to add.
699
1007
  */
700
1008
  addBlockHeight(block_height: number): void;
701
1009
  /**
702
1010
  * Add a new state path to the offline query object.
703
1011
  *
704
- * @param {string} commitment: The commitment corresponding to a record inpout
705
- * @param {string} state_path: The state path corresponding to the commitment
1012
+ * @param {string} commitment: The commitment corresponding to a record input.
1013
+ * @param {string} state_path: The state path corresponding to the commitment.
706
1014
  */
707
1015
  addStatePath(commitment: string, state_path: string): void;
708
1016
  /**
709
- * Get a json string representation of the offline query object
1017
+ * Get a json string representation of the offline query object.
1018
+ *
1019
+ * @returns {string} JSON string representation of the offline query object.
710
1020
  */
711
1021
  toString(): string;
712
1022
  /**
713
- * Create an offline query object from a json string representation
1023
+ * Create an offline query object from a json string representation.
1024
+ *
1025
+ * @param {string} JSON string representation of the offline query object.
714
1026
  */
715
1027
  static fromString(s: string): OfflineQuery;
716
1028
  }
@@ -794,10 +1106,20 @@ export class Plaintext {
794
1106
  find(name: string): Plaintext;
795
1107
  /**
796
1108
  * Encrypt a plaintext with an address and randomizer.
1109
+ *
1110
+ * @param {Address} address The address to encrypt the plaintext for.
1111
+ * @param {Scalar} randomizer The randomizer to use for encryption.
1112
+ *
1113
+ * @returns {Ciphertext} The encrypted ciphertext.
797
1114
  */
798
1115
  encrypt(address: Address, randomizer: Scalar): Ciphertext;
799
1116
  /**
800
1117
  * Encrypt a plaintext with a transition view key.
1118
+ *
1119
+ * @param {Field} transition_view_key The transition view key of the transition
1120
+ * associated with the plaintext.
1121
+ *
1122
+ * @returns {Ciphertext} The encrypted ciphertext.
801
1123
  */
802
1124
  encryptSymmetric(transition_view_key: Field): Ciphertext;
803
1125
  /**
@@ -818,6 +1140,8 @@ export class Plaintext {
818
1140
  static fromBytesLe(bytes: Uint8Array): Plaintext;
819
1141
  /**
820
1142
  * Get the left endian byte array representation of the plaintext.
1143
+ *
1144
+ * @returns {Uint8Array} The left endian byte array representation of the plaintext.
821
1145
  */
822
1146
  toBytesLe(): Uint8Array;
823
1147
  /**
@@ -830,6 +1154,8 @@ export class Plaintext {
830
1154
  static fromBitsLe(bits: Array<any>): Plaintext;
831
1155
  /**
832
1156
  * Get the left endian boolean array representation of the bits of the plaintext.
1157
+ *
1158
+ * @returns {Array} The left endian boolean array representation of the bits of the plaintext.
833
1159
  */
834
1160
  toBitsLe(): Array<any>;
835
1161
  /**
@@ -842,6 +1168,8 @@ export class Plaintext {
842
1168
  static fromFields(fields: Array<any>): Plaintext;
843
1169
  /**
844
1170
  * Get the field array representation of the plaintext.
1171
+ *
1172
+ * @returns {Array} The field array representation of the plaintext.
845
1173
  */
846
1174
  toFields(): Array<any>;
847
1175
  /**
@@ -1297,6 +1625,40 @@ export class Program {
1297
1625
  export class ProgramManager {
1298
1626
  private constructor();
1299
1627
  free(): void;
1628
+ /**
1629
+ * Create an execution `Authorization` for a given program:function tuple with specified inputs.
1630
+ *
1631
+ * @param private_key The private key of the signer.
1632
+ * @param program The program source code containing the function to authorize.
1633
+ * @param function_name The function to authorize.
1634
+ * @param inputs A javascript array of inputs to the function.
1635
+ * @param imports The imports to the program in the format {"programname.aleo":"aleo instructions source code"}.
1636
+ */
1637
+ static authorize(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, imports?: object | null): Promise<Authorization>;
1638
+ /**
1639
+ * Create an execution `Authorization` without generating a circuit. Use this function when
1640
+ * fast delegated proving is needed.
1641
+ *
1642
+ * @param private_key The private key of the signer.
1643
+ * @param program The program source code containing the function to authorize.
1644
+ * @param function_name The function to authorize.
1645
+ * @param inputs A javascript array of inputs to the function.
1646
+ * @param imports The imports to the program in the format {"programname.aleo":"aleo instructions source code"}.
1647
+ */
1648
+ static buildAuthorizationUnchecked(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, imports?: object | null): Promise<Authorization>;
1649
+ /**
1650
+ * Create an `Authorization` for `credits.aleo/fee_public` or `credits.aleo/fee_private`.
1651
+ * This object requires an associated execution or deployment ID. This can be gained from
1652
+ * any previously created authorization by calling (authorization.toExecutionId()).
1653
+ *
1654
+ * @param private_key The private key of the signer.
1655
+ * @param deployment_or_execution_id The id of the deployment or execution to authorize the fee program for.
1656
+ * @param base_fee_credits The base fee to be paid for the authorization
1657
+ * @param priority_fee_credits The optional priority fee to be paid for the transaction
1658
+ * @param fee_record The record to spend the fee from
1659
+ * @returns {Authorization}
1660
+ */
1661
+ static authorizeFee(private_key: PrivateKey, deployment_or_execution_id: string, base_fee_credits: number, priority_fee_credits: number, fee_record?: RecordPlaintext | null): Promise<Authorization>;
1300
1662
  /**
1301
1663
  * Deploy an Aleo program
1302
1664
  *
@@ -1434,6 +1796,24 @@ export class ProgramManager {
1434
1796
  * @returns {Transaction} Transaction object
1435
1797
  */
1436
1798
  static buildJoinTransaction(private_key: PrivateKey, record_1: RecordPlaintext, record_2: RecordPlaintext, priority_fee_credits: number, fee_record?: RecordPlaintext | null, url?: string | null, join_proving_key?: ProvingKey | null, join_verifying_key?: VerifyingKey | null, fee_proving_key?: ProvingKey | null, fee_verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null): Promise<Transaction>;
1799
+ /**
1800
+ * Create a `ProvingRequest` object. This object creates authorizations for the top level
1801
+ * function and associated fee function. This object can be sent directly to a remote prover
1802
+ * OR used to extract both execution and fee authorizations.
1803
+ *
1804
+ * @param private_key The private key of the signer.
1805
+ * @param program The program source code containing the function to authorize.
1806
+ * @param function_name The function to authorize.
1807
+ * @param inputs A javascript array of inputs to the function.
1808
+ * @param base_fee_credits The base fee to be paid for the authorization
1809
+ * @param priority_fee_credits The optional priority fee to be paid for the transaction
1810
+ * @param fee_record The record to spend the fee from
1811
+ * @param imports The imports to the program in the format {"programname.aleo":"aleo instructions source code"}.
1812
+ * @param url The url of the Aleo network node to send the transaction to
1813
+ * @param broadcast (optional) Flag to indicate if the transaction should be broadcast
1814
+ * @returns {Authorization}
1815
+ */
1816
+ static buildProvingRequest(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, base_fee_credits: number, priority_fee_credits: number, fee_record: RecordPlaintext | null | undefined, imports: object | null | undefined, broadcast: boolean, unchecked: boolean): Promise<ProvingRequest>;
1437
1817
  /**
1438
1818
  * Split an Aleo credits record into two separate records. This function does not require a fee.
1439
1819
  *
@@ -1669,6 +2049,57 @@ export class ProvingKey {
1669
2049
  */
1670
2050
  toString(): string;
1671
2051
  }
2052
+ /**
2053
+ * Represents a proving request to a prover.
2054
+ */
2055
+ export class ProvingRequest {
2056
+ private constructor();
2057
+ free(): void;
2058
+ /**
2059
+ * Creates a new ProvingRequest from a function Authorization and an optional fee Authorization.
2060
+ *
2061
+ * @param {Authorization} authorization An Authorization for a function.
2062
+ * @param {Authorization} fee_authorization The authorization for the `credits.aleo/fee_public` or `credits.aleo/fee_private` function that pays the fee for the execution of the main function.
2063
+ * @param {boolean} broadcast Flag that indicates whether the remote proving service should attempt to submit the transaction on the caller's behalf.
2064
+ */
2065
+ static new(authorization: Authorization, fee_authorization: Authorization | null | undefined, broadcast: boolean): ProvingRequest;
2066
+ /**
2067
+ * Creates a ProvingRequest from a string representation.
2068
+ *
2069
+ * @param {Uint8Array} request String representation of the ProvingRequest.
2070
+ */
2071
+ static fromString(request: string): ProvingRequest;
2072
+ /**
2073
+ * Creates a string representation of the ProvingRequest.
2074
+ */
2075
+ toString(): string;
2076
+ /**
2077
+ * Creates a ProvingRequest from a left-endian byte representation of the ProvingRequest.
2078
+ *
2079
+ * @param {Uint8Array} bytes Left-endian bytes representing the proving request.
2080
+ */
2081
+ static fromBytesLe(bytes: Uint8Array): ProvingRequest;
2082
+ /**
2083
+ * Creates a left-endian byte representation of the ProvingRequest.
2084
+ */
2085
+ toBytesLe(): Uint8Array;
2086
+ /**
2087
+ * Get the Authorization of the main function in the ProvingRequest.
2088
+ */
2089
+ authorization(): Authorization;
2090
+ /**
2091
+ * Get the fee Authorization in the ProvingRequest.
2092
+ */
2093
+ feeAuthorization(): Authorization | undefined;
2094
+ /**
2095
+ * Get the broadcast flag set in the ProvingRequest.
2096
+ */
2097
+ broadcast(): boolean;
2098
+ /**
2099
+ * Check if a ProvingRequest is the same as another ProvingRequest.
2100
+ */
2101
+ equals(other: ProvingRequest): boolean;
2102
+ }
1672
2103
  /**
1673
2104
  * Encrypted Aleo record
1674
2105
  */
@@ -1683,7 +2114,7 @@ export class RecordCiphertext {
1683
2114
  */
1684
2115
  static fromString(record: string): RecordCiphertext;
1685
2116
  /**
1686
- * Return the string reprensentation of the record ciphertext
2117
+ * Return the string representation of the record ciphertext
1687
2118
  *
1688
2119
  * @returns {string} String representation of the record ciphertext
1689
2120
  */
@@ -1696,6 +2127,15 @@ export class RecordCiphertext {
1696
2127
  * @returns {RecordPlaintext} Record plaintext object
1697
2128
  */
1698
2129
  decrypt(view_key: ViewKey): RecordPlaintext;
2130
+ /**
2131
+ * Generate the record view key. The record view key can only decrypt record if the
2132
+ * supplied view key belongs to the record owner.
2133
+ *
2134
+ * @param {ViewKey} view_key View key used to generate the record view key
2135
+ *
2136
+ * @returns {Group} record view key
2137
+ */
2138
+ recordViewKey(view_key: ViewKey): Field;
1699
2139
  /**
1700
2140
  * Determines if the account corresponding to the view key is the owner of the record
1701
2141
  *
@@ -1722,16 +2162,36 @@ export class RecordCiphertext {
1722
2162
  static fromBytesLe(bytes: Uint8Array): RecordCiphertext;
1723
2163
  /**
1724
2164
  * Get the left endian byte array representation of the record ciphertext.
2165
+ *
2166
+ * @returns {Uint8Array} Left endian byte array representation of the record ciphertext.
1725
2167
  */
1726
2168
  toBytesLe(): Uint8Array;
1727
2169
  /**
1728
2170
  * Get the left endian boolean array representation of the record ciphertext bits.
2171
+ *
2172
+ * returns {Array} Left endian boolean array representation of the bits of the record ciphertext.
1729
2173
  */
1730
2174
  toBitsLe(): Array<any>;
1731
2175
  /**
1732
2176
  * Get the field array representation of the record ciphertext.
2177
+ *
2178
+ * @returns {Array} Field array representation of the record ciphertext.
1733
2179
  */
1734
2180
  toFields(): Array<any>;
2181
+ /**
2182
+ * Decrypt the record ciphertext into plaintext using a record view key.
2183
+ *
2184
+ * @param {Field} record_vk Record view key used to decrypt the record.
2185
+ *
2186
+ * @returns {RecordPlaintext}
2187
+ */
2188
+ decryptWithRecordViewKey(record_vk: Field): RecordPlaintext;
2189
+ /**
2190
+ * Get the record nonce.
2191
+ *
2192
+ * @returns {Group} The record nonce.
2193
+ */
2194
+ nonce(): Group;
1735
2195
  }
1736
2196
  /**
1737
2197
  * Plaintext representation of an Aleo record
@@ -1739,17 +2199,27 @@ export class RecordCiphertext {
1739
2199
  export class RecordPlaintext {
1740
2200
  private constructor();
1741
2201
  free(): void;
1742
- commitment(program_id: string, record_name: string): Field;
2202
+ commitment(program_id: string, record_name: string, record_view_key: string): Field;
1743
2203
  /**
1744
2204
  * Return a record plaintext from a string.
1745
2205
  *
1746
- * @param {string} record String representation of a plaintext representation of an Aleo record
2206
+ * @param {string} record String representation of a plaintext representation of an Aleo record.
2207
+ *
1747
2208
  * @returns {RecordPlaintext} Record plaintext
1748
2209
  */
1749
2210
  static fromString(record: string): RecordPlaintext;
2211
+ /**
2212
+ * Get the record entry matching a key.
2213
+ *
2214
+ * @param {string} input The key to retrieve the value in the record data field.
2215
+ *
2216
+ * @returns {Plaintext} The plaintext value corresponding to the key.
2217
+ */
1750
2218
  getMember(input: string): Plaintext;
1751
2219
  /**
1752
2220
  * Get the owner of the record.
2221
+ *
2222
+ * @returns {Address} Address of the owner of the record.
1753
2223
  */
1754
2224
  owner(): Address;
1755
2225
  /**
@@ -1852,14 +2322,24 @@ export class RecordPlaintext {
1852
2322
  * @param {PrivateKey} private_key Private key of the account that owns the record
1853
2323
  * @param {string} program_id Program ID of the program that the record is associated with
1854
2324
  * @param {string} record_name Name of the record
2325
+ * @param {string} record_view_key The string representation of the record view key.
1855
2326
  *
1856
2327
  * @returns {string} Serial number of the record
1857
2328
  */
1858
- serialNumberString(private_key: PrivateKey, program_id: string, record_name: string): string;
2329
+ serialNumberString(private_key: PrivateKey, program_id: string, record_name: string, record_view_key: string): string;
1859
2330
  /**
1860
2331
  * Get the tag of the record using the graph key.
1861
2332
  */
1862
2333
  tag(graph_key: GraphKey, commitment: Field): Field;
2334
+ /**
2335
+ * Generate the record view key. The record view key can only decrypt record if the
2336
+ * supplied view key belongs to the record owner.
2337
+ *
2338
+ * @param {ViewKey} view_key View key used to generate the record view key
2339
+ *
2340
+ * @returns {Group} record view key
2341
+ */
2342
+ recordViewKey(view_key: ViewKey): Field;
1863
2343
  }
1864
2344
  /**
1865
2345
  * Scalar field element.
@@ -2163,7 +2643,6 @@ export class Transaction {
2163
2643
  */
2164
2644
  id(): string;
2165
2645
  /**
2166
- * Get the
2167
2646
  * Get the type of the transaction (will return "deploy" or "execute")
2168
2647
  *
2169
2648
  * @returns {string} Transaction type
@@ -2278,20 +2757,38 @@ export class Transition {
2278
2757
  outputs(convert_to_js: boolean): Array<any>;
2279
2758
  /**
2280
2759
  * Get the transition public key of the transition.
2760
+ *
2761
+ * @returns {Group} Transition public key
2281
2762
  */
2282
2763
  tpk(): Group;
2283
2764
  /**
2284
2765
  * Get the transition view key of the transition.
2766
+ *
2767
+ * @param {ViewKey} view_key The view key of the transition signer.
2768
+ *
2769
+ * @returns {Field} Transition view key
2285
2770
  */
2286
2771
  tvk(view_key: ViewKey): Field;
2287
2772
  /**
2288
2773
  * Get the transition commitment of the transition.
2774
+ *
2775
+ * @returns {Field} Transition commitment
2289
2776
  */
2290
2777
  tcm(): Field;
2291
2778
  /**
2292
2779
  * Get the transition signer commitment of the transition.
2780
+ *
2781
+ * @returns {Field} Transition signer commitment
2293
2782
  */
2294
2783
  scm(): Field;
2784
+ /**
2785
+ * Decrypt the transition using the transition view key.
2786
+ *
2787
+ * @param {Field} tvk The transition view key.
2788
+ *
2789
+ * @returns {Transition} The transition with public values for inputs and outputs.
2790
+ */
2791
+ decryptTransition(tvk: Field): Transition;
2295
2792
  }
2296
2793
  /**
2297
2794
  * Verifying key for a function within an Aleo program