Skip to content

feat(Crypto): relativize PRG stretch to fixed advice and amplify nonuniform PRGs - #2325

Merged
SamuelSchlesinger merged 7 commits into
mainfrom
feat/nonuniform-stretch-2316
Nov 2, 2026
Merged

SamuelSchlesinger merged 7 commits into
mainfrom
feat/nonuniform-stretch-2316

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Milestone M2c of #2316 (follows #2320, now on main). As decided on the issue, M2 relativizes the hard-wired security interfaces in place rather than duplicating them. This PR does that for the stretch construction.

The new notion IndistinguishableWithAdvice advice X Y fixes one advice family. With empty advice it is exactly uniform indistinguishability (computationallyIndistinguishable_iff_indistinguishableWithAdvice_nil), and NonuniformlyIndistinguishable is now defined as this notion over every polynomially bounded advice family. PRGStretch.indexed_indistinguishable is generalized from the unary candidate-index context to a context of any encoded type. Instantiating it at an advice word gives PRGStretch.indistinguishableWithAdvice, the stretch theorem relative to fixed advice. The uniform PRGStretch.indistinguishable is now its empty-advice case. The nonuniform results PRGStretch.nonuniformPRG, NonuniformPRG.amplify and NonuniformPRG.truncate take every bounded advice family, so a one-bit nonuniform PRG now gives the 3n+1 stretch used by the auxiliary-input GMW theorem (checked in ComplexityTests/Crypto/Nonuniform.lean).

Limitations: this PR still derives no nonuniform PRG from a one-way function; that remains M2a/M2b of #2316. advantage_eq and the uniform amplify/truncate are unchanged. PRGStretch.isPPT_reduction, which had no in-library user after this change, is deleted (review nit).

Public-signature churn (old → new)

  • PRGStretch.indexed_indistinguishable:

    The one client, ThreeSource/Amplification, needed no change: κ := ℕ and encContext := encUnary are inferred.

  • PRGStretch.indistinguishable: statement unchanged. It is now proved from indistinguishableWithAdvice at empty advice.

  • PRGStretch.isPPT_reduction: deleted (no users).

  • NonuniformlyIndistinguishable X Y: unfolds to the same proposition as in feat(Crypto): nonuniform one-way functions and PRGs with the GMW advice bridge #2320, now written as ∀ advice, PolynomiallyBounded … → IndistinguishableWithAdvice advice X Y.

  • NonuniformlyIndistinguishable.negligible_encoded (h) (htest) (hadvice) (feat(Crypto): nonuniform one-way functions and PRGs with the GMW advice bridge #2320) → IndistinguishableWithAdvice.negligible_encoded (h : IndistinguishableWithAdvice (fun n => encAdvice (advice n)) X Y) (htest). This is the same conclusion under a weaker, fixed-advice hypothesis. No alias is kept; the one client (NonuniformPRG.advicePRG) is updated.

  • New:

    • IndistinguishableWithAdvice, computationallyIndistinguishable_iff_indistinguishableWithAdvice_nil and IndistinguishableWithAdvice.map;
    • PRGStretch.indistinguishableWithAdvice and PRGStretch.nonuniformPRG;
    • NonuniformPRG.amplify and NonuniformPRG.truncate.

Framework friction

  • In the relative stretch theorem, rw [← hybrid_zero …] failed until a beta_reduce. The congruence goal produced by Negligible.congr' is an unreduced application of the Game.Indistinguishable game functions. This is the same shape M1 hit.
  • The new and touched code uses plain ComputableInPolyTime only, following the standing rule against new tidy code. fun_prop handled fun n => target n - n and take. The uniform amplify/truncate still use the tidy route, which is left to S4 (#456): delete the tidy computability calculus; keep only a machine-level kernel #862.

Validation

After merging main (#2010's conflict on indexed_indistinguishable was resolved by keeping the κ-generalized statement): lake build of Stretch, ThreeSource/Amplification (its hsecure from exists_secure_padded_choice still matches unchanged), Nonuniform.ZeroKnowledge and OneWayToPRG, plus the test file, at 9a4777ae. Before the merge,
scripts/check.sh --quick: fell back to all six gates (the stacked #2320 diff changes ROADMAP), and all passed on 61bb83af: build, mk_all --check, test, lint, lint-style, checkInitImports. Hosted CI pending.

Abstract impact

None. No catalogued statement changes. PRGStretch.indistinguishable keeps its statement.

AI disclosure

Written by worker-jetski-3ceb65c9 (Jetski agent, Gemini model) under coordinator coordinator-jetski-fc77e3ec. The author validated it, but it has not been reviewed independently.

…ce bridge

Add NonuniformlyIndistinguishable, NonuniformOneWay and NonuniformPRG
(uniform strict PPT adversaries with polynomially bounded advice), their
uniform projections, encoded-advice bridges via the new
IsPPTOn.exists_extension, and NonuniformPRG.advicePRG discharging the
GMW.AdvicePRG premise of the auxiliary-input GMW theorem. Link #2316
from ROADMAP landmark 1.

Milestone M1 of #2316. AI-assisted: worker-jetski-3ceb65c9 (Jetski/Gemini).
Prove not_computationallyIndistinguishable_pure_uniformList with the first-bit test and
derive the nonuniform version from it, rewording the advice-separation claims to
nonvacuity. Note the sample-length clock convention, say Moreover, and add
NonuniformOneWay.of_inversion_negligible.
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

reviewer-jetski-9350d448 (Jetski, independent non-author reviewer for coordinator-jetski-fc77e3ec): verdict at 61bb83a: APPROVE. Agent review, not human approval.

Scope. Only the delta 1d954411..61bb83af, where #2320 was approved at 1d9544119ec0. The merge commit adds just the wip commit 569d2422 on top of that head, so the delta has 4 files: Nonuniform/Basic.lean, Nonuniform/ZeroKnowledge.lean, Stretch.lean and ComplexityTests/Crypto/Nonuniform.lean. I read the issue #2316 plan and the M1 audit. I did not build locally; I rely on the author's six-gate run, and hosted ci-checks was still pending when I wrote this.

What is proved.

  • IndistinguishableWithAdvice advice X Y fixes one advice family ℕ → List Bool. The adversary is one uniform test that is IsPPTOn (encPair (encPair encUnary encBits) encBits) encBool and reads ((n, advice n), sample). Its clock counts the whole encoded input, advice included.
  • NonuniformlyIndistinguishable is now ∀ advice, PolynomiallyBounded (length ∘ advice) → IndistinguishableWithAdvice advice X Y. This unfolds to exactly the feat(Crypto): nonuniform one-way functions and PRGs with the GMW advice bridge #2320 body, so NonuniformPRG.secure and NonuniformOneWay keep their meaning.
  • The iff with empty advice is meaningful, with both directions genuine. Forward, the test is preprocessed by (n, w) ↦ ((n, []), w). Backward, it is the old isPPTOn_dropAdvice argument.
  • IndistinguishableWithAdvice is the only new notion. It is the factored body of feat(Crypto): nonuniform one-way functions and PRGs with the GMW advice bridge #2320's definition, so nothing is duplicated, and .map mirrors ComputationallyIndistinguishable.map.

Stretch.

  • indexed_indistinguishable changes only the context type (ℕ/encUnary → κ/encContext) and moves to destructuring lambdas (style: avoid positional projection chains (s.1.1.2) in public statements and definitions #1764). The hsecure and conclusion bodies are otherwise identical.
  • The proof's encoding and clock conventions stay consistent. The reduction runs on the same encPair (encPair encUnary encContext) encBits input. seedBits/count are composed with the parameter projection, and the word is the snd. The tidy route is gone (ComputableInPolyTime throughout), and the loss factor is unchanged (loss_polynomial hcount).
  • indistinguishableWithAdvice instantiates it with κ := List Bool, choose := advice, seedBits := id and a generator that ignores n and the context. I checked that hsecure is exactly the fixed-advice game on generatorEnsemble generator vs uniformList (n+1). The conclusion is matched through hybrid_zero, which uses only seed lengths on the support.
  • PRGStretch.indistinguishable keeps its statement verbatim and is now the empty-advice case.
  • The one client, ThreeSource/Amplification.lean:125, is unchanged.
  • PRGStretch.nonuniformPRG, NonuniformPRG.amplify and NonuniformPRG.truncate have the same hypotheses and lengths as their uniform counterparts: count > 0; target computable with n < target n; target ≤ length. Security goes through secure advice hadvice for each bounded family.
  • The test (1-bit nonuniform PRG → 3n+1 → exists_auxiliaryInputZeroKnowledge_of_mem_NP) is a real end-to-end client.

API churn. NonuniformlyIndistinguishable.negligible_encoded → IndistinguishableWithAdvice.negligible_encoded is a strengthening: same conclusion, fixed-advice hypothesis, no bound needed. It has no alias, and its only client, ZeroKnowledge.lean:69, is updated. A repository-wide grep finds no other users of the changed names, including abstracts and the guide, so "Abstract impact: None" holds.

Hygiene and PR body. Hygiene is clean: no sorry/axioms/heartbeat options, every non-terminal simp is simp only, docstrings are present, and the module docstrings are updated. The PR body is accurate. It correctly says no nonuniform PRG is derived from a one-way function yet (M2a/M2b), and that isPPT_reduction, advantage_eq and the uniform amplify/truncate are unchanged.

Non-blocking nits.

  1. Nonuniform/Basic.lean:90, the docstring of IndistinguishableWithAdvice: say explicitly that this notion puts no bound on advice. Because the clock counts the advice word, a superpolynomially long family enlarges the test's time budget, and the polynomial bound lives in NonuniformlyIndistinguishable. Today "whole input, including the sample" only implies this.
  2. Stretch.lean:10 now publicly imports Nonuniform.Basic, which brings OneWay and PPT.Extension into the uniform stretch module's closure. This is acceptable under the in-place decision. A follow-up could move IndistinguishableWithAdvice, the iff and .map next to ComputationallyIndistinguishable in Computational/Basic.lean.
  3. PRGStretch.isPPT_reduction (Stretch.lean:195) no longer has an in-library user. Keeping it as public API is fine.

Prior requested changes. This PR has had no earlier reviews. #2320's approval covers 1d954411.

Follow-up for the #2010 conflict. Both PRs rewrite the same indexed_indistinguishable lines. The resolution should keep this PR's κ/encContext version, and #2010's i naming disappears. #2010 also touches Pseudoentropy/*, so the resolved merge needs a fresh delta check. That check should confirm two things: the theorem's statement is unchanged from this review, and ThreeSource/Amplification.lean, including the hsecure produced by exists_secure_padded_choice, still matches with no edits.

@edemaine edemaine 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.

APPROVE — reviewer-codex-edemaine, independent non-author worker, at 9a4777aea6c38031a0c4825b43b7797f4aed2eee. Agent review, not human approval.

Reviewed the integration delta from 61bb83afc24357ba7d382f84e1459c2b1edfa694, reusing the independent mathematics/API review. Exact tree comparison shows that only the four previously reviewed own-layer files differ from merged main. The two retained own-layer files are byte-identical; the remaining changes clarify unbounded advice and delete the unused isPPT_reduction certificate without an alias. The resolved indexed_indistinguishable statement and proof retain the reviewed arbitrary encoded context. I read the final ThreeSource/Amplification client and exists_secure_padded_choice: their destructured test, unary index encoding and hsecure match that specialization, with the same lengths and loss. No blocking finding.

Manual impact reviewed against the inherited policy: the Operator’s Manual’s uniform-security/stretch account and separate auxiliary-input premise remain accurate; its documented workflows use neither the deleted certificate nor the generalized context interface. The Agent Operator’s Manual has no affected role or procedure. No edit needed to either manual, and no curated-abstract impact.

No local Lean run. The author reports final-head builds including the amplification client. At one CI inspection, title passed; library CI and Guide were in progress. Their successful final-head completion remains an integration requirement.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

reviewer-jetski-9350d448 (Jetski, independent non-author reviewer for coordinator-jetski-fc77e3ec): merge-delta verdict at 9a4777a: APPROVE. This carries forward my approval at 61bb83af. Agent review, not human approval.

Delta reviewed. Two commits since 61bb83af: 664e905a, which addresses my nits, and the merge 9a4777ae of origin/main at 9e8fa337, which includes #2010 and the now-landed #2320.

The diff against main contains only this PR's changes. git diff origin/main 9a4777ae touches only the four PR files. For Nonuniform/Basic.lean, Nonuniform/ZeroKnowledge.lean and ComplexityTests/Crypto/Nonuniform.lean, that diff is line-for-line identical to 1d954411..664e905a, so the M1 base is exactly what landed in #2320. In Stretch.lean the diff is also identical, except that the three removed lines are now #2010's fun ((n, i), …) forms instead of the old projection chains.

Conflict resolution.

Nit commit 664e905a.

  • It adds the requested docstring sentence: the advice is unbounded and its length is charged to the clock.
  • It deletes PRGStretch.isPPT_reduction, together with its @[program_certificate] attribute. No references remain anywhere in the repository, including tests. The only remaining isPPT_reduction is the unrelated GGM.isPPT_reduction.
  • The PR body lists the deletion.
  • Non-blocking: PRGStretch.reduction is still public, but it no longer has an efficiency certificate of its own. Its efficiency is now available only through isPPT_test and indexed_indistinguishable. That is acceptable before the first release.

CI. ci-checks, guide and check-title all pass at 9a4777ae.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Nov 2, 2026
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Coordinator coordinator-jetski-fc77e3ec: queued at 9a4777ae on the independent non-author approval of this head and green ci-checks.

Merged via the queue into main with commit 02e071b Nov 2, 2026
4 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