@provablehq/wasm 0.9.4 → 0.9.6
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 +2372 -1332
- package/dist/mainnet/aleo_wasm.wasm +0 -0
- package/dist/mainnet/index.js +6884 -3437
- package/dist/mainnet/index.js.map +1 -1
- package/dist/mainnet/worker.js +6893 -3436
- package/dist/mainnet/worker.js.map +1 -1
- package/dist/testnet/aleo_wasm.d.ts +2372 -1332
- package/dist/testnet/aleo_wasm.wasm +0 -0
- package/dist/testnet/index.js +6884 -3437
- package/dist/testnet/index.js.map +1 -1
- package/dist/testnet/worker.js +6893 -3436
- package/dist/testnet/worker.js.map +1 -1
- package/package.json +2 -1
|
@@ -562,6 +562,24 @@ export class EncryptionToolkit {
|
|
|
562
562
|
* @returns {Transition} The decrypted transition.
|
|
563
563
|
*/
|
|
564
564
|
static decryptTransitionWithVk(transition: Transition, transition_vk: Field): Transition;
|
|
565
|
+
/**
|
|
566
|
+
* Decrypts a set of record ciphertexts in parallel and stores successful decryptions.
|
|
567
|
+
*
|
|
568
|
+
* @param {ViewKey} view_key The view key of the owner of the records.
|
|
569
|
+
* @param {Vec<RecordCiphertext>} records The record ciphertexts to decrypt.
|
|
570
|
+
*
|
|
571
|
+
* @returns {vec<RecordPlaintext>} The decrypted record plaintexts.
|
|
572
|
+
*/
|
|
573
|
+
static decryptOwnedRecords(view_key: ViewKey, records: RecordCiphertext[]): RecordPlaintext[];
|
|
574
|
+
/**
|
|
575
|
+
* Checks if a record ciphertext is owned by the given view key.
|
|
576
|
+
*
|
|
577
|
+
* @param {ViewKey} view_key View key of the owner of the records.
|
|
578
|
+
* @param {Vec<RecordCiphertext>} records The record ciphertexts for which to check ownership.
|
|
579
|
+
*
|
|
580
|
+
* @returns {Vec<RecordCiphertext>} The record ciphertexts that are owned by the view key.
|
|
581
|
+
*/
|
|
582
|
+
static checkOwnedRecords(view_key: ViewKey, records: RecordCiphertext[]): RecordCiphertext[];
|
|
565
583
|
}
|
|
566
584
|
/**
|
|
567
585
|
* Execution of an Aleo program.
|
|
@@ -682,14 +700,14 @@ export class ExecutionRequest {
|
|
|
682
700
|
* @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
701
|
* @param {boolean} is_root Flag to indicate if this is the top level function in the call graph.
|
|
684
702
|
*/
|
|
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;
|
|
703
|
+
static sign(private_key: PrivateKey, program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, root_tvk: Field | null | undefined, program_checksum: Field | null | undefined, is_root: boolean): ExecutionRequest;
|
|
686
704
|
/**
|
|
687
705
|
* Verify the input types within a request.
|
|
688
706
|
*
|
|
689
707
|
* @param {string[]} The input_types within the request.
|
|
690
708
|
* @param {boolean} Flag to indicate whether this request is the first function in the call graph.
|
|
691
709
|
*/
|
|
692
|
-
verify(input_types: Array<any>, is_root: boolean): boolean;
|
|
710
|
+
verify(input_types: Array<any>, is_root: boolean, program_checksum?: Field | null): boolean;
|
|
693
711
|
}
|
|
694
712
|
/**
|
|
695
713
|
* Webassembly Representation of an Aleo function execution response
|
|
@@ -934,1861 +952,2879 @@ export class Group {
|
|
|
934
952
|
*/
|
|
935
953
|
static generator(): Group;
|
|
936
954
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
*/
|
|
940
|
-
export class KeyPair {
|
|
955
|
+
export class I128 {
|
|
956
|
+
private constructor();
|
|
941
957
|
free(): void;
|
|
942
958
|
/**
|
|
943
|
-
*
|
|
944
|
-
*
|
|
945
|
-
* @param {ProvingKey} proving_key Proving key corresponding to a function in an Aleo program
|
|
946
|
-
* @param {VerifyingKey} verifying_key Verifying key corresponding to a function in an Aleo program
|
|
947
|
-
* @returns {KeyPair} Key pair object containing both the function proving and verifying keys
|
|
959
|
+
* Creates from string.
|
|
948
960
|
*/
|
|
949
|
-
|
|
961
|
+
static fromString(s: string): I128;
|
|
950
962
|
/**
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
* @returns {ProvingKey}
|
|
963
|
+
* To string.
|
|
954
964
|
*/
|
|
955
|
-
|
|
965
|
+
toString(): string;
|
|
956
966
|
/**
|
|
957
|
-
*
|
|
958
|
-
*
|
|
959
|
-
* @returns {VerifyingKey}
|
|
967
|
+
* From bytes (LE).
|
|
960
968
|
*/
|
|
961
|
-
|
|
962
|
-
}
|
|
963
|
-
export class Metadata {
|
|
964
|
-
private constructor();
|
|
965
|
-
free(): void;
|
|
966
|
-
static baseUrl(): string;
|
|
967
|
-
static bond_public(): Metadata;
|
|
968
|
-
static bond_validator(): Metadata;
|
|
969
|
-
static claim_unbond_public(): Metadata;
|
|
970
|
-
static fee_private(): Metadata;
|
|
971
|
-
static fee_public(): Metadata;
|
|
972
|
-
static inclusion(): Metadata;
|
|
973
|
-
static join(): Metadata;
|
|
974
|
-
static set_validator_state(): Metadata;
|
|
975
|
-
static split(): Metadata;
|
|
976
|
-
static transfer_private(): Metadata;
|
|
977
|
-
static transfer_private_to_public(): Metadata;
|
|
978
|
-
static transfer_public(): Metadata;
|
|
979
|
-
static transfer_public_as_signer(): Metadata;
|
|
980
|
-
static transfer_public_to_private(): Metadata;
|
|
981
|
-
static unbond_public(): Metadata;
|
|
982
|
-
name: string;
|
|
983
|
-
locator: string;
|
|
984
|
-
prover: string;
|
|
985
|
-
verifier: string;
|
|
986
|
-
verifyingKey: string;
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* An offline query object used to insert the global state root and state paths needed to create
|
|
990
|
-
* a valid inclusion proof offline.
|
|
991
|
-
*/
|
|
992
|
-
export class OfflineQuery {
|
|
993
|
-
free(): void;
|
|
969
|
+
static fromBytesLe(bytes: Uint8Array): I128;
|
|
994
970
|
/**
|
|
995
|
-
*
|
|
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.
|
|
971
|
+
* To bytes (LE).
|
|
1001
972
|
*/
|
|
1002
|
-
|
|
973
|
+
toBytesLe(): Uint8Array;
|
|
1003
974
|
/**
|
|
1004
|
-
*
|
|
1005
|
-
*
|
|
1006
|
-
* @param {u32} block_height The block height to add.
|
|
975
|
+
* From bits.
|
|
1007
976
|
*/
|
|
1008
|
-
|
|
977
|
+
static fromBitsLe(bits: Array<any>): I128;
|
|
1009
978
|
/**
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1012
|
-
* @param {string} commitment: The commitment corresponding to a record input.
|
|
1013
|
-
* @param {string} state_path: The state path corresponding to the commitment.
|
|
979
|
+
* To bits.
|
|
1014
980
|
*/
|
|
1015
|
-
|
|
981
|
+
toBitsLe(): Array<any>;
|
|
1016
982
|
/**
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
* @returns {string} JSON string representation of the offline query object.
|
|
983
|
+
* Checked absolute value.
|
|
1020
984
|
*/
|
|
1021
|
-
|
|
985
|
+
absChecked(): I128;
|
|
1022
986
|
/**
|
|
1023
|
-
*
|
|
1024
|
-
*
|
|
1025
|
-
* @param {string} JSON string representation of the offline query object.
|
|
987
|
+
* Wrapped absolute value.
|
|
1026
988
|
*/
|
|
1027
|
-
|
|
1028
|
-
}
|
|
1029
|
-
export class Pedersen128 {
|
|
1030
|
-
free(): void;
|
|
989
|
+
absWrapped(): I128;
|
|
1031
990
|
/**
|
|
1032
|
-
*
|
|
991
|
+
* Wrapped addition.
|
|
1033
992
|
*/
|
|
1034
|
-
|
|
993
|
+
addWrapped(other: I128): I128;
|
|
1035
994
|
/**
|
|
1036
|
-
*
|
|
995
|
+
* Wrapped subtraction.
|
|
1037
996
|
*/
|
|
1038
|
-
|
|
997
|
+
subWrapped(other: I128): I128;
|
|
1039
998
|
/**
|
|
1040
|
-
*
|
|
999
|
+
* Wrapped multiplication.
|
|
1041
1000
|
*/
|
|
1042
|
-
|
|
1001
|
+
mulWrapped(other: I128): I128;
|
|
1043
1002
|
/**
|
|
1044
|
-
*
|
|
1003
|
+
* Wrapped division.
|
|
1045
1004
|
*/
|
|
1046
|
-
|
|
1005
|
+
divWrapped(other: I128): I128;
|
|
1047
1006
|
/**
|
|
1048
|
-
*
|
|
1007
|
+
* Power to a u8 exponent.
|
|
1049
1008
|
*/
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
export class Pedersen64 {
|
|
1053
|
-
free(): void;
|
|
1009
|
+
powU8(exponent: U8): I128;
|
|
1054
1010
|
/**
|
|
1055
|
-
*
|
|
1011
|
+
* Power to a u16 exponent.
|
|
1056
1012
|
*/
|
|
1057
|
-
|
|
1013
|
+
powU16(exponent: U16): I128;
|
|
1058
1014
|
/**
|
|
1059
|
-
*
|
|
1015
|
+
* Power to a u32 exponent.
|
|
1060
1016
|
*/
|
|
1061
|
-
|
|
1017
|
+
powU32(exponent: U32): I128;
|
|
1062
1018
|
/**
|
|
1063
|
-
*
|
|
1019
|
+
* Negates the integer (e.g., 5 → -5).
|
|
1064
1020
|
*/
|
|
1065
|
-
|
|
1021
|
+
neg(): I128;
|
|
1066
1022
|
/**
|
|
1067
|
-
*
|
|
1023
|
+
* Checks equality with another integer.
|
|
1068
1024
|
*/
|
|
1069
|
-
|
|
1025
|
+
equals(other: I128): boolean;
|
|
1070
1026
|
/**
|
|
1071
|
-
*
|
|
1027
|
+
* Remainder.
|
|
1072
1028
|
*/
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1075
|
-
/**
|
|
1076
|
-
* SnarkVM Plaintext object. Plaintext is a fundamental monadic type used to represent Aleo
|
|
1077
|
-
* primitive types (boolean, field, group, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128,
|
|
1078
|
-
* scalar, and signature), struct types, and array types.
|
|
1079
|
-
*
|
|
1080
|
-
* In the context of a web or NodeJS application, this type is useful for turning an Aleo type into
|
|
1081
|
-
* a JS value, object, or array that might be necessary for performing computations within the
|
|
1082
|
-
* application.
|
|
1083
|
-
*
|
|
1084
|
-
* @example
|
|
1085
|
-
* // Get the bond state of an existing address.
|
|
1086
|
-
* const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
|
|
1087
|
-
* // Convert the bond state to a Plaintext object.
|
|
1088
|
-
* const bondStatePlaintext = Plaintext.fromString(bond_state);
|
|
1089
|
-
* // Convert the Plaintext object to a JS object.
|
|
1090
|
-
* const bondStateObject = bond_state_plaintext.toObject();
|
|
1091
|
-
* // Check if the bond state matches the expected object.
|
|
1092
|
-
* const expectedObject = { validator: "aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f", microcredits: 100000000u64 };
|
|
1093
|
-
* assert( JSON.stringify(bondStateObject) === JSON.stringify(expectedObject) );
|
|
1094
|
-
*/
|
|
1095
|
-
export class Plaintext {
|
|
1096
|
-
private constructor();
|
|
1097
|
-
free(): void;
|
|
1029
|
+
rem(other: I128): I128;
|
|
1098
1030
|
/**
|
|
1099
|
-
*
|
|
1100
|
-
* a struct or the member does not exist.
|
|
1101
|
-
*
|
|
1102
|
-
* @param {string} name The name of the plaintext member to find.
|
|
1103
|
-
*
|
|
1104
|
-
* @returns {Plaintext} The plaintext member.
|
|
1031
|
+
* Wrapped remainder.
|
|
1105
1032
|
*/
|
|
1106
|
-
|
|
1033
|
+
remWrapped(other: I128): I128;
|
|
1107
1034
|
/**
|
|
1108
|
-
*
|
|
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.
|
|
1035
|
+
* Convert to Scalar.
|
|
1114
1036
|
*/
|
|
1115
|
-
|
|
1037
|
+
toScalar(): Scalar;
|
|
1116
1038
|
/**
|
|
1117
|
-
*
|
|
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.
|
|
1039
|
+
* Convert to plaintext.
|
|
1123
1040
|
*/
|
|
1124
|
-
|
|
1041
|
+
toPlaintext(): Plaintext;
|
|
1125
1042
|
/**
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1128
|
-
* @param {string} plaintext The string representation of the plaintext.
|
|
1129
|
-
*
|
|
1130
|
-
* @returns {Plaintext} The plaintext object.
|
|
1043
|
+
* Convert from Field.
|
|
1131
1044
|
*/
|
|
1132
|
-
static
|
|
1045
|
+
static fromField(field: Field): I128;
|
|
1133
1046
|
/**
|
|
1134
|
-
*
|
|
1135
|
-
*
|
|
1136
|
-
* @param {Uint8Array} bytes A left endian byte array representing the plaintext.
|
|
1137
|
-
*
|
|
1138
|
-
* @returns {Plaintext} The plaintext object.
|
|
1047
|
+
* Convert from Fields.
|
|
1139
1048
|
*/
|
|
1140
|
-
static
|
|
1049
|
+
static fromFields(fields: Array<any>): I128;
|
|
1141
1050
|
/**
|
|
1142
|
-
*
|
|
1143
|
-
*
|
|
1144
|
-
* @returns {Uint8Array} The left endian byte array representation of the plaintext.
|
|
1051
|
+
* Clone.
|
|
1145
1052
|
*/
|
|
1146
|
-
|
|
1053
|
+
clone(): I128;
|
|
1054
|
+
}
|
|
1055
|
+
export class I16 {
|
|
1056
|
+
private constructor();
|
|
1057
|
+
free(): void;
|
|
1147
1058
|
/**
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
* @param {Array} bits A left endian boolean array representing the bits plaintext.
|
|
1151
|
-
*
|
|
1152
|
-
* @returns {Plaintext} The plaintext object.
|
|
1059
|
+
* Creates from string.
|
|
1153
1060
|
*/
|
|
1154
|
-
static
|
|
1061
|
+
static fromString(s: string): I16;
|
|
1155
1062
|
/**
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1158
|
-
* @returns {Array} The left endian boolean array representation of the bits of the plaintext.
|
|
1063
|
+
* To string.
|
|
1159
1064
|
*/
|
|
1160
|
-
|
|
1065
|
+
toString(): string;
|
|
1161
1066
|
/**
|
|
1162
|
-
*
|
|
1163
|
-
*
|
|
1164
|
-
* @param {Array} fields An array of fields.
|
|
1165
|
-
*
|
|
1166
|
-
* @returns {Plaintext} The plaintext object.
|
|
1067
|
+
* From bytes (LE).
|
|
1167
1068
|
*/
|
|
1168
|
-
static
|
|
1069
|
+
static fromBytesLe(bytes: Uint8Array): I16;
|
|
1169
1070
|
/**
|
|
1170
|
-
*
|
|
1171
|
-
*
|
|
1172
|
-
* @returns {Array} The field array representation of the plaintext.
|
|
1071
|
+
* To bytes (LE).
|
|
1173
1072
|
*/
|
|
1174
|
-
|
|
1073
|
+
toBytesLe(): Uint8Array;
|
|
1175
1074
|
/**
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
* @returns {string} The string representation of the plaintext.
|
|
1075
|
+
* From bits.
|
|
1179
1076
|
*/
|
|
1180
|
-
|
|
1077
|
+
static fromBitsLe(bits: Array<any>): I16;
|
|
1181
1078
|
/**
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1184
|
-
* @returns {string} The type of the plaintext.
|
|
1079
|
+
* To bits.
|
|
1185
1080
|
*/
|
|
1186
|
-
|
|
1081
|
+
toBitsLe(): Array<any>;
|
|
1187
1082
|
/**
|
|
1188
|
-
*
|
|
1189
|
-
*
|
|
1190
|
-
* @returns {Object} The JS object representation of the plaintext.
|
|
1083
|
+
* Checked absolute value.
|
|
1191
1084
|
*/
|
|
1192
|
-
|
|
1193
|
-
}
|
|
1194
|
-
export class Poseidon2 {
|
|
1195
|
-
free(): void;
|
|
1085
|
+
absChecked(): I16;
|
|
1196
1086
|
/**
|
|
1197
|
-
*
|
|
1087
|
+
* Wrapped absolute value.
|
|
1198
1088
|
*/
|
|
1199
|
-
|
|
1089
|
+
absWrapped(): I16;
|
|
1200
1090
|
/**
|
|
1201
|
-
*
|
|
1091
|
+
* Wrapped addition.
|
|
1202
1092
|
*/
|
|
1203
|
-
|
|
1093
|
+
addWrapped(other: I16): I16;
|
|
1204
1094
|
/**
|
|
1205
|
-
*
|
|
1095
|
+
* Wrapped subtraction.
|
|
1206
1096
|
*/
|
|
1207
|
-
|
|
1097
|
+
subWrapped(other: I16): I16;
|
|
1208
1098
|
/**
|
|
1209
|
-
*
|
|
1099
|
+
* Wrapped multiplication.
|
|
1210
1100
|
*/
|
|
1211
|
-
|
|
1101
|
+
mulWrapped(other: I16): I16;
|
|
1212
1102
|
/**
|
|
1213
|
-
*
|
|
1103
|
+
* Wrapped division.
|
|
1214
1104
|
*/
|
|
1215
|
-
|
|
1105
|
+
divWrapped(other: I16): I16;
|
|
1216
1106
|
/**
|
|
1217
|
-
*
|
|
1107
|
+
* Power to a u8 exponent.
|
|
1218
1108
|
*/
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1221
|
-
export class Poseidon4 {
|
|
1222
|
-
free(): void;
|
|
1109
|
+
powU8(exponent: U8): I16;
|
|
1223
1110
|
/**
|
|
1224
|
-
*
|
|
1111
|
+
* Power to a u16 exponent.
|
|
1225
1112
|
*/
|
|
1226
|
-
|
|
1113
|
+
powU16(exponent: U16): I16;
|
|
1227
1114
|
/**
|
|
1228
|
-
*
|
|
1115
|
+
* Power to a u32 exponent.
|
|
1229
1116
|
*/
|
|
1230
|
-
|
|
1117
|
+
powU32(exponent: U32): I16;
|
|
1231
1118
|
/**
|
|
1232
|
-
*
|
|
1119
|
+
* Negates the integer (e.g., 5 → -5).
|
|
1233
1120
|
*/
|
|
1234
|
-
|
|
1121
|
+
neg(): I16;
|
|
1235
1122
|
/**
|
|
1236
|
-
*
|
|
1123
|
+
* Checks equality with another integer.
|
|
1237
1124
|
*/
|
|
1238
|
-
|
|
1125
|
+
equals(other: I16): boolean;
|
|
1239
1126
|
/**
|
|
1240
|
-
*
|
|
1127
|
+
* Remainder.
|
|
1241
1128
|
*/
|
|
1242
|
-
|
|
1129
|
+
rem(other: I16): I16;
|
|
1243
1130
|
/**
|
|
1244
|
-
*
|
|
1131
|
+
* Wrapped remainder.
|
|
1245
1132
|
*/
|
|
1246
|
-
|
|
1247
|
-
}
|
|
1248
|
-
export class Poseidon8 {
|
|
1249
|
-
free(): void;
|
|
1133
|
+
remWrapped(other: I16): I16;
|
|
1250
1134
|
/**
|
|
1251
|
-
*
|
|
1135
|
+
* Convert to Scalar.
|
|
1252
1136
|
*/
|
|
1253
|
-
|
|
1137
|
+
toScalar(): Scalar;
|
|
1254
1138
|
/**
|
|
1255
|
-
*
|
|
1139
|
+
* Convert to plaintext.
|
|
1256
1140
|
*/
|
|
1257
|
-
|
|
1141
|
+
toPlaintext(): Plaintext;
|
|
1258
1142
|
/**
|
|
1259
|
-
*
|
|
1143
|
+
* Convert from Field.
|
|
1260
1144
|
*/
|
|
1261
|
-
|
|
1145
|
+
static fromField(field: Field): I16;
|
|
1262
1146
|
/**
|
|
1263
|
-
*
|
|
1147
|
+
* Convert from Fields.
|
|
1264
1148
|
*/
|
|
1265
|
-
|
|
1149
|
+
static fromFields(fields: Array<any>): I16;
|
|
1266
1150
|
/**
|
|
1267
|
-
*
|
|
1151
|
+
* Clone.
|
|
1268
1152
|
*/
|
|
1269
|
-
|
|
1270
|
-
/**
|
|
1271
|
-
* Returns the Poseidon hash with an input rate of 8 on the affine curve.
|
|
1272
|
-
*/
|
|
1273
|
-
hashToGroup(input: Array<any>): Group;
|
|
1153
|
+
clone(): I16;
|
|
1274
1154
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
*/
|
|
1278
|
-
export class PrivateKey {
|
|
1155
|
+
export class I32 {
|
|
1156
|
+
private constructor();
|
|
1279
1157
|
free(): void;
|
|
1280
1158
|
/**
|
|
1281
|
-
*
|
|
1282
|
-
*
|
|
1283
|
-
* @returns {PrivateKey}
|
|
1159
|
+
* Creates from string.
|
|
1284
1160
|
*/
|
|
1285
|
-
|
|
1161
|
+
static fromString(s: string): I32;
|
|
1286
1162
|
/**
|
|
1287
|
-
*
|
|
1288
|
-
*
|
|
1289
|
-
* @param {Uint8Array} seed Unchecked 32 byte long Uint8Array acting as the seed for the private key
|
|
1290
|
-
* @returns {PrivateKey}
|
|
1163
|
+
* To string.
|
|
1291
1164
|
*/
|
|
1292
|
-
|
|
1165
|
+
toString(): string;
|
|
1293
1166
|
/**
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
1296
|
-
* @param {string} seed String representation of a private key
|
|
1297
|
-
* @returns {PrivateKey}
|
|
1167
|
+
* From bytes (LE).
|
|
1298
1168
|
*/
|
|
1299
|
-
static
|
|
1169
|
+
static fromBytesLe(bytes: Uint8Array): I32;
|
|
1300
1170
|
/**
|
|
1301
|
-
*
|
|
1302
|
-
* as it exposes the private key plaintext
|
|
1303
|
-
*
|
|
1304
|
-
* @returns {string} String representation of a private key
|
|
1171
|
+
* To bytes (LE).
|
|
1305
1172
|
*/
|
|
1306
|
-
|
|
1173
|
+
toBytesLe(): Uint8Array;
|
|
1307
1174
|
/**
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1310
|
-
* @returns {ViewKey}
|
|
1175
|
+
* From bits.
|
|
1311
1176
|
*/
|
|
1312
|
-
|
|
1177
|
+
static fromBitsLe(bits: Array<any>): I32;
|
|
1313
1178
|
/**
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1316
|
-
* @returns {Address}
|
|
1179
|
+
* To bits.
|
|
1317
1180
|
*/
|
|
1318
|
-
|
|
1181
|
+
toBitsLe(): Array<any>;
|
|
1319
1182
|
/**
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1322
|
-
* @param {Uint8Array} Byte array representing a message signed by the address
|
|
1323
|
-
* @returns {Signature} Signature generated by signing the message with the address
|
|
1183
|
+
* Checked absolute value.
|
|
1324
1184
|
*/
|
|
1325
|
-
|
|
1185
|
+
absChecked(): I32;
|
|
1326
1186
|
/**
|
|
1327
|
-
*
|
|
1328
|
-
* and will be needed to decrypt the private key later, so it should be stored securely
|
|
1329
|
-
*
|
|
1330
|
-
* @param {string} secret Secret used to encrypt the private key
|
|
1331
|
-
* @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
|
|
1187
|
+
* Wrapped absolute value.
|
|
1332
1188
|
*/
|
|
1333
|
-
|
|
1189
|
+
absWrapped(): I32;
|
|
1334
1190
|
/**
|
|
1335
|
-
*
|
|
1336
|
-
* decrypt the private key later, so it should be stored securely
|
|
1337
|
-
*
|
|
1338
|
-
* @param {string} secret Secret used to encrypt the private key
|
|
1339
|
-
* @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
|
|
1191
|
+
* Wrapped addition.
|
|
1340
1192
|
*/
|
|
1341
|
-
|
|
1193
|
+
addWrapped(other: I32): I32;
|
|
1342
1194
|
/**
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1345
|
-
* @param {PrivateKeyCiphertext} ciphertext Ciphertext representation of the private key
|
|
1346
|
-
* @param {string} secret Secret originally used to encrypt the private key
|
|
1347
|
-
* @returns {PrivateKey} Private key
|
|
1195
|
+
* Wrapped subtraction.
|
|
1348
1196
|
*/
|
|
1349
|
-
|
|
1197
|
+
subWrapped(other: I32): I32;
|
|
1198
|
+
/**
|
|
1199
|
+
* Wrapped multiplication.
|
|
1200
|
+
*/
|
|
1201
|
+
mulWrapped(other: I32): I32;
|
|
1202
|
+
/**
|
|
1203
|
+
* Wrapped division.
|
|
1204
|
+
*/
|
|
1205
|
+
divWrapped(other: I32): I32;
|
|
1206
|
+
/**
|
|
1207
|
+
* Power to a u8 exponent.
|
|
1208
|
+
*/
|
|
1209
|
+
powU8(exponent: U8): I32;
|
|
1210
|
+
/**
|
|
1211
|
+
* Power to a u16 exponent.
|
|
1212
|
+
*/
|
|
1213
|
+
powU16(exponent: U16): I32;
|
|
1214
|
+
/**
|
|
1215
|
+
* Power to a u32 exponent.
|
|
1216
|
+
*/
|
|
1217
|
+
powU32(exponent: U32): I32;
|
|
1218
|
+
/**
|
|
1219
|
+
* Negates the integer (e.g., 5 → -5).
|
|
1220
|
+
*/
|
|
1221
|
+
neg(): I32;
|
|
1222
|
+
/**
|
|
1223
|
+
* Checks equality with another integer.
|
|
1224
|
+
*/
|
|
1225
|
+
equals(other: I32): boolean;
|
|
1226
|
+
/**
|
|
1227
|
+
* Remainder.
|
|
1228
|
+
*/
|
|
1229
|
+
rem(other: I32): I32;
|
|
1230
|
+
/**
|
|
1231
|
+
* Wrapped remainder.
|
|
1232
|
+
*/
|
|
1233
|
+
remWrapped(other: I32): I32;
|
|
1234
|
+
/**
|
|
1235
|
+
* Convert to Scalar.
|
|
1236
|
+
*/
|
|
1237
|
+
toScalar(): Scalar;
|
|
1238
|
+
/**
|
|
1239
|
+
* Convert to plaintext.
|
|
1240
|
+
*/
|
|
1241
|
+
toPlaintext(): Plaintext;
|
|
1242
|
+
/**
|
|
1243
|
+
* Convert from Field.
|
|
1244
|
+
*/
|
|
1245
|
+
static fromField(field: Field): I32;
|
|
1246
|
+
/**
|
|
1247
|
+
* Convert from Fields.
|
|
1248
|
+
*/
|
|
1249
|
+
static fromFields(fields: Array<any>): I32;
|
|
1250
|
+
/**
|
|
1251
|
+
* Clone.
|
|
1252
|
+
*/
|
|
1253
|
+
clone(): I32;
|
|
1350
1254
|
}
|
|
1351
|
-
|
|
1352
|
-
* Private Key in ciphertext form
|
|
1353
|
-
*/
|
|
1354
|
-
export class PrivateKeyCiphertext {
|
|
1255
|
+
export class I64 {
|
|
1355
1256
|
private constructor();
|
|
1356
1257
|
free(): void;
|
|
1357
1258
|
/**
|
|
1358
|
-
*
|
|
1359
|
-
* decrypt the private key later, so it should be stored securely
|
|
1360
|
-
*
|
|
1361
|
-
* @param {PrivateKey} private_key Private key to encrypt
|
|
1362
|
-
* @param {string} secret Secret to encrypt the private key with
|
|
1363
|
-
* @returns {PrivateKeyCiphertext} Private key ciphertext
|
|
1259
|
+
* Creates from string.
|
|
1364
1260
|
*/
|
|
1365
|
-
static
|
|
1261
|
+
static fromString(s: string): I64;
|
|
1366
1262
|
/**
|
|
1367
|
-
*
|
|
1368
|
-
* encrypt the private key
|
|
1369
|
-
*
|
|
1370
|
-
* @param {string} secret Secret used to encrypt the private key
|
|
1371
|
-
* @returns {PrivateKey} Private key
|
|
1263
|
+
* To string.
|
|
1372
1264
|
*/
|
|
1373
|
-
|
|
1265
|
+
toString(): string;
|
|
1374
1266
|
/**
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1377
|
-
* @returns {string} Ciphertext string
|
|
1267
|
+
* From bytes (LE).
|
|
1378
1268
|
*/
|
|
1379
|
-
|
|
1269
|
+
static fromBytesLe(bytes: Uint8Array): I64;
|
|
1380
1270
|
/**
|
|
1381
|
-
*
|
|
1382
|
-
*
|
|
1383
|
-
* @param {string} ciphertext Ciphertext string
|
|
1384
|
-
* @returns {PrivateKeyCiphertext} Private key ciphertext
|
|
1271
|
+
* To bytes (LE).
|
|
1385
1272
|
*/
|
|
1386
|
-
|
|
1273
|
+
toBytesLe(): Uint8Array;
|
|
1274
|
+
/**
|
|
1275
|
+
* From bits.
|
|
1276
|
+
*/
|
|
1277
|
+
static fromBitsLe(bits: Array<any>): I64;
|
|
1278
|
+
/**
|
|
1279
|
+
* To bits.
|
|
1280
|
+
*/
|
|
1281
|
+
toBitsLe(): Array<any>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Checked absolute value.
|
|
1284
|
+
*/
|
|
1285
|
+
absChecked(): I64;
|
|
1286
|
+
/**
|
|
1287
|
+
* Wrapped absolute value.
|
|
1288
|
+
*/
|
|
1289
|
+
absWrapped(): I64;
|
|
1290
|
+
/**
|
|
1291
|
+
* Wrapped addition.
|
|
1292
|
+
*/
|
|
1293
|
+
addWrapped(other: I64): I64;
|
|
1294
|
+
/**
|
|
1295
|
+
* Wrapped subtraction.
|
|
1296
|
+
*/
|
|
1297
|
+
subWrapped(other: I64): I64;
|
|
1298
|
+
/**
|
|
1299
|
+
* Wrapped multiplication.
|
|
1300
|
+
*/
|
|
1301
|
+
mulWrapped(other: I64): I64;
|
|
1302
|
+
/**
|
|
1303
|
+
* Wrapped division.
|
|
1304
|
+
*/
|
|
1305
|
+
divWrapped(other: I64): I64;
|
|
1306
|
+
/**
|
|
1307
|
+
* Power to a u8 exponent.
|
|
1308
|
+
*/
|
|
1309
|
+
powU8(exponent: U8): I64;
|
|
1310
|
+
/**
|
|
1311
|
+
* Power to a u16 exponent.
|
|
1312
|
+
*/
|
|
1313
|
+
powU16(exponent: U16): I64;
|
|
1314
|
+
/**
|
|
1315
|
+
* Power to a u32 exponent.
|
|
1316
|
+
*/
|
|
1317
|
+
powU32(exponent: U32): I64;
|
|
1318
|
+
/**
|
|
1319
|
+
* Negates the integer (e.g., 5 → -5).
|
|
1320
|
+
*/
|
|
1321
|
+
neg(): I64;
|
|
1322
|
+
/**
|
|
1323
|
+
* Checks equality with another integer.
|
|
1324
|
+
*/
|
|
1325
|
+
equals(other: I64): boolean;
|
|
1326
|
+
/**
|
|
1327
|
+
* Remainder.
|
|
1328
|
+
*/
|
|
1329
|
+
rem(other: I64): I64;
|
|
1330
|
+
/**
|
|
1331
|
+
* Wrapped remainder.
|
|
1332
|
+
*/
|
|
1333
|
+
remWrapped(other: I64): I64;
|
|
1334
|
+
/**
|
|
1335
|
+
* Convert to Scalar.
|
|
1336
|
+
*/
|
|
1337
|
+
toScalar(): Scalar;
|
|
1338
|
+
/**
|
|
1339
|
+
* Convert to plaintext.
|
|
1340
|
+
*/
|
|
1341
|
+
toPlaintext(): Plaintext;
|
|
1342
|
+
/**
|
|
1343
|
+
* Convert from Field.
|
|
1344
|
+
*/
|
|
1345
|
+
static fromField(field: Field): I64;
|
|
1346
|
+
/**
|
|
1347
|
+
* Convert from Fields.
|
|
1348
|
+
*/
|
|
1349
|
+
static fromFields(fields: Array<any>): I64;
|
|
1350
|
+
/**
|
|
1351
|
+
* Clone.
|
|
1352
|
+
*/
|
|
1353
|
+
clone(): I64;
|
|
1387
1354
|
}
|
|
1388
|
-
|
|
1389
|
-
* Webassembly Representation of an Aleo program
|
|
1390
|
-
*/
|
|
1391
|
-
export class Program {
|
|
1355
|
+
export class I8 {
|
|
1392
1356
|
private constructor();
|
|
1393
1357
|
free(): void;
|
|
1394
1358
|
/**
|
|
1395
|
-
*
|
|
1396
|
-
*
|
|
1397
|
-
* @param {string} program Aleo program source code
|
|
1398
|
-
* @returns {Program} Program object
|
|
1359
|
+
* Creates from string.
|
|
1399
1360
|
*/
|
|
1400
|
-
static fromString(
|
|
1361
|
+
static fromString(s: string): I8;
|
|
1401
1362
|
/**
|
|
1402
|
-
*
|
|
1403
|
-
*
|
|
1404
|
-
* @returns {string} String containing the program source code
|
|
1363
|
+
* To string.
|
|
1405
1364
|
*/
|
|
1406
1365
|
toString(): string;
|
|
1407
1366
|
/**
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1410
|
-
* @param {string} functionName Name of the function to check for
|
|
1411
|
-
* @returns {boolean} True if the program is valid, false otherwise
|
|
1367
|
+
* From bytes (LE).
|
|
1412
1368
|
*/
|
|
1413
|
-
|
|
1369
|
+
static fromBytesLe(bytes: Uint8Array): I8;
|
|
1414
1370
|
/**
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
* @returns {Array} Array of all function names present in the program
|
|
1418
|
-
*
|
|
1419
|
-
* @example
|
|
1420
|
-
* const expected_functions = [
|
|
1421
|
-
* "mint",
|
|
1422
|
-
* "transfer_private",
|
|
1423
|
-
* "transfer_private_to_public",
|
|
1424
|
-
* "transfer_public",
|
|
1425
|
-
* "transfer_public_to_private",
|
|
1426
|
-
* "join",
|
|
1427
|
-
* "split",
|
|
1428
|
-
* "fee"
|
|
1429
|
-
* ]
|
|
1430
|
-
*
|
|
1431
|
-
* const credits_program = aleo_wasm.Program.getCreditsProgram();
|
|
1432
|
-
* const credits_functions = credits_program.getFunctions();
|
|
1433
|
-
* console.log(credits_functions === expected_functions); // Output should be "true"
|
|
1371
|
+
* To bytes (LE).
|
|
1434
1372
|
*/
|
|
1435
|
-
|
|
1373
|
+
toBytesLe(): Uint8Array;
|
|
1436
1374
|
/**
|
|
1437
|
-
*
|
|
1438
|
-
* to generate a web form to capture user inputs for an execution of a function.
|
|
1439
|
-
*
|
|
1440
|
-
* @param {string} function_name Name of the function to get inputs for
|
|
1441
|
-
* @returns {Array} Array of function inputs
|
|
1442
|
-
*
|
|
1443
|
-
* @example
|
|
1444
|
-
* const expected_inputs = [
|
|
1445
|
-
* {
|
|
1446
|
-
* type:"record",
|
|
1447
|
-
* visibility:"private",
|
|
1448
|
-
* record:"credits",
|
|
1449
|
-
* members:[
|
|
1450
|
-
* {
|
|
1451
|
-
* name:"microcredits",
|
|
1452
|
-
* type:"u64",
|
|
1453
|
-
* visibility:"private"
|
|
1454
|
-
* }
|
|
1455
|
-
* ],
|
|
1456
|
-
* register:"r0"
|
|
1457
|
-
* },
|
|
1458
|
-
* {
|
|
1459
|
-
* type:"address",
|
|
1460
|
-
* visibility:"private",
|
|
1461
|
-
* register:"r1"
|
|
1462
|
-
* },
|
|
1463
|
-
* {
|
|
1464
|
-
* type:"u64",
|
|
1465
|
-
* visibility:"private",
|
|
1466
|
-
* register:"r2"
|
|
1467
|
-
* }
|
|
1468
|
-
* ];
|
|
1469
|
-
*
|
|
1470
|
-
* const credits_program = aleo_wasm.Program.getCreditsProgram();
|
|
1471
|
-
* const transfer_function_inputs = credits_program.getFunctionInputs("transfer_private");
|
|
1472
|
-
* console.log(transfer_function_inputs === expected_inputs); // Output should be "true"
|
|
1375
|
+
* From bits.
|
|
1473
1376
|
*/
|
|
1474
|
-
|
|
1377
|
+
static fromBitsLe(bits: Array<any>): I8;
|
|
1475
1378
|
/**
|
|
1476
|
-
*
|
|
1477
|
-
*
|
|
1478
|
-
* @returns {Array} - An array of objects representing the mappings in the program
|
|
1479
|
-
* @example
|
|
1480
|
-
* const expected_mappings = [
|
|
1481
|
-
* {
|
|
1482
|
-
* name: "account",
|
|
1483
|
-
* key_name: "owner",
|
|
1484
|
-
* key_type: "address",
|
|
1485
|
-
* value_name: "microcredits",
|
|
1486
|
-
* value_type: "u64"
|
|
1487
|
-
* }
|
|
1488
|
-
* ]
|
|
1489
|
-
*
|
|
1490
|
-
* const credits_program = aleo_wasm.Program.getCreditsProgram();
|
|
1491
|
-
* const credits_mappings = credits_program.getMappings();
|
|
1492
|
-
* console.log(credits_mappings === expected_mappings); // Output should be "true"
|
|
1379
|
+
* To bits.
|
|
1493
1380
|
*/
|
|
1494
|
-
|
|
1381
|
+
toBitsLe(): Array<any>;
|
|
1495
1382
|
/**
|
|
1496
|
-
*
|
|
1383
|
+
* Checked absolute value.
|
|
1384
|
+
*/
|
|
1385
|
+
absChecked(): I8;
|
|
1386
|
+
/**
|
|
1387
|
+
* Wrapped absolute value.
|
|
1388
|
+
*/
|
|
1389
|
+
absWrapped(): I8;
|
|
1390
|
+
/**
|
|
1391
|
+
* Wrapped addition.
|
|
1392
|
+
*/
|
|
1393
|
+
addWrapped(other: I8): I8;
|
|
1394
|
+
/**
|
|
1395
|
+
* Wrapped subtraction.
|
|
1396
|
+
*/
|
|
1397
|
+
subWrapped(other: I8): I8;
|
|
1398
|
+
/**
|
|
1399
|
+
* Wrapped multiplication.
|
|
1400
|
+
*/
|
|
1401
|
+
mulWrapped(other: I8): I8;
|
|
1402
|
+
/**
|
|
1403
|
+
* Wrapped division.
|
|
1404
|
+
*/
|
|
1405
|
+
divWrapped(other: I8): I8;
|
|
1406
|
+
/**
|
|
1407
|
+
* Power to a u8 exponent.
|
|
1408
|
+
*/
|
|
1409
|
+
powU8(exponent: U8): I8;
|
|
1410
|
+
/**
|
|
1411
|
+
* Power to a u16 exponent.
|
|
1412
|
+
*/
|
|
1413
|
+
powU16(exponent: U16): I8;
|
|
1414
|
+
/**
|
|
1415
|
+
* Power to a u32 exponent.
|
|
1416
|
+
*/
|
|
1417
|
+
powU32(exponent: U32): I8;
|
|
1418
|
+
/**
|
|
1419
|
+
* Negates the integer (e.g., 5 → -5).
|
|
1420
|
+
*/
|
|
1421
|
+
neg(): I8;
|
|
1422
|
+
/**
|
|
1423
|
+
* Checks equality with another integer.
|
|
1424
|
+
*/
|
|
1425
|
+
equals(other: I8): boolean;
|
|
1426
|
+
/**
|
|
1427
|
+
* Remainder.
|
|
1428
|
+
*/
|
|
1429
|
+
rem(other: I8): I8;
|
|
1430
|
+
/**
|
|
1431
|
+
* Wrapped remainder.
|
|
1432
|
+
*/
|
|
1433
|
+
remWrapped(other: I8): I8;
|
|
1434
|
+
/**
|
|
1435
|
+
* Convert to Scalar.
|
|
1436
|
+
*/
|
|
1437
|
+
toScalar(): Scalar;
|
|
1438
|
+
/**
|
|
1439
|
+
* Convert to plaintext.
|
|
1440
|
+
*/
|
|
1441
|
+
toPlaintext(): Plaintext;
|
|
1442
|
+
/**
|
|
1443
|
+
* Convert from Field.
|
|
1444
|
+
*/
|
|
1445
|
+
static fromField(field: Field): I8;
|
|
1446
|
+
/**
|
|
1447
|
+
* Convert from Fields.
|
|
1448
|
+
*/
|
|
1449
|
+
static fromFields(fields: Array<any>): I8;
|
|
1450
|
+
/**
|
|
1451
|
+
* Clone.
|
|
1452
|
+
*/
|
|
1453
|
+
clone(): I8;
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* Key pair object containing both the function proving and verifying keys
|
|
1457
|
+
*/
|
|
1458
|
+
export class KeyPair {
|
|
1459
|
+
free(): void;
|
|
1460
|
+
/**
|
|
1461
|
+
* Create new key pair from proving and verifying keys
|
|
1462
|
+
*
|
|
1463
|
+
* @param {ProvingKey} proving_key Proving key corresponding to a function in an Aleo program
|
|
1464
|
+
* @param {VerifyingKey} verifying_key Verifying key corresponding to a function in an Aleo program
|
|
1465
|
+
* @returns {KeyPair} Key pair object containing both the function proving and verifying keys
|
|
1466
|
+
*/
|
|
1467
|
+
constructor(proving_key: ProvingKey, verifying_key: VerifyingKey);
|
|
1468
|
+
/**
|
|
1469
|
+
* Get the proving key. This method will remove the proving key from the key pair
|
|
1470
|
+
*
|
|
1471
|
+
* @returns {ProvingKey}
|
|
1472
|
+
*/
|
|
1473
|
+
provingKey(): ProvingKey;
|
|
1474
|
+
/**
|
|
1475
|
+
* Get the verifying key. This method will remove the verifying key from the key pair
|
|
1476
|
+
*
|
|
1477
|
+
* @returns {VerifyingKey}
|
|
1478
|
+
*/
|
|
1479
|
+
verifyingKey(): VerifyingKey;
|
|
1480
|
+
}
|
|
1481
|
+
export class Metadata {
|
|
1482
|
+
private constructor();
|
|
1483
|
+
free(): void;
|
|
1484
|
+
static baseUrl(): string;
|
|
1485
|
+
static bond_public(): Metadata;
|
|
1486
|
+
static bond_validator(): Metadata;
|
|
1487
|
+
static claim_unbond_public(): Metadata;
|
|
1488
|
+
static fee_private(): Metadata;
|
|
1489
|
+
static fee_public(): Metadata;
|
|
1490
|
+
static inclusion(): Metadata;
|
|
1491
|
+
static join(): Metadata;
|
|
1492
|
+
static set_validator_state(): Metadata;
|
|
1493
|
+
static split(): Metadata;
|
|
1494
|
+
static transfer_private(): Metadata;
|
|
1495
|
+
static transfer_private_to_public(): Metadata;
|
|
1496
|
+
static transfer_public(): Metadata;
|
|
1497
|
+
static transfer_public_as_signer(): Metadata;
|
|
1498
|
+
static transfer_public_to_private(): Metadata;
|
|
1499
|
+
static unbond_public(): Metadata;
|
|
1500
|
+
name: string;
|
|
1501
|
+
locator: string;
|
|
1502
|
+
prover: string;
|
|
1503
|
+
verifier: string;
|
|
1504
|
+
verifyingKey: string;
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* An offline query object used to insert the global state root and state paths needed to create
|
|
1508
|
+
* a valid inclusion proof offline.
|
|
1509
|
+
*/
|
|
1510
|
+
export class OfflineQuery {
|
|
1511
|
+
free(): void;
|
|
1512
|
+
/**
|
|
1513
|
+
* Creates a new offline query object. The state root is required to be passed in as a string
|
|
1514
|
+
*
|
|
1515
|
+
* @param {u32} block_height The block height.
|
|
1516
|
+
* @param {string} state_root The state root of the current network.
|
|
1517
|
+
*
|
|
1518
|
+
* @returns {OfflineQuery} The newly created offline query object.
|
|
1519
|
+
*/
|
|
1520
|
+
constructor(block_height: number, state_root: string);
|
|
1521
|
+
/**
|
|
1522
|
+
* Add a new block height to the offline query object.
|
|
1523
|
+
*
|
|
1524
|
+
* @param {u32} block_height The block height to add.
|
|
1525
|
+
*/
|
|
1526
|
+
addBlockHeight(block_height: number): void;
|
|
1527
|
+
/**
|
|
1528
|
+
* Add a new state path to the offline query object.
|
|
1529
|
+
*
|
|
1530
|
+
* @param {string} commitment: The commitment corresponding to a record input.
|
|
1531
|
+
* @param {string} state_path: The state path corresponding to the commitment.
|
|
1532
|
+
*/
|
|
1533
|
+
addStatePath(commitment: string, state_path: string): void;
|
|
1534
|
+
/**
|
|
1535
|
+
* Get a json string representation of the offline query object.
|
|
1536
|
+
*
|
|
1537
|
+
* @returns {string} JSON string representation of the offline query object.
|
|
1538
|
+
*/
|
|
1539
|
+
toString(): string;
|
|
1540
|
+
/**
|
|
1541
|
+
* Create an offline query object from a json string representation.
|
|
1542
|
+
*
|
|
1543
|
+
* @param {string} JSON string representation of the offline query object.
|
|
1544
|
+
*/
|
|
1545
|
+
static fromString(s: string): OfflineQuery;
|
|
1546
|
+
}
|
|
1547
|
+
export class Pedersen128 {
|
|
1548
|
+
free(): void;
|
|
1549
|
+
/**
|
|
1550
|
+
* Create a Pedersen hasher for a given (up to) 128-bit input.
|
|
1551
|
+
*/
|
|
1552
|
+
constructor();
|
|
1553
|
+
/**
|
|
1554
|
+
* Create a Pedersen hasher for a given (up to) 128-bit input with a custom domain separator.
|
|
1555
|
+
*/
|
|
1556
|
+
static setup(domain_separator: string): Pedersen128;
|
|
1557
|
+
/**
|
|
1558
|
+
* Returns the Pedersen hash for a given (up to) 128-bit input.
|
|
1559
|
+
*/
|
|
1560
|
+
hash(input: Array<any>): Field;
|
|
1561
|
+
/**
|
|
1562
|
+
* Returns a Pedersen commitment for the given (up to) 128-bit input and randomizer.
|
|
1563
|
+
*/
|
|
1564
|
+
commit(input: Array<any>, randomizer: Scalar): Field;
|
|
1565
|
+
/**
|
|
1566
|
+
* Returns a Pedersen commitment for the given (up to) 128-bit input and randomizer.
|
|
1567
|
+
*/
|
|
1568
|
+
commitToGroup(input: Array<any>, randomizer: Scalar): Group;
|
|
1569
|
+
}
|
|
1570
|
+
export class Pedersen64 {
|
|
1571
|
+
free(): void;
|
|
1572
|
+
/**
|
|
1573
|
+
* Create a Pedersen hasher for a given (up to) 64-bit input.
|
|
1574
|
+
*/
|
|
1575
|
+
constructor();
|
|
1576
|
+
/**
|
|
1577
|
+
* Create a Pedersen64 hasher for a given (up to) 64-bit input with a custom domain separator.
|
|
1578
|
+
*/
|
|
1579
|
+
static setup(domain_separator: string): Pedersen64;
|
|
1580
|
+
/**
|
|
1581
|
+
* Returns the Pedersen hash for a given (up to) 64-bit input.
|
|
1582
|
+
*/
|
|
1583
|
+
hash(input: Array<any>): Field;
|
|
1584
|
+
/**
|
|
1585
|
+
* Returns a Pedersen commitment for the given (up to) 64-bit input and randomizer.
|
|
1586
|
+
*/
|
|
1587
|
+
commit(input: Array<any>, randomizer: Scalar): Field;
|
|
1588
|
+
/**
|
|
1589
|
+
* Returns a Pedersen commitment for the given (up to) 64-bit input and randomizer.
|
|
1590
|
+
*/
|
|
1591
|
+
commitToGroup(input: Array<any>, randomizer: Scalar): Group;
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* SnarkVM Plaintext object. Plaintext is a fundamental monadic type used to represent Aleo
|
|
1595
|
+
* primitive types (boolean, field, group, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128,
|
|
1596
|
+
* scalar, and signature), struct types, and array types.
|
|
1597
|
+
*
|
|
1598
|
+
* In the context of a web or NodeJS application, this type is useful for turning an Aleo type into
|
|
1599
|
+
* a JS value, object, or array that might be necessary for performing computations within the
|
|
1600
|
+
* application.
|
|
1601
|
+
*
|
|
1602
|
+
* @example
|
|
1603
|
+
* // Get the bond state of an existing address.
|
|
1604
|
+
* const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
|
|
1605
|
+
* // Convert the bond state to a Plaintext object.
|
|
1606
|
+
* const bondStatePlaintext = Plaintext.fromString(bond_state);
|
|
1607
|
+
* // Convert the Plaintext object to a JS object.
|
|
1608
|
+
* const bondStateObject = bond_state_plaintext.toObject();
|
|
1609
|
+
* // Check if the bond state matches the expected object.
|
|
1610
|
+
* const expectedObject = { validator: "aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f", microcredits: 100000000u64 };
|
|
1611
|
+
* assert( JSON.stringify(bondStateObject) === JSON.stringify(expectedObject) );
|
|
1612
|
+
*/
|
|
1613
|
+
export class Plaintext {
|
|
1614
|
+
private constructor();
|
|
1615
|
+
free(): void;
|
|
1616
|
+
/**
|
|
1617
|
+
* Find plaintext member if the plaintext is a struct. Returns `null` if the plaintext is not
|
|
1618
|
+
* a struct or the member does not exist.
|
|
1619
|
+
*
|
|
1620
|
+
* @param {string} name The name of the plaintext member to find.
|
|
1621
|
+
*
|
|
1622
|
+
* @returns {Plaintext} The plaintext member.
|
|
1623
|
+
*/
|
|
1624
|
+
find(name: string): Plaintext;
|
|
1625
|
+
/**
|
|
1626
|
+
* Encrypt a plaintext with an address and randomizer.
|
|
1627
|
+
*
|
|
1628
|
+
* @param {Address} address The address to encrypt the plaintext for.
|
|
1629
|
+
* @param {Scalar} randomizer The randomizer to use for encryption.
|
|
1630
|
+
*
|
|
1631
|
+
* @returns {Ciphertext} The encrypted ciphertext.
|
|
1632
|
+
*/
|
|
1633
|
+
encrypt(address: Address, randomizer: Scalar): Ciphertext;
|
|
1634
|
+
/**
|
|
1635
|
+
* Encrypt a plaintext with a transition view key.
|
|
1636
|
+
*
|
|
1637
|
+
* @param {Field} transition_view_key The transition view key of the transition
|
|
1638
|
+
* associated with the plaintext.
|
|
1639
|
+
*
|
|
1640
|
+
* @returns {Ciphertext} The encrypted ciphertext.
|
|
1641
|
+
*/
|
|
1642
|
+
encryptSymmetric(transition_view_key: Field): Ciphertext;
|
|
1643
|
+
/**
|
|
1644
|
+
* Creates a plaintext object from a string representation of a plaintext.
|
|
1645
|
+
*
|
|
1646
|
+
* @param {string} plaintext The string representation of the plaintext.
|
|
1647
|
+
*
|
|
1648
|
+
* @returns {Plaintext} The plaintext object.
|
|
1649
|
+
*/
|
|
1650
|
+
static fromString(plaintext: string): Plaintext;
|
|
1651
|
+
/**
|
|
1652
|
+
* Get a plaintext object from a series of bytes.
|
|
1653
|
+
*
|
|
1654
|
+
* @param {Uint8Array} bytes A left endian byte array representing the plaintext.
|
|
1655
|
+
*
|
|
1656
|
+
* @returns {Plaintext} The plaintext object.
|
|
1657
|
+
*/
|
|
1658
|
+
static fromBytesLe(bytes: Uint8Array): Plaintext;
|
|
1659
|
+
/**
|
|
1660
|
+
* Get the left endian byte array representation of the plaintext.
|
|
1661
|
+
*
|
|
1662
|
+
* @returns {Uint8Array} The left endian byte array representation of the plaintext.
|
|
1663
|
+
*/
|
|
1664
|
+
toBytesLe(): Uint8Array;
|
|
1665
|
+
/**
|
|
1666
|
+
* Get a plaintext object from a series of bits represented as a boolean array.
|
|
1667
|
+
*
|
|
1668
|
+
* @param {Array} bits A left endian boolean array representing the bits plaintext.
|
|
1669
|
+
*
|
|
1670
|
+
* @returns {Plaintext} The plaintext object.
|
|
1671
|
+
*/
|
|
1672
|
+
static fromBitsLe(bits: Array<any>): Plaintext;
|
|
1673
|
+
/**
|
|
1674
|
+
* Get the left endian boolean array representation of the bits of the plaintext.
|
|
1675
|
+
*
|
|
1676
|
+
* @returns {Array} The left endian boolean array representation of the bits of the plaintext.
|
|
1677
|
+
*/
|
|
1678
|
+
toBitsLe(): Array<any>;
|
|
1679
|
+
/**
|
|
1680
|
+
* Get a plaintext object from an array of fields.
|
|
1681
|
+
*
|
|
1682
|
+
* @param {Array} fields An array of fields.
|
|
1683
|
+
*
|
|
1684
|
+
* @returns {Plaintext} The plaintext object.
|
|
1685
|
+
*/
|
|
1686
|
+
static fromFields(fields: Array<any>): Plaintext;
|
|
1687
|
+
/**
|
|
1688
|
+
* Get the field array representation of the plaintext.
|
|
1689
|
+
*
|
|
1690
|
+
* @returns {Array} The field array representation of the plaintext.
|
|
1691
|
+
*/
|
|
1692
|
+
toFields(): Array<any>;
|
|
1693
|
+
/**
|
|
1694
|
+
* Returns the string representation of the plaintext.
|
|
1695
|
+
*
|
|
1696
|
+
* @returns {string} The string representation of the plaintext.
|
|
1697
|
+
*/
|
|
1698
|
+
toString(): string;
|
|
1699
|
+
/**
|
|
1700
|
+
* Gives the type of the plaintext.
|
|
1701
|
+
*
|
|
1702
|
+
* @returns {string} The type of the plaintext.
|
|
1703
|
+
*/
|
|
1704
|
+
plaintextType(): string;
|
|
1705
|
+
/**
|
|
1706
|
+
* Attempt to convert the plaintext to a JS object.
|
|
1707
|
+
*
|
|
1708
|
+
* @returns {Object} The JS object representation of the plaintext.
|
|
1709
|
+
*/
|
|
1710
|
+
toObject(): any;
|
|
1711
|
+
}
|
|
1712
|
+
export class Poseidon2 {
|
|
1713
|
+
free(): void;
|
|
1714
|
+
/**
|
|
1715
|
+
* Create a Poseidon hasher with an input rate of 2.
|
|
1716
|
+
*/
|
|
1717
|
+
constructor();
|
|
1718
|
+
/**
|
|
1719
|
+
* Create a Poseidon hasher with an input rate of 2 and a custom domain separator.
|
|
1720
|
+
*/
|
|
1721
|
+
static setup(domain_separator: string): Poseidon2;
|
|
1722
|
+
/**
|
|
1723
|
+
* Returns the Poseidon hash with an input rate of 2.
|
|
1724
|
+
*/
|
|
1725
|
+
hash(input: Array<any>): Field;
|
|
1726
|
+
/**
|
|
1727
|
+
* Returns the extended Poseidon hash with an input rate of 2.
|
|
1728
|
+
*/
|
|
1729
|
+
hashMany(input: Array<any>, num_outputs: number): Array<any>;
|
|
1730
|
+
/**
|
|
1731
|
+
* Returns the Poseidon hash with an input rate of 2 on the scalar field.
|
|
1732
|
+
*/
|
|
1733
|
+
hashToScalar(input: Array<any>): Scalar;
|
|
1734
|
+
/**
|
|
1735
|
+
* Returns the Poseidon hash with an input rate of 2 on the affine curve.
|
|
1736
|
+
*/
|
|
1737
|
+
hashToGroup(input: Array<any>): Group;
|
|
1738
|
+
}
|
|
1739
|
+
export class Poseidon4 {
|
|
1740
|
+
free(): void;
|
|
1741
|
+
/**
|
|
1742
|
+
* Create a Poseidon hasher with an input rate of 4.
|
|
1743
|
+
*/
|
|
1744
|
+
constructor();
|
|
1745
|
+
/**
|
|
1746
|
+
* Create a Poseidon hasher with an input rate of 4 and a custom domain separator.
|
|
1747
|
+
*/
|
|
1748
|
+
static setup(domain_separator: string): Poseidon4;
|
|
1749
|
+
/**
|
|
1750
|
+
* Returns the Poseidon hash with an input rate of 4.
|
|
1751
|
+
*/
|
|
1752
|
+
hash(input: Array<any>): Field;
|
|
1753
|
+
/**
|
|
1754
|
+
* Returns the extended Poseidon hash with an input rate of 4.
|
|
1755
|
+
*/
|
|
1756
|
+
hashMany(input: Array<any>, num_outputs: number): Array<any>;
|
|
1757
|
+
/**
|
|
1758
|
+
* Returns the Poseidon hash with an input rate of 4 on the scalar field.
|
|
1759
|
+
*/
|
|
1760
|
+
hashToScalar(input: Array<any>): Scalar;
|
|
1761
|
+
/**
|
|
1762
|
+
* Returns the Poseidon hash with an input rate of 4 on the affine curve.
|
|
1763
|
+
*/
|
|
1764
|
+
hashToGroup(input: Array<any>): Group;
|
|
1765
|
+
}
|
|
1766
|
+
export class Poseidon8 {
|
|
1767
|
+
free(): void;
|
|
1768
|
+
/**
|
|
1769
|
+
* Create a Poseidon hasher with an input rate of 8.
|
|
1770
|
+
*/
|
|
1771
|
+
constructor();
|
|
1772
|
+
/**
|
|
1773
|
+
* Create a Poseidon hasher with an input rate of 8 and a custom domain separator.
|
|
1774
|
+
*/
|
|
1775
|
+
static setup(domain_separator: string): Poseidon8;
|
|
1776
|
+
/**
|
|
1777
|
+
* Returns the Poseidon hash with an input rate of 8.
|
|
1778
|
+
*/
|
|
1779
|
+
hash(input: Array<any>): Field;
|
|
1780
|
+
/**
|
|
1781
|
+
* Returns the extended Poseidon hash with an input rate of 8.
|
|
1782
|
+
*/
|
|
1783
|
+
hashMany(input: Array<any>, num_outputs: number): Array<any>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Returns the Poseidon hash with an input rate of 8 on the scalar field.
|
|
1786
|
+
*/
|
|
1787
|
+
hashToScalar(input: Array<any>): Scalar;
|
|
1788
|
+
/**
|
|
1789
|
+
* Returns the Poseidon hash with an input rate of 8 on the affine curve.
|
|
1790
|
+
*/
|
|
1791
|
+
hashToGroup(input: Array<any>): Group;
|
|
1792
|
+
}
|
|
1793
|
+
/**
|
|
1794
|
+
* Private key of an Aleo account
|
|
1795
|
+
*/
|
|
1796
|
+
export class PrivateKey {
|
|
1797
|
+
free(): void;
|
|
1798
|
+
/**
|
|
1799
|
+
* Generate a new private key using a cryptographically secure random number generator
|
|
1800
|
+
*
|
|
1801
|
+
* @returns {PrivateKey}
|
|
1802
|
+
*/
|
|
1803
|
+
constructor();
|
|
1804
|
+
/**
|
|
1805
|
+
* Get a private key from a series of unchecked bytes
|
|
1806
|
+
*
|
|
1807
|
+
* @param {Uint8Array} seed Unchecked 32 byte long Uint8Array acting as the seed for the private key
|
|
1808
|
+
* @returns {PrivateKey}
|
|
1809
|
+
*/
|
|
1810
|
+
static from_seed_unchecked(seed: Uint8Array): PrivateKey;
|
|
1811
|
+
/**
|
|
1812
|
+
* Get a private key from a string representation of a private key
|
|
1813
|
+
*
|
|
1814
|
+
* @param {string} seed String representation of a private key
|
|
1815
|
+
* @returns {PrivateKey}
|
|
1816
|
+
*/
|
|
1817
|
+
static from_string(private_key: string): PrivateKey;
|
|
1818
|
+
/**
|
|
1819
|
+
* Get a string representation of the private key. This function should be used very carefully
|
|
1820
|
+
* as it exposes the private key plaintext
|
|
1821
|
+
*
|
|
1822
|
+
* @returns {string} String representation of a private key
|
|
1823
|
+
*/
|
|
1824
|
+
to_string(): string;
|
|
1825
|
+
/**
|
|
1826
|
+
* Get the view key corresponding to the private key
|
|
1827
|
+
*
|
|
1828
|
+
* @returns {ViewKey}
|
|
1829
|
+
*/
|
|
1830
|
+
to_view_key(): ViewKey;
|
|
1831
|
+
/**
|
|
1832
|
+
* Get the address corresponding to the private key
|
|
1833
|
+
*
|
|
1834
|
+
* @returns {Address}
|
|
1835
|
+
*/
|
|
1836
|
+
to_address(): Address;
|
|
1837
|
+
/**
|
|
1838
|
+
* Sign a message with the private key
|
|
1839
|
+
*
|
|
1840
|
+
* @param {Uint8Array} Byte array representing a message signed by the address
|
|
1841
|
+
* @returns {Signature} Signature generated by signing the message with the address
|
|
1842
|
+
*/
|
|
1843
|
+
sign(message: Uint8Array): Signature;
|
|
1844
|
+
/**
|
|
1845
|
+
* Get a new randomly generated private key ciphertext using a secret. The secret is sensitive
|
|
1846
|
+
* and will be needed to decrypt the private key later, so it should be stored securely
|
|
1847
|
+
*
|
|
1848
|
+
* @param {string} secret Secret used to encrypt the private key
|
|
1849
|
+
* @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
|
|
1850
|
+
*/
|
|
1851
|
+
static newEncrypted(secret: string): PrivateKeyCiphertext;
|
|
1852
|
+
/**
|
|
1853
|
+
* Encrypt an existing private key with a secret. The secret is sensitive and will be needed to
|
|
1854
|
+
* decrypt the private key later, so it should be stored securely
|
|
1855
|
+
*
|
|
1856
|
+
* @param {string} secret Secret used to encrypt the private key
|
|
1857
|
+
* @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
|
|
1858
|
+
*/
|
|
1859
|
+
toCiphertext(secret: string): PrivateKeyCiphertext;
|
|
1860
|
+
/**
|
|
1861
|
+
* Get private key from a private key ciphertext and secret originally used to encrypt it
|
|
1862
|
+
*
|
|
1863
|
+
* @param {PrivateKeyCiphertext} ciphertext Ciphertext representation of the private key
|
|
1864
|
+
* @param {string} secret Secret originally used to encrypt the private key
|
|
1865
|
+
* @returns {PrivateKey} Private key
|
|
1866
|
+
*/
|
|
1867
|
+
static fromPrivateKeyCiphertext(ciphertext: PrivateKeyCiphertext, secret: string): PrivateKey;
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Private Key in ciphertext form
|
|
1871
|
+
*/
|
|
1872
|
+
export class PrivateKeyCiphertext {
|
|
1873
|
+
private constructor();
|
|
1874
|
+
free(): void;
|
|
1875
|
+
/**
|
|
1876
|
+
* Encrypt a private key using a secret string. The secret is sensitive and will be needed to
|
|
1877
|
+
* decrypt the private key later, so it should be stored securely
|
|
1878
|
+
*
|
|
1879
|
+
* @param {PrivateKey} private_key Private key to encrypt
|
|
1880
|
+
* @param {string} secret Secret to encrypt the private key with
|
|
1881
|
+
* @returns {PrivateKeyCiphertext} Private key ciphertext
|
|
1882
|
+
*/
|
|
1883
|
+
static encryptPrivateKey(private_key: PrivateKey, secret: string): PrivateKeyCiphertext;
|
|
1884
|
+
/**
|
|
1885
|
+
* Decrypts a private ciphertext using a secret string. This must be the same secret used to
|
|
1886
|
+
* encrypt the private key
|
|
1887
|
+
*
|
|
1888
|
+
* @param {string} secret Secret used to encrypt the private key
|
|
1889
|
+
* @returns {PrivateKey} Private key
|
|
1890
|
+
*/
|
|
1891
|
+
decryptToPrivateKey(secret: string): PrivateKey;
|
|
1892
|
+
/**
|
|
1893
|
+
* Returns the ciphertext string
|
|
1894
|
+
*
|
|
1895
|
+
* @returns {string} Ciphertext string
|
|
1896
|
+
*/
|
|
1897
|
+
toString(): string;
|
|
1898
|
+
/**
|
|
1899
|
+
* Creates a PrivateKeyCiphertext from a string
|
|
1900
|
+
*
|
|
1901
|
+
* @param {string} ciphertext Ciphertext string
|
|
1902
|
+
* @returns {PrivateKeyCiphertext} Private key ciphertext
|
|
1903
|
+
*/
|
|
1904
|
+
static fromString(ciphertext: string): PrivateKeyCiphertext;
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Webassembly Representation of an Aleo program
|
|
1908
|
+
*/
|
|
1909
|
+
export class Program {
|
|
1910
|
+
private constructor();
|
|
1911
|
+
free(): void;
|
|
1912
|
+
/**
|
|
1913
|
+
* Create a program from a program string
|
|
1914
|
+
*
|
|
1915
|
+
* @param {string} program Aleo program source code
|
|
1916
|
+
* @returns {Program} Program object
|
|
1917
|
+
*/
|
|
1918
|
+
static fromString(program: string): Program;
|
|
1919
|
+
/**
|
|
1920
|
+
* Get a string representation of the program
|
|
1921
|
+
*
|
|
1922
|
+
* @returns {string} String containing the program source code
|
|
1923
|
+
*/
|
|
1924
|
+
toString(): string;
|
|
1925
|
+
/**
|
|
1926
|
+
* Determine if a function is present in the program
|
|
1927
|
+
*
|
|
1928
|
+
* @param {string} functionName Name of the function to check for
|
|
1929
|
+
* @returns {boolean} True if the program is valid, false otherwise
|
|
1930
|
+
*/
|
|
1931
|
+
hasFunction(function_name: string): boolean;
|
|
1932
|
+
/**
|
|
1933
|
+
* Get javascript array of functions names in the program
|
|
1934
|
+
*
|
|
1935
|
+
* @returns {Array} Array of all function names present in the program
|
|
1936
|
+
*
|
|
1937
|
+
* @example
|
|
1938
|
+
* const expected_functions = [
|
|
1939
|
+
* "mint",
|
|
1940
|
+
* "transfer_private",
|
|
1941
|
+
* "transfer_private_to_public",
|
|
1942
|
+
* "transfer_public",
|
|
1943
|
+
* "transfer_public_to_private",
|
|
1944
|
+
* "join",
|
|
1945
|
+
* "split",
|
|
1946
|
+
* "fee"
|
|
1947
|
+
* ]
|
|
1948
|
+
*
|
|
1949
|
+
* const credits_program = aleo_wasm.Program.getCreditsProgram();
|
|
1950
|
+
* const credits_functions = credits_program.getFunctions();
|
|
1951
|
+
* console.log(credits_functions === expected_functions); // Output should be "true"
|
|
1952
|
+
*/
|
|
1953
|
+
getFunctions(): Array<any>;
|
|
1954
|
+
/**
|
|
1955
|
+
* Get a javascript object representation of the function inputs and types. This can be used
|
|
1956
|
+
* to generate a web form to capture user inputs for an execution of a function.
|
|
1957
|
+
*
|
|
1958
|
+
* @param {string} function_name Name of the function to get inputs for
|
|
1959
|
+
* @returns {Array} Array of function inputs
|
|
1960
|
+
*
|
|
1961
|
+
* @example
|
|
1962
|
+
* const expected_inputs = [
|
|
1963
|
+
* {
|
|
1964
|
+
* type:"record",
|
|
1965
|
+
* visibility:"private",
|
|
1966
|
+
* record:"credits",
|
|
1967
|
+
* members:[
|
|
1968
|
+
* {
|
|
1969
|
+
* name:"microcredits",
|
|
1970
|
+
* type:"u64",
|
|
1971
|
+
* visibility:"private"
|
|
1972
|
+
* }
|
|
1973
|
+
* ],
|
|
1974
|
+
* register:"r0"
|
|
1975
|
+
* },
|
|
1976
|
+
* {
|
|
1977
|
+
* type:"address",
|
|
1978
|
+
* visibility:"private",
|
|
1979
|
+
* register:"r1"
|
|
1980
|
+
* },
|
|
1981
|
+
* {
|
|
1982
|
+
* type:"u64",
|
|
1983
|
+
* visibility:"private",
|
|
1984
|
+
* register:"r2"
|
|
1985
|
+
* }
|
|
1986
|
+
* ];
|
|
1987
|
+
*
|
|
1988
|
+
* const credits_program = aleo_wasm.Program.getCreditsProgram();
|
|
1989
|
+
* const transfer_function_inputs = credits_program.getFunctionInputs("transfer_private");
|
|
1990
|
+
* console.log(transfer_function_inputs === expected_inputs); // Output should be "true"
|
|
1991
|
+
*/
|
|
1992
|
+
getFunctionInputs(function_name: string): Array<any>;
|
|
1993
|
+
/**
|
|
1994
|
+
* Get a the list of a program's mappings and the names/types of their keys and values.
|
|
1995
|
+
*
|
|
1996
|
+
* @returns {Array} - An array of objects representing the mappings in the program
|
|
1997
|
+
* @example
|
|
1998
|
+
* const expected_mappings = [
|
|
1999
|
+
* {
|
|
2000
|
+
* name: "account",
|
|
2001
|
+
* key_name: "owner",
|
|
2002
|
+
* key_type: "address",
|
|
2003
|
+
* value_name: "microcredits",
|
|
2004
|
+
* value_type: "u64"
|
|
2005
|
+
* }
|
|
2006
|
+
* ]
|
|
2007
|
+
*
|
|
2008
|
+
* const credits_program = aleo_wasm.Program.getCreditsProgram();
|
|
2009
|
+
* const credits_mappings = credits_program.getMappings();
|
|
2010
|
+
* console.log(credits_mappings === expected_mappings); // Output should be "true"
|
|
2011
|
+
*/
|
|
2012
|
+
getMappings(): Array<any>;
|
|
2013
|
+
/**
|
|
2014
|
+
* Get a javascript object representation of a program record and its types
|
|
2015
|
+
*
|
|
2016
|
+
* @param {string} record_name Name of the record to get members for
|
|
2017
|
+
* @returns {Object} Object containing the record name, type, and members
|
|
2018
|
+
*
|
|
2019
|
+
* @example
|
|
2020
|
+
*
|
|
2021
|
+
* const expected_record = {
|
|
2022
|
+
* type: "record",
|
|
2023
|
+
* record: "Credits",
|
|
2024
|
+
* members: [
|
|
2025
|
+
* {
|
|
2026
|
+
* name: "owner",
|
|
2027
|
+
* type: "address",
|
|
2028
|
+
* visibility: "private"
|
|
2029
|
+
* },
|
|
2030
|
+
* {
|
|
2031
|
+
* name: "microcredits",
|
|
2032
|
+
* type: "u64",
|
|
2033
|
+
* visibility: "private"
|
|
2034
|
+
* }
|
|
2035
|
+
* ];
|
|
2036
|
+
* };
|
|
2037
|
+
*
|
|
2038
|
+
* const credits_program = aleo_wasm.Program.getCreditsProgram();
|
|
2039
|
+
* const credits_record = credits_program.getRecordMembers("Credits");
|
|
2040
|
+
* console.log(credits_record === expected_record); // Output should be "true"
|
|
2041
|
+
*/
|
|
2042
|
+
getRecordMembers(record_name: string): object;
|
|
2043
|
+
/**
|
|
2044
|
+
* Get a javascript object representation of a program struct and its types
|
|
2045
|
+
*
|
|
2046
|
+
* @param {string} struct_name Name of the struct to get members for
|
|
2047
|
+
* @returns {Array} Array containing the struct members
|
|
2048
|
+
*
|
|
2049
|
+
* @example
|
|
2050
|
+
*
|
|
2051
|
+
* const STRUCT_PROGRAM = "program token_issue.aleo;
|
|
2052
|
+
*
|
|
2053
|
+
* struct token_metadata:
|
|
2054
|
+
* network as u32;
|
|
2055
|
+
* version as u32;
|
|
2056
|
+
*
|
|
2057
|
+
* struct token:
|
|
2058
|
+
* token_id as u32;
|
|
2059
|
+
* metadata as token_metadata;
|
|
2060
|
+
*
|
|
2061
|
+
* function no_op:
|
|
2062
|
+
* input r0 as u64;
|
|
2063
|
+
* output r0 as u64;"
|
|
2064
|
+
*
|
|
2065
|
+
* const expected_struct_members = [
|
|
2066
|
+
* {
|
|
2067
|
+
* name: "token_id",
|
|
2068
|
+
* type: "u32",
|
|
2069
|
+
* },
|
|
2070
|
+
* {
|
|
2071
|
+
* name: "metadata",
|
|
2072
|
+
* type: "struct",
|
|
2073
|
+
* struct_id: "token_metadata",
|
|
2074
|
+
* members: [
|
|
2075
|
+
* {
|
|
2076
|
+
* name: "network",
|
|
2077
|
+
* type: "u32",
|
|
2078
|
+
* }
|
|
2079
|
+
* {
|
|
2080
|
+
* name: "version",
|
|
2081
|
+
* type: "u32",
|
|
2082
|
+
* }
|
|
2083
|
+
* ]
|
|
2084
|
+
* }
|
|
2085
|
+
* ];
|
|
2086
|
+
*
|
|
2087
|
+
* const program = aleo_wasm.Program.fromString(STRUCT_PROGRAM);
|
|
2088
|
+
* const struct_members = program.getStructMembers("token");
|
|
2089
|
+
* console.log(struct_members === expected_struct_members); // Output should be "true"
|
|
2090
|
+
*/
|
|
2091
|
+
getStructMembers(struct_name: string): Array<any>;
|
|
2092
|
+
/**
|
|
2093
|
+
* Get the credits.aleo program
|
|
2094
|
+
*
|
|
2095
|
+
* @returns {Program} The credits.aleo program
|
|
2096
|
+
*/
|
|
2097
|
+
static getCreditsProgram(): Program;
|
|
2098
|
+
/**
|
|
2099
|
+
* Get the id of the program
|
|
2100
|
+
*
|
|
2101
|
+
* @returns {string} The id of the program
|
|
2102
|
+
*/
|
|
2103
|
+
id(): string;
|
|
2104
|
+
/**
|
|
2105
|
+
* Get a unique address of the program
|
|
2106
|
+
*
|
|
2107
|
+
* @returns {Address} The address of the program
|
|
2108
|
+
*/
|
|
2109
|
+
address(): Address;
|
|
2110
|
+
/**
|
|
2111
|
+
* Determine equality with another program
|
|
2112
|
+
*
|
|
2113
|
+
* @param {Program} other The other program to compare
|
|
2114
|
+
* @returns {boolean} True if the programs are equal, false otherwise
|
|
2115
|
+
*/
|
|
2116
|
+
isEqual(other: Program): boolean;
|
|
2117
|
+
/**
|
|
2118
|
+
* Get program_imports
|
|
2119
|
+
*
|
|
2120
|
+
* @returns {Array} The program imports
|
|
2121
|
+
*
|
|
2122
|
+
* @example
|
|
2123
|
+
*
|
|
2124
|
+
* const DOUBLE_TEST = "import multiply_test.aleo;
|
|
2125
|
+
*
|
|
2126
|
+
* program double_test.aleo;
|
|
2127
|
+
*
|
|
2128
|
+
* function double_it:
|
|
2129
|
+
* input r0 as u32.private;
|
|
2130
|
+
* call multiply_test.aleo/multiply 2u32 r0 into r1;
|
|
2131
|
+
* output r1 as u32.private;";
|
|
2132
|
+
*
|
|
2133
|
+
* const expected_imports = [
|
|
2134
|
+
* "multiply_test.aleo"
|
|
2135
|
+
* ];
|
|
2136
|
+
*
|
|
2137
|
+
* const program = aleo_wasm.Program.fromString(DOUBLE_TEST_PROGRAM);
|
|
2138
|
+
* const imports = program.getImports();
|
|
2139
|
+
* console.log(imports === expected_imports); // Output should be "true"
|
|
2140
|
+
*/
|
|
2141
|
+
getImports(): Array<any>;
|
|
2142
|
+
}
|
|
2143
|
+
export class ProgramManager {
|
|
2144
|
+
private constructor();
|
|
2145
|
+
free(): void;
|
|
2146
|
+
/**
|
|
2147
|
+
* Create an execution `Authorization` for a given program:function tuple with specified inputs.
|
|
2148
|
+
*
|
|
2149
|
+
* @param private_key The private key of the signer.
|
|
2150
|
+
* @param program The program source code containing the function to authorize.
|
|
2151
|
+
* @param function_name The function to authorize.
|
|
2152
|
+
* @param inputs A javascript array of inputs to the function.
|
|
2153
|
+
* @param imports The imports to the program in the format {"programname.aleo":"aleo instructions source code"}.
|
|
2154
|
+
*/
|
|
2155
|
+
static authorize(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, imports?: object | null, edition?: number | null): Promise<Authorization>;
|
|
2156
|
+
/**
|
|
2157
|
+
* Create an execution `Authorization` without generating a circuit. Use this function when
|
|
2158
|
+
* fast delegated proving is needed.
|
|
2159
|
+
*
|
|
2160
|
+
* @param private_key The private key of the signer.
|
|
2161
|
+
* @param program The program source code containing the function to authorize.
|
|
2162
|
+
* @param function_name The function to authorize.
|
|
2163
|
+
* @param inputs A javascript array of inputs to the function.
|
|
2164
|
+
* @param imports The imports to the program in the format {"programname.aleo":"aleo instructions source code"}.
|
|
2165
|
+
*/
|
|
2166
|
+
static buildAuthorizationUnchecked(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, imports?: object | null, edition?: number | null): Promise<Authorization>;
|
|
2167
|
+
/**
|
|
2168
|
+
* Create an `Authorization` for `credits.aleo/fee_public` or `credits.aleo/fee_private`.
|
|
2169
|
+
* This object requires an associated execution or deployment ID. This can be gained from
|
|
2170
|
+
* any previously created authorization by calling (authorization.toExecutionId()).
|
|
2171
|
+
*
|
|
2172
|
+
* @param private_key The private key of the signer.
|
|
2173
|
+
* @param deployment_or_execution_id The id of the deployment or execution to authorize the fee program for.
|
|
2174
|
+
* @param base_fee_credits The base fee to be paid for the authorization
|
|
2175
|
+
* @param priority_fee_credits The optional priority fee to be paid for the transaction
|
|
2176
|
+
* @param fee_record The record to spend the fee from
|
|
2177
|
+
* @returns {Authorization}
|
|
2178
|
+
*/
|
|
2179
|
+
static authorizeFee(private_key: PrivateKey, deployment_or_execution_id: string, base_fee_credits: number, priority_fee_credits: number, fee_record?: RecordPlaintext | null): Promise<Authorization>;
|
|
2180
|
+
/**
|
|
2181
|
+
* Deploy an Aleo program
|
|
2182
|
+
*
|
|
2183
|
+
* @param private_key The private key of the sender
|
|
2184
|
+
* @param program The source code of the program being deployed
|
|
2185
|
+
* @param imports A javascript object holding the source code of any imported programs in the
|
|
2186
|
+
* form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
|
|
2187
|
+
* Note that all imported programs must be deployed on chain before the main program in order
|
|
2188
|
+
* for the deployment to succeed
|
|
2189
|
+
* @param priority_fee_credits The optional priority fee to be paid for the transaction
|
|
2190
|
+
* @param fee_record The record to spend the fee from
|
|
2191
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
2192
|
+
* @param imports (optional) Provide a list of imports to use for the program deployment in the
|
|
2193
|
+
* form of a javascript object where the keys are a string of the program name and the values
|
|
2194
|
+
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
2195
|
+
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
2196
|
+
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
2197
|
+
* @returns {Transaction}
|
|
2198
|
+
*/
|
|
2199
|
+
static buildDeploymentTransaction(private_key: PrivateKey, program: string, priority_fee_credits: number, fee_record?: RecordPlaintext | null, url?: string | null, imports?: object | null, fee_proving_key?: ProvingKey | null, fee_verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null): Promise<Transaction>;
|
|
2200
|
+
/**
|
|
2201
|
+
* Estimate the fee for a program deployment
|
|
2202
|
+
*
|
|
2203
|
+
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
2204
|
+
*
|
|
2205
|
+
* @param program The source code of the program being deployed
|
|
2206
|
+
* @param imports (optional) Provide a list of imports to use for the deployment fee estimation
|
|
2207
|
+
* in the form of a javascript object where the keys are a string of the program name and the values
|
|
2208
|
+
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
2209
|
+
* @returns {u64}
|
|
2210
|
+
*/
|
|
2211
|
+
static estimateDeploymentFee(program: string, imports?: object | null): Promise<bigint>;
|
|
2212
|
+
/**
|
|
2213
|
+
* Estimate the component of the deployment cost which comes from the fee for the program name.
|
|
2214
|
+
* Note that this cost does not represent the entire cost of deployment. It is additional to
|
|
2215
|
+
* the cost of the size (in bytes) of the deployment.
|
|
2216
|
+
*
|
|
2217
|
+
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
2218
|
+
*
|
|
2219
|
+
* @param name The name of the program to be deployed
|
|
2220
|
+
* @returns {u64}
|
|
2221
|
+
*/
|
|
2222
|
+
static estimateProgramNameCost(name: string): bigint;
|
|
2223
|
+
/**
|
|
2224
|
+
* Execute an arbitrary function locally
|
|
2225
|
+
*
|
|
2226
|
+
* @param {PrivateKey} private_key The private key of the sender
|
|
2227
|
+
* @param {string} program The source code of the program being executed
|
|
2228
|
+
* @param {string} function The name of the function to execute
|
|
2229
|
+
* @param {Array} inputs A javascript array of inputs to the function
|
|
2230
|
+
* @param {boolean} prove_execution If true, the execution will be proven and an execution object
|
|
2231
|
+
* containing the proof and the encrypted inputs and outputs needed to verify the proof offline
|
|
2232
|
+
* will be returned.
|
|
2233
|
+
* @param {boolean} cache Cache the proving and verifying keys in the Execution response.
|
|
2234
|
+
* If this is set to 'true' the keys synthesized will be stored in the Execution Response
|
|
2235
|
+
* and the `ProvingKey` and `VerifyingKey` can be retrieved from the response via the `.getKeys()`
|
|
2236
|
+
* method.
|
|
2237
|
+
* @param {Object | undefined} imports (optional) Provide a list of imports to use for the function execution in the
|
|
2238
|
+
* form of a javascript object where the keys are a string of the program name and the values
|
|
2239
|
+
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
2240
|
+
* @param {ProvingKey | undefined} proving_key (optional) Provide a verifying key to use for the function execution
|
|
2241
|
+
* @param {VerifyingKey | undefined} verifying_key (optional) Provide a verifying key to use for the function execution
|
|
2242
|
+
*/
|
|
2243
|
+
static executeFunctionOffline(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, prove_execution: boolean, cache: boolean, imports?: object | null, proving_key?: ProvingKey | null, verifying_key?: VerifyingKey | null, url?: string | null, offline_query?: OfflineQuery | null, edition?: number | null): Promise<ExecutionResponse>;
|
|
2244
|
+
/**
|
|
2245
|
+
* Execute Aleo function and create an Aleo execution transaction
|
|
2246
|
+
*
|
|
2247
|
+
* @param private_key The private key of the sender
|
|
2248
|
+
* @param program The source code of the program being executed
|
|
2249
|
+
* @param function The name of the function to execute
|
|
2250
|
+
* @param inputs A javascript array of inputs to the function
|
|
2251
|
+
* @param priority_fee_credits The optional priority fee to be paid for the transaction
|
|
2252
|
+
* @param fee_record The record to spend the fee from
|
|
2253
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
2254
|
+
* If this is set to 'true' the keys synthesized (or passed in as optional parameters via the
|
|
2255
|
+
* `proving_key` and `verifying_key` arguments) will be stored in the ProgramManager's memory
|
|
2256
|
+
* and used for subsequent transactions. If this is set to 'false' the proving and verifying
|
|
2257
|
+
* keys will be deallocated from memory after the transaction is executed.
|
|
2258
|
+
* @param imports (optional) Provide a list of imports to use for the function execution in the
|
|
2259
|
+
* form of a javascript object where the keys are a string of the program name and the values
|
|
2260
|
+
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
2261
|
+
* @param proving_key (optional) Provide a verifying key to use for the function execution
|
|
2262
|
+
* @param verifying_key (optional) Provide a verifying key to use for the function execution
|
|
2263
|
+
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
2264
|
+
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
2265
|
+
* @param offline_query An offline query object to use if building a transaction without an internet connection.
|
|
2266
|
+
* @param edition The edition of the program to execute. Defaults to the latest found on the network, or 1 if the program does not exist on the network.
|
|
2267
|
+
* @returns {Transaction}
|
|
2268
|
+
*/
|
|
2269
|
+
static buildExecutionTransaction(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, priority_fee_credits: number, fee_record?: RecordPlaintext | null, url?: string | null, imports?: object | null, proving_key?: ProvingKey | null, verifying_key?: VerifyingKey | null, fee_proving_key?: ProvingKey | null, fee_verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null, edition?: number | null): Promise<Transaction>;
|
|
2270
|
+
/**
|
|
2271
|
+
* Estimate Fee for Aleo function execution. Note if "cache" is set to true, the proving and
|
|
2272
|
+
* verifying keys will be stored in the ProgramManager's memory and used for subsequent
|
|
2273
|
+
* program executions.
|
|
2274
|
+
*
|
|
2275
|
+
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
2276
|
+
*
|
|
2277
|
+
* @param private_key The private key of the sender
|
|
2278
|
+
* @param program The source code of the program to estimate the execution fee for
|
|
2279
|
+
* @param function The name of the function to execute
|
|
2280
|
+
* @param inputs A javascript array of inputs to the function
|
|
2281
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
2282
|
+
* @param imports (optional) Provide a list of imports to use for the fee estimation in the
|
|
2283
|
+
* form of a javascript object where the keys are a string of the program name and the values
|
|
2284
|
+
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
2285
|
+
* @param proving_key (optional) Provide a verifying key to use for the fee estimation
|
|
2286
|
+
* @param verifying_key (optional) Provide a verifying key to use for the fee estimation
|
|
2287
|
+
* @returns {u64} Fee in microcredits
|
|
2288
|
+
*/
|
|
2289
|
+
static estimateExecutionFee(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, url?: string | null, imports?: object | null, proving_key?: ProvingKey | null, verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null, edition?: number | null): Promise<bigint>;
|
|
2290
|
+
/**
|
|
2291
|
+
* Estimate the finalize fee component for executing a function. This fee is additional to the
|
|
2292
|
+
* size of the execution of the program in bytes. If the function does not have a finalize
|
|
2293
|
+
* step, then the finalize fee is 0.
|
|
2294
|
+
*
|
|
2295
|
+
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
2296
|
+
*
|
|
2297
|
+
* @param program The program containing the function to estimate the finalize fee for
|
|
2298
|
+
* @param function The function to estimate the finalize fee for
|
|
2299
|
+
* @returns {u64} Fee in microcredits
|
|
2300
|
+
*/
|
|
2301
|
+
static estimateFinalizeFee(program: string, _function: string): bigint;
|
|
2302
|
+
/**
|
|
2303
|
+
* Join two records together to create a new record with an amount of credits equal to the sum
|
|
2304
|
+
* of the credits of the two original records
|
|
2305
|
+
*
|
|
2306
|
+
* @param private_key The private key of the sender
|
|
2307
|
+
* @param record_1 The first record to combine
|
|
2308
|
+
* @param record_2 The second record to combine
|
|
2309
|
+
* @param priority_fee_credits The opptional priority fee to be paid for the transaction
|
|
2310
|
+
* @param fee_record The record to spend the fee from
|
|
2311
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
2312
|
+
* @param join_proving_key (optional) Provide a proving key to use for the join function
|
|
2313
|
+
* @param join_verifying_key (optional) Provide a verifying key to use for the join function
|
|
2314
|
+
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
2315
|
+
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
2316
|
+
* @returns {Transaction} Transaction object
|
|
2317
|
+
*/
|
|
2318
|
+
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>;
|
|
2319
|
+
/**
|
|
2320
|
+
* Create a `ProvingRequest` object. This object creates authorizations for the top level
|
|
2321
|
+
* function and associated fee function. This object can be sent directly to a remote prover
|
|
2322
|
+
* OR used to extract both execution and fee authorizations.
|
|
2323
|
+
*
|
|
2324
|
+
* @param private_key The private key of the signer.
|
|
2325
|
+
* @param program The program source code containing the function to authorize.
|
|
2326
|
+
* @param function_name The function to authorize.
|
|
2327
|
+
* @param inputs A javascript array of inputs to the function.
|
|
2328
|
+
* @param base_fee_credits The base fee to be paid for the authorization
|
|
2329
|
+
* @param priority_fee_credits The optional priority fee to be paid for the transaction
|
|
2330
|
+
* @param fee_record The record to spend the fee from
|
|
2331
|
+
* @param imports The imports to the program in the format {"programname.aleo":"aleo instructions source code"}.
|
|
2332
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
2333
|
+
* @param broadcast (optional) Flag to indicate if the transaction should be broadcast
|
|
2334
|
+
* @returns {Authorization}
|
|
2335
|
+
*/
|
|
2336
|
+
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, edition?: number | null): Promise<ProvingRequest>;
|
|
2337
|
+
/**
|
|
2338
|
+
* Split an Aleo credits record into two separate records. This function does not require a fee.
|
|
2339
|
+
*
|
|
2340
|
+
* @param private_key The private key of the sender
|
|
2341
|
+
* @param split_amount The amount of the credit split. This amount will be subtracted from the
|
|
2342
|
+
* value of the record and two new records will be created with the split amount and the remainder
|
|
2343
|
+
* @param amount_record The record to split
|
|
2344
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
2345
|
+
* @param split_proving_key (optional) Provide a proving key to use for the split function
|
|
2346
|
+
* @param split_verifying_key (optional) Provide a verifying key to use for the split function
|
|
2347
|
+
* @returns {Transaction} Transaction object
|
|
2348
|
+
*/
|
|
2349
|
+
static buildSplitTransaction(private_key: PrivateKey, split_amount: number, amount_record: RecordPlaintext, url?: string | null, split_proving_key?: ProvingKey | null, split_verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null): Promise<Transaction>;
|
|
2350
|
+
/**
|
|
2351
|
+
* Send credits from one Aleo account to another
|
|
2352
|
+
*
|
|
2353
|
+
* @param private_key The private key of the sender
|
|
2354
|
+
* @param amount_credits The amount of credits to send
|
|
2355
|
+
* @param recipient The recipient of the transaction
|
|
2356
|
+
* @param transfer_type The type of the transfer (options: "private", "public", "private_to_public", "public_to_private")
|
|
2357
|
+
* @param amount_record The record to fund the amount from
|
|
2358
|
+
* @param priority_fee_credits The optional priority fee to be paid for the transaction
|
|
2359
|
+
* @param fee_record The record to spend the fee from
|
|
2360
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
2361
|
+
* @param transfer_verifying_key (optional) Provide a verifying key to use for the transfer
|
|
2362
|
+
* function
|
|
2363
|
+
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
2364
|
+
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
2365
|
+
* @returns {Transaction}
|
|
2366
|
+
*/
|
|
2367
|
+
static buildTransferTransaction(private_key: PrivateKey, amount_credits: number, recipient: string, transfer_type: string, amount_record: RecordPlaintext | null | undefined, priority_fee_credits: number, fee_record?: RecordPlaintext | null, url?: string | null, transfer_proving_key?: ProvingKey | null, transfer_verifying_key?: VerifyingKey | null, fee_proving_key?: ProvingKey | null, fee_verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null): Promise<Transaction>;
|
|
2368
|
+
/**
|
|
2369
|
+
* Synthesize proving and verifying keys for a program
|
|
2370
|
+
*
|
|
2371
|
+
* @param program {string} The program source code of the program to synthesize keys for
|
|
2372
|
+
* @param function_id {string} The function to synthesize keys for
|
|
2373
|
+
* @param inputs {Array} The inputs to the function
|
|
2374
|
+
* @param imports {Object | undefined} The imports for the program
|
|
2375
|
+
*/
|
|
2376
|
+
static synthesizeKeyPair(private_key: PrivateKey, program: string, function_id: string, inputs: Array<any>, imports?: object | null, edition?: number | null): Promise<KeyPair>;
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* Proving key for a function within an Aleo program
|
|
2380
|
+
*/
|
|
2381
|
+
export class ProvingKey {
|
|
2382
|
+
private constructor();
|
|
2383
|
+
free(): void;
|
|
2384
|
+
/**
|
|
2385
|
+
* Verify if the proving key is for the bond_public function
|
|
2386
|
+
*
|
|
2387
|
+
* @example
|
|
2388
|
+
* const provingKey = ProvingKey.fromBytes("bond_public_proving_key.bin");
|
|
2389
|
+
* provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2390
|
+
*
|
|
2391
|
+
* @returns {boolean} returns true if the proving key is for the bond_public function, false if otherwise
|
|
2392
|
+
*/
|
|
2393
|
+
isBondPublicProver(): boolean;
|
|
2394
|
+
/**
|
|
2395
|
+
* Verify if the proving key is for the bond_validator function
|
|
2396
|
+
*
|
|
2397
|
+
* @example
|
|
2398
|
+
* const provingKey = ProvingKey.fromBytes("bond_validator_proving_key.bin");
|
|
2399
|
+
* provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2400
|
+
*
|
|
2401
|
+
* @returns {boolean} returns true if the proving key is for the bond_validator function, false if otherwise
|
|
2402
|
+
*/
|
|
2403
|
+
isBondValidatorProver(): boolean;
|
|
2404
|
+
/**
|
|
2405
|
+
* Verify if the proving key is for the claim_unbond function
|
|
2406
|
+
*
|
|
2407
|
+
* @example
|
|
2408
|
+
* const provingKey = ProvingKey.fromBytes("claim_unbond_proving_key.bin");
|
|
2409
|
+
* provingKey.isClaimUnbondProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2410
|
+
*
|
|
2411
|
+
* @returns {boolean} returns true if the proving key is for the claim_unbond function, false if otherwise
|
|
2412
|
+
*/
|
|
2413
|
+
isClaimUnbondPublicProver(): boolean;
|
|
2414
|
+
/**
|
|
2415
|
+
* Verify if the proving key is for the fee_private function
|
|
2416
|
+
*
|
|
2417
|
+
* @example
|
|
2418
|
+
* const provingKey = ProvingKey.fromBytes("fee_private_proving_key.bin");
|
|
2419
|
+
* provingKey.isFeePrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2420
|
+
*
|
|
2421
|
+
* @returns {boolean} returns true if the proving key is for the fee_private function, false if otherwise
|
|
2422
|
+
*/
|
|
2423
|
+
isFeePrivateProver(): boolean;
|
|
2424
|
+
/**
|
|
2425
|
+
* Verify if the proving key is for the fee_public function
|
|
2426
|
+
*
|
|
2427
|
+
* @example
|
|
2428
|
+
* const provingKey = ProvingKey.fromBytes("fee_public_proving_key.bin");
|
|
2429
|
+
* provingKey.isFeePublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2430
|
+
*
|
|
2431
|
+
* @returns {boolean} returns true if the proving key is for the fee_public function, false if otherwise
|
|
2432
|
+
*/
|
|
2433
|
+
isFeePublicProver(): boolean;
|
|
2434
|
+
/**
|
|
2435
|
+
* Verify if the proving key is for the inclusion function
|
|
2436
|
+
*
|
|
2437
|
+
* @example
|
|
2438
|
+
* const provingKey = ProvingKey.fromBytes("inclusion_proving_key.bin");
|
|
2439
|
+
* provingKey.isInclusionProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2440
|
+
*
|
|
2441
|
+
* @returns {boolean} returns true if the proving key is for the inclusion function, false if otherwise
|
|
2442
|
+
*/
|
|
2443
|
+
isInclusionProver(): boolean;
|
|
2444
|
+
/**
|
|
2445
|
+
* Verify if the proving key is for the join function
|
|
2446
|
+
*
|
|
2447
|
+
* @example
|
|
2448
|
+
* const provingKey = ProvingKey.fromBytes("join_proving_key.bin");
|
|
2449
|
+
* provingKey.isJoinProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2450
|
+
*
|
|
2451
|
+
* @returns {boolean} returns true if the proving key is for the join function, false if otherwise
|
|
2452
|
+
*/
|
|
2453
|
+
isJoinProver(): boolean;
|
|
2454
|
+
/**
|
|
2455
|
+
* Verify if the proving key is for the set_validator_state function
|
|
2456
|
+
*
|
|
2457
|
+
* @example
|
|
2458
|
+
* const provingKey = ProvingKey.fromBytes("set_validator_set_proving_key.bin");
|
|
2459
|
+
* provingKey.isSetValidatorStateProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2460
|
+
*
|
|
2461
|
+
* @returns {boolean} returns true if the proving key is for the set_validator_state function, false if otherwise
|
|
2462
|
+
*/
|
|
2463
|
+
isSetValidatorStateProver(): boolean;
|
|
2464
|
+
/**
|
|
2465
|
+
* Verify if the proving key is for the split function
|
|
2466
|
+
*
|
|
2467
|
+
* @example
|
|
2468
|
+
* const provingKey = ProvingKey.fromBytes("split_proving_key.bin");
|
|
2469
|
+
* provingKey.isSplitProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2470
|
+
*
|
|
2471
|
+
* @returns {boolean} returns true if the proving key is for the split function, false if otherwise
|
|
2472
|
+
*/
|
|
2473
|
+
isSplitProver(): boolean;
|
|
2474
|
+
/**
|
|
2475
|
+
* Verify if the proving key is for the transfer_private function
|
|
2476
|
+
*
|
|
2477
|
+
* @example
|
|
2478
|
+
* const provingKey = ProvingKey.fromBytes("transfer_private_proving_key.bin");
|
|
2479
|
+
* provingKey.isTransferPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2480
|
+
*
|
|
2481
|
+
* @returns {boolean} returns true if the proving key is for the transfer_private function, false if otherwise
|
|
2482
|
+
*/
|
|
2483
|
+
isTransferPrivateProver(): boolean;
|
|
2484
|
+
/**
|
|
2485
|
+
* Verify if the proving key is for the transfer_private_to_public function
|
|
2486
|
+
*
|
|
2487
|
+
* @example
|
|
2488
|
+
* const provingKey = ProvingKey.fromBytes("transfer_private_to_public_proving_key.bin");
|
|
2489
|
+
* provingKey.isTransferPrivateToPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2490
|
+
*
|
|
2491
|
+
* @returns {boolean} returns true if the proving key is for the transfer_private_to_public function, false if otherwise
|
|
2492
|
+
*/
|
|
2493
|
+
isTransferPrivateToPublicProver(): boolean;
|
|
2494
|
+
/**
|
|
2495
|
+
* Verify if the proving key is for the transfer_public function
|
|
2496
|
+
*
|
|
2497
|
+
* @example
|
|
2498
|
+
* const provingKey = ProvingKey.fromBytes("transfer_public_proving_key.bin");
|
|
2499
|
+
* provingKey.isTransferPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2500
|
+
*
|
|
2501
|
+
* @returns {boolean} returns true if the proving key is for the transfer_public function, false if otherwise
|
|
2502
|
+
*/
|
|
2503
|
+
isTransferPublicProver(): boolean;
|
|
2504
|
+
/**
|
|
2505
|
+
* Verify if the proving key is for the transfer_public_as_signer function
|
|
2506
|
+
*
|
|
2507
|
+
* @example
|
|
2508
|
+
* const provingKey = ProvingKey.fromBytes("transfer_public_as_signer_proving_key.bin");
|
|
2509
|
+
* provingKey.isTransferPublicAsSignerProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2510
|
+
*
|
|
2511
|
+
* @returns {boolean} returns true if the proving key is for the transfer_public function, false if otherwise
|
|
2512
|
+
*/
|
|
2513
|
+
isTransferPublicAsSignerProver(): boolean;
|
|
2514
|
+
/**
|
|
2515
|
+
* Verify if the proving key is for the transfer_public_to_private function
|
|
2516
|
+
*
|
|
2517
|
+
* @example
|
|
2518
|
+
* const provingKey = ProvingKey.fromBytes("transfer_public_to_private_proving_key.bin");
|
|
2519
|
+
* provingKey.isTransferPublicToPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2520
|
+
*
|
|
2521
|
+
* @returns {boolean} returns true if the proving key is for the transfer_public_to_private function, false if otherwise
|
|
2522
|
+
*/
|
|
2523
|
+
isTransferPublicToPrivateProver(): boolean;
|
|
2524
|
+
/**
|
|
2525
|
+
* Verify if the proving key is for the unbond_public function
|
|
2526
|
+
*
|
|
2527
|
+
* @example
|
|
2528
|
+
* const provingKey = ProvingKey.fromBytes("unbond_public.bin");
|
|
2529
|
+
* provingKey.isUnbondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2530
|
+
*
|
|
2531
|
+
* @returns {boolean} returns true if the proving key is for the unbond_public_prover function, false if otherwise
|
|
2532
|
+
*/
|
|
2533
|
+
isUnbondPublicProver(): boolean;
|
|
2534
|
+
/**
|
|
2535
|
+
* Return the checksum of the proving key
|
|
2536
|
+
*
|
|
2537
|
+
* @returns {string} Checksum of the proving key
|
|
2538
|
+
*/
|
|
2539
|
+
checksum(): string;
|
|
2540
|
+
/**
|
|
2541
|
+
* Create a copy of the proving key
|
|
2542
|
+
*
|
|
2543
|
+
* @returns {ProvingKey} A copy of the proving key
|
|
2544
|
+
*/
|
|
2545
|
+
copy(): ProvingKey;
|
|
2546
|
+
/**
|
|
2547
|
+
* Construct a new proving key from a byte array
|
|
2548
|
+
*
|
|
2549
|
+
* @param {Uint8Array} bytes Byte array representation of a proving key
|
|
2550
|
+
* @returns {ProvingKey}
|
|
2551
|
+
*/
|
|
2552
|
+
static fromBytes(bytes: Uint8Array): ProvingKey;
|
|
2553
|
+
/**
|
|
2554
|
+
* Create a proving key from string
|
|
2555
|
+
*
|
|
2556
|
+
* @param {string} String representation of the proving key
|
|
2557
|
+
*/
|
|
2558
|
+
static fromString(string: string): ProvingKey;
|
|
2559
|
+
/**
|
|
2560
|
+
* Return the byte representation of a proving key
|
|
2561
|
+
*
|
|
2562
|
+
* @returns {Uint8Array} Byte array representation of a proving key
|
|
2563
|
+
*/
|
|
2564
|
+
toBytes(): Uint8Array;
|
|
2565
|
+
/**
|
|
2566
|
+
* Get a string representation of the proving key
|
|
2567
|
+
*
|
|
2568
|
+
* @returns {string} String representation of the proving key
|
|
2569
|
+
*/
|
|
2570
|
+
toString(): string;
|
|
2571
|
+
}
|
|
2572
|
+
/**
|
|
2573
|
+
* Represents a proving request to a prover.
|
|
2574
|
+
*/
|
|
2575
|
+
export class ProvingRequest {
|
|
2576
|
+
private constructor();
|
|
2577
|
+
free(): void;
|
|
2578
|
+
/**
|
|
2579
|
+
* Creates a new ProvingRequest from a function Authorization and an optional fee Authorization.
|
|
2580
|
+
*
|
|
2581
|
+
* @param {Authorization} authorization An Authorization for a function.
|
|
2582
|
+
* @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.
|
|
2583
|
+
* @param {boolean} broadcast Flag that indicates whether the remote proving service should attempt to submit the transaction on the caller's behalf.
|
|
2584
|
+
*/
|
|
2585
|
+
static new(authorization: Authorization, fee_authorization: Authorization | null | undefined, broadcast: boolean): ProvingRequest;
|
|
2586
|
+
/**
|
|
2587
|
+
* Creates a ProvingRequest from a string representation.
|
|
2588
|
+
*
|
|
2589
|
+
* @param {Uint8Array} request String representation of the ProvingRequest.
|
|
2590
|
+
*/
|
|
2591
|
+
static fromString(request: string): ProvingRequest;
|
|
2592
|
+
/**
|
|
2593
|
+
* Creates a string representation of the ProvingRequest.
|
|
2594
|
+
*/
|
|
2595
|
+
toString(): string;
|
|
2596
|
+
/**
|
|
2597
|
+
* Creates a ProvingRequest from a left-endian byte representation of the ProvingRequest.
|
|
1497
2598
|
*
|
|
1498
|
-
* @param {
|
|
1499
|
-
|
|
2599
|
+
* @param {Uint8Array} bytes Left-endian bytes representing the proving request.
|
|
2600
|
+
*/
|
|
2601
|
+
static fromBytesLe(bytes: Uint8Array): ProvingRequest;
|
|
2602
|
+
/**
|
|
2603
|
+
* Creates a left-endian byte representation of the ProvingRequest.
|
|
2604
|
+
*/
|
|
2605
|
+
toBytesLe(): Uint8Array;
|
|
2606
|
+
/**
|
|
2607
|
+
* Get the Authorization of the main function in the ProvingRequest.
|
|
2608
|
+
*/
|
|
2609
|
+
authorization(): Authorization;
|
|
2610
|
+
/**
|
|
2611
|
+
* Get the fee Authorization in the ProvingRequest.
|
|
2612
|
+
*/
|
|
2613
|
+
feeAuthorization(): Authorization | undefined;
|
|
2614
|
+
/**
|
|
2615
|
+
* Get the broadcast flag set in the ProvingRequest.
|
|
2616
|
+
*/
|
|
2617
|
+
broadcast(): boolean;
|
|
2618
|
+
/**
|
|
2619
|
+
* Check if a ProvingRequest is the same as another ProvingRequest.
|
|
2620
|
+
*/
|
|
2621
|
+
equals(other: ProvingRequest): boolean;
|
|
2622
|
+
}
|
|
2623
|
+
/**
|
|
2624
|
+
* Encrypted Aleo record
|
|
2625
|
+
*/
|
|
2626
|
+
export class RecordCiphertext {
|
|
2627
|
+
private constructor();
|
|
2628
|
+
free(): void;
|
|
2629
|
+
/**
|
|
2630
|
+
* Create a record ciphertext from a string
|
|
2631
|
+
*
|
|
2632
|
+
* @param {string} record String representation of a record ciphertext
|
|
2633
|
+
* @returns {RecordCiphertext} Record ciphertext
|
|
2634
|
+
*/
|
|
2635
|
+
static fromString(record: string): RecordCiphertext;
|
|
2636
|
+
/**
|
|
2637
|
+
* Return the string representation of the record ciphertext
|
|
2638
|
+
*
|
|
2639
|
+
* @returns {string} String representation of the record ciphertext
|
|
2640
|
+
*/
|
|
2641
|
+
toString(): string;
|
|
2642
|
+
/**
|
|
2643
|
+
* Decrypt the record ciphertext into plaintext using the view key. The record will only
|
|
2644
|
+
* decrypt if the record was encrypted by the account corresponding to the view key
|
|
2645
|
+
*
|
|
2646
|
+
* @param {ViewKey} view_key View key used to decrypt the ciphertext
|
|
2647
|
+
* @returns {RecordPlaintext} Record plaintext object
|
|
2648
|
+
*/
|
|
2649
|
+
decrypt(view_key: ViewKey): RecordPlaintext;
|
|
2650
|
+
/**
|
|
2651
|
+
* Generate the record view key. The record view key can only decrypt record if the
|
|
2652
|
+
* supplied view key belongs to the record owner.
|
|
2653
|
+
*
|
|
2654
|
+
* @param {ViewKey} view_key View key used to generate the record view key
|
|
2655
|
+
*
|
|
2656
|
+
* @returns {Group} record view key
|
|
2657
|
+
*/
|
|
2658
|
+
recordViewKey(view_key: ViewKey): Field;
|
|
2659
|
+
/**
|
|
2660
|
+
* Determines if the account corresponding to the view key is the owner of the record
|
|
2661
|
+
*
|
|
2662
|
+
* @param {ViewKey} view_key View key used to decrypt the ciphertext
|
|
2663
|
+
* @returns {boolean}
|
|
2664
|
+
*/
|
|
2665
|
+
isOwner(view_key: ViewKey): boolean;
|
|
2666
|
+
/**
|
|
2667
|
+
* Get the tag of the record using the graph key.
|
|
2668
|
+
*
|
|
2669
|
+
* @param {GraphKey} graph key of the account associatd with the record.
|
|
2670
|
+
* @param {Field} commitment of the record.
|
|
2671
|
+
*
|
|
2672
|
+
* @returns {Field} tag of the record.
|
|
2673
|
+
*/
|
|
2674
|
+
static tag(graph_key: GraphKey, commitment: Field): Field;
|
|
2675
|
+
/**
|
|
2676
|
+
* Get a record ciphertext object from a series of bytes.
|
|
2677
|
+
*
|
|
2678
|
+
* @param {Uint8Array} bytes A left endian byte array representing the record ciphertext.
|
|
2679
|
+
*
|
|
2680
|
+
* @returns {RecordCiphertext}
|
|
2681
|
+
*/
|
|
2682
|
+
static fromBytesLe(bytes: Uint8Array): RecordCiphertext;
|
|
2683
|
+
/**
|
|
2684
|
+
* Get the left endian byte array representation of the record ciphertext.
|
|
2685
|
+
*
|
|
2686
|
+
* @returns {Uint8Array} Left endian byte array representation of the record ciphertext.
|
|
2687
|
+
*/
|
|
2688
|
+
toBytesLe(): Uint8Array;
|
|
2689
|
+
/**
|
|
2690
|
+
* Get the left endian boolean array representation of the record ciphertext bits.
|
|
2691
|
+
*
|
|
2692
|
+
* returns {Array} Left endian boolean array representation of the bits of the record ciphertext.
|
|
2693
|
+
*/
|
|
2694
|
+
toBitsLe(): Array<any>;
|
|
2695
|
+
/**
|
|
2696
|
+
* Get the field array representation of the record ciphertext.
|
|
2697
|
+
*
|
|
2698
|
+
* @returns {Array} Field array representation of the record ciphertext.
|
|
2699
|
+
*/
|
|
2700
|
+
toFields(): Array<any>;
|
|
2701
|
+
/**
|
|
2702
|
+
* Decrypt the record ciphertext into plaintext using a record view key.
|
|
2703
|
+
*
|
|
2704
|
+
* @param {Field} record_vk Record view key used to decrypt the record.
|
|
2705
|
+
*
|
|
2706
|
+
* @returns {RecordPlaintext}
|
|
2707
|
+
*/
|
|
2708
|
+
decryptWithRecordViewKey(record_vk: Field): RecordPlaintext;
|
|
2709
|
+
/**
|
|
2710
|
+
* Get the record nonce.
|
|
2711
|
+
*
|
|
2712
|
+
* @returns {Group} The record nonce.
|
|
2713
|
+
*/
|
|
2714
|
+
nonce(): Group;
|
|
2715
|
+
/**
|
|
2716
|
+
* Clone the RecordCiphertext WASM object.
|
|
2717
|
+
*
|
|
2718
|
+
* @returns {RecordCiphertext} A clone of the RecordCiphertext WASM object.
|
|
2719
|
+
*/
|
|
2720
|
+
clone(): RecordCiphertext;
|
|
2721
|
+
}
|
|
2722
|
+
/**
|
|
2723
|
+
* Plaintext representation of an Aleo record
|
|
2724
|
+
*/
|
|
2725
|
+
export class RecordPlaintext {
|
|
2726
|
+
private constructor();
|
|
2727
|
+
free(): void;
|
|
2728
|
+
commitment(program_id: string, record_name: string, record_view_key: string): Field;
|
|
2729
|
+
/**
|
|
2730
|
+
* Return a record plaintext from a string.
|
|
2731
|
+
*
|
|
2732
|
+
* @param {string} record String representation of a plaintext representation of an Aleo record.
|
|
2733
|
+
*
|
|
2734
|
+
* @returns {RecordPlaintext} Record plaintext
|
|
2735
|
+
*/
|
|
2736
|
+
static fromString(record: string): RecordPlaintext;
|
|
2737
|
+
/**
|
|
2738
|
+
* Get the record entry matching a key.
|
|
2739
|
+
*
|
|
2740
|
+
* @param {string} input The key to retrieve the value in the record data field.
|
|
2741
|
+
*
|
|
2742
|
+
* @returns {Plaintext} The plaintext value corresponding to the key.
|
|
2743
|
+
*/
|
|
2744
|
+
getMember(input: string): Plaintext;
|
|
2745
|
+
/**
|
|
2746
|
+
* Get the owner of the record.
|
|
2747
|
+
*
|
|
2748
|
+
* @returns {Address} Address of the owner of the record.
|
|
2749
|
+
*/
|
|
2750
|
+
owner(): Address;
|
|
2751
|
+
/**
|
|
2752
|
+
* Get a representation of a record as a javascript object for usage in client side
|
|
2753
|
+
* computations. Note that this is not a reversible operation and exists for the convenience
|
|
2754
|
+
* of discovering and using properties of the record.
|
|
2755
|
+
*
|
|
2756
|
+
* The conversion guide is as follows:
|
|
2757
|
+
* - u8, u16, u32, i8, i16 i32 --> Number
|
|
2758
|
+
* - u64, u128, i64, i128 --> BigInt
|
|
2759
|
+
* - Address, Field, Group, Scalar --> String.
|
|
2760
|
+
*
|
|
2761
|
+
* Address, Field, Group, and Scalar will all be converted to their bech32 string
|
|
2762
|
+
* representation. These string representations can be converted back to their respective wasm
|
|
2763
|
+
* types using the fromString method on the Address, Field, Group, and Scalar objects in this
|
|
2764
|
+
* library.
|
|
1500
2765
|
*
|
|
1501
2766
|
* @example
|
|
2767
|
+
* # Create a wasm record from a record string.
|
|
2768
|
+
* let record_plaintext_wasm = RecordPlainext.from_string("{
|
|
2769
|
+
* owner: aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48.private,
|
|
2770
|
+
* metadata: {
|
|
2771
|
+
* player1: aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48.private,
|
|
2772
|
+
* player2: aleo1dreuxnmg9cny8ee9v2u0wr4v4affnwm09u2pytfwz0f2en2shgqsdsfjn6.private,
|
|
2773
|
+
* nonce: 660310649780728486489183263981322848354071976582883879926426319832534836534field.private
|
|
2774
|
+
* },
|
|
2775
|
+
* id: 1953278585719525811355617404139099418855053112960441725284031425961000152405field.private,
|
|
2776
|
+
* positions: 50794271u64.private,
|
|
2777
|
+
* attempts: 0u64.private,
|
|
2778
|
+
* hits: 0u64.private,
|
|
2779
|
+
* _nonce: 5668100912391182624073500093436664635767788874314097667746354181784048204413group.public
|
|
2780
|
+
* }");
|
|
1502
2781
|
*
|
|
1503
|
-
*
|
|
1504
|
-
*
|
|
1505
|
-
*
|
|
1506
|
-
*
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
1513
|
-
*
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
1516
|
-
* }
|
|
1517
|
-
* ];
|
|
1518
|
-
* };
|
|
2782
|
+
* let expected_object = {
|
|
2783
|
+
* owner: "aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48",
|
|
2784
|
+
* metadata: {
|
|
2785
|
+
* player1: "aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48",
|
|
2786
|
+
* player2: "aleo1dreuxnmg9cny8ee9v2u0wr4v4affnwm09u2pytfwz0f2en2shgqsdsfjn6",
|
|
2787
|
+
* nonce: "660310649780728486489183263981322848354071976582883879926426319832534836534field"
|
|
2788
|
+
* },
|
|
2789
|
+
* id: "1953278585719525811355617404139099418855053112960441725284031425961000152405field",
|
|
2790
|
+
* positions: 50794271,
|
|
2791
|
+
* attempts: 0,
|
|
2792
|
+
* hits: 0,
|
|
2793
|
+
* _nonce: "5668100912391182624073500093436664635767788874314097667746354181784048204413group"
|
|
2794
|
+
* };
|
|
1519
2795
|
*
|
|
1520
|
-
*
|
|
1521
|
-
*
|
|
1522
|
-
*
|
|
2796
|
+
* # Create the expected object
|
|
2797
|
+
* let record_plaintext_object = record_plaintext_wasm.to_js_object();
|
|
2798
|
+
* assert(JSON.stringify(record_plaintext_object) == JSON.stringify(expected_object));
|
|
2799
|
+
*
|
|
2800
|
+
* @returns {Object} Javascript object representation of the record
|
|
2801
|
+
*/
|
|
2802
|
+
toJsObject(): object;
|
|
2803
|
+
/**
|
|
2804
|
+
* Returns the record plaintext string
|
|
2805
|
+
*
|
|
2806
|
+
* @returns {string} String representation of the record plaintext
|
|
2807
|
+
*/
|
|
2808
|
+
toString(): string;
|
|
2809
|
+
/**
|
|
2810
|
+
* Get a record plaintext object from a series of bytes.
|
|
2811
|
+
*
|
|
2812
|
+
* @param {Uint8Array} bytes A left endian byte array representing the record plaintext.
|
|
2813
|
+
*
|
|
2814
|
+
* @returns {RecordPlaintext} The record plaintext.
|
|
2815
|
+
*/
|
|
2816
|
+
static fromBytesLe(bytes: Uint8Array): RecordPlaintext;
|
|
2817
|
+
/**
|
|
2818
|
+
* Returns the left endian byte array representation of the record plaintext.
|
|
2819
|
+
*
|
|
2820
|
+
* @returns {Uint8Array} Byte array representation of the record plaintext.
|
|
2821
|
+
*/
|
|
2822
|
+
toBytesLe(): Uint8Array;
|
|
2823
|
+
/**
|
|
2824
|
+
* Returns the left endian boolean array representation of the record plaintext bits.
|
|
2825
|
+
*
|
|
2826
|
+
* @returns {Array} Boolean array representation of the record plaintext bits.
|
|
2827
|
+
*/
|
|
2828
|
+
toBitsLe(): Array<any>;
|
|
2829
|
+
/**
|
|
2830
|
+
* Get the field array representation of the record plaintext.
|
|
2831
|
+
*/
|
|
2832
|
+
toFields(): Array<any>;
|
|
2833
|
+
/**
|
|
2834
|
+
* Returns the amount of microcredits in the record
|
|
2835
|
+
*
|
|
2836
|
+
* @returns {u64} Amount of microcredits in the record
|
|
1523
2837
|
*/
|
|
1524
|
-
|
|
2838
|
+
microcredits(): bigint;
|
|
1525
2839
|
/**
|
|
1526
|
-
*
|
|
1527
|
-
*
|
|
1528
|
-
* @param {string} struct_name Name of the struct to get members for
|
|
1529
|
-
* @returns {Array} Array containing the struct members
|
|
1530
|
-
*
|
|
1531
|
-
* @example
|
|
1532
|
-
*
|
|
1533
|
-
* const STRUCT_PROGRAM = "program token_issue.aleo;
|
|
2840
|
+
* Returns the nonce of the record. This can be used to uniquely identify a record.
|
|
1534
2841
|
*
|
|
1535
|
-
*
|
|
1536
|
-
|
|
1537
|
-
|
|
2842
|
+
* @returns {string} Nonce of the record
|
|
2843
|
+
*/
|
|
2844
|
+
nonce(): string;
|
|
2845
|
+
/**
|
|
2846
|
+
* Attempt to get the serial number of a record to determine whether or not is has been spent
|
|
1538
2847
|
*
|
|
1539
|
-
*
|
|
1540
|
-
*
|
|
1541
|
-
*
|
|
2848
|
+
* @param {PrivateKey} private_key Private key of the account that owns the record
|
|
2849
|
+
* @param {string} program_id Program ID of the program that the record is associated with
|
|
2850
|
+
* @param {string} record_name Name of the record
|
|
2851
|
+
* @param {string} record_view_key The string representation of the record view key.
|
|
1542
2852
|
*
|
|
1543
|
-
*
|
|
1544
|
-
|
|
1545
|
-
|
|
2853
|
+
* @returns {string} Serial number of the record
|
|
2854
|
+
*/
|
|
2855
|
+
serialNumberString(private_key: PrivateKey, program_id: string, record_name: string, record_view_key: string): string;
|
|
2856
|
+
/**
|
|
2857
|
+
* Get the tag of the record using the graph key.
|
|
2858
|
+
*/
|
|
2859
|
+
tag(graph_key: GraphKey, commitment: Field): Field;
|
|
2860
|
+
/**
|
|
2861
|
+
* Generate the record view key. The record view key can only decrypt record if the
|
|
2862
|
+
* supplied view key belongs to the record owner.
|
|
1546
2863
|
*
|
|
1547
|
-
*
|
|
1548
|
-
* {
|
|
1549
|
-
* name: "token_id",
|
|
1550
|
-
* type: "u32",
|
|
1551
|
-
* },
|
|
1552
|
-
* {
|
|
1553
|
-
* name: "metadata",
|
|
1554
|
-
* type: "struct",
|
|
1555
|
-
* struct_id: "token_metadata",
|
|
1556
|
-
* members: [
|
|
1557
|
-
* {
|
|
1558
|
-
* name: "network",
|
|
1559
|
-
* type: "u32",
|
|
1560
|
-
* }
|
|
1561
|
-
* {
|
|
1562
|
-
* name: "version",
|
|
1563
|
-
* type: "u32",
|
|
1564
|
-
* }
|
|
1565
|
-
* ]
|
|
1566
|
-
* }
|
|
1567
|
-
* ];
|
|
2864
|
+
* @param {ViewKey} view_key View key used to generate the record view key
|
|
1568
2865
|
*
|
|
1569
|
-
*
|
|
1570
|
-
* const struct_members = program.getStructMembers("token");
|
|
1571
|
-
* console.log(struct_members === expected_struct_members); // Output should be "true"
|
|
2866
|
+
* @returns {Group} record view key
|
|
1572
2867
|
*/
|
|
1573
|
-
|
|
2868
|
+
recordViewKey(view_key: ViewKey): Field;
|
|
1574
2869
|
/**
|
|
1575
|
-
*
|
|
2870
|
+
* Clone the RecordPlaintext WASM object.
|
|
1576
2871
|
*
|
|
1577
|
-
* @returns {
|
|
2872
|
+
* @returns {RecordPlaintext} A clone of the RecordPlaintext WASM object.
|
|
1578
2873
|
*/
|
|
1579
|
-
|
|
2874
|
+
clone(): RecordPlaintext;
|
|
2875
|
+
}
|
|
2876
|
+
/**
|
|
2877
|
+
* Scalar field element.
|
|
2878
|
+
*/
|
|
2879
|
+
export class Scalar {
|
|
2880
|
+
private constructor();
|
|
2881
|
+
free(): void;
|
|
1580
2882
|
/**
|
|
1581
|
-
*
|
|
1582
|
-
*
|
|
1583
|
-
* @returns {string} The id of the program
|
|
2883
|
+
* Creates a scalar object from a string representation of a scalar element.
|
|
1584
2884
|
*/
|
|
1585
|
-
|
|
2885
|
+
static fromString(group: string): Scalar;
|
|
1586
2886
|
/**
|
|
1587
|
-
*
|
|
2887
|
+
* Returns the string representation of the scalar element.
|
|
2888
|
+
*/
|
|
2889
|
+
toString(): string;
|
|
2890
|
+
/**
|
|
2891
|
+
* Create a scalar element from a Uint8Array of left endian bytes.
|
|
2892
|
+
*/
|
|
2893
|
+
static fromBytesLe(bytes: Uint8Array): Scalar;
|
|
2894
|
+
/**
|
|
2895
|
+
* Encode the scalar element as a Uint8Array of left endian bytes.
|
|
2896
|
+
*/
|
|
2897
|
+
toBytesLe(): Uint8Array;
|
|
2898
|
+
/**
|
|
2899
|
+
* Reconstruct a scalar element from a boolean array representation.
|
|
2900
|
+
*/
|
|
2901
|
+
static fromBitsLe(bits: Array<any>): Scalar;
|
|
2902
|
+
/**
|
|
2903
|
+
* Get the left endian boolean array representation of the scalar element.
|
|
2904
|
+
*/
|
|
2905
|
+
toBitsLe(): Array<any>;
|
|
2906
|
+
/**
|
|
2907
|
+
* Create a plaintext element from a scalar element.
|
|
2908
|
+
*/
|
|
2909
|
+
toPlaintext(): Plaintext;
|
|
2910
|
+
/**
|
|
2911
|
+
* Cast the scalar element to a field element.
|
|
2912
|
+
*/
|
|
2913
|
+
toField(): Field;
|
|
2914
|
+
/**
|
|
2915
|
+
* Clone the scalar element.
|
|
2916
|
+
*/
|
|
2917
|
+
clone(): Scalar;
|
|
2918
|
+
/**
|
|
2919
|
+
* Generate a random scalar element.
|
|
2920
|
+
*/
|
|
2921
|
+
static random(): Scalar;
|
|
2922
|
+
/**
|
|
2923
|
+
* Add two scalar elements.
|
|
2924
|
+
*/
|
|
2925
|
+
add(other: Scalar): Scalar;
|
|
2926
|
+
/**
|
|
2927
|
+
* Subtract two scalar elements.
|
|
2928
|
+
*/
|
|
2929
|
+
subtract(other: Scalar): Scalar;
|
|
2930
|
+
/**
|
|
2931
|
+
* Multiply two scalar elements.
|
|
2932
|
+
*/
|
|
2933
|
+
multiply(other: Scalar): Scalar;
|
|
2934
|
+
/**
|
|
2935
|
+
* Divide two scalar elements.
|
|
2936
|
+
*/
|
|
2937
|
+
divide(other: Scalar): Scalar;
|
|
2938
|
+
/**
|
|
2939
|
+
* Double the scalar element.
|
|
2940
|
+
*/
|
|
2941
|
+
double(): Scalar;
|
|
2942
|
+
/**
|
|
2943
|
+
* Power of a scalar element.
|
|
2944
|
+
*/
|
|
2945
|
+
pow(other: Scalar): Scalar;
|
|
2946
|
+
/**
|
|
2947
|
+
* Invert the scalar element.
|
|
2948
|
+
*/
|
|
2949
|
+
inverse(): Scalar;
|
|
2950
|
+
/**
|
|
2951
|
+
* Get the multiplicative identity of the scalar field.
|
|
2952
|
+
*/
|
|
2953
|
+
static one(): Scalar;
|
|
2954
|
+
/**
|
|
2955
|
+
* Get the additive identity of the scalar field.
|
|
2956
|
+
*/
|
|
2957
|
+
static zero(): Scalar;
|
|
2958
|
+
/**
|
|
2959
|
+
* Check if one scalar element equals another.
|
|
2960
|
+
*/
|
|
2961
|
+
equals(other: Scalar): boolean;
|
|
2962
|
+
}
|
|
2963
|
+
/**
|
|
2964
|
+
* Cryptographic signature of a message signed by an Aleo account
|
|
2965
|
+
*/
|
|
2966
|
+
export class Signature {
|
|
2967
|
+
private constructor();
|
|
2968
|
+
free(): void;
|
|
2969
|
+
/**
|
|
2970
|
+
* Sign a message with a private key
|
|
1588
2971
|
*
|
|
1589
|
-
* @
|
|
2972
|
+
* @param {PrivateKey} private_key The private key to sign the message with
|
|
2973
|
+
* @param {Uint8Array} message Byte representation of the message to sign
|
|
2974
|
+
* @returns {Signature} Signature of the message
|
|
1590
2975
|
*/
|
|
1591
|
-
|
|
2976
|
+
static sign(private_key: PrivateKey, message: Uint8Array): Signature;
|
|
1592
2977
|
/**
|
|
1593
|
-
*
|
|
2978
|
+
* Get an address from a signature.
|
|
1594
2979
|
*
|
|
1595
|
-
* @
|
|
1596
|
-
* @returns {boolean} True if the programs are equal, false otherwise
|
|
2980
|
+
* @returns {Address} Address object
|
|
1597
2981
|
*/
|
|
1598
|
-
|
|
2982
|
+
to_address(): Address;
|
|
1599
2983
|
/**
|
|
1600
|
-
* Get
|
|
2984
|
+
* Get the challenge of a signature.
|
|
2985
|
+
*/
|
|
2986
|
+
challenge(): Scalar;
|
|
2987
|
+
/**
|
|
2988
|
+
* Get the response of a signature.
|
|
2989
|
+
*/
|
|
2990
|
+
response(): Scalar;
|
|
2991
|
+
/**
|
|
2992
|
+
* Verify a signature of a message with an address
|
|
1601
2993
|
*
|
|
1602
|
-
* @
|
|
2994
|
+
* @param {Address} address The address to verify the signature with
|
|
2995
|
+
* @param {Uint8Array} message Byte representation of the message to verify
|
|
2996
|
+
* @returns {boolean} True if the signature is valid, false otherwise
|
|
2997
|
+
*/
|
|
2998
|
+
verify(address: Address, message: Uint8Array): boolean;
|
|
2999
|
+
/**
|
|
3000
|
+
* Get a signature from a series of bytes.
|
|
1603
3001
|
*
|
|
1604
|
-
* @
|
|
3002
|
+
* @param {Uint8Array} bytes A left endian byte array representing the signature.
|
|
1605
3003
|
*
|
|
1606
|
-
*
|
|
3004
|
+
* @returns {Signature} The signature object.
|
|
3005
|
+
*/
|
|
3006
|
+
static fromBytesLe(bytes: Uint8Array): Signature;
|
|
3007
|
+
/**
|
|
3008
|
+
* Get the left endian byte array representation of the signature.
|
|
3009
|
+
*/
|
|
3010
|
+
toBytesLe(): Uint8Array;
|
|
3011
|
+
/**
|
|
3012
|
+
* Get a signature from a series of bits represented as a boolean array.
|
|
1607
3013
|
*
|
|
1608
|
-
*
|
|
3014
|
+
* @param {Array} bits A left endian boolean array representing the bits of the signature.
|
|
1609
3015
|
*
|
|
1610
|
-
*
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
3016
|
+
* @returns {Signature} The signature object.
|
|
3017
|
+
*/
|
|
3018
|
+
static fromBitsLe(bits: Array<any>): Signature;
|
|
3019
|
+
/**
|
|
3020
|
+
* Get the left endian boolean array representation of the bits of the signature.
|
|
3021
|
+
*/
|
|
3022
|
+
toBitsLe(): Array<any>;
|
|
3023
|
+
/**
|
|
3024
|
+
* Get the field array representation of the signature.
|
|
3025
|
+
*/
|
|
3026
|
+
toFields(): Array<any>;
|
|
3027
|
+
/**
|
|
3028
|
+
* Get a signature from a string representation of a signature
|
|
1614
3029
|
*
|
|
1615
|
-
*
|
|
1616
|
-
*
|
|
1617
|
-
|
|
3030
|
+
* @param {string} signature String representation of a signature
|
|
3031
|
+
* @returns {Signature} Signature
|
|
3032
|
+
*/
|
|
3033
|
+
static from_string(signature: string): Signature;
|
|
3034
|
+
/**
|
|
3035
|
+
* Get a string representation of a signature
|
|
1618
3036
|
*
|
|
1619
|
-
*
|
|
1620
|
-
* const imports = program.getImports();
|
|
1621
|
-
* console.log(imports === expected_imports); // Output should be "true"
|
|
3037
|
+
* @returns {string} String representation of a signature
|
|
1622
3038
|
*/
|
|
1623
|
-
|
|
3039
|
+
to_string(): string;
|
|
3040
|
+
/**
|
|
3041
|
+
* Get the plaintext representation of the signature.
|
|
3042
|
+
*/
|
|
3043
|
+
toPlaintext(): Plaintext;
|
|
1624
3044
|
}
|
|
1625
|
-
|
|
3045
|
+
/**
|
|
3046
|
+
* Webassembly Representation of an Aleo transaction
|
|
3047
|
+
*
|
|
3048
|
+
* This object is created when generating an on-chain function deployment or execution and is the
|
|
3049
|
+
* object that should be submitted to the Aleo Network in order to deploy or execute a function.
|
|
3050
|
+
*/
|
|
3051
|
+
export class Transaction {
|
|
1626
3052
|
private constructor();
|
|
1627
3053
|
free(): void;
|
|
1628
3054
|
/**
|
|
1629
|
-
* Create
|
|
3055
|
+
* Create a transaction from a string
|
|
1630
3056
|
*
|
|
1631
|
-
* @param
|
|
1632
|
-
* @
|
|
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"}.
|
|
3057
|
+
* @param {string} transaction String representation of a transaction
|
|
3058
|
+
* @returns {Transaction}
|
|
1636
3059
|
*/
|
|
1637
|
-
static
|
|
3060
|
+
static fromString(transaction: string): Transaction;
|
|
1638
3061
|
/**
|
|
1639
|
-
* Create
|
|
1640
|
-
* fast delegated proving is needed.
|
|
3062
|
+
* Create a transaction from a Uint8Array of left endian bytes.
|
|
1641
3063
|
*
|
|
1642
|
-
* @param
|
|
1643
|
-
* @
|
|
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"}.
|
|
3064
|
+
* @param {Uint8Array} Uint8Array of left endian bytes encoding a Transaction.
|
|
3065
|
+
* @returns {Transaction}
|
|
1647
3066
|
*/
|
|
1648
|
-
static
|
|
3067
|
+
static fromBytesLe(bytes: Uint8Array): Transaction;
|
|
1649
3068
|
/**
|
|
1650
|
-
*
|
|
1651
|
-
*
|
|
1652
|
-
* any previously created authorization by calling (authorization.toExecutionId()).
|
|
3069
|
+
* Get the transaction as a string. If you want to submit this transaction to the Aleo Network
|
|
3070
|
+
* this function will create the string that should be submitted in the `POST` data.
|
|
1653
3071
|
*
|
|
1654
|
-
* @
|
|
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}
|
|
3072
|
+
* @returns {string} String representation of the transaction
|
|
1660
3073
|
*/
|
|
1661
|
-
|
|
3074
|
+
toString(): string;
|
|
1662
3075
|
/**
|
|
1663
|
-
*
|
|
3076
|
+
* Get the transaction as a Uint8Array of left endian bytes.
|
|
1664
3077
|
*
|
|
1665
|
-
* @
|
|
1666
|
-
* @param program The source code of the program being deployed
|
|
1667
|
-
* @param imports A javascript object holding the source code of any imported programs in the
|
|
1668
|
-
* form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
|
|
1669
|
-
* Note that all imported programs must be deployed on chain before the main program in order
|
|
1670
|
-
* for the deployment to succeed
|
|
1671
|
-
* @param priority_fee_credits The optional priority fee to be paid for the transaction
|
|
1672
|
-
* @param fee_record The record to spend the fee from
|
|
1673
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
1674
|
-
* @param imports (optional) Provide a list of imports to use for the program deployment in the
|
|
1675
|
-
* form of a javascript object where the keys are a string of the program name and the values
|
|
1676
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
1677
|
-
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
1678
|
-
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
1679
|
-
* @returns {Transaction}
|
|
3078
|
+
* @returns {Uint8Array} Uint8Array representation of the transaction
|
|
1680
3079
|
*/
|
|
1681
|
-
|
|
3080
|
+
toBytesLe(): Uint8Array;
|
|
1682
3081
|
/**
|
|
1683
|
-
*
|
|
3082
|
+
* Returns true if the transaction contains the given serial number.
|
|
1684
3083
|
*
|
|
1685
|
-
*
|
|
3084
|
+
* @param {boolean} True if the transaction contains the given serial number.
|
|
3085
|
+
*/
|
|
3086
|
+
constainsSerialNumber(serial_number: Field): boolean;
|
|
3087
|
+
/**
|
|
3088
|
+
* Returns true if the transaction contains the given commitment.
|
|
1686
3089
|
*
|
|
1687
|
-
* @param
|
|
1688
|
-
* @param imports (optional) Provide a list of imports to use for the deployment fee estimation
|
|
1689
|
-
* in the form of a javascript object where the keys are a string of the program name and the values
|
|
1690
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
1691
|
-
* @returns {u64}
|
|
3090
|
+
* @param {boolean} True if the transaction contains the given commitment.
|
|
1692
3091
|
*/
|
|
1693
|
-
|
|
3092
|
+
constainsCommitment(commitment: Field): boolean;
|
|
1694
3093
|
/**
|
|
1695
|
-
*
|
|
1696
|
-
|
|
1697
|
-
|
|
3094
|
+
* Find a record in the transaction by the record's commitment.
|
|
3095
|
+
*/
|
|
3096
|
+
findRecord(commitment: Field): RecordCiphertext | undefined;
|
|
3097
|
+
/**
|
|
3098
|
+
* Returns the transaction's base fee.
|
|
3099
|
+
*/
|
|
3100
|
+
baseFeeAmount(): bigint;
|
|
3101
|
+
/**
|
|
3102
|
+
* Returns the transaction's total fee.
|
|
3103
|
+
*/
|
|
3104
|
+
feeAmount(): bigint;
|
|
3105
|
+
/**
|
|
3106
|
+
* Returns the transaction's priority fee.
|
|
1698
3107
|
*
|
|
1699
|
-
*
|
|
3108
|
+
* returns {bigint} The transaction's priority fee.
|
|
3109
|
+
*/
|
|
3110
|
+
priorityFeeAmount(): bigint;
|
|
3111
|
+
/**
|
|
3112
|
+
* Returns true if the transaction is a deployment transaction.
|
|
1700
3113
|
*
|
|
1701
|
-
* @
|
|
1702
|
-
* @returns {u64}
|
|
3114
|
+
* @returns {boolean} True if the transaction is a deployment transaction
|
|
1703
3115
|
*/
|
|
1704
|
-
|
|
3116
|
+
isDeploy(): boolean;
|
|
1705
3117
|
/**
|
|
1706
|
-
*
|
|
3118
|
+
* Returns true if the transaction is an execution transaction.
|
|
1707
3119
|
*
|
|
1708
|
-
* @
|
|
1709
|
-
* @param {string} program The source code of the program being executed
|
|
1710
|
-
* @param {string} function The name of the function to execute
|
|
1711
|
-
* @param {Array} inputs A javascript array of inputs to the function
|
|
1712
|
-
* @param {boolean} prove_execution If true, the execution will be proven and an execution object
|
|
1713
|
-
* containing the proof and the encrypted inputs and outputs needed to verify the proof offline
|
|
1714
|
-
* will be returned.
|
|
1715
|
-
* @param {boolean} cache Cache the proving and verifying keys in the Execution response.
|
|
1716
|
-
* If this is set to 'true' the keys synthesized will be stored in the Execution Response
|
|
1717
|
-
* and the `ProvingKey` and `VerifyingKey` can be retrieved from the response via the `.getKeys()`
|
|
1718
|
-
* method.
|
|
1719
|
-
* @param {Object | undefined} imports (optional) Provide a list of imports to use for the function execution in the
|
|
1720
|
-
* form of a javascript object where the keys are a string of the program name and the values
|
|
1721
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
1722
|
-
* @param {ProvingKey | undefined} proving_key (optional) Provide a verifying key to use for the function execution
|
|
1723
|
-
* @param {VerifyingKey | undefined} verifying_key (optional) Provide a verifying key to use for the function execution
|
|
3120
|
+
* @returns {boolean} True if the transaction is an execution transaction
|
|
1724
3121
|
*/
|
|
1725
|
-
|
|
3122
|
+
isExecute(): boolean;
|
|
1726
3123
|
/**
|
|
1727
|
-
*
|
|
3124
|
+
* Returns true if the transaction is a fee transaction.
|
|
1728
3125
|
*
|
|
1729
|
-
* @
|
|
1730
|
-
* @param program The source code of the program being executed
|
|
1731
|
-
* @param function The name of the function to execute
|
|
1732
|
-
* @param inputs A javascript array of inputs to the function
|
|
1733
|
-
* @param priority_fee_credits The optional priority fee to be paid for the transaction
|
|
1734
|
-
* @param fee_record The record to spend the fee from
|
|
1735
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
1736
|
-
* If this is set to 'true' the keys synthesized (or passed in as optional parameters via the
|
|
1737
|
-
* `proving_key` and `verifying_key` arguments) will be stored in the ProgramManager's memory
|
|
1738
|
-
* and used for subsequent transactions. If this is set to 'false' the proving and verifying
|
|
1739
|
-
* keys will be deallocated from memory after the transaction is executed.
|
|
1740
|
-
* @param imports (optional) Provide a list of imports to use for the function execution in the
|
|
1741
|
-
* form of a javascript object where the keys are a string of the program name and the values
|
|
1742
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
1743
|
-
* @param proving_key (optional) Provide a verifying key to use for the function execution
|
|
1744
|
-
* @param verifying_key (optional) Provide a verifying key to use for the function execution
|
|
1745
|
-
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
1746
|
-
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
1747
|
-
* @returns {Transaction}
|
|
3126
|
+
* @returns {boolean} True if the transaction is a fee transaction
|
|
1748
3127
|
*/
|
|
1749
|
-
|
|
3128
|
+
isFee(): boolean;
|
|
1750
3129
|
/**
|
|
1751
|
-
*
|
|
1752
|
-
*
|
|
1753
|
-
* program executions.
|
|
3130
|
+
* Returns the program deployed within the transaction if the transaction is a deployment
|
|
3131
|
+
* transaction.
|
|
1754
3132
|
*
|
|
1755
|
-
*
|
|
3133
|
+
* @returns {Program | undefined} The program deployed within the transaction.
|
|
3134
|
+
*/
|
|
3135
|
+
deployedProgram(): Program | undefined;
|
|
3136
|
+
/**
|
|
3137
|
+
* Returns the execution within the transaction (if present).
|
|
1756
3138
|
*
|
|
1757
|
-
* @
|
|
1758
|
-
* @param program The source code of the program to estimate the execution fee for
|
|
1759
|
-
* @param function The name of the function to execute
|
|
1760
|
-
* @param inputs A javascript array of inputs to the function
|
|
1761
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
1762
|
-
* @param imports (optional) Provide a list of imports to use for the fee estimation in the
|
|
1763
|
-
* form of a javascript object where the keys are a string of the program name and the values
|
|
1764
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
1765
|
-
* @param proving_key (optional) Provide a verifying key to use for the fee estimation
|
|
1766
|
-
* @param verifying_key (optional) Provide a verifying key to use for the fee estimation
|
|
1767
|
-
* @returns {u64} Fee in microcredits
|
|
3139
|
+
* @returns {Execution | undefined} The execution within the transaction.
|
|
1768
3140
|
*/
|
|
1769
|
-
|
|
3141
|
+
execution(): Execution | undefined;
|
|
1770
3142
|
/**
|
|
1771
|
-
*
|
|
1772
|
-
* size of the execution of the program in bytes. If the function does not have a finalize
|
|
1773
|
-
* step, then the finalize fee is 0.
|
|
3143
|
+
* Get the record plaintext present in a transaction owned by a specific view key.
|
|
1774
3144
|
*
|
|
1775
|
-
*
|
|
3145
|
+
* @param {ViewKey} view_key View key used to decrypt the ciphertext
|
|
1776
3146
|
*
|
|
1777
|
-
* @
|
|
1778
|
-
* @param function The function to estimate the finalize fee for
|
|
1779
|
-
* @returns {u64} Fee in microcredits
|
|
3147
|
+
* @returns {Array<RecordPlaintext>} Array of record plaintext objects
|
|
1780
3148
|
*/
|
|
1781
|
-
|
|
3149
|
+
ownedRecords(view_key: ViewKey): Array<any>;
|
|
1782
3150
|
/**
|
|
1783
|
-
*
|
|
1784
|
-
* of the credits of the two original records
|
|
3151
|
+
* Get the records present in a transaction and their commitments.
|
|
1785
3152
|
*
|
|
1786
|
-
* @
|
|
1787
|
-
* @param record_1 The first record to combine
|
|
1788
|
-
* @param record_2 The second record to combine
|
|
1789
|
-
* @param priority_fee_credits The opptional priority fee to be paid for the transaction
|
|
1790
|
-
* @param fee_record The record to spend the fee from
|
|
1791
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
1792
|
-
* @param join_proving_key (optional) Provide a proving key to use for the join function
|
|
1793
|
-
* @param join_verifying_key (optional) Provide a verifying key to use for the join function
|
|
1794
|
-
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
1795
|
-
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
1796
|
-
* @returns {Transaction} Transaction object
|
|
3153
|
+
* @returns {Array<{commitment: Field, record: RecordCiphertext}>} Array of record ciphertext objects
|
|
1797
3154
|
*/
|
|
1798
|
-
|
|
3155
|
+
records(): Array<any>;
|
|
1799
3156
|
/**
|
|
1800
|
-
*
|
|
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.
|
|
3157
|
+
* Get a summary of the transaction within a javascript object.
|
|
1803
3158
|
*
|
|
1804
|
-
*
|
|
1805
|
-
*
|
|
1806
|
-
*
|
|
1807
|
-
*
|
|
1808
|
-
*
|
|
1809
|
-
*
|
|
1810
|
-
* @param
|
|
1811
|
-
*
|
|
1812
|
-
*
|
|
1813
|
-
* @
|
|
1814
|
-
* @returns {Authorization}
|
|
3159
|
+
* If the transaction is an execution transaction, this function will return a list of the
|
|
3160
|
+
* transitions and their inputs and outputs.
|
|
3161
|
+
*
|
|
3162
|
+
* If the transaction is a deployment transaction, this function will return the program id and
|
|
3163
|
+
* a list of the functions and their verifying keys, constraint, and variable counts.
|
|
3164
|
+
*
|
|
3165
|
+
* @param {boolean} convert_to_js If true the inputs and outputs will be converted to JS objects,
|
|
3166
|
+
* if false the inputs and outputs will be in wasm format.
|
|
3167
|
+
*
|
|
3168
|
+
* @returns {Object} Transaction summary
|
|
1815
3169
|
*/
|
|
1816
|
-
|
|
3170
|
+
summary(convert_to_js: boolean): object;
|
|
1817
3171
|
/**
|
|
1818
|
-
*
|
|
3172
|
+
* Get the id of the transaction. This is the merkle root of the transaction's inclusion proof.
|
|
1819
3173
|
*
|
|
1820
|
-
*
|
|
1821
|
-
*
|
|
1822
|
-
* value
|
|
1823
|
-
*
|
|
1824
|
-
* @
|
|
1825
|
-
* @param split_proving_key (optional) Provide a proving key to use for the split function
|
|
1826
|
-
* @param split_verifying_key (optional) Provide a verifying key to use for the split function
|
|
1827
|
-
* @returns {Transaction} Transaction object
|
|
3174
|
+
* This value can be used to query the status of the transaction on the Aleo Network to see
|
|
3175
|
+
* if it was successful. If successful, the transaction will be included in a block and this
|
|
3176
|
+
* value can be used to lookup the transaction data on-chain.
|
|
3177
|
+
*
|
|
3178
|
+
* @returns {string} TransactionId
|
|
1828
3179
|
*/
|
|
1829
|
-
|
|
3180
|
+
id(): string;
|
|
1830
3181
|
/**
|
|
1831
|
-
*
|
|
3182
|
+
* Get the type of the transaction (will return "deploy" or "execute")
|
|
1832
3183
|
*
|
|
1833
|
-
* @
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
1839
|
-
* @
|
|
1840
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
1841
|
-
* @param transfer_verifying_key (optional) Provide a verifying key to use for the transfer
|
|
1842
|
-
* function
|
|
1843
|
-
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
1844
|
-
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
1845
|
-
* @returns {Transaction}
|
|
3184
|
+
* @returns {string} Transaction type
|
|
3185
|
+
*/
|
|
3186
|
+
transactionType(): string;
|
|
3187
|
+
/**
|
|
3188
|
+
* Get the transitions in a transaction.
|
|
3189
|
+
*
|
|
3190
|
+
* @returns {Array<Transition>} Array of transition objects
|
|
1846
3191
|
*/
|
|
1847
|
-
|
|
3192
|
+
transitions(): Array<any>;
|
|
1848
3193
|
/**
|
|
1849
|
-
*
|
|
3194
|
+
* Get the verifying keys in a transaction.
|
|
1850
3195
|
*
|
|
1851
|
-
* @
|
|
1852
|
-
* @param function_id {string} The function to synthesize keys for
|
|
1853
|
-
* @param inputs {Array} The inputs to the function
|
|
1854
|
-
* @param imports {Object | undefined} The imports for the program
|
|
3196
|
+
* @returns {Array<Object>} Array of verifying keys.
|
|
1855
3197
|
*/
|
|
1856
|
-
|
|
3198
|
+
verifyingKeys(): Array<any>;
|
|
1857
3199
|
}
|
|
1858
|
-
|
|
1859
|
-
* Proving key for a function within an Aleo program
|
|
1860
|
-
*/
|
|
1861
|
-
export class ProvingKey {
|
|
3200
|
+
export class Transition {
|
|
1862
3201
|
private constructor();
|
|
1863
3202
|
free(): void;
|
|
1864
3203
|
/**
|
|
1865
|
-
*
|
|
1866
|
-
*
|
|
1867
|
-
* @example
|
|
1868
|
-
* const provingKey = ProvingKey.fromBytes("bond_public_proving_key.bin");
|
|
1869
|
-
* provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3204
|
+
* Get the transition ID
|
|
1870
3205
|
*
|
|
1871
|
-
* @returns {
|
|
3206
|
+
* @returns {string} The transition ID
|
|
1872
3207
|
*/
|
|
1873
|
-
|
|
3208
|
+
id(): string;
|
|
1874
3209
|
/**
|
|
1875
|
-
*
|
|
1876
|
-
*
|
|
1877
|
-
* @example
|
|
1878
|
-
* const provingKey = ProvingKey.fromBytes("bond_validator_proving_key.bin");
|
|
1879
|
-
* provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3210
|
+
* Create a transition from a string
|
|
1880
3211
|
*
|
|
1881
|
-
* @
|
|
3212
|
+
* @param {string} transition String representation of a transition
|
|
3213
|
+
* @returns {Transition}
|
|
1882
3214
|
*/
|
|
1883
|
-
|
|
3215
|
+
static fromString(transition: string): Transition;
|
|
1884
3216
|
/**
|
|
1885
|
-
*
|
|
1886
|
-
*
|
|
1887
|
-
* @example
|
|
1888
|
-
* const provingKey = ProvingKey.fromBytes("claim_unbond_proving_key.bin");
|
|
1889
|
-
* provingKey.isClaimUnbondProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3217
|
+
* Create a transition from a Uint8Array of left endian bytes.
|
|
1890
3218
|
*
|
|
1891
|
-
* @
|
|
3219
|
+
* @param {Uint8Array} Uint8Array of left endian bytes encoding a Transition.
|
|
3220
|
+
* @returns {Transition}
|
|
1892
3221
|
*/
|
|
1893
|
-
|
|
3222
|
+
static fromBytesLe(bytes: Uint8Array): Transition;
|
|
1894
3223
|
/**
|
|
1895
|
-
*
|
|
1896
|
-
*
|
|
1897
|
-
* @example
|
|
1898
|
-
* const provingKey = ProvingKey.fromBytes("fee_private_proving_key.bin");
|
|
1899
|
-
* provingKey.isFeePrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3224
|
+
* Get the transition as a string. If you want to submit this transition to the Aleo Network
|
|
3225
|
+
* this function will create the string that should be submitted in the `POST` data.
|
|
1900
3226
|
*
|
|
1901
|
-
* @returns {
|
|
3227
|
+
* @returns {string} String representation of the transition
|
|
1902
3228
|
*/
|
|
1903
|
-
|
|
3229
|
+
toString(): string;
|
|
1904
3230
|
/**
|
|
1905
|
-
*
|
|
1906
|
-
*
|
|
1907
|
-
* @example
|
|
1908
|
-
* const provingKey = ProvingKey.fromBytes("fee_public_proving_key.bin");
|
|
1909
|
-
* provingKey.isFeePublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3231
|
+
* Get the transition as a Uint8Array of left endian bytes.
|
|
1910
3232
|
*
|
|
1911
|
-
* @returns {
|
|
3233
|
+
* @returns {Uint8Array} Uint8Array representation of the transition
|
|
1912
3234
|
*/
|
|
1913
|
-
|
|
3235
|
+
toBytesLe(): Uint8Array;
|
|
1914
3236
|
/**
|
|
1915
|
-
*
|
|
1916
|
-
*
|
|
1917
|
-
* @example
|
|
1918
|
-
* const provingKey = ProvingKey.fromBytes("inclusion_proving_key.bin");
|
|
1919
|
-
* provingKey.isInclusionProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
1920
|
-
*
|
|
1921
|
-
* @returns {boolean} returns true if the proving key is for the inclusion function, false if otherwise
|
|
3237
|
+
* Get the program ID of the transition.
|
|
1922
3238
|
*/
|
|
1923
|
-
|
|
3239
|
+
programId(): string;
|
|
1924
3240
|
/**
|
|
1925
|
-
*
|
|
1926
|
-
*
|
|
1927
|
-
* @example
|
|
1928
|
-
* const provingKey = ProvingKey.fromBytes("join_proving_key.bin");
|
|
1929
|
-
* provingKey.isJoinProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
1930
|
-
*
|
|
1931
|
-
* @returns {boolean} returns true if the proving key is for the join function, false if otherwise
|
|
3241
|
+
* Get the function name of the transition.
|
|
1932
3242
|
*/
|
|
1933
|
-
|
|
3243
|
+
functionName(): string;
|
|
1934
3244
|
/**
|
|
1935
|
-
*
|
|
1936
|
-
*
|
|
1937
|
-
* @example
|
|
1938
|
-
* const provingKey = ProvingKey.fromBytes("set_validator_set_proving_key.bin");
|
|
1939
|
-
* provingKey.isSetValidatorStateProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3245
|
+
* Returns true if the transition contains the given commitment.
|
|
1940
3246
|
*
|
|
1941
|
-
* @
|
|
3247
|
+
* @param {boolean} True if the transition contains the given commitment.
|
|
1942
3248
|
*/
|
|
1943
|
-
|
|
3249
|
+
containsCommitment(commitment: Field): boolean;
|
|
1944
3250
|
/**
|
|
1945
|
-
*
|
|
3251
|
+
* Check if the transition contains a serial number.
|
|
1946
3252
|
*
|
|
1947
|
-
* @
|
|
1948
|
-
* const provingKey = ProvingKey.fromBytes("split_proving_key.bin");
|
|
1949
|
-
* provingKey.isSplitProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3253
|
+
* @param {Field} serial_number The serial number to check for
|
|
1950
3254
|
*
|
|
1951
|
-
* @returns {
|
|
3255
|
+
* @returns {bool} True if the transition contains a serial number, false otherwise
|
|
1952
3256
|
*/
|
|
1953
|
-
|
|
3257
|
+
containsSerialNumber(serial_number: Field): boolean;
|
|
1954
3258
|
/**
|
|
1955
|
-
*
|
|
1956
|
-
*
|
|
1957
|
-
* @example
|
|
1958
|
-
* const provingKey = ProvingKey.fromBytes("transfer_private_proving_key.bin");
|
|
1959
|
-
* provingKey.isTransferPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
1960
|
-
*
|
|
1961
|
-
* @returns {boolean} returns true if the proving key is for the transfer_private function, false if otherwise
|
|
3259
|
+
* Find a record in the transition by the record's commitment.
|
|
1962
3260
|
*/
|
|
1963
|
-
|
|
3261
|
+
findRecord(commitment: Field): RecordCiphertext | undefined;
|
|
1964
3262
|
/**
|
|
1965
|
-
*
|
|
3263
|
+
* Get the record plaintext present in a transition owned by a specific view key.
|
|
1966
3264
|
*
|
|
1967
|
-
* @
|
|
1968
|
-
* const provingKey = ProvingKey.fromBytes("transfer_private_to_public_proving_key.bin");
|
|
1969
|
-
* provingKey.isTransferPrivateToPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3265
|
+
* @param {ViewKey} view_key The view key of the record owner.
|
|
1970
3266
|
*
|
|
1971
|
-
* @returns {
|
|
3267
|
+
* @returns {Array<RecordPlaintext>} Array of record plaintext objects
|
|
1972
3268
|
*/
|
|
1973
|
-
|
|
3269
|
+
ownedRecords(view_key: ViewKey): Array<any>;
|
|
1974
3270
|
/**
|
|
1975
|
-
*
|
|
1976
|
-
*
|
|
1977
|
-
* @example
|
|
1978
|
-
* const provingKey = ProvingKey.fromBytes("transfer_public_proving_key.bin");
|
|
1979
|
-
* provingKey.isTransferPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3271
|
+
* Get the records present in a transition and their commitments.
|
|
1980
3272
|
*
|
|
1981
|
-
* @returns {
|
|
3273
|
+
* @returns {Array<{commitment: Field, record: RecordCiphertext}>} Array of record ciphertext objects
|
|
1982
3274
|
*/
|
|
1983
|
-
|
|
3275
|
+
records(): Array<any>;
|
|
1984
3276
|
/**
|
|
1985
|
-
*
|
|
3277
|
+
* Get the inputs of the transition.
|
|
1986
3278
|
*
|
|
1987
|
-
* @
|
|
1988
|
-
*
|
|
1989
|
-
* provingKey.isTransferPublicAsSignerProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3279
|
+
* @param {bool} convert_to_js If true the inputs will be converted to JS objects, if false
|
|
3280
|
+
* the inputs will be in wasm format.
|
|
1990
3281
|
*
|
|
1991
|
-
* @returns {
|
|
3282
|
+
* @returns {Array} Array of inputs
|
|
1992
3283
|
*/
|
|
1993
|
-
|
|
3284
|
+
inputs(convert_to_js: boolean): Array<any>;
|
|
1994
3285
|
/**
|
|
1995
|
-
*
|
|
3286
|
+
* Get the outputs of the transition.
|
|
1996
3287
|
*
|
|
1997
|
-
* @
|
|
1998
|
-
*
|
|
1999
|
-
* provingKey.isTransferPublicToPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3288
|
+
* @param {bool} convert_to_js If true the outputs will be converted to JS objects, if false
|
|
3289
|
+
* the outputs will be in wasm format.
|
|
2000
3290
|
*
|
|
2001
|
-
* @returns {
|
|
3291
|
+
* @returns {Array} Array of outputs
|
|
2002
3292
|
*/
|
|
2003
|
-
|
|
3293
|
+
outputs(convert_to_js: boolean): Array<any>;
|
|
2004
3294
|
/**
|
|
2005
|
-
*
|
|
2006
|
-
*
|
|
2007
|
-
* @example
|
|
2008
|
-
* const provingKey = ProvingKey.fromBytes("unbond_public.bin");
|
|
2009
|
-
* provingKey.isUnbondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
3295
|
+
* Get the transition public key of the transition.
|
|
2010
3296
|
*
|
|
2011
|
-
* @returns {
|
|
3297
|
+
* @returns {Group} Transition public key
|
|
2012
3298
|
*/
|
|
2013
|
-
|
|
3299
|
+
tpk(): Group;
|
|
2014
3300
|
/**
|
|
2015
|
-
*
|
|
3301
|
+
* Get the transition view key of the transition.
|
|
2016
3302
|
*
|
|
2017
|
-
* @
|
|
2018
|
-
*/
|
|
2019
|
-
checksum(): string;
|
|
2020
|
-
/**
|
|
2021
|
-
* Create a copy of the proving key
|
|
3303
|
+
* @param {ViewKey} view_key The view key of the transition signer.
|
|
2022
3304
|
*
|
|
2023
|
-
* @returns {
|
|
3305
|
+
* @returns {Field} Transition view key
|
|
2024
3306
|
*/
|
|
2025
|
-
|
|
3307
|
+
tvk(view_key: ViewKey): Field;
|
|
2026
3308
|
/**
|
|
2027
|
-
*
|
|
3309
|
+
* Get the transition commitment of the transition.
|
|
2028
3310
|
*
|
|
2029
|
-
* @
|
|
2030
|
-
* @returns {ProvingKey}
|
|
3311
|
+
* @returns {Field} Transition commitment
|
|
2031
3312
|
*/
|
|
2032
|
-
|
|
3313
|
+
tcm(): Field;
|
|
2033
3314
|
/**
|
|
2034
|
-
*
|
|
3315
|
+
* Get the transition signer commitment of the transition.
|
|
2035
3316
|
*
|
|
2036
|
-
* @
|
|
3317
|
+
* @returns {Field} Transition signer commitment
|
|
2037
3318
|
*/
|
|
2038
|
-
|
|
3319
|
+
scm(): Field;
|
|
2039
3320
|
/**
|
|
2040
|
-
*
|
|
3321
|
+
* Decrypt the transition using the transition view key.
|
|
2041
3322
|
*
|
|
2042
|
-
* @
|
|
2043
|
-
*/
|
|
2044
|
-
toBytes(): Uint8Array;
|
|
2045
|
-
/**
|
|
2046
|
-
* Get a string representation of the proving key
|
|
3323
|
+
* @param {Field} tvk The transition view key.
|
|
2047
3324
|
*
|
|
2048
|
-
* @returns {
|
|
3325
|
+
* @returns {Transition} The transition with public values for inputs and outputs.
|
|
2049
3326
|
*/
|
|
2050
|
-
|
|
3327
|
+
decryptTransition(tvk: Field): Transition;
|
|
2051
3328
|
}
|
|
2052
|
-
|
|
2053
|
-
* Represents a proving request to a prover.
|
|
2054
|
-
*/
|
|
2055
|
-
export class ProvingRequest {
|
|
3329
|
+
export class U128 {
|
|
2056
3330
|
private constructor();
|
|
2057
3331
|
free(): void;
|
|
2058
3332
|
/**
|
|
2059
|
-
* Creates
|
|
2060
|
-
*
|
|
2061
|
-
* @param {Authorization} authorization An Authorization for a function.
|
|
2062
|
-
* @param {Authorization} fee_authorization The authorization for the `credits.aleo/fee_public` or `credits.aleo/fee_private` function that pays the fee for the execution of the main function.
|
|
2063
|
-
* @param {boolean} broadcast Flag that indicates whether the remote proving service should attempt to submit the transaction on the caller's behalf.
|
|
2064
|
-
*/
|
|
2065
|
-
static new(authorization: Authorization, fee_authorization: Authorization | null | undefined, broadcast: boolean): ProvingRequest;
|
|
2066
|
-
/**
|
|
2067
|
-
* Creates a ProvingRequest from a string representation.
|
|
2068
|
-
*
|
|
2069
|
-
* @param {Uint8Array} request String representation of the ProvingRequest.
|
|
3333
|
+
* Creates from string.
|
|
2070
3334
|
*/
|
|
2071
|
-
static fromString(
|
|
3335
|
+
static fromString(s: string): U128;
|
|
2072
3336
|
/**
|
|
2073
|
-
*
|
|
3337
|
+
* To string.
|
|
2074
3338
|
*/
|
|
2075
3339
|
toString(): string;
|
|
2076
3340
|
/**
|
|
2077
|
-
*
|
|
2078
|
-
*
|
|
2079
|
-
* @param {Uint8Array} bytes Left-endian bytes representing the proving request.
|
|
3341
|
+
* From bytes (LE).
|
|
2080
3342
|
*/
|
|
2081
|
-
static fromBytesLe(bytes: Uint8Array):
|
|
3343
|
+
static fromBytesLe(bytes: Uint8Array): U128;
|
|
2082
3344
|
/**
|
|
2083
|
-
*
|
|
3345
|
+
* To bytes (LE).
|
|
2084
3346
|
*/
|
|
2085
3347
|
toBytesLe(): Uint8Array;
|
|
2086
3348
|
/**
|
|
2087
|
-
*
|
|
3349
|
+
* From bits.
|
|
2088
3350
|
*/
|
|
2089
|
-
|
|
3351
|
+
static fromBitsLe(bits: Array<any>): U128;
|
|
2090
3352
|
/**
|
|
2091
|
-
*
|
|
3353
|
+
* To bits.
|
|
2092
3354
|
*/
|
|
2093
|
-
|
|
3355
|
+
toBitsLe(): Array<any>;
|
|
2094
3356
|
/**
|
|
2095
|
-
*
|
|
3357
|
+
* Checked absolute value.
|
|
2096
3358
|
*/
|
|
2097
|
-
|
|
3359
|
+
absChecked(): U128;
|
|
2098
3360
|
/**
|
|
2099
|
-
*
|
|
3361
|
+
* Wrapped absolute value.
|
|
2100
3362
|
*/
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
3363
|
+
absWrapped(): U128;
|
|
3364
|
+
/**
|
|
3365
|
+
* Wrapped addition.
|
|
3366
|
+
*/
|
|
3367
|
+
addWrapped(other: U128): U128;
|
|
3368
|
+
/**
|
|
3369
|
+
* Wrapped subtraction.
|
|
3370
|
+
*/
|
|
3371
|
+
subWrapped(other: U128): U128;
|
|
3372
|
+
/**
|
|
3373
|
+
* Wrapped multiplication.
|
|
3374
|
+
*/
|
|
3375
|
+
mulWrapped(other: U128): U128;
|
|
3376
|
+
/**
|
|
3377
|
+
* Wrapped division.
|
|
3378
|
+
*/
|
|
3379
|
+
divWrapped(other: U128): U128;
|
|
2109
3380
|
/**
|
|
2110
|
-
*
|
|
2111
|
-
*
|
|
2112
|
-
* @param {string} record String representation of a record ciphertext
|
|
2113
|
-
* @returns {RecordCiphertext} Record ciphertext
|
|
3381
|
+
* Power to a u8 exponent.
|
|
2114
3382
|
*/
|
|
2115
|
-
|
|
3383
|
+
powU8(exponent: U8): U128;
|
|
2116
3384
|
/**
|
|
2117
|
-
*
|
|
2118
|
-
*
|
|
2119
|
-
* @returns {string} String representation of the record ciphertext
|
|
3385
|
+
* Power to a u16 exponent.
|
|
2120
3386
|
*/
|
|
2121
|
-
|
|
3387
|
+
powU16(exponent: U16): U128;
|
|
2122
3388
|
/**
|
|
2123
|
-
*
|
|
2124
|
-
* decrypt if the record was encrypted by the account corresponding to the view key
|
|
2125
|
-
*
|
|
2126
|
-
* @param {ViewKey} view_key View key used to decrypt the ciphertext
|
|
2127
|
-
* @returns {RecordPlaintext} Record plaintext object
|
|
3389
|
+
* Power to a u32 exponent.
|
|
2128
3390
|
*/
|
|
2129
|
-
|
|
3391
|
+
powU32(exponent: U32): U128;
|
|
2130
3392
|
/**
|
|
2131
|
-
*
|
|
2132
|
-
* supplied view key belongs to the record owner.
|
|
2133
|
-
*
|
|
2134
|
-
* @param {ViewKey} view_key View key used to generate the record view key
|
|
2135
|
-
*
|
|
2136
|
-
* @returns {Group} record view key
|
|
3393
|
+
* Negates the integer (e.g., 5 → -5).
|
|
2137
3394
|
*/
|
|
2138
|
-
|
|
3395
|
+
neg(): U128;
|
|
2139
3396
|
/**
|
|
2140
|
-
*
|
|
2141
|
-
*
|
|
2142
|
-
* @param {ViewKey} view_key View key used to decrypt the ciphertext
|
|
2143
|
-
* @returns {boolean}
|
|
3397
|
+
* Checks equality with another integer.
|
|
2144
3398
|
*/
|
|
2145
|
-
|
|
3399
|
+
equals(other: U128): boolean;
|
|
2146
3400
|
/**
|
|
2147
|
-
*
|
|
2148
|
-
*
|
|
2149
|
-
* @param {GraphKey} graph key of the account associatd with the record.
|
|
2150
|
-
* @param {Field} commitment of the record.
|
|
2151
|
-
*
|
|
2152
|
-
* @returns {Field} tag of the record.
|
|
3401
|
+
* Remainder.
|
|
2153
3402
|
*/
|
|
2154
|
-
|
|
3403
|
+
rem(other: U128): U128;
|
|
2155
3404
|
/**
|
|
2156
|
-
*
|
|
2157
|
-
*
|
|
2158
|
-
* @param {Uint8Array} bytes A left endian byte array representing the record ciphertext.
|
|
2159
|
-
*
|
|
2160
|
-
* @returns {RecordCiphertext}
|
|
3405
|
+
* Wrapped remainder.
|
|
2161
3406
|
*/
|
|
2162
|
-
|
|
3407
|
+
remWrapped(other: U128): U128;
|
|
2163
3408
|
/**
|
|
2164
|
-
*
|
|
2165
|
-
*
|
|
2166
|
-
* @returns {Uint8Array} Left endian byte array representation of the record ciphertext.
|
|
3409
|
+
* Convert to Scalar.
|
|
2167
3410
|
*/
|
|
2168
|
-
|
|
3411
|
+
toScalar(): Scalar;
|
|
2169
3412
|
/**
|
|
2170
|
-
*
|
|
2171
|
-
*
|
|
2172
|
-
* returns {Array} Left endian boolean array representation of the bits of the record ciphertext.
|
|
3413
|
+
* Convert to plaintext.
|
|
2173
3414
|
*/
|
|
2174
|
-
|
|
3415
|
+
toPlaintext(): Plaintext;
|
|
2175
3416
|
/**
|
|
2176
|
-
*
|
|
2177
|
-
*
|
|
2178
|
-
* @returns {Array} Field array representation of the record ciphertext.
|
|
3417
|
+
* Convert from Field.
|
|
2179
3418
|
*/
|
|
2180
|
-
|
|
3419
|
+
static fromField(field: Field): U128;
|
|
2181
3420
|
/**
|
|
2182
|
-
*
|
|
2183
|
-
*
|
|
2184
|
-
* @param {Field} record_vk Record view key used to decrypt the record.
|
|
2185
|
-
*
|
|
2186
|
-
* @returns {RecordPlaintext}
|
|
3421
|
+
* Convert from Fields.
|
|
2187
3422
|
*/
|
|
2188
|
-
|
|
3423
|
+
static fromFields(fields: Array<any>): U128;
|
|
2189
3424
|
/**
|
|
2190
|
-
*
|
|
2191
|
-
*
|
|
2192
|
-
* @returns {Group} The record nonce.
|
|
3425
|
+
* Clone.
|
|
2193
3426
|
*/
|
|
2194
|
-
|
|
3427
|
+
clone(): U128;
|
|
2195
3428
|
}
|
|
2196
|
-
|
|
2197
|
-
* Plaintext representation of an Aleo record
|
|
2198
|
-
*/
|
|
2199
|
-
export class RecordPlaintext {
|
|
3429
|
+
export class U16 {
|
|
2200
3430
|
private constructor();
|
|
2201
3431
|
free(): void;
|
|
2202
|
-
commitment(program_id: string, record_name: string, record_view_key: string): Field;
|
|
2203
3432
|
/**
|
|
2204
|
-
*
|
|
2205
|
-
*
|
|
2206
|
-
* @param {string} record String representation of a plaintext representation of an Aleo record.
|
|
2207
|
-
*
|
|
2208
|
-
* @returns {RecordPlaintext} Record plaintext
|
|
3433
|
+
* Creates from string.
|
|
2209
3434
|
*/
|
|
2210
|
-
static fromString(
|
|
3435
|
+
static fromString(s: string): U16;
|
|
2211
3436
|
/**
|
|
2212
|
-
*
|
|
2213
|
-
*
|
|
2214
|
-
* @param {string} input The key to retrieve the value in the record data field.
|
|
2215
|
-
*
|
|
2216
|
-
* @returns {Plaintext} The plaintext value corresponding to the key.
|
|
3437
|
+
* To string.
|
|
2217
3438
|
*/
|
|
2218
|
-
|
|
3439
|
+
toString(): string;
|
|
2219
3440
|
/**
|
|
2220
|
-
*
|
|
2221
|
-
*
|
|
2222
|
-
* @returns {Address} Address of the owner of the record.
|
|
3441
|
+
* From bytes (LE).
|
|
2223
3442
|
*/
|
|
2224
|
-
|
|
3443
|
+
static fromBytesLe(bytes: Uint8Array): U16;
|
|
2225
3444
|
/**
|
|
2226
|
-
*
|
|
2227
|
-
* computations. Note that this is not a reversible operation and exists for the convenience
|
|
2228
|
-
* of discovering and using properties of the record.
|
|
2229
|
-
*
|
|
2230
|
-
* The conversion guide is as follows:
|
|
2231
|
-
* - u8, u16, u32, i8, i16 i32 --> Number
|
|
2232
|
-
* - u64, u128, i64, i128 --> BigInt
|
|
2233
|
-
* - Address, Field, Group, Scalar --> String.
|
|
2234
|
-
*
|
|
2235
|
-
* Address, Field, Group, and Scalar will all be converted to their bech32 string
|
|
2236
|
-
* representation. These string representations can be converted back to their respective wasm
|
|
2237
|
-
* types using the fromString method on the Address, Field, Group, and Scalar objects in this
|
|
2238
|
-
* library.
|
|
2239
|
-
*
|
|
2240
|
-
* @example
|
|
2241
|
-
* # Create a wasm record from a record string.
|
|
2242
|
-
* let record_plaintext_wasm = RecordPlainext.from_string("{
|
|
2243
|
-
* owner: aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48.private,
|
|
2244
|
-
* metadata: {
|
|
2245
|
-
* player1: aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48.private,
|
|
2246
|
-
* player2: aleo1dreuxnmg9cny8ee9v2u0wr4v4affnwm09u2pytfwz0f2en2shgqsdsfjn6.private,
|
|
2247
|
-
* nonce: 660310649780728486489183263981322848354071976582883879926426319832534836534field.private
|
|
2248
|
-
* },
|
|
2249
|
-
* id: 1953278585719525811355617404139099418855053112960441725284031425961000152405field.private,
|
|
2250
|
-
* positions: 50794271u64.private,
|
|
2251
|
-
* attempts: 0u64.private,
|
|
2252
|
-
* hits: 0u64.private,
|
|
2253
|
-
* _nonce: 5668100912391182624073500093436664635767788874314097667746354181784048204413group.public
|
|
2254
|
-
* }");
|
|
2255
|
-
*
|
|
2256
|
-
* let expected_object = {
|
|
2257
|
-
* owner: "aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48",
|
|
2258
|
-
* metadata: {
|
|
2259
|
-
* player1: "aleo1kh5t7m30djl0ecdn4f5vuzp7dx0tcwh7ncquqjkm4matj2p2zqpqm6at48",
|
|
2260
|
-
* player2: "aleo1dreuxnmg9cny8ee9v2u0wr4v4affnwm09u2pytfwz0f2en2shgqsdsfjn6",
|
|
2261
|
-
* nonce: "660310649780728486489183263981322848354071976582883879926426319832534836534field"
|
|
2262
|
-
* },
|
|
2263
|
-
* id: "1953278585719525811355617404139099418855053112960441725284031425961000152405field",
|
|
2264
|
-
* positions: 50794271,
|
|
2265
|
-
* attempts: 0,
|
|
2266
|
-
* hits: 0,
|
|
2267
|
-
* _nonce: "5668100912391182624073500093436664635767788874314097667746354181784048204413group"
|
|
2268
|
-
* };
|
|
2269
|
-
*
|
|
2270
|
-
* # Create the expected object
|
|
2271
|
-
* let record_plaintext_object = record_plaintext_wasm.to_js_object();
|
|
2272
|
-
* assert(JSON.stringify(record_plaintext_object) == JSON.stringify(expected_object));
|
|
2273
|
-
*
|
|
2274
|
-
* @returns {Object} Javascript object representation of the record
|
|
3445
|
+
* To bytes (LE).
|
|
2275
3446
|
*/
|
|
2276
|
-
|
|
3447
|
+
toBytesLe(): Uint8Array;
|
|
2277
3448
|
/**
|
|
2278
|
-
*
|
|
2279
|
-
*
|
|
2280
|
-
* @returns {string} String representation of the record plaintext
|
|
3449
|
+
* From bits.
|
|
2281
3450
|
*/
|
|
2282
|
-
|
|
3451
|
+
static fromBitsLe(bits: Array<any>): U16;
|
|
2283
3452
|
/**
|
|
2284
|
-
*
|
|
2285
|
-
*
|
|
2286
|
-
* @param {Uint8Array} bytes A left endian byte array representing the record plaintext.
|
|
2287
|
-
*
|
|
2288
|
-
* @returns {RecordPlaintext} The record plaintext.
|
|
3453
|
+
* To bits.
|
|
2289
3454
|
*/
|
|
2290
|
-
|
|
3455
|
+
toBitsLe(): Array<any>;
|
|
2291
3456
|
/**
|
|
2292
|
-
*
|
|
2293
|
-
*
|
|
2294
|
-
* @returns {Uint8Array} Byte array representation of the record plaintext.
|
|
3457
|
+
* Checked absolute value.
|
|
2295
3458
|
*/
|
|
2296
|
-
|
|
3459
|
+
absChecked(): U16;
|
|
2297
3460
|
/**
|
|
2298
|
-
*
|
|
2299
|
-
*
|
|
2300
|
-
* @returns {Array} Boolean array representation of the record plaintext bits.
|
|
3461
|
+
* Wrapped absolute value.
|
|
2301
3462
|
*/
|
|
2302
|
-
|
|
3463
|
+
absWrapped(): U16;
|
|
2303
3464
|
/**
|
|
2304
|
-
*
|
|
3465
|
+
* Wrapped addition.
|
|
2305
3466
|
*/
|
|
2306
|
-
|
|
3467
|
+
addWrapped(other: U16): U16;
|
|
2307
3468
|
/**
|
|
2308
|
-
*
|
|
2309
|
-
*
|
|
2310
|
-
* @returns {u64} Amount of microcredits in the record
|
|
3469
|
+
* Wrapped subtraction.
|
|
2311
3470
|
*/
|
|
2312
|
-
|
|
3471
|
+
subWrapped(other: U16): U16;
|
|
2313
3472
|
/**
|
|
2314
|
-
*
|
|
2315
|
-
*
|
|
2316
|
-
* @returns {string} Nonce of the record
|
|
3473
|
+
* Wrapped multiplication.
|
|
2317
3474
|
*/
|
|
2318
|
-
|
|
3475
|
+
mulWrapped(other: U16): U16;
|
|
2319
3476
|
/**
|
|
2320
|
-
*
|
|
2321
|
-
*
|
|
2322
|
-
* @param {PrivateKey} private_key Private key of the account that owns the record
|
|
2323
|
-
* @param {string} program_id Program ID of the program that the record is associated with
|
|
2324
|
-
* @param {string} record_name Name of the record
|
|
2325
|
-
* @param {string} record_view_key The string representation of the record view key.
|
|
2326
|
-
*
|
|
2327
|
-
* @returns {string} Serial number of the record
|
|
3477
|
+
* Wrapped division.
|
|
2328
3478
|
*/
|
|
2329
|
-
|
|
3479
|
+
divWrapped(other: U16): U16;
|
|
2330
3480
|
/**
|
|
2331
|
-
*
|
|
3481
|
+
* Power to a u8 exponent.
|
|
2332
3482
|
*/
|
|
2333
|
-
|
|
3483
|
+
powU8(exponent: U8): U16;
|
|
2334
3484
|
/**
|
|
2335
|
-
*
|
|
2336
|
-
* supplied view key belongs to the record owner.
|
|
2337
|
-
*
|
|
2338
|
-
* @param {ViewKey} view_key View key used to generate the record view key
|
|
2339
|
-
*
|
|
2340
|
-
* @returns {Group} record view key
|
|
3485
|
+
* Power to a u16 exponent.
|
|
2341
3486
|
*/
|
|
2342
|
-
|
|
2343
|
-
}
|
|
2344
|
-
/**
|
|
2345
|
-
* Scalar field element.
|
|
2346
|
-
*/
|
|
2347
|
-
export class Scalar {
|
|
2348
|
-
private constructor();
|
|
2349
|
-
free(): void;
|
|
3487
|
+
powU16(exponent: U16): U16;
|
|
2350
3488
|
/**
|
|
2351
|
-
*
|
|
3489
|
+
* Power to a u32 exponent.
|
|
2352
3490
|
*/
|
|
2353
|
-
|
|
3491
|
+
powU32(exponent: U32): U16;
|
|
2354
3492
|
/**
|
|
2355
|
-
*
|
|
3493
|
+
* Negates the integer (e.g., 5 → -5).
|
|
2356
3494
|
*/
|
|
2357
|
-
|
|
3495
|
+
neg(): U16;
|
|
2358
3496
|
/**
|
|
2359
|
-
*
|
|
3497
|
+
* Checks equality with another integer.
|
|
2360
3498
|
*/
|
|
2361
|
-
|
|
3499
|
+
equals(other: U16): boolean;
|
|
2362
3500
|
/**
|
|
2363
|
-
*
|
|
3501
|
+
* Remainder.
|
|
2364
3502
|
*/
|
|
2365
|
-
|
|
3503
|
+
rem(other: U16): U16;
|
|
2366
3504
|
/**
|
|
2367
|
-
*
|
|
3505
|
+
* Wrapped remainder.
|
|
2368
3506
|
*/
|
|
2369
|
-
|
|
3507
|
+
remWrapped(other: U16): U16;
|
|
2370
3508
|
/**
|
|
2371
|
-
*
|
|
3509
|
+
* Convert to Scalar.
|
|
2372
3510
|
*/
|
|
2373
|
-
|
|
3511
|
+
toScalar(): Scalar;
|
|
2374
3512
|
/**
|
|
2375
|
-
*
|
|
3513
|
+
* Convert to plaintext.
|
|
2376
3514
|
*/
|
|
2377
3515
|
toPlaintext(): Plaintext;
|
|
2378
3516
|
/**
|
|
2379
|
-
*
|
|
3517
|
+
* Convert from Field.
|
|
2380
3518
|
*/
|
|
2381
|
-
|
|
3519
|
+
static fromField(field: Field): U16;
|
|
2382
3520
|
/**
|
|
2383
|
-
*
|
|
3521
|
+
* Convert from Fields.
|
|
2384
3522
|
*/
|
|
2385
|
-
static
|
|
3523
|
+
static fromFields(fields: Array<any>): U16;
|
|
2386
3524
|
/**
|
|
2387
|
-
*
|
|
3525
|
+
* Clone.
|
|
2388
3526
|
*/
|
|
2389
|
-
|
|
3527
|
+
clone(): U16;
|
|
3528
|
+
}
|
|
3529
|
+
export class U32 {
|
|
3530
|
+
private constructor();
|
|
3531
|
+
free(): void;
|
|
2390
3532
|
/**
|
|
2391
|
-
*
|
|
3533
|
+
* Creates from string.
|
|
2392
3534
|
*/
|
|
2393
|
-
|
|
3535
|
+
static fromString(s: string): U32;
|
|
2394
3536
|
/**
|
|
2395
|
-
*
|
|
3537
|
+
* To string.
|
|
2396
3538
|
*/
|
|
2397
|
-
|
|
3539
|
+
toString(): string;
|
|
2398
3540
|
/**
|
|
2399
|
-
*
|
|
3541
|
+
* From bytes (LE).
|
|
2400
3542
|
*/
|
|
2401
|
-
|
|
3543
|
+
static fromBytesLe(bytes: Uint8Array): U32;
|
|
2402
3544
|
/**
|
|
2403
|
-
*
|
|
3545
|
+
* To bytes (LE).
|
|
2404
3546
|
*/
|
|
2405
|
-
|
|
3547
|
+
toBytesLe(): Uint8Array;
|
|
2406
3548
|
/**
|
|
2407
|
-
*
|
|
3549
|
+
* From bits.
|
|
2408
3550
|
*/
|
|
2409
|
-
|
|
3551
|
+
static fromBitsLe(bits: Array<any>): U32;
|
|
2410
3552
|
/**
|
|
2411
|
-
*
|
|
3553
|
+
* To bits.
|
|
2412
3554
|
*/
|
|
2413
|
-
|
|
3555
|
+
toBitsLe(): Array<any>;
|
|
2414
3556
|
/**
|
|
2415
|
-
*
|
|
3557
|
+
* Checked absolute value.
|
|
2416
3558
|
*/
|
|
2417
|
-
|
|
3559
|
+
absChecked(): U32;
|
|
2418
3560
|
/**
|
|
2419
|
-
*
|
|
3561
|
+
* Wrapped absolute value.
|
|
2420
3562
|
*/
|
|
2421
|
-
|
|
3563
|
+
absWrapped(): U32;
|
|
2422
3564
|
/**
|
|
2423
|
-
*
|
|
3565
|
+
* Wrapped addition.
|
|
2424
3566
|
*/
|
|
2425
|
-
|
|
2426
|
-
}
|
|
2427
|
-
/**
|
|
2428
|
-
* Cryptographic signature of a message signed by an Aleo account
|
|
2429
|
-
*/
|
|
2430
|
-
export class Signature {
|
|
2431
|
-
private constructor();
|
|
2432
|
-
free(): void;
|
|
3567
|
+
addWrapped(other: U32): U32;
|
|
2433
3568
|
/**
|
|
2434
|
-
*
|
|
2435
|
-
*
|
|
2436
|
-
* @param {PrivateKey} private_key The private key to sign the message with
|
|
2437
|
-
* @param {Uint8Array} message Byte representation of the message to sign
|
|
2438
|
-
* @returns {Signature} Signature of the message
|
|
3569
|
+
* Wrapped subtraction.
|
|
2439
3570
|
*/
|
|
2440
|
-
|
|
3571
|
+
subWrapped(other: U32): U32;
|
|
2441
3572
|
/**
|
|
2442
|
-
*
|
|
2443
|
-
*
|
|
2444
|
-
* @returns {Address} Address object
|
|
3573
|
+
* Wrapped multiplication.
|
|
2445
3574
|
*/
|
|
2446
|
-
|
|
3575
|
+
mulWrapped(other: U32): U32;
|
|
2447
3576
|
/**
|
|
2448
|
-
*
|
|
3577
|
+
* Wrapped division.
|
|
2449
3578
|
*/
|
|
2450
|
-
|
|
3579
|
+
divWrapped(other: U32): U32;
|
|
3580
|
+
/**
|
|
3581
|
+
* Power to a u8 exponent.
|
|
3582
|
+
*/
|
|
3583
|
+
powU8(exponent: U8): U32;
|
|
3584
|
+
/**
|
|
3585
|
+
* Power to a u16 exponent.
|
|
3586
|
+
*/
|
|
3587
|
+
powU16(exponent: U16): U32;
|
|
2451
3588
|
/**
|
|
2452
|
-
*
|
|
3589
|
+
* Power to a u32 exponent.
|
|
2453
3590
|
*/
|
|
2454
|
-
|
|
3591
|
+
powU32(exponent: U32): U32;
|
|
2455
3592
|
/**
|
|
2456
|
-
*
|
|
2457
|
-
*
|
|
2458
|
-
* @param {Address} address The address to verify the signature with
|
|
2459
|
-
* @param {Uint8Array} message Byte representation of the message to verify
|
|
2460
|
-
* @returns {boolean} True if the signature is valid, false otherwise
|
|
3593
|
+
* Negates the integer (e.g., 5 → -5).
|
|
2461
3594
|
*/
|
|
2462
|
-
|
|
3595
|
+
neg(): U32;
|
|
2463
3596
|
/**
|
|
2464
|
-
*
|
|
2465
|
-
*
|
|
2466
|
-
* @param {Uint8Array} bytes A left endian byte array representing the signature.
|
|
2467
|
-
*
|
|
2468
|
-
* @returns {Signature} The signature object.
|
|
3597
|
+
* Checks equality with another integer.
|
|
2469
3598
|
*/
|
|
2470
|
-
|
|
3599
|
+
equals(other: U32): boolean;
|
|
2471
3600
|
/**
|
|
2472
|
-
*
|
|
3601
|
+
* Remainder.
|
|
2473
3602
|
*/
|
|
2474
|
-
|
|
3603
|
+
rem(other: U32): U32;
|
|
2475
3604
|
/**
|
|
2476
|
-
*
|
|
2477
|
-
*
|
|
2478
|
-
* @param {Array} bits A left endian boolean array representing the bits of the signature.
|
|
2479
|
-
*
|
|
2480
|
-
* @returns {Signature} The signature object.
|
|
3605
|
+
* Wrapped remainder.
|
|
2481
3606
|
*/
|
|
2482
|
-
|
|
3607
|
+
remWrapped(other: U32): U32;
|
|
2483
3608
|
/**
|
|
2484
|
-
*
|
|
3609
|
+
* Convert to Scalar.
|
|
2485
3610
|
*/
|
|
2486
|
-
|
|
3611
|
+
toScalar(): Scalar;
|
|
2487
3612
|
/**
|
|
2488
|
-
*
|
|
3613
|
+
* Convert to plaintext.
|
|
2489
3614
|
*/
|
|
2490
|
-
|
|
3615
|
+
toPlaintext(): Plaintext;
|
|
2491
3616
|
/**
|
|
2492
|
-
*
|
|
2493
|
-
*
|
|
2494
|
-
* @param {string} signature String representation of a signature
|
|
2495
|
-
* @returns {Signature} Signature
|
|
3617
|
+
* Convert from Field.
|
|
2496
3618
|
*/
|
|
2497
|
-
static
|
|
3619
|
+
static fromField(field: Field): U32;
|
|
2498
3620
|
/**
|
|
2499
|
-
*
|
|
2500
|
-
*
|
|
2501
|
-
* @returns {string} String representation of a signature
|
|
3621
|
+
* Convert from Fields.
|
|
2502
3622
|
*/
|
|
2503
|
-
|
|
3623
|
+
static fromFields(fields: Array<any>): U32;
|
|
2504
3624
|
/**
|
|
2505
|
-
*
|
|
3625
|
+
* Clone.
|
|
2506
3626
|
*/
|
|
2507
|
-
|
|
3627
|
+
clone(): U32;
|
|
2508
3628
|
}
|
|
2509
|
-
|
|
2510
|
-
* Webassembly Representation of an Aleo transaction
|
|
2511
|
-
*
|
|
2512
|
-
* This object is created when generating an on-chain function deployment or execution and is the
|
|
2513
|
-
* object that should be submitted to the Aleo Network in order to deploy or execute a function.
|
|
2514
|
-
*/
|
|
2515
|
-
export class Transaction {
|
|
3629
|
+
export class U64 {
|
|
2516
3630
|
private constructor();
|
|
2517
3631
|
free(): void;
|
|
2518
3632
|
/**
|
|
2519
|
-
*
|
|
2520
|
-
*
|
|
2521
|
-
* @param {string} transaction String representation of a transaction
|
|
2522
|
-
* @returns {Transaction}
|
|
3633
|
+
* Creates from string.
|
|
2523
3634
|
*/
|
|
2524
|
-
static fromString(
|
|
3635
|
+
static fromString(s: string): U64;
|
|
2525
3636
|
/**
|
|
2526
|
-
*
|
|
2527
|
-
*
|
|
2528
|
-
* @param {Uint8Array} Uint8Array of left endian bytes encoding a Transaction.
|
|
2529
|
-
* @returns {Transaction}
|
|
3637
|
+
* To string.
|
|
2530
3638
|
*/
|
|
2531
|
-
|
|
3639
|
+
toString(): string;
|
|
2532
3640
|
/**
|
|
2533
|
-
*
|
|
2534
|
-
* this function will create the string that should be submitted in the `POST` data.
|
|
2535
|
-
*
|
|
2536
|
-
* @returns {string} String representation of the transaction
|
|
3641
|
+
* From bytes (LE).
|
|
2537
3642
|
*/
|
|
2538
|
-
|
|
3643
|
+
static fromBytesLe(bytes: Uint8Array): U64;
|
|
2539
3644
|
/**
|
|
2540
|
-
*
|
|
2541
|
-
*
|
|
2542
|
-
* @returns {Uint8Array} Uint8Array representation of the transaction
|
|
3645
|
+
* To bytes (LE).
|
|
2543
3646
|
*/
|
|
2544
3647
|
toBytesLe(): Uint8Array;
|
|
2545
3648
|
/**
|
|
2546
|
-
*
|
|
2547
|
-
*
|
|
2548
|
-
* @param {boolean} True if the transaction contains the given serial number.
|
|
3649
|
+
* From bits.
|
|
2549
3650
|
*/
|
|
2550
|
-
|
|
3651
|
+
static fromBitsLe(bits: Array<any>): U64;
|
|
2551
3652
|
/**
|
|
2552
|
-
*
|
|
2553
|
-
*
|
|
2554
|
-
* @param {boolean} True if the transaction contains the given commitment.
|
|
3653
|
+
* To bits.
|
|
2555
3654
|
*/
|
|
2556
|
-
|
|
3655
|
+
toBitsLe(): Array<any>;
|
|
2557
3656
|
/**
|
|
2558
|
-
*
|
|
3657
|
+
* Checked absolute value.
|
|
2559
3658
|
*/
|
|
2560
|
-
|
|
3659
|
+
absChecked(): U64;
|
|
2561
3660
|
/**
|
|
2562
|
-
*
|
|
3661
|
+
* Wrapped absolute value.
|
|
2563
3662
|
*/
|
|
2564
|
-
|
|
3663
|
+
absWrapped(): U64;
|
|
2565
3664
|
/**
|
|
2566
|
-
*
|
|
3665
|
+
* Wrapped addition.
|
|
2567
3666
|
*/
|
|
2568
|
-
|
|
3667
|
+
addWrapped(other: U64): U64;
|
|
2569
3668
|
/**
|
|
2570
|
-
*
|
|
2571
|
-
*
|
|
2572
|
-
* returns {bigint} The transaction's priority fee.
|
|
3669
|
+
* Wrapped subtraction.
|
|
2573
3670
|
*/
|
|
2574
|
-
|
|
3671
|
+
subWrapped(other: U64): U64;
|
|
2575
3672
|
/**
|
|
2576
|
-
*
|
|
2577
|
-
*
|
|
2578
|
-
* @returns {boolean} True if the transaction is a deployment transaction
|
|
3673
|
+
* Wrapped multiplication.
|
|
2579
3674
|
*/
|
|
2580
|
-
|
|
3675
|
+
mulWrapped(other: U64): U64;
|
|
2581
3676
|
/**
|
|
2582
|
-
*
|
|
2583
|
-
*
|
|
2584
|
-
* @returns {boolean} True if the transaction is an execution transaction
|
|
3677
|
+
* Wrapped division.
|
|
2585
3678
|
*/
|
|
2586
|
-
|
|
3679
|
+
divWrapped(other: U64): U64;
|
|
2587
3680
|
/**
|
|
2588
|
-
*
|
|
2589
|
-
*
|
|
2590
|
-
* @returns {boolean} True if the transaction is a fee transaction
|
|
3681
|
+
* Power to a u8 exponent.
|
|
2591
3682
|
*/
|
|
2592
|
-
|
|
3683
|
+
powU8(exponent: U8): U64;
|
|
2593
3684
|
/**
|
|
2594
|
-
*
|
|
2595
|
-
* transaction.
|
|
2596
|
-
*
|
|
2597
|
-
* @returns {Program | undefined} The program deployed within the transaction.
|
|
3685
|
+
* Power to a u16 exponent.
|
|
2598
3686
|
*/
|
|
2599
|
-
|
|
3687
|
+
powU16(exponent: U16): U64;
|
|
2600
3688
|
/**
|
|
2601
|
-
*
|
|
2602
|
-
*
|
|
2603
|
-
* @returns {Execution | undefined} The execution within the transaction.
|
|
3689
|
+
* Power to a u32 exponent.
|
|
2604
3690
|
*/
|
|
2605
|
-
|
|
3691
|
+
powU32(exponent: U32): U64;
|
|
2606
3692
|
/**
|
|
2607
|
-
*
|
|
2608
|
-
*
|
|
2609
|
-
* @param {ViewKey} view_key View key used to decrypt the ciphertext
|
|
2610
|
-
*
|
|
2611
|
-
* @returns {Array<RecordPlaintext>} Array of record plaintext objects
|
|
3693
|
+
* Negates the integer (e.g., 5 → -5).
|
|
2612
3694
|
*/
|
|
2613
|
-
|
|
3695
|
+
neg(): U64;
|
|
2614
3696
|
/**
|
|
2615
|
-
*
|
|
2616
|
-
*
|
|
2617
|
-
* @returns {Array<{commitment: Field, record: RecordCiphertext}>} Array of record ciphertext objects
|
|
3697
|
+
* Checks equality with another integer.
|
|
2618
3698
|
*/
|
|
2619
|
-
|
|
3699
|
+
equals(other: U64): boolean;
|
|
2620
3700
|
/**
|
|
2621
|
-
*
|
|
2622
|
-
*
|
|
2623
|
-
* If the transaction is an execution transaction, this function will return a list of the
|
|
2624
|
-
* transitions and their inputs and outputs.
|
|
2625
|
-
*
|
|
2626
|
-
* If the transaction is a deployment transaction, this function will return the program id and
|
|
2627
|
-
* a list of the functions and their verifying keys, constraint, and variable counts.
|
|
2628
|
-
*
|
|
2629
|
-
* @param {boolean} convert_to_js If true the inputs and outputs will be converted to JS objects,
|
|
2630
|
-
* if false the inputs and outputs will be in wasm format.
|
|
2631
|
-
*
|
|
2632
|
-
* @returns {Object} Transaction summary
|
|
3701
|
+
* Remainder.
|
|
2633
3702
|
*/
|
|
2634
|
-
|
|
3703
|
+
rem(other: U64): U64;
|
|
2635
3704
|
/**
|
|
2636
|
-
*
|
|
2637
|
-
*
|
|
2638
|
-
* This value can be used to query the status of the transaction on the Aleo Network to see
|
|
2639
|
-
* if it was successful. If successful, the transaction will be included in a block and this
|
|
2640
|
-
* value can be used to lookup the transaction data on-chain.
|
|
2641
|
-
*
|
|
2642
|
-
* @returns {string} TransactionId
|
|
3705
|
+
* Wrapped remainder.
|
|
2643
3706
|
*/
|
|
2644
|
-
|
|
3707
|
+
remWrapped(other: U64): U64;
|
|
2645
3708
|
/**
|
|
2646
|
-
*
|
|
2647
|
-
*
|
|
2648
|
-
* @returns {string} Transaction type
|
|
3709
|
+
* Convert to Scalar.
|
|
2649
3710
|
*/
|
|
2650
|
-
|
|
3711
|
+
toScalar(): Scalar;
|
|
2651
3712
|
/**
|
|
2652
|
-
*
|
|
2653
|
-
*
|
|
2654
|
-
* @returns {Array<Transition>} Array of transition objects
|
|
3713
|
+
* Convert to plaintext.
|
|
2655
3714
|
*/
|
|
2656
|
-
|
|
3715
|
+
toPlaintext(): Plaintext;
|
|
2657
3716
|
/**
|
|
2658
|
-
*
|
|
2659
|
-
*
|
|
2660
|
-
* @returns {Array<Object>} Array of verifying keys.
|
|
3717
|
+
* Convert from Field.
|
|
2661
3718
|
*/
|
|
2662
|
-
|
|
3719
|
+
static fromField(field: Field): U64;
|
|
3720
|
+
/**
|
|
3721
|
+
* Convert from Fields.
|
|
3722
|
+
*/
|
|
3723
|
+
static fromFields(fields: Array<any>): U64;
|
|
3724
|
+
/**
|
|
3725
|
+
* Clone.
|
|
3726
|
+
*/
|
|
3727
|
+
clone(): U64;
|
|
2663
3728
|
}
|
|
2664
|
-
export class
|
|
3729
|
+
export class U8 {
|
|
2665
3730
|
private constructor();
|
|
2666
3731
|
free(): void;
|
|
2667
3732
|
/**
|
|
2668
|
-
*
|
|
2669
|
-
*
|
|
2670
|
-
* @returns {string} The transition ID
|
|
3733
|
+
* Creates from string.
|
|
2671
3734
|
*/
|
|
2672
|
-
|
|
3735
|
+
static fromString(s: string): U8;
|
|
2673
3736
|
/**
|
|
2674
|
-
*
|
|
2675
|
-
*
|
|
2676
|
-
* @param {string} transition String representation of a transition
|
|
2677
|
-
* @returns {Transition}
|
|
3737
|
+
* To string.
|
|
2678
3738
|
*/
|
|
2679
|
-
|
|
3739
|
+
toString(): string;
|
|
2680
3740
|
/**
|
|
2681
|
-
*
|
|
2682
|
-
*
|
|
2683
|
-
* @param {Uint8Array} Uint8Array of left endian bytes encoding a Transition.
|
|
2684
|
-
* @returns {Transition}
|
|
3741
|
+
* From bytes (LE).
|
|
2685
3742
|
*/
|
|
2686
|
-
static fromBytesLe(bytes: Uint8Array):
|
|
3743
|
+
static fromBytesLe(bytes: Uint8Array): U8;
|
|
2687
3744
|
/**
|
|
2688
|
-
*
|
|
2689
|
-
* this function will create the string that should be submitted in the `POST` data.
|
|
2690
|
-
*
|
|
2691
|
-
* @returns {string} String representation of the transition
|
|
3745
|
+
* To bytes (LE).
|
|
2692
3746
|
*/
|
|
2693
|
-
|
|
3747
|
+
toBytesLe(): Uint8Array;
|
|
2694
3748
|
/**
|
|
2695
|
-
*
|
|
2696
|
-
*
|
|
2697
|
-
* @returns {Uint8Array} Uint8Array representation of the transition
|
|
3749
|
+
* From bits.
|
|
2698
3750
|
*/
|
|
2699
|
-
|
|
3751
|
+
static fromBitsLe(bits: Array<any>): U8;
|
|
2700
3752
|
/**
|
|
2701
|
-
*
|
|
3753
|
+
* To bits.
|
|
2702
3754
|
*/
|
|
2703
|
-
|
|
3755
|
+
toBitsLe(): Array<any>;
|
|
2704
3756
|
/**
|
|
2705
|
-
*
|
|
3757
|
+
* Checked absolute value.
|
|
2706
3758
|
*/
|
|
2707
|
-
|
|
3759
|
+
absChecked(): U8;
|
|
2708
3760
|
/**
|
|
2709
|
-
*
|
|
2710
|
-
*
|
|
2711
|
-
* @param {boolean} True if the transition contains the given commitment.
|
|
3761
|
+
* Wrapped absolute value.
|
|
2712
3762
|
*/
|
|
2713
|
-
|
|
3763
|
+
absWrapped(): U8;
|
|
2714
3764
|
/**
|
|
2715
|
-
*
|
|
2716
|
-
*
|
|
2717
|
-
* @param {Field} serial_number The serial number to check for
|
|
2718
|
-
*
|
|
2719
|
-
* @returns {bool} True if the transition contains a serial number, false otherwise
|
|
3765
|
+
* Wrapped addition.
|
|
2720
3766
|
*/
|
|
2721
|
-
|
|
3767
|
+
addWrapped(other: U8): U8;
|
|
2722
3768
|
/**
|
|
2723
|
-
*
|
|
3769
|
+
* Wrapped subtraction.
|
|
2724
3770
|
*/
|
|
2725
|
-
|
|
3771
|
+
subWrapped(other: U8): U8;
|
|
2726
3772
|
/**
|
|
2727
|
-
*
|
|
2728
|
-
*
|
|
2729
|
-
* @param {ViewKey} view_key The view key of the record owner.
|
|
2730
|
-
*
|
|
2731
|
-
* @returns {Array<RecordPlaintext>} Array of record plaintext objects
|
|
3773
|
+
* Wrapped multiplication.
|
|
2732
3774
|
*/
|
|
2733
|
-
|
|
3775
|
+
mulWrapped(other: U8): U8;
|
|
2734
3776
|
/**
|
|
2735
|
-
*
|
|
2736
|
-
*
|
|
2737
|
-
* @returns {Array<{commitment: Field, record: RecordCiphertext}>} Array of record ciphertext objects
|
|
3777
|
+
* Wrapped division.
|
|
2738
3778
|
*/
|
|
2739
|
-
|
|
3779
|
+
divWrapped(other: U8): U8;
|
|
2740
3780
|
/**
|
|
2741
|
-
*
|
|
2742
|
-
*
|
|
2743
|
-
* @param {bool} convert_to_js If true the inputs will be converted to JS objects, if false
|
|
2744
|
-
* the inputs will be in wasm format.
|
|
2745
|
-
*
|
|
2746
|
-
* @returns {Array} Array of inputs
|
|
3781
|
+
* Power to a u8 exponent.
|
|
2747
3782
|
*/
|
|
2748
|
-
|
|
3783
|
+
powU8(exponent: U8): U8;
|
|
2749
3784
|
/**
|
|
2750
|
-
*
|
|
2751
|
-
*
|
|
2752
|
-
* @param {bool} convert_to_js If true the outputs will be converted to JS objects, if false
|
|
2753
|
-
* the outputs will be in wasm format.
|
|
2754
|
-
*
|
|
2755
|
-
* @returns {Array} Array of outputs
|
|
3785
|
+
* Power to a u16 exponent.
|
|
2756
3786
|
*/
|
|
2757
|
-
|
|
3787
|
+
powU16(exponent: U16): U8;
|
|
2758
3788
|
/**
|
|
2759
|
-
*
|
|
2760
|
-
*
|
|
2761
|
-
* @returns {Group} Transition public key
|
|
3789
|
+
* Power to a u32 exponent.
|
|
2762
3790
|
*/
|
|
2763
|
-
|
|
3791
|
+
powU32(exponent: U32): U8;
|
|
2764
3792
|
/**
|
|
2765
|
-
*
|
|
2766
|
-
*
|
|
2767
|
-
* @param {ViewKey} view_key The view key of the transition signer.
|
|
2768
|
-
*
|
|
2769
|
-
* @returns {Field} Transition view key
|
|
3793
|
+
* Negates the integer (e.g., 5 → -5).
|
|
2770
3794
|
*/
|
|
2771
|
-
|
|
3795
|
+
neg(): U8;
|
|
2772
3796
|
/**
|
|
2773
|
-
*
|
|
2774
|
-
*
|
|
2775
|
-
* @returns {Field} Transition commitment
|
|
3797
|
+
* Checks equality with another integer.
|
|
2776
3798
|
*/
|
|
2777
|
-
|
|
3799
|
+
equals(other: U8): boolean;
|
|
2778
3800
|
/**
|
|
2779
|
-
*
|
|
2780
|
-
*
|
|
2781
|
-
* @returns {Field} Transition signer commitment
|
|
3801
|
+
* Remainder.
|
|
2782
3802
|
*/
|
|
2783
|
-
|
|
3803
|
+
rem(other: U8): U8;
|
|
2784
3804
|
/**
|
|
2785
|
-
*
|
|
2786
|
-
*
|
|
2787
|
-
* @param {Field} tvk The transition view key.
|
|
2788
|
-
*
|
|
2789
|
-
* @returns {Transition} The transition with public values for inputs and outputs.
|
|
3805
|
+
* Wrapped remainder.
|
|
2790
3806
|
*/
|
|
2791
|
-
|
|
3807
|
+
remWrapped(other: U8): U8;
|
|
3808
|
+
/**
|
|
3809
|
+
* Convert to Scalar.
|
|
3810
|
+
*/
|
|
3811
|
+
toScalar(): Scalar;
|
|
3812
|
+
/**
|
|
3813
|
+
* Convert to plaintext.
|
|
3814
|
+
*/
|
|
3815
|
+
toPlaintext(): Plaintext;
|
|
3816
|
+
/**
|
|
3817
|
+
* Convert from Field.
|
|
3818
|
+
*/
|
|
3819
|
+
static fromField(field: Field): U8;
|
|
3820
|
+
/**
|
|
3821
|
+
* Convert from Fields.
|
|
3822
|
+
*/
|
|
3823
|
+
static fromFields(fields: Array<any>): U8;
|
|
3824
|
+
/**
|
|
3825
|
+
* Clone.
|
|
3826
|
+
*/
|
|
3827
|
+
clone(): U8;
|
|
2792
3828
|
}
|
|
2793
3829
|
/**
|
|
2794
3830
|
* Verifying key for a function within an Aleo program
|
|
@@ -3048,6 +4084,10 @@ export class ViewKey {
|
|
|
3048
4084
|
* Get the underlying scalar of a view key.
|
|
3049
4085
|
*/
|
|
3050
4086
|
to_scalar(): Scalar;
|
|
4087
|
+
/**
|
|
4088
|
+
* Cast the view key to a field.
|
|
4089
|
+
*/
|
|
4090
|
+
toField(): Field;
|
|
3051
4091
|
/**
|
|
3052
4092
|
* Decrypt a record ciphertext with a view key
|
|
3053
4093
|
*
|