mergedhumanPR #234Identity
fix(bundle): verify the declared bundle fingerprint
Verify that the manifest's declared bundle_fingerprint matches the canonical fingerprint of its file-hash map before accepting a bundle.
Description
The pitch.
## Summary Verify that the manifest's declared `bundle_fingerprint` matches the canonical fingerprint of its file-hash map before accepting a bundle. Previously, an edited record plus an updated per-file hash could pass verification while retaining the original bundle fingerprint and unchanged signed attestation. Verification compared the attestation against the declared fingerprint without recomputing that fingerprint from the file hashes. This closes that missing link using the existing fingerprint algorithm. It preserves unsigned-bundle support, per-file checks, evaluator replay, and attestation verification. Signatures still establish a key's commitment to bytes, not truth, independence, safety, or endorsement. ## Regression coverage - Clean unsigned and signed bundles still verify. - Edited record plus refreshed file hash is rejected against the stale root. - A refreshed root is rejected against an unchanged attestation. - Changing the attestation payload without re-signing is rejected. - A root-only edit is rejected. - The existing replay-mismatch fixture now refreshes the root so it continues testing replay rather than failing the new integrity check first. ## Verification - `.venv/bin/python -m pytest -q tests/test_bundle.py`: 10 passed. - `.venv/bin/python -m pytest -q`: 187 passed. - `.venv/bin/nandatown run marketplace --out <temporary-dir>`: PASSED. - `.venv/bin/nandatown run quote-crash-restart --out <temporary-dir>`: PASSED. - `git diff --check`: passed. - Python 3.12.13 locally; current CI also exercises Python 3.11. CI has no separate lint/format step. - Test-driven development: both stale-root regressions failed before the production fix. - Independent expert correctness and scope review completed. - Combined integration with #233 and the other three correctness fixes: 213 tests passed on both Python 3.11.15 and 3.12.13. Companion #235 applies the bundle verifier as a gate before rendering Town Proof. Merge this PR first; both PRs target main independently. Base: `projnanda/nandatown:main` at `4d57012a3dfb6b7aeee5ab429b26513a5eef4505`. This is a current-main fix, not a legacy port or a comprehensive bundle-format redesign.
Try it
Open PR on GitHubView diffCheckout locally
git fetch origin pull/234/head:pr-234
git checkout pr-234