import { PublicKey, Signer, Transaction, Connection } from '@solana/web3.js';
export { Connection, PublicKey, clusterApiUrl } from '@solana/web3.js';

interface MPCSigner {
    publicKey: PublicKey;
    sign(data: Uint8Array): Promise<Uint8Array>;
}

declare class MPCKeypair implements Signer {
    publicKey: PublicKey;
    secretKey: Uint8Array;
    private mpcSigner;
    constructor(mpcSigner: MPCSigner);
    sign(message: Uint8Array): Promise<Uint8Array>;
    signTransaction(tx: Transaction): Promise<Transaction>;
    signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
}

/**
 * Initialize the WASM module and create an MPC signer
 * @returns Promise resolving to an MPCSigner instance
 */
declare function createMPCSigner(): Promise<MPCSigner>;
/**
 * Create an MPC signer from existing secret key bytes
 * @param secretKeyBytes The secret key bytes
 * @returns Promise resolving to an MPCSigner instance
 */
declare function createMPCSignerFromSecretKey(secretKeyBytes: Uint8Array): Promise<MPCSigner>;

/**
 * Create a Solana transfer transaction
 * @param connection The Solana connection
 * @param from The sender's public key
 * @param to The recipient's public key
 * @param lamports The amount to transfer in lamports
 * @returns Promise resolving to a Transaction
 */
declare function createTransferTx(connection: Connection, from: PublicKey, to: PublicKey, lamports: number): Promise<Transaction>;

/**
 * Network configuration for Solana TSS operations
 */
type SolanaNetwork = 'mainnet-beta' | 'devnet' | 'testnet';
/**
 * TSS Keypair structure
 */
interface TSSKeypair {
    publicKey: PublicKey;
    secretKey: Uint8Array;
}
/**
 * Partial signature for TSS aggregation
 */
interface PartialSignature {
    signer: PublicKey;
    signature: Uint8Array;
    nonce: Uint8Array;
}
/**
 * TSS wallet aggregate data
 */
interface AggregateWallet {
    aggregatedPublicKey: PublicKey;
    participantKeys: PublicKey[];
    threshold: number;
}
/**
 * Step 1 data for aggregate signing
 */
interface AggSignStepOneData {
    secretNonce: Uint8Array;
    publicNonce: Uint8Array;
    participantKey: PublicKey;
}
/**
 * Step 2 data for aggregate signing
 */
interface AggSignStepTwoData {
    partialSignature: Uint8Array;
    publicNonce: Uint8Array;
    participantKey: PublicKey;
}
/**
 * Transaction details for TSS signing
 */
interface TSSTransactionDetails {
    amount: number;
    to: PublicKey;
    from: PublicKey;
    network: SolanaNetwork;
    memo?: string;
    recentBlockhash: string;
}
/**
 * Complete TSS signature ready for broadcast
 */
interface CompleteSignature {
    signature: Uint8Array;
    publicKey: PublicKey;
    transaction: Uint8Array;
}

/**
 * TSS Wallet implementation supporting all solana-tss functions
 */
declare class TSSWallet {
    private connection;
    private network;
    constructor(network?: SolanaNetwork);
    /**
     * Generate a new TSS keypair
     * Equivalent to: solana-tss generate
     */
    generateKeypair(): Promise<TSSKeypair>;
    /**
     * Check the balance of an address
     * Equivalent to: solana-tss balance <address>
     */
    getBalance(publicKey: PublicKey): Promise<number>;
    /**
     * Request an airdrop from the faucet (devnet/testnet only)
     * Equivalent to: solana-tss airdrop <address> <amount>
     */
    requestAirdrop(publicKey: PublicKey, amount: number): Promise<string>;
    /**
     * Aggregate multiple public keys into a single multisig address
     * Equivalent to: solana-tss aggregate-keys <key1> <key2> ... <keyN>
     */
    aggregateKeys(participantKeys: PublicKey[], threshold?: number): AggregateWallet;
    /**
     * Get recent blockhash for transaction signing
     * Equivalent to: solana-tss recent-block-hash
     */
    getRecentBlockhash(): Promise<string>;
    /**
     * Switch to a different Solana network
     */
    switchNetwork(network: SolanaNetwork): void;
    /**
     * Get current network
     */
    getCurrentNetwork(): SolanaNetwork;
    /**
     * Get connection instance
     */
    getConnection(): Connection;
    /**
     * Private helper to combine public keys (simplified implementation)
     * In production, this would use proper TSS key aggregation schemes
     */
    private combinePublicKeys;
    /**
     * Validate a public key string
     */
    static validatePublicKey(keyString: string): PublicKey;
    /**
     * Format balance for display
     */
    static formatBalance(lamports: number): string;
}

/**
 * TSS Signing implementation for multi-party signature aggregation
 */
declare class TSSSigningService {
    private connection;
    constructor(connection: Connection);
    /**
     * Send a transaction using a single private key (non-TSS)
     * Equivalent to: solana-tss send-single
     */
    sendSingle(fromSecretKey: Uint8Array, to: PublicKey, amount: number, memo?: string): Promise<string>;
    /**
     * Step 1 of aggregate signing: Generate nonce and commitment
     * Equivalent to: solana-tss agg-send-step-one
     */
    aggregateSignStepOne(participantSecretKey: Uint8Array, transactionDetails: TSSTransactionDetails): Promise<AggSignStepOneData>;
    /**
     * Step 2 of aggregate signing: Create partial signature
     * Equivalent to: solana-tss agg-send-step-two
     */
    aggregateSignStepTwo(stepOneData: AggSignStepOneData, participantSecretKey: Uint8Array, transactionDetails: TSSTransactionDetails, allPublicNonces: Uint8Array[]): Promise<AggSignStepTwoData>;
    /**
     * Aggregate all partial signatures and broadcast transaction
     * Equivalent to: solana-tss aggregate-signatures-and-broadcast
     */
    aggregateSignaturesAndBroadcast(partialSignatures: AggSignStepTwoData[], transactionDetails: TSSTransactionDetails, aggregateWallet: AggregateWallet): Promise<string>;
    /**
     * Create a transaction from transaction details
     */
    private createTransactionFromDetails;
    /**
     * Derive public key from secret key
     */
    private derivePublicKey;
    /**
     * Aggregate nonces for TSS signing
     */
    private aggregateNonces;
    /**
     * Create a partial signature for TSS
     */
    private createPartialSignature;
    /**
     * Aggregate partial signatures into a complete signature
     */
    private aggregatePartialSignatures;
    /**
     * Verify a partial signature
     */
    verifyPartialSignature(signature: PartialSignature, message: Uint8Array): boolean;
}

/**
 * CLI interface matching the original solana-tss functionality
 */
declare class TSSCli {
    private wallet;
    private signingService;
    constructor(network?: SolanaNetwork);
    /**
     * Generate a pair of keys
     * solana-tss generate
     */
    generate(): Promise<{
        publicKey: string;
        secretKey: string;
    }>;
    /**
     * Check the balance of an address
     * solana-tss balance <address>
     */
    balance(address: string): Promise<number>;
    /**
     * Request an airdrop from a faucet
     * solana-tss airdrop <address> <amount>
     */
    airdrop(address: string, amount: number): Promise<string>;
    /**
     * Send a transaction using a single private key
     * solana-tss send-single <from_secret> <to> <amount> [memo]
     */
    sendSingle(fromSecretHex: string, to: string, amount: number, memo?: string): Promise<string>;
    /**
     * Aggregate a list of addresses into a single address
     * solana-tss aggregate-keys <key1> <key2> ... <keyN>
     */
    aggregateKeys(keyStrings: string[], threshold?: number): {
        aggregatedPublicKey: string;
        participantKeys: string[];
        threshold: number;
    };
    /**
     * Start aggregate signing
     * solana-tss agg-send-step-one <participant_secret> <to> <amount> <network> [memo] [recent_block_hash]
     */
    aggregateSignStepOne(participantSecretHex: string, to: string, amount: number, memo?: string, recentBlockhash?: string): Promise<{
        secretNonce: string;
        publicNonce: string;
        participantKey: string;
    }>;
    /**
     * Print the hash of a recent block
     * solana-tss recent-block-hash
     */
    recentBlockHash(): Promise<string>;
    /**
     * Step 2 of aggregate signing
     * solana-tss agg-send-step-two <step_one_data> <participant_secret> <to> <amount> <network> <all_public_nonces> [memo] [recent_block_hash]
     */
    aggregateSignStepTwo(stepOneDataJson: string, participantSecretHex: string, to: string, amount: number, allPublicNoncesHex: string[], memo?: string, recentBlockhash?: string): Promise<{
        partialSignature: string;
        publicNonce: string;
        participantKey: string;
    }>;
    /**
     * Aggregate all the partial signatures together and send transaction
     * solana-tss aggregate-signatures-and-broadcast <partial_signatures> <transaction_details> <aggregate_wallet>
     */
    aggregateSignaturesAndBroadcast(partialSignaturesJson: string, transactionDetailsJson: string, aggregateWalletJson: string): Promise<string>;
    /**
     * Switch to a different network
     */
    switchNetwork(network: SolanaNetwork): void;
    /**
     * Get current network
     */
    getCurrentNetwork(): SolanaNetwork;
    /**
     * Format balance for display
     */
    static formatBalance(balance: number): string;
    /**
     * Helper to print help information
     */
    static printHelp(): string;
}

export { type AggSignStepOneData, type AggSignStepTwoData, type AggregateWallet, type CompleteSignature, MPCKeypair, type MPCSigner, type PartialSignature, type SolanaNetwork, TSSCli, type TSSKeypair, TSSSigningService, type TSSTransactionDetails, TSSWallet, createMPCSigner, createMPCSignerFromSecretKey, createTransferTx };
