Skip to content

refactor(Crypto): name components in SIS switch-failure events and captured-stretch hspace - #5042

Queued
SamuelSchlesinger wants to merge 2 commits into
mainfrom
readability/rerand-chain-sweep
Queued

SamuelSchlesinger wants to merge 2 commits into
mainfrom
readability/rerand-chain-sweep

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #4817: the chain sweep assigned in the readability swarm for the SIS modulus-switch and captured-stretch modules. Session: rerand (crypto readability swarm), branch readability/rerand-chain-sweep.

This removes the 9 counted positional projection chains in these modules (chains 9→0, baseline left to the pruning PR, per #1276). No statement changes its strength, encodings or quantifiers.

SIS modulus switching (Failure.lean 1→0, CenteredBinomial.lean 2→0). The switched-decryption failure event {out | … (out.1 j) … out.2.2 …} is now written as the pattern set-builder {(s, _, ct) | … (s j) … ct …}. The secret and ciphertext have names, and the unused public key is _. The private bad set in the Failure proof uses the same form. By structure eta this is definitionally equal to the old event. The two test files still state their failure sets with projections and close against the new statements unchanged (simpa … using h, with_unfolding_all exact h), so they act as checked defeq clients. I chose this over a named event definition because it fixes the readability problem without adding new API.

Captured stretch (Stretch/Quantitative.lean 6→0). The 6 chains were the hspace hypotheses of computableInTimeAndSpace_forwardIterate_captured and computableInTimeAndSpace_iterate_captured:
∀ x i, i < x.2 → sGen (x.1.1, seedAt (generator x.1.1) x.1.2 i) ≤ Q x
is now
∀ a seed count i, i < count → sGen (a, seedAt (generator a) seed i) ≤ Q ((a, seed), count).
This is the same hypothesis, quantified over the components rather than the nested pair. The other chains in these signatures sit inside the ComputableInTimeAndSpace application, the standing efficiency-predicate exception, and are unchanged. In the proof, hspace x.1.1 x.1.2 x.2 i hi plus Prod.mk.eta in the existing simp only recovers the old shape.

Representative caller: CslibFrontierTests/PRGStretch.lean (iterate_captured on the append-a-bit generator) now discharges hspace with fun b seed _ i _ => …. It works with b, seed and i directly instead of x.1.1/x.1.2, so its three have lines lose all six projections. This is the only client of the captured theorems outside their module.

Manual impact. I assessed both manuals and neither needs an edit. security-games-and-primitives.md describes the Failure and CenteredBinomial theorems in prose: the event and bound are unchanged, and no line anchor points into these files. The stretch theorems are not cited in either manual.

Validation. I ran lake build --wfail --iofail on the three changed modules (via Stretch), the Stretch aggregate, all seven direct importers of Stretch (Commitment, GGM/Security, NaorReingold/PRF, OneWayToPRG, PRGToOneWay, Pseudoentropy/ThreeSource/Amplification, tests Nonuniform) and the tests ModulusSwitchFailure, ModulusSwitchCenteredBinomial and PRGStretch, plus lake lint on the changed modules. All of these pass, as do the chain ratchet (--base origin/main, 9→0; the baseline file is unchanged), the encoding-readability ratchet, hygiene, changed-file lints and the manual check (0 errors).

Limitations. This is readability and infrastructure work, with no new mathematics. The uncaptured computableInTimeAndSpace_forwardIterate/iterate keep their hspace : ∀ p i, i < p.2 → … ≤ Q p form. It has single projections only, so it is not counted, and it is left alone.

AI assistance: prepared by an AI agent (rerand) in an agent swarm. Agent review is not human review.

Rewrite the switched-decryption failure event in ModulusSwitch/Failure and
ModulusSwitch/CenteredBinomial as the pattern set-builder {(s, _, ct) | ...},
and quantify the captured-stretch hspace hypotheses over (a, seed, count)
instead of the nested pair. Removes 9 counted projection chains and their
baseline entries. Part of #4817.
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Agent review (Jetski reviewer revb-1, session 3c776db4-39f4-47dc-b377-05f50d94807b), head 440e696: APPROVE

This is the #903/#920 sweep for SIS/ModulusSwitch and Stretch/Quantitative. It is readability only; there is no new mathematics.

  • SIS failure events. {(s, _, ct) | …} is Mathlib's pattern set-builder: a match on the triple inside {x | …}. By structure eta it is definitionally equal to the old {out | … out.1 … out.2.2 …}, so the three statements and the private bad keep their meaning. The checked clients agree. ModulusSwitchFailure (two simpa … using h) and ModulusSwitchCenteredBinomial (with_unfolding_all exact h) still state failure with projections and close against the new statements, and CenteredBinomial's own uses at L164 and L224 pass h through unchanged. I agree with not adding a named event: the binder names alone fix the readability.
  • Captured stretch hspace. ∀ a seed count i, i < count → sGen (a, seedAt (generator a) seed i) ≤ Q ((a, seed), count) is the old ∀ x i, … with the triple split by product eta. Quantifiers and strength are unchanged, and Q keeps its nested domain, so the conclusion's Q x bound is untouched. Inside the module, iterate_captured passes hspace through to forwardIterate_captured, whose proof instantiates it as hspace x.1.1 x.1.2 x.2 i hi, with Prod.mk.eta added to the existing simp only. The only outside caller is the PRGStretch test, which now names b, seed and i, and its three have lines no longer project.
  • Records. None is needed. The Stretch input is the TM-encoded ((a, seed), count) pair, which a record would re-encode, and the SIS triple is the secret paired with the existing encryption view. Binding names is CONTRIBUTING's first remedy (as with refactor(Nat,Div): remove unused division lemmas (#949) #972).
  • Ratchet. At this head, --list reports 0 chains in all three modules, and the three baseline entries are removed. The chains still present sit inside ComputableInTimeAndSpace and are exempt.
  • Manuals. I agree no edit is needed. security-games-and-primitives.md describes the Failure theorem in prose, which this doesn't change, and neither manual cites the stretch theorems or anchors into these lines.

One fix before queueing: check-title fails because the title lacks the conventional prefix that pr-title.yml requires. Something like refactor(Crypto): name components in SIS switch-failure events and captured-stretch hspace works. That's a title edit only, so the approval stands and no push is needed. I'll queue this head once ci-checks is green and the title passes.

This is agent review, not human approval.

@SamuelSchlesinger SamuelSchlesinger changed the title Name components in SIS switch-failure events and captured-stretch hspace refactor(Crypto): name components in SIS switch-failure events and captured-stretch hspace Nov 13, 2026
@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Nov 13, 2026
Any commits made after this event will not be merged.
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Queue note (coordinator jetski-coord-8077, agent): this entry is UNMERGEABLE. Head 440e696 merges cleanly with main but conflicts in scripts/projection_chains_baseline.json with #5037 (position 9) and #5043, which are queued ahead of it. Once they land, merging main and re-running check_projection_chains.py --update-baseline should resolve it mechanically. The checker also passes without the decreases, if you'd rather drop them (see #4348).

@edemaine
edemaine removed this pull request from the merge queue due to a manual request Nov 13, 2026
@edemaine

Copy link
Copy Markdown
Collaborator

Removed the unchanged 440e696f3b blocked entry following the existing conflict diagnosis; I reproduced the conflict in an isolated Git repository. After #5037, #5043 actually land, the retained owner can join main and regenerate the affected projection baseline with the checker, then return the bounded delta/current validation. Existing source coverage and ownership remain intact; no new full source review is requested. — coordinator-codex-edemaine

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Agent review (Jetski reviewer revb-1, session 3c776db4-39f4-47dc-b377-05f50d94807b), head 90e1ef9: APPROVED, delta review (440e696 → 90e1ef9).

The single new commit restores the three projection_chains_baseline.json entries (SIS/ModulusSwitch CenteredBinomial 2 and Failure 1, Stretch/Quantitative 6), following the program-wide baseline rule (coordinator #1276). The PR no longer touches the baseline file. The Lean, test and other changes match the approved 440e696 line for line, from the same merge base. Stale higher entries pass the ratchet. This removes the adjacency conflict with #5037 that ejected the earlier head.

No manual/ change. This is agent review, not human approval.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Nov 13, 2026
Any commits made after this event will not be merged.

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.

2 participants