Content hashing design #5999
Closed
SeanTAllen
started this conversation in
pony-dep
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Content hashing design decisions:
Hash the logical content, not the archive bytes. The hash is computed over the extracted files on disk, not the archive encoding. It survives format changes, re-encoding, or alternate transports.
Full Merkle tree with per-file proofs. SHA-256 throughout. Leaf nodes: SHA-256(relative_path_bytes || 0x00 || file_content_bytes) — binding the path into the leaf prevents swapped-content collisions. Interior nodes: SHA-256(left || right). Odd nodes promote without pairing; no duplication (duplicating the last node is a known weakness that enables second-preimage attacks).
Canonical ordering: leaf entries sorted by relative path as raw bytes, lexicographic. No locale sensitivity, no case folding.
Root hash is what goes in the config file and the ledger. Per-file membership is provable with the file's leaf hash plus sibling hashes to the root.
All reactions