/**
 * SNARK Utilities
 *
 * Provides utilities for working with SNARKs (Succinct Non-interactive ARguments of Knowledge):
 * - Trusted setup management
 * - Proof serialization/deserialization
 * - Key management (proving and verification keys)
 *
 * This module is designed to work with snarkjs/circom-compatible systems.
 * For production use, integrate with actual SNARK libraries.
 *
 * @packageDocumentation
 */
import { VorionError } from '../../common/errors.js';
import { type ZKProof, type SerializedZKProof, type ProvingKey, type VerificationKey, type TrustedSetupParams } from './types.js';
/**
 * SNARK-related errors
 */
export declare class SNARKError extends VorionError {
    code: string;
    statusCode: number;
    constructor(message: string, details?: Record<string, unknown>);
}
/**
 * Proof Serialization Service
 *
 * Handles conversion between binary proof format and serialized format
 * for storage and transmission.
 *
 * @example
 * ```typescript
 * const serializer = new ProofSerializer();
 *
 * // Serialize for storage
 * const serialized = serializer.serialize(proof);
 *
 * // Deserialize
 * const proof = serializer.deserialize(serialized);
 * ```
 */
export declare class ProofSerializer {
    /**
     * Serialize a ZK proof for storage/transmission
     */
    serialize(proof: ZKProof): SerializedZKProof;
    /**
     * Deserialize a ZK proof from storage/transmission format
     */
    deserialize(serialized: SerializedZKProof): ZKProof;
    /**
     * Serialize proof to compact binary format
     */
    serializeBinary(proof: ZKProof): Uint8Array;
    /**
     * Deserialize proof from compact binary format
     */
    deserializeBinary(data: Uint8Array): ZKProof;
    /**
     * Calculate proof hash for integrity verification
     */
    calculateProofHash(proof: ZKProof): Promise<string>;
    /**
     * Verify proof integrity using hash
     */
    verifyProofIntegrity(proof: ZKProof, expectedHash: string): Promise<boolean>;
    private uint8ArrayToBase64;
    private base64ToUint8Array;
}
/**
 * Key Management Service
 *
 * Manages proving and verification keys for ZK circuits.
 *
 * Key Types:
 * - Proving Key (pk): Used to generate proofs, can be large (MBs)
 * - Verification Key (vk): Used to verify proofs, typically small (KBs)
 *
 * @example
 * ```typescript
 * const keyManager = new KeyManager();
 *
 * // Store keys
 * await keyManager.storeProvingKey(circuitId, keyData);
 * await keyManager.storeVerificationKey(circuitId, keyData);
 *
 * // Retrieve keys
 * const pk = await keyManager.getProvingKey(circuitId);
 * const vk = await keyManager.getVerificationKey(circuitId);
 * ```
 */
export declare class KeyManager {
    private provingKeys;
    private verificationKeys;
    constructor();
    /**
     * Store a proving key
     */
    storeProvingKey(circuitId: string, keyData: Uint8Array, version?: string): Promise<ProvingKey>;
    /**
     * Store a verification key
     */
    storeVerificationKey(circuitId: string, keyData: Uint8Array, version?: string): Promise<VerificationKey>;
    /**
     * Get a proving key by circuit ID
     */
    getProvingKey(circuitId: string): ProvingKey | undefined;
    /**
     * Get a verification key by circuit ID
     */
    getVerificationKey(circuitId: string): VerificationKey | undefined;
    /**
     * Verify key integrity
     */
    verifyKeyIntegrity(key: ProvingKey | VerificationKey): Promise<boolean>;
    /**
     * Export keys for backup
     */
    exportKeys(): {
        provingKeys: ProvingKey[];
        verificationKeys: VerificationKey[];
    };
    /**
     * Import keys from backup
     */
    importKeys(data: {
        provingKeys: Array<Omit<ProvingKey, 'keyData'> & {
            keyData: string;
        }>;
        verificationKeys: Array<Omit<VerificationKey, 'keyData'> & {
            keyData: string;
        }>;
    }): Promise<void>;
    /**
     * Delete keys for a circuit
     */
    deleteKeys(circuitId: string): void;
    /**
     * List all circuit IDs with stored keys
     */
    listCircuits(): string[];
    private generateKeyId;
    private computeKeyHash;
    private base64ToUint8Array;
}
/**
 * Trusted Setup Manager
 *
 * Manages the trusted setup ceremony for SNARK circuits.
 *
 * The trusted setup is a critical security component that generates the
 * proving and verification keys. The "toxic waste" from the ceremony
 * must be destroyed to ensure system security.
 *
 * Phases:
 * 1. Contribution: Multiple parties contribute randomness
 * 2. Verification: Verify all contributions are valid
 * 3. Complete: Finalize keys and destroy toxic waste
 *
 * For production, consider using:
 * - Powers of Tau ceremony for universal setup
 * - Multi-party computation (MPC) for circuit-specific setup
 *
 * @example
 * ```typescript
 * const setup = new TrustedSetupManager();
 *
 * // Initialize ceremony
 * const params = await setup.initializeCeremony('age_verification', 10);
 *
 * // Contribute randomness
 * await setup.contribute(params.circuitId, contribution);
 *
 * // Finalize
 * const { provingKey, verificationKey } = await setup.finalize(params.circuitId);
 * ```
 */
export declare class TrustedSetupManager {
    private ceremonies;
    constructor();
    /**
     * Initialize a new trusted setup ceremony
     */
    initializeCeremony(circuitId: string, participantsRequired: number, deadline?: Date): Promise<TrustedSetupParams>;
    /**
     * Add a contribution to the ceremony
     *
     * In production, this would involve:
     * 1. Downloading current Powers of Tau
     * 2. Adding local randomness
     * 3. Computing new parameters
     * 4. Providing proof of contribution
     */
    contribute(circuitId: string, contributorId: string, contribution: Uint8Array): Promise<ContributionReceipt>;
    /**
     * Verify all contributions
     */
    verifyContributions(circuitId: string): Promise<boolean>;
    /**
     * Finalize the ceremony and generate keys
     */
    finalize(circuitId: string): Promise<{
        provingKey: Uint8Array;
        verificationKey: Uint8Array;
    }>;
    /**
     * Get ceremony status
     */
    getCeremonyStatus(circuitId: string): TrustedSetupParams | undefined;
    /**
     * Get contribution history
     */
    getContributions(circuitId: string): ContributionRecord[];
    private hashContribution;
    private generateSimulatedKey;
}
/**
 * Contribution record
 */
interface ContributionRecord {
    contributorId: string;
    hash: string;
    timestamp: Date;
}
/**
 * Contribution receipt
 */
export interface ContributionReceipt {
    circuitId: string;
    contributorId: string;
    contributionIndex: number;
    contributionHash: string;
    timestamp: Date;
}
/**
 * SNARK Integration Helpers
 *
 * Utility functions for integrating with snarkjs/circom in production.
 *
 * Usage with snarkjs:
 * ```typescript
 * import * as snarkjs from 'snarkjs';
 *
 * // Generate proof
 * const { proof, publicSignals } = await snarkjs.groth16.fullProve(
 *   witness,
 *   'circuit.wasm',
 *   'circuit_final.zkey'
 * );
 *
 * // Verify proof
 * const valid = await snarkjs.groth16.verify(
 *   verificationKey,
 *   publicSignals,
 *   proof
 * );
 * ```
 */
export declare class SNARKIntegration {
    /**
     * Convert snarkjs proof format to ZKProof
     *
     * snarkjs Groth16 proof format:
     * {
     *   pi_a: [string, string, string],
     *   pi_b: [[string, string], [string, string], [string, string]],
     *   pi_c: [string, string, string],
     *   protocol: 'groth16'
     * }
     */
    static fromSnarkJS(snarkProof: SnarkJSProof, publicSignals: string[], circuit: string): ZKProof;
    /**
     * Convert ZKProof to snarkjs format
     */
    static toSnarkJS(proof: ZKProof): {
        proof: SnarkJSProof;
        publicSignals: string[];
    };
    /**
     * Load circuit WASM from file/buffer
     *
     * In production, use:
     * ```typescript
     * const wasmBuffer = await fs.readFile('circuit.wasm');
     * ```
     */
    static loadCircuitWasm(path: string): Promise<Uint8Array>;
    /**
     * Load zkey (proving key) from file/buffer
     */
    static loadZkey(path: string): Promise<Uint8Array>;
    /**
     * Export verification key for on-chain verification
     *
     * Exports verification key in format suitable for Solidity verifier contracts.
     */
    static exportVerificationKeyForSolidity(vk: VerificationKey): string;
}
/**
 * snarkjs proof format
 */
interface SnarkJSProof {
    pi_a: [string, string, string];
    pi_b: [[string, string], [string, string], [string, string]];
    pi_c: [string, string, string];
    protocol: string;
    curve?: string;
}
/**
 * Create a proof serializer
 */
export declare function createProofSerializer(): ProofSerializer;
/**
 * Create a key manager
 */
export declare function createKeyManager(): KeyManager;
/**
 * Create a trusted setup manager
 */
export declare function createTrustedSetupManager(): TrustedSetupManager;
export {};
//# sourceMappingURL=snark-utils.d.ts.map