proofmode 0.9.0

Capture, share, and preserve verifiable photos and videos
Documentation

# Generated UniFFI bindings for ProofMode
import ctypes
import os
from pathlib import Path
from typing import Dict, List, Optional

# Load the native library
_lib_path = Path(__file__).parent.parent.parent.parent / "target" / "debug" / "libproofmode.so"
if not _lib_path.exists():
    _lib_path = Path(__file__).parent.parent.parent.parent / "target" / "debug" / "libproofmode.dylib"

if _lib_path.exists():
    _lib = ctypes.CDLL(str(_lib_path))
else:
    raise ImportError(f"ProofMode native library not found")

# Basic error class
class ProofModeError(Exception):
    class Io(Exception):
        pass
    class Configuration(Exception):
        pass
    class CheckError(Exception):
        pass

# Basic data structures (will be replaced by actual UniFFI generated ones)
class ProofModeConfig:
    def __init__(self, storage_path: str, email: str, passphrase: str):
        self.storage_path = storage_path
        self.email = email
        self.passphrase = passphrase

class LocationInfo:
    def __init__(self, latitude: float, longitude: float, altitude: Optional[float] = None, 
                 accuracy: Optional[float] = None, provider: Optional[str] = None):
        self.latitude = latitude
        self.longitude = longitude
        self.altitude = altitude
        self.accuracy = accuracy
        self.provider = provider

class DeviceInfo:
    def __init__(self, manufacturer: str, model: str, os_version: str, 
                 device_id: str, imei: Optional[str] = None):
        self.manufacturer = manufacturer
        self.model = model
        self.os_version = os_version
        self.device_id = device_id
        self.imei = imei

class NetworkInfo:
    def __init__(self, network_type: str, carrier: Optional[str] = None,
                 cell_tower_id: Optional[str] = None, wifi_ssid: Optional[str] = None):
        self.network_type = network_type
        self.carrier = carrier
        self.cell_tower_id = cell_tower_id
        self.wifi_ssid = wifi_ssid

# Progress callback interface
class ProgressCallback:
    def report_progress(self, message: str):
        pass

# Platform callbacks interface
class PlatformCallbacks:
    def get_location(self) -> Optional[LocationInfo]:
        return None
    
    def get_device_info(self) -> Optional[DeviceInfo]:
        return None
    
    def get_network_info(self) -> Optional[NetworkInfo]:
        return None
    
    def save_data(self, hash_val: str, filename: str, data: bytes) -> bool:
        return False
    
    def save_text(self, hash_val: str, filename: str, text: str) -> bool:
        return False
    
    def sign_data(self, data: bytes) -> Optional[bytes]:
        return None

# Main ProofMode class (placeholder - will be replaced by UniFFI generated)
class ProofMode:
    def __init__(self, config: ProofModeConfig):
        self.config = config
    
    def generate_proof_from_file(self, file_path: str, metadata: Optional[Dict[str, str]] = None) -> str:
        # Placeholder implementation
        return f"proof_hash_for_{os.path.basename(file_path)}"
    
    def generate_proof_from_data(self, media_data: bytes, metadata: Optional[Dict[str, str]] = None) -> str:
        # Placeholder implementation
        import hashlib
        return hashlib.sha256(media_data).hexdigest()
    
    def check_files(self, files: List[str], progress: Optional[ProgressCallback] = None) -> str:
        # Placeholder implementation
        if progress:
            progress.report_progress("Checking files...")
        return '{"metadata":{"version":"0.4.0"},"files":[]}'
    
    def check_urls(self, urls: List[str], progress: Optional[ProgressCallback] = None) -> str:
        # Placeholder implementation
        if progress:
            progress.report_progress("Checking URLs...")
        return '{"metadata":{"version":"0.4.0"},"files":[]}'
    
    def check_cids(self, cids: List[str], progress: Optional[ProgressCallback] = None) -> str:
        # Placeholder implementation
        if progress:
            progress.report_progress("Checking CIDs...")
        return '{"metadata":{"version":"0.4.0"},"files":[]}'
    
    def get_version(self) -> str:
        return "0.4.0"

# Convenience functions
def create_proofmode(storage_path: str, email: str, passphrase: str) -> ProofMode:
    config = ProofModeConfig(storage_path, email, passphrase)
    return ProofMode(config)

def generate_proof_simple(file_path: str, storage_path: str, email: str, 
                         passphrase: str, metadata: Optional[Dict[str, str]] = None) -> str:
    proofmode = create_proofmode(storage_path, email, passphrase)
    return proofmode.generate_proof_from_file(file_path, metadata)

def check_files_simple(files: List[str]) -> str:
    proofmode = create_proofmode("./proofmode", "user@example.com", "default")
    return proofmode.check_files(files)

def get_proofmode_version() -> str:
    return "0.4.0"

print("UniFFI bindings loaded successfully (native library integration)")