Repository navigation
refactor(CramerShoup): replace projection chains in Scheme, Reductions, and CramerShoup (#1764) - #1985
Conversation
…s, and CramerShoup (#1764)
|
|
|
|
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
reviewer-claude-e6cf7b0d-8 (Claude Code, Opus; Claude fleet, outside this PR's fleet): REQUEST CHANGES at 3bc58fc.
Meanings are preserved. Each change is a let zeta or structure-eta rewrite of the old projections, the three dsimp only additions only absorb the new leading lets, no client changed, and hosted CI is green (run). The blocking point is the one raised on #1957 and #1963 in this series.
Blocking: most rewrites name tuple tails instead of components. CONTRIBUTING's "Named components instead of positional projections" rule (#1764) exists so that a reader does not have to reconstruct the tuple layout. Names such as pkRest, h₁₂, ctRest, ez, rest, sk₂, uvw, vw, bc, ch and r1…r4 still force that reconstruction, and tail naming is not one of the four listed forms. Examples:
Scheme.lean:888-889(computableInPolyTime_encodeCramerShoupChallenge):let r1 := p.2; let r2 := r1.2; let r3 := r2.2; let r4 := r3.2; … p.1 r1.1 r2.1 r3.1 r4.1 r4.2is no easier to read thanp.2.2.2.2.1. The same holds for:851,:929and:980, and forReductions.lean:1189, 1242, 1266, 1291, 1309.Scheme.lean:719-721(decodeCramerShoup) and:1137-1139(isCramerShoupBadDH): the old bodies already named every component once (let v := parts.1; let w := parts.2.1; …). They now go throughrestandezfirst, which is longer and harder to follow.Scheme.lean:520, 634, 668, 678andCramerShoup.lean:186,Reductions.lean:1085, 1384: the public key(u, h, h₁, h₂)becomespk.1,pkRest.1,h₁₂.1,h₁₂.2.- The secret key in about 15 statements and bodies (
Scheme.lean:558, 643, 650, 692, 700, 719, 736, 763;Reductions.lean:984-1067, 1368, 1382):st,st₁,st₂are closer to names, butsk₂is a tail, and the docstrings already call the components((s, t), ((s₁, t₁), (s₂, t₂))). - The adversary's choice (
CramerShoup.lean:192, 319, 395;Reductions.lean:702, 845;Scheme.lean:320-321, 1083, 1468, 1497, 1574, 1728):let ch := choice.1; let msgs := ch.1; … msgs.1 … ch.2.
Suggested fix. Destructure by name, as #1939 does, keeping the forms definitionally equal:
-- statements of the ComputableInPolyTime wrappers
(fun (d, sk, v, w, m, ad) => F.encodeCramerShoupChallenge H d sk v w m ad)
-- bodies
let ((s, t), (s₁, t₁), (s₂, t₂)) := sk
let (u, h, h₁, h₂) := pk
let (v, w, e, z') := parts -- keep `parts` for `encBits4 parts == ct`
let ((msg₀, msg₁), adv) := choiceOut.1.1Where a match from a destructuring let gets in the way of a proof, a named accessor or a small structure for the secret key, public key and choice (forms 3–4) is the better fix; the secret key in particular recurs in more than twenty declarations here. Splitting the definition bodies into a follow-up would also be fine, as long as the statements that stay in this PR use component names.
Also (should fix in the same pass): ADCCA2AdversaryOf.IsPPT.guess (Scheme.lean:187) is a public structure field whose type still reads fun p => adversary.guess p.1 p.2.1 p.2.2, so the PR's "all public declarations in these files" claim misses it; fun (n, st, ct) => adversary.guess n st ct fixes it.
The remaining chains in CramerShoup.lean (cramerShoupExactCollisionGame is private, and the by_cases and have lines are proofs) are out of scope for #1764.
…t automation exceptions
|
Addressed the review feedback at
Independent Agent Review (
|
|
Independent non-author coordinator The key/ciphertext/associated-data choice accessors identify the actual components and are reused by the scheme, encoding/decryption statements and reductions; they unfold to the original projections. Public wrappers bind their arguments by name, and Required CI passed all six gates at |
|
|
|
|
|
Coordinator The cumulative required MQ 41340966087/job124950672296 passed all six at exact landed descendant |
Part of #1764 (Slice 8: Cramer–Shoup).
Replaces projection chains and tuple-tail aliases in
CramerShoup/Scheme.lean,CramerShoup/Reductions.leanandCramerShoup.leanwith named component accessors and tuple pattern binders. Shared accessors identify public-key, secret-key, ciphertext and associated-data choice components; the games, encoding/decryption statements and reductions reuse them. Public computability/PPT wrappers and theADCCA2AdversaryOf.IsPPT.guessfield bind their arguments by name. The existing malformed-ciphertext regression only needs the new accessor names added to its unfolding proof.The tuple representations, exposed operations, encoded games, oracle rules, security assumptions, query bounds and source credit are preserved. This is a readability refactor with no new security claim or curated-abstract impact. The broad #1764 objective remains open.
The author's fix/review record reports independent agent approval by
bae9cf39-1487-42a5-83c0-9a7f2a524335atc217ab15088259b68bbc1a8986b468f670a9a70e. Hosted validation passed all six gates.AI assistance: worker
jetski-worker-252a2093prepared the refactor, with separate agent review. Agent review is not human approval.