@provablehq/wasm
Version:
SnarkVM WASM binaries with javascript bindings
1,554 lines • 199 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
export function runRayonThread(receiver: number): void;
export function initThreadPool(url: URL, num_threads: number): Promise<void>;
/**
* Set the WASM log level from JS. Called automatically by the SDK's
* `setLogLevel(level)` to keep TS and WASM logging in sync.
* Levels: 0=silent, 1=error, 2=warn, 3=info (default), 4=debug.
* Values above 4 are clamped to debug.
*/
export function setWasmLogLevel(level: number): 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, program_imports?: ProgramImports | null): boolean;
/**
* Verify a batch SNARK proof against multiple verifying keys and their corresponding public inputs.
*
* This function verifies a batch proof produced by Aleo programs that may not be deployed on chain.
* Each verifying key is paired with one or more sets of public inputs (instances).
*
* @param {Array<string>} verifying_keys Array of verifying key strings, one per circuit
* @param {Array<Array<Array<string>>>} inputs 3D array of field element strings [circuit_idx][instance_idx][field_idx]
* @param {Proof} proof The batch proof to verify
* @returns {boolean} True if the batch proof is valid, false otherwise
*/
export function snarkVerifyBatch(verifying_keys: Array<any>, inputs: Array<any>, proof: Proof): boolean;
/**
* Verify a SNARK proof against a verifying key and public inputs.
*
* This function verifies a proof produced by an Aleo program that may not be deployed on chain.
* It directly invokes the Varuna proof verification from snarkVM.
*
* @param {VerifyingKey} verifying_key The verifying key for the circuit
* @param {Array<string>} inputs Array of field element strings representing public inputs (e.g. ["1field", "2field"])
* @param {Proof} proof The proof to verify
* @returns {boolean} True if the proof is valid, false otherwise
*/
export function snarkVerify(verifying_key: VerifyingKey, inputs: Array<any>, proof: Proof): boolean;
export function stringToField(string: string): Field;
/**
* 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 { getOrInitConsensusVersionTestHeights } from '@provablehq/sdk';
*
* Set the consensus version heights.
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
*/
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.
* The input is automatically lowercased before parsing.
*
* @param {string} address String representation of an address
* @returns {Address} Address
*/
static from_string(address: string): Address;
/**
* Get the left endian byte array representation of the address.
*/
toBytesLe(): Uint8Array;
/**
* Cast the address to an I8 with lossy truncation.
*/
toI8Lossy(): I8;
/**
* Cast the address to a U8 with lossy truncation.
*/
toU8Lossy(): U8;
/**
* 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;
/**
* Cast the address to an I16 with lossy truncation.
*/
toI16Lossy(): I16;
/**
* Cast the address to an I32 with lossy truncation.
*/
toI32Lossy(): I32;
/**
* Cast the address to an I64 with lossy truncation.
*/
toI64Lossy(): I64;
/**
* Get the plaintext representation of the address.
*/
toPlaintext(): Plaintext;
/**
* Get a string representation of an Aleo address object
*
* @returns {string} String representation of the address
*/
toString(): string;
/**
* Cast the address to a U16 with lossy truncation.
*/
toU16Lossy(): U16;
/**
* Cast the address to a U32 with lossy truncation.
*/
toU32Lossy(): U32;
/**
* Cast the address to a U64 with lossy truncation.
*/
toU64Lossy(): U64;
/**
* 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;
/**
* Cast the address to an I128 with lossy truncation.
*/
toI128Lossy(): I128;
/**
* Cast the address to a U128 with lossy truncation.
*/
toU128Lossy(): U128;
/**
* 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;
/**
* Cast the address to a Scalar with lossy truncation (via x-coordinate).
*/
toScalarLossy(): Scalar;
/**
* 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;
/**
* Cast the address to a Boolean with lossy truncation (LSB of x-coordinate).
*/
toBooleanLossy(): Boolean;
/**
* 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;
/**
* Check if the input is a valid Aleo address.
* String addresses are automatically lowercased before validation.
*
* @param {string | Uint8Array} address - Either a string representation of an address
* or a Uint8Array of bytes in little-endian format.
* @returns {boolean} True if the input is a valid address, false otherwise.
*/
static isValid(address: any): boolean;
/**
* Cast the address to a Field element (x-coordinate of the underlying group point).
*/
toField(): Field;
/**
* 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;
/**
* Cast the boolean to an Address (strict, via Group). Returns an error if conversion fails.
*/
toAddress(): Address;
/**
* 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;
/**
* Cast the boolean to a Group element (lossy, via Field with Elligator-2 fallback).
* This conversion never fails.
*/
toGroupLossy(): Group;
/**
* Cast the boolean to an Address (lossy, via Group with Elligator-2 fallback).
*/
toAddressLossy(): Address;
/**
* 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;
/**
* Cast the boolean to an I8 (false=0, true=1).
*/
toI8(): I8;
/**
* Cast the boolean to a U8 (false=0, true=1).
*/
toU8(): U8;
/**
* Check if one boolean element equals another.
*/
equals(other: Boolean): boolean;
/**
* Generate a random boolean element.
*/
static random(): Boolean;
/**
* Cast the boolean to an I16 (false=0, true=1).
*/
toI16(): I16;
/**
* Cast the boolean to an I32 (false=0, true=1).
*/
toI32(): I32;
/**
* Cast the boolean to an I64 (false=0, true=1).
*/
toI64(): I64;
/**
* Cast the boolean to a U16 (false=0, true=1).
*/
toU16(): U16;
/**
* Cast the boolean to a U32 (false=0, true=1).
*/
toU32(): U32;
/**
* Cast the boolean to a U64 (false=0, true=1).
*/
toU64(): U64;
/**
* Cast the boolean to an I128 (false=0, true=1).
*/
toI128(): I128;
/**
* Cast the boolean to a U128 (false=0, true=1).
*/
toU128(): U128;
/**
* Cast the boolean to a Field element (false=0, true=1). Lossless.
*/
toField(): Field;
/**
* Cast the boolean to a Group element (strict, via Field x-coordinate recovery).
* Returns an error if the resulting field is not a valid x-coordinate.
*/
toGroup(): Group;
/**
* Cast the boolean to a Scalar element (false=0, true=1). Lossless.
*/
toScalar(): Scalar;
/**
* Returns the string representation of the boolean element.
*/
toString(): string;
}
/**
* A query implementation that delegates state fetching to JS callback functions.
*
* Instead of making direct HTTP calls via reqwest, each QueryTrait method
* calls a JS function that returns a Promise. The JS side handles the actual
* network request through the configured transport.
*/
export class CallbackQuery {
free(): void;
[Symbol.dispose](): void;
/**
* Create a new CallbackQuery with JS callback functions.
*
* @param {Function} get_state_root A function that returns Promise<string> (the state root)
* @param {Function} get_state_paths A function that takes string[] (commitments) and returns Promise<string[]> (state paths)
* @param {Function} get_block_height A function that returns Promise<number> (the block height)
*/
constructor(get_state_root: Function, get_state_paths: Function, get_block_height: Function);
}
/**
* 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;
}
/**
* A fixed-size representation of an Aleo record. Like static records, a dynamic record
* contains an owner, nonce, and a version, but instead of storing the full data it only
* stores the Merkle root of the data, ensuring all dynamic records have a constant size.
*/
export class DynamicRecord {
private constructor();
free(): void;
[Symbol.dispose](): void;
/**
* Returns the dynamic record as a little-endian bit array (JS Array of booleans).
*/
toBitsLe(): Array<any>;
/**
* Creates a DynamicRecord from a RecordPlaintext.
*/
static fromRecord(record: RecordPlaintext): DynamicRecord;
/**
* Creates a DynamicRecord from its string representation.
*/
static fromString(s: string): DynamicRecord;
/**
* Serializes the dynamic record to a little-endian byte array (Uint8Array).
*/
toBytesLe(): Uint8Array;
/**
* Deserializes a DynamicRecord from a little-endian byte array (Uint8Array).
*/
static fromBytesLe(bytes: Uint8Array): DynamicRecord;
/**
* Returns the Merkle root of the record data as a Field.
*/
root(): Field;
/**
* Returns the nonce of the record as a Group.
*/
nonce(): Group;
/**
* Returns the owner address of the dynamic record.
*/
owner(): Address;
/**
* Returns `true` if the dynamic record is a hiding variant (version != 0).
*/
isHiding(): boolean;
/**
* Returns the dynamic record as an array of field elements.
*/
toFields(): Array<any>;
/**
* Converts this DynamicRecord back to a RecordPlaintext.
* `owner_is_private` controls whether the owner field uses private or public visibility.
*/
toRecord(owner_is_private: boolean): RecordPlaintext;
/**
* Returns the string representation of the dynamic record.
*/
toString(): string;
}
/**
* 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;
/**
* Alias for `sk_tag` (camelCase).
*/
skTag(): Field;
/**
* Alias for `to_tpk` (camelCase).
*/
toTpk(): Group;
/**
* Creates an request object from a bytes representation of an request.
*/
static fromBytesLe(bytes: Uint8Array): ExecutionRequest;
/**
* Returns the function name.
*/
function_name(): string;
/**
* Alias for `input_ids` (camelCase).
*/
inputIds(): Array<any>;
/**
* Alias for `network_id` (camelCase).
*/
networkId(): number;
/**
* Alias for `program_id` (camelCase).
*/
programId(): string;
/**
* Alias for `function_name` (camelCase).
*/
functionName(): string;
/**
* Builds a request from externally-signed data using externally-supplied record view keys.
*
* For record inputs, the caller provides `record_view_keys` and `gammas` directly.
* The method uses these to compute commitment, serial number, tag, and InputID for each record.
*
* @param {string} program_id The id of the program.
* @param {string} function_name The function name.
* @param {string[]} inputs The inputs to the function.
* @param {string[]} input_types The input types of the function.
* @param {Signature} signature The externally-computed signature.
* @param {Field} tvk The transition view key.
* @param {Address} signer The signer address.
* @param {Field} sk_tag The tag secret key.
* @param {Field[] | undefined} record_view_keys Pre-computed record view keys (required when there are record inputs).
* @param {Group[] | undefined} gammas An array of gammas (required when there are record inputs).
*/
static fromExternallySignedData(program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, signature: Signature, tvk: Field, signer: Address, sk_tag: Field, record_view_keys?: Array<any> | null, gammas?: Array<any> | null): ExecutionRequest;
/**
* Computes the function ID and serialized input data for a program function call.
* This is a helper for external signing wallets and other applications that need to compute
* publicly computable inputs for the `Request::sign` function.
*
* @param {string} program_id The id of the program.
* @param {string} function_name The function name.
* @param {string[]} input_types The input types of the function as strings.
* @param {string[]} inputs The inputs to the function as strings.
* @param {boolean} is_root Flag to indicate if this is the top level function in the call graph.
* @param {Field | undefined} program_checksum The program checksum (required if the program has a constructor).
* @param {ViewKey | undefined} view_key The view key of the signer to compute a record's tag and h values.
*
* @returns {ExternalSigningInput}
*/
static computeExternalSigningInputs(program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, is_root: boolean, program_checksum?: Field | null, view_key?: ViewKey | null): object;
/**
* Returns the signer commitment `scm`.
*/
scm(): Field;
/**
* Returns the transition commitment `tcm`.
*/
tcm(): Field;
/**
* Returns the transition view key `tvk`.
*/
tvk(): Field;
/**
* Builds a request from externally-signed data using a view key to derive record view keys.
*
* For record inputs, the method computes `record_view_key = (nonce * view_key).to_x_coordinate()`
* for each record, then uses it with the supplied `gammas` to compute commitment, serial number,
* tag, and InputID.
*
* @param {string} program_id The id of the program.
* @param {string} function_name The function name.
* @param {string[]} inputs The inputs to the function.
* @param {string[]} input_types The input types of the function.
* @param {Signature} signature The externally-computed signature.
* @param {Field} tvk The transition view key.
* @param {Address} signer The signer address.
* @param {Field} sk_tag The tag secret key.
* @param {ViewKey} view_key The view key of the signer.
* @param {Group[] | undefined} gammas An array of gammas (required when there are record inputs).
*/
static fromExternallySignedDataWithViewKey(program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, signature: Signature, tvk: Field, signer: Address, sk_tag: Field, view_key: ViewKey, gammas?: Array<any> | null): ExecutionRequest;
/**
* Builds a request from externally-signed data with pre-computed input IDs.
*
* Each element of `input_ids` is either:
* - A `Field` for constant, public, or private inputs (the input hash).
* - A JS Array `[Field, Group, Field, Field, Field]` for record inputs
* (commitment, gamma, record_view_key, serial_number, tag).
*
* The `input_types` array is used to determine the InputID variant for scalar fields.
*
* @param {string} program_id The id of the program.
* @param {string} function_name The function name.
* @param {string[]} inputs The inputs to the function.
* @param {string[]} input_types The input types of the function.
* @param {Signature} signature The externally-computed signature.
* @param {Field} tvk The transition view key.
* @param {Address} signer The signer address.
* @param {Field} sk_tag The tag secret key.
* @param {(Field | [Field, Group, Field, Field, Field])[]} input_ids Pre-computed input IDs.
*/
static fromExternallySignedDataWithInputIds(program_id: string, function_name: string, inputs: Array<any>, input_types: Array<any>, signature: Signature, tvk: Field, signer: Address, sk_tag: Field, input_ids: Array<any>): ExecutionRequest;
/**
* 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 {Field | undefined} program_checksum The checksum of the program. This is undefined if the call is not dynamic.
* @param {boolean} is_root Flag to indicate if this is the top level function in the call graph.
* @param {boolean} is_dynamic Flag to indicate if this is a dynamic call.
*/
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, is_dynamic: 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[]} input_types The input types within the request.
* @param {boolean} is_root Flag to indicate whether this request is the first function in the call graph.
* @param {Field | undefined} program_checksum The checksum of the program. This is undefined if the call is not dynamic.
*/
verify(input_types: Array<any>, is_root: boolean, program_checksum?: Field | null): boolean;
/**
* Returns the input IDs for the transition.
*
* Each element is either a WASM `Field` (for constant/public/private/external_record inputs)
* or a JS Array `[Field, Group, Field, Field, Field]` (for record inputs: commitment, gamma,
* record_view_key, serial_number, tag).
*/
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;
/**
* Cast the field element to an Address (strict, via Group x-coordinate recovery).
* Returns an error if the field is not a valid x-coordinate on the curve.
*/
toAddress(): Address;
/**
* Get the left endian boolean array representation of the field element.
*/
toBitsLe(): Array<any>;
/**
* Cast the field element to a Boolean (strict).
* Returns an error if the field is not zero or one.
*/
toBoolean(): Boolean;
/**
* 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;
/**
* Cast the field to an I8 with lossy truncation.
*/
toI8Lossy(): I8;
/**
* Cast the field to a U8 with lossy truncation.
*/
toU8Lossy(): U8;
/**
* Reconstruct a field element from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): Field;
/**
* Cast the field to an I16 with lossy truncation.
*/
toI16Lossy(): I16;
/**
* Cast the field to an I32 with lossy truncation.
*/
toI32Lossy(): I32;
/**
* Cast the field to an I64 with lossy truncation.
*/
toI64Lossy(): I64;
/**
* Create a plaintext from the field element.
*/
toPlaintext(): Plaintext;
/**
* Cast the field to a U16 with lossy truncation.
*/
toU16Lossy(): U16;
/**
* Cast the field to a U32 with lossy truncation.
*/
toU32Lossy(): U32;
/**
* Cast the field to a U64 with lossy truncation.
*/
toU64Lossy(): U64;
/**
* Create a field element from a Uint8Array of left endian bytes.
*/
static fromBytesLe(bytes: Uint8Array): Field;
/**
* Cast the field to an I128 with lossy truncation.
*/
toI128Lossy(): I128;
/**
* Cast the field to a U128 with lossy truncation.
*/
toU128Lossy(): U128;
/**
* Cast the field element to a Group element with lossy conversion.
*
* Uses the snarkVM cast_lossy path: tries x-coordinate recovery first,
* falls back to the generator for field == 1, and applies Elligator-2
* otherwise. This conversion never fails.
*/
toGroupLossy(): Group;
/**
* Cast the field element to a Scalar with lossy truncation.
*/
toScalarLossy(): Scalar;
/**
* Cast the field element to an Address with lossy conversion (via Group, Elligator-2 fallback).
*/
toAddressLossy(): Address;
/**
* Cast the field element to a Boolean with lossy truncation (extracts least-significant bit).
*/
toBooleanLossy(): Boolean;
/**
* 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;
/**
* Cast the field element to a Group element (strict).
*
* Attempts to recover the group element from the field as an x-coordinate.
* Returns an error if the field is not a valid x-coordinate on the curve.
*/
toGroup(): Group;
/**
* 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;
/**
* Get a string representation of a graph key
*
* @returns {string} String representation of a graph key
*/
toString(): string;
/**
* 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;
/**
* Generate the group element from the x coordinate of the group.
*/
static fromField(field: Field): Group;
/**
* Cast the group element to an Address (lossless — Address wraps Group).
*/
toAddress(): Address;
/**
* 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;
/**
* Cast the group to an I8 with lossy truncation.
*/
toI8Lossy(): I8;
/**
* Cast the group to a U8 with lossy truncation.
*/
toU8Lossy(): U8;
/**
* Reconstruct a group element from a boolean array representation.
*/
static fromBitsLe(bits: Array<any>): Group;
/**
* Cast the group to an I16 with lossy truncation.
*/
toI16Lossy(): I16;
/**
* Cast the group to an I32 with lossy truncation.
*/
toI32Lossy(): I32;
/**
* Cast the group to an I64 with lossy truncation.
*/
toI64Lossy(): I64;
/**
* Create a plaintext element from a group element.
*/
toPlaintext(): Plaintext;
/**
* Cast the group to a U16 with lossy truncation.
*/
toU16Lossy(): U16;
/**
* Cast the group to a U32 with lossy truncation.
*/
toU32Lossy(): U32;
/**
* Cast the group to a U64 with lossy truncation.
*/
toU64Lossy(): U64;
/**
* Create a group element from a Uint8Array of left endian bytes.
*/
static fromBytesLe(bytes: Uint8Array): Group;
/**
* Cast the group to an I128 with lossy truncation.
*/
toI128Lossy(): I128;
/**
* Cast the group to a U128 with lossy truncation.
*/
toU128Lossy(): U128;
/**
* Multiply a group element by a scalar element.
*/
scalarMultiply(scalar: Scalar): Group;
/**
* Cast the group element to a Scalar with lossy truncation (via x-coordinate).
*/
toScalarLossy(): Scalar;
/**
* Get the x-coordinate of the group element.
*/
toXCoordinate(): Field;
/**
* Cast the group element to a Boolean with lossy truncation (LSB of x-coordinate).
*/
toBooleanLossy(): Boolean;
/**
* Generate the group element from a string representation of the x coordinate of the group.
*/
static fromFieldString(field: string): Group;
/**
* 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;
/**
* Cast the group element to a Field (returns x-coordinate).
* This is an alias for `toXCoordinate()`.
*/
toField(): Field;
/**
* 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.
*/
st