@provablehq/wasm 0.9.1 → 0.9.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.
@@ -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
  /**
@@ -228,8 +309,6 @@ export class BHP768 {
228
309
  * SnarkVM Ciphertext object. A Ciphertext represents an symmetrically encrypted plaintext. This
229
310
  * object provides decryption methods to recover the plaintext from the ciphertext (given the
230
311
  * api consumer has the proper decryption materials).
231
- *
232
- * @example
233
312
  */
234
313
  export class Ciphertext {
235
314
  private constructor();
@@ -353,6 +432,28 @@ export class ComputeKey {
353
432
  */
354
433
  pr_sig(): Group;
355
434
  }
435
+ export class EncryptionToolkit {
436
+ private constructor();
437
+ free(): void;
438
+ /**
439
+ * Generates a transition view key from the view key and the transition public key.
440
+ */
441
+ static generateTvk(view_key: ViewKey, tpk: Group): Field;
442
+ /**
443
+ * Creates a record view key from the view key. This can be later be used to decrypt a
444
+ */
445
+ static generateRecordViewKey(view_key: ViewKey, record_ciphertext: RecordCiphertext): Field;
446
+ /**
447
+ * Decrypts a record ciphertext using the record view key. Decryption only succeeds
448
+ * if the record view key was generated from the view key of the record owner.
449
+ */
450
+ static decryptRecordWithRVk(record_vk: Field, record_ciphertext: RecordCiphertext): RecordPlaintext;
451
+ /**
452
+ * Decrypts a transition using the transition view key. The ciphertext inputs and outputs
453
+ * can only be decrypted if the transition view key was generated by the transaction signer.
454
+ */
455
+ static decryptTransitionWithVk(transition: Transition, transition_vk: Field): Transition;
456
+ }
356
457
  /**
357
458
  * Execution of an Aleo program.
358
459
  */
@@ -390,6 +491,93 @@ export class Execution {
390
491
  */
391
492
  transitions(): Array<any>;
392
493
  }
494
+ export class ExecutionRequest {
495
+ private constructor();
496
+ free(): void;
497
+ /**
498
+ * Returns the request as a string.
499
+ */
500
+ toString(): string;
501
+ /**
502
+ * Builds a request object from a string representation of a request.
503
+ */
504
+ static fromString(request: string): ExecutionRequest;
505
+ /**
506
+ * Returns the bytes representation of the request.
507
+ */
508
+ toBytesLe(): Uint8Array;
509
+ /**
510
+ * Creates an request object from a bytes representation of an request.
511
+ */
512
+ static fromBytesLe(bytes: Uint8Array): ExecutionRequest;
513
+ /**
514
+ * Returns the request signer.
515
+ */
516
+ signer(): Address;
517
+ /**
518
+ * Returns the network ID.
519
+ */
520
+ network_id(): number;
521
+ /**
522
+ * Returns the program ID.
523
+ */
524
+ program_id(): string;
525
+ /**
526
+ * Returns the function name.
527
+ */
528
+ function_name(): string;
529
+ /**
530
+ * Returns the input IDs for the transition.
531
+ */
532
+ input_ids(): Array<any>;
533
+ /**
534
+ * Returns the function inputs as an array of strings.
535
+ */
536
+ inputs(): Array<any>;
537
+ /**
538
+ * Returns the signature for the transition.
539
+ */
540
+ signature(): Signature;
541
+ /**
542
+ * Returns the tag secret key `sk_tag`.
543
+ */
544
+ sk_tag(): Field;
545
+ /**
546
+ * Returns the transition view key `tvk`.
547
+ */
548
+ tvk(): Field;
549
+ /**
550
+ * Returns the transition public key `tpk`.
551
+ */
552
+ to_tpk(): Group;
553
+ /**
554
+ * Returns the transition commitment `tcm`.
555
+ */
556
+ tcm(): Field;
557
+ /**
558
+ * Returns the signer commitment `scm`.
559
+ */
560
+ scm(): Field;
561
+ /**
562
+ * Create a new request by signing over a program ID and set of inputs.
563
+ *
564
+ * @param {PrivateKey} private_key The private key of the signer.
565
+ * @param {string} program_id The id of the program to create the signature for.
566
+ * @param {string} function_name The function name to create the signature for.
567
+ * @param {string[]} inputs The inputs to the function.
568
+ * @param {string[]} input_types The input types of the function.
569
+ * @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.
570
+ * @param {boolean} is_root Flag to indicate if this is the top level function in the call graph.
571
+ */
572
+ 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;
573
+ /**
574
+ * Verify the input types within a request.
575
+ *
576
+ * @param {string[]} The input_types within the request.
577
+ * @param {boolean} Flag to indicate whether this request is the first function in the call graph.
578
+ */
579
+ verify(input_types: Array<any>, is_root: boolean): boolean;
580
+ }
393
581
  /**
394
582
  * Webassembly Representation of an Aleo function execution response
395
583
  *
@@ -1297,6 +1485,29 @@ export class Program {
1297
1485
  export class ProgramManager {
1298
1486
  private constructor();
1299
1487
  free(): void;
1488
+ /**
1489
+ * Create an execution `Authorization` for a given program:function tuple with specified inputs.
1490
+ *
1491
+ * @param private_key The private key of the signer.
1492
+ * @param program The program source code containing the function to authorize.
1493
+ * @param function_name The function to authorize.
1494
+ * @param inputs A javascript array of inputs to the function.
1495
+ * @param imports The imports to the program in the format {"programname.aleo":"aleo instructions source code"}.
1496
+ */
1497
+ static authorize(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, imports?: object | null): Promise<Authorization>;
1498
+ /**
1499
+ * Create an `Authorization` for `credits.aleo/fee_public` or `credits.aleo/fee_private`.
1500
+ * This object requires an associated execution or deployment ID. This can be gained from
1501
+ * any previously created authorization by calling (authorization.toExecutionId()).
1502
+ *
1503
+ * @param private_key The private key of the signer.
1504
+ * @param deployment_or_execution_id The id of the deployment or execution to authorize the fee program for.
1505
+ * @param base_fee_credits The base fee to be paid for the authorization
1506
+ * @param priority_fee_credits The optional priority fee to be paid for the transaction
1507
+ * @param fee_record The record to spend the fee from
1508
+ * @returns {Authorization}
1509
+ */
1510
+ 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
1511
  /**
1301
1512
  * Deploy an Aleo program
1302
1513
  *
@@ -1683,7 +1894,7 @@ export class RecordCiphertext {
1683
1894
  */
1684
1895
  static fromString(record: string): RecordCiphertext;
1685
1896
  /**
1686
- * Return the string reprensentation of the record ciphertext
1897
+ * Return the string representation of the record ciphertext
1687
1898
  *
1688
1899
  * @returns {string} String representation of the record ciphertext
1689
1900
  */
@@ -1696,6 +1907,15 @@ export class RecordCiphertext {
1696
1907
  * @returns {RecordPlaintext} Record plaintext object
1697
1908
  */
1698
1909
  decrypt(view_key: ViewKey): RecordPlaintext;
1910
+ /**
1911
+ * Generate the record view key. The record view key can only decrypt record if the
1912
+ * supplied view key belongs to the record owner.
1913
+ *
1914
+ * @param {ViewKey} view_key View key used to generate the record view key
1915
+ *
1916
+ * @returns {Group} record view key
1917
+ */
1918
+ recordViewKey(view_key: ViewKey): Field;
1699
1919
  /**
1700
1920
  * Determines if the account corresponding to the view key is the owner of the record
1701
1921
  *
@@ -1732,6 +1952,18 @@ export class RecordCiphertext {
1732
1952
  * Get the field array representation of the record ciphertext.
1733
1953
  */
1734
1954
  toFields(): Array<any>;
1955
+ /**
1956
+ * Decrypt the record ciphertext into plaintext using a record view key.
1957
+ *
1958
+ * @param {Field} record_vk Record view key used to decrypt the record.
1959
+ *
1960
+ * @returns {RecordPlaintext}
1961
+ */
1962
+ decryptWithRecordViewKey(record_vk: Field): RecordPlaintext;
1963
+ /**
1964
+ * Get the record nonce.
1965
+ */
1966
+ nonce(): Group;
1735
1967
  }
1736
1968
  /**
1737
1969
  * Plaintext representation of an Aleo record
@@ -2163,7 +2395,6 @@ export class Transaction {
2163
2395
  */
2164
2396
  id(): string;
2165
2397
  /**
2166
- * Get the
2167
2398
  * Get the type of the transaction (will return "deploy" or "execute")
2168
2399
  *
2169
2400
  * @returns {string} Transaction type
@@ -2292,6 +2523,14 @@ export class Transition {
2292
2523
  * Get the transition signer commitment of the transition.
2293
2524
  */
2294
2525
  scm(): Field;
2526
+ /**
2527
+ * Decrypt the transition using the transition view key.
2528
+ *
2529
+ * @param {Field} tvk The transition view key.
2530
+ *
2531
+ * @returns {Transition} The transition with public values for inputs and outputs.
2532
+ */
2533
+ decryptTransition(tvk: Field): Transition;
2295
2534
  }
2296
2535
  /**
2297
2536
  * Verifying key for a function within an Aleo program
Binary file
@@ -5,4 +5,4 @@
5
5
  */
6
6
  export function initThreadPool(threads?: number): Promise<void>;
7
7
 
8
- export * from "./aleo_wasm";
8
+ export * from "./aleo_wasm.js";