@provablehq/wasm 0.9.2 → 0.9.4-offline
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.
- package/dist/mainnet/aleo_wasm.d.ts +514 -16
- package/dist/mainnet/aleo_wasm.wasm +0 -0
- package/dist/mainnet/index.js +1558 -166
- package/dist/mainnet/index.js.map +1 -1
- package/dist/mainnet/worker.js +1562 -165
- package/dist/mainnet/worker.js.map +1 -1
- package/dist/testnet/aleo_wasm.d.ts +514 -16
- package/dist/testnet/aleo_wasm.wasm +0 -0
- package/dist/testnet/index.js +1558 -166
- package/dist/testnet/index.js.map +1 -1
- package/dist/testnet/worker.js +1562 -165
- package/dist/testnet/worker.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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
|
*
|
|
@@ -1468,12 +1848,13 @@ export class ProgramManager {
|
|
|
1468
1848
|
/**
|
|
1469
1849
|
* Synthesize proving and verifying keys for a program
|
|
1470
1850
|
*
|
|
1471
|
-
* @param
|
|
1472
|
-
* @param
|
|
1473
|
-
* @param
|
|
1474
|
-
* @param
|
|
1851
|
+
* @param {string} program The program source code of the program to synthesize keys for
|
|
1852
|
+
* @param {string} function_id The function to synthesize keys for
|
|
1853
|
+
* @param {Array} inputs The inputs to the function
|
|
1854
|
+
* @param {Object | undefined} imports The imports for the program
|
|
1475
1855
|
*/
|
|
1476
1856
|
static synthesizeKeyPair(private_key: PrivateKey, program: string, function_id: string, inputs: Array<any>, imports?: object | null): Promise<KeyPair>;
|
|
1857
|
+
static loadInclusionProver(proving_key: ProvingKey): void;
|
|
1477
1858
|
}
|
|
1478
1859
|
/**
|
|
1479
1860
|
* Proving key for a function within an Aleo program
|
|
@@ -1669,6 +2050,57 @@ export class ProvingKey {
|
|
|
1669
2050
|
*/
|
|
1670
2051
|
toString(): string;
|
|
1671
2052
|
}
|
|
2053
|
+
/**
|
|
2054
|
+
* Represents a proving request to a prover.
|
|
2055
|
+
*/
|
|
2056
|
+
export class ProvingRequest {
|
|
2057
|
+
private constructor();
|
|
2058
|
+
free(): void;
|
|
2059
|
+
/**
|
|
2060
|
+
* Creates a new ProvingRequest from a function Authorization and an optional fee Authorization.
|
|
2061
|
+
*
|
|
2062
|
+
* @param {Authorization} authorization An Authorization for a function.
|
|
2063
|
+
* @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.
|
|
2064
|
+
* @param {boolean} broadcast Flag that indicates whether the remote proving service should attempt to submit the transaction on the caller's behalf.
|
|
2065
|
+
*/
|
|
2066
|
+
static new(authorization: Authorization, fee_authorization: Authorization | null | undefined, broadcast: boolean): ProvingRequest;
|
|
2067
|
+
/**
|
|
2068
|
+
* Creates a ProvingRequest from a string representation.
|
|
2069
|
+
*
|
|
2070
|
+
* @param {Uint8Array} request String representation of the ProvingRequest.
|
|
2071
|
+
*/
|
|
2072
|
+
static fromString(request: string): ProvingRequest;
|
|
2073
|
+
/**
|
|
2074
|
+
* Creates a string representation of the ProvingRequest.
|
|
2075
|
+
*/
|
|
2076
|
+
toString(): string;
|
|
2077
|
+
/**
|
|
2078
|
+
* Creates a ProvingRequest from a left-endian byte representation of the ProvingRequest.
|
|
2079
|
+
*
|
|
2080
|
+
* @param {Uint8Array} bytes Left-endian bytes representing the proving request.
|
|
2081
|
+
*/
|
|
2082
|
+
static fromBytesLe(bytes: Uint8Array): ProvingRequest;
|
|
2083
|
+
/**
|
|
2084
|
+
* Creates a left-endian byte representation of the ProvingRequest.
|
|
2085
|
+
*/
|
|
2086
|
+
toBytesLe(): Uint8Array;
|
|
2087
|
+
/**
|
|
2088
|
+
* Get the Authorization of the main function in the ProvingRequest.
|
|
2089
|
+
*/
|
|
2090
|
+
authorization(): Authorization;
|
|
2091
|
+
/**
|
|
2092
|
+
* Get the fee Authorization in the ProvingRequest.
|
|
2093
|
+
*/
|
|
2094
|
+
feeAuthorization(): Authorization | undefined;
|
|
2095
|
+
/**
|
|
2096
|
+
* Get the broadcast flag set in the ProvingRequest.
|
|
2097
|
+
*/
|
|
2098
|
+
broadcast(): boolean;
|
|
2099
|
+
/**
|
|
2100
|
+
* Check if a ProvingRequest is the same as another ProvingRequest.
|
|
2101
|
+
*/
|
|
2102
|
+
equals(other: ProvingRequest): boolean;
|
|
2103
|
+
}
|
|
1672
2104
|
/**
|
|
1673
2105
|
* Encrypted Aleo record
|
|
1674
2106
|
*/
|
|
@@ -1683,7 +2115,7 @@ export class RecordCiphertext {
|
|
|
1683
2115
|
*/
|
|
1684
2116
|
static fromString(record: string): RecordCiphertext;
|
|
1685
2117
|
/**
|
|
1686
|
-
* Return the string
|
|
2118
|
+
* Return the string representation of the record ciphertext
|
|
1687
2119
|
*
|
|
1688
2120
|
* @returns {string} String representation of the record ciphertext
|
|
1689
2121
|
*/
|
|
@@ -1696,6 +2128,15 @@ export class RecordCiphertext {
|
|
|
1696
2128
|
* @returns {RecordPlaintext} Record plaintext object
|
|
1697
2129
|
*/
|
|
1698
2130
|
decrypt(view_key: ViewKey): RecordPlaintext;
|
|
2131
|
+
/**
|
|
2132
|
+
* Generate the record view key. The record view key can only decrypt record if the
|
|
2133
|
+
* supplied view key belongs to the record owner.
|
|
2134
|
+
*
|
|
2135
|
+
* @param {ViewKey} view_key View key used to generate the record view key
|
|
2136
|
+
*
|
|
2137
|
+
* @returns {Group} record view key
|
|
2138
|
+
*/
|
|
2139
|
+
recordViewKey(view_key: ViewKey): Field;
|
|
1699
2140
|
/**
|
|
1700
2141
|
* Determines if the account corresponding to the view key is the owner of the record
|
|
1701
2142
|
*
|
|
@@ -1722,16 +2163,36 @@ export class RecordCiphertext {
|
|
|
1722
2163
|
static fromBytesLe(bytes: Uint8Array): RecordCiphertext;
|
|
1723
2164
|
/**
|
|
1724
2165
|
* Get the left endian byte array representation of the record ciphertext.
|
|
2166
|
+
*
|
|
2167
|
+
* @returns {Uint8Array} Left endian byte array representation of the record ciphertext.
|
|
1725
2168
|
*/
|
|
1726
2169
|
toBytesLe(): Uint8Array;
|
|
1727
2170
|
/**
|
|
1728
2171
|
* Get the left endian boolean array representation of the record ciphertext bits.
|
|
2172
|
+
*
|
|
2173
|
+
* returns {Array} Left endian boolean array representation of the bits of the record ciphertext.
|
|
1729
2174
|
*/
|
|
1730
2175
|
toBitsLe(): Array<any>;
|
|
1731
2176
|
/**
|
|
1732
2177
|
* Get the field array representation of the record ciphertext.
|
|
2178
|
+
*
|
|
2179
|
+
* @returns {Array} Field array representation of the record ciphertext.
|
|
1733
2180
|
*/
|
|
1734
2181
|
toFields(): Array<any>;
|
|
2182
|
+
/**
|
|
2183
|
+
* Decrypt the record ciphertext into plaintext using a record view key.
|
|
2184
|
+
*
|
|
2185
|
+
* @param {Field} record_vk Record view key used to decrypt the record.
|
|
2186
|
+
*
|
|
2187
|
+
* @returns {RecordPlaintext}
|
|
2188
|
+
*/
|
|
2189
|
+
decryptWithRecordViewKey(record_vk: Field): RecordPlaintext;
|
|
2190
|
+
/**
|
|
2191
|
+
* Get the record nonce.
|
|
2192
|
+
*
|
|
2193
|
+
* @returns {Group} The record nonce.
|
|
2194
|
+
*/
|
|
2195
|
+
nonce(): Group;
|
|
1735
2196
|
}
|
|
1736
2197
|
/**
|
|
1737
2198
|
* Plaintext representation of an Aleo record
|
|
@@ -1739,17 +2200,27 @@ export class RecordCiphertext {
|
|
|
1739
2200
|
export class RecordPlaintext {
|
|
1740
2201
|
private constructor();
|
|
1741
2202
|
free(): void;
|
|
1742
|
-
commitment(program_id: string, record_name: string): Field;
|
|
2203
|
+
commitment(program_id: string, record_name: string, record_view_key: string): Field;
|
|
1743
2204
|
/**
|
|
1744
2205
|
* Return a record plaintext from a string.
|
|
1745
2206
|
*
|
|
1746
|
-
* @param {string} record String representation of a plaintext representation of an Aleo record
|
|
2207
|
+
* @param {string} record String representation of a plaintext representation of an Aleo record.
|
|
2208
|
+
*
|
|
1747
2209
|
* @returns {RecordPlaintext} Record plaintext
|
|
1748
2210
|
*/
|
|
1749
2211
|
static fromString(record: string): RecordPlaintext;
|
|
2212
|
+
/**
|
|
2213
|
+
* Get the record entry matching a key.
|
|
2214
|
+
*
|
|
2215
|
+
* @param {string} input The key to retrieve the value in the record data field.
|
|
2216
|
+
*
|
|
2217
|
+
* @returns {Plaintext} The plaintext value corresponding to the key.
|
|
2218
|
+
*/
|
|
1750
2219
|
getMember(input: string): Plaintext;
|
|
1751
2220
|
/**
|
|
1752
2221
|
* Get the owner of the record.
|
|
2222
|
+
*
|
|
2223
|
+
* @returns {Address} Address of the owner of the record.
|
|
1753
2224
|
*/
|
|
1754
2225
|
owner(): Address;
|
|
1755
2226
|
/**
|
|
@@ -1852,14 +2323,24 @@ export class RecordPlaintext {
|
|
|
1852
2323
|
* @param {PrivateKey} private_key Private key of the account that owns the record
|
|
1853
2324
|
* @param {string} program_id Program ID of the program that the record is associated with
|
|
1854
2325
|
* @param {string} record_name Name of the record
|
|
2326
|
+
* @param {string} record_view_key The string representation of the record view key.
|
|
1855
2327
|
*
|
|
1856
2328
|
* @returns {string} Serial number of the record
|
|
1857
2329
|
*/
|
|
1858
|
-
serialNumberString(private_key: PrivateKey, program_id: string, record_name: string): string;
|
|
2330
|
+
serialNumberString(private_key: PrivateKey, program_id: string, record_name: string, record_view_key: string): string;
|
|
1859
2331
|
/**
|
|
1860
2332
|
* Get the tag of the record using the graph key.
|
|
1861
2333
|
*/
|
|
1862
2334
|
tag(graph_key: GraphKey, commitment: Field): Field;
|
|
2335
|
+
/**
|
|
2336
|
+
* Generate the record view key. The record view key can only decrypt record if the
|
|
2337
|
+
* supplied view key belongs to the record owner.
|
|
2338
|
+
*
|
|
2339
|
+
* @param {ViewKey} view_key View key used to generate the record view key
|
|
2340
|
+
*
|
|
2341
|
+
* @returns {Group} record view key
|
|
2342
|
+
*/
|
|
2343
|
+
recordViewKey(view_key: ViewKey): Field;
|
|
1863
2344
|
}
|
|
1864
2345
|
/**
|
|
1865
2346
|
* Scalar field element.
|
|
@@ -2163,7 +2644,6 @@ export class Transaction {
|
|
|
2163
2644
|
*/
|
|
2164
2645
|
id(): string;
|
|
2165
2646
|
/**
|
|
2166
|
-
* Get the
|
|
2167
2647
|
* Get the type of the transaction (will return "deploy" or "execute")
|
|
2168
2648
|
*
|
|
2169
2649
|
* @returns {string} Transaction type
|
|
@@ -2278,20 +2758,38 @@ export class Transition {
|
|
|
2278
2758
|
outputs(convert_to_js: boolean): Array<any>;
|
|
2279
2759
|
/**
|
|
2280
2760
|
* Get the transition public key of the transition.
|
|
2761
|
+
*
|
|
2762
|
+
* @returns {Group} Transition public key
|
|
2281
2763
|
*/
|
|
2282
2764
|
tpk(): Group;
|
|
2283
2765
|
/**
|
|
2284
2766
|
* Get the transition view key of the transition.
|
|
2767
|
+
*
|
|
2768
|
+
* @param {ViewKey} view_key The view key of the transition signer.
|
|
2769
|
+
*
|
|
2770
|
+
* @returns {Field} Transition view key
|
|
2285
2771
|
*/
|
|
2286
2772
|
tvk(view_key: ViewKey): Field;
|
|
2287
2773
|
/**
|
|
2288
2774
|
* Get the transition commitment of the transition.
|
|
2775
|
+
*
|
|
2776
|
+
* @returns {Field} Transition commitment
|
|
2289
2777
|
*/
|
|
2290
2778
|
tcm(): Field;
|
|
2291
2779
|
/**
|
|
2292
2780
|
* Get the transition signer commitment of the transition.
|
|
2781
|
+
*
|
|
2782
|
+
* @returns {Field} Transition signer commitment
|
|
2293
2783
|
*/
|
|
2294
2784
|
scm(): Field;
|
|
2785
|
+
/**
|
|
2786
|
+
* Decrypt the transition using the transition view key.
|
|
2787
|
+
*
|
|
2788
|
+
* @param {Field} tvk The transition view key.
|
|
2789
|
+
*
|
|
2790
|
+
* @returns {Transition} The transition with public values for inputs and outputs.
|
|
2791
|
+
*/
|
|
2792
|
+
decryptTransition(tvk: Field): Transition;
|
|
2295
2793
|
}
|
|
2296
2794
|
/**
|
|
2297
2795
|
* Verifying key for a function within an Aleo program
|