Download models/proof.py from dipan004/Proofly: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/spaces/dipan004/Proofly/resolve/main/models/proof.py
- Command line
-
hf download hf://spaces/dipan004/Proofly/models/proof.py
-
curl -L -o proof.py https://huggingface.co/spaces/dipan004/Proofly/resolve/main/models/proof.py
1.56 kB
| """ | |
| Proof data model representing a cryptographic proof of existence. | |
| """ | |
| from dataclasses import dataclass, asdict | |
| from typing import Optional | |
| from datetime import datetime | |
| import json | |
| 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) | |
| def from_dict(cls, data: dict) -> 'Proof': | |
| """Create proof from dictionary.""" | |
| return cls(**data) | |
| def from_json(cls, json_str: str) -> 'Proof': | |
| """Deserialize proof from JSON string.""" | |
| return cls.from_dict(json.loads(json_str)) | |
| 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) |