@provablehq/wasm 0.6.13 → 0.7.1

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.
@@ -0,0 +1,1692 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Verify an execution with a single function and a single transition. Executions with multiple
5
+ * transitions or functions will fail to verify. Also, this does not verify that the state root of
6
+ * the execution is included in the Aleo Network ledger.
7
+ *
8
+ * @param {Execution} execution The function execution to verify
9
+ * @param {VerifyingKey} verifying_key The verifying key for the function
10
+ * @param {Program} program The program that the function execution belongs to
11
+ * @param {String} function_id The name of the function that was executed
12
+ * @returns {boolean} True if the execution is valid, false otherwise
13
+ * @param {Execution} execution
14
+ * @param {VerifyingKey} verifying_key
15
+ * @param {Program} program
16
+ * @param {string} function_id
17
+ * @returns {boolean}
18
+ */
19
+ export function verifyFunctionExecution(execution: Execution, verifying_key: VerifyingKey, program: Program, function_id: string): boolean;
20
+ /**
21
+ * @param {number} receiver
22
+ */
23
+ export function runRayonThread(receiver: number): void;
24
+ /**
25
+ * @param {URL} url
26
+ * @param {number} num_threads
27
+ * @returns {Promise<void>}
28
+ */
29
+ export function initThreadPool(url: URL, num_threads: number): Promise<void>;
30
+ /**
31
+ * Public address of an Aleo account
32
+ */
33
+ export class Address {
34
+ free(): void;
35
+ /**
36
+ * Derive an Aleo address from a private key
37
+ *
38
+ * @param {PrivateKey} private_key The private key to derive the address from
39
+ * @returns {Address} Address corresponding to the private key
40
+ * @param {PrivateKey} private_key
41
+ * @returns {Address}
42
+ */
43
+ static from_private_key(private_key: PrivateKey): Address;
44
+ /**
45
+ * Derive an Aleo address from a view key
46
+ *
47
+ * @param {ViewKey} view_key The view key to derive the address from
48
+ * @returns {Address} Address corresponding to the view key
49
+ * @param {ViewKey} view_key
50
+ * @returns {Address}
51
+ */
52
+ static from_view_key(view_key: ViewKey): Address;
53
+ /**
54
+ * Create an aleo address object from a string representation of an address
55
+ *
56
+ * @param {string} address String representation of an addressm
57
+ * @returns {Address} Address
58
+ * @param {string} address
59
+ * @returns {Address}
60
+ */
61
+ static from_string(address: string): Address;
62
+ /**
63
+ * Get a string representation of an Aleo address object
64
+ *
65
+ * @param {Address} Address
66
+ * @returns {string} String representation of the address
67
+ * @returns {string}
68
+ */
69
+ to_string(): string;
70
+ /**
71
+ * Verify a signature for a message signed by the address
72
+ *
73
+ * @param {Uint8Array} Byte array representing a message signed by the address
74
+ * @returns {boolean} Boolean representing whether or not the signature is valid
75
+ * @param {Uint8Array} message
76
+ * @param {Signature} signature
77
+ * @returns {boolean}
78
+ */
79
+ verify(message: Uint8Array, signature: Signature): boolean;
80
+ }
81
+ /**
82
+ * Execution of an Aleo program.
83
+ */
84
+ export class Execution {
85
+ free(): void;
86
+ /**
87
+ * Returns the string representation of the execution.
88
+ * @returns {string}
89
+ */
90
+ toString(): string;
91
+ /**
92
+ * Creates an execution object from a string representation of an execution.
93
+ * @param {string} execution
94
+ * @returns {Execution}
95
+ */
96
+ static fromString(execution: string): Execution;
97
+ }
98
+ /**
99
+ * Webassembly Representation of an Aleo function execution response
100
+ *
101
+ * This object is returned by the execution of an Aleo function off-chain. It provides methods for
102
+ * retrieving the outputs of the function execution.
103
+ */
104
+ export class ExecutionResponse {
105
+ free(): void;
106
+ /**
107
+ * Get the outputs of the executed function
108
+ *
109
+ * @returns {Array} Array of strings representing the outputs of the function
110
+ * @returns {Array<any>}
111
+ */
112
+ getOutputs(): Array<any>;
113
+ /**
114
+ * Returns the execution object if present, null if otherwise.
115
+ *
116
+ * @returns {Execution | undefined} The execution object if present, null if otherwise
117
+ * @returns {Execution | undefined}
118
+ */
119
+ getExecution(): Execution | undefined;
120
+ /**
121
+ * Returns the program keys if present
122
+ * @returns {KeyPair}
123
+ */
124
+ getKeys(): KeyPair;
125
+ /**
126
+ * Returns the proving_key if the proving key was cached in the Execution response.
127
+ * Note the proving key is removed from the response object after the first call to this
128
+ * function. Subsequent calls will return null.
129
+ *
130
+ * @returns {ProvingKey | undefined} The proving key
131
+ * @returns {ProvingKey | undefined}
132
+ */
133
+ getProvingKey(): ProvingKey | undefined;
134
+ /**
135
+ * Returns the verifying_key associated with the program
136
+ *
137
+ * @returns {VerifyingKey} The verifying key
138
+ * @returns {VerifyingKey}
139
+ */
140
+ getVerifyingKey(): VerifyingKey;
141
+ /**
142
+ * Returns the function identifier
143
+ * @returns {string}
144
+ */
145
+ getFunctionId(): string;
146
+ /**
147
+ * Returns the program
148
+ * @returns {Program}
149
+ */
150
+ getProgram(): Program;
151
+ }
152
+ /**
153
+ */
154
+ export class Field {
155
+ free(): void;
156
+ /**
157
+ * @returns {string}
158
+ */
159
+ toString(): string;
160
+ /**
161
+ * @param {string} field
162
+ * @returns {Field}
163
+ */
164
+ static fromString(field: string): Field;
165
+ }
166
+ /**
167
+ * Key pair object containing both the function proving and verifying keys
168
+ */
169
+ export class KeyPair {
170
+ free(): void;
171
+ /**
172
+ * Create new key pair from proving and verifying keys
173
+ *
174
+ * @param {ProvingKey} proving_key Proving key corresponding to a function in an Aleo program
175
+ * @param {VerifyingKey} verifying_key Verifying key corresponding to a function in an Aleo program
176
+ * @returns {KeyPair} Key pair object containing both the function proving and verifying keys
177
+ * @param {ProvingKey} proving_key
178
+ * @param {VerifyingKey} verifying_key
179
+ */
180
+ constructor(proving_key: ProvingKey, verifying_key: VerifyingKey);
181
+ /**
182
+ * Get the proving key. This method will remove the proving key from the key pair
183
+ *
184
+ * @returns {ProvingKey}
185
+ * @returns {ProvingKey}
186
+ */
187
+ provingKey(): ProvingKey;
188
+ /**
189
+ * Get the verifying key. This method will remove the verifying key from the key pair
190
+ *
191
+ * @returns {VerifyingKey}
192
+ * @returns {VerifyingKey}
193
+ */
194
+ verifyingKey(): VerifyingKey;
195
+ }
196
+ /**
197
+ */
198
+ export class Metadata {
199
+ free(): void;
200
+ /**
201
+ * @returns {string}
202
+ */
203
+ static baseUrl(): string;
204
+ /**
205
+ * @returns {Metadata}
206
+ */
207
+ static bond_public(): Metadata;
208
+ /**
209
+ * @returns {Metadata}
210
+ */
211
+ static bond_validator(): Metadata;
212
+ /**
213
+ * @returns {Metadata}
214
+ */
215
+ static claim_unbond_public(): Metadata;
216
+ /**
217
+ * @returns {Metadata}
218
+ */
219
+ static fee_private(): Metadata;
220
+ /**
221
+ * @returns {Metadata}
222
+ */
223
+ static fee_public(): Metadata;
224
+ /**
225
+ * @returns {Metadata}
226
+ */
227
+ static inclusion(): Metadata;
228
+ /**
229
+ * @returns {Metadata}
230
+ */
231
+ static join(): Metadata;
232
+ /**
233
+ * @returns {Metadata}
234
+ */
235
+ static set_validator_state(): Metadata;
236
+ /**
237
+ * @returns {Metadata}
238
+ */
239
+ static split(): Metadata;
240
+ /**
241
+ * @returns {Metadata}
242
+ */
243
+ static transfer_private(): Metadata;
244
+ /**
245
+ * @returns {Metadata}
246
+ */
247
+ static transfer_private_to_public(): Metadata;
248
+ /**
249
+ * @returns {Metadata}
250
+ */
251
+ static transfer_public(): Metadata;
252
+ /**
253
+ * @returns {Metadata}
254
+ */
255
+ static transfer_public_as_signer(): Metadata;
256
+ /**
257
+ * @returns {Metadata}
258
+ */
259
+ static transfer_public_to_private(): Metadata;
260
+ /**
261
+ * @returns {Metadata}
262
+ */
263
+ static unbond_public(): Metadata;
264
+ /**
265
+ */
266
+ locator: string;
267
+ /**
268
+ */
269
+ name: string;
270
+ /**
271
+ */
272
+ prover: string;
273
+ /**
274
+ */
275
+ verifier: string;
276
+ /**
277
+ */
278
+ verifyingKey: string;
279
+ }
280
+ /**
281
+ * An offline query object used to insert the global state root and state paths needed to create
282
+ * a valid inclusion proof offline.
283
+ */
284
+ export class OfflineQuery {
285
+ free(): void;
286
+ /**
287
+ * Creates a new offline query object. The state root is required to be passed in as a string
288
+ * @param {number} block_height
289
+ * @param {string} state_root
290
+ */
291
+ constructor(block_height: number, state_root: string);
292
+ /**
293
+ * Add a new block height to the offline query object.
294
+ * @param {number} block_height
295
+ */
296
+ addBlockHeight(block_height: number): void;
297
+ /**
298
+ * Add a new state path to the offline query object.
299
+ *
300
+ * @param {string} commitment: The commitment corresponding to a record inpout
301
+ * @param {string} state_path: The state path corresponding to the commitment
302
+ * @param {string} commitment
303
+ * @param {string} state_path
304
+ */
305
+ addStatePath(commitment: string, state_path: string): void;
306
+ /**
307
+ * Get a json string representation of the offline query object
308
+ * @returns {string}
309
+ */
310
+ toString(): string;
311
+ /**
312
+ * Create an offline query object from a json string representation
313
+ * @param {string} s
314
+ * @returns {OfflineQuery}
315
+ */
316
+ static fromString(s: string): OfflineQuery;
317
+ }
318
+ /**
319
+ * Private key of an Aleo account
320
+ */
321
+ export class PrivateKey {
322
+ free(): void;
323
+ /**
324
+ * Generate a new private key using a cryptographically secure random number generator
325
+ *
326
+ * @returns {PrivateKey}
327
+ */
328
+ constructor();
329
+ /**
330
+ * Get a private key from a series of unchecked bytes
331
+ *
332
+ * @param {Uint8Array} seed Unchecked 32 byte long Uint8Array acting as the seed for the private key
333
+ * @returns {PrivateKey}
334
+ * @param {Uint8Array} seed
335
+ * @returns {PrivateKey}
336
+ */
337
+ static from_seed_unchecked(seed: Uint8Array): PrivateKey;
338
+ /**
339
+ * Get a private key from a string representation of a private key
340
+ *
341
+ * @param {string} seed String representation of a private key
342
+ * @returns {PrivateKey}
343
+ * @param {string} private_key
344
+ * @returns {PrivateKey}
345
+ */
346
+ static from_string(private_key: string): PrivateKey;
347
+ /**
348
+ * Get a string representation of the private key. This function should be used very carefully
349
+ * as it exposes the private key plaintext
350
+ *
351
+ * @returns {string} String representation of a private key
352
+ * @returns {string}
353
+ */
354
+ to_string(): string;
355
+ /**
356
+ * Get the view key corresponding to the private key
357
+ *
358
+ * @returns {ViewKey}
359
+ * @returns {ViewKey}
360
+ */
361
+ to_view_key(): ViewKey;
362
+ /**
363
+ * Get the address corresponding to the private key
364
+ *
365
+ * @returns {Address}
366
+ * @returns {Address}
367
+ */
368
+ to_address(): Address;
369
+ /**
370
+ * Sign a message with the private key
371
+ *
372
+ * @param {Uint8Array} Byte array representing a message signed by the address
373
+ * @returns {Signature} Signature generated by signing the message with the address
374
+ * @param {Uint8Array} message
375
+ * @returns {Signature}
376
+ */
377
+ sign(message: Uint8Array): Signature;
378
+ /**
379
+ * Get a new randomly generated private key ciphertext using a secret. The secret is sensitive
380
+ * and will be needed to decrypt the private key later, so it should be stored securely
381
+ *
382
+ * @param {string} secret Secret used to encrypt the private key
383
+ * @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
384
+ * @param {string} secret
385
+ * @returns {PrivateKeyCiphertext}
386
+ */
387
+ static newEncrypted(secret: string): PrivateKeyCiphertext;
388
+ /**
389
+ * Encrypt an existing private key with a secret. The secret is sensitive and will be needed to
390
+ * decrypt the private key later, so it should be stored securely
391
+ *
392
+ * @param {string} secret Secret used to encrypt the private key
393
+ * @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
394
+ * @param {string} secret
395
+ * @returns {PrivateKeyCiphertext}
396
+ */
397
+ toCiphertext(secret: string): PrivateKeyCiphertext;
398
+ /**
399
+ * Get private key from a private key ciphertext and secret originally used to encrypt it
400
+ *
401
+ * @param {PrivateKeyCiphertext} ciphertext Ciphertext representation of the private key
402
+ * @param {string} secret Secret originally used to encrypt the private key
403
+ * @returns {PrivateKey} Private key
404
+ * @param {PrivateKeyCiphertext} ciphertext
405
+ * @param {string} secret
406
+ * @returns {PrivateKey}
407
+ */
408
+ static fromPrivateKeyCiphertext(ciphertext: PrivateKeyCiphertext, secret: string): PrivateKey;
409
+ }
410
+ /**
411
+ * Private Key in ciphertext form
412
+ */
413
+ export class PrivateKeyCiphertext {
414
+ free(): void;
415
+ /**
416
+ * Encrypt a private key using a secret string. The secret is sensitive and will be needed to
417
+ * decrypt the private key later, so it should be stored securely
418
+ *
419
+ * @param {PrivateKey} private_key Private key to encrypt
420
+ * @param {string} secret Secret to encrypt the private key with
421
+ * @returns {PrivateKeyCiphertext} Private key ciphertext
422
+ * @param {PrivateKey} private_key
423
+ * @param {string} secret
424
+ * @returns {PrivateKeyCiphertext}
425
+ */
426
+ static encryptPrivateKey(private_key: PrivateKey, secret: string): PrivateKeyCiphertext;
427
+ /**
428
+ * Decrypts a private ciphertext using a secret string. This must be the same secret used to
429
+ * encrypt the private key
430
+ *
431
+ * @param {string} secret Secret used to encrypt the private key
432
+ * @returns {PrivateKey} Private key
433
+ * @param {string} secret
434
+ * @returns {PrivateKey}
435
+ */
436
+ decryptToPrivateKey(secret: string): PrivateKey;
437
+ /**
438
+ * Returns the ciphertext string
439
+ *
440
+ * @returns {string} Ciphertext string
441
+ * @returns {string}
442
+ */
443
+ toString(): string;
444
+ /**
445
+ * Creates a PrivateKeyCiphertext from a string
446
+ *
447
+ * @param {string} ciphertext Ciphertext string
448
+ * @returns {PrivateKeyCiphertext} Private key ciphertext
449
+ * @param {string} ciphertext
450
+ * @returns {PrivateKeyCiphertext}
451
+ */
452
+ static fromString(ciphertext: string): PrivateKeyCiphertext;
453
+ }
454
+ /**
455
+ * Webassembly Representation of an Aleo program
456
+ */
457
+ export class Program {
458
+ free(): void;
459
+ /**
460
+ * Create a program from a program string
461
+ *
462
+ * @param {string} program Aleo program source code
463
+ * @returns {Program} Program object
464
+ * @param {string} program
465
+ * @returns {Program}
466
+ */
467
+ static fromString(program: string): Program;
468
+ /**
469
+ * Get a string representation of the program
470
+ *
471
+ * @returns {string} String containing the program source code
472
+ * @returns {string}
473
+ */
474
+ toString(): string;
475
+ /**
476
+ * Determine if a function is present in the program
477
+ *
478
+ * @param {string} functionName Name of the function to check for
479
+ * @returns {boolean} True if the program is valid, false otherwise
480
+ * @param {string} function_name
481
+ * @returns {boolean}
482
+ */
483
+ hasFunction(function_name: string): boolean;
484
+ /**
485
+ * Get javascript array of functions names in the program
486
+ *
487
+ * @returns {Array} Array of all function names present in the program
488
+ *
489
+ * @example
490
+ * const expected_functions = [
491
+ * "mint",
492
+ * "transfer_private",
493
+ * "transfer_private_to_public",
494
+ * "transfer_public",
495
+ * "transfer_public_to_private",
496
+ * "join",
497
+ * "split",
498
+ * "fee"
499
+ * ]
500
+ *
501
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
502
+ * const credits_functions = credits_program.getFunctions();
503
+ * console.log(credits_functions === expected_functions); // Output should be "true"
504
+ * @returns {Array<any>}
505
+ */
506
+ getFunctions(): Array<any>;
507
+ /**
508
+ * Get a javascript object representation of the function inputs and types. This can be used
509
+ * to generate a web form to capture user inputs for an execution of a function.
510
+ *
511
+ * @param {string} function_name Name of the function to get inputs for
512
+ * @returns {Array} Array of function inputs
513
+ *
514
+ * @example
515
+ * const expected_inputs = [
516
+ * {
517
+ * type:"record",
518
+ * visibility:"private",
519
+ * record:"credits",
520
+ * members:[
521
+ * {
522
+ * name:"microcredits",
523
+ * type:"u64",
524
+ * visibility:"private"
525
+ * }
526
+ * ],
527
+ * register:"r0"
528
+ * },
529
+ * {
530
+ * type:"address",
531
+ * visibility:"private",
532
+ * register:"r1"
533
+ * },
534
+ * {
535
+ * type:"u64",
536
+ * visibility:"private",
537
+ * register:"r2"
538
+ * }
539
+ * ];
540
+ *
541
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
542
+ * const transfer_function_inputs = credits_program.getFunctionInputs("transfer_private");
543
+ * console.log(transfer_function_inputs === expected_inputs); // Output should be "true"
544
+ * @param {string} function_name
545
+ * @returns {Array<any>}
546
+ */
547
+ getFunctionInputs(function_name: string): Array<any>;
548
+ /**
549
+ * Get a the list of a program's mappings and the names/types of their keys and values.
550
+ *
551
+ * @returns {Array} - An array of objects representing the mappings in the program
552
+ * @example
553
+ * const expected_mappings = [
554
+ * {
555
+ * name: "account",
556
+ * key_name: "owner",
557
+ * key_type: "address",
558
+ * value_name: "microcredits",
559
+ * value_type: "u64"
560
+ * }
561
+ * ]
562
+ *
563
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
564
+ * const credits_mappings = credits_program.getMappings();
565
+ * console.log(credits_mappings === expected_mappings); // Output should be "true"
566
+ * @returns {Array<any>}
567
+ */
568
+ getMappings(): Array<any>;
569
+ /**
570
+ * Get a javascript object representation of a program record and its types
571
+ *
572
+ * @param {string} record_name Name of the record to get members for
573
+ * @returns {Object} Object containing the record name, type, and members
574
+ *
575
+ * @example
576
+ *
577
+ * const expected_record = {
578
+ * type: "record",
579
+ * record: "Credits",
580
+ * members: [
581
+ * {
582
+ * name: "owner",
583
+ * type: "address",
584
+ * visibility: "private"
585
+ * },
586
+ * {
587
+ * name: "microcredits",
588
+ * type: "u64",
589
+ * visibility: "private"
590
+ * }
591
+ * ];
592
+ * };
593
+ *
594
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
595
+ * const credits_record = credits_program.getRecordMembers("Credits");
596
+ * console.log(credits_record === expected_record); // Output should be "true"
597
+ * @param {string} record_name
598
+ * @returns {object}
599
+ */
600
+ getRecordMembers(record_name: string): object;
601
+ /**
602
+ * Get a javascript object representation of a program struct and its types
603
+ *
604
+ * @param {string} struct_name Name of the struct to get members for
605
+ * @returns {Array} Array containing the struct members
606
+ *
607
+ * @example
608
+ *
609
+ * const STRUCT_PROGRAM = "program token_issue.aleo;
610
+ *
611
+ * struct token_metadata:
612
+ * network as u32;
613
+ * version as u32;
614
+ *
615
+ * struct token:
616
+ * token_id as u32;
617
+ * metadata as token_metadata;
618
+ *
619
+ * function no_op:
620
+ * input r0 as u64;
621
+ * output r0 as u64;"
622
+ *
623
+ * const expected_struct_members = [
624
+ * {
625
+ * name: "token_id",
626
+ * type: "u32",
627
+ * },
628
+ * {
629
+ * name: "metadata",
630
+ * type: "struct",
631
+ * struct_id: "token_metadata",
632
+ * members: [
633
+ * {
634
+ * name: "network",
635
+ * type: "u32",
636
+ * }
637
+ * {
638
+ * name: "version",
639
+ * type: "u32",
640
+ * }
641
+ * ]
642
+ * }
643
+ * ];
644
+ *
645
+ * const program = aleo_wasm.Program.fromString(STRUCT_PROGRAM);
646
+ * const struct_members = program.getStructMembers("token");
647
+ * console.log(struct_members === expected_struct_members); // Output should be "true"
648
+ * @param {string} struct_name
649
+ * @returns {Array<any>}
650
+ */
651
+ getStructMembers(struct_name: string): Array<any>;
652
+ /**
653
+ * Get the credits.aleo program
654
+ *
655
+ * @returns {Program} The credits.aleo program
656
+ * @returns {Program}
657
+ */
658
+ static getCreditsProgram(): Program;
659
+ /**
660
+ * Get the id of the program
661
+ *
662
+ * @returns {string} The id of the program
663
+ * @returns {string}
664
+ */
665
+ id(): string;
666
+ /**
667
+ * Get a unique address of the program
668
+ *
669
+ * @returns {Address} The address of the program
670
+ * @returns {Address}
671
+ */
672
+ address(): Address;
673
+ /**
674
+ * Determine equality with another program
675
+ *
676
+ * @param {Program} other The other program to compare
677
+ * @returns {boolean} True if the programs are equal, false otherwise
678
+ * @param {Program} other
679
+ * @returns {boolean}
680
+ */
681
+ isEqual(other: Program): boolean;
682
+ /**
683
+ * Get program_imports
684
+ *
685
+ * @returns {Array} The program imports
686
+ *
687
+ * @example
688
+ *
689
+ * const DOUBLE_TEST = "import multiply_test.aleo;
690
+ *
691
+ * program double_test.aleo;
692
+ *
693
+ * function double_it:
694
+ * input r0 as u32.private;
695
+ * call multiply_test.aleo/multiply 2u32 r0 into r1;
696
+ * output r1 as u32.private;";
697
+ *
698
+ * const expected_imports = [
699
+ * "multiply_test.aleo"
700
+ * ];
701
+ *
702
+ * const program = aleo_wasm.Program.fromString(DOUBLE_TEST_PROGRAM);
703
+ * const imports = program.getImports();
704
+ * console.log(imports === expected_imports); // Output should be "true"
705
+ * @returns {Array<any>}
706
+ */
707
+ getImports(): Array<any>;
708
+ }
709
+ /**
710
+ */
711
+ export class ProgramManager {
712
+ free(): void;
713
+ /**
714
+ * Deploy an Aleo program
715
+ *
716
+ * @param private_key The private key of the sender
717
+ * @param program The source code of the program being deployed
718
+ * @param imports A javascript object holding the source code of any imported programs in the
719
+ * form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
720
+ * Note that all imported programs must be deployed on chain before the main program in order
721
+ * for the deployment to succeed
722
+ * @param fee_credits The amount of credits to pay as a fee
723
+ * @param fee_record The record to spend the fee from
724
+ * @param url The url of the Aleo network node to send the transaction to
725
+ * @param imports (optional) Provide a list of imports to use for the program deployment in the
726
+ * form of a javascript object where the keys are a string of the program name and the values
727
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
728
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
729
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
730
+ * @returns {Transaction}
731
+ * @param {PrivateKey} private_key
732
+ * @param {string} program
733
+ * @param {number} fee_credits
734
+ * @param {RecordPlaintext | undefined} [fee_record]
735
+ * @param {string | undefined} [url]
736
+ * @param {object | undefined} [imports]
737
+ * @param {ProvingKey | undefined} [fee_proving_key]
738
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
739
+ * @param {OfflineQuery | undefined} [offline_query]
740
+ * @returns {Promise<Transaction>}
741
+ */
742
+ static buildDeploymentTransaction(private_key: PrivateKey, program: string, fee_credits: number, fee_record?: RecordPlaintext, url?: string, imports?: object, fee_proving_key?: ProvingKey, fee_verifying_key?: VerifyingKey, offline_query?: OfflineQuery): Promise<Transaction>;
743
+ /**
744
+ * Estimate the fee for a program deployment
745
+ *
746
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
747
+ *
748
+ * @param program The source code of the program being deployed
749
+ * @param imports (optional) Provide a list of imports to use for the deployment fee estimation
750
+ * in the form of a javascript object where the keys are a string of the program name and the values
751
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
752
+ * @returns {u64}
753
+ * @param {string} program
754
+ * @param {object | undefined} [imports]
755
+ * @returns {Promise<bigint>}
756
+ */
757
+ static estimateDeploymentFee(program: string, imports?: object): Promise<bigint>;
758
+ /**
759
+ * Estimate the component of the deployment cost which comes from the fee for the program name.
760
+ * Note that this cost does not represent the entire cost of deployment. It is additional to
761
+ * the cost of the size (in bytes) of the deployment.
762
+ *
763
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
764
+ *
765
+ * @param name The name of the program to be deployed
766
+ * @returns {u64}
767
+ * @param {string} name
768
+ * @returns {bigint}
769
+ */
770
+ static estimateProgramNameCost(name: string): bigint;
771
+ /**
772
+ * Execute an arbitrary function locally
773
+ *
774
+ * @param {PrivateKey} private_key The private key of the sender
775
+ * @param {string} program The source code of the program being executed
776
+ * @param {string} function The name of the function to execute
777
+ * @param {Array} inputs A javascript array of inputs to the function
778
+ * @param {boolean} prove_execution If true, the execution will be proven and an execution object
779
+ * containing the proof and the encrypted inputs and outputs needed to verify the proof offline
780
+ * will be returned.
781
+ * @param {boolean} cache Cache the proving and verifying keys in the Execution response.
782
+ * If this is set to 'true' the keys synthesized will be stored in the Execution Response
783
+ * and the `ProvingKey` and `VerifyingKey` can be retrieved from the response via the `.getKeys()`
784
+ * method.
785
+ * @param {Object | undefined} imports (optional) Provide a list of imports to use for the function execution in the
786
+ * form of a javascript object where the keys are a string of the program name and the values
787
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
788
+ * @param {ProvingKey | undefined} proving_key (optional) Provide a verifying key to use for the function execution
789
+ * @param {VerifyingKey | undefined} verifying_key (optional) Provide a verifying key to use for the function execution
790
+ * @param {PrivateKey} private_key
791
+ * @param {string} program
792
+ * @param {string} _function
793
+ * @param {Array<any>} inputs
794
+ * @param {boolean} prove_execution
795
+ * @param {boolean} cache
796
+ * @param {object | undefined} [imports]
797
+ * @param {ProvingKey | undefined} [proving_key]
798
+ * @param {VerifyingKey | undefined} [verifying_key]
799
+ * @param {string | undefined} [url]
800
+ * @param {OfflineQuery | undefined} [offline_query]
801
+ * @returns {Promise<ExecutionResponse>}
802
+ */
803
+ static executeFunctionOffline(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, prove_execution: boolean, cache: boolean, imports?: object, proving_key?: ProvingKey, verifying_key?: VerifyingKey, url?: string, offline_query?: OfflineQuery): Promise<ExecutionResponse>;
804
+ /**
805
+ * Execute Aleo function and create an Aleo execution transaction
806
+ *
807
+ * @param private_key The private key of the sender
808
+ * @param program The source code of the program being executed
809
+ * @param function The name of the function to execute
810
+ * @param inputs A javascript array of inputs to the function
811
+ * @param fee_credits The amount of credits to pay as a fee
812
+ * @param fee_record The record to spend the fee from
813
+ * @param url The url of the Aleo network node to send the transaction to
814
+ * If this is set to 'true' the keys synthesized (or passed in as optional parameters via the
815
+ * `proving_key` and `verifying_key` arguments) will be stored in the ProgramManager's memory
816
+ * and used for subsequent transactions. If this is set to 'false' the proving and verifying
817
+ * keys will be deallocated from memory after the transaction is executed.
818
+ * @param imports (optional) Provide a list of imports to use for the function execution in the
819
+ * form of a javascript object where the keys are a string of the program name and the values
820
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
821
+ * @param proving_key (optional) Provide a verifying key to use for the function execution
822
+ * @param verifying_key (optional) Provide a verifying key to use for the function execution
823
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
824
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
825
+ * @returns {Transaction}
826
+ * @param {PrivateKey} private_key
827
+ * @param {string} program
828
+ * @param {string} _function
829
+ * @param {Array<any>} inputs
830
+ * @param {number} fee_credits
831
+ * @param {RecordPlaintext | undefined} [fee_record]
832
+ * @param {string | undefined} [url]
833
+ * @param {object | undefined} [imports]
834
+ * @param {ProvingKey | undefined} [proving_key]
835
+ * @param {VerifyingKey | undefined} [verifying_key]
836
+ * @param {ProvingKey | undefined} [fee_proving_key]
837
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
838
+ * @param {OfflineQuery | undefined} [offline_query]
839
+ * @returns {Promise<Transaction>}
840
+ */
841
+ static buildExecutionTransaction(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, fee_credits: number, fee_record?: RecordPlaintext, url?: string, imports?: object, proving_key?: ProvingKey, verifying_key?: VerifyingKey, fee_proving_key?: ProvingKey, fee_verifying_key?: VerifyingKey, offline_query?: OfflineQuery): Promise<Transaction>;
842
+ /**
843
+ * Estimate Fee for Aleo function execution. Note if "cache" is set to true, the proving and
844
+ * verifying keys will be stored in the ProgramManager's memory and used for subsequent
845
+ * program executions.
846
+ *
847
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
848
+ *
849
+ * @param private_key The private key of the sender
850
+ * @param program The source code of the program to estimate the execution fee for
851
+ * @param function The name of the function to execute
852
+ * @param inputs A javascript array of inputs to the function
853
+ * @param url The url of the Aleo network node to send the transaction to
854
+ * @param imports (optional) Provide a list of imports to use for the fee estimation in the
855
+ * form of a javascript object where the keys are a string of the program name and the values
856
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
857
+ * @param proving_key (optional) Provide a verifying key to use for the fee estimation
858
+ * @param verifying_key (optional) Provide a verifying key to use for the fee estimation
859
+ * @returns {u64} Fee in microcredits
860
+ * @param {PrivateKey} private_key
861
+ * @param {string} program
862
+ * @param {string} _function
863
+ * @param {Array<any>} inputs
864
+ * @param {string | undefined} [url]
865
+ * @param {object | undefined} [imports]
866
+ * @param {ProvingKey | undefined} [proving_key]
867
+ * @param {VerifyingKey | undefined} [verifying_key]
868
+ * @param {OfflineQuery | undefined} [offline_query]
869
+ * @returns {Promise<bigint>}
870
+ */
871
+ static estimateExecutionFee(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, url?: string, imports?: object, proving_key?: ProvingKey, verifying_key?: VerifyingKey, offline_query?: OfflineQuery): Promise<bigint>;
872
+ /**
873
+ * Estimate the finalize fee component for executing a function. This fee is additional to the
874
+ * size of the execution of the program in bytes. If the function does not have a finalize
875
+ * step, then the finalize fee is 0.
876
+ *
877
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
878
+ *
879
+ * @param program The program containing the function to estimate the finalize fee for
880
+ * @param function The function to estimate the finalize fee for
881
+ * @returns {u64} Fee in microcredits
882
+ * @param {string} program
883
+ * @param {string} _function
884
+ * @returns {bigint}
885
+ */
886
+ static estimateFinalizeFee(program: string, _function: string): bigint;
887
+ /**
888
+ * Join two records together to create a new record with an amount of credits equal to the sum
889
+ * of the credits of the two original records
890
+ *
891
+ * @param private_key The private key of the sender
892
+ * @param record_1 The first record to combine
893
+ * @param record_2 The second record to combine
894
+ * @param fee_credits The amount of credits to pay as a fee
895
+ * @param fee_record The record to spend the fee from
896
+ * @param url The url of the Aleo network node to send the transaction to
897
+ * @param join_proving_key (optional) Provide a proving key to use for the join function
898
+ * @param join_verifying_key (optional) Provide a verifying key to use for the join function
899
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
900
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
901
+ * @returns {Transaction} Transaction object
902
+ * @param {PrivateKey} private_key
903
+ * @param {RecordPlaintext} record_1
904
+ * @param {RecordPlaintext} record_2
905
+ * @param {number} fee_credits
906
+ * @param {RecordPlaintext | undefined} [fee_record]
907
+ * @param {string | undefined} [url]
908
+ * @param {ProvingKey | undefined} [join_proving_key]
909
+ * @param {VerifyingKey | undefined} [join_verifying_key]
910
+ * @param {ProvingKey | undefined} [fee_proving_key]
911
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
912
+ * @param {OfflineQuery | undefined} [offline_query]
913
+ * @returns {Promise<Transaction>}
914
+ */
915
+ static buildJoinTransaction(private_key: PrivateKey, record_1: RecordPlaintext, record_2: RecordPlaintext, fee_credits: number, fee_record?: RecordPlaintext, url?: string, join_proving_key?: ProvingKey, join_verifying_key?: VerifyingKey, fee_proving_key?: ProvingKey, fee_verifying_key?: VerifyingKey, offline_query?: OfflineQuery): Promise<Transaction>;
916
+ /**
917
+ * Split an Aleo credits record into two separate records. This function does not require a fee.
918
+ *
919
+ * @param private_key The private key of the sender
920
+ * @param split_amount The amount of the credit split. This amount will be subtracted from the
921
+ * value of the record and two new records will be created with the split amount and the remainder
922
+ * @param amount_record The record to split
923
+ * @param url The url of the Aleo network node to send the transaction to
924
+ * @param split_proving_key (optional) Provide a proving key to use for the split function
925
+ * @param split_verifying_key (optional) Provide a verifying key to use for the split function
926
+ * @returns {Transaction} Transaction object
927
+ * @param {PrivateKey} private_key
928
+ * @param {number} split_amount
929
+ * @param {RecordPlaintext} amount_record
930
+ * @param {string | undefined} [url]
931
+ * @param {ProvingKey | undefined} [split_proving_key]
932
+ * @param {VerifyingKey | undefined} [split_verifying_key]
933
+ * @param {OfflineQuery | undefined} [offline_query]
934
+ * @returns {Promise<Transaction>}
935
+ */
936
+ static buildSplitTransaction(private_key: PrivateKey, split_amount: number, amount_record: RecordPlaintext, url?: string, split_proving_key?: ProvingKey, split_verifying_key?: VerifyingKey, offline_query?: OfflineQuery): Promise<Transaction>;
937
+ /**
938
+ * Send credits from one Aleo account to another
939
+ *
940
+ * @param private_key The private key of the sender
941
+ * @param amount_credits The amount of credits to send
942
+ * @param recipient The recipient of the transaction
943
+ * @param transfer_type The type of the transfer (options: "private", "public", "private_to_public", "public_to_private")
944
+ * @param amount_record The record to fund the amount from
945
+ * @param fee_credits The amount of credits to pay as a fee
946
+ * @param fee_record The record to spend the fee from
947
+ * @param url The url of the Aleo network node to send the transaction to
948
+ * @param transfer_verifying_key (optional) Provide a verifying key to use for the transfer
949
+ * function
950
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
951
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
952
+ * @returns {Transaction}
953
+ * @param {PrivateKey} private_key
954
+ * @param {number} amount_credits
955
+ * @param {string} recipient
956
+ * @param {string} transfer_type
957
+ * @param {RecordPlaintext | undefined} amount_record
958
+ * @param {number} fee_credits
959
+ * @param {RecordPlaintext | undefined} [fee_record]
960
+ * @param {string | undefined} [url]
961
+ * @param {ProvingKey | undefined} [transfer_proving_key]
962
+ * @param {VerifyingKey | undefined} [transfer_verifying_key]
963
+ * @param {ProvingKey | undefined} [fee_proving_key]
964
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
965
+ * @param {OfflineQuery | undefined} [offline_query]
966
+ * @returns {Promise<Transaction>}
967
+ */
968
+ static buildTransferTransaction(private_key: PrivateKey, amount_credits: number, recipient: string, transfer_type: string, amount_record: RecordPlaintext | undefined, fee_credits: number, fee_record?: RecordPlaintext, url?: string, transfer_proving_key?: ProvingKey, transfer_verifying_key?: VerifyingKey, fee_proving_key?: ProvingKey, fee_verifying_key?: VerifyingKey, offline_query?: OfflineQuery): Promise<Transaction>;
969
+ /**
970
+ * Synthesize proving and verifying keys for a program
971
+ *
972
+ * @param program {string} The program source code of the program to synthesize keys for
973
+ * @param function_id {string} The function to synthesize keys for
974
+ * @param inputs {Array} The inputs to the function
975
+ * @param imports {Object | undefined} The imports for the program
976
+ * @param {PrivateKey} private_key
977
+ * @param {string} program
978
+ * @param {string} function_id
979
+ * @param {Array<any>} inputs
980
+ * @param {object | undefined} [imports]
981
+ * @returns {Promise<KeyPair>}
982
+ */
983
+ static synthesizeKeyPair(private_key: PrivateKey, program: string, function_id: string, inputs: Array<any>, imports?: object): Promise<KeyPair>;
984
+ }
985
+ /**
986
+ * Proving key for a function within an Aleo program
987
+ */
988
+ export class ProvingKey {
989
+ free(): void;
990
+ /**
991
+ * Verify if the proving key is for the bond_public function
992
+ *
993
+ * @example
994
+ * const provingKey = ProvingKey.fromBytes("bond_public_proving_key.bin");
995
+ * provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
996
+ *
997
+ * @returns {boolean} returns true if the proving key is for the bond_public function, false if otherwise
998
+ * @returns {boolean}
999
+ */
1000
+ isBondPublicProver(): boolean;
1001
+ /**
1002
+ * Verify if the proving key is for the bond_validator function
1003
+ *
1004
+ * @example
1005
+ * const provingKey = ProvingKey.fromBytes("bond_validator_proving_key.bin");
1006
+ * provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
1007
+ *
1008
+ * @returns {boolean} returns true if the proving key is for the bond_validator function, false if otherwise
1009
+ * @returns {boolean}
1010
+ */
1011
+ isBondValidatorProver(): boolean;
1012
+ /**
1013
+ * Verify if the proving key is for the claim_unbond function
1014
+ *
1015
+ * @example
1016
+ * const provingKey = ProvingKey.fromBytes("claim_unbond_proving_key.bin");
1017
+ * provingKey.isClaimUnbondProver() ? console.log("Key verified") : throw new Error("Invalid key");
1018
+ *
1019
+ * @returns {boolean} returns true if the proving key is for the claim_unbond function, false if otherwise
1020
+ * @returns {boolean}
1021
+ */
1022
+ isClaimUnbondPublicProver(): boolean;
1023
+ /**
1024
+ * Verify if the proving key is for the fee_private function
1025
+ *
1026
+ * @example
1027
+ * const provingKey = ProvingKey.fromBytes("fee_private_proving_key.bin");
1028
+ * provingKey.isFeePrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
1029
+ *
1030
+ * @returns {boolean} returns true if the proving key is for the fee_private function, false if otherwise
1031
+ * @returns {boolean}
1032
+ */
1033
+ isFeePrivateProver(): boolean;
1034
+ /**
1035
+ * Verify if the proving key is for the fee_public function
1036
+ *
1037
+ * @example
1038
+ * const provingKey = ProvingKey.fromBytes("fee_public_proving_key.bin");
1039
+ * provingKey.isFeePublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
1040
+ *
1041
+ * @returns {boolean} returns true if the proving key is for the fee_public function, false if otherwise
1042
+ * @returns {boolean}
1043
+ */
1044
+ isFeePublicProver(): boolean;
1045
+ /**
1046
+ * Verify if the proving key is for the inclusion function
1047
+ *
1048
+ * @example
1049
+ * const provingKey = ProvingKey.fromBytes("inclusion_proving_key.bin");
1050
+ * provingKey.isInclusionProver() ? console.log("Key verified") : throw new Error("Invalid key");
1051
+ *
1052
+ * @returns {boolean} returns true if the proving key is for the inclusion function, false if otherwise
1053
+ * @returns {boolean}
1054
+ */
1055
+ isInclusionProver(): boolean;
1056
+ /**
1057
+ * Verify if the proving key is for the join function
1058
+ *
1059
+ * @example
1060
+ * const provingKey = ProvingKey.fromBytes("join_proving_key.bin");
1061
+ * provingKey.isJoinProver() ? console.log("Key verified") : throw new Error("Invalid key");
1062
+ *
1063
+ * @returns {boolean} returns true if the proving key is for the join function, false if otherwise
1064
+ * @returns {boolean}
1065
+ */
1066
+ isJoinProver(): boolean;
1067
+ /**
1068
+ * Verify if the proving key is for the set_validator_state function
1069
+ *
1070
+ * @example
1071
+ * const provingKey = ProvingKey.fromBytes("set_validator_set_proving_key.bin");
1072
+ * provingKey.isSetValidatorStateProver() ? console.log("Key verified") : throw new Error("Invalid key");
1073
+ *
1074
+ * @returns {boolean} returns true if the proving key is for the set_validator_state function, false if otherwise
1075
+ * @returns {boolean}
1076
+ */
1077
+ isSetValidatorStateProver(): boolean;
1078
+ /**
1079
+ * Verify if the proving key is for the split function
1080
+ *
1081
+ * @example
1082
+ * const provingKey = ProvingKey.fromBytes("split_proving_key.bin");
1083
+ * provingKey.isSplitProver() ? console.log("Key verified") : throw new Error("Invalid key");
1084
+ *
1085
+ * @returns {boolean} returns true if the proving key is for the split function, false if otherwise
1086
+ * @returns {boolean}
1087
+ */
1088
+ isSplitProver(): boolean;
1089
+ /**
1090
+ * Verify if the proving key is for the transfer_private function
1091
+ *
1092
+ * @example
1093
+ * const provingKey = ProvingKey.fromBytes("transfer_private_proving_key.bin");
1094
+ * provingKey.isTransferPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
1095
+ *
1096
+ * @returns {boolean} returns true if the proving key is for the transfer_private function, false if otherwise
1097
+ * @returns {boolean}
1098
+ */
1099
+ isTransferPrivateProver(): boolean;
1100
+ /**
1101
+ * Verify if the proving key is for the transfer_private_to_public function
1102
+ *
1103
+ * @example
1104
+ * const provingKey = ProvingKey.fromBytes("transfer_private_to_public_proving_key.bin");
1105
+ * provingKey.isTransferPrivateToPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
1106
+ *
1107
+ * @returns {boolean} returns true if the proving key is for the transfer_private_to_public function, false if otherwise
1108
+ * @returns {boolean}
1109
+ */
1110
+ isTransferPrivateToPublicProver(): boolean;
1111
+ /**
1112
+ * Verify if the proving key is for the transfer_public function
1113
+ *
1114
+ * @example
1115
+ * const provingKey = ProvingKey.fromBytes("transfer_public_proving_key.bin");
1116
+ * provingKey.isTransferPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
1117
+ *
1118
+ * @returns {boolean} returns true if the proving key is for the transfer_public function, false if otherwise
1119
+ * @returns {boolean}
1120
+ */
1121
+ isTransferPublicProver(): boolean;
1122
+ /**
1123
+ * Verify if the proving key is for the transfer_public_as_signer function
1124
+ *
1125
+ * @example
1126
+ * const provingKey = ProvingKey.fromBytes("transfer_public_as_signer_proving_key.bin");
1127
+ * provingKey.isTransferPublicAsSignerProver() ? console.log("Key verified") : throw new Error("Invalid key");
1128
+ *
1129
+ * @returns {boolean} returns true if the proving key is for the transfer_public function, false if otherwise
1130
+ * @returns {boolean}
1131
+ */
1132
+ isTransferPublicAsSignerProver(): boolean;
1133
+ /**
1134
+ * Verify if the proving key is for the transfer_public_to_private function
1135
+ *
1136
+ * @example
1137
+ * const provingKey = ProvingKey.fromBytes("transfer_public_to_private_proving_key.bin");
1138
+ * provingKey.isTransferPublicToPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
1139
+ *
1140
+ * @returns {boolean} returns true if the proving key is for the transfer_public_to_private function, false if otherwise
1141
+ * @returns {boolean}
1142
+ */
1143
+ isTransferPublicToPrivateProver(): boolean;
1144
+ /**
1145
+ * Verify if the proving key is for the unbond_public function
1146
+ *
1147
+ * @example
1148
+ * const provingKey = ProvingKey.fromBytes("unbond_public.bin");
1149
+ * provingKey.isUnbondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
1150
+ *
1151
+ * @returns {boolean} returns true if the proving key is for the unbond_public_prover function, false if otherwise
1152
+ * @returns {boolean}
1153
+ */
1154
+ isUnbondPublicProver(): boolean;
1155
+ /**
1156
+ * Return the checksum of the proving key
1157
+ *
1158
+ * @returns {string} Checksum of the proving key
1159
+ * @returns {string}
1160
+ */
1161
+ checksum(): string;
1162
+ /**
1163
+ * Create a copy of the proving key
1164
+ *
1165
+ * @returns {ProvingKey} A copy of the proving key
1166
+ * @returns {ProvingKey}
1167
+ */
1168
+ copy(): ProvingKey;
1169
+ /**
1170
+ * Construct a new proving key from a byte array
1171
+ *
1172
+ * @param {Uint8Array} bytes Byte array representation of a proving key
1173
+ * @returns {ProvingKey}
1174
+ * @param {Uint8Array} bytes
1175
+ * @returns {ProvingKey}
1176
+ */
1177
+ static fromBytes(bytes: Uint8Array): ProvingKey;
1178
+ /**
1179
+ * Create a proving key from string
1180
+ *
1181
+ * @param {string} String representation of the proving key
1182
+ * @param {string} string
1183
+ * @returns {ProvingKey}
1184
+ */
1185
+ static fromString(string: string): ProvingKey;
1186
+ /**
1187
+ * Return the byte representation of a proving key
1188
+ *
1189
+ * @returns {Uint8Array} Byte array representation of a proving key
1190
+ * @returns {Uint8Array}
1191
+ */
1192
+ toBytes(): Uint8Array;
1193
+ /**
1194
+ * Get a string representation of the proving key
1195
+ *
1196
+ * @returns {string} String representation of the proving key
1197
+ * @returns {string}
1198
+ */
1199
+ toString(): string;
1200
+ }
1201
+ /**
1202
+ * Encrypted Aleo record
1203
+ */
1204
+ export class RecordCiphertext {
1205
+ free(): void;
1206
+ /**
1207
+ * Create a record ciphertext from a string
1208
+ *
1209
+ * @param {string} record String representation of a record ciphertext
1210
+ * @returns {RecordCiphertext} Record ciphertext
1211
+ * @param {string} record
1212
+ * @returns {RecordCiphertext}
1213
+ */
1214
+ static fromString(record: string): RecordCiphertext;
1215
+ /**
1216
+ * Return the string reprensentation of the record ciphertext
1217
+ *
1218
+ * @returns {string} String representation of the record ciphertext
1219
+ * @returns {string}
1220
+ */
1221
+ toString(): string;
1222
+ /**
1223
+ * Decrypt the record ciphertext into plaintext using the view key. The record will only
1224
+ * decrypt if the record was encrypted by the account corresponding to the view key
1225
+ *
1226
+ * @param {ViewKey} view_key View key used to decrypt the ciphertext
1227
+ * @returns {RecordPlaintext} Record plaintext object
1228
+ * @param {ViewKey} view_key
1229
+ * @returns {RecordPlaintext}
1230
+ */
1231
+ decrypt(view_key: ViewKey): RecordPlaintext;
1232
+ /**
1233
+ * Determines if the account corresponding to the view key is the owner of the record
1234
+ *
1235
+ * @param {ViewKey} view_key View key used to decrypt the ciphertext
1236
+ * @returns {boolean}
1237
+ * @param {ViewKey} view_key
1238
+ * @returns {boolean}
1239
+ */
1240
+ isOwner(view_key: ViewKey): boolean;
1241
+ }
1242
+ /**
1243
+ * Plaintext representation of an Aleo record
1244
+ */
1245
+ export class RecordPlaintext {
1246
+ free(): void;
1247
+ /**
1248
+ * @param {string} program_id
1249
+ * @param {string} record_name
1250
+ * @returns {Field}
1251
+ */
1252
+ commitment(program_id: string, record_name: string): Field;
1253
+ /**
1254
+ * Return a record plaintext from a string.
1255
+ *
1256
+ * @param {string} record String representation of a plaintext representation of an Aleo record
1257
+ * @returns {RecordPlaintext} Record plaintext
1258
+ * @param {string} record
1259
+ * @returns {RecordPlaintext}
1260
+ */
1261
+ static fromString(record: string): RecordPlaintext;
1262
+ /**
1263
+ * Returns the record plaintext string
1264
+ *
1265
+ * @returns {string} String representation of the record plaintext
1266
+ * @returns {string}
1267
+ */
1268
+ toString(): string;
1269
+ /**
1270
+ * Returns the amount of microcredits in the record
1271
+ *
1272
+ * @returns {u64} Amount of microcredits in the record
1273
+ * @returns {bigint}
1274
+ */
1275
+ microcredits(): bigint;
1276
+ /**
1277
+ * Returns the nonce of the record. This can be used to uniquely identify a record.
1278
+ *
1279
+ * @returns {string} Nonce of the record
1280
+ * @returns {string}
1281
+ */
1282
+ nonce(): string;
1283
+ /**
1284
+ * Attempt to get the serial number of a record to determine whether or not is has been spent
1285
+ *
1286
+ * @param {PrivateKey} private_key Private key of the account that owns the record
1287
+ * @param {string} program_id Program ID of the program that the record is associated with
1288
+ * @param {string} record_name Name of the record
1289
+ * @returns {string} Serial number of the record
1290
+ * @param {PrivateKey} private_key
1291
+ * @param {string} program_id
1292
+ * @param {string} record_name
1293
+ * @returns {string}
1294
+ */
1295
+ serialNumberString(private_key: PrivateKey, program_id: string, record_name: string): string;
1296
+ }
1297
+ /**
1298
+ * Cryptographic signature of a message signed by an Aleo account
1299
+ */
1300
+ export class Signature {
1301
+ free(): void;
1302
+ /**
1303
+ * Sign a message with a private key
1304
+ *
1305
+ * @param {PrivateKey} private_key The private key to sign the message with
1306
+ * @param {Uint8Array} message Byte representation of the message to sign
1307
+ * @returns {Signature} Signature of the message
1308
+ * @param {PrivateKey} private_key
1309
+ * @param {Uint8Array} message
1310
+ * @returns {Signature}
1311
+ */
1312
+ static sign(private_key: PrivateKey, message: Uint8Array): Signature;
1313
+ /**
1314
+ * Verify a signature of a message with an address
1315
+ *
1316
+ * @param {Address} address The address to verify the signature with
1317
+ * @param {Uint8Array} message Byte representation of the message to verify
1318
+ * @returns {boolean} True if the signature is valid, false otherwise
1319
+ * @param {Address} address
1320
+ * @param {Uint8Array} message
1321
+ * @returns {boolean}
1322
+ */
1323
+ verify(address: Address, message: Uint8Array): boolean;
1324
+ /**
1325
+ * Get a signature from a string representation of a signature
1326
+ *
1327
+ * @param {string} signature String representation of a signature
1328
+ * @returns {Signature} Signature
1329
+ * @param {string} signature
1330
+ * @returns {Signature}
1331
+ */
1332
+ static from_string(signature: string): Signature;
1333
+ /**
1334
+ * Get a string representation of a signature
1335
+ *
1336
+ * @returns {string} String representation of a signature
1337
+ * @returns {string}
1338
+ */
1339
+ to_string(): string;
1340
+ }
1341
+ /**
1342
+ * Webassembly Representation of an Aleo transaction
1343
+ *
1344
+ * This object is created when generating an on-chain function deployment or execution and is the
1345
+ * object that should be submitted to the Aleo Network in order to deploy or execute a function.
1346
+ */
1347
+ export class Transaction {
1348
+ free(): void;
1349
+ /**
1350
+ * Create a transaction from a string
1351
+ *
1352
+ * @param {string} transaction String representation of a transaction
1353
+ * @returns {Transaction}
1354
+ * @param {string} transaction
1355
+ * @returns {Transaction}
1356
+ */
1357
+ static fromString(transaction: string): Transaction;
1358
+ /**
1359
+ * Get the transaction as a string. If you want to submit this transaction to the Aleo Network
1360
+ * this function will create the string that should be submitted in the `POST` data.
1361
+ *
1362
+ * @returns {string} String representation of the transaction
1363
+ * @returns {string}
1364
+ */
1365
+ toString(): string;
1366
+ /**
1367
+ * Get the id of the transaction. This is the merkle root of the transaction's inclusion proof.
1368
+ *
1369
+ * This value can be used to query the status of the transaction on the Aleo Network to see
1370
+ * if it was successful. If successful, the transaction will be included in a block and this
1371
+ * value can be used to lookup the transaction data on-chain.
1372
+ *
1373
+ * @returns {string} Transaction id
1374
+ * @returns {string}
1375
+ */
1376
+ transactionId(): string;
1377
+ /**
1378
+ * Get the type of the transaction (will return "deploy" or "execute")
1379
+ *
1380
+ * @returns {string} Transaction type
1381
+ * @returns {string}
1382
+ */
1383
+ transactionType(): string;
1384
+ }
1385
+ /**
1386
+ * Verifying key for a function within an Aleo program
1387
+ */
1388
+ export class VerifyingKey {
1389
+ free(): void;
1390
+ /**
1391
+ * Returns the verifying key for the bond_public function
1392
+ *
1393
+ * @returns {VerifyingKey} Verifying key for the bond_public function
1394
+ * @returns {VerifyingKey}
1395
+ */
1396
+ static bondPublicVerifier(): VerifyingKey;
1397
+ /**
1398
+ * Returns the verifying key for the bond_validator function
1399
+ *
1400
+ * @returns {VerifyingKey} Verifying key for the bond_validator function
1401
+ * @returns {VerifyingKey}
1402
+ */
1403
+ static bondValidatorVerifier(): VerifyingKey;
1404
+ /**
1405
+ * Returns the verifying key for the claim_delegator function
1406
+ *
1407
+ * @returns {VerifyingKey} Verifying key for the claim_unbond_public function
1408
+ * @returns {VerifyingKey}
1409
+ */
1410
+ static claimUnbondPublicVerifier(): VerifyingKey;
1411
+ /**
1412
+ * Returns the verifying key for the fee_private function
1413
+ *
1414
+ * @returns {VerifyingKey} Verifying key for the fee_private function
1415
+ * @returns {VerifyingKey}
1416
+ */
1417
+ static feePrivateVerifier(): VerifyingKey;
1418
+ /**
1419
+ * Returns the verifying key for the fee_public function
1420
+ *
1421
+ * @returns {VerifyingKey} Verifying key for the fee_public function
1422
+ * @returns {VerifyingKey}
1423
+ */
1424
+ static feePublicVerifier(): VerifyingKey;
1425
+ /**
1426
+ * Returns the verifying key for the inclusion function
1427
+ *
1428
+ * @returns {VerifyingKey} Verifying key for the inclusion function
1429
+ * @returns {VerifyingKey}
1430
+ */
1431
+ static inclusionVerifier(): VerifyingKey;
1432
+ /**
1433
+ * Returns the verifying key for the join function
1434
+ *
1435
+ * @returns {VerifyingKey} Verifying key for the join function
1436
+ * @returns {VerifyingKey}
1437
+ */
1438
+ static joinVerifier(): VerifyingKey;
1439
+ /**
1440
+ * Returns the verifying key for the set_validator_state function
1441
+ *
1442
+ * @returns {VerifyingKey} Verifying key for the set_validator_state function
1443
+ * @returns {VerifyingKey}
1444
+ */
1445
+ static setValidatorStateVerifier(): VerifyingKey;
1446
+ /**
1447
+ * Returns the verifying key for the split function
1448
+ *
1449
+ * @returns {VerifyingKey} Verifying key for the split function
1450
+ * @returns {VerifyingKey}
1451
+ */
1452
+ static splitVerifier(): VerifyingKey;
1453
+ /**
1454
+ * Returns the verifying key for the transfer_private function
1455
+ *
1456
+ * @returns {VerifyingKey} Verifying key for the transfer_private function
1457
+ * @returns {VerifyingKey}
1458
+ */
1459
+ static transferPrivateVerifier(): VerifyingKey;
1460
+ /**
1461
+ * Returns the verifying key for the transfer_private_to_public function
1462
+ *
1463
+ * @returns {VerifyingKey} Verifying key for the transfer_private_to_public function
1464
+ * @returns {VerifyingKey}
1465
+ */
1466
+ static transferPrivateToPublicVerifier(): VerifyingKey;
1467
+ /**
1468
+ * Returns the verifying key for the transfer_public function
1469
+ *
1470
+ * @returns {VerifyingKey} Verifying key for the transfer_public function
1471
+ * @returns {VerifyingKey}
1472
+ */
1473
+ static transferPublicVerifier(): VerifyingKey;
1474
+ /**
1475
+ * Returns the verifying key for the transfer_public_as_signer function
1476
+ *
1477
+ * @returns {VerifyingKey} Verifying key for the transfer_public_as_signer function
1478
+ * @returns {VerifyingKey}
1479
+ */
1480
+ static transferPublicAsSignerVerifier(): VerifyingKey;
1481
+ /**
1482
+ * Returns the verifying key for the transfer_public_to_private function
1483
+ *
1484
+ * @returns {VerifyingKey} Verifying key for the transfer_public_to_private function
1485
+ * @returns {VerifyingKey}
1486
+ */
1487
+ static transferPublicToPrivateVerifier(): VerifyingKey;
1488
+ /**
1489
+ * Returns the verifying key for the unbond_public function
1490
+ *
1491
+ * @returns {VerifyingKey} Verifying key for the unbond_public function
1492
+ * @returns {VerifyingKey}
1493
+ */
1494
+ static unbondPublicVerifier(): VerifyingKey;
1495
+ /**
1496
+ * Returns the verifying key for the bond_public function
1497
+ *
1498
+ * @returns {VerifyingKey} Verifying key for the bond_public function
1499
+ * @returns {boolean}
1500
+ */
1501
+ isBondPublicVerifier(): boolean;
1502
+ /**
1503
+ * Returns the verifying key for the bond_validator function
1504
+ *
1505
+ * @returns {VerifyingKey} Verifying key for the bond_validator function
1506
+ * @returns {boolean}
1507
+ */
1508
+ isBondValidatorVerifier(): boolean;
1509
+ /**
1510
+ * Verifies the verifying key is for the claim_delegator function
1511
+ *
1512
+ * @returns {bool}
1513
+ * @returns {boolean}
1514
+ */
1515
+ isClaimUnbondPublicVerifier(): boolean;
1516
+ /**
1517
+ * Verifies the verifying key is for the fee_private function
1518
+ *
1519
+ * @returns {bool}
1520
+ * @returns {boolean}
1521
+ */
1522
+ isFeePrivateVerifier(): boolean;
1523
+ /**
1524
+ * Verifies the verifying key is for the fee_public function
1525
+ *
1526
+ * @returns {bool}
1527
+ * @returns {boolean}
1528
+ */
1529
+ isFeePublicVerifier(): boolean;
1530
+ /**
1531
+ * Verifies the verifying key is for the inclusion function
1532
+ *
1533
+ * @returns {bool}
1534
+ * @returns {boolean}
1535
+ */
1536
+ isInclusionVerifier(): boolean;
1537
+ /**
1538
+ * Verifies the verifying key is for the join function
1539
+ *
1540
+ * @returns {bool}
1541
+ * @returns {boolean}
1542
+ */
1543
+ isJoinVerifier(): boolean;
1544
+ /**
1545
+ * Verifies the verifying key is for the set_validator_state function
1546
+ *
1547
+ * @returns {bool}
1548
+ * @returns {boolean}
1549
+ */
1550
+ isSetValidatorStateVerifier(): boolean;
1551
+ /**
1552
+ * Verifies the verifying key is for the split function
1553
+ *
1554
+ * @returns {bool}
1555
+ * @returns {boolean}
1556
+ */
1557
+ isSplitVerifier(): boolean;
1558
+ /**
1559
+ * Verifies the verifying key is for the transfer_private function
1560
+ *
1561
+ * @returns {bool}
1562
+ * @returns {boolean}
1563
+ */
1564
+ isTransferPrivateVerifier(): boolean;
1565
+ /**
1566
+ * Verifies the verifying key is for the transfer_private_to_public function
1567
+ *
1568
+ * @returns {bool}
1569
+ * @returns {boolean}
1570
+ */
1571
+ isTransferPrivateToPublicVerifier(): boolean;
1572
+ /**
1573
+ * Verifies the verifying key is for the transfer_public function
1574
+ *
1575
+ * @returns {bool}
1576
+ * @returns {boolean}
1577
+ */
1578
+ isTransferPublicVerifier(): boolean;
1579
+ /**
1580
+ * Verifies the verifying key is for the transfer_public_as_signer function
1581
+ *
1582
+ * @returns {bool}
1583
+ * @returns {boolean}
1584
+ */
1585
+ isTransferPublicAsSignerVerifier(): boolean;
1586
+ /**
1587
+ * Verifies the verifying key is for the transfer_public_to_private function
1588
+ *
1589
+ * @returns {bool}
1590
+ * @returns {boolean}
1591
+ */
1592
+ isTransferPublicToPrivateVerifier(): boolean;
1593
+ /**
1594
+ * Verifies the verifying key is for the unbond_public function
1595
+ *
1596
+ * @returns {bool}
1597
+ * @returns {boolean}
1598
+ */
1599
+ isUnbondPublicVerifier(): boolean;
1600
+ /**
1601
+ * Get the checksum of the verifying key
1602
+ *
1603
+ * @returns {string} Checksum of the verifying key
1604
+ * @returns {string}
1605
+ */
1606
+ checksum(): string;
1607
+ /**
1608
+ * Create a copy of the verifying key
1609
+ *
1610
+ * @returns {VerifyingKey} A copy of the verifying key
1611
+ * @returns {VerifyingKey}
1612
+ */
1613
+ copy(): VerifyingKey;
1614
+ /**
1615
+ * Construct a new verifying key from a byte array
1616
+ *
1617
+ * @param {Uint8Array} bytes Byte representation of a verifying key
1618
+ * @returns {VerifyingKey}
1619
+ * @param {Uint8Array} bytes
1620
+ * @returns {VerifyingKey}
1621
+ */
1622
+ static fromBytes(bytes: Uint8Array): VerifyingKey;
1623
+ /**
1624
+ * Create a verifying key from string
1625
+ *
1626
+ * @param {String} string String representation of a verifying key
1627
+ * @returns {VerifyingKey}
1628
+ * @param {string} string
1629
+ * @returns {VerifyingKey}
1630
+ */
1631
+ static fromString(string: string): VerifyingKey;
1632
+ /**
1633
+ * Create a byte array from a verifying key
1634
+ *
1635
+ * @returns {Uint8Array} Byte representation of a verifying key
1636
+ * @returns {Uint8Array}
1637
+ */
1638
+ toBytes(): Uint8Array;
1639
+ /**
1640
+ * Get a string representation of the verifying key
1641
+ *
1642
+ * @returns {String} String representation of the verifying key
1643
+ * @returns {string}
1644
+ */
1645
+ toString(): string;
1646
+ }
1647
+ /**
1648
+ */
1649
+ export class ViewKey {
1650
+ free(): void;
1651
+ /**
1652
+ * Create a new view key from a private key
1653
+ *
1654
+ * @param {PrivateKey} private_key Private key
1655
+ * @returns {ViewKey} View key
1656
+ * @param {PrivateKey} private_key
1657
+ * @returns {ViewKey}
1658
+ */
1659
+ static from_private_key(private_key: PrivateKey): ViewKey;
1660
+ /**
1661
+ * Create a new view key from a string representation of a view key
1662
+ *
1663
+ * @param {string} view_key String representation of a view key
1664
+ * @returns {ViewKey} View key
1665
+ * @param {string} view_key
1666
+ * @returns {ViewKey}
1667
+ */
1668
+ static from_string(view_key: string): ViewKey;
1669
+ /**
1670
+ * Get a string representation of a view key
1671
+ *
1672
+ * @returns {string} String representation of a view key
1673
+ * @returns {string}
1674
+ */
1675
+ to_string(): string;
1676
+ /**
1677
+ * Get the address corresponding to a view key
1678
+ *
1679
+ * @returns {Address} Address
1680
+ * @returns {Address}
1681
+ */
1682
+ to_address(): Address;
1683
+ /**
1684
+ * Decrypt a record ciphertext with a view key
1685
+ *
1686
+ * @param {string} ciphertext String representation of a record ciphertext
1687
+ * @returns {string} String representation of a record plaintext
1688
+ * @param {string} ciphertext
1689
+ * @returns {string}
1690
+ */
1691
+ decrypt(ciphertext: string): string;
1692
+ }