//! 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.
use BTreeMap;
use crate*;
const HASH_VERSION: u8 = 1;
// โโโ Content Hash โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
/// A 256-bit BLAKE3 content hash.
;
pub
pub use Normalizer;
// โโโ Public API โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
/// Hash a single function.
/// Hash all functions in a file, returning name โ hash map.
/// Hash a complete file's content (all items serialized together).
/// Uses Poseidon2 for SNARK-friendly file-level content addressing.
/// Parse a single hex digit (0-9, a-f, A-F) to its numeric value.
trident/src/package/hash/mod.rs
ฯ 0.0%