Skip to content

proof(xmss): bound model forgery by direct hash queries - #5455

Draft
alexanderlhicks wants to merge 54 commits into
build/xmss-vcvio-compatfrom
prototype/xmss-fresh-repin
Draft

alexanderlhicks wants to merge 54 commits into
build/xmss-vcvio-compatfrom
prototype/xmss-fresh-repin

Conversation

@alexanderlhicks

@alexanderlhicks alexanderlhicks commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex, an AI agent, prepared and published this draft.

This is the first of two leanXMSS proof drafts stacked on the VCVio dependency migration, #5377. Its base branch is build/xmss-vcvio-compat. Review this proof independently of the follow-up that switches the public theorems and removes the old proof.

Model theorem

XmssSecurity.Fresh.forgeAdvantage_le_of_adversaryBound bounds the probability of forgery by (2q + 344) / 2^128. For each public key, the adversary makes at most q direct hash queries on every path. The experiment is EthLib’s existing XmssSecurity.forgeAdvantage Concrete.scheme adversary. Key generation, signing and verification use the same oracle and their queries are outside this adversary budget. The former model bound, (2q + 634) / 2^128, follows by weakening the numerator.

Start at EthLib/Cryptography/Proofs/Xmss/Security/Fresh/Main.lean for the theorem and its assembly. The proof samples the key-generation table, accounts for guesses of hidden chain values on oracle reads, and follows an accepting verification through the two tree layers. The scan bounds cover a signer that retries sequential randomizers, including inputs the adversary has already queried.

Fresh/Generic.lean contains local forms of the generic lemmas used by the proof. EthLib can import their upstream counterparts after a subsequent VCVio pin. VCVio #1431

Validation

The branch adds 16 fresh-proof modules and extracts shared hash-oracle definitions used by the old proof. At 9d1d48ae4, all 16 fresh modules, 85 affected EthLib modules and the downstream consumer elaborated with warnings as errors using cached dependencies. The two model theorems depend only on propext, Classical.choice and Quot.sound. This was a targeted 102-file rebuild. The repository-wide build and declaration checks belong to hosted CI.

Known standalone CI failure. At this head, scripts/check_layers.py reports 16 modules in Fresh/ with no importer from a library root. The proof was compiled by naming its modules explicitly. The required layer check will need to pass on this PR before it can merge. The retirement draft connects the public security umbrella to the new proof and moves its regression fixture to the downstream test package. Its layer check passes. An isolated candidate brings those two changes forward and registers the fixture under the downstream Contracts root. Its security umbrella and regression fixture compiled with warnings as errors.

alexanderlhicks and others added 30 commits December 3, 2026 16:10
State every definition and lemma of the fresh leanXMSS blueprint (v4,
main line L0 to L16, generic V1 to V7) with open proofs. Assemble the
own-query bound (2q + 344) / 2^128 and the frozen (2q + 634) / 2^128
from those statements without an open proof in the assembly.

The directory imports only the model definitions (IdealStatement and
below) and VCVio modules that are built at the pin. Local placeholders
copy FreshKeyQueries, runLog, agreeUntilBad_add_iff, scanWithAnswer and
orbit. V1 and the signer reordering (L4b) carry the checked proofs of
the collaborating session.

This is a prototype: the files use sorry and are not imported by the
Proofs root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Make the KI candidate of a chain-slot input require a one-digest payload,
so deciding KI never reads a hidden value for a malformed input (L5).
Give a bottom-digest input a target only when it is a cell (L6a). State
L7 over the visible cache with every replayed query covered, add the
link from an accepted folded verification to that replay, and prove L8
on G2 from the link and the per-table classification.

Replace the V6 placeholder by the run-time-target provenance statements
and add the weighted cap placeholder, both copied from the VCVio
vlemmas worktree. Drop unused hypotheses of L15. Add a regression module
for the hidden-read leak, outside the assembly's imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The current upstream provenance statement cannot serve L6a: a signing
step writes several cache entries, and targets present from the start
must force the flag. Remove the copied statements and keep L6a stated
directly, with a note that it will use the revised V6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… facts

Record the three obligations of the second review as statements:
reveal consistency of the run state (L8), injectivity of the codeword
decoding (L8 at the top digest), and that deciding KI off a probe reads
only exposed hidden cells (L5). Drop the unneeded `not bad` from the
link lemma.

Rewrite the oracle-form handler so every table read is a query of one
oracle, with hidden reads annotated by their recorded payloads; the
games differ only in how they answer those queries. Graph computations
inside the handler run as free programs on table queries.

Prove L5 (`G2_eq_G3`) from three open step facts: the recording step
keeps its invariant, the recording step projects to the testing step,
and G3's flag equals a recorded payload that hits. The proof composes
handlers, applies V1 and V2's projection, and evaluates `finalize` at a
fixed table. No relational coupling is used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`classical` adds `Classical.propDecidable` at low priority, so a `decide`
or `if h :` over a finite type such as `Message × Randomness` picked the
executable `Fintype` instance, which unfolding tries to evaluate. Pass
`Classical.propDecidable` explicitly in `parse`, `chainSlot`,
`encodingCell`, `candidate`, `posOf` and the `Sel_a` ghost update, and
adapt the regression proof.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `RevealMono`: a revealed codeword or a selected cell belongs to a
requested leaf, and a revealed top codeword is the table's own. It is
preserved from every state, under any answers that agree with the table
on the remaining cells, because L1's repeated-leaf abort runs the signer
only at a leaf's first request and the top search is deterministic.

`RecInv` is now the recorded-probe clause together with `RevealMono`;
the unused `bad = false` clause is dropped. `recordStep_inv` is proved
from what each step can change (new module `Fresh/Steps.lean`): a hash
step touches only c_A, the flag, the probes and the records; a signing
step only shrinks the hidden set and writes only bottom-digest cells,
which are never in a chain slot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At a fixed table, a recording step seen through `recProj` is a testing
step. A signing step neither reads nor writes the flag or the records
(the scan commutes with them, and the table answers ignore annotations),
so it commutes with `recProj`. A hash step agrees case by case; a warm
probe needs the payload recorded at its cold write, which `RecInv`
provides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… for G3

Move `exposedAnswer` and `keygenAnswer_reads_exposed` into
`Fresh/Steps.lean`, below `Deferral`, so the proof of G3's flag can use
them. Add the all-paths form G3 consumes: with the remaining cells fixed,
deciding KI off a probe queries only exposed hidden cells, whatever the
hidden values. Note in L16 that its cap needs an invariant-carrying
variant, since an unreachable state can make one query cost 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…answers

signStep_support and revealMono_step now take answers in OracleComp spec', so G3's
restFix handler can use them directly; ProbComp answers are the case spec' = unifSpec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… step 4b-(b))

G3_flag_eq: the joint run of G3 keeps JInv (every cached hidden cell is exposed, the flag
says some cached value lies in its record, RevealMono), step by step through
simulateQ_run_simulateQ_run_preservesInv; hidden reads are allowed queries (exposed cells
via keygenAnswer_hidReads_exposed, the cells a signature exposes), and finalize caches
every cell. G2_eq_G3 now depends on sorryAx only through keygenAnswer_hidReads_exposed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ewrites

scanTrials_frame covers what scanTrials_recProj did; one simulateQ_tableAnswer_qread
replaces the three per-case rewrite lemmas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… plain hidden oracle once

exposedAnswer and keygenAnswer_reads_exposed had no consumer; PlainHid moves to Steps and
restRead uses it. Docstrings of Steps state what each lemma is for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…drop a repeated clause

Generic gains IsQueryBoundP.cost_le_mul_of_mem_support_run_simulateQ_of_inv (VCVio
5c622c348), which L16's docstring now names; RevealConsistent no longer repeats
RevealMono's top-codeword clause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sed hidden cells

With it, G2_eq_G3 (L5) is sorry-free. The graph-read helpers move from
Deferral to Steps, next to their new consumer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e provenance (L6a)

New module Fresh/Classify: parsing facts for model hash inputs (payload
injectivity from HashInputLemmas), the hash and signing steps of G2 at a
fixed table, and one run invariant ProvInv (RevealMono, reveal
consistency, no keygen input in c_A off bad, provenance of target
matches, snapshot/Sel_a link) preserved by every step of impl2. The
statements move unchanged from Lemmas to Classify.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A target match in fullCache at a slot other than bd(a) is honest or Hit:
a c_A entry goes through L6a, and a keygen input is in its own slot, where
only the selected top trial carries the codeword target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New module Fresh/Layers: a covered replay is the cache's Option run; the
descent along a chain walk and along a Merkle climb (V7, inlined) uses the
slot lemma L6 at each step; a covered keygen chain input is exposed, so
the forged codeword dominates the reveal and equals it. The layer
definitions and the L7/L8 statements move unchanged from Lemmas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
L7 on the top layer plus L6 at the top digest pin the signed bottom root
and the top randomizer; L7 on the bottom layer and reveal consistency
then make the forgery the logged signature (Contains) unless its digest
cell differs from the selected one, in which case the snapshot invariant
gives Sel_e. win_imp_hit_or_sel now depends only on the link lemma.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The review labels on decodeDigest_injective and reveal_consistent went
with them to Classify; their docstrings there state the facts only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The codeword digests are in bijection with the words of digit sum 106
through their digits (a subtype equivalence, so no binder ranges over a
filter of Finset.univ); the count comes from Code's codeCount_target.
0 < p < 1 is then arithmetic on that numeral, and a slice's codeword
digests are at most its codeword cells by card_biUnion_le.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both invariants become structures, so their consumers read them by name
(revealMono, revealConsistent, noKeygen, provenance, snap; signedAt_snap,
sel_snap, topRevealed_eq) instead of by position. Deferral's RecInv steps
now state the post-state's flag as written, since RevealMono no longer
unfolds to see through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
L6a is the run invariant ProvInv and L7 proves its own two descents, so
Generic no longer states V6 or V7; its section note says where they live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nestInput

- Module titles drop the slice numbers; Regression describes its case
  instead of citing a review; Lemmas says the link lemma is still open.
- Translate, HashInputLemmas, Code and EncodingLemmas are imported
  privately where only proofs use them (the codeword helpers in Lemmas
  become private accordingly).
- L3 (a) parse_honestInput is closed from honestInput_slot and
  parse_tweakable.
- Proof lines over 100 characters in Classify, Layers and Steps are
  wrapped, and three double blank lines removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every hash answer of a G2 run at a table lands in the visible cache and
stays there (hashStep_visible: hiddenness is unchanged by a hash step and
c_A grows only at a cold probe or a non-keygen input), so the cache's run
of any hash-only program lifted into A' returns that program's output
(hashAt_run_visible). Concrete.verify splits into bottomRecover then
topRecover then the root check (verify_eq_recover, via Translate's
verify_eq and the climb equivalence with Merkle.climb), and a completed
cache run is a covered replay. No not-bad hypothesis is used.

win_imp_hit_or_sel is now sorry-free.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At a table, the masked G2 handler and G1o's differ only at a cold probe:
if the payload is the hidden value both set bad, and otherwise the input
is not keygen's (keygenAnswer_chainSlot), so both draw fresh and the
steps coincide (AgreeUntilBad.of_run_eq_or_bad). Both handlers keep bad
(hashStep_bad; a signing step leaves the flag). VCVio's identical-until-
bad equalities, the union bound and the projection of run2 to its run
state then give G1o_le_G2 table by table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With bad = "the log is not valid" and the invariant "every snapshotted
leaf is in the log", G0's handlers with and without the repeat check are
dominated by each other until bad (DominatedUntilBad.of_evalDistEq_or_bad):
a request at a snapshotted leaf invalidates the log in both, and any other
step is the same code. A win needs a valid log, so the two win
probabilities bound each other per keygen outcome. The invariant keeps
the argument off unreachable states; agreeUntilBad_add_iff is not needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gameRun_eq: by induction on the adversary, the existing game's WriterT
log run under the random oracle, followed by any continuation on output,
log and cache, is G0's single StateT handler without the repeat check
(a world query is the same romImpl step; a signing request is the same
romImpl run of the signer, its entry appended to the log). The folded
verifier runs under G0's handler as romImpl runs it on the state's cache
(simulateQ_impl0_liftM), which gives forgeAdvantage_eq_G0 as an equality
of programs. advPrime_isQueryBoundP adds the reused 172-query verifier
bound through a lift of IsQueryBoundP to A''s oracle.

The signing-branch equation impl0_false_sign_run is proved by unfold,
dsimp and simp: closing it by rfl, or by simp before dsimp, ran for
minutes (defeq through two different matchers of the same bind).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
G1o read on the full cache (c_A joined to keygen's inputs) has, step by
step and from every state, the law of G1; VCVio's distributional state
projection lifts it to the runs. The signing step uses the scan
correspondence and the fact that a table's secret key stores the
table's chain values and paths (replayed on keygen's cache).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A hash step at a table is one of three programs (warm, cold probe, cold
input off the hidden slots), each stated once in Classify together with
the parameter and keygen-answer reads. hashStep_table, hashStep_visible,
implAt_agreeUntilBad and hashStep_false_table rewrite with them instead
of repeating the case split. The generic split is hashStep_shape, from
which hashStep_fields and hashStep_bad follow. Removes two erw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alexanderlhicks and others added 24 commits December 3, 2026 16:10
Docstring for impl0_dominated; ProvInv's fields named in its
preservation proofs and RevealConsistent's docstring; one climb_eq for
both layers; simulateQ_impl0_liftComp_liftComp without the prime; the
consumer-less agreeUntilBad_add_iff deleted with its section, and the
empty provenance section folded into Generic's module docstring;
docstrings no longer name the removed descent lemma or describe build
status; double blank lines and long lines in Layers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The three cases of a hash step (warm, cold probe, cold off the hidden
slots) are stated once in Steps for any answers to the reads and any
test flag, with the probe bookkeeping as RunState.noteProbe. The table
lemmas in Classify specialise them, and Deferral's recordStep_inv,
hashStep_recProj (tableAnswer) and hashStep_jinv (restFix) rewrite with
them instead of splitting by hand. Removes four erw from Deferral.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
selectTrial_eq_scan has no user once L4a goes through signer_eq and
scanTrials_proj; it is deleted, and acceptedAnswers and increment stay
for L12. L4a's law equality is named G1_evalDistEq_G1o. The parameter
read in implAt_sign is a rw; romImpl_inr_run holds the one remaining
erw of Lemmas (was nine). implAt_agreeUntilBad drops its unused
hypothesis and says the step agreement holds from every state. No
build-status wording left in Generic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VCVio's `QueryImpl` is now a structure. The fresh proof's handlers
(`impl0`, `qread`, `implO`, `tableAnswer`, `restFix`, `restRead`,
`restFixPlain`, `forgetHid`, `tabAnswer`, `annotY`, `hashAt`, `relabel`,
`eagerAnswer`, V2's `forget` and `annotatedBase`, and `oRun`'s cache
handler) are built with `toFun`; their answers are unchanged. Two proofs
follow: an equality of handlers uses `ext1`, and the lifted-hash run
rewrites by the induction hypothesis before unfolding `impl0`.

No theorem statement changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At the new pin VCVio has `FreshKeyQueries`, `runLog` with its lemmas,
`scanWithAnswer` and `orbit`, and the stale modules have built, so the
fresh proof uses them instead of local placeholders:

- `FreshKeyQueries`, `runLog`, `evalWithAnswerFn_eq_of_forall_mem_runLog`,
  `scanWithAnswer`, `orbit` and Layers' `runLog_pure`/`runLog_query_bind`
  are VCVio's;
- `verify_isQueryBoundP` is EthLib's (`XmssSecurity/CachedSelectionBound`);
- `codeword_card` is EthLib's `validDigests_card` (`Proof/Scan/Card`).

The generic lemmas of the VCVio branch `prototype/xmss-fresh-vlemmas`
that the pin lacks are copied into `Generic.lean` with their statements
and proofs, each section naming its upstream file: V2 (AnnotatedRead),
V3 (Wald, with `tsum_prEvent_mul_eq_of_ite`), V4 (Orbit), V5 (the
FreshKeys iff theorems) and the weighted caps (StepWeight). They replace
the placeholders `freshKeyQueries_iff`, `retryLoop_eq_scan`,
`sum_prEvent_scan_select_eq`, `sum_cyclic_selection_mass_le` and
`wald_of_steps`. V2's local form `prEvent_annotated_flag_le` keeps its
statement and is proved from the copy (`annotated_eq_annImpl`).

`Generic.lean` has no `sorry` left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New module `Fresh/Pricing.lean`; `prEvent_bad_le`, `prEvent_hit_le` and
`evalDist_table_eq_join` move there from `Lemmas.lean` with their
statements unchanged, and `Lemmas` imports it.

- L11: at each table, VCVio's `expected_credit_of_increments` on `impl2`
  with the credit `targetQueries / N`. A cold target query is a fresh
  answer written at its input, which truncates to the target with
  probability `1/N`; every other step leaves the hit flag and the count.
- L10: in `G3` the joint invariant `ChargeInv` (V2's charge is at most the
  payloads recorded at cached hidden cells over `N`, and there is at most
  one payload per probe) holds through every step and `finalize`, since
  each step reads hidden cells only with the records of its pre-state.
  With V2 (`prEvent_annotated_flag_le`) this bounds `G3`'s flag by the
  expected probes over `N`. L5 (`G2_eq_G3`) carries the flag and the
  probes to `G2` at fixed remaining cells, and `evalDist_table_eq_join`
  (now proved, from VCVio's uniform pair bijection) averages over them.

The assembly now rests on six sorried lemmas: L3, L12, L13, L15 (two)
and L16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`CachedSelectionBound` and `Scan/Card` pulled most of the old
`XmssSecurity/Proof/` tree into `Fresh.Main`'s import closure. The fresh
proof no longer imports them:

- `verify_isQueryBoundP` is proved in `Lemmas` from EthLib's
  `isQueryBoundP_verifyWith` (`Xmss/QueryBound.lean`), with the lift
  `isQueryBoundP_liftM_hashSpec` as a local lemma;
- `codeword_card` is proved again by the local bijection between codeword
  digests and the words of the code (`Code`, `EncodingLemmas`).

`Generic`'s docstrings state that its copies are local copies of the named
VCVio files, and the unused sorried `topSignFrom_queryBound_one` is
removed with its section header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New module `Fresh/Keygen.lean`; the L3 section (`relabel`, `eagerAnswer`
and the L3 statements) moves there from `Lemmas.lean` with its statements
unchanged, and `Main` imports it.

- (a) `trialInput_injective`: a trial's randomizer `R0top[b] + c` keeps
  the counter below the cap.
- (b), (c) `keygen_freshKeyQueries`, `relabel_freshKeyQueries`: keygen is
  fresh on positions (`keygen_fresh`). Each piece is fresh on its own set
  of positions, and VCVio's `FreshKeyQueries` composes in sequence over
  disjoint sets (`FreshKeyQueries.bind_union`): a chain walk on its first
  steps, a leaf on its chain steps and its leaf, a tree on the positions
  below its node (`TreeShape`, one shape for both layers), a top search
  on its trials. Fresh positions make fresh inputs, and the relabelling
  and the log keep freshness.

The positions are read from the slot (and a trial's counter), not from
the answers, so the argument holds on every path; it reuses none of the
old `XmssSecurity/Proof/` query bounds, and `Keygen` imports no module of
that tree beyond those the fresh proof already used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…3 c-d)

- `run'_randomOracle_of_fresh`: a program fresh on its inputs, run under
  the lazy random oracle from a cache empty on them, draws one fresh
  uniform answer per query. It is VCVio's
  `run'_simulateQ_parallelStateT_withCaching_eq` without a side oracle,
  proved by the same induction.
- (c) `keygen_run_eq_relabel`: both runs are the uncached run, and the
  relabelling answers each query with the same uniform draw.
- (d) `relabel_run_eq_eager`: VCVio's lazy-eager lemma
  (`evalDist_simulateQ_randomOracle_run'_empty_eq_uniformTable`) on the
  finite position oracle; a relabelled query reads the table at the
  input's position.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `keygen_output_eq`: keygen's run on `keygenCache g` is the table's root
  and top searches (`oRun_keygen`, from L4a's `tree_honest` and
  `topTree_honest` and the new `oRun_topSignFrom`). The eager answers of
  `g` agree with that cache, since the honest input of a position lies at
  that position (`posOf_honestInput`), so the eager run has the same value
  and logs only cached entries (`oRun_answer`).
- `hashCacheOfLog_eq_keygenCache`: the log records the cache. Every keygen
  position is visited (`visits_keygen`: a tree visits every position
  below its node, a top search every trial up to its first codeword), and
  a cache entry is the honest input of its position, so every cached
  input is logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- (f) `coins_answers_bijective`: `tableOf` rebuilds a table from coins and
  answers (a hidden value is the truncated answer one step below, a high
  half and a chain end are read off a chain step's answer), and it is
  inverse to `g ↦ (g.coins, g.answers)`.
- `keygen_eq_eager`: the logged run's cache is its log entered into the
  empty cache on every path (`withQueryLog_run_cache`), and the run's law
  is the eager table's by (c) and (d).
- `samples_tableOf`: keygen's four coin draws and a uniform answer table,
  through `tableOf`, are one uniform table (VCVio's uniform pair and
  bijection lemmas).
- `G0_true_eq_G1`: keygen under the random oracle has the law of a
  uniform table's public key, secret key and keygen cache
  (`keygen_evalDistEq`, from (e) at the table), and `G0'` and `G1` run
  the same adversary after it.

L3 has no `sorry`; the assembly now rests on L12, L13, L15 (two) and L16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The statements of L12 to L16 move from `Lemmas.lean` to two new modules,
with their statements unchanged: `Fresh/SliceSteps.lean` (L14 and L16's
pathwise count) and `Fresh/Partner.lean` (L12, L13, L15, `theta_lt_one`
and `accounting_le`). `Main` imports `Partner`.

- How a step of `G2` moves the slice of `bd(a)`: only a query of a cold
  cell of `a` before `a` is requested (`ColdCell`) changes it, by a fresh
  answer written into the cell (`impl2_slice`, `impl2_encoding`,
  `slice_cacheQuery_self`); bottom-digest inputs of distinct leaves and
  cells are distinct (`encodingInput_inj`).
- `probes_add_targetQueries_add_cells_le`: the weighted cap
  `IsQueryBoundP.cost_le_mul_of_mem_support_run_simulateQ_of_inv` with
  weight 2 and the invariant `ProvInv` (whose `RevealMono` gives "a
  selection has a snapshot"). A hash query adds at most one probe and one
  cold target query; a cold cell of `bd(a)` before `a` is requested is
  neither, and adds one cell (`units_hash_le`). Coins and signing
  requests add nothing (`units_other_le`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A slice of `bd(a)` is a cache of VCVio's lazy random oracle on cells
(`Slice.cache`), and the signer's scan of message `m` is VCVio's
first-accepted scan of the cells `(m, rho)` along the orbit of
`rho -> rho + 1`:

- the pass factors and selection weights are the slice's (`passFactor_eq`,
  `selectionWeight_eq`), since a uniform answer is accepted with
  probability `p` (`prEvent_accepted`) and the orbit runs backwards by
  `rho - k` (`increment_symm_iterate`);
- an orbit of `2^32` randomizers has distinct cells (`orbit_nodup`);
- summed over all starts, the scan selects a cell of a set of cached
  codeword cells with the summed weights (`sum_prEvent_scan_mem`).

`Slice.H_le` is the local copy of VCVio's `mul_sum_sum_selectionWeight_le`
with one line per message, its sums regrouped by `sum_eq_sum_rowsIn` and
`card_eq_sum_rowsIn`, divided by `p`.

The sets of cells are locally irreducible: unfolding a membership in them
reaches `Finset.univ` over `Message × Randomness`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `countsTrials`: from every state, a step of `G2` at a table either
  leaves the cells and codeword cells of the slice of `bd(a)` as they
  are, or (a cold cell of `a` before `a` is requested) adds one cell,
  which is a codeword cell with probability exactly `p`. This is the
  hypothesis of the local copy of VCVio's Wald identities, so
  `E[V] <= p E[n]` and `E[(V/p - n)^2] <= ((1-p)/p) E[n]` at each table
  (`run2_V_le`, `run2_sq_le`), and over `G2` (`expect_G2_le`).
- `reserve_le`: on each path, by L14, `V H / p <= V (n + V (1-p)/p) / p`,
  which with `delta = V/p - n` is `(2-p) n^2 + (3-2p) n delta +
  (1-p) delta^2`; AM-GM with `kappa` and `n <= q'` (L16's pathwise count,
  `n_le_cap`) bound it by `(2 - p + 3/2 kappa) q' n +
  (1 + 3/(2 kappa)) delta^2` (`reserve_le_real`).
- `expect_VH_le`: the two give `theta' N E[n]`, with
  `theta' N` the real `thetaNum q'` (`theta_mul_digestCount`).
- `theta_lt_one`: `thetaNum` is increasing in the cap, and at
  `2^127 - 1` it is below `2^128` by `norm_num` on the exact codeword
  count `|C| = 323504418562481994618807509487594`.

`p` and `kappa` are irreducible real constants (`rateR`, `kappaR`):
unfolding `|C| / 2^128` in a definitional check exceeds the recursion
limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`accounting_le`: `theta' < 1` gives `1 + theta' <= 2`, so the
probes, the cold target queries and `(1 + theta')` per cell cost at most
`E[probes + targetQueries + 2 sum_a n_a] / N`, and the pathwise count
`probes_add_targetQueries_add_cells_le` bounds the expectation by `2q'`
(`expect_le_const`; expectations are additive, `expect_add`,
`expect_sum`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A slice is a cache of VCVio's lazy random oracle on cells, with one key
for all cells and answers decoded to their digests when these are
codewords (`keyOf`, `decodeAns`); VCVio's partners are then the cells of
`K` (`Slice.mem_K`). Summed over all messages and starts, VCVio's
occupied and partnered masses of the signer's scans are `H` and `Phi`
(`sum_cachedMass`, `sum_partneredMass`, by L14's
`sum_prEvent_scan_mem`).

- `compensate_slice`: VCVio's `compensate_sum` at a cold cell, with the
  family of all messages and starts, `epsilon = 1/N` (`priorPairRate_le`
  with the codeword cells as rows, and `prEvent_decodeAns_le`), scaled by
  `N/p`: `E[N Phi'] + V H / p <= N Phi + E[V' H' / p]`.
- `run2_Phi_le`: `run_compensated` at each table, with value `N Phi` and
  reserve `V H / p` (finite by L14, `reserve_ne_top`), from every state:
  a cold cell of `a` before `a` is requested is `compensate_slice`, and
  every other step leaves the slice. Both start at zero.
- `expect_Phi_le`: the average over tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `scanTrials_slice`: the signer's scan at a table, read on the slice of
  its leaf, is VCVio's first-accepted scan of the cells `(m, rho)` along
  the orbit of `rho -> rho + 1`, run on the slice as a cache.
- `signStep_sel_le_scan`: at `a`'s first request, the step draws the
  start, runs the scan, and keeps the scan's cache and selection;
  everything after reads the table only, so `Sel_a` is an event of the
  scan (`prEvent_bind_le_of_support`).
- `scan_sel_le`: for one start, a partnered selection at the end of the
  scan is a selection partnered at entry or a fresh codeword landing on
  a stored digest (VCVio's `stopped_cache`, `stopped_partner_le`); the
  second has probability at most `|S|/N` (`prEvent_storedDigest_le`).
- `signStep_sel_le`: averaged over the start, the partnered masses of
  message `m` sum to at most `Phi` (`sum_partneredMass_msg`,
  `sum_rowsIn_K_le`), so the step costs `Phi/N + |S|/(pN)` on the
  snapshot it takes.
- `run2_sel_le`: VCVio's `expected_credit_of_increments` with the credit
  `selCredit`, which `a`'s first signing step sets to that bound and no
  other step changes (`snap_isSome_step`, `selPartner_step`); this holds
  from every state. `prEvent_sel_le` averages over tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… lemmas

The fresh proof kept its own copies of four lemmas of the old proof, two of
them under the same short names. The originals move unchanged into a light
module, XmssSecurity/HashOracle.lean, which both proofs import, and the
copies go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…through coins_answers_bijective

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Small definitional lemmas name the forms the rewrites need: the shapes'
node computations, the coins and the parameter of a table, a trial's honest
input, and a handler's answer to a table query. Eight of the erw were plain
rewrites already.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Key generation needs the top tree irreducible only for keygen_fresh, so the
attribute applies to that theorem alone. The slice sets need it only for
L14 and the partner lemmas, so L14 moves beside them in Partner and one
list, in one section, covers them all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…space

The extension lemmas of OracleComp.FreshKeyQueries now live in that
namespace, so dot notation on a freshness hypothesis finds them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aration

Every comment sentence of Fresh/ now has a line of its own, within 100
characters, and the layout check reports nothing there. Each declaration
and each field of TreeShape has a doc comment. The docs describe the code
as it is: the provenance notes, the copy markers and the references to the
planning documents are gone, and the docstring of the pathwise count names
the invariant its proof uses. Only comments and whitespace change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…olds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant