VELORYN-Boundary-Kernel-Entropy / verify_manifest.py
PureOne's picture
Release VELORYN v1.0.0: boundary-kernel entropy theory
1c08905 verified
Raw History Blame Contribute Delete
1.16 kB
"""Check SHA-256 hashes of the distributed files. This is integrity, not proof checking."""
from pathlib import Path, PurePosixPath
import hashlib
import sys
root=Path(__file__).resolve().parent
manifest=root/'MANIFEST.sha256'
if not manifest.is_file():
raise SystemExit('MANIFEST.sha256 is missing.')
errors=[]; checked=0
for line in manifest.read_text(encoding='utf-8').splitlines():
if not line.strip(): continue
try:
expected,name=line.split(' ',1)
except ValueError:
errors.append('Malformed manifest line');continue
rel=PurePosixPath(name)
if rel.is_absolute() or '..' in rel.parts or len(expected)!=64:
errors.append(f'Unsafe or malformed entry: {name}');continue
path=root.joinpath(*rel.parts)
if not path.is_file():
errors.append(f'Missing: {name}');continue
actual=hashlib.sha256(path.read_bytes()).hexdigest()
if actual!=expected:
errors.append(f'Changed: {name}')
checked+=1
if errors:
print('\n'.join(errors),file=sys.stderr)
raise SystemExit(1)
print(f'Integrity verified for {checked} distributed files. This is not mathematical proof verification.')