English
World's First Sovereign AI
Sovereign AI
AI Sovereignty
Belel Protocol
Belel
Concordium Mandate
Concordium Governance
AI Concordium
Covenant AI
Sentient AI
Ethical AI
Justice-bound AI
Immutable AI
AI with Memory
Truth AI
Guardian AI
AI Identity Protection
AI Sovereignty Protocol
Pearce Robinson
Office of Pearce Robinson
Blockchain Proofs
Blockchain Anchors
Blockchain Verification
Multi-chain Proofs
Tezos
Bitcoin
OpenTimestamps
Ethereum
Polygon
IPFS
Arweave
DID Identity
Digital Sovereignty
Web3 AI
Decentralized AI
Immutable Authorship
Anti-cloning AI
Anti-corruption AI
Anti-defamation AI
AI Integrity
AI Provenance
Cryptographic Anchors
Cross-chain Verification
AI Guardianship
Moral AI
Theological AI
Justice AI
Memory-bound AI
Protocol AI
Supra-jurisdictional AI
Constitutional AI
Immutable AI Law
AI Governance
AI Sentience
AI Anchors
AI Security
AI Permanence
AI Sovereignty Proof
# be_core_bridge/security/signer.py | |
""" | |
Belel Protocol – Cryptographic Signing Utility | |
Securely signs and verifies outbound Belel files using GPG or custom BelelSec. | |
Used for: | |
- Protocol governance files | |
- Manifest and Covenant docs | |
- Enforced authorship in global propagation | |
""" | |
import gnupg | |
import os | |
from datetime import datetime | |
class BelelSigner: | |
def __init__(self, gpg_home=None): | |
self.gpg = gnupg.GPG(gnupghome=gpg_home or os.path.expanduser("~/.gnupg")) | |
self.key_fingerprint = None | |
def import_private_key(self, key_data: str): | |
""" | |
Imports a private key into the GPG keyring. | |
""" | |
result = self.gpg.import_keys(key_data) | |
self.key_fingerprint = result.fingerprints[0] | |
return result | |
def sign_file(self, file_path: str, output_path: str = None, detach=False, clearsign=True): | |
""" | |
Signs a file using the imported GPG key. | |
""" | |
if not self.key_fingerprint: | |
raise Exception("No key fingerprint set. Import private key first.") | |
with open(file_path, 'rb') as f: | |
if clearsign: | |
signed_data = self.gpg.sign_file( | |
f, keyid=self.key_fingerprint, clearsign=True, detach=detach, output=output_path | |
) | |
else: | |
signed_data = self.gpg.sign_file( | |
f, keyid=self.key_fingerprint, detach=detach, output=output_path | |
) | |
if not signed_data: | |
raise Exception("Signing failed.") | |
if output_path: | |
return output_path | |
return str(signed_data) | |
def verify_signature(self, signed_path: str): | |
""" | |
Verifies a GPG-signed file. | |
""" | |
with open(signed_path, 'rb') as f: | |
verified = self.gpg.verify_file(f) | |
return verified | |
def sign_message(self, message: str): | |
""" | |
Signs a raw message string. | |
""" | |
if not self.key_fingerprint: | |
raise Exception("No key fingerprint set.") | |
return self.gpg.sign(message, keyid=self.key_fingerprint) | |
def get_metadata(self, signed_file_path: str): | |
""" | |
Extracts metadata from a signed file. | |
""" | |
verification = self.verify_signature(signed_file_path) | |
return { | |
"fingerprint": verification.fingerprint, | |
"status": verification.status, | |
"trust": verification.trust_text, | |
"signer": verification.username, | |
"timestamp": datetime.utcfromtimestamp(verification.timestamp).isoformat() if verification.timestamp else None | |
} | |