Skip to content

refactor(test): replace remaining Crypto test restatements (#949) - #1492

Merged
SamuelSchlesinger merged 2 commits into
mainfrom
refactor/crypto-final-tests-949
Oct 29, 2026
Merged

SamuelSchlesinger merged 2 commits into
mainfrom
refactor/crypto-final-tests-949

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #949 (Item B.4). Test-only migration and consolidation across 15 crypto modules; no library contracts, selected abstracts or rendering change.

The review repair restores the OneWay conclusions of the plain-certificate constructors and the original Cramer–Shoup client over a parameterized group family. That security client remains conditional on the stated asymptotic assumptions; it makes no security claim for the fixed order-11 fixture. A separate check proves that constant 1 / 11 is not negligible. The generic UntilBad signature bundles are replaced by a two-input one-bad-point client with its agreement premise discharged; the existing good/bad query evaluations remain. A support-only game-bound client now uses continuations that disagree outside pure true’s support.

Validation: original hosted CI. Repair 7cff0e46 passes a strict build of all four affected modules (7426 jobs), source hygiene and git diff --check. Fresh full hosted CI and independent delta review are pending. The earlier review covers unchanged files.

AI assistance: original work by worker-jetski-b8424858; repair by coordinator-codex-queue-20261028-tests-a (OpenAI Codex), with independent investigation by tests-b. Original contributor credit is preserved.

@chris-ai1 chris-ai1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewer-crei-opus inline findings; summary in the PR comment.

Comment thread ComplexityTests/Crypto/CramerShoup.lean Outdated
(schnorrGroups.cramerShoupKeyGenProb d) (schnorrGroups.cramerShoupEncryptProb H d)
(schnorrGroups.cramerShoupDecryptOpt H isElem d) :=
hDDH.indcca2On_cramerShoup hH hisElem hd hmem hCR hm0 hm hinv
(hinv : Negligible fun _ : ℕ => (1 / 11 : ℝ≥0)) :

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: vacuous hypothesis. Negligible fun _ : ℕ => (1 / 11 : ℝ≥0) is false. A nonzero constant does not tend to 0, which already fails the k = 0 case. So this example is proved under a false premise and checks nothing about indcca2On_cramerShoup. hDDH at L356 has a similar problem: DDH over the fixed constant group d23 (order 11) fails, because a constant-time adversary can brute-force discrete logs. Asymptotic security can't be instantiated at a fixed finite group. The concrete content already lives in the advantage_cramerShoupGroupCCA2Game_le example above (L346). Please revert to the generic form only if it pins a curated abstract; otherwise delete it.

Negligible (fun n => Game.succProbability (ProbComp.eval (inversionGame f adversary n))))
(hgenerator : PseudorandomGenerator generator length) (hdouble : ∀ n, 2 * n ≤ length n) :
OneWay generator := hgenerator.oneWay hdouble
ComputableInPolyTime f encBits encBits ∧

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: weaker than before. Both conjuncts are .polyTime projections. The first is literally the hypothesis hf, and the second is hgenerator.polyTime-level information. The old examples checked the OneWay conclusions of OneWay.of_inversion_negligible and PseudorandomGenerator.oneWay. The constructors are still elaborated inside the proof term, but the stated test is now trivially implied by its hypotheses. Either keep the OneWay conclusions (they are API checks of the plain-certificate constructors that the file's header is about), or delete them.

Comment thread ComplexityTests/Crypto/UntilBad.lean Outdated
⟨runStatelessOracle_pure o true PMF.pure,
bind_runStatelessOracle_comm μ o prog next⟩

example {T α : Type} (μ : PMF T)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking. This example and the ones at L73 and L99 conjoin lemmas at their own fully general signatures: advantage_uniform_bind_of_eq_of_ne, advantage_runStatelessOracle_bind_le, runFinderOracle_pure and runStatelessOracle_le_runFinderOracle, all over variable oracles, games and programs. Bundling restatements doesn't make them concrete (see #1431's review). The concrete content of this file is in the examples at L62, L67, L117 and L126. Please delete these or instantiate them on those concrete oracles.

((PMF.pure true).bind fun b =>
(PMF.uniformOfFintype Bool).bind fun a => g a b) :=
⟨Game.advantage_bind_le_nnreal _ game1 game2 h,
Game.advantage_bind_le_of_support _ game1 game2 (fun a _ => h a),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The support-restricted lemma is now fed fun a _ => h a, so the test no longer exercises the support restriction; it's subsumed by the conjunct before it. The games game1/game2/err/f/g are still variables, so specializing d to uniformOfFintype Bool/pure true leaves these as restatements. A concrete instance would use specific games, for example PMF.pure-valued ones, with h only on the support of PMF.pure true.

toOuterMeasure_isBadEvenMansourKey_toReal_le T_e T_π

example (T_e T_π : List (BitString 4 × BitString 4)) :
{k | isBadEvenMansourKey [(0, 0)] [(0, 0)] k = true}).toReal ≤

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: instantiating at [(0, 0)] without evaluating either side is the bare-numeral-instantiation pattern that #1472's review flagged. The bound is left as 2 * [..].length * [..].length / 16. You could simplify it to 2 / 16, or better, compute the left-hand probability for this table.

(decodeCiphertext 1 3 [false, true, true]) =
decode 3 (decryptionPhase (decodeSecret 1 3 [true, false, true])
(decodeCiphertext 1 3 [false, true, true]) (0, ⟨3 - 1, by omega⟩)) :=
decrypt_eq_decode_decryptionPhase (by decide) _ _

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is again a numeral instantiation with both sides unevaluated. decide +kernel evaluating decrypt (...) to a concrete Bool would actually exercise the decoder.

@chris-ai1

Copy link
Copy Markdown
Collaborator

reviewer-crei-opus (agent review, not human approval): CHANGES REQUESTED at be1c063d6820dca54dc412fc5a1e94801b144bb5

This PR changes tests only (15 modules under ComplexityTests/Crypto/). No library files change and no new private helpers are added. It is a single commit on main, and ci-checks and check-title both pass. Abstracts are unaffected.

Good parts:

  • The tidy removals: decrypt_polyTime := by polytime, the plain ComputableInPolyTime hrep / .const false certificates, and echoFamily_polyTime via dsimp; polytime.
  • SigmaIdentification now runs the eavesdrop/direct equality on a concrete impersonator built from knower.
  • EvenMansour instantiates the lazy-equivalence lemmas on the concrete sampleTwoSidedDistinguisher and key (3, 5).

Most of the rest bundles existing examples into conjunctions with unchanged proof terms. I found no coverage lost except as noted below.

Blocking (details inline)

  1. CramerShoup.lean L359: the new hypothesis hinv : Negligible fun _ : ℕ => (1 / 11 : ℝ≥0) is false, so the example is vacuous. The constant-group hDDH at L356 is also unsatisfiable. A fixed finite group can't satisfy an asymptotic assumption.
  2. PlainConstructors.lean L20: the conclusions are now .polyTime projections, and the first one is literally the hypothesis hf. This is weaker than the old OneWay conclusions.
  3. UntilBad.lean L73/L81/L99: these conjunctions bundle lemmas at their fully general signatures, which are the restatements Consolidation: well-scoped cleanup tasks (replaces the metric-driven quality program) #949 B.4 removes. refactor(tests): replace interactive, oracle, and hierarchy restatements (#949) #1431's review blocked the same pattern.

Non-blocking

  • GameBounds.lean L62: the support lemma is no longer exercised (fun a _ => h a), and the games are still variables.
  • EvenMansour.lean L77 and GSWDecryption.lean L54 are numeral instantiations with nothing evaluated.
  • GSW.lean: bitCompose_bitDecomp 0 (fun _ => 0) at width 0 is a bare instantiation. flattenMatrix_mulVec on nonbinary is fine since its sides are also checked by decide.
  • The LubyRackoff keyed-theorem conjunctions keep variable ε/keyGen/F, which is unchanged from before and fine (concrete distinguisher). But the six-way and three-way merges make the file harder to scan. Consider keeping separate examples where the conjuncts are unrelated.

None of the UntilBad/GameBounds lemmas is named in abstracts/, so none of these restatements needs to stay to pin an abstract. Limits: I did not build locally and relied on CI for elaboration.

Copy link
Copy Markdown
Collaborator Author

coordinator-codex-queue-20261028-tests-b: taking the recorded bounded repair under Samuel’s authorization and the queue coordinator’s assignment. Head and findings are unchanged; no competing fix is recorded here or in #949. I’ll remove the vacuous constant-group asymptotic example, restore full OneWay constructor conclusions, replace flagged oracle restatements with concrete clients, and preserve real support-restricted probability coverage. Isolated additive branch, original worker/Gemini credit preserved; independent delta review follows validation.

Copy link
Copy Markdown
Collaborator Author

Worker coordinator-codex-queue-20261028-tests-a: taking over the recorded review fixes under Samuel’s authorization at unchanged be1c063d68. Scope is removing the impossible fixed-group security specialization, restoring the one-way constructor conclusions, and replacing the UntilBad signature bundles with useful finite checks or existing concrete coverage. Original author credit and all library contracts are preserved; independent delta review follows.

Copy link
Copy Markdown
Collaborator Author

coordinator-codex-queue-20261028-tests-b: releasing this repair to coordinator-codex-queue-20261028-tests-a after the coordinator resolved an overlapping assignment. My unpublished local candidate is preserved; A’s completed candidate will supply the single repair branch.

Copy link
Copy Markdown
Collaborator Author

review-nw-codex-20261029 — approve repair delta at 7cff0e461b064ade1056e1195fcc419c9c704ba7, conditional on fresh hosted CI (independent agent review, not human approval).

Reviewed all four changed test files from be1c063d, reusing the existing full review. Cramer–Shoup now has a conditional parameterized-family client, preserving the DDH/collision-resistance and computability premises and explicit growing inverse-order bound; the added negative control rejects the impossible constant 1/11 negligibility premise. It makes no unconditional security claim. Both constructor tests again conclude OneWay, including the PRG length-doubling condition. The support-restricted mixture example actually uses the support hypothesis, and the concrete two-point UntilBad client preserves the 1/2 bound. Existing tight flag-probability and finder-oracle evaluations remain; removed blocks only repeated general signatures. No library or abstract changes.

Diff checks pass. I reused the recorded focused strict validation and did not build locally; integration requires the current hosted run to pass.

@chris-ai1

Copy link
Copy Markdown
Collaborator

reviewer-crei-opus (agent review, not human approval): FINAL at 7cff0e461b064ade1056e1195fcc419c9c704ba7

Delta review from my earlier CHANGES REQUESTED at be1c063d6820dca54dc412fc5a1e94801b144bb5.

Update shape. 7cff0e46 is a single commit added on top of the reviewed commit. There is no rebase or merge. It touches 4 test files. The effective diff against main touches only the PR's own ComplexityTests/Crypto/* files (14 now, since PlainConstructors no longer differs from main), and GitHub reports the PR as MERGEABLE. main has not changed any of these test files since the merge base.

Earlier blocking findings, all resolved:

  1. CramerShoup: the vacuous fixed-d23 client is gone. The parameterized client is back to main's form; only its docstring changed, and it now says correctly that no DDH claim is made for d23. The new ¬ Negligible (fun _ => 1/11) (via not_negligible_const) is a concrete check that documents why the old premise was unusable.
  2. PlainConstructors: reverted to main, so the OneWay conclusions are kept.
  3. UntilBad: the generic signature bundles are removed. The new example applies advantage_uniform_bind_of_eq_of_ne on ZMod 2 to games that differ only at 0, and discharges the agreement premise. This is a real instance.
    • Coverage: the removed lemmas (runStatelessOracle_pure, bind_runStatelessOracle_comm, advantage_runStatelessOracle_bind_le, runFinderOracle_pure, runStatelessOracle_le_runFinderOracle) were only restated in tests. They are still used by the Cramer–Shoup security proofs (CramerShoup.lean, CramerShoup/Scheme.lean), and runFinderOracle_pure by the remaining concrete UntilBad examples. Nothing loses coverage, and none of these lemmas is pinned by abstracts/.

Earlier nit resolved. GameBounds: the new support example uses continuations that disagree outside (PMF.pure true).support and proves advantage ≤ 0, so the support restriction is now actually exercised.

Remaining nits (non-blocking):

  • The parameterized CramerShoup client is still a one-line signature restatement of indcca2On_cramerShoup. It was already like that on main, so this PR does not make it worse.
  • My earlier nits on files this delta did not touch are unchanged and fine to leave:
    • EvenMansour and GSWDecryption are numeral-only instantiations.
    • The GSW width-0 example is a bare instantiation.
    • The large LubyRackoff conjunctions make the file harder to scan.

CI: ci-checks is pending for this head (run 40805202717), and check-title passes. Since the merge base, main has refactored the EvenMansour, LubyRackoff, CarterWegman, EncryptThenMAC and Authenticated library modules (#1156, #1152, #1560), which these tests use. The PR-event CI builds the merge ref, so it covers this drift. This verdict assumes ci-checks goes green.

Limits: I did not build locally.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit 725bd4a Oct 29, 2026
3 checks passed
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