Skip to content

eBPF-based security platform

proofs: name the idealized hash the tree sync model assumes

Daniel Borkmanne5b2ad72ae4d
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index 47b540f4..30b0fb6d 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -1339,8 +1339,9 @@ the model follows the C.
sync rather than the next segment, and the cut a sync makes before
a walk back that refuses; the base and prefix checks are left out
of the model, as they only refuse more. A manifest digest names
- one publication; the hash is injective on
- (root, digest) and never 64 zeros; only sync writes the tree files,
+ one publication; the hash is injective on every (root, digest)
+ pair, an idealized hash, which no hash onto 32 bytes is, and
+ never 64 zeros; only sync writes the tree files,
each write whole, one sync at a time; the unlink of ``pending.json``
succeeds; an extend and its eventlog record are one write. An
outcome line holds whether the selector matched, not which of 1
diff --git a/testing/proofs/lean4/Shirudo/TreeSync.lean b/testing/proofs/lean4/Shirudo/TreeSync.lean
index 8930c5bb..635bd251 100644
--- a/testing/proofs/lean4/Shirudo/TreeSync.lean
+++ b/testing/proofs/lean4/Shirudo/TreeSync.lean
@@ -57,11 +57,12 @@ refusing a negative generation, and on a manifest digest naming one
publication. The cursor
and the order rest on the loop's own cursor check and recovery's; that each
operation is applied once rests on recovery's comparison of the replayed
-root and on its look at this boot's records, with the hash collision
-resistant. The outcomes record rests on the order of the writes, a line
-before the state that covers it, on the cut at the start of a sync, on
-recovery writing the lines of the operations the stopped sync passed over,
-and on `tree_publication_check()` numbering the operations without a gap;
+root and on its look at this boot's records, with the hash injective, an
+idealized hash (see `Assumptions`). The outcomes record rests on the order
+of the writes, a line before the state that covers it, on the cut at the
+start of a sync, on recovery writing the lines of the operations the
+stopped sync passed over, and on `tree_publication_check()` numbering the
+operations without a gap;
the head on the state written at acceptance and on the cursor check of
`Follows`. The parent check of `Follows` is not needed by any of these
theorems. `Assumptions` states what the C cannot show.
@@ -274,8 +275,8 @@ theorem rootOf_append (log : List (Line D)) (l : Line D) :
simp [rootOf, List.foldl_append]
/-- No operation leaves the projection root where it was, so a root tells
-whether the line of an operation is there: the hash is collision
-resistant, modelled as `Shirudo.Chain` models it. -/
+whether the line of an operation is there, for the idealized hash of
+`Chain.register_injective`, injective on every (root, digest) pair. -/
theorem rootOf_ne_next (hH : ∀ a b c d, H a b = H c d → a = c ∧ b = d)
(hinit : ∀ a b, H a b ≠ init) (log : List (Line D)) (d : D) :
rootOf H init log ≠ H (rootOf H init log) d := by
@@ -1613,9 +1614,13 @@ theorem recover_inv {Signed : Pub T M I D → M → Prop}
names one publication: it is the SHA-256 of the manifest, and
`bpm_oci_get_signed()` takes the one payload layer the manifest names by
its SHA-256 and checks it, while a registry may wrap one publication in any
-number of manifests. And the projection hash is collision resistant,
-modelled as `Shirudo.Chain` models it: injective on (root, digest) pairs
-and never the 64 zeros. -/
+number of manifests. And the projection hash is injective on (root,
+digest) pairs and never the 64 zeros, the idealized hash of
+`Chain.register_injective`. No hash onto 32 bytes is injective on every
+pair, so the theorems that rest on `hash_inj` hold of SHA-256 only as far
+as no two of the pairs it folds on the node collide, as
+`Chain.register_injective_on` states for the register; the proofs here do
+not narrow it to those pairs. -/
structure Assumptions (H : D → D → D) (init : D)
(Signed : Pub T M I D → M → Prop) : Prop where
binds : ∀ p p' m, Signed p m → Signed p' m → p = p'