UNPKG

@neabyte/quantum-zkp

Version:

Educational quantum-resistant zero-knowledge proof library for learning and prototyping

136 lines (135 loc) 3.71 kB
export type AlgorithmType = 'lattice' | 'hash' | 'multivariate' | 'hybrid'; export type ProofType = 'lattice' | 'hash' | 'multivariate' | 'hybrid'; export interface ProofParameters { dimension?: number; modulus?: bigint; chainLength?: number; variables?: number; equations?: number; parties?: number; algorithms?: AlgorithmType[]; weights?: Record<AlgorithmType, number>; } export interface BaseProof { type: ProofType; commitment: Buffer; challenge: Buffer; response: Buffer; parameters: ProofParameters; quantumSafe: boolean; timestamp: number; version: string; } export interface LatticeProof extends BaseProof { type: 'lattice'; dimension: number; modulus: bigint; polynomialCommitment: Buffer; } export interface HashProof extends BaseProof { type: 'hash'; chainLength: number; hashChain: Buffer[]; commitmentChain: Buffer; merkleTree?: Buffer[][]; merkleProof?: Buffer[]; } export interface MultivariateProof extends BaseProof { type: 'multivariate'; variables: number; equations: number; polynomialSystem: Buffer; solution: Buffer; } export interface HybridProof extends BaseProof { type: 'hybrid'; proofs: (LatticeProof | HashProof | MultivariateProof)[]; combined: Buffer; algorithmWeights: Record<AlgorithmType, number>; } export type Proof = LatticeProof | HashProof | MultivariateProof | HybridProof; export interface ThresholdProof { shares: Buffer[]; proofs: Proof[]; parties: number; algorithm: AlgorithmType; quantumSafe: boolean; threshold: number; reconstructionKey: Buffer; } export interface VerificationResult { isValid: boolean; algorithm: AlgorithmType; verificationTime: number; error?: string; } export interface PerformanceMetrics { generationTime: number; verificationTime: number; proofSize: number; memoryUsage: number; } export interface SecurityLevel { quantumResistant: boolean; classicalSecurity: number; quantumSecurity: number; recommendedUse: string[]; } export interface AlgorithmConfig { name: AlgorithmType; securityLevel: SecurityLevel; performanceProfile: PerformanceMetrics; recommendedFor: string[]; limitations: string[]; } export interface ZKPConfig { defaultAlgorithm: AlgorithmType; algorithms: Record<AlgorithmType, AlgorithmConfig>; batchSize: number; enableCaching: boolean; enableParallelProcessing: boolean; securityLevel: 'standard' | 'high' | 'maximum'; } export interface ValidationOptions { strictMode?: boolean; allowLegacyAlgorithms?: boolean; maxProofSize?: number; timeout?: number; } export interface BatchProcessingOptions { parallel: boolean; batchSize: number; progressCallback?: (progress: number) => void; } export interface ErrorDetails { code: string; message: string; algorithm?: AlgorithmType; suggestion?: string; } export declare class ZKPError extends Error { readonly code: string; readonly algorithm?: AlgorithmType; readonly suggestion?: string; constructor(details: ErrorDetails); } export interface BenchmarkResult { algorithm: AlgorithmType; operationsPerSecond: number; averageProofSize: number; averageGenerationTime: number; averageVerificationTime: number; memoryUsage: number; cpuUsage: number; } export interface SecurityAuditResult { algorithm: AlgorithmType; vulnerabilities: string[]; recommendations: string[]; riskLevel: 'low' | 'medium' | 'high' | 'critical'; alignment: { nist: boolean; iso: boolean; fips: boolean; }; }