import { Address } from './encoding/address.js'; import * as encoding from './encoding/encoding.js'; import { NamedMapSchema } from './encoding/schema/index.js'; import { MultisigMetadata } from './multisig.js'; import { EncodedMultisig, EncodedPQSig } from './types/transactions/encoded.js'; import type { DelegatedLsigSigner, ProgramDataSigner } from './signer.js'; /** sanityCheckProgram performs heuristic program validation: * check if passed in bytes are Algorand address or is B64 encoded, rather than Teal bytes * * @param program - Program bytes to check */ export declare function sanityCheckProgram(program: Uint8Array): void; /** * The domain-separation prefix prepended to a program before it is hashed into * an escrow address, or signed for delegation by a single ed25519 account. */ export declare const PROGRAM_TAG: Uint8Array; /** * The domain-separation prefix prepended to a post-quantum delegating account's * address and a program before the program is signed for delegation. */ export declare const PQ_PROGRAM_TAG: Uint8Array; /** * The domain-separation prefix prepended to a delegating multisig account's * address and a program before the program is signed for delegation. */ export declare const MSIG_PROGRAM_TAG: Uint8Array; /** LogicSig implementation LogicSig cannot sign transactions in all cases. Instead, use LogicSigAccount as a safe, general purpose signing mechanism. Since LogicSig does not track the provided signature's public key, LogicSig cannot sign transactions when delegated to a non-multisig account _and_ the sender is not the delegating account. */ export declare class LogicSig implements encoding.Encodable { static readonly encodingSchema: NamedMapSchema; logic: Uint8Array; args: Uint8Array[]; sig?: Uint8Array; msig?: EncodedMultisig; lmsig?: EncodedMultisig; /** * The post-quantum delegation signature, if the delegating account is a * post-quantum account. At most one of `sig`, `msig`, `lmsig` and `pqsig` may * be set. */ pqsig?: EncodedPQSig; constructor(program: Uint8Array, programArgs?: Array | null); getEncodingSchema(): encoding.Schema; toEncodingData(): Map; static fromEncodingData(data: unknown): LogicSig; /** * @deprecated This function does not perform full verification and should not be fully trusted on its own. * For example, it does not evaluate programs and does not have the ability to validate PQ signatures. * * Performs signature verification * @param publicKey - Verification key (derived from sender address or escrow address) */ verify(publicKey: Uint8Array): boolean; /** * Compute hash of the logic sig program (that is the same as escrow account address) as string address * @returns String representation of the address */ address(): Address; /** * @deprecated Use `signWithSigner` instead * * Creates signature (if no msig provided) or multi signature otherwise * @param secretKey - Secret key to sign with * @param msig - Multisig account as \{version, threshold, addrs\} */ sign(secretKey: Uint8Array, msig?: MultisigMetadata): void; /** * Signs this LogicSig for delegation using the given signer. * * @remarks * Re-signing an already-signed LogicSig is allowed, and replaces the previous * delegation signature. At most one of `sig`, `msig`, `lmsig` and `pqsig` may * be set, so any signature left over from an earlier call is cleared. * * @param signer - The signer to delegate to * @param msig - Optional multisig account the signer is a subsigner of * @returns The address the signer signed as. When `msig` is omitted this is * the delegating account. When `msig` is given it is the individual * subsigner, not the multisig, so the delegating account is * `multisigAddress(msig)`. Either way it is an authorizing address, which * is not necessarily the address a signer sends transactions from. * @throws If the signer returns a signature of the wrong kind for the * requested delegation, or an `lmsig` whose version, threshold or public * keys do not match `msig` */ signWithSigner(signer: DelegatedLsigSigner, msig?: MultisigMetadata): Promise
; /** * Removes every delegation signature from this LogicSig, so that exactly one * of them can be set afterwards. */ private clearSignatures; /** * @deprecated Use `appendToMultisigWithSigner` instead * * Appends a signature to multi signature * @param secretKey - Secret key to sign with */ appendToMultisig(secretKey: Uint8Array): void; /** * Appends an additional subsignature to this LogicSig's existing multisig * delegation. * * @remarks * The multisig preimage is taken from the `lmsig` already on this LogicSig, * so {@link signWithSigner} must have been called with an `msig` argument * first. The signer must hold a key belonging to that multisig. * * A signature already collected from another member is never silently * replaced: if the signer returns a different signature for a subsig that is * already filled in, this throws instead. * * @param signer - The signer to append a subsignature from * @throws If there is no multisig on this LogicSig, if the signer returns no * signature, a signature for a key outside the multisig, or one that * conflicts with a signature already collected */ appendToMultisigWithSigner(signer: DelegatedLsigSigner): Promise; /** * @deprecated Use `signWithSigner` followed by `.sig` instead */ signProgram(secretKey: Uint8Array): Uint8Array; /** * @deprecated Use `signWithSigner` followed by `.sig` instead */ signProgramMultisig(secretKey: Uint8Array, msig: EncodedMultisig): Uint8Array; /** * @deprecated Use `signWithSigner` followed by `.sig` instead */ singleSignMultisig(secretKey: Uint8Array, msig: EncodedMultisig): [sig: Uint8Array, index: number]; toByte(): Uint8Array; static fromByte(encoded: ArrayLike): LogicSig; /** * Signs arbitrary data for use with the `ed25519verify` opcode from within * this LogicSig's program. * * @remarks * This does not modify the LogicSig or delegate it; the LogicSig is only used * for the address that domain-separates the signature. The program is * responsible for verifying the returned signature against the signer's * public key. * * @param signer - The signer to sign the data with * @param data - The data to sign * @returns A promise which resolves to the raw signature over the data */ signDataWithSigner(signer: ProgramDataSigner, data: Uint8Array): Promise; } /** * Represents an account that can sign with a LogicSig program. */ export declare class LogicSigAccount implements encoding.Encodable { static readonly encodingSchema: NamedMapSchema; lsig: LogicSig; sigkey?: Uint8Array; /** * Create a new LogicSigAccount. By default this will create an escrow * LogicSig account. Call `sign` or `signMultisig` on the newly created * LogicSigAccount to make it a delegated account. * * @param program - The compiled TEAL program which contains the logic for * this LogicSig. * @param args - An optional array of arguments for the program. */ constructor(program: Uint8Array, args?: Array | null); getEncodingSchema(): encoding.Schema; toEncodingData(): Map; static fromEncodingData(data: unknown): LogicSigAccount; /** * Encode this object into msgpack. */ toByte(): Uint8Array; /** * Decode a msgpack object into a LogicSigAccount. * @param encoded - The encoded LogicSigAccount. */ static fromByte(encoded: ArrayLike): LogicSigAccount; /** * Check if this LogicSigAccount has been delegated to another account with a * signature. * * Note this function only checks for the presence of a delegation signature. * To verify the delegation signature, use `verify`. */ isDelegated(): boolean; /** * @deprecated This function does not perform full verification and should not be fully trusted on its own. * For example, it does not evaluate programs and does not have the ability to validate PQ signatures. * * Verifies this LogicSig's program and signatures. * @returns true if and only if the LogicSig program and signatures are valid. */ verify(): boolean; /** * Get the address of this LogicSigAccount. * * If the LogicSig is delegated to another account, this will return the * address of that account. * * If the LogicSig is not delegated to another account, this will return an * escrow address that is the hash of the LogicSig's program code. */ address(): Address; /** * @deprecated Use `signMultisigWithSigner` instead * * Turns this LogicSigAccount into a delegated LogicSig. This type of LogicSig * has the authority to sign transactions on behalf of another account, called * the delegating account. Use this function if the delegating account is a * multisig account. * * @param msig - The multisig delegating account * @param secretKey - The secret key of one of the members of the delegating * multisig account. Use `appendToMultisig` to add additional signatures * from other members. */ signMultisig(msig: MultisigMetadata, secretKey: Uint8Array): void; /** * Turns this LogicSigAccount into a delegated LogicSig, signed by one member * of a delegating multisig account. * * @remarks * This produces a LogicSig with a single subsignature filled in. Unless the * multisig's threshold is 1, call {@link LogicSigAccount.appendToMultisigWithSigner} * with the remaining members' signers before the LogicSig can authorize * transactions. * * If the delegating account is not a multisig, use * {@link LogicSigAccount.signWithSigner} instead. * * @param msig - The multisig delegating to this LogicSig * @param signer - The signer of one member of `msig` */ signMultisigWithSigner(msig: MultisigMetadata, signer: DelegatedLsigSigner): Promise; /** * @deprecated Use appendToMultisigWithSigner * * Adds an additional signature from a member of the delegating multisig * account. * * @param secretKey - The secret key of one of the members of the delegating * multisig account. */ appendToMultisig(secretKey: Uint8Array): void; /** * Adds an additional signature from a member of the delegating multisig * account. * * @remarks * {@link LogicSigAccount.signMultisigWithSigner} must have been called first * to establish the multisig this signature belongs to. * * @param signer - The signer of another member of the delegating multisig account */ appendToMultisigWithSigner(signer: DelegatedLsigSigner): Promise; /** * @deprecated Use `signWithSigner` instead * * Turns this LogicSigAccount into a delegated LogicSig. This type of LogicSig * has the authority to sign transactions on behalf of another account, called * the delegating account. If the delegating account is a multisig account, * use `signMultisig` instead. * * @param secretKey - The secret key of the delegating account. */ sign(secretKey: Uint8Array): void; /** * Turns this LogicSigAccount into a delegated LogicSig, signed by the given * signer. This type of LogicSig has the authority to sign transactions on * behalf of another account, called the delegating account. * * @remarks * If the delegating account is a multisig account, use * {@link LogicSigAccount.signMultisigWithSigner} instead. * * The delegating account is taken to be the address the signer reports having * signed as, not any sending address the signer advertises: for a rekeyed * account the latter is the address it sends transactions from, which is not * the account authorizing this delegation. * * @param signer - The signer of the delegating account. */ signWithSigner(signer: DelegatedLsigSigner): Promise; } /** * logicSigFromByte accepts encoded logic sig bytes and attempts to call logicsig.fromByte on it, * returning the result */ export declare function logicSigFromByte(encoded: Uint8Array): LogicSig; /** * The domain-separation prefix prepended, along with the program's address, to * data signed for verification by the `ed25519verify` opcode. */ export declare const SIGN_PROGRAM_DATA_PREFIX: Uint8Array; /** * tealSign creates a signature compatible with ed25519verify opcode from program hash * @param sk - Uint8Array with secret key * @param data - Uint8Array with data to sign * @param programHash - string representation of teal program hash (= contract address for LogicSigs) */ export declare function tealSign(sk: Uint8Array, data: Uint8Array, programHash: string | Address): Uint8Array; /** * verifyTealSign verifies a signature as would the ed25519verify opcode * @param data - Uint8Array with original signed data * @param programHash - string representation of teal program hash (= contract address for LogicSigs) * @param sig - uint8array with the signature to verify (produced by tealSign/tealSignFromProgram) * @param pk - uint8array with public key to verify against */ export declare function verifyTealSign(data: Uint8Array, programHash: string | Address, sig: Uint8Array, pk: Uint8Array): boolean; /** * tealSignFromProgram creates a signature compatible with ed25519verify opcode from raw program bytes * @param sk - uint8array with secret key * @param data - Uint8Array with data to sign * @param program - Uint8Array with teal program */ export declare function tealSignFromProgram(sk: Uint8Array, data: Uint8Array, program: Uint8Array): Uint8Array;