import { VorionError } from '../../common/errors.js';
import { type ZKProof, type VerificationResult, type ZKProofPolicyCondition, ZKCircuitType } from './types.js';
import { ZKVerifierService } from './verifier.js';
import { ZKProverService } from './prover.js';
/**
 * ZKP policy integration error
 */
export declare class ZKPPolicyError extends VorionError {
    readonly circuit?: string;
    code: string;
    statusCode: number;
    constructor(message: string, circuit?: string, details?: Record<string, unknown>);
}
/**
 * Session-based proof cache
 *
 * Caches ZK proofs and verification results per session to avoid
 * repeated proof generation and verification.
 *
 * Features:
 * - Per-session isolation
 * - Automatic expiration
 * - Proof refresh tracking
 *
 * @example
 * ```typescript
 * const cache = new SessionProofCacheManager();
 *
 * // Store proof for session
 * await cache.storeProof(sessionId, proof);
 *
 * // Retrieve cached proof
 * const proof = cache.getProof(sessionId, 'age_verification');
 *
 * // Check if proof needs refresh
 * const needsRefresh = cache.needsRefresh(sessionId, 'age_verification');
 * ```
 */
export declare class SessionProofCacheManager {
    private sessions;
    private readonly defaultSessionTTL;
    private readonly refreshThreshold;
    private cleanupInterval;
    constructor(options?: {
        /** Default session TTL in milliseconds (default: 1 hour) */
        sessionTTL?: number;
        /** Refresh threshold as percentage of TTL (default: 0.2 = 20%) */
        refreshThreshold?: number;
        /** Cleanup interval in milliseconds (default: 5 minutes) */
        cleanupInterval?: number;
    });
    /**
     * Create or get a session
     */
    getOrCreateSession(sessionId: string, ttl?: number): SessionProofCacheEntry;
    /**
     * Store a proof in the session cache
     */
    storeProof(sessionId: string, proof: ZKProof): void;
    /**
     * Store a verification result in the session cache
     */
    storeVerificationResult(sessionId: string, circuit: string, result: VerificationResult): void;
    /**
     * Get a cached proof
     */
    getProof(sessionId: string, circuit: string): ZKProof | undefined;
    /**
     * Get a cached verification result
     */
    getVerificationResult(sessionId: string, circuit: string): VerificationResult | undefined;
    /**
     * Check if a proof needs refresh based on remaining TTL
     */
    needsRefresh(sessionId: string, circuit: string): boolean;
    /**
     * Check if a proof is valid (not expired)
     */
    isProofValid(sessionId: string, circuit: string): boolean;
    /**
     * Invalidate a specific proof
     */
    invalidateProof(sessionId: string, circuit: string): void;
    /**
     * Invalidate all proofs for a session
     */
    invalidateSession(sessionId: string): void;
    /**
     * Get all circuits with cached proofs for a session
     */
    getCachedCircuits(sessionId: string): string[];
    /**
     * Clean up expired sessions
     */
    private cleanup;
    /**
     * Destroy the cache manager
     */
    destroy(): void;
}
/**
 * Session cache entry
 */
interface SessionProofCacheEntry {
    sessionId: string;
    proofs: Map<string, ZKProof>;
    verificationResults: Map<string, VerificationResult>;
    createdAt: Date;
    expiresAt: Date;
    lastAccessedAt: Date;
}
/**
 * Proof refresh policy configuration
 */
export interface ProofRefreshPolicy {
    /** Circuit type this policy applies to */
    circuit: ZKCircuitType | string;
    /** Minimum validity period in milliseconds */
    minValidityPeriod: number;
    /** Whether to auto-refresh when below threshold */
    autoRefresh: boolean;
    /** Refresh callback (for auto-refresh) */
    refreshCallback?: (sessionId: string, circuit: string) => Promise<ZKProof | null>;
    /** Maximum refresh attempts */
    maxRefreshAttempts: number;
}
/**
 * Proof Refresh Manager
 *
 * Manages automatic proof refresh based on policies.
 */
export declare class ProofRefreshManager {
    private policies;
    private refreshAttempts;
    private prover;
    constructor(prover?: ZKProverService);
    /**
     * Register a refresh policy for a circuit
     */
    registerPolicy(policy: ProofRefreshPolicy): void;
    /**
     * Get policy for a circuit
     */
    getPolicy(circuit: string): ProofRefreshPolicy | undefined;
    /**
     * Check if proof needs refresh based on policy
     */
    needsRefresh(proof: ZKProof): boolean;
    /**
     * Attempt to refresh a proof
     */
    refreshProof(sessionId: string, circuit: string, currentProof?: ZKProof): Promise<ZKProof | null>;
    /**
     * Clear refresh attempts for a session
     */
    clearAttempts(sessionId: string): void;
}
/**
 * ZKP Policy Condition Evaluator
 *
 * Evaluates ZK proof conditions as part of policy evaluation.
 *
 * Integration with Vorion policy engine:
 * - Register as custom condition type
 * - Evaluate ZKP requirements
 * - Cache results in session
 *
 * @example
 * ```typescript
 * const evaluator = new ZKPPolicyConditionEvaluator();
 *
 * // Define a policy condition requiring age proof
 * const condition: ZKProofPolicyCondition = {
 *   circuit: ZKCircuitType.AGE_VERIFICATION,
 *   publicInputsPattern: { ageThreshold: 18 },
 *   maxProofAge: 3600000 // 1 hour
 * };
 *
 * // Evaluate condition
 * const result = await evaluator.evaluate(sessionId, condition, proof);
 * ```
 */
export declare class ZKPPolicyConditionEvaluator {
    private verifier;
    private sessionCache;
    private refreshManager;
    constructor(options?: {
        verifier?: ZKVerifierService;
        sessionCache?: SessionProofCacheManager;
        refreshManager?: ProofRefreshManager;
    });
    /**
     * Evaluate a ZKP policy condition
     */
    evaluate(sessionId: string, condition: ZKProofPolicyCondition, providedProof?: ZKProof): Promise<PolicyConditionResult>;
    /**
     * Evaluate multiple conditions (AND logic)
     */
    evaluateAll(sessionId: string, conditions: ZKProofPolicyCondition[], proofs?: Map<string, ZKProof>): Promise<MultiConditionResult>;
    /**
     * Evaluate conditions with OR logic (any one satisfied)
     */
    evaluateAny(sessionId: string, conditions: ZKProofPolicyCondition[], proofs?: Map<string, ZKProof>): Promise<MultiConditionResult>;
    /**
     * Get missing proofs for conditions
     */
    getMissingProofs(sessionId: string, conditions: ZKProofPolicyCondition[]): string[];
    /**
     * Match public inputs against a pattern
     */
    private matchPublicInputsPattern;
    /**
     * Get the session cache manager
     */
    getSessionCache(): SessionProofCacheManager;
    /**
     * Get the refresh manager
     */
    getRefreshManager(): ProofRefreshManager;
    /**
     * Destroy the evaluator and cleanup resources
     */
    destroy(): void;
}
/**
 * Result of evaluating a single policy condition
 */
export interface PolicyConditionResult {
    /** Whether condition is satisfied */
    satisfied: boolean;
    /** Reason for failure */
    reason?: string;
    /** Circuit that was evaluated */
    circuit: string;
    /** Verification result if available */
    verificationResult?: VerificationResult;
    /** Whether proof is required but missing */
    requiresProof?: boolean;
    /** Whether result was from cache */
    fromCache?: boolean;
    /** Proof age in milliseconds */
    proofAge?: number;
}
/**
 * Result of evaluating multiple conditions
 */
export interface MultiConditionResult {
    /** Whether all (AND) or any (OR) conditions are satisfied */
    allSatisfied: boolean;
    /** Individual results */
    results: PolicyConditionResult[];
    /** First failed condition (for AND) */
    failedCondition?: PolicyConditionResult;
    /** First satisfied condition (for OR) */
    satisfiedCondition?: PolicyConditionResult;
}
/**
 * Create a session proof cache manager
 */
export declare function createSessionProofCache(options?: {
    sessionTTL?: number;
    refreshThreshold?: number;
    cleanupInterval?: number;
}): SessionProofCacheManager;
/**
 * Create a proof refresh manager
 */
export declare function createProofRefreshManager(prover?: ZKProverService): ProofRefreshManager;
/**
 * Create a ZKP policy condition evaluator
 */
export declare function createZKPPolicyEvaluator(options?: {
    verifier?: ZKVerifierService;
    sessionCache?: SessionProofCacheManager;
    refreshManager?: ProofRefreshManager;
}): ZKPPolicyConditionEvaluator;
export {};
//# sourceMappingURL=integration.d.ts.map