Expand description
Content addressing for Trident: AST normalization + Poseidon2 hashing.
Every function definition gets a cryptographic identity (Poseidon2 hash) based on its normalized AST. Names are replaced with de Bruijn indices, dependency references are replaced with their hashes, and the result is deterministically serialized before hashing.
Uses Poseidon2 over the Goldilocks field for SNARK-friendly content addressing — content hashes are cheaply provable inside ZK proofs, enabling trustless compilation verification and on-chain registries.
Properties:
- Two functions with identical computation but different variable names produce the same hash.
- Changing any dependency changes the hash of all dependents.
- Renaming a function does not change its hash.
- Adding/removing comments or formatting does not change the hash.
Structs§
- Content
Hash - A 256-bit BLAKE3 content hash.
- Normalizer
- Normalize and serialize a function definition to bytes.
Functions§
- hash_
file - Hash all functions in a file, returning name → hash map.
- hash_
file_ content - Hash a complete file’s content (all items serialized together). Uses Poseidon2 for SNARK-friendly file-level content addressing.
- hash_
function - Hash a single function.