lcert_verify
lcert-verify — a zero-trust verifier for LCERT-1 proof-carrying certificates.
The verifier re-derives a certificate's verdict from the primitive quantities the
certificate carries, using only the Python standard library. It checks internal
consistency and integrity; it does not re-run the physics. See SCOPE.
Verify a bundle, abstaining rather than asserting when evidence is missing.
Returns a dict with verdict (see the taxonomy above), ok,
trust_anchor ("fingerprint" or "NONE"), internally_consistent,
n_certificates, n_gated_loci, errors and fingerprint.
Why an anchor is required by default. The re-derivation catches any tamper that leaves the recorded verdict inconsistent with the shipped bounds. It cannot catch a tamper that edits both consistently — that forgery is internally perfect, and only a fingerprint obtained out of band refutes it. Reporting such a bundle as verified would be asserting something this code did not establish, so it abstains.
Recompute the outputs commitment, and bind the KPIs to the preregistration.
Defensive throughout, for the reason given on verify_manifest_and_root: a malformed bundle is a verdict, never an exception.
Re-derive every LCERT-BOUND-1 certificate — the domain-agnostic kind.
A producer supplies, per locus, an outward-rounded interval [lo, hi] for
some quantity, plus a threshold and which side of it is safe. This function
recomputes the admission verdict from those numbers and rejects any recorded
claim that is more favourable than the re-derivation.
It computes no physics, and that is deliberate. Where the intervals come from — a thermal solver, a timing engine, a model evaluation — is the producer's problem and its evidence. What is checked here is that the verdict written down follows from the numbers written down. That is the part a third party can do without trusting anyone, and it is the only part this file claims to do.
Assemble a domain-agnostic LCERT-BOUND-1 certificate.
loci is an iterable of (lo, hi) pairs: your outward-rounded enclosure
of the quantity at each locus. direction is "below" (safe means the
upper bound stays under the threshold) or "above".
The verdict is derived here and re-derived by the verifier, never supplied. Nothing about this certificate is lithography-specific; where the intervals come from is your analysis and your evidence, and this file does not and cannot compute them.
Check every payload file against the manifest, then recompute the root.
Every field is read defensively. A bundle missing seed, or carrying a
manifest that is not a mapping of names to hex digests, is a REJECTION with a
reason -- not a KeyError. A checker that raises on hostile input is a denial
of service and tells the caller nothing.
Per-locus re-derivation of the interval-gate classification and verdict.
Frozen semantics of the reference interval gate: outward-rounded margin / i_noise intervals per the sub/super-threshold branch, K widened 2 ULP each way, certainly_safe = (m_lo > 0) and (down(m_lom_lo) >= Kin_hi), certainly_unsafe = (m_hi <= 0) or (up(m_him_hi) < Kin_lo), ADMIT iff no certainly-unsafe locus and no straddle (straddle -> safe-direction REJECT); zero loci -> trivially ADMIT + stable (the committed convention).
Re-derive the transcendental constants instead of trusting them.
kappa must satisfy the erfc round-trip |0.5erfc(kappa) - budget| < 1e-12 (math.erfc, stdlib), and K must equal 2.0kappakappasafety*safety/n_photons recomputed in the committed operation order (bit-identical float64 — same ops, same order as the reference producer).
Write a canonical bundle directory; return the path to bundle.json.
prereg is any JSON-serializable object recording what was declared
before measurement; it is always copied in and manifest-covered.
Assemble a stochastic gate certificate record in LCERT columnar form.
loci is an iterable of (I_lo, I_hi, ae0) triples. kappa and K are derived
here and re-derived by the verifier; the verdict is likewise re-derived, never supplied --
which is the entire point of the format.
Invert 0.5*erfc(kappa) = budget by bisection, to the tolerance the verifier enforces.
The verifier does not trust a supplied kappa; it re-runs the erfc round-trip. This helper produces a kappa that survives that check.
SHA-256 of bundle.json — the out-of-band trust anchor.
Per-locus breakdown of why a certificate reached its verdict.
Returns the same classification the verdict is derived from, plus the margin arithmetic for each locus, so a reader can see how close a locus was to the boundary rather than only which side of it fell.
Human-readable rendering, with the actionable part first.
Full result as JSON. The canonical machine format.
One line per certificate — convenient for streaming into a log pipeline.
SARIF 2.1.0 — renders in GitHub code scanning and most IDE problem panes.
An abstention is emitted at warning level with the reason, never suppressed:
a reader scanning the Security tab must see that no assertion was made.
JUnit XML — appears in the test report of essentially every CI system.
JUnit has no 'abstained' state. An abstention is therefore a failure with the reason attached: reporting it as a pass would be exactly the confident wrong answer this project exists to avoid.
Render a verification result as a single self-contained HTML document.
Compare two bundle directories.
Anchors are optional here and their absence is reported rather than ignored: a diff between two unanchored bundles compares two documents of unknown provenance, which is worth knowing before acting on it.
Streaming counterpart of lcert_verify.verify_bundle().
Same result shape and same verdicts; streaming: True is added so a caller
can tell which path produced it. progress(n_so_far) is called per
certificate if supplied.