import time import hmac import hashlib from dataclasses import dataclass from typing import Dict, Any @dataclass class DID: did: str key: str # simple shared-secret for HMAC-style signing (for MVP) def sign(self, message: str) -> str: return hmac.new(self.key.encode("utf-8"), message.encode("utf-8"), hashlib.sha256).hexdigest() def verify(self, message: str, signature: str) -> bool: expected = self.sign(message) return hmac.compare_digest(expected, signature) @dataclass class GovernanceLogEntry: action: str did: str details: Dict[str, Any] signature: str timestamp: float def to_dict(self) -> Dict[str, Any]: return { "action": self.action, "did": self.did, "details": self.details, "signature": self.signature, "timestamp": self.timestamp, }