@provablehq/wasm
Version:
SnarkVM WASM binaries with javascript bindings
1,713 lines • 145 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
export function runRayonThread(receiver: number): void;
export function initThreadPool(url: URL, num_threads: number): Promise<void>;
/**
* Verify an execution. Executions with multiple transitions must have the program source code and
* verifying keys of imported functions supplied from outside to correctly verify. Also, this does
* not verify that the state root of the execution is included in the Aleo Network ledger.
*
* @param {Execution} execution The function execution to verify
* @param {VerifyingKey} verifying_key The verifying key for the function
* @param {Program} program The program that the function execution belongs to
* @param {String} function_id The name of the function that was executed
* @param {Object} imports The imports for the program in the form of { "program_id.aleo":"source code", ... }
* @param {Object} import_verifying_keys The verifying keys for the imports in the form of { "program_id.aleo": [["function, "verifying_key"], ...], ...}
* @returns {boolean} True if the execution is valid, false otherwise
*/
export function verifyFunctionExecution(execution: Execution, verifying_key: VerifyingKey, program: Program, function_id: string, imports: object | null | undefined, imported_verifying_keys: object | null | undefined, block_height: number): boolean;
/**
* Set test consensus version heights for testing.
*
* @param {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
*
* @example
* import { getOrInitConsensusVersionHeights } from @provablehq/sdk;
*
* Set the consensus version heights.
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10");
*/
export function getOrInitConsensusVersionTestHeights(heights?: string | null): Array<any>;
/**
* Public address of an Aleo account
*/
export class Address {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Get an address object from a group.
*
* @param {Group} group The group object.
*
* @returns {Address} The address object.
*/
static fromGroup(group: Group): Address;
/**
* Get the left endian boolean array representation of the bits of the address.
*/
toBitsLe(): Array<any>;
/**
* Get an address object from an array of fields.
*
* @param {Array} fields An array of fields.
*
* @returns {Plaintext} The address object.
*/
static fromFields(fields: Array<any>): Address;
/**
* Create an aleo address object from a string representation of an address
*
* @param {string} address String representation of an addressm
* @returns {Address} Address
*/
static from_string(address: string): Address;
/**
* Get the left endian byte array representation of the address.
*/
toBytesLe(): Uint8Array;
/**
* Get an address from a series of bits represented as a boolean array.
*
* @param {Array} bits A left endian boolean array representing the bits of the address.
*
* @returns {Address} The address object.
*/
static fromBitsLe(bits: Array<any>): Address;
/**
* Get the plaintext representation of the address.
*/
toPlaintext(): Plaintext;
/**
* Get an address from a series of bytes.
*
* @param {Uint8Array} bytes A left endian byte array representing the address.
*
* @returns {Address} The address object.
*/
static fromBytesLe(bytes: Uint8Array): Address;
/**
* Derive an Aleo address from a view key
*
* @param {ViewKey} view_key The view key to derive the address from
* @returns {Address} Address corresponding to the view key
*/
static from_view_key(view_key: ViewKey): Address;
/**
* Get the address of a program based on the program ID.
*
* @param {string} program_id The program ID string.
* @returns {Address} The address corresponding to the program ID.
*/
static fromProgramId(program_id: string): Address;
/**
* Derive an Aleo address from a compute key.
*
* @param {ComputeKey} compute_key The compute key to derive the address from
*/
static from_compute_key(compute_key: ComputeKey): Address;
/**
* Derive an Aleo address from a private key
*
* @param {PrivateKey} private_key The private key to derive the address from
* @returns {Address} Address corresponding to the private key
*/
static from_private_key(private_key: PrivateKey): Address;
/**
* Verify a signature for a message signed by the address
*
* @param {Uint8Array} Byte array representing a message signed by the address
* @returns {boolean} Boolean representing whether or not the signature is valid
*/
verify(message: Uint8Array, signature: Signature): boolean;
/**
* Get the group representation of the address object.
*/
toGroup(): Group;
/**
* Get the field array representation of the address.
*/
toFields(): Array<any>;
/**
* Get a string representation of an Aleo address object
*
* @param {Address} Address
* @returns {string} String representation of the address
*/
to_string(): string;
}
/**
* Authorization object containing the authorization for a transaction.
*/
export class Authorization {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Reconstructs an Authorization object from its string representation.
*
* @param {String} authorization The string representation of the Authorization.
*/
static fromString(authorization: string): Authorization;
/**
* Returns the left-endian byte representation of the Authorization.
*/
toBytesLe(): Uint8Array;
/**
* Get the transitions in an Authorization.
*
* @returns {Array<Transition>} Array of transition objects
*/
transitions(): Array<any>;
/**
* Creates an authorization object from a left-endian byte representation of an Authorization.
*
* @param {Uint8Array} bytes Left-endian bytes representing the Authorization.
*/
static fromBytesLe(bytes: Uint8Array): Authorization;
/**
* Get the function name.
*
* @returns {string} The function name.
*/
functionName(): string;
/**
* Returns `true` if the Authorization is for `credits.aleo/fee_public`.
*/
isFeePublic(): boolean;
/**
* Returns `true` if the Authorization is for `credits.aleo/fee_private`.
*/
isFeePrivate(): boolean;
/**
* Returns the execution ID for the Authorization.
*
* @returns {Field} The execution ID for the Authorization, call toString() after this result to get the string representation.
*/
toExecutionId(): Field;
/**
* Insert a transition into the Authorization.
*
* @param {Transition} transition The transition object to insert into the Authorization.
*/
insertTransition(transition: Transition): void;
/**
* Returns the number of `Request`s in the Authorization.
*/
len(): number;
/**
* Create a new authorization from a request object.
*
* @param {ExecutionRequest} request The ExecutionRequest to build the authorization from.
*/
static new(request: ExecutionRequest): Authorization;
/**
* Check if an Authorization object is the same as another.
*
* @param {Authorization} other The Authorization object to determine equality with.
*/
equals(other: Authorization): boolean;
/**
* Return `true` if the Authorization is empty.
*/
isEmpty(): boolean;
/**
* Returns `true` if the Authorization is for `credits.aleo/split`.
*/
isSplit(): boolean;
/**
* Returns a new and independent replica of the Authorization.
*/
replicate(): Authorization;
/**
* Returns the string representation of the Authorization.
*/
toString(): string;
}
export class BHP1024 {
free(): void;
[Symbol.dispose](): void;
/**
* Returns a BHP hash with an input hasher of 1024 bits.
*/
hashToGroup(input: Array<any>): Group;
/**
* Returns a BHP commitment with an input hasher of 1024 bits and randomizer.
*/
commitToGroup(input: Array<any>, randomizer: Scalar): Group;
/**
* Create a BHP hasher with an input size of 1024 bits.
*/
constructor();
/**
* Returns the BHP hash with an input hasher of 1024 bits.
*/
hash(input: Array<any>): Field;
/**
* Create a BHP hasher with an input size of 1024 bits with a custom domain separator.
*/
static setup(domain_separator: string): BHP1024;
/**
* Returns a BHP commitment with an input hasher of 1024 bits and randomizer.
*/
commit(input: Array<any>, randomizer: Scalar): Field;
}
export class BHP256 {
free(): void;
[Symbol.dispose](): void;
/**
* Returns a BHP hash with an input hasher of 256 bits.
*/
hashToGroup(input: Array<any>): Group;
/**
* Returns a BHP commitment with an input hasher of 256 bits and randomizer.
*/
commitToGroup(input: Array<any>, randomizer: Scalar): Group;
/**
* Create a BHP hasher with an input size of 256 bits.
*/
constructor();
/**
* Returns the BHP hash with an input hasher of 256 bits.
*/
hash(input: Array<any>): Field;
/**
* Create a BHP hasher with an input size of 256 bits with a custom domain separator.
*/
static setup(domain_separator: string): BHP256;
/**
* Returns a BHP commitment with an input hasher of 256 bits and randomizer.
*/
commit(input: Array<any>, randomizer: Scalar): Field;
}
export class BHP512 {
free(): void;
[Symbol.dispose](): void;
/**
* Returns a BHP hash with an input hasher of 512 bits.
*/
hashToGroup(input: Array<any>): Group;
/**
* Returns a BHP commitment with an input hasher of 512 bits and randomizer.
*/
commitToGroup(input: Array<any>, randomizer: Scalar): Group;
/**
* Create a BHP hasher with an input size of 512 bits.
*/
constructor();
/**
* Returns the BHP hash with an input hasher of 512 bits.
*/
hash(input: Array<any>): Field;
/**
* Create a BHP hasher with an input size of 512 bits with a custom domain separator.
*/
static setup(domain_separator: string): BHP512;
/**
* Returns a BHP commitment with an input hasher of 512 bits and randomizer.
*/
commit(input: Array<any>, randomizer: Scalar): Field;
}
export class BHP768 {
free(): void;
[Symbol.dispose](): void;
/**
* Returns a BHP hash with an input hasher of 768 bits.
*/
hashToGroup(input: Array<any>): Group;
/**
* Returns a BHP commitment with an input hasher of 768 bits and randomizer.
*/
commitToGroup(input: Array<any>, randomizer: Scalar): Group;
/**
* Create a BHP hasher with an input size of 768 bits.
*/
constructor();
/**
* Returns the BHP hash with an input hasher of 768 bits.
*/
hash(input: Array<any>): Field;
/**
* Create a BHP hasher with an input size of 768 bits with a custom domain separator.
*/
static setup(domain_separator: string): BHP768;
/**
* Returns a BHP commitment with an input hasher of 768 bits and randomizer.
*/
commit(input: Array<any>, randomizer: Scalar): Field;
}
/**
* Boolean element.
*/
export class Boolean {
free(): void;
[Symbol.dispose](): void;
/**
* Get the left endian boolean array representation of the boolean element.
*/
toBitsLe(): Array<any>;
/**
* Creates a boolean object from a string representation ("true"/"false").
*/
static fromString(boolean: string): Boolean;
/**
* Encode the boolean element as a Uint8Array of left endian bytes.
*/
toBytesLe(): Uint8Array;
/**
* Reconstruct a boolean element from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): Boolean;
/**
* Create a plaintext from the boolean element.
*/
toPlaintext(): Plaintext;
/**
* Create a boolean element from a Uint8Array of left endian bytes.
*/
static fromBytesLe(bytes: Uint8Array): Boolean;
/**
* Logical OR.
*/
or(other: Boolean): Boolean;
/**
* Logical AND.
*/
and(other: Boolean): Boolean;
/**
* Creates a Boolean from a native JS bool.
*/
constructor(value: boolean);
/**
* Logical NOR.
*/
nor(other: Boolean): Boolean;
/**
* Logical NOT.
*/
not(): Boolean;
/**
* Logical XOR.
*/
xor(other: Boolean): Boolean;
/**
* Logical NAND.
*/
nand(other: Boolean): Boolean;
/**
* Clone the boolean element.
*/
clone(): Boolean;
/**
* Check if one boolean element equals another.
*/
equals(other: Boolean): boolean;
/**
* Generate a random boolean element.
*/
static random(): Boolean;
/**
* Returns the string representation of the boolean element.
*/
toString(): string;
}
/**
* SnarkVM Ciphertext object. A Ciphertext represents an symmetrically encrypted plaintext. This
* object provides decryption methods to recover the plaintext from the ciphertext (given the
* api consumer has the proper decryption materials).
*/
export class Ciphertext {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Get the left endian boolean array representation of the bits of the ciphertext.
*/
toBitsLe(): Array<any>;
/**
* Get a ciphertext object from an array of fields.
*
* @param {Array} fields An array of fields.
*
* @returns {Ciphertext} The ciphertext object.
*/
static fromFields(fields: Array<any>): Ciphertext;
/**
* Deserialize a Ciphertext string into a Ciphertext object.
*
* @param {string} ciphertext A string representation of the ciphertext.
*
* @returns {Ciphertext} The Ciphertext object.
*/
static fromString(ciphertext: string): Ciphertext;
/**
* Get the left endian byte array representation of the ciphertext.
*/
toBytesLe(): Uint8Array;
/**
* Get a ciphertext object from a series of bits represented as a boolean array.
*
* @param {Array} bits A left endian boolean array representing the bits of the ciphertext.
*
* @returns {Ciphertext} The ciphertext object.
*/
static fromBitsLe(bits: Array<any>): Ciphertext;
/**
* Deserialize a left endian byte array into a Ciphertext.
*
* @param {Uint8Array} bytes The byte array representing the Ciphertext.
*
* @returns {Ciphertext} The Ciphertext object.
*/
static fromBytesLe(bytes: Uint8Array): Ciphertext;
/**
* Decrypts a ciphertext into plaintext using the given ciphertext view key.
*
* @param {Field} transition_view_key The transition view key that was used to encrypt the ciphertext.
*
* @returns {Plaintext} The decrypted plaintext.
*/
decryptSymmetric(transition_view_key: Field): Plaintext;
/**
* Decrypt a ciphertext using the view key of the transition signer, transition public key, and
* (program, function, index) tuple.
*
* @param {ViewKey} view_key The view key of the transition signer.
* @param {Group} transition_public_key The transition public key used to encrypt the ciphertext.
* @param {string} program The program ID associated with the ciphertext.
* @param {string} function_name The name of the function associated with the encrypted inputs and outputs.
* @param {u16} index The index of the input or output parameter that was encrypted.
*
* @returns {Plaintext} The decrypted plaintext.
*/
decryptWithTransitionInfo(view_key: ViewKey, transition_public_key: Group, program: string, function_name: string, index: number): Plaintext;
/**
* Decrypt a ciphertext using the transition view key and a (program, function, index) tuple.
*
* @param {Field} transition_view_key The transition view key that was used to encrypt the ciphertext.
* @param {string} program The program ID associated with the ciphertext.
* @param {string} function_name The name of the function associated with the encrypted inputs and outputs.
* @param {u16} index The index of the input or output parameter that was encrypted.
*
* @returns {Plaintext} The decrypted plaintext.
*/
decryptWithTransitionViewKey(transition_view_key: Field, program: string, function_name: string, index: number): Plaintext;
/**
* Decrypt the ciphertext using the given view key.
*
* @param {ViewKey} viewKey The view key of the account that encrypted the ciphertext.
* @param {Group} nonce The nonce used to encrypt the ciphertext.
*
* @returns {Plaintext} The decrypted plaintext.
*/
decrypt(view_key: ViewKey, nonce: Group): Plaintext;
/**
* Serialize a Ciphertext object into a byte array.
*
* @returns {Uint8Array} The serialized Ciphertext.
*/
toBytes(): Uint8Array;
/**
* Get the field array representation of the ciphertext.
*/
toFields(): Array<any>;
/**
* Serialize a Ciphertext into a js string.
*
* @returns {string} The serialized Ciphertext.
*/
toString(): string;
}
export class ComputeKey {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Create a new compute key from a private key.
*
* @param {PrivateKey} private_key Private key
*
* @returns {ComputeKey} Compute key
*/
static from_private_key(private_key: PrivateKey): ComputeKey;
/**
* Get the pr_tag of the compute key.
*
* @returns {Group} pr_tag
*/
pk_sig(): Group;
/**
* Get the pr_sig of the compute key.
*
* @returns {Group} pr_sig
*/
pr_sig(): Group;
/**
* Get the sk_prf of the compute key.
*
* @returns {Scalar} sk_prf
*/
sk_prf(): Scalar;
/**
* Get the address from the compute key.
*
* @returns {Address}
*/
address(): Address;
}
/**
* EncryptionToolkit provides a set of functions for encrypting, decrypting, and generating individual view keys for records, transitions, and ciphertexts.
*/
export class EncryptionToolkit {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Generates a transition view key from the view key and the transition public key.
*
* @param {ViewKey} view_key The view key of the account that generated the transition.
* @param {Group} tpk The transition public key.
*
* @returns {Field} The transition view key.
*/
static generateTvk(view_key: ViewKey, tpk: Group): Field;
/**
* Decrypt the sender ciphertext associated with a record.
*
* @param {ViewKey} view_key View key associated with the record.
* @param {RecordPlaintext} record Record plaintext associated with a sender.
* @param {Field} sender_ciphertext Sender ciphertext associated with the record.
*
* @returns {Address} address of the sender.
*/
static decryptSender(view_key: ViewKey, record: RecordPlaintext, sender_ciphertext: Field): Address;
/**
* Checks if a record ciphertext is owned by the given view key.
*
* @param {ViewKey} view_key View key of the owner of the records.
* @param {Vec<RecordCiphertext>} records The record ciphertexts for which to check ownership.
*
* @returns {Vec<RecordCiphertext>} The record ciphertexts that are owned by the view key.
*/
static checkOwnedRecords(view_key: ViewKey, records: RecordCiphertext[]): RecordCiphertext[];
/**
* Decrypts a set of record ciphertexts in parallel and stores successful decryptions.
*
* @param {ViewKey} view_key The view key of the owner of the records.
* @param {Vec<RecordCiphertext>} records The record ciphertexts to decrypt.
*
* @returns {vec<RecordPlaintext>} The decrypted record plaintexts.
*/
static decryptOwnedRecords(view_key: ViewKey, records: RecordCiphertext[]): RecordPlaintext[];
/**
* Decrypt the sender ciphertext associated with the record with the record view key.
*
* @param {Field} record_view_key Record view key associated with the record.
* @param {Field} sender_ciphertext Sender ciphertext associated with the record.
*
* @return {Address} the address of the sender.
*/
static decryptSenderWithRvk(record_view_key: Field, sender_ciphertext: Field): Address;
/**
* Creates a record view key from the view key. This can be later be used to decrypt a
*
* @param {ViewKey} view_key The view key of the owner of the record.
* @param {RecordCiphertext} record_ciphertext The record ciphertext used to derive the record view key.
*
* @returns {Field} The record view key.
*/
static generateRecordViewKey(view_key: ViewKey, record_ciphertext: RecordCiphertext): Field;
/**
* Decrypts a transition using the transition view key. The ciphertext inputs and outputs
* can only be decrypted if the transition view key was generated by the transaction signer.
*
* @param {Transition} transition The transition to decrypt.
* @param {Field} transition_vk The transition view key.
*
* @returns {Transition} The decrypted transition.
*/
static decryptTransitionWithVk(transition: Transition, transition_vk: Field): Transition;
/**
* Decrypts a record ciphertext using the record view key. Decryption only succeeds
* if the record view key was generated from the view key of the record owner.
*
* @param {Field} record_vk The record view key.
* @param {RecordCiphertext} record_ciphertext The record ciphertext to decrypt.
*
* @returns {RecordPlaintext} The decrypted record plaintext.
*/
static decryptRecordWithRVk(record_vk: Field, record_ciphertext: RecordCiphertext): RecordPlaintext;
}
/**
* Execution of an Aleo program.
*/
export class Execution {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Creates an execution object from a string representation of an execution.
*
* @returns {Execution | Error} The wasm representation of an execution object.
*/
static fromString(execution: string): Execution;
/**
* Returns the transitions present in the execution.
*
* @returns Array<Transition> the array of transitions present in the execution.
*/
transitions(): Array<any>;
/**
* Returns the global state root of the execution.
*
* @returns {Execution | Error} The global state root used in the execution.
*/
globalStateRoot(): string;
/**
* Returns the proof of the execution.
*
* @returns {string} The execution proof.
*/
proof(): string;
/**
* Returns the string representation of the execution.
*
* @returns {string} The string representation of the execution.
*/
toString(): string;
}
export class ExecutionRequest {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Returns the network ID.
*/
network_id(): number;
/**
* Returns the program ID.
*/
program_id(): string;
/**
* Builds a request object from a string representation of a request.
*
* @param {string} request String representation of the request.
*/
static fromString(request: string): ExecutionRequest;
/**
* Returns the bytes representation of the request.
*/
toBytesLe(): Uint8Array;
/**
* Creates an request object from a bytes representation of an request.
*/
static fromBytesLe(bytes: Uint8Array): ExecutionRequest;
/**
* Returns the function name.
*/
function_name(): string;
/**
* Returns the signer commitment `scm`.
*/
scm(): Field;
/**
* Returns the transition commitment `tcm`.
*/
tcm(): Field;
/**
* Returns the transition view key `tvk`.
*/
tvk(): Field;
/**
* Create a new request by signing over a program ID and set of inputs.
*
* @param {PrivateKey} private_key The private key of the signer.
* @param {string} program_id The id of the program to create the signature for.
* @param {string} function_name The function name to create the signature for.
* @param {string[]} inputs The inputs to the function.
* @param {string[]} input_types The input types of the function.
* @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.
* @param {boolean} is_root Flag to indicate if this is the top level function in the call graph.
*/
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;
/**
* Returns the function inputs as an array of strings.
*/
inputs(): Array<any>;
/**
* Returns the request signer.
*/
signer(): Address;
/**
* Returns the tag secret key `sk_tag`.
*/
sk_tag(): Field;
/**
* Returns the transition public key `tpk`.
*/
to_tpk(): Group;
/**
* Verify the input types within a request.
*
* @param {string[]} The input_types within the request.
* @param {boolean} Flag to indicate whether this request is the first function in the call graph.
*/
verify(input_types: Array<any>, is_root: boolean, program_checksum?: Field | null): boolean;
/**
* Returns the input IDs for the transition.
*/
input_ids(): Array<any>;
/**
* Returns the signature for the transition.
*/
signature(): Signature;
/**
* Returns the request as a string.
*
* @returns {string} String representation of the request.
*/
toString(): string;
}
/**
* Webassembly Representation of an Aleo function execution response
*
* This object is returned by the execution of an Aleo function off-chain. It provides methods for
* retrieving the outputs of the function execution.
*/
export class ExecutionResponse {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Get the outputs of the executed function
*
* @returns {Array} Array of strings representing the outputs of the function
*/
getOutputs(): Array<any>;
/**
* Returns the program
*/
getProgram(): Program;
/**
* Returns the execution object if present, null if otherwise.
*
* @returns {Execution | undefined} The execution object if present, null if otherwise
*/
getExecution(): Execution | undefined;
/**
* Returns the function identifier
*/
getFunctionId(): string;
/**
* Returns the proving_key if the proving key was cached in the Execution response.
* Note the proving key is removed from the response object after the first call to this
* function. Subsequent calls will return null.
*
* @returns {ProvingKey | undefined} The proving key
*/
getProvingKey(): ProvingKey | undefined;
/**
* Returns the verifying_key associated with the program
*
* @returns {VerifyingKey} The verifying key
*/
getVerifyingKey(): VerifyingKey;
/**
* Returns the program keys if present
*/
getKeys(): KeyPair;
}
/**
* Field element.
*/
export class Field {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Get the left endian boolean array representation of the field element.
*/
toBitsLe(): Array<any>;
/**
* Creates a field object from a string representation of a field element.
*/
static fromString(field: string): Field;
/**
* Encode the field element as a Uint8Array of left endian bytes.
*/
toBytesLe(): Uint8Array;
/**
* Reconstruct a field element from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): Field;
/**
* Create a plaintext from the field element.
*/
toPlaintext(): Plaintext;
/**
* Create a field element from a Uint8Array of left endian bytes.
*/
static fromBytesLe(bytes: Uint8Array): Field;
/**
* Initializes a new field as a domain separator.
*/
static newDomainSeparator(domain: string): Field;
/**
* Add two field elements.
*/
add(other: Field): Field;
/**
* Get the multiplicative identity of the field.
*/
static one(): Field;
/**
* Power of a field element.
*/
pow(other: Field): Field;
/**
* Get the additive identity element of the field.
*/
static zero(): Field;
/**
* Clone the field element.
*/
clone(): Field;
/**
* Divide two field elements.
*/
divide(other: Field): Field;
/**
* Double the field element.
*/
double(): Field;
/**
* Check if one field element equals another.
*/
equals(other: Field): boolean;
/**
* Generate a random field element.
*/
static random(): Field;
/**
* Invert the field element.
*/
inverse(): Field;
/**
* Multiply two field elements.
*/
multiply(other: Field): Field;
/**
* Subtract two field elements.
*/
subtract(other: Field): Field;
/**
* Returns the string representation of the field element.
*/
toString(): string;
}
export class GraphKey {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Create a new graph key from a string representation of a graph key
*
* @param {string} graph_key String representation of a graph key
* @returns {GraphKey} Graph key
*/
static from_string(graph_key: string): GraphKey;
/**
* Create a new graph key from a view key.
*
* @param {ViewKey} view_key View key
* @returns {GraphKey} Graph key
*/
static from_view_key(view_key: ViewKey): GraphKey;
/**
* Get the sk_tag of the graph key. Used to determine ownership of records.
*/
sk_tag(): Field;
/**
* Get a string representation of a graph key
*
* @returns {string} String representation of a graph key
*/
to_string(): string;
}
/**
* Elliptic curve element.
*/
export class Group {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Get the left endian boolean array representation of the group element.
*/
toBitsLe(): Array<any>;
/**
* Creates a group object from a string representation of a group element.
*/
static fromString(group: string): Group;
/**
* Encode the group element as a Uint8Array of left endian bytes.
*/
toBytesLe(): Uint8Array;
/**
* Reconstruct a group element from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): Group;
/**
* Create a plaintext element from a group element.
*/
toPlaintext(): Plaintext;
/**
* Create a group element from a Uint8Array of left endian bytes.
*/
static fromBytesLe(bytes: Uint8Array): Group;
/**
* Multiply a group element by a scalar element.
*/
scalarMultiply(scalar: Scalar): Group;
/**
* Get the x-coordinate of the group element.
*/
toXCoordinate(): Field;
/**
* Add two group elements.
*/
add(other: Group): Group;
/**
* Get the group identity element under the group operation (i.e. the point at infinity.)
*/
static zero(): Group;
/**
* Clone the group element.
*/
clone(): Group;
/**
* Double the group element.
*/
double(): Group;
/**
* Check if one group element equals another.
*/
equals(other: Group): boolean;
/**
* Generate a random group element.
*/
static random(): Group;
/**
* Get the inverse of the group element. This is the reflection of the point about the axis
* of symmetry i.e. (x,y) -> (x, -y).
*/
inverse(): Group;
/**
* Subtract two group elements (equivalently: add the inverse of an element).
*/
subtract(other: Group): Group;
/**
* Get the generator of the group.
*/
static generator(): Group;
/**
* Get the field array representation of the group.
*/
toFields(): Array<any>;
/**
* Returns the string representation of the group element.
*/
toString(): string;
}
export class I128 {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Attempt to construct the integer from a field element.
*/
static fromField(field: Field): I128;
/**
* Get the boolean array representation of the integer.
*/
toBitsLe(): Array<any>;
/**
* Checked absolute value.
*/
absChecked(): I128;
/**
* Wrapped absolute value.
*/
absWrapped(): I128;
/**
* Wrapped addition with another integer.
*/
addWrapped(other: I128): I128;
/**
* Wrapped division.
*/
divWrapped(other: I128): I128;
/**
* Atttempt to construct the integer from a list of field elements.
*/
static fromFields(fields: Array<any>): I128;
/**
* Construct an integer from a string representation.
*/
static fromString(s: string): I128;
/**
* Wrapped multiplication with another integer.
*/
mulWrapped(other: I128): I128;
/**
* Get the remainder from an integer division which wraps if there's an overflow.
*/
remWrapped(other: I128): I128;
/**
* Wrapped subtraction with another integer.
*/
subWrapped(other: I128): I128;
/**
* Construct an integer from a byte array representation.
*/
toBytesLe(): Uint8Array;
/**
* Construct an integer from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): I128;
/**
* Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
*/
toPlaintext(): Plaintext;
/**
* Get the byte array representation of the integer.
*/
static fromBytesLe(bytes: Uint8Array): I128;
/**
* Negate the integer (e.g., 5 → -5).
*/
neg(): I128;
/**
* Get the remainder from integer division.
*/
rem(other: I128): I128;
/**
* Clone the integer in wasm memory.
*/
clone(): I128;
/**
* Check equality with another integer.
*/
equals(other: I128): boolean;
/**
* Exponentiate the integer with a u8 exponent.
*/
powU8(exponent: U8): I128;
/**
* Exponentiate the integer with a u16 exponent.
*/
powU16(exponent: U16): I128;
/**
* Exponentiate the integer with a u32 exponent.
*/
powU32(exponent: U32): I128;
/**
* Convert the integer to a Scalar value.
*/
toScalar(): Scalar;
/**
* Get the string representation of the integer.
*/
toString(): string;
}
export class I16 {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Attempt to construct the integer from a field element.
*/
static fromField(field: Field): I16;
/**
* Get the boolean array representation of the integer.
*/
toBitsLe(): Array<any>;
/**
* Checked absolute value.
*/
absChecked(): I16;
/**
* Wrapped absolute value.
*/
absWrapped(): I16;
/**
* Wrapped addition with another integer.
*/
addWrapped(other: I16): I16;
/**
* Wrapped division.
*/
divWrapped(other: I16): I16;
/**
* Atttempt to construct the integer from a list of field elements.
*/
static fromFields(fields: Array<any>): I16;
/**
* Construct an integer from a string representation.
*/
static fromString(s: string): I16;
/**
* Wrapped multiplication with another integer.
*/
mulWrapped(other: I16): I16;
/**
* Get the remainder from an integer division which wraps if there's an overflow.
*/
remWrapped(other: I16): I16;
/**
* Wrapped subtraction with another integer.
*/
subWrapped(other: I16): I16;
/**
* Construct an integer from a byte array representation.
*/
toBytesLe(): Uint8Array;
/**
* Construct an integer from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): I16;
/**
* Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
*/
toPlaintext(): Plaintext;
/**
* Get the byte array representation of the integer.
*/
static fromBytesLe(bytes: Uint8Array): I16;
/**
* Negate the integer (e.g., 5 → -5).
*/
neg(): I16;
/**
* Get the remainder from integer division.
*/
rem(other: I16): I16;
/**
* Clone the integer in wasm memory.
*/
clone(): I16;
/**
* Check equality with another integer.
*/
equals(other: I16): boolean;
/**
* Exponentiate the integer with a u8 exponent.
*/
powU8(exponent: U8): I16;
/**
* Exponentiate the integer with a u16 exponent.
*/
powU16(exponent: U16): I16;
/**
* Exponentiate the integer with a u32 exponent.
*/
powU32(exponent: U32): I16;
/**
* Convert the integer to a Scalar value.
*/
toScalar(): Scalar;
/**
* Get the string representation of the integer.
*/
toString(): string;
}
export class I32 {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Attempt to construct the integer from a field element.
*/
static fromField(field: Field): I32;
/**
* Get the boolean array representation of the integer.
*/
toBitsLe(): Array<any>;
/**
* Checked absolute value.
*/
absChecked(): I32;
/**
* Wrapped absolute value.
*/
absWrapped(): I32;
/**
* Wrapped addition with another integer.
*/
addWrapped(other: I32): I32;
/**
* Wrapped division.
*/
divWrapped(other: I32): I32;
/**
* Atttempt to construct the integer from a list of field elements.
*/
static fromFields(fields: Array<any>): I32;
/**
* Construct an integer from a string representation.
*/
static fromString(s: string): I32;
/**
* Wrapped multiplication with another integer.
*/
mulWrapped(other: I32): I32;
/**
* Get the remainder from an integer division which wraps if there's an overflow.
*/
remWrapped(other: I32): I32;
/**
* Wrapped subtraction with another integer.
*/
subWrapped(other: I32): I32;
/**
* Construct an integer from a byte array representation.
*/
toBytesLe(): Uint8Array;
/**
* Construct an integer from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): I32;
/**
* Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
*/
toPlaintext(): Plaintext;
/**
* Get the byte array representation of the integer.
*/
static fromBytesLe(bytes: Uint8Array): I32;
/**
* Negate the integer (e.g., 5 → -5).
*/
neg(): I32;
/**
* Get the remainder from integer division.
*/
rem(other: I32): I32;
/**
* Clone the integer in wasm memory.
*/
clone(): I32;
/**
* Check equality with another integer.
*/
equals(other: I32): boolean;
/**
* Exponentiate the integer with a u8 exponent.
*/
powU8(exponent: U8): I32;
/**
* Exponentiate the integer with a u16 exponent.
*/
powU16(exponent: U16): I32;
/**
* Exponentiate the integer with a u32 exponent.
*/
powU32(exponent: U32): I32;
/**
* Convert the integer to a Scalar value.
*/
toScalar(): Scalar;
/**
* Get the string representation of the integer.
*/
toString(): string;
}
export class I64 {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Attempt to construct the integer from a field element.
*/
static fromField(field: Field): I64;
/**
* Get the boolean array representation of the integer.
*/
toBitsLe(): Array<any>;
/**
* Checked absolute value.
*/
absChecked(): I64;
/**
* Wrapped absolute value.
*/
absWrapped(): I64;
/**
* Wrapped addition with another integer.
*/
addWrapped(other: I64): I64;
/**
* Wrapped division.
*/
divWrapped(other: I64): I64;
/**
* Atttempt to construct the integer from a list of field elements.
*/
static fromFields(fields: Array<any>): I64;
/**
* Construct an integer from a string representation.
*/
static fromString(s: string): I64;
/**
* Wrapped multiplication with another integer.
*/
mulWrapped(other: I64): I64;
/**
* Get the remainder from an integer division which wraps if there's an overflow.
*/
remWrapped(other: I64): I64;
/**
* Wrapped subtraction with another integer.
*/
subWrapped(other: I64): I64;
/**
* Construct an integer from a byte array representation.
*/
toBytesLe(): Uint8Array;
/**
* Construct an integer from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): I64;
/**
* Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
*/
toPlaintext(): Plaintext;
/**
* Get the byte array representation of the integer.
*/
static fromBytesLe(bytes: Uint8Array): I64;
/**
* Negate the integer (e.g., 5 → -5).
*/
neg(): I64;
/**
* Get the remainder from integer division.
*/
rem(other: I64): I64;
/**
* Clone the integer in wasm memory.
*/
clone(): I64;
/**
* Check equality with another integer.
*/
equals(other: I64): boolean;
/**
* Exponentiate the integer with a u8 exponent.
*/
powU8(exponent: U8): I64;
/**
* Exponentiate the integer with a u16 exponent.
*/
powU16(exponent: U16): I64;
/**
* Exponentiate the integer with a u32 exponent.
*/
powU32(exponent: U32): I64;
/**
* Convert the integer to a Scalar value.
*/
toScalar(): Scalar;
/**
* Get the string representation of the integer.
*/
toString(): string;
}
export class I8 {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Attempt to construct the integer from a field element.
*/
static fromField(field: Field): I8;
/**
* Get the boolean array representation of the integer.
*/
toBitsLe(): Array<any>;
/**
* Checked absolute value.
*/
absChecked(): I8;
/**
* Wrapped absolute value.
*/
absWrapped(): I8;
/**
* Wrapped addition with another integer.
*/
addWrapped(other: I8): I8;
/**
* Wrapped division.
*/
divWrapped(other: I8): I8;
/**
* Atttempt to construct the integer from a list of field elements.
*/
static fromFields(fields: Array<any>): I8;
/**
* Construct an integer from a string representation.
*/
static fromString(s: string): I8;
/**
* Wrapped multiplication with another integer.
*/
mulWrapped(other: I8): I8;
/**
* Get the remainder from an integer division which wraps if there's an overflow.
*/
remWrapped(other: I8): I8;
/**
* Wrapped subtraction with another integer.
*/
subWrapped(other: I8): I8;
/**
* Construct an integer from a byte array representation.
*/
toBytesLe(): Uint8Array;
/**
* Construct an integer from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): I8;
/**
* Convert the integer to the Plaintext type. This must be done before hashing an integer to ensure it matches hashes with a leo/aleo program.
*/
toPlaintext(): Plaintext;
/**
* Get the byte array representation of the integer.
*/
static fromBytesLe(bytes: Uint8Array): I8;
/**
* Negate the integer (e.g., 5 → -5).
*/
neg(): I8;
/**
* Get the remainder from integer division.
*/
rem(other: I8): I8;
/**
* Clone the integer in wasm memory.
*/
clone(): I8;
/**
* Check equality with another integer.
*/
equals(other: I8): boolean;
/**
* Exponentiate the integer with a u8 exponent.
*/
powU8(exponent: U8): I8;
/**
* Exponentiate the integer with a u16 exponent.
*/
powU16(exponent: U16): I8;
/**
* Exponentiate the integer with a u32 exponent.
*/
powU32(exponent: U32): I8;
/**
* Convert the integer to a Scalar value.
*/
toScalar(): Scalar;
/**
* Get the string representation of the integer.
*/
toString(): string;
}
/**
* Key pair object containing both the function proving and verifying keys
*/
export class KeyPair {
free(): void;
[Symbol.dispose](): void;
/**
* Get the proving key. This method will remove the proving key from the key pair
*
* @returns {ProvingKey}
*/
provingKey(): ProvingKey;
/**
* Get the verifying key. This method will remove the verifying key from the key pair
*
* @returns {VerifyingKey}
*/
verifyingKey(): VerifyingKey;
/**
* Create new key pair from proving and verifying keys
*
* @param {ProvingKey} proving_key Proving key corresponding to a function in an Aleo program
* @param {VerifyingKey} verifying_key Verifying key corresponding to a function in an Aleo program
* @returns {KeyPair} Key pair object containing both the function proving and verifying keys
*/
constructor(proving_key: ProvingKey, verifying_key: VerifyingKey);
}
export class Metadata {
private constructor();
free(): void;
[Symbol.dispose](): void;
static fee_public(): Metadata;
static bond_public(): Metadata;
static fee_private(): Metadata;
static unbond_public(): Metadata;
static bond_validator(): Metadata;
static transfer_public(): Metadata;
static transfer_private(): Metadata;
static claim_unbond_public(): Metadata;
static set_validator_state(): Metadata;
static transfer_public_as_signer(): Metadata;
static transfer_private_to_public(): Metadata;
static transfer_public_to_private(): Metadata;
static join(): Metadata;
static split(): Metadata;
static baseUrl(): string;
static inclusion(): Metadata;
name: string;
locator: string;
prover: string;
verifier: string;
verifyingKey: string;
}
/**
* An offline query object used to insert the global state root and state paths needed to create
* a valid inclusion proof offline.
*/
export class OfflineQuery {
free(): void;
[Symbol.dispose](): void;
/**
* Create an offline query object from a json string representation.
*
* @param {string} JSON string representation of the offline query object.
*/
static fromString(s: string): OfflineQuery;
/**
* Add a new state path to the offline query object.
*
* @param {string} commitment: The commitment corresponding to a record input.
* @param {string} state_path: The state path corresponding to the commitment.
*/
addStatePath(commitment: string, state_path: string): void;
/**
* Add a new block height to the offline query object.
*
* @param {u32} block_height The block height to add.
*/
addBlockHeight(block_height: number): void;
/**
* Creates a new offline query object. The state root is required to be passed in as a string
*
* @param {u32} block_height The block height.
* @param {string} state_root The state root of the current network.
*
* @returns {OfflineQuery} The newly created offline query object.
*/
constructor(block_height: number, state_root: string);
/**
* Get a json string representation of the offline query object.
*
* @returns {string} JSON string representation of the offline query object.
*/
toString(): string;
}
export class Pedersen128 {
free(): void;
[Symbol.dispose](): void;
/**
* Returns a Pedersen commitment for the given (up to) 128-bit input and randomizer.
*/
commitToGroup(input: Array<any>, randomizer: Scalar): Group;
/**
* Create a Pedersen hasher for a given (up to) 128-bit input.
*/
constructor();
/**
* Returns the Pedersen hash for a given (up to) 128-bit input.
*/
hash(input: Array<any>): Field;
/**
* Create a Pedersen hasher for a given (up to) 128-bit input with a custom domain separator.
*/
static setup(domain_separator: string): Pedersen128;
/**
* Returns a Pedersen commitment for the given (up to) 128-bit input and randomizer.
*/
commit(input: Array<any>, randomizer: Scalar): Field;
}
export class Pedersen64 {
free(): void;
[Symbol.dispose](): void;
/**
* Returns a Pedersen commitment for the given (up to) 64-bit input and randomizer.
*/
commitToGroup(input: Array<any>, randomizer: Scalar): Group;
/**
* Create a Pedersen hasher for a given (up to) 64-bit input.
*/
constructor();
/**
* Returns the Pedersen hash for a given (up to) 64-bit input.
*/
hash(input: Array<any>): Field;
/**
* Create a Pedersen64 hasher for a given (up to) 64-bit input with a custom domain separator.
*/
static setup(domain_separator: string): Pedersen64;
/**
* Returns a Pedersen commitment for the given (up to) 64-bit input and randomizer.
*/
commit(input: Array<any>, randomizer: Scalar): Field;
}
/**
* SnarkVM Plaintext object. Plaintext is a fundamental monadic type used to represent Aleo
* primitive types (boolean, field, group, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128,
* scalar, and signature), struct types, and array types.
*
* In the context of a web or NodeJS application, this type is useful for turning an Aleo type into
* a JS value, object, or array that might be necessary for performing computations within the
* application.
*
* @example
* // Get the bond state of an existing address.
* const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
* // Convert the bond state to a Plaintext object.
* const bondStatePlaintext = Plaintext.fromString(bond_state);
* // Convert the Plaintext object to a JS object.
* const bondStateObject = bond_state_plaintext.toObject();
* // Check if the bond state matches the expected object.
* const expectedObject = { validator: "aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f", microcredits: 100000000u64 };
* assert( JSON.stringify(bondStateObject) === JSON.stringify(expectedObject) );
*/
export class Plaintext {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Get the little endian boolean array representation of the bits of the plaintext.
*
* @returns {Array} The little endian boolean array representation of the bits of the plaintext.
*/
toBitsLe(): Array<any>;
/**
* Get a plaintext object from an array of fields.
*
* @param {Array} fields An array of fields.
*
* @returns {Plaintext} The plaintext object.
*/
static fromFields(fields: Array<any>): Plaintext;
/**
* Creates a plaintext object from a string representation of a plaintext.
*
* @param {string} plaintext The string representation of the plaintext.
*
*