Download code/scripts/p2/verifier_hash.py from viai957/align: direct link, hf CLI and curl.
- Browser
- Download file 756 Bytes
-
https://huggingface.co/viai957/align/resolve/main/code/scripts/p2/verifier_hash.py
- Command line
-
hf download hf://viai957/align/code/scripts/p2/verifier_hash.py
-
curl -L -o verifier_hash.py https://huggingface.co/viai957/align/resolve/main/code/scripts/p2/verifier_hash.py
756 Bytes
| #!/usr/bin/env python3 | |
| """Frozen-verifier hash (docs/LEAN_VERIFIER.md 7.2): sha256 over each align/verify/**/*.py in sorted path order, | |
| hashing `path + NUL + bytes + NUL`. `--check HEX` exits 1 on mismatch.""" | |
| import argparse, hashlib, sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[2] | |
| def verifier_hash() -> str: | |
| h = hashlib.sha256() | |
| for p in sorted((ROOT / "align/verify").rglob("*.py")): | |
| rel = p.relative_to(ROOT).as_posix() | |
| h.update(rel.encode() + b"\0" + p.read_bytes() + b"\0") | |
| return h.hexdigest() | |
| if __name__ == "__main__": | |
| ap = argparse.ArgumentParser(); ap.add_argument("--check") | |
| a = ap.parse_args(); v = verifier_hash(); print(v) | |
| sys.exit(1 if a.check and a.check != v else 0) | |