UNPKG

facezk-core

Version:

ZKP-AI Proof of Humanity: Live Selfie Check with Biometric Template Extraction and Fuzzy Hashing

250 lines 6.73 kB
/** * FaceZK Core - Modular Architecture * Privacy-first human verification with plugin-based architecture */ import type { Input, CoreConfig } from './interfaces'; import { PluginManager } from './plugin-manager'; import type { BiometricTemplate } from '../types'; export interface VerificationSession { id: string; startTime: Date; state: 'initializing' | 'detecting' | 'verifying' | 'completed' | 'failed'; progress: number; result?: VerificationResult; error?: string; /** Expression state management */ expressionState?: { lastStableFrame: number; stableExpressions: { blink: { detected: boolean; confidence: number; timestamp: number; }; smile: { detected: boolean; confidence: number; timestamp: number; }; headTurn: { detected: boolean; confidence: number; timestamp: number; }; }; frameCount: number; debounceTimer?: ReturnType<typeof setTimeout>; /** Sequential challenge tracking */ currentStep: 'blink' | 'head-turn' | 'smile' | 'completed'; stepProgress: { blink: { completed: boolean; confidence: number; timestamp: number; }; 'head-turn': { completed: boolean; confidence: number; timestamp: number; }; smile: { completed: boolean; confidence: number; timestamp: number; }; }; stepOrder: ('blink' | 'head-turn' | 'smile')[]; stepTimeouts: Map<string, ReturnType<typeof setTimeout>>; }; } export interface VerificationResult { verified: boolean; humanityCode: string; biometricId: string; livenessScore: number; confidence: number; timestamp: Date; sessionId: string; metadata: { processingTime: number; frameCount: number; challengesCompleted: string[]; stableExpressions?: { blink: { detected: boolean; confidence: number; timestamp: number; }; smile: { detected: boolean; confidence: number; timestamp: number; }; headTurn: { detected: boolean; confidence: number; timestamp: number; }; }; }; } export interface VerificationOptions { enableLiveness: boolean; livenessChallenges: string[]; minConfidence: number; minLivenessScore: number; maxProcessingTime: number; enableAudit: boolean; } export declare class FaceZKCore { private pluginManager; private config; private currentSession; private errorHandler; private isInitialized; private humanIntegration; private livenessState; private storedTemplates; private systemSalt; private facezkConfig; /** Expression state debouncing */ private expressionDebounceMs; private minStableFrames; constructor(config: CoreConfig, pluginManager?: PluginManager); /** * Initialize FaceZK with all required plugins */ initialize(): Promise<void>; /** * Start a new verification session */ startSession(): VerificationSession; /** * Process input for verification with expression state management */ processInput(input: Input, options?: Partial<VerificationOptions>): Promise<VerificationResult | null>; /** * Compare humanity codes for verification */ compareHumanityCodes(code1: string, code2: string): Promise<{ match: boolean; similarity: number; }>; /** * Compare biometric templates */ compareBiometricTemplates(template1: BiometricTemplate, template2: BiometricTemplate): Promise<{ match: boolean; similarity: number; }>; /** * Get stored template by biometric ID */ getStoredTemplate(biometricId: string): BiometricTemplate | undefined; /** * Clear stored templates */ clearStoredTemplates(): void; /** * Get current session */ getCurrentSession(): VerificationSession | null; /** * Reset current session */ resetSession(): void; /** * Get plugin information */ getPluginInfo(pluginId: string): import("./interfaces").PluginInfo | null; /** * List all plugins */ listPlugins(): import("./interfaces").PluginInfo[]; /** * Get system statistics */ getSystemStats(): { memory: any; audit: any; session: VerificationSession | null; plugins: import("./interfaces").PluginInfo[]; }; /** * Dispose FaceZK Core */ dispose(): Promise<void>; /** * Validate configuration */ private validateConfig; /** * Generate session ID */ private generateSessionId; /** * Log audit event */ private logAuditEvent; /** * Detect face in input using Human.js */ private detectFace; /** * Extract biometric template from face detection result */ private extractBiometricTemplate; /** * Generate biometric ID from template */ private generateBiometricId; /** * Perform liveness detection using frame analysis */ private performLivenessDetection; /** * Generate humanity code from biometric ID */ private generateHumanityCode; /** * Calculate confidence score from face detection and liveness */ private calculateConfidence; /** * Check verification criteria */ private checkVerificationCriteria; /** * Update expression state with new frame analysis */ private updateExpressionState; /** * Update sequential challenge progress */ private updateSequentialProgress; /** * Process blink step */ private processBlinkStep; /** * Process head turn step */ private processHeadTurnStep; /** * Process smile step */ private processSmileStep; /** * Advance to the next step in the sequence */ private advanceToNextStep; /** * Finalize expression state after debounce period */ private finalizeExpressionState; /** * Check if we have stable expressions for verification */ private hasStableExpressions; } //# sourceMappingURL=facezk-core.d.ts.map