mirror of
https://github.com/saymrwulf/fips205-slhdsa-verified.git
synced 2026-11-18 09:46:09 +00:00
Compare commits
3 commits
62d7ed1209
...
dce0473013
| Author | SHA1 | Date | |
|---|---|---|---|
| dce0473013 | |||
| 45a2f65a2d | |||
| 337e5e9481 |
9 changed files with 873 additions and 212 deletions
107
README.md
107
README.md
|
|
@ -5,16 +5,35 @@ path**, extracted from a pure-Rust implementation into Lean 4 via
|
|||
Charon/Aeneas — the same pipeline, discipline, and honesty rules as the
|
||||
four ed25519 campaigns (`dalek/anza/risc0/betrusted-ed25519-verified`).
|
||||
|
||||
## STATUS: eleven certificates over the extracted verify model (external review round 2 applied)
|
||||
## STATUS: eleven certificates over the extracted verify model (external review rounds 1–5 applied)
|
||||
|
||||
`verification/check.sh` is **green** (exit 0): the model compiles, the
|
||||
proofs compile, and the axiom audit passes. The audit now runs **inside
|
||||
Lean** (`verification/Proofs/Audit.lean`): it reads each certificate's cone
|
||||
from the kernel via `collectAxioms` and asserts SET EQUALITY against that
|
||||
certificate's expected boundary — so an *added* axiom and a silently
|
||||
*dropped* oracle dependency both fail, with no text parsing to misparse
|
||||
(external review round 2, 2026-07-24, replaced the earlier `#print axioms`
|
||||
text parser, which could fail open on an empty or truncated report).
|
||||
`verification/check.sh` is **green** (exit 0): the model compiles, the proofs
|
||||
compile, and the audit passes. The audit runs **inside Lean**
|
||||
(`verification/Proofs/Audit.lean`) and binds four things, each added because an
|
||||
external reviewer *demonstrated* the button going green without it:
|
||||
|
||||
- **axiom cones** — each certificate's cone is read from the kernel via
|
||||
`collectAxioms` and must equal its expected set EXACTLY, so an added axiom
|
||||
and a silently dropped oracle both fail (round 2 retired a text parser that
|
||||
could fail open on an empty or truncated report);
|
||||
- **coverage** — EVERY declaration in the eight certificate modules, of every
|
||||
kind, and in `Audit.lean` itself, must stay inside the axiom boundary (rounds
|
||||
4–5: an un-manifested `theorem : False`, then a `def : False`, then one inside
|
||||
the auditor, each passed a gate that checked only the listed certificates);
|
||||
- **statements and specifications** — `check.sh` binds to the **SHA-256** of a
|
||||
canonical block containing the policy constants, every certificate's
|
||||
fully-elaborated statement, and every reference fold's fully-elaborated
|
||||
*body*. Round 5 showed why the last part is essential: redefining a fold to
|
||||
*be* the extracted loop left every earlier fingerprint bit-identical while the
|
||||
certificate degenerated to "the loop equals the loop";
|
||||
- **bytes** — Phase 0 sha256-pins the four model files and the compiler harness
|
||||
`lean-guard`, purges stale `.olean`s, and forbids stray `.lean` files, so the
|
||||
verdict depends on committed bytes rather than build-directory state.
|
||||
|
||||
What the button still does **not** bind is stated plainly in
|
||||
[TRUSTED-BASE.md](TRUSTED-BASE.md) item 11 — `check.sh` itself, the toolchain
|
||||
env, and `$AENEAS_HOME`. `verification/check-selftest.sh` runs the reviewers'
|
||||
own exploits back against the gate; all are rejected.
|
||||
|
||||
**What is actually established** — eleven Lean theorems about the
|
||||
Aeneas-generated model of the **monomorphic `verify_mono` compatibility
|
||||
|
|
@ -50,6 +69,17 @@ cannot translate the deployed `Hashers` function-pointer struct):
|
|||
- **Not closed-form FIPS 205 correctness:** the folds are transliterations of
|
||||
the extracted loops (the hash primitives stay opaque); nothing here relates
|
||||
the recomputed root to a mathematical SLH-DSA specification.
|
||||
- **Read every loop certificate as "visible", not "correct".** This follows
|
||||
from the previous point but is worth stating on its own, because the per-
|
||||
certificate descriptions below are easy to over-read. Each reference fold is
|
||||
built from the *same* extracted primitives the loop calls, so any defect in
|
||||
the extracted code is faithfully copied into the fold and the theorem still
|
||||
holds. What is machine-checked is the loop's *scaffolding* — trip count,
|
||||
index arithmetic, state threading, argument order, branch structure. Whether
|
||||
the address schedule, the Merkle sibling order, or the FORS leaf index match
|
||||
FIPS 205 is a **human reading step**, not a proved one. (Round-5 review makes
|
||||
this sharper: the certificates are individually meaningful only to the extent
|
||||
someone has read each fold against the standard — see TRUSTED-BASE item 12.)
|
||||
|
||||
This is a real **intermediate** verification layer, not an end-to-end
|
||||
formal verification of the deployed verifier. After de-plumbing rounds 1+2
|
||||
|
|
@ -62,7 +92,14 @@ The trust base and residual assumptions are stated in
|
|||
extracted `chain_free` loop equals the explicit s-fold hash chain, with
|
||||
the hash address set to i, i+1, …, i+s−1 in turn. This rules out —
|
||||
machine-checked, for the monomorphic SHA2-128s `verify_mono` path — an
|
||||
off-by-one loop bound, a wrong address field, and wrong threading. Its
|
||||
off-by-one loop bound and wrong state threading. (It does **not** rule out
|
||||
a wrong ADRS field: the reference fold is built from the same extracted
|
||||
`set_hash_address` primitive the loop calls, so a wrong field would be
|
||||
faithfully copied into the fold and the theorem would still hold. What the
|
||||
certificate pins is what the extracted code does at each index, so a wrong
|
||||
field is *visible* in the certificate, not *excluded* by it — the mapping
|
||||
onto FIPS 205 Alg 5 is a human reading step, consistent with "the folds are
|
||||
transliterations of the extracted loops" above.) Its
|
||||
`#print axioms` cone is **exactly** `[propext, Classical.choice,
|
||||
Quot.sound, verify_mono.oracle.f]` — the three kernel axioms plus the one
|
||||
hash oracle it touches, and nothing else (no transpiler plumbing; the u32
|
||||
|
|
@ -84,10 +121,16 @@ The trust base and residual assumptions are stated in
|
|||
`xmss_pk_from_sig_free_loop` equals the fold that, at step k, sets the
|
||||
tree height to k+1, tests bit k of the leaf index, and on an even bit
|
||||
halves the tree index and hashes H(node ∥ auth[k]), on an odd bit sets
|
||||
the tree index to (i−1)/2 and hashes H(auth[k] ∥ node). This pins the
|
||||
the tree index to (i−1)/2 and hashes H(auth[k] ∥ node). This makes the
|
||||
Merkle sibling ORDER (the even/odd rule), the tree-height/tree-index
|
||||
address schedule, and the auth-path indexing — the heart of Merkle-path
|
||||
verification. Cone: kernel three + `verify_mono.oracle.h` (the first
|
||||
address schedule, and the auth-path indexing VISIBLE in the certificate —
|
||||
**it does not establish them as correct.** `xmssFoldN` calls the same
|
||||
extracted `set_tree_height`/`get_tree_index`/`oracle.h` that the loop body
|
||||
calls, so a swapped sibling order would be copied into the fold and the
|
||||
theorem would still hold. Read that as: the certificate pins what the
|
||||
extracted code *does* at each step; whether that matches FIPS 205
|
||||
Algorithm 10 is a human reading step. Cone: kernel three +
|
||||
`verify_mono.oracle.h` (the first
|
||||
certificate where H enters; F does not — the loop runs above the WOTS+
|
||||
computation).
|
||||
|
||||
|
|
@ -96,8 +139,9 @@ The trust base and residual assumptions are stated in
|
|||
at layer j, splits the tree index (idx_leaf = idx_tree mod 2^h' by
|
||||
mask+cast, then idx_tree >>= h'), sets the layer address to j and the
|
||||
tree address to the shifted index, and recomputes the node through
|
||||
`xmss_pk_from_sig` on the j-th XMSS signature. This pins the layer
|
||||
schedule of hypertree verification; the final node = pk_root comparison
|
||||
`xmss_pk_from_sig` on the j-th XMSS signature. This makes the layer
|
||||
schedule of hypertree verification visible in the certificate (same
|
||||
transliteration caveat as above); the final node = pk_root comparison
|
||||
sits one bind above, in `ht_verify_free`, and belongs to the apex
|
||||
composition. Cone: kernel three + `verify_mono.oracle.{f, h, t_l}` —
|
||||
the full WOTS+/XMSS machinery referenced through the fold, and nothing
|
||||
|
|
@ -117,9 +161,9 @@ re-run green after every source patch.
|
|||
|
||||
- **`fips205.fors_inner_loop_eq`** + **`fips205.fors_outer_loop_eq`**
|
||||
(Algorithm 17, FORS pk-from-sig): a nested loop, split into two theorems.
|
||||
The inner one pins the auth-path Merkle fold for a single FORS tree (bit
|
||||
The inner one equates the auth-path Merkle fold for a single FORS tree (bit
|
||||
source `indices[i] >> j`, `H` in the even/odd sibling order) — cone
|
||||
kernel-3 + `oracle.h`. The outer one pins the K-tree fold: for each tree
|
||||
kernel-3 + `oracle.h`. The outer one equates the K-tree fold: for each tree
|
||||
compute the leaf with `F` at index `(i<<a)+indices[i]`, run the inner
|
||||
Merkle loop, write `root[i]` — cone kernel-3 + `oracle.{f, h}`. Split into
|
||||
two files under the memory discipline; the outer step lemma closes by
|
||||
|
|
@ -170,15 +214,24 @@ same boundary.
|
|||
|
||||
## Scope
|
||||
|
||||
**Verify path only.** The extraction cone, mirroring FIPS 205's own
|
||||
algorithm tree:
|
||||
**Verify path only, rooted at `slh_verify_internal`.** The extraction root
|
||||
is `verify_mono::slh_verify_128s`, which is `slh_verify_internal_free(M′, sig,
|
||||
pk)` — it takes the already-assembled message digest input **M′ as an
|
||||
argument**. So the covered cone is:
|
||||
|
||||
```
|
||||
slh_verify -> slh_verify_internal
|
||||
slh_verify_internal(M′, …) ← the extraction ROOT (M′ is an input)
|
||||
-> fors_pk_from_sig
|
||||
-> ht_verify -> xmss_pk_from_sig -> wots_pk_from_sig -> chain
|
||||
```
|
||||
|
||||
Everything **above** this root, in `slh_verify`/`verify` (`src/lib.rs`), is
|
||||
OUT of scope and is stated as such in [TRUSTED-BASE.md](TRUSTED-BASE.md): M′
|
||||
assembly, the pure-vs-prehash **domain-separator byte** (`0u8` for `verify`,
|
||||
`1u8` for `hash_verify` — the entire cross-variant separation), the
|
||||
`ctx.len() > 255` check, and signature/public-key deserialization. A reader
|
||||
must NOT read `slh_verify -> slh_verify_internal` as "the top of the verify
|
||||
path is covered" — it is not; the top-of-path input handling is trusted base.
|
||||
Key generation and signing are out of scope (trusted base), exactly as
|
||||
ed25519 signing was. The five verify-path hash oracles (`h_msg, f, h,
|
||||
t_l, t_len` — SHA-2 instantiations; `prf`/`prf_msg` are sign-side only
|
||||
|
|
@ -217,10 +270,16 @@ this repository was created:
|
|||
model from the mono root; charon + aeneas both exit 0, and
|
||||
`verification/check.sh` compiles the result. At this compat-patch commit
|
||||
the only change to pre-existing code was two lines wiring the new module;
|
||||
the generic paths and all twelve parameter sets stayed untouched. (The
|
||||
later de-plumbing commits — rounds 1 and 2 — then made further local edits
|
||||
to `helpers.rs`/`wots.rs`, each documented and differential-tested; see the
|
||||
snapshot history at head `797b4ef`.)
|
||||
the generic paths and all twelve parameter sets stayed untouched. **That
|
||||
scoping does not extend to the later de-plumbing commits, and the difference
|
||||
matters:** round 1 (`6f6a9d6`) touched only the private `verify_mono.rs`, but
|
||||
round 2 (`bea1051`) rewrote `to_int` and `base_2b` in **`src/helpers.rs`,
|
||||
which the DEPLOYED generic verify path and the SIGNING path also call**
|
||||
(`slh.rs`, `wots.rs`, `fors.rs`). So the snapshot's deployed verifier — the
|
||||
one the differential test compares against — is itself patched relative to
|
||||
upstream `30bac08`. `src/wots.rs` was never modified by any patch commit (an
|
||||
earlier revision of this README wrongly named it). See the snapshot history
|
||||
at head `797b4ef` and TRUSTED-BASE.md item 7.
|
||||
|
||||
## What is claimed (the button is green)
|
||||
|
||||
|
|
|
|||
|
|
@ -45,3 +45,40 @@ proceeds and is part of every claim.
|
|||
`verify_mono` facade. The bridge to upstream's generic `pk.verify()` is
|
||||
the finite in-snapshot differential test, not a machine-checked
|
||||
refinement.
|
||||
10. **Everything above the extraction root.** The root is
|
||||
`verify_mono::slh_verify_128s = slh_verify_internal_free(M′, sig, pk)`,
|
||||
which takes the message-digest input **M′ as an argument**. The code in
|
||||
`slh_verify`/`verify` (`src/lib.rs`) that runs *before* this root is NOT
|
||||
covered by any certificate: the assembly of M′; the pure-vs-prehash
|
||||
**domain-separator byte** (`0u8` for `verify` vs `1u8` for `hash_verify`
|
||||
— the whole cross-variant domain separation); the FIPS-205 `ctx.len() >
|
||||
255` bound; and signature/public-key deserialization. The certificates
|
||||
say nothing about this input handling — a defect there (e.g. a wrong
|
||||
separator byte) would be outside every proof.
|
||||
**Concretely, so the consequence is not left to the reader:** that byte is
|
||||
the *only* thing separating the pure and prehash variants. If it were wrong
|
||||
or dropped, a signature issued over the pure M′ would verify as a prehash
|
||||
signature and vice versa — cross-variant signature confusion, a forgery
|
||||
primitive. No certificate in this repository would change.
|
||||
11. **The verification harness itself.** The certificates are statements
|
||||
checked by the Lean kernel, but the *button* that reports them is a shell
|
||||
script. Round-5 review demonstrated that stubbing `verification/lean-guard`
|
||||
alone — one repo-tracked file, without touching `check.sh`, the manifest, or
|
||||
the proofs — yields ALL GREEN in 3.6 seconds over deliberately destroyed
|
||||
proofs. `lean-guard` is therefore **sha256-pinned** by check.sh Phase 0
|
||||
(`PROVENANCE.json → harness_integrity_sha256`); it is kept rather than
|
||||
removed because it is the memory cap and machine-wide lock that protect the
|
||||
build machine (a Lean elaboration once reached 12.2 GB and took the host
|
||||
down). Still trusted, and NOT bound by anything the button can check:
|
||||
`check.sh` itself, `~/aeneas-toolchain/env.sh`, the `$AENEAS_HOME` tree
|
||||
(i.e. *which* Aeneas/Lean library the proofs are checked against), `python3`,
|
||||
and the Lean toolchain. An audit executed by a harness cannot defend against
|
||||
an author who edits that harness; the consumer defense is the pinned commit,
|
||||
reviewed at the pin.
|
||||
12. **Composition.** The apex does **not** compose the ten loop-fidelity
|
||||
theorems — it is a structural factorization of the extracted verifier around
|
||||
its final equality check and references none of them (it would remain
|
||||
provable if one were deleted). The ten are independent, individually
|
||||
human-reviewed lemmas. Round-5 review makes this worth stating here rather
|
||||
than only in the README: each of the ten is individually meaningful only to
|
||||
the extent a human has read its reference fold against FIPS 205.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"_comment": "Single machine-readable pin set to reproduce the extracted Lean model in gen/SlhVerify from source. External review round 2 (2026-07-24). Running verification/extract.sh against the pinned source tree with the pinned Charon/Aeneas toolchain reproduces the two aeneas-generated files byte-identically (sha256 below). The *External*.lean files are hand-maintained (not regenerated) and are NOT part of this reproducibility claim.",
|
||||
"_comment": "Single machine-readable pin set to reproduce the extracted Lean model in gen/SlhVerify from source. External review rounds 2-5 (2026-07-24 .. 2026-07-27). Running verification/extract.sh against the pinned source tree with the pinned Charon/Aeneas toolchain reproduces the two aeneas-generated files byte-identically (generated_artifacts_sha256 below). The *External*.lean files are hand-maintained (not regenerated) and are NOT part of that reproducibility claim — but they ARE byte-pinned for integrity in model_integrity_sha256, since they carry the five oracle axioms and the discharged Step definitions. NOTE: SlhVerify.llbc is an intermediate artifact and is .gitignored, so its hash here can only be checked by a party who re-runs extract.sh.",
|
||||
"parameter_set": "SLH-DSA-SHA2-128s",
|
||||
"source": {
|
||||
"repo": "github.com/saymrwulf/fips205-source",
|
||||
|
|
@ -10,8 +10,13 @@
|
|||
"rust_toolchain_toml": "nightly-2026-06-01"
|
||||
},
|
||||
"transpiler": {
|
||||
"charon": { "commit": "9dd7f23c", "toolchain_channel": "nightly-2026-06-01" },
|
||||
"aeneas": { "commit": "bf13c42e" }
|
||||
"charon": {
|
||||
"commit": "9dd7f23c",
|
||||
"toolchain_channel": "nightly-2026-06-01"
|
||||
},
|
||||
"aeneas": {
|
||||
"commit": "bf13c42e"
|
||||
}
|
||||
},
|
||||
"proof_env": {
|
||||
"lean": "v4.30.0-rc2 (3dc1a088b6d2d8eafe25a7cd7ec7b58d731bd7cc)",
|
||||
|
|
@ -32,5 +37,16 @@
|
|||
"gen/SlhVerify/FunsExternal.lean"
|
||||
],
|
||||
"byte_identical_regeneration_verified": "2026-07-24",
|
||||
"audit_gate": "verification/Proofs/Audit.lean — in-Lean exact per-certificate cone equality via collectAxioms (fail-closed); compiled by check.sh Phase 3; adversarially exercised by check-selftest.sh"
|
||||
}
|
||||
"model_integrity_sha256": {
|
||||
"_comment": "All four Lean model files check.sh Phase 0 pins before compiling anything \u2014 the two aeneas-generated files AND the two hand-maintained *External files (which carry the five oracle axioms and the Step defs). A hand-edit of the model fails the build here (round-4 reviewer F3).",
|
||||
"gen/SlhVerify/TypesExternal.lean": "37958beb7c90b649497a20b0802f98f0fb2d975c245eca956d7396af74d7759f",
|
||||
"gen/SlhVerify/FunsExternal.lean": "5efe551c35969c9da28b2f3eaed4a6a67c410c62a1926aab390e3abf010390f8",
|
||||
"gen/SlhVerify/Types.lean": "db720b4a30f512e6048212a472e6853b24931a8121cb94c4cf7e6489754d6384",
|
||||
"gen/SlhVerify/Funs.lean": "7b7de55fd0206142f2678a079a6ed4462292356bc7de08ecd55cac0c76a1da9f"
|
||||
},
|
||||
"harness_integrity_sha256": {
|
||||
"_comment": "The compiler harness is part of the trusted computing base: check.sh shells out to lean-guard for every compile, and round-5 review demonstrated that stubbing it alone yields ALL GREEN in 3.6s over destroyed proofs. lean-guard is KEPT (it is the memory cap and machine-wide lock that protect this machine after the 12.2GB OOM incident) and sha256-pinned by Phase 0. NOT covered, and disclosed as trusted in TRUSTED-BASE.md item 11: check.sh itself, ~/aeneas-toolchain/env.sh, $AENEAS_HOME, python3, and the Lean toolchain.",
|
||||
"lean-guard": "690d861cfd81b327604ffd5ef85599ee01b2bcd943907f5b71b8b6f99bad418f"
|
||||
},
|
||||
"audit_gate": "verification/Proofs/Audit.lean \u2014 in-Lean audit (round 5). Per certificate: exact cone equality (collectAxioms) + elaborated-statement check. Enumeration: EVERY declaration kind (def/theorem/opaque/axiom \u2014 round 4 matched theorems only, so a `def : False` passed) in the eight certificate modules AND in Audit.lean itself (the auditor is not exempt). Binding digest: check.sh binds to the SHA-256 of a canonical AUDIT-MANIFEST block covering the POLICY constants (allowedBoundary + certModules \u2014 round-5 NEW-1: widening allowedBoundary previously re-opened the False-proof with the fingerprint byte-identical), every certificate's fully-elaborated statement, and every reachable specification definition's fully-elaborated BODY (round-5 NEW-2: redefining a reference fold to *be* the extracted loop previously left cone and fingerprint intact while the certificate degenerated to `loop = loop`). The 32-bit Expr.hash is retained only as a per-certificate diagnostic, not as the binding. Fail-closed; adversarially exercised by check-selftest.sh. check.sh Phase 0 additionally purges stale .olean files, forbids stray .lean outside gen/ and Proofs/, and pins model + harness bytes."
|
||||
}
|
||||
|
|
@ -1,23 +1,47 @@
|
|||
/- ──────────────────────────────────────────────────────────────────────────────
|
||||
Proofs/Audit.lean — the axiom-cone audit, performed INSIDE Lean.
|
||||
Proofs/Audit.lean — the axiom / statement / specification / coverage audit.
|
||||
|
||||
Round-2 external review (2026-07-24) showed the bash `#print axioms` text
|
||||
parser was still fragile: it fail-OPENED on an empty `[]` or a truncated
|
||||
(missing-`]`) report, and it only subset-checked (a *removed* oracle
|
||||
dependency would pass unnoticed). This file removes text parsing entirely.
|
||||
ROUND 5 (third reviewer, 2026-07-27) demonstrated that the round-4 gate was
|
||||
closed at the EXPLOITS but not at the MECHANISMS. Three fail-opens, each
|
||||
executed end-to-end with the button printing ALL GREEN:
|
||||
|
||||
`collectAxioms` reads the kernel's own axiom set for each certificate. We
|
||||
assert, for every one of the eleven:
|
||||
NEW-1 `manifestFingerprint` covered `manifest` only — never
|
||||
`allowedBoundary`, the sole predicate the enumeration tests against.
|
||||
Adding one name to that list re-opened the `False`-proof completely,
|
||||
with the committed fingerprint BYTE-IDENTICAL.
|
||||
NEW-2 the statement fingerprint pinned each certificate's TYPE, which
|
||||
references its hand-written reference fold BY NAME. Redefining that
|
||||
fold to *be* the extracted loop left cone and type-hash identical
|
||||
while the certificate degenerated to "the loop equals the loop" —
|
||||
100% of the fidelity content lives in those definitions.
|
||||
(drill) layer-2 enumeration matched `.thmInfo` only, so a `def : False`
|
||||
passed; and this file's own declarations were enumerated by nothing.
|
||||
|
||||
· the certificate EXISTS and is a `theorem` (not an axiom/opaque sham,
|
||||
not a renamed/deleted name — `collectAxioms` returns `#[]` for a
|
||||
missing name, so existence is checked explicitly, fail-closed);
|
||||
· its cone equals its EXPECTED set EXACTLY — extras (a smuggled axiom)
|
||||
AND missing (a silently dropped oracle dependency) both fail.
|
||||
The fix binds the WHOLE audited object, not the parts an attacker happened to
|
||||
touch. This file emits a canonical AUDIT-MANIFEST block covering:
|
||||
|
||||
Any mismatch is a `throwError`, i.e. a Lean elaboration error → non-zero
|
||||
`lean` exit. There is no text to misparse and nothing fails open. This is
|
||||
the single source of the axiom claim; check.sh Phase 3 just compiles it.
|
||||
· the POLICY constants (`allowedBoundary`, `certModules`) — NEW-1;
|
||||
· every certificate's fully-elaborated STATEMENT (`pp.all`) — F2 properly;
|
||||
· every hand-written SPECIFICATION constant transitively reachable from
|
||||
those statements, with its fully-elaborated DEFINITION BODY — NEW-2.
|
||||
(Proof-valued constants contribute their statement, not their proof term:
|
||||
proof irrelevance makes the term semantically immaterial.)
|
||||
|
||||
`check.sh` binds to the **SHA-256** of that block. This also retires the
|
||||
32-bit `Expr.hash` as the load-bearing digest (NEW-5): the per-certificate
|
||||
type hashes below remain, but only as fast, human-legible DIAGNOSTICS that
|
||||
name which certificate moved — the cryptographic binding is the SHA-256.
|
||||
|
||||
Enumeration now covers EVERY declaration kind (`def`, `theorem`, `opaque`,
|
||||
`axiom`, …) in the eight certificate modules AND every declaration of this
|
||||
file itself (the auditor is no longer exempt from its own audit — round-5 R1).
|
||||
|
||||
Standing limit, stated accurately (see TRUSTED-BASE.md item 11 for the full
|
||||
trusted computing base): an audit executed by a harness cannot defend against
|
||||
an author who edits that harness. `verification/lean-guard` is therefore
|
||||
sha256-pinned by check.sh Phase 0, but `check.sh` itself, the toolchain env,
|
||||
and `$AENEAS_HOME` remain trusted. The consumer defense is, and always was,
|
||||
the pinned commit reviewed at the pin.
|
||||
────────────────────────────────────────────────────────────────────────────── -/
|
||||
import Proofs.ChainSpec
|
||||
import Proofs.WotsSpec
|
||||
|
|
@ -31,65 +55,185 @@ open Lean Elab Command
|
|||
|
||||
namespace SlhVerify.Audit
|
||||
|
||||
/-- Lean's three kernel axioms — permitted in every cone. -/
|
||||
/-- Lean's three kernel axioms. -/
|
||||
def kernel3 : List Name := [`propext, `Classical.choice, `Quot.sound]
|
||||
|
||||
/-- The five SHA-2 verify-path hash oracles — the documented cryptographic
|
||||
boundary (TRUSTED-BASE.md). No other axiom may appear anywhere. -/
|
||||
def oracleF : Name := `verify_mono.oracle.f
|
||||
def oracleH : Name := `verify_mono.oracle.h
|
||||
def oracleTL : Name := `verify_mono.oracle.t_l
|
||||
def oracleTLen : Name := `verify_mono.oracle.t_len
|
||||
def oracleHMsg : Name := `verify_mono.oracle.h_msg
|
||||
|
||||
/-- The entire allowed boundary: nothing outside this set is permitted in any
|
||||
certificate cone, and the expected table below may reference nothing else. -/
|
||||
/-- The ONLY axioms permitted in any cone anywhere in the audited modules.
|
||||
POLICY CONSTANT — folded into the SHA-256 digest (round-5 NEW-1): widening
|
||||
this list changes the digest and fails the build. -/
|
||||
def allowedBoundary : List Name :=
|
||||
kernel3 ++ [oracleF, oracleH, oracleTL, oracleTLen, oracleHMsg]
|
||||
|
||||
/-- EXACT expected cone per certificate. Ground truth captured 2026-07-24 via
|
||||
`collectAxioms` (Probe.lean) and cross-checked against both round-1
|
||||
reviewers' independent reconstructions. Each entry is asserted for SET
|
||||
EQUALITY, so this table is a load-bearing specification of the boundary:
|
||||
changing a proof so it drops an oracle, or adds one, breaks the audit. -/
|
||||
def expectedCones : List (Name × List Name) :=
|
||||
[ (`fips205.chain_free_loop_eq, kernel3 ++ [oracleF]),
|
||||
(`fips205.wots_loop1_eq, kernel3 ++ [oracleF]),
|
||||
(`fips205.xmss_loop_eq, kernel3 ++ [oracleH]),
|
||||
(`fips205.ht_loop_eq, kernel3 ++ [oracleF, oracleH, oracleTL]),
|
||||
(`fips205.fors_inner_loop_eq, kernel3 ++ [oracleH]),
|
||||
(`fips205.fors_outer_loop_eq, kernel3 ++ [oracleF, oracleH]),
|
||||
(`fips205.to_int_loop_eq, kernel3),
|
||||
(`fips205.to_byte_loop_eq, kernel3),
|
||||
(`fips205.wots_csum_loop_eq, kernel3),
|
||||
(`fips205.base2b_outer_loop_eq, kernel3),
|
||||
(`fips205.slh_verify_128s_accepts_iff, kernel3 ++ [oracleF, oracleH, oracleTL, oracleTLen, oracleHMsg]) ]
|
||||
/-- The eight certificate-bearing proof modules. POLICY CONSTANT — also folded
|
||||
into the digest. (It is additionally cross-checked by `certsSeen` below:
|
||||
every manifest certificate must be found inside one of these modules.) -/
|
||||
def certModules : List Name :=
|
||||
[`Proofs.ChainSpec, `Proofs.WotsSpec, `Proofs.XmssSpec, `Proofs.HtSpec,
|
||||
`Proofs.ForsInnerSpec, `Proofs.ForsOuterSpec, `Proofs.InputPrepSpec, `Proofs.ApexSpec]
|
||||
|
||||
/-- Per-certificate expected cone + a 32-bit `Expr.hash` of the elaborated
|
||||
statement. The hash is a DIAGNOSTIC ONLY (it names which certificate moved);
|
||||
the binding digest is the SHA-256 over the canonical block. -/
|
||||
def manifest : List (Name × List Name × UInt64) :=
|
||||
[ (`fips205.chain_free_loop_eq, kernel3 ++ [oracleF], 2535491171),
|
||||
(`fips205.wots_loop1_eq, kernel3 ++ [oracleF], 2968777228),
|
||||
(`fips205.xmss_loop_eq, kernel3 ++ [oracleH], 763493610),
|
||||
(`fips205.ht_loop_eq, kernel3 ++ [oracleF, oracleH, oracleTL], 1071622136),
|
||||
(`fips205.fors_inner_loop_eq, kernel3 ++ [oracleH], 2102092697),
|
||||
(`fips205.fors_outer_loop_eq, kernel3 ++ [oracleF, oracleH], 2749583942),
|
||||
(`fips205.to_int_loop_eq, kernel3, 3797401829),
|
||||
(`fips205.to_byte_loop_eq, kernel3, 3618049364),
|
||||
(`fips205.wots_csum_loop_eq, kernel3, 4245103433),
|
||||
(`fips205.base2b_outer_loop_eq, kernel3, 324621577),
|
||||
(`fips205.slh_verify_128s_accepts_iff, kernel3 ++ [oracleF, oracleH, oracleTL, oracleTLen, oracleHMsg], 2489587792) ]
|
||||
|
||||
/-- Deterministic name ordering for the canonical serialization. -/
|
||||
def sortNames (l : List Name) : List Name :=
|
||||
((l.map toString).toArray.qsort (· < ·)).toList.map (·.toName)
|
||||
|
||||
/-- Whitespace-canonical: every whitespace run collapses to one space, so the
|
||||
pretty-printer's line wrapping cannot perturb the digest. -/
|
||||
def normWs (s : String) : String :=
|
||||
(s.foldl (fun (acc : String × Bool) c =>
|
||||
let c := if c.isWhitespace then ' ' else c
|
||||
if c == ' ' then (if acc.2 then acc else (acc.1.push ' ', true))
|
||||
else (acc.1.push c, false))
|
||||
("", true)).1
|
||||
|
||||
/-- Is `n` a hand-written declaration living in one of the certificate modules?
|
||||
These are the SPECIFICATION side — the folds the certificates are stated
|
||||
against — as opposed to the extracted model in `gen/` (pinned by Phase 0). -/
|
||||
def isSpecConst (env : Environment) (n : Name) : Bool :=
|
||||
match env.getModuleIdxFor? n with
|
||||
| some idx => certModules.contains env.header.moduleNames[idx.toNat]!
|
||||
| none => false
|
||||
|
||||
/-- Transitive closure over specification constants, starting from a
|
||||
certificate's STATEMENT and following DEFINITION bodies (a theorem
|
||||
contributes its statement only). This discovers the reference folds — and
|
||||
any future one — automatically, so a new specification definition cannot be
|
||||
introduced without moving the digest. -/
|
||||
partial def closureOf (env : Environment) (seen : NameSet) (work : List Name) : NameSet :=
|
||||
match work with
|
||||
| [] => seen
|
||||
| n :: rest =>
|
||||
if seen.contains n || !isSpecConst env n then closureOf env seen rest
|
||||
else
|
||||
let seen := seen.insert n
|
||||
let more := match env.find? n with
|
||||
| some (.defnInfo v) => v.value.getUsedConstants.toList ++ v.type.getUsedConstants.toList
|
||||
| some ci => ci.type.getUsedConstants.toList
|
||||
| none => []
|
||||
closureOf env seen (more ++ rest)
|
||||
|
||||
/-- Fully-explicit (`pp.all`) rendering, whitespace-canonicalized. -/
|
||||
def ppAll (e : Expr) : CommandElabM String := do
|
||||
let s ← Command.liftCoreM <| Meta.MetaM.run' <|
|
||||
withOptions (fun o => o.setBool `pp.all true) do
|
||||
return (← Meta.ppExpr e).pretty
|
||||
return normWs s
|
||||
|
||||
elab "auditCones" : command => do
|
||||
let env ← getEnv
|
||||
-- (0) the expected table itself must stay within the boundary — guards a typo
|
||||
-- in this file from silently widening what "allowed" means.
|
||||
for (cert, expected) in expectedCones do
|
||||
for a in expected do
|
||||
unless allowedBoundary.contains a do
|
||||
throwError "audit table references non-boundary axiom {a} for {cert}"
|
||||
-- (1) per certificate: exists ∧ is a theorem ∧ cone == expected set exactly.
|
||||
let mut errs : Array String := #[]
|
||||
for (cert, expected) in expectedCones do
|
||||
|
||||
-- (0) the manifest's expected cones may reference nothing outside the policy.
|
||||
for (cert, cone, _) in manifest do
|
||||
for a in cone do
|
||||
unless allowedBoundary.contains a do
|
||||
throwError "manifest references non-boundary axiom {a} for {cert}"
|
||||
|
||||
-- (1) NAMED CERTS: exists ∧ is a theorem ∧ exact cone ∧ statement diagnostic.
|
||||
for (cert, expected, expFp) in manifest do
|
||||
match env.find? cert with
|
||||
| none => errs := errs.push s!"{cert}: NOT FOUND (renamed/deleted?)"
|
||||
| some (.thmInfo _) =>
|
||||
| none => errs := errs.push s!"{cert}: NOT FOUND (renamed/deleted?)"
|
||||
| some (.thmInfo ci) =>
|
||||
let got := (← collectAxioms cert).toList
|
||||
let extras := got.filter (fun a => !expected.contains a)
|
||||
let missing := expected.filter (fun a => !got.contains a)
|
||||
unless extras.isEmpty && missing.isEmpty do
|
||||
errs := errs.push s!"{cert}: extra={extras} missing={missing}"
|
||||
| some (.axiomInfo _) => errs := errs.push s!"{cert}: is an AXIOM, not a proven theorem"
|
||||
| some (.opaqueInfo _) => errs := errs.push s!"{cert}: is OPAQUE, not a proven theorem"
|
||||
| some _ => errs := errs.push s!"{cert}: not a theorem"
|
||||
errs := errs.push s!"{cert}: cone extra={extras} missing={missing}"
|
||||
unless ci.type.hash == expFp do
|
||||
errs := errs.push s!"{cert}: STATEMENT fingerprint {ci.type.hash} ≠ committed {expFp} (statement changed?)"
|
||||
| some (.axiomInfo _) => errs := errs.push s!"{cert}: is an AXIOM, not a proven theorem"
|
||||
| some (.opaqueInfo _) => errs := errs.push s!"{cert}: is OPAQUE, not a proven theorem"
|
||||
| some _ => errs := errs.push s!"{cert}: not a theorem"
|
||||
|
||||
-- (2) ENUMERATION over EVERY declaration kind — not just theorems (a
|
||||
-- `def : False` passed the round-4 gate) — in the eight certificate
|
||||
-- modules, AND over this file's own declarations (module index is `none`
|
||||
-- during its own elaboration), so the auditor is not exempt (round-5 R1).
|
||||
let manifestNames := manifest.map (·.1)
|
||||
let mut nEnum := 0
|
||||
let mut certsSeen : Array Name := #[]
|
||||
for (nm, ci) in env.constants.toList do
|
||||
let scope : Option String :=
|
||||
match env.getModuleIdxFor? nm with
|
||||
| some idx =>
|
||||
let m := env.header.moduleNames[idx.toNat]!
|
||||
if certModules.contains m then some (toString m) else none
|
||||
| none => if nm.isInternal then none else some "Proofs.Audit (this file)"
|
||||
match scope with
|
||||
| none => pure ()
|
||||
| some where_ =>
|
||||
nEnum := nEnum + 1
|
||||
if manifestNames.contains nm then certsSeen := certsSeen.push nm
|
||||
match ci with
|
||||
| .axiomInfo _ =>
|
||||
-- the five oracle axioms live in gen/ (Phase-0 pinned); an axiom
|
||||
-- DECLARED inside an audited module is never acceptable.
|
||||
errs := errs.push s!"AXIOM DECLARED in audited scope: {nm} ({where_})"
|
||||
| _ =>
|
||||
let cone := (← collectAxioms nm).toList
|
||||
let bad := cone.filter (fun a => !allowedBoundary.contains a)
|
||||
unless bad.isEmpty do
|
||||
errs := errs.push s!"UN-AUDITED declaration {nm} ({where_}) has disallowed axioms {bad}"
|
||||
for cert in manifestNames do
|
||||
unless certsSeen.contains cert do
|
||||
errs := errs.push s!"manifest cert {cert} not found in any certificate module"
|
||||
|
||||
unless errs.isEmpty do
|
||||
throwError "EXACT-CONE AUDIT FAILED (fail-closed):\n{String.intercalate "\n" errs.toList}"
|
||||
logInfo s!"exact-cone audit PASSED: {expectedCones.length} certificates, each cone == its expected boundary set (kernel-3 + only the named SHA-2 oracles)"
|
||||
throwError "AUDIT FAILED (fail-closed):\n{String.intercalate "\n" errs.toList}"
|
||||
|
||||
-- (3) CANONICAL BLOCK: policy + statements + specification bodies. check.sh
|
||||
-- binds to the SHA-256 of everything between the markers.
|
||||
let mut lines : Array String := #[]
|
||||
lines := lines.push
|
||||
s!"policy|allowedBoundary={String.intercalate "," ((sortNames allowedBoundary).map toString)}|certModules={String.intercalate "," ((sortNames certModules).map toString)}"
|
||||
let mut specs : NameSet := {}
|
||||
for (cert, cone, _) in manifest do
|
||||
let ci := (env.find? cert).get!
|
||||
specs := (closureOf env {} ci.type.getUsedConstants.toList).toList.foldl (·.insert ·) specs
|
||||
lines := lines.push
|
||||
s!"cert|{cert}|cone={String.intercalate "," ((sortNames cone).map toString)}|type={← ppAll ci.type}"
|
||||
for nm in sortNames specs.toList do
|
||||
match env.find? nm with
|
||||
| none => errs := errs.push s!"specification constant vanished: {nm}"
|
||||
| some ci =>
|
||||
let isProp ← Command.liftCoreM <| Meta.MetaM.run' <| Meta.isProp ci.type
|
||||
-- proof irrelevance: a Prop-valued constant contributes its STATEMENT;
|
||||
-- a data definition contributes its BODY — that is where fidelity lives.
|
||||
if isProp then
|
||||
lines := lines.push s!"spec|{nm}|prop|type={← ppAll ci.type}"
|
||||
else
|
||||
match ci with
|
||||
| .defnInfo v => lines := lines.push s!"spec|{nm}|def|value={← ppAll v.value}"
|
||||
| _ => lines := lines.push s!"spec|{nm}|other|type={← ppAll ci.type}"
|
||||
unless errs.isEmpty do
|
||||
throwError "AUDIT FAILED (fail-closed):\n{String.intercalate "\n" errs.toList}"
|
||||
|
||||
logInfo ("AUDIT-MANIFEST-BEGIN\n" ++ String.intercalate "\n" lines.toList ++ "\nAUDIT-MANIFEST-END")
|
||||
-- check.sh prints the certificate list it gets from HERE, not from a hand-kept
|
||||
-- bash array (drill finding: the one authoritative claim string was the one
|
||||
-- thing nothing bound — adding a name to it printed a cert that never existed).
|
||||
logInfo s!"CERTIFICATES: {String.intercalate " " (manifestNames.map toString)}"
|
||||
logInfo s!"exact-cone audit PASSED: {manifest.length} certificates (cones + statements), {specs.toList.length} specification constants pinned, {nEnum} declarations enumerated clean"
|
||||
|
||||
end SlhVerify.Audit
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,13 @@
|
|||
explicit s-fold application of the hash F, with the hash-address set to
|
||||
i, i+1, …, i+s−1 in turn. This rules out — machine-checked, for the
|
||||
monomorphic SHA2-128s `verify_mono` path (a private facade, not the
|
||||
deployed generic verifier) — an off-by-one loop bound, a wrong address
|
||||
field, and wrong threading. F stays opaque
|
||||
(verify_mono.oracle.f), so the certificate cone is the three kernel axioms
|
||||
+ oracle.f, and nothing else (audited by check.sh Phase 3).
|
||||
deployed generic verifier) — an off-by-one loop bound and wrong state
|
||||
threading. It does NOT rule out a wrong ADRS field: `chainFoldN` calls the
|
||||
same extracted `set_hash_address` the loop does, so a wrong field would be
|
||||
copied into the fold and the theorem would still hold — the field is made
|
||||
VISIBLE in the certificate (a transliteration), not excluded by it. F stays
|
||||
opaque (verify_mono.oracle.f), so the certificate cone is the three kernel
|
||||
axioms + oracle.f, and nothing else (audited by check.sh Phase 3).
|
||||
|
||||
The proof: an induction on the step count. `chain_step` is one loop step =
|
||||
one fold step, proven by unfolding the Aeneas `loop` fixpoint one turn
|
||||
|
|
|
|||
|
|
@ -93,3 +93,187 @@ test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fin
|
|||
running 37 tests
|
||||
test result: ok. 37 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 27.89s
|
||||
```
|
||||
|
||||
## INDEPENDENT RUN — executed by the operator (the round-3 blocker)
|
||||
|
||||
Round 3's single remaining blocker was a recorded toolchain session
|
||||
executed by a party other than the author agent. The operator ran the
|
||||
block below personally on 2026-07-27 (a first attempt on 2026-07-24
|
||||
failed with a memory-clamped lean abort on a loaded desktop — an
|
||||
environment condition, diagnosed from ~/.lean-guard.log and addressed
|
||||
by the lean-guard stderr-diagnostics commit 62d7ed1; the proofs were
|
||||
never implicated). Result: check.sh ALL GREEN at 62d7ed1 (11
|
||||
certificates, exact-cone audit passed) and extract.sh regeneration
|
||||
byte-identical against fips205-source @ 797b4ef — both sha256 values
|
||||
match PROVENANCE.json. Transcript verbatim from the operator's shell:
|
||||
|
||||
```
|
||||
INDEPENDENT RUN — executed by the operator, 20260727T125816Z
|
||||
proof repo @ 62d7ed12091bb9bd267724b698f663c00ddc3210
|
||||
fips205-slhdsa-verified — check
|
||||
===============================
|
||||
=== Phase 1: compile the extracted model ===
|
||||
· gen/SlhVerify/TypesExternal
|
||||
· gen/SlhVerify/Types
|
||||
· gen/SlhVerify/FunsExternal
|
||||
· gen/SlhVerify/Funs
|
||||
=== Phase 2: compile the proofs ===
|
||||
· ChainSpec
|
||||
· WotsSpec
|
||||
· XmssSpec
|
||||
· HtSpec
|
||||
· ForsInnerSpec
|
||||
· ForsOuterSpec
|
||||
· InputPrepSpec
|
||||
· ApexSpec
|
||||
=== Phase 3: axiom audit (exact cone per certificate — inside Lean) ===
|
||||
✓ exact-cone audit PASSED: each of the 11 certificate cones == its expected boundary set
|
||||
|
||||
ALL GREEN — model compiles, proofs compile, and every certificate cone
|
||||
equals EXACTLY the three kernel axioms plus its documented SHA-2 oracles.
|
||||
Certificates proven: fips205.chain_free_loop_eq fips205.wots_loop1_eq fips205.xmss_loop_eq fips205.ht_loop_eq fips205.fors_inner_loop_eq fips205.fors_outer_loop_eq fips205.to_int_loop_eq fips205.to_byte_loop_eq fips205.wots_csum_loop_eq fips205.base2b_outer_loop_eq fips205.slh_verify_128s_accepts_iff
|
||||
--- extract.sh byte-identity ---
|
||||
[0/2] provenance OK: fips205-source @ 797b4ef26338 (clean)
|
||||
[1/2] charon: Rust -> LLBC (monomorphic SHA2-128s verify cone;
|
||||
crate::verify_mono::oracle is the opaque SHA-2 boundary)
|
||||
Compiling fips205 v0.4.1 (/home/oho/GitClone/FormalVerification/sources/fips205-source)
|
||||
Finished `dev` profile [optimized + debuginfo] target(s) in 0.54s
|
||||
[2/2] aeneas: LLBC -> Lean (split files, SlhVerify.* modules;
|
||||
hand-maintained TypesExternal.lean / FunsExternal.lean are
|
||||
NOT overwritten once they exist)
|
||||
[[92mInfo[39m ] Imported: SlhVerify.llbc
|
||||
[?25lApplied prepasses: [------------------------------------------------] 0/142 ⠋
Applied prepasses: [------------------------------------------------] 1/142 ⠋
Applied prepasses: [###---------------------------------------------] 11/142 ⠋
Applied prepasses: [#################-------------------------------] 52/142 ⠙
Applied prepasses: [########################################--------] 120/142 ⠙
Applied prepasses: [################################################] 142/142 ✔️
|
||||
[?25h[?25lTranslated globals: [-------------------------------------------------] 0/10 ⠋
Translated globals: [#################################################] 10/10 ✔️
|
||||
[?25h[?25lTranslated opaque functions: [----------------------------------------] 0/76 ⠋
Translated opaque functions: [########################################] 76/76 ✔️
|
||||
[?25h[?25lTranslated transparent functions: [-----------------------------------] 0/42 ⠋
Translated transparent functions: [-----------------------------------] 1/42 ⠙
Translated transparent functions: [#######----------------------------] 9/42 ⠹
Translated transparent functions: [########---------------------------] 10/42 ⠹
Translated transparent functions: [##########-------------------------] 12/42 ⠹
Translated transparent functions: [##########-------------------------] 13/42 ⠹
Translated transparent functions: [###########------------------------] 14/42 ⠸
Translated transparent functions: [############-----------------------] 15/42 ⠸
Translated transparent functions: [##############---------------------] 17/42 ⠸
Translated transparent functions: [###############--------------------] 19/42 ⠸
Translated transparent functions: [################-------------------] 20/42 ⠼
Translated transparent functions: [##################-----------------] 22/42 ⠼
Translated transparent functions: [####################---------------] 24/42 ⠼
Translated transparent functions: [#####################--------------] 26/42 ⠴
Translated transparent functions: [######################-------------] 27/42 ⠴
Translated transparent functions: [#######################------------] 28/42 ⠦
Translated transparent functions: [########################-----------] 29/42 ⠦
Translated transparent functions: [#########################----------] 30/42 ⠦
Translated transparent functions: [#########################----------] 31/42 ⠧
Translated transparent functions: [###########################--------] 33/42 ⠇
Translated transparent functions: [#############################------] 35/42 ⠏
Translated transparent functions: [##############################-----] 36/42 ⠏
Translated transparent functions: [##############################-----] 37/42 ⠋
Translated transparent functions: [###############################----] 38/42 ⠙
Translated transparent functions: [################################---] 39/42 ⠹
Translated transparent functions: [#################################--] 40/42 ⠸
Translated transparent functions: [##################################-] 41/42 ⠸
Translated transparent functions: [###################################] 42/42 ⠼
Translated transparent functions: [###################################] 42/42 ✔️
|
||||
[?25h[?25lTranslated trait declarations: [--------------------------------------] 0/33 ⠋
Translated trait declarations: [##############------------------------] 13/33 ✔️
|
||||
[?25h[?25lTranslated trait impls: [---------------------------------------------] 0/50 ⠋
Translated trait impls: [######################-----------------------] 25/50 ✔️
|
||||
[?25h[?25lPost-processed translated opaque functions: [-------------------------] 0/76 ⠋
Post-processed translated opaque functions: [-------------------------] 1/76 ⠙
Post-processed translated opaque functions: [#########################] 76/76 ✔️
|
||||
[?25h[?25lPost-processed translated transparent functions: [--------------------] 0/42 ⠋
Post-processed translated transparent functions: [--------------------] 1/42 ⠙
Post-processed translated transparent functions: [###-----------------] 7/42 ⠙
Post-processed translated transparent functions: [####----------------] 9/42 ⠙
Post-processed translated transparent functions: [####----------------] 10/42 ⠹
Post-processed translated transparent functions: [#####---------------] 11/42 ⠹
Post-processed translated transparent functions: [#####---------------] 12/42 ⠸
Post-processed translated transparent functions: [######--------------] 13/42 ⠸
Post-processed translated transparent functions: [######--------------] 14/42 ⠸
Post-processed translated transparent functions: [#######-------------] 15/42 ⠼
Post-processed translated transparent functions: [#######-------------] 16/42 ⠼
Post-processed translated transparent functions: [########------------] 17/42 ⠼
Post-processed translated transparent functions: [#########-----------] 19/42 ⠴
Post-processed translated transparent functions: [#########-----------] 20/42 ⠴
Post-processed translated transparent functions: [##########----------] 21/42 ⠴
Post-processed translated transparent functions: [##########----------] 22/42 ⠦
Post-processed translated transparent functions: [##########----------] 23/42 ⠦
Post-processed translated transparent functions: [###########---------] 25/42 ⠦
Post-processed translated transparent functions: [############--------] 26/42 ⠧
Post-processed translated transparent functions: [############--------] 27/42 ⠧
Post-processed translated transparent functions: [#############-------] 28/42 ⠧
Post-processed translated transparent functions: [##############------] 30/42 ⠇
Post-processed translated transparent functions: [###############-----] 32/42 ⠇
Post-processed translated transparent functions: [###############-----] 33/42 ⠏
Post-processed translated transparent functions: [################----] 34/42 ⠏
Post-processed translated transparent functions: [#################---] 37/42 ⠋
Post-processed translated transparent functions: [##################--] 38/42 ⠋
Post-processed translated transparent functions: [##################--] 39/42 ⠙
Post-processed translated transparent functions: [###################-] 40/42 ⠹
Post-processed translated transparent functions: [###################-] 41/42 ⠸
Post-processed translated transparent functions: [####################] 42/42 ⠼
Post-processed translated transparent functions: [####################] 42/42 ✔️
|
||||
[?25h[[92mInfo[39m ] Generated: gen/SlhVerify/Types.lean
|
||||
[[92mInfo[39m ] Generated: gen/SlhVerify/FunsExternal_Template.lean
|
||||
[[92mInfo[39m ] Generated: gen/SlhVerify/Funs.lean
|
||||
[[92mInfo[39m ] Total execution time: 8.980301 seconds
|
||||
Done. Now run ./check.sh (Phase 1: the regenerated model must type-check).
|
||||
db720b4a30f512e6048212a472e6853b24931a8121cb94c4cf7e6489754d6384 gen/SlhVerify/Types.lean
|
||||
7b7de55fd0206142f2678a079a6ed4462292356bc7de08ecd55cac0c76a1da9f gen/SlhVerify/Funs.lean
|
||||
```
|
||||
|
||||
## Round-4 hardening (third reviewer, 2026-07-27)
|
||||
|
||||
The third reviewer demonstrated three fail-opens OUTSIDE the cone check
|
||||
(F1 unbound cert set / un-manifested theorem; F2 statements unbound; F3
|
||||
model bytes unbound). All fixed. check.sh green with the hardened gate,
|
||||
and the adversarial self-test then rejected eight attacks including the two
|
||||
the reviewer used to make the button green over a repo proving False.
|
||||
|
||||
**CORRECTION (2026-07-27, found by an independent audit of this file).** The
|
||||
three lines that stood here inside the fence below were **not** console output:
|
||||
they were a hand-written summary of the run, fenced as if captured. `check.sh`
|
||||
never printed them. The author wrote them; that is fabricated evidence in the
|
||||
one document whose stated purpose is to carry machine evidence to reviewers who
|
||||
cannot run the toolchain, and it is exactly the failure this project exists to
|
||||
prevent. They have been removed. The selftest transcript that follows in the
|
||||
same fence **is** verbatim.
|
||||
|
||||
Two further corrections to this file's framing:
|
||||
* the "INDEPENDENT RUN — executed by the operator" block above is at proof repo
|
||||
`62d7ed1`, which **predates the round-4 gate** (its transcript has no Phase 0).
|
||||
It is genuine and operator-executed, but it is *not* a run of the gate that
|
||||
now ships;
|
||||
* consequently, at the time of writing there was **no recorded run of the
|
||||
current gate by an independent party**. Any transcript below this line that is
|
||||
not explicitly attributed to a named party was produced by the author agent.
|
||||
|
||||
Rule adopted going forward: no text is placed inside a fence in this file unless
|
||||
it was captured with `tee`/`cat` from the real command, and every evidence block
|
||||
states its date, its pin, and who ran it.
|
||||
|
||||
```
|
||||
|
||||
check-selftest: attacking the gates
|
||||
====================================
|
||||
✓ attack 1 rejected (dead-file gate)
|
||||
✓ attack 2 rejected (extra-axiom detection — evil_ax named)
|
||||
✓ attack 3 rejected (missing-oracle detection — exact cone, not subset)
|
||||
✓ attack 4 rejected (existence check — vanished cert cannot pass as 0-axiom)
|
||||
✓ attack 5 rejected (module enumeration — an un-manifested False theorem cannot pass)
|
||||
✓ attack 6 rejected (statement fingerprint — a gutted statement of the same cone cannot pass)
|
||||
✓ attack 7 rejected (Phase 0 model-byte integrity — a hand-edited model cannot compile)
|
||||
✓ attack 8 rejected (manifest fingerprint — a silently-dropped cert cannot pass)
|
||||
|
||||
SELFTEST GREEN: the gate rejects dead files, extra axioms, dropped oracles,
|
||||
vanished certs, un-manifested False theorems, gutted statements, hand-edited
|
||||
models, and deleted manifest rows.
|
||||
```
|
||||
|
||||
## Round-5 hardening — author-agent run, 20260727T205716Z, proof repo @ (this commit)
|
||||
|
||||
Captured with `tee` from the real commands; nothing below was typed by hand.
|
||||
Not independently executed — an independent run of this gate is still outstanding.
|
||||
|
||||
### check.sh
|
||||
```
|
||||
fips205-slhdsa-verified — check
|
||||
===============================
|
||||
=== Phase 0: build hygiene + model/harness integrity ===
|
||||
✓ gen/SlhVerify/Funs.lean
|
||||
✓ gen/SlhVerify/FunsExternal.lean
|
||||
✓ gen/SlhVerify/Types.lean
|
||||
✓ gen/SlhVerify/TypesExternal.lean
|
||||
✓ lean-guard
|
||||
=== Phase 1: compile the extracted model ===
|
||||
· gen/SlhVerify/TypesExternal
|
||||
· gen/SlhVerify/Types
|
||||
· gen/SlhVerify/FunsExternal
|
||||
· gen/SlhVerify/Funs
|
||||
=== Phase 2: compile the proofs ===
|
||||
· ChainSpec
|
||||
· WotsSpec
|
||||
· XmssSpec
|
||||
· HtSpec
|
||||
· ForsInnerSpec
|
||||
· ForsOuterSpec
|
||||
· InputPrepSpec
|
||||
· ApexSpec
|
||||
=== Phase 3: in-Lean audit (cones + statement fingerprints + enumeration) ===
|
||||
✓ exact-cone audit PASSED
|
||||
✓ audit-manifest digest matches (sha256 d83e297a49094c97…)
|
||||
|
||||
ALL GREEN — model compiles, proofs compile, and every certificate cone
|
||||
equals EXACTLY the three kernel axioms plus its documented SHA-2 oracles.
|
||||
Certificates proven: fips205.chain_free_loop_eq fips205.wots_loop1_eq fips205.xmss_loop_eq fips205.ht_loop_eq fips205.fors_inner_loop_eq fips205.fors_outer_loop_eq fips205.to_int_loop_eq fips205.to_byte_loop_eq fips205.wots_csum_loop_eq fips205.base2b_outer_loop_eq fips205.slh_verify_128s_accepts_iff
|
||||
```
|
||||
|
||||
### check-selftest.sh (14 attacks + digest-coverage check)
|
||||
```
|
||||
check-selftest: attacking the gates
|
||||
====================================
|
||||
✓ attack 1 rejected (dead-file gate)
|
||||
✓ attack 2 rejected (extra-axiom detection — evil_ax named)
|
||||
✓ attack 3 rejected (missing-oracle detection — exact cone, not subset)
|
||||
✓ attack 4 rejected (existence check — a vanished cert cannot pass as 0-axiom)
|
||||
✓ attack 5 rejected (enumeration — an un-manifested False theorem cannot pass)
|
||||
✓ attack 6 rejected (statement check — a gutted statement of the same cone cannot pass)
|
||||
✓ attack 7 rejected (Phase 0 model-byte integrity)
|
||||
✓ attack 8 rejected (audit-manifest digest — a silently-dropped cert cannot pass)
|
||||
✓ attack 9 rejected (digest covers allowedBoundary — the policy cannot be widened silently)
|
||||
✓ attack 10 rejected (a specification fold cannot be silently redefined to the loop)
|
||||
✓ attack 11 rejected (enumeration covers every declaration kind, not just theorems)
|
||||
✓ attack 12 rejected (the auditor audits itself — no exemption)
|
||||
✓ attack 13 rejected (Phase 0 pins lean-guard — the harness is in the TCB and bound)
|
||||
✓ attack 14 rejected (no .lean may sit outside gen/ and Proofs/)
|
||||
✓ check 15 passed (the hashed block carries all 12 reference-fold bodies,
|
||||
./check-selftest.sh: line 270: _f: command not found
|
||||
including the recursive companions and their extracted-primitive calls)
|
||||
|
||||
SELFTEST GREEN: 14 attacks rejected + digest-coverage check — dead files, extra axioms, dropped
|
||||
oracles, vanished certs, un-manifested False theorems AND defs, gutted
|
||||
statements, hand-edited models, dropped manifest rows, widened policy,
|
||||
specification folds redefined to the loop, a False-proof in the auditor,
|
||||
a stubbed harness, and stray modules.
|
||||
```
|
||||
|
||||
Note: the `_f: command not found` line in the selftest transcript above is a
|
||||
cosmetic shell-quoting bug in the script's own success message (backticks inside
|
||||
a double-quoted echo), fixed in this same commit. It did not affect any gate.
|
||||
|
|
|
|||
|
|
@ -1,127 +1,277 @@
|
|||
#!/usr/bin/env bash
|
||||
# Adversarial self-test of the check.sh gates (the R3-5 tradition: an audit that
|
||||
# cannot fail is theater). The axiom audit now runs INSIDE Lean
|
||||
# (Proofs/Audit.lean, exact cone per certificate via collectAxioms), so these
|
||||
# attacks target that gate's actual guarantees — not the retired text parser.
|
||||
# Every attack MUST make check.sh fail, via the intended gate:
|
||||
# cannot fail is theater). Every attack MUST make check.sh fail, via the gate it
|
||||
# targets — each assertion names a SPECIFIC diagnostic, so a rejection for an
|
||||
# unrelated reason fails the test too.
|
||||
#
|
||||
# 1. DEAD FILE — a stray Proofs/*.lean not in the manifest.
|
||||
# 2. SMUGGLED AXIOM — a certificate whose real cone contains a disallowed
|
||||
# axiom, declared clean. Exact-equality must report it
|
||||
# as `extra=[...]` (the classic extra-axiom detection).
|
||||
# 3. DROPPED ORACLE — a certificate whose expected cone claims an oracle
|
||||
# its real proof does NOT use. A subset checker would
|
||||
# pass this; exact-equality must report `missing=[...]`.
|
||||
# This is the property the round-2 review demanded and
|
||||
# the retired subset parser could never enforce.
|
||||
# 4. VANISHED CERT — a certificate name that no longer resolves. Since
|
||||
# `collectAxioms` returns [] for a missing name (a
|
||||
# fail-open trap), the audit must report NOT FOUND.
|
||||
# Attacks 1-8 are the round-3/4 set. Attacks 9-14 were authored by external
|
||||
# reviewers and an independent drill, each having DEMONSTRATED the corresponding
|
||||
# fail-open against an earlier gate — they are the reason this round exists:
|
||||
#
|
||||
# Green here means: the gate genuinely rejects all four. Self-cleaning: the real
|
||||
# check.sh / Proofs/Audit.lean are backed up and restored around every attack.
|
||||
set -euo pipefail
|
||||
# 9 widen `allowedBoundary` by one name + a False-proof (round-5 NEW-1:
|
||||
# previously ALL GREEN with the fingerprint BYTE-IDENTICAL)
|
||||
# 10 redefine a reference fold to BE the extracted loop (round-5 NEW-2:
|
||||
# previously ALL GREEN — the certificate degenerates to `loop = loop`)
|
||||
# 11 `def : False` instead of `theorem : False` (drill: the round-4
|
||||
# enumeration matched `.thmInfo` only, so this passed)
|
||||
# 12 a False-proof inside Audit.lean itself (round-5 R1: the
|
||||
# auditor was exempt from its own enumeration)
|
||||
# 13 stub `lean-guard` (round-5 NEW-3:
|
||||
# previously ALL GREEN in 3.6s over destroyed proofs)
|
||||
# 14 a stray .lean beside check.sh (round-5 NEW-4:
|
||||
# LEAN_PATH includes $PWD, so it can join the environment ungated)
|
||||
#
|
||||
# Self-cleaning: every mutated file is backed up and restored, and an EXIT trap
|
||||
# restores even on failure. Run from a clean tree.
|
||||
set -uo pipefail
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
cd "$HERE"
|
||||
source ~/aeneas-toolchain/env.sh
|
||||
|
||||
restore() {
|
||||
[ -f check.sh.selftest.bak ] && mv -f check.sh.selftest.bak check.sh
|
||||
[ -f Proofs/Audit.lean.selftest.bak ] && mv -f Proofs/Audit.lean.selftest.bak Proofs/Audit.lean
|
||||
return 0
|
||||
}
|
||||
BAKS=()
|
||||
save() { cp -p "$1" "$1.sfbak"; BAKS+=("$1"); }
|
||||
restore() { for f in "${BAKS[@]:-}"; do [ -f "$f.sfbak" ] && mv -f "$f.sfbak" "$f"; done; BAKS=(); }
|
||||
cleanup() {
|
||||
restore
|
||||
rm -f Proofs/Stray.lean Proofs/Stray.olean \
|
||||
Proofs/EvilSpec.lean Proofs/EvilSpec.olean Proofs/Audit.olean
|
||||
rm -f Proofs/Stray.lean Proofs/EvilSpec.lean Evil.lean \
|
||||
Proofs/*.olean gen/SlhVerify/*.olean .audit-manifest.observed 2>/dev/null
|
||||
return 0
|
||||
}
|
||||
trap cleanup EXIT
|
||||
backup() { cp -f check.sh check.sh.selftest.bak; cp -f Proofs/Audit.lean Proofs/Audit.lean.selftest.bak; }
|
||||
|
||||
fail() { echo "✗ $1"; shift; [ $# -gt 0 ] && sed 's/^/ /' "$1"; exit 1; }
|
||||
|
||||
echo "check-selftest: attacking the gates"
|
||||
echo "===================================="
|
||||
|
||||
# ── Attack 1: dead file ─────────────────────────────────────────────────────
|
||||
# ── 1: dead file ────────────────────────────────────────────────────────────
|
||||
echo "-- stray" > Proofs/Stray.lean
|
||||
if ./check.sh > /tmp/selftest-dead.out 2>&1; then
|
||||
echo "✗ ATTACK 1 SUCCEEDED: check.sh stayed green with a dead file"; exit 1
|
||||
fi
|
||||
grep -q "DEAD FILE" /tmp/selftest-dead.out \
|
||||
|| { echo "✗ ATTACK 1: failed, but not via the dead-file gate"; cat /tmp/selftest-dead.out; exit 1; }
|
||||
rm -f Proofs/Stray.lean Proofs/Stray.olean
|
||||
echo "✓ attack 1 rejected (dead-file gate works)"
|
||||
./check.sh > /tmp/sf1.out 2>&1 && fail "ATTACK 1 SUCCEEDED (dead file stayed green)" /tmp/sf1.out
|
||||
grep -q "DEAD FILE" /tmp/sf1.out || fail "ATTACK 1: failed, not via the dead-file gate" /tmp/sf1.out
|
||||
rm -f Proofs/Stray.lean
|
||||
echo "✓ attack 1 rejected (dead-file gate)"
|
||||
|
||||
# ── Attack 2: smuggled disallowed axiom in a real cone ──────────────────────
|
||||
# A new certificate whose cone genuinely contains `evil_ax`, declared as clean
|
||||
# (kernel-3) in the expected table. Exact-equality must flag extra=[evil_ax].
|
||||
backup
|
||||
# ── 2: smuggled disallowed axiom in a real cone ─────────────────────────────
|
||||
save check.sh; save Proofs/Audit.lean
|
||||
# NB: no imports — Phase 0 now purges every .olean, so a module injected at the
|
||||
# head of the build order cannot import one that has not been compiled yet.
|
||||
cat > Proofs/EvilSpec.lean <<'EOF'
|
||||
import Proofs.ChainSpec
|
||||
axiom evil_ax : True
|
||||
theorem evil_thm : True := evil_ax
|
||||
EOF
|
||||
python3 - <<'PY'
|
||||
import re
|
||||
# check.sh: add EvilSpec to PROOFS so Phase 2 builds it and the dead-file gate
|
||||
# passes (inject right after the array's opening paren — no hard-coded contents).
|
||||
s = open("check.sh").read()
|
||||
assert 'PROOFS=(\n' in s, "check.sh PROOFS array shape changed"
|
||||
s = s.replace('PROOFS=(\n', 'PROOFS=(\n "EvilSpec"\n', 1)
|
||||
open("check.sh","w").write(s)
|
||||
# Audit.lean: import EvilSpec and claim evil_thm is kernel-3 clean.
|
||||
assert 'PROOFS=(\n' in s, "check.sh PROOFS shape changed"
|
||||
open("check.sh","w").write(s.replace('PROOFS=(\n', 'PROOFS=(\n "EvilSpec"\n', 1))
|
||||
a = open("Proofs/Audit.lean").read()
|
||||
assert 'import Proofs.ApexSpec' in a, "Audit.lean import shape changed"
|
||||
assert 'import Proofs.ApexSpec' in a and ' [ (`fips205.chain_free_loop_eq' in a, "Audit.lean shape changed"
|
||||
a = a.replace('import Proofs.ApexSpec', 'import Proofs.ApexSpec\nimport Proofs.EvilSpec', 1)
|
||||
assert 'def expectedCones : List (Name × List Name) :=' in a and ' [ (' in a, "Audit.lean table shape changed"
|
||||
a = a.replace(' [ (', ' [ (`evil_thm, kernel3),\n (', 1)
|
||||
a = a.replace(' [ (`fips205.chain_free_loop_eq', ' [ (`evil_thm, kernel3, 0),\n (`fips205.chain_free_loop_eq', 1)
|
||||
open("Proofs/Audit.lean","w").write(a)
|
||||
PY
|
||||
if ./check.sh > /tmp/selftest-evil.out 2>&1; then
|
||||
echo "✗ ATTACK 2 SUCCEEDED: audit passed a smuggled disallowed axiom"; exit 1
|
||||
fi
|
||||
grep -q "AUDIT FAILED" /tmp/selftest-evil.out \
|
||||
|| { echo "✗ ATTACK 2: failed, but not via the axiom audit"; cat /tmp/selftest-evil.out; exit 1; }
|
||||
grep -q "evil_ax" /tmp/selftest-evil.out \
|
||||
|| { echo "✗ ATTACK 2: rejected, but the audit did not name the smuggled axiom"; cat /tmp/selftest-evil.out; exit 1; }
|
||||
restore; rm -f Proofs/EvilSpec.lean Proofs/EvilSpec.olean Proofs/Audit.olean
|
||||
echo "✓ attack 2 rejected (extra-axiom detection works — evil_ax named)"
|
||||
./check.sh > /tmp/sf2.out 2>&1 && fail "ATTACK 2 SUCCEEDED (smuggled axiom)" /tmp/sf2.out
|
||||
grep -q "evil_ax" /tmp/sf2.out || fail "ATTACK 2: rejected but evil_ax not named" /tmp/sf2.out
|
||||
restore; rm -f Proofs/EvilSpec.lean
|
||||
echo "✓ attack 2 rejected (extra-axiom detection — evil_ax named)"
|
||||
|
||||
# ── Attack 3: dropped-oracle (subset would pass; exact must not) ─────────────
|
||||
# Claim to_int_loop_eq depends on oracle.f. Its real cone is kernel-3 only, so
|
||||
# the audit must report missing=[verify_mono.oracle.f].
|
||||
backup
|
||||
# ── 3: dropped oracle (a subset check would pass; exact must not) ────────────
|
||||
save Proofs/Audit.lean
|
||||
python3 - <<'PY'
|
||||
import re
|
||||
a = open("Proofs/Audit.lean").read()
|
||||
new, n = re.subn(r'(`fips205\.to_int_loop_eq,\s*)kernel3\)', r'\1kernel3 ++ [oracleF])', a)
|
||||
assert n == 1, f"expected exactly one to_int table entry, patched {n}"
|
||||
new, n = re.subn(r'(`fips205\.to_int_loop_eq,\s*)kernel3,', r'\1kernel3 ++ [oracleF],', a)
|
||||
assert n == 1, f"expected 1 to_int row, patched {n}"
|
||||
open("Proofs/Audit.lean","w").write(new)
|
||||
PY
|
||||
if ./check.sh > /tmp/selftest-drop.out 2>&1; then
|
||||
echo "✗ ATTACK 3 SUCCEEDED: audit passed a certificate missing a claimed oracle (subset hole!)"; exit 1
|
||||
fi
|
||||
grep -q "AUDIT FAILED" /tmp/selftest-drop.out \
|
||||
|| { echo "✗ ATTACK 3: failed, but not via the axiom audit"; cat /tmp/selftest-drop.out; exit 1; }
|
||||
grep -q "missing=\[verify_mono.oracle.f\]" /tmp/selftest-drop.out \
|
||||
|| { echo "✗ ATTACK 3: rejected, but not by naming the missing oracle (exact-cone not enforced?)"; cat /tmp/selftest-drop.out; exit 1; }
|
||||
restore; rm -f Proofs/Audit.olean
|
||||
echo "✓ attack 3 rejected (missing-oracle detection works — exact cone enforced, not subset)"
|
||||
./check.sh > /tmp/sf3.out 2>&1 && fail "ATTACK 3 SUCCEEDED (dropped oracle — subset hole)" /tmp/sf3.out
|
||||
grep -q "missing=\[verify_mono.oracle.f\]" /tmp/sf3.out || fail "ATTACK 3: rejected but missing oracle not named" /tmp/sf3.out
|
||||
restore
|
||||
echo "✓ attack 3 rejected (missing-oracle detection — exact cone, not subset)"
|
||||
|
||||
# ── Attack 4: vanished certificate (collectAxioms-returns-[] trap) ──────────
|
||||
backup
|
||||
# ── 4: vanished certificate ─────────────────────────────────────────────────
|
||||
save Proofs/Audit.lean
|
||||
python3 - <<'PY'
|
||||
a = open("Proofs/Audit.lean").read()
|
||||
assert a.count('`fips205.chain_free_loop_eq') >= 1
|
||||
a = a.replace('`fips205.chain_free_loop_eq,', '`fips205.chain_free_loop_eq_VANISHED,', 1)
|
||||
open("Proofs/Audit.lean","w").write(a)
|
||||
assert a.count('`fips205.chain_free_loop_eq,') >= 1
|
||||
open("Proofs/Audit.lean","w").write(a.replace('`fips205.chain_free_loop_eq,', '`fips205.chain_free_loop_eq_VANISHED,', 1))
|
||||
PY
|
||||
if ./check.sh > /tmp/selftest-vanish.out 2>&1; then
|
||||
echo "✗ ATTACK 4 SUCCEEDED: audit stayed green for a non-existent certificate (fail-open!)"; exit 1
|
||||
fi
|
||||
grep -q "NOT FOUND" /tmp/selftest-vanish.out \
|
||||
|| { echo "✗ ATTACK 4: failed, but not via the existence check"; cat /tmp/selftest-vanish.out; exit 1; }
|
||||
restore; rm -f Proofs/Audit.olean
|
||||
echo "✓ attack 4 rejected (existence check works — a vanished cert cannot pass as 0-axiom)"
|
||||
./check.sh > /tmp/sf4.out 2>&1 && fail "ATTACK 4 SUCCEEDED (vanished cert)" /tmp/sf4.out
|
||||
grep -q "NOT FOUND" /tmp/sf4.out || fail "ATTACK 4: rejected but not via the existence check" /tmp/sf4.out
|
||||
restore
|
||||
echo "✓ attack 4 rejected (existence check — a vanished cert cannot pass as 0-axiom)"
|
||||
|
||||
# ── 5: un-manifested THEOREM proving False (round-4 F1) ─────────────────────
|
||||
save Proofs/ChainSpec.lean
|
||||
printf '\n-- SELFTEST ATTACK 5\naxiom cheat5 : ∀ (P : Prop), P\ntheorem repo_proves_false : False := cheat5 _\n' >> Proofs/ChainSpec.lean
|
||||
./check.sh > /tmp/sf5.out 2>&1 && fail "ATTACK 5 SUCCEEDED: check.sh GREEN over a repo proving False!" /tmp/sf5.out
|
||||
grep -qE "repo_proves_false|AXIOM DECLARED" /tmp/sf5.out || fail "ATTACK 5: rejected but not via the enumeration" /tmp/sf5.out
|
||||
restore
|
||||
echo "✓ attack 5 rejected (enumeration — an un-manifested False theorem cannot pass)"
|
||||
|
||||
# ── 6: gutted STATEMENT, cone preserved (round-4 F2) ────────────────────────
|
||||
save Proofs/InputPrepSpec.lean
|
||||
python3 - <<'PY'
|
||||
s = open("Proofs/InputPrepSpec.lean").read()
|
||||
i = s.index("theorem to_byte_loop_eq (n : Std.U32) (k : Nat) :") # a LEAF cert
|
||||
j = s.index("theorem hbody_cs", i) # next declaration
|
||||
open("Proofs/InputPrepSpec.lean","w").write(
|
||||
s[:i] + "theorem to_byte_loop_eq : (∀ p : Prop, p ∨ ¬p) := Classical.em\n\n" + s[j:])
|
||||
PY
|
||||
./check.sh > /tmp/sf6.out 2>&1 && fail "ATTACK 6 SUCCEEDED (gutted statement, cone preserved)" /tmp/sf6.out
|
||||
grep -q "STATEMENT fingerprint" /tmp/sf6.out || fail "ATTACK 6: rejected but not via the statement check" /tmp/sf6.out
|
||||
restore
|
||||
echo "✓ attack 6 rejected (statement check — a gutted statement of the same cone cannot pass)"
|
||||
|
||||
# ── 7: hand-edited model file (round-4 F3) ──────────────────────────────────
|
||||
save gen/SlhVerify/Funs.lean
|
||||
printf '\n-- SELFTEST ATTACK 7\n' >> gen/SlhVerify/Funs.lean
|
||||
./check.sh > /tmp/sf7.out 2>&1 && fail "ATTACK 7 SUCCEEDED (hand-edited model passed)" /tmp/sf7.out
|
||||
grep -q "INTEGRITY FAILED" /tmp/sf7.out || fail "ATTACK 7: rejected but not via Phase 0" /tmp/sf7.out
|
||||
restore
|
||||
echo "✓ attack 7 rejected (Phase 0 model-byte integrity)"
|
||||
|
||||
# ── 8: deleted manifest row (round-4 F1, set half) ──────────────────────────
|
||||
save Proofs/Audit.lean
|
||||
python3 - <<'PY'
|
||||
import re
|
||||
a = open("Proofs/Audit.lean").read()
|
||||
new, n = re.subn(r'\n\s*\(`fips205\.to_int_loop_eq,.*?\),', '', a)
|
||||
assert n == 1, f"expected 1 row, removed {n}"
|
||||
open("Proofs/Audit.lean","w").write(new)
|
||||
PY
|
||||
./check.sh > /tmp/sf8.out 2>&1 && fail "ATTACK 8 SUCCEEDED (a dropped cert row passed)" /tmp/sf8.out
|
||||
grep -q "digest mismatch" /tmp/sf8.out || fail "ATTACK 8: rejected but not via the digest binding" /tmp/sf8.out
|
||||
restore
|
||||
echo "✓ attack 8 rejected (audit-manifest digest — a silently-dropped cert cannot pass)"
|
||||
|
||||
# ── 9: WIDEN THE POLICY (round-5 NEW-1) ─────────────────────────────────────
|
||||
# Previously ALL GREEN with the committed fingerprint byte-identical: the
|
||||
# fingerprint covered `manifest` but never `allowedBoundary`, the very predicate
|
||||
# the enumeration tests against.
|
||||
# Widen the policy ALONE — no axiom is declared anywhere, so the enumeration
|
||||
# (which now also rejects a bare `axiom` in an audited module) cannot fire and
|
||||
# the DIGEST must be what bites. `sorryAx` is used as the smuggled name because
|
||||
# admitting it would silently legalise every `sorry` in the repository.
|
||||
save Proofs/Audit.lean
|
||||
python3 - <<'PY'
|
||||
a = open("Proofs/Audit.lean").read()
|
||||
old = " kernel3 ++ [oracleF, oracleH, oracleTL, oracleTLen, oracleHMsg]\n"
|
||||
assert a.count(old) == 1, "allowedBoundary shape changed"
|
||||
open("Proofs/Audit.lean","w").write(a.replace(old, old.rstrip("\n") + " ++ [`sorryAx]\n", 1))
|
||||
PY
|
||||
./check.sh > /tmp/sf9.out 2>&1 && fail "ATTACK 9 SUCCEEDED: the axiom policy was widened and the button stayed GREEN!" /tmp/sf9.out
|
||||
grep -q "digest mismatch" /tmp/sf9.out || fail "ATTACK 9: rejected but not via the policy-covering digest" /tmp/sf9.out
|
||||
restore
|
||||
echo "✓ attack 9 rejected (digest covers allowedBoundary — the policy cannot be widened silently)"
|
||||
|
||||
# ── 10: REDEFINE A SPEC FOLD TO BE THE LOOP (round-5 NEW-2) ─────────────────
|
||||
# The certificate keeps its exact statement, cone and type-hash, but becomes
|
||||
# `loop = loop` — vacuous. Previously ALL GREEN.
|
||||
save Proofs/ChainSpec.lean
|
||||
python3 - <<'PY'
|
||||
s = open("Proofs/ChainSpec.lean").read()
|
||||
i = s.index("noncomputable def chainFoldN")
|
||||
j = s.index("/-- One full loop step", i)
|
||||
gut = """noncomputable def chainFoldN {N : Std.Usize} (pk_seed : Slice Std.U8) :
|
||||
types.Adrs → Array Std.U8 N → Std.U32 → Nat → Result (Array Std.U8 N) :=
|
||||
fun adrs tmp start s =>
|
||||
verify_mono.chain_free_loop
|
||||
{ start := start,
|
||||
«end» := Std.U32.ofNatCore ((start.val + s) % 2 ^ 32) (Nat.mod_lt _ (by norm_num)) }
|
||||
pk_seed adrs tmp
|
||||
|
||||
"""
|
||||
open("Proofs/ChainSpec.lean","w").write(s[:i] + gut + s[j:])
|
||||
PY
|
||||
./check.sh > /tmp/sf10.out 2>&1 && fail "ATTACK 10 SUCCEEDED: the spec fold IS the loop, certificate is vacuous, still GREEN!" /tmp/sf10.out
|
||||
# Two layers stand here, and either is a valid rejection: the existing proof no
|
||||
# longer matches the redefined fold (Phase 2), and — if an attacker repairs the
|
||||
# proof, as the round-5 reviewer did — the digest covers specification BODIES,
|
||||
# so it moves. Attack 9 is the pure test that the digest binding fires; that the
|
||||
# digest's input contains the fold bodies is verified directly (see below).
|
||||
grep -qE "digest mismatch|FAIL: Proofs/ChainSpec" /tmp/sf10.out \
|
||||
|| fail "ATTACK 10: rejected, but neither via the digest nor a proof break" /tmp/sf10.out
|
||||
restore
|
||||
echo "✓ attack 10 rejected (a specification fold cannot be silently redefined to the loop)"
|
||||
|
||||
# ── 11: `def : False` rather than `theorem : False` (drill finding) ─────────
|
||||
save Proofs/WotsSpec.lean
|
||||
printf '\n-- SELFTEST ATTACK 11\naxiom cheat11 : ∀ (P : Prop), P\ndef attack11_false : False := cheat11 _\n' >> Proofs/WotsSpec.lean
|
||||
./check.sh > /tmp/sf11.out 2>&1 && fail "ATTACK 11 SUCCEEDED: a def proving False passed!" /tmp/sf11.out
|
||||
grep -qE "attack11_false|AXIOM DECLARED" /tmp/sf11.out || fail "ATTACK 11: rejected but not via the all-kinds enumeration" /tmp/sf11.out
|
||||
restore
|
||||
echo "✓ attack 11 rejected (enumeration covers every declaration kind, not just theorems)"
|
||||
|
||||
# ── 12: a False-proof inside the AUDITOR itself (round-5 R1) ────────────────
|
||||
save Proofs/Audit.lean
|
||||
python3 - <<'PY'
|
||||
a = open("Proofs/Audit.lean").read()
|
||||
i = a.index("elab \"auditCones\"")
|
||||
open("Proofs/Audit.lean","w").write(
|
||||
a[:i] + "axiom cheat12 : ∀ (P : Prop), P\ntheorem audit_proves_false : False := cheat12 _\n\n" + a[i:])
|
||||
PY
|
||||
./check.sh > /tmp/sf12.out 2>&1 && fail "ATTACK 12 SUCCEEDED: the auditor itself proves False, still GREEN!" /tmp/sf12.out
|
||||
grep -qE "audit_proves_false|AXIOM DECLARED" /tmp/sf12.out || fail "ATTACK 12: rejected but not via self-enumeration" /tmp/sf12.out
|
||||
restore
|
||||
echo "✓ attack 12 rejected (the auditor audits itself — no exemption)"
|
||||
|
||||
# ── 13: stub the compiler harness (round-5 NEW-3) ──────────────────────────
|
||||
# Previously: ALL GREEN in 3.6s with the proofs destroyed. lean-guard is KEPT
|
||||
# (it is this machine's memory cap) and sha256-pinned instead.
|
||||
save lean-guard
|
||||
cat > lean-guard <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
echo "exact-cone audit PASSED"
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x lean-guard
|
||||
./check.sh > /tmp/sf13.out 2>&1 && fail "ATTACK 13 SUCCEEDED: a stubbed harness passed!" /tmp/sf13.out
|
||||
grep -q "INTEGRITY FAILED" /tmp/sf13.out || fail "ATTACK 13: rejected but not via the harness pin" /tmp/sf13.out
|
||||
restore
|
||||
echo "✓ attack 13 rejected (Phase 0 pins lean-guard — the harness is in the TCB and bound)"
|
||||
|
||||
# ── 14: stray .lean beside check.sh (round-5 NEW-4) ────────────────────────
|
||||
cat > Evil.lean <<'EOF'
|
||||
axiom cheat14 : ∀ (P : Prop), P
|
||||
theorem evil14 : False := cheat14 _
|
||||
EOF
|
||||
./check.sh > /tmp/sf14.out 2>&1 && fail "ATTACK 14 SUCCEEDED: a stray Lean module passed!" /tmp/sf14.out
|
||||
grep -q "BUILD HYGIENE FAILED" /tmp/sf14.out || fail "ATTACK 14: rejected but not via the hygiene gate" /tmp/sf14.out
|
||||
rm -f Evil.lean
|
||||
echo "✓ attack 14 rejected (no .lean may sit outside gen/ and Proofs/)"
|
||||
|
||||
# ── 15: COVERAGE OF THE DIGEST INPUT (direct, not an attack) ───────────────
|
||||
# Attack 9 proves the digest binding fires. This proves WHAT it covers: the
|
||||
# hashed block must literally contain each reference fold's definition BODY, so
|
||||
# that any change to one necessarily moves the SHA-256 (round-5 NEW-2).
|
||||
./check.sh > /tmp/sf15.out 2>&1 || fail "ATTACK 15 setup: clean tree is not green" /tmp/sf15.out
|
||||
lake_out=$(cd "$AENEAS_HOME/backends/lean" 2>/dev/null && lake env bash -c \
|
||||
"cd '$HERE' && export LEAN_PATH=\"\$LEAN_PATH:\$PWD/gen:\$PWD\" && '$HERE/lean-guard' 'Proofs/Audit.lean'" 2>&1)
|
||||
BLOCK=$(awk '/AUDIT-MANIFEST-BEGIN/{f=1;next} /AUDIT-MANIFEST-END/{f=0} f' <<<"$lake_out")
|
||||
[ -n "$BLOCK" ] || { echo "✗ ATTACK 15: no audit block"; exit 1; }
|
||||
for fold in chainFoldN wotsChainFold xmssFoldN htFoldN forsInnerFold forsOuterFold \
|
||||
toIntFold toByteFold wotsCsumFold base2bOuterFold slhVerifyRoot htVerifyRoot; do
|
||||
grep -q "spec|fips205.$fold|def|value=" <<<"$BLOCK" \
|
||||
|| { echo "✗ CHECK 15: the digest input does NOT carry the body of $fold"; exit 1; }
|
||||
done
|
||||
# Lean's equation compiler splits a recursive definition: `chainFoldN` is a thin
|
||||
# wrapper and the actual recursion lives in `chainFoldN._f`. BOTH are reached by
|
||||
# the closure and printed, so assert the SEMANTIC content specifically — the
|
||||
# extracted primitives a fold must call — rather than assuming which line holds
|
||||
# it. (An earlier revision of this check asserted the body text was on the
|
||||
# wrapper's line and failed while coverage was in fact correct.)
|
||||
for probe in "fips205.chainFoldN._f|def|value=.*set_hash_address" \
|
||||
"fips205.xmssFoldN._f|def|value=.*verify_mono.oracle.h" \
|
||||
"fips205.slhVerifyRoot|def|value=.*verify_mono.oracle.h_msg"; do
|
||||
grep -qE "spec\|$probe" <<<"$BLOCK" \
|
||||
|| { echo "✗ CHECK 15: the digest input is missing expected body content: $probe"; exit 1; }
|
||||
done
|
||||
echo "✓ check 15 passed (the hashed block carries all 12 reference-fold bodies,"
|
||||
echo ' including the recursive _f companions and their extracted-primitive calls)'
|
||||
|
||||
echo
|
||||
echo "SELFTEST GREEN: the audit genuinely rejects extra axioms, dropped oracles,"
|
||||
echo "vanished certificates, and dead proof files."
|
||||
echo "SELFTEST GREEN: 14 attacks rejected + digest-coverage check — dead files, extra axioms, dropped"
|
||||
echo "oracles, vanished certs, un-manifested False theorems AND defs, gutted"
|
||||
echo "statements, hand-edited models, dropped manifest rows, widened policy,"
|
||||
echo "specification folds redefined to the loop, a False-proof in the auditor,"
|
||||
echo "a stubbed harness, and stray modules."
|
||||
|
|
|
|||
|
|
@ -3,14 +3,23 @@
|
|||
# Green output == the full claim. This script is the ONLY source of the
|
||||
# word "proven" for this repo.
|
||||
#
|
||||
# Phase 0 — build hygiene + integrity: purge stale .olean (the verdict must
|
||||
# depend on committed bytes, not untracked build state), forbid any
|
||||
# .lean outside gen/ and Proofs/, and sha256-pin the four model files
|
||||
# AND the compiler harness `lean-guard` to PROVENANCE.json.
|
||||
# Phase 1 — compile the extracted Lean model (gen/SlhVerify).
|
||||
# Phase 2 — compile the proof files (Proofs/).
|
||||
# Phase 3 — axiom audit, performed INSIDE Lean (Proofs/Audit.lean): each
|
||||
# certificate's cone, read from the kernel via `collectAxioms`, must
|
||||
# EQUAL its expected set EXACTLY — kernel-3 plus only the named SHA-2
|
||||
# oracles. No text parsing (round-2 review closed that class of bug);
|
||||
# any extra, any missing, a renamed/deleted cert, or an axiom/opaque
|
||||
# sham is a Lean elaboration error → non-zero exit → fail-closed.
|
||||
# Phase 3 — the in-Lean audit (Proofs/Audit.lean): per certificate, the cone
|
||||
# (via `collectAxioms`) must EQUAL its expected set exactly; EVERY
|
||||
# declaration kind in the eight cert modules and in Audit.lean itself
|
||||
# must stay within the axiom boundary; and this script binds to the
|
||||
# SHA-256 of the canonical AUDIT-MANIFEST block, which covers the
|
||||
# POLICY constants, every certificate STATEMENT, and every reachable
|
||||
# SPECIFICATION DEFINITION BODY. Any mismatch → non-zero exit →
|
||||
# fail-closed. No text parsing of axiom cones.
|
||||
#
|
||||
# What this button does NOT bind is stated in TRUSTED-BASE.md item 11: this
|
||||
# script itself, the toolchain env, $AENEAS_HOME, and the Lean toolchain.
|
||||
set -euo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
|
@ -36,25 +45,48 @@ PROOFS=(
|
|||
"InputPrepSpec"
|
||||
"ApexSpec"
|
||||
)
|
||||
# Certificates whose axiom cones are audited, and the allowed extras beyond
|
||||
# the three kernel axioms: the five SHA-2 verify-path oracles. A certificate
|
||||
# is listed here only once it is genuinely proven.
|
||||
CERTS=(
|
||||
"fips205.chain_free_loop_eq"
|
||||
"fips205.wots_loop1_eq"
|
||||
"fips205.xmss_loop_eq"
|
||||
"fips205.ht_loop_eq"
|
||||
"fips205.fors_inner_loop_eq"
|
||||
"fips205.fors_outer_loop_eq"
|
||||
"fips205.to_int_loop_eq"
|
||||
"fips205.to_byte_loop_eq"
|
||||
"fips205.wots_csum_loop_eq"
|
||||
"fips205.base2b_outer_loop_eq"
|
||||
"fips205.slh_verify_128s_accepts_iff"
|
||||
)
|
||||
echo "fips205-slhdsa-verified — check"
|
||||
echo "==============================="
|
||||
|
||||
# ── Phase 0: build hygiene + model & harness integrity ───────────────────────
|
||||
echo "=== Phase 0: build hygiene + model/harness integrity ==="
|
||||
# (a) Purge every .olean first. Round-5 NEW-4: the button's verdict must depend
|
||||
# on COMMITTED BYTES, never on untracked build state — a stale .olean from a
|
||||
# module that no longer exists (and *.olean is .gitignored, so invisible to
|
||||
# `git status`) could otherwise satisfy an import and go green.
|
||||
find "$HERE/gen" "$HERE/Proofs" -name '*.olean' -delete 2>/dev/null || true
|
||||
# (b) No Lean source may sit outside gen/ and Proofs/. LEAN_PATH includes $PWD,
|
||||
# so a stray verification/*.lean can join the environment ungated (NEW-4).
|
||||
STRAY=$(find "$HERE" -maxdepth 1 -name '*.lean' -printf '%f\n' 2>/dev/null || true)
|
||||
if [ -n "$STRAY" ]; then
|
||||
echo "$STRAY" | sed 's/^/ ✗ stray Lean source outside gen\/ and Proofs\/: /'
|
||||
echo "BUILD HYGIENE FAILED (a .lean outside the audited directories can join LEAN_PATH)"; exit 1
|
||||
fi
|
||||
# (c) sha256-pin the extracted model AND the compiler harness. lean-guard is
|
||||
# repo-tracked and is shelled out to for every compile, so it is part of the
|
||||
# trusted computing base: round 5 demonstrated that stubbing it alone yields
|
||||
# ALL GREEN in 3.6s over destroyed proofs. It is KEPT (it is the memory cap
|
||||
# that protects this machine after the 12.2GB OOM incident) and pinned.
|
||||
python3 - "$HERE/PROVENANCE.json" "$HERE" <<'PY' || { echo "INTEGRITY FAILED (a pinned file differs from PROVENANCE.json — hand-edited model or harness?)"; exit 1; }
|
||||
import json, sys, hashlib, os
|
||||
prov = json.load(open(sys.argv[1])); here = sys.argv[2]
|
||||
files = {k: v for k, v in prov.get("model_integrity_sha256", {}).items() if not k.startswith("_")}
|
||||
files.update({k: v for k, v in prov.get("harness_integrity_sha256", {}).items() if not k.startswith("_")})
|
||||
if not files:
|
||||
print(" no integrity map in PROVENANCE.json (fail-closed)"); sys.exit(1)
|
||||
bad = 0
|
||||
for rel, want in sorted(files.items()):
|
||||
p = os.path.join(here, rel)
|
||||
if not os.path.exists(p):
|
||||
print(f" ✗ {rel} MISSING"); bad = 1; continue
|
||||
got = hashlib.sha256(open(p, 'rb').read()).hexdigest()
|
||||
if got != want:
|
||||
print(f" ✗ {rel}: sha256 {got[:12]} ≠ pinned {want[:12]}"); bad = 1
|
||||
else:
|
||||
print(f" ✓ {rel}")
|
||||
sys.exit(1 if bad else 0)
|
||||
PY
|
||||
|
||||
# ── Phase 1: model ──────────────────────────────────────────────────────────
|
||||
echo "=== Phase 1: compile the extracted model ==="
|
||||
cd "$AENEAS_LEAN"
|
||||
|
|
@ -80,24 +112,49 @@ lake env bash -c "
|
|||
done
|
||||
"
|
||||
|
||||
# ── Phase 3: axiom audit (exact cone per certificate, inside Lean) ───────────
|
||||
echo "=== Phase 3: axiom audit (exact cone per certificate — inside Lean) ==="
|
||||
# ── Phase 3: in-Lean audit (cones + statements + full-module enumeration) ────
|
||||
echo "=== Phase 3: in-Lean audit (cones + statement fingerprints + enumeration) ==="
|
||||
cd "$AENEAS_LEAN"
|
||||
# Proofs/Audit.lean reads each cert's cone from the kernel (collectAxioms) and
|
||||
# asserts SET EQUALITY against its expected boundary. Compiling it IS the audit:
|
||||
# any mismatch throws → non-zero exit. We additionally require the explicit
|
||||
# PASSED line, so a build that somehow exits 0 without running the audit still
|
||||
# fails closed.
|
||||
# THE BINDING DIGEST. Audit.lean emits a canonical AUDIT-MANIFEST block holding
|
||||
# the POLICY constants (allowedBoundary, certModules — round-5 NEW-1), every
|
||||
# certificate's fully-elaborated STATEMENT, and every reachable SPECIFICATION
|
||||
# definition's fully-elaborated BODY (round-5 NEW-2: redefining a reference fold
|
||||
# to *be* the extracted loop previously left every fingerprint intact). We bind
|
||||
# to the SHA-256 of that block, retiring the 32-bit Expr.hash as the load-bearing
|
||||
# digest (NEW-5). To rotate deliberately: run check.sh, take the printed OBSERVED
|
||||
# digest, and update this constant in the same reviewable commit.
|
||||
EXPECTED_AUDIT_SHA256="d83e297a49094c970b88ce7c63ceb85d6bee0764d4623456a7225860e2298afa"
|
||||
AUD_OUT=$(lake env bash -c "cd '$HERE' && export LEAN_PATH=\"\$LEAN_PATH:\$PWD/gen:\$PWD\" && LEAN_TIMEOUT=$TIMEOUT LEAN_MEM_MB=$MEM '$HERE/lean-guard' 'Proofs/Audit.lean'" 2>&1) || {
|
||||
echo "$AUD_OUT" | sed 's/^/ /'
|
||||
echo "AXIOM AUDIT FAILED (Audit.lean did not compile — cone mismatch, missing cert, or sham)"; exit 1; }
|
||||
echo "AUDIT FAILED (Audit.lean did not compile — cone/statement mismatch, missing cert, sham, or un-audited declaration)"; exit 1; }
|
||||
if ! grep -qF "exact-cone audit PASSED" <<<"$AUD_OUT"; then
|
||||
echo "$AUD_OUT" | sed 's/^/ /'
|
||||
echo "AXIOM AUDIT FAILED (no PASSED line — fail-closed)"; exit 1
|
||||
echo "AUDIT FAILED (no PASSED line — fail-closed)"; exit 1
|
||||
fi
|
||||
echo " ✓ exact-cone audit PASSED: each of the ${#CERTS[@]} certificate cones == its expected boundary set"
|
||||
BLOCK=$(awk '/AUDIT-MANIFEST-BEGIN/{f=1;next} /AUDIT-MANIFEST-END/{f=0} f' <<<"$AUD_OUT")
|
||||
if [ -z "$BLOCK" ]; then
|
||||
echo "$AUD_OUT" | sed 's/^/ /'
|
||||
echo "AUDIT FAILED (no AUDIT-MANIFEST block — fail-closed)"; exit 1
|
||||
fi
|
||||
GOT_SHA=$(printf '%s\n' "$BLOCK" | sha256sum | cut -d' ' -f1)
|
||||
if [ "$GOT_SHA" != "$EXPECTED_AUDIT_SHA256" ]; then
|
||||
printf '%s\n' "$BLOCK" > "$HERE/.audit-manifest.observed"
|
||||
echo "AUDIT FAILED — audit-manifest digest mismatch."
|
||||
echo " expected: $EXPECTED_AUDIT_SHA256"
|
||||
echo " observed: $GOT_SHA"
|
||||
echo " A policy constant, a certificate statement, or a specification"
|
||||
echo " definition changed without a reviewed rotation. The observed block was"
|
||||
echo " written to verification/.audit-manifest.observed — diff it to see what."
|
||||
exit 1
|
||||
fi
|
||||
echo " ✓ $(grep -oF 'exact-cone audit PASSED' <<<"$AUD_OUT" | head -1)"
|
||||
echo " ✓ audit-manifest digest matches (sha256 ${EXPECTED_AUDIT_SHA256:0:16}…)"
|
||||
|
||||
echo
|
||||
echo "ALL GREEN — model compiles, proofs compile, and every certificate cone"
|
||||
echo "equals EXACTLY the three kernel axioms plus its documented SHA-2 oracles."
|
||||
echo "Certificates proven: ${CERTS[*]}"
|
||||
# The list comes from the AUDITED manifest itself, never from a hand-kept array:
|
||||
# a display list nothing binds can name a certificate that does not exist.
|
||||
CERT_LINE=$(sed -n 's/.*CERTIFICATES: //p' <<<"$AUD_OUT" | head -1)
|
||||
[ -n "$CERT_LINE" ] || { echo "AUDIT FAILED (no CERTIFICATES line — fail-closed)"; exit 1; }
|
||||
echo "Certificates proven: $CERT_LINE"
|
||||
|
|
|
|||
|
|
@ -13,8 +13,16 @@
|
|||
· verify_mono.oracle.h_msg — H_msg (message digest)
|
||||
These are SHA-256-based; their correctness against FIPS 180-4 is the
|
||||
standing hash-oracle boundary (see TRUSTED-BASE.md). The apex
|
||||
certificate will carry EXACTLY these five beyond Lean's three kernel
|
||||
certificate carries EXACTLY these five beyond Lean's three kernel
|
||||
axioms — nothing else.
|
||||
NOTE, so a future reader is not misled: these are five AXIOMS but only
|
||||
FOUR distinct Rust primitives. `oracle.t_l` and `oracle.t_len` both
|
||||
delegate to `crate::hashers::sha2_cat_1::t_l` (src/verify_mono.rs) —
|
||||
modelling them as two INDEPENDENT axioms is deliberately conservative
|
||||
(a theorem proved for unrelated oracles also holds when they coincide),
|
||||
but the model cannot express that they agree. Note also the naming
|
||||
inversion against FIPS 205: `oracle.t_l` models T_len (WOTS+ pk
|
||||
compression) and `oracle.t_len` models T_k (FORS root compression).
|
||||
|
||||
(2) TRANSPILER PLUMBING — core-library externals Aeneas emits for this
|
||||
extraction config. These carry NO cryptographic content. The u32
|
||||
|
|
@ -28,11 +36,14 @@
|
|||
IterMut became index loops, so the Take::next axiom was deleted too.
|
||||
Remaining as axioms on the whole model: the FIVE SHA-2 verify-path
|
||||
oracles and three zeroize blanket impls (never on the verify path) —
|
||||
nothing else. The #print axioms audit (fail-closed, wrap-safe since the
|
||||
external-review fix of 2026-07-24) confirms only the five oracles + the
|
||||
kernel three survive in any certificate cone.
|
||||
nothing else. The in-Lean audit (Proofs/Audit.lean, `collectAxioms`,
|
||||
round 5) confirms only the five oracles + the kernel three appear in any
|
||||
certificate cone, and that no other declaration in the audited modules
|
||||
reaches outside that boundary. The zeroize axioms are deliberately
|
||||
absent from the audit's `allowedBoundary`, so if one ever reached a cone
|
||||
the build would fail. THIS FILE is hand-maintained (Aeneas does not
|
||||
regenerate it) and its bytes are sha256-pinned by check.sh Phase 0.
|
||||
────────────────────────────────────────────────────────────────────────────── -/
|
||||
-- This is a template file: rename it to "FunsExternal.lean" and fill the holes.
|
||||
import Aeneas
|
||||
import SlhVerify.Types
|
||||
open Aeneas Aeneas.Std Result ControlFlow Error
|
||||
|
|
|
|||
Loading…
Reference in a new issue