""" Proof data model representing a cryptographic proof of existence. """ from dataclasses import dataclass, asdict from typing import Optional from datetime import datetime import json @dataclass class Proof: """ Immutable proof object containing hash, metadata, and validation info. """ proof_id: str content_hash: str hash_algorithm: str content_type: str content_size: int timestamp: str validation_status: str metadata: dict extracted_text: Optional[str] = None # OCR output (if applicable) ocr_engine: Optional[str] = None # Fixed: "tesseract" ocr_status: Optional[str] = None # "success" | "skipped" | "failed" def to_dict(self) -> dict: """Convert proof to dictionary.""" return asdict(self) def to_json(self) -> str: """Serialize proof to JSON string.""" return json.dumps(self.to_dict(), indent=2) @classmethod def from_dict(cls, data: dict) -> 'Proof': """Create proof from dictionary.""" return cls(**data) @classmethod def from_json(cls, json_str: str) -> 'Proof': """Deserialize proof from JSON string.""" return cls.from_dict(json.loads(json_str)) @dataclass class VerificationResult: """ Result of proof verification operation. """ proof_id: str is_valid: bool original_hash: str computed_hash: str timestamp: str message: str def to_dict(self) -> dict: """Convert result to dictionary.""" return asdict(self)