import { PublicKey } from "@solana/web3.js"; /** * Keypair for UTXO ownership. * Public key is derived via Poseidon: pubkey = Poseidon(privateKey) */ export type Keypair = { privateKey: bigint; publicKey: bigint; }; /** * UTXO structure matching the circuit's UTXOCommitment template. * commitment = Poseidon(amount, pubkey, blinding, mintAddress) */ export type UTXO = { /** Amount in lamports/token units */ amount: bigint; /** Owner's public key (derived from private key via Poseidon) */ pubkey: bigint; /** Random blinding factor for commitment privacy */ blinding: bigint; /** Token mint address as field element */ mintAddress: bigint; }; /** * Serialized UTXO with precomputed commitment and optional ownership data. */ export type SerializedUTXO = UTXO & { /** 32-byte commitment: Poseidon(amount, pubkey, blinding, mintAddress) */ commitment: Uint8Array; /** Private key for spending (only present for owned UTXOs) */ privateKey?: bigint; /** Leaf index in the Merkle tree (set after insertion) */ pathIndex?: number; }; /** * Input UTXO with Merkle proof data for spending. */ export type InputUTXO = SerializedUTXO & { /** Leaf index in the Merkle tree */ pathIndex: number; /** Merkle path elements (sibling hashes from leaf to root) */ pathElements: Uint8Array[]; /** Private key for nullifier derivation */ privateKey: bigint; }; /** * Generate a random keypair. * Private key is a random 32-byte scalar. * Public key is derived via Poseidon: pubkey = Poseidon(privateKey) */ export declare function generateKeypair(): Keypair; /** * Derive public key from private key. * Matches circuit's Keypair template: publicKey = Poseidon(privateKey) */ export declare function derivePublicKey(privateKey: bigint): bigint; /** * Create keypair from a known private key. */ export declare function keypairFromPrivateKey(privateKey: bigint): Keypair; /** * Compute UTXO commitment. * Matches circuit's UTXOCommitment template: * commitment = Poseidon(amount, pubkey, blinding, mintAddress) */ export declare function commitUTXO(utxo: UTXO): Uint8Array; /** * Create a random UTXO with the given parameters. */ export declare function createUTXO(params: { amount: bigint; pubkey: bigint; mintAddress: PublicKey; }): SerializedUTXO; /** * Create a UTXO with a specified private key (for owned UTXOs). */ export declare function createOwnedUTXO(params: { amount: bigint; privateKey: bigint; mintAddress: PublicKey; }): SerializedUTXO; /** * Create a zero UTXO (for deposits where no input exists). * Zero UTXOs have amount=0 and are used as placeholders in 2-in-2-out transactions. */ export declare function createZeroUTXO(pubkey: bigint, mintAddress: PublicKey): SerializedUTXO; /** * Create a zero UTXO with private key (for owned zero UTXOs). */ export declare function createOwnedZeroUTXO(privateKey: bigint, mintAddress: PublicKey): SerializedUTXO;