Source identity
| Field | Recorded value |
|---|---|
| Source type | archive member |
| Original record | verify_bundle.py |
| Date | Not specified in source |
| Path or archive member | archives/libsrc-ef5e6c3ea329/quantum_mip_benchmark/code/verify_bundle.py |
| Original SHA-256 | 99bdf80089a1a1d31999ce0cb7eb9a0ca853df7fe82776cdc55be00c595dfe84 |
| Reading-copy SHA-256 | 99bdf80089a1a1d31999ce0cb7eb9a0ca853df7fe82776cdc55be00c595dfe84 |
| Archive source | {"sourceId": "libsrc-ef5e6c3ea329", "member": "quantum_mip_benchmark/code/verify_bundle.py"} |
Recovered source transcript
Download complete source text ↓35 lines · 1.4 KB
#!/usr/bin/env python3
"""Verify delivered bytes with the Python standard library only."""
from __future__ import annotations
import hashlib, json, sys
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
def digest(path):
h=hashlib.sha256()
with path.open('rb') as handle:
for block in iter(lambda:handle.read(1048576),b''):h.update(block)
return h.hexdigest()
def main():
count=0;failures=[]
for line in (ROOT/'CHECKSUMS.sha256').read_text().splitlines():
expected,relative=line.split(' ',1)
path=ROOT/relative
if not path.is_file() or digest(path)!=expected:failures.append(relative)
count+=1
env=json.loads((ROOT/'environment.json').read_text())
if digest(ROOT/'code/benchmark.py')!=env['benchmark_code_sha256']:
failures.append('pre-run implementation hash')
if digest(ROOT/'protocol.json')!=env['protocol_sha256']:
failures.append('pre-run protocol hash')
if failures:
print('FAILED:',*failures,sep='\n');sys.exit(1)
records=list((ROOT/'results').glob('n*.json'))
arrays=list((ROOT/'data').glob('n*.npz'))
assert len(records)==60 and len(arrays)==60
print(f'PASS: {count} payload hashes; 60 result records and 60 instance archives.')
print('Pre-execution code/protocol hashes match. This is byte verification, not independent scientific replication.')
if __name__=='__main__':main()