Skip to main content

Module tensor_integrity

Module tensor_integrity 

Source
Expand description

Tamper-evident, append-only lineage commitments for tensor provenance, plus a zero-knowledge binding to verified linear-transformation proofs.

Companion to super::tensor_provenance (which tracks the parent→child DAG). This module adds the integrity layer the audit calls for:

  • Immutable, append-only lineage DAG. Each node is content-addressed by a BLAKE3 commitment over domain ++ parent_commitment ++ operation ++ params ++ data_bits. Any post-hoc edit to an ancestor’s data/operation changes that node’s commitment and therefore every descendant’s — so tampering anywhere in the lineage is detectable (verify_lineage). The DAG is append-only: the only way to extend it is to derive a new child; there is no in-place mutation path.
  • zk-transformation binding. transformation_commitment binds (input, output, operation) cryptographically — the public witness. For a linear tensor map (prove y = W·x without revealing W), the actual zero-knowledge proof is the real arkworks Groth16 private_matrix_multiply (crate::zk_proofs / linear_algebra). General per-op zk-SNARKs over arbitrary tensor ops are a recorded boundary (each op needs its own R1CS circuit).

Heap note: like tensor_provenance, this is the cold, host-side provenance layer (it walks a HashMap-backed graph and allocates small scratch Vecs for sorting). It is off the zero-heap hot path — the hot numerical kernels are in ode_advanced / ode_solver, which allocate nothing.

Structs§

LineageCommitment
A 32-byte BLAKE3 commitment content-addressing a tensor state within its lineage.

Functions§

commit_state
Content-address a single tensor state given its parent’s commitment (or None for a genesis/root state). The commitment binds the parent, the operation + its params (in deterministic key order), and the full data bits.
integrity_root
A Merkle-style integrity root over a set of leaf commitments (e.g. all current head states): a single 32-byte digest witnessing the whole provenance frontier. Order-independent (commitments are sorted first).
lineage_commitment
Fold the lineage commitment for state_id from the root down to the node. Returns None if the chain is broken (a referenced ancestor is missing).
transformation_commitment
Bind an input state, an output state, and the operation that produced it into a public 32-byte commitment — the witness a zero-knowledge transformation proof is checked against. (For linear maps, the ZK proof itself is the real Groth16 private_matrix_multiply; this is the public binding it commits to.)
verify_lineage
Verify that state_id’s lineage reproduces expected — i.e. nothing in the chain (data, operation, params, or structure) was altered after the commitment was taken.