Repository navigation
feat(Schemes): hash-and-MAC and hash-and-sign with named MAC/signature and collision reductions - #1163
Conversation
🤖 PR SummaryNew Constructions: Hash-and-MAC and Hash-and-SignThis PR formalizes the hash-then-authenticate domain-extension constructions for MAC and digital signature schemes, following Boneh–Shoup §8.2 (Theorem 8.1) and Katz–Lindell 3rd ed. §6.3.1 / §13.3. The core idea is to apply a keyed collision-resistant hash function to the message first and then invoke the underlying short-message primitive on the hash output. Two new scheme modules, each with security bounds stated as advantage inequalities against named reductions, are added.
Proof StructureEach security proof follows a uniform pattern:
Generic Infrastructure: Query Relabeling and Collision DetectionThe file
These lemmas are used to relate the forger’s query log under the composed scheme to the logs produced by the reductions. Test Coverage and Universe‑Polymorphism Canaries
Imports
No Statistics
Lean Declarations ✏️ Added: 47 declaration(s)
📋 **Additional Analysis**The diff adds new modules, tests, and re-exports that align with VCVio's contribution guidelines. No issues found with style, licensing, imports, module system, documentation, or testing practices. 📄 **Per-File Summaries**
Last updated: 2026-11-21 20:44 UTC. |
e679a98 to
18993fb
Compare
…e and collision reductions `VCVio/Schemes/HashAndMac.lean` composes a short-message MAC with a keyed hash family and proves, for both UF-CMA and SUF-CMA, Adv(scheme, A) ≤ Adv(mac, macReduction A) + keyedCRAdvantage(H, crReduction A). `VCVio/Schemes/HashAndSign.lean` does the same for signatures (hash key in the public key), for EUF-CMA and SUF-CMA, with `sigReduction` / `strongSigReduction` and `crReduction` / `strongCRReduction`. The shared simulation step lives in `VCVio/OracleComp/QueryTracking/LoggingOracle/Relabel.lean`: translating each chosen-message query by `f` before a logging handler gives the run of the logging handler for the composite, with its log relabelled by `f` (`QueryImpl.run_simulateQ_withLogging_translate`), plus the generic collision extraction `QueryLog.collisionCandidate`.
18993fb to
70c922e
Compare
…eryLog `QueryLog` and its existing API live in `OracleSpec.QueryLog`. The relabelling and collision helpers were declared in a root-level `QueryLog` namespace, which made `log.relabel f` fail to resolve by dot notation and started a parallel namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The log relabelling and collision API takes messages, digests and responses in independent universes. The simulation laws take any index universe and a shared response universe, as gotcha 9 asks of public reusable laws. The translation needs messages and digests in the response universe, because `withLogging` does. - `VCVioTest/UniversePolymorphism.lean` uses `relabel_singleton` and `run_simulateQ_map_log` at nonzero universes. - `VCVioTest/OracleComp/QueryLogRelabel.lean` checks relabelling and collision extraction for `n % 4` on `ℕ`. Dropping either conjunct of the search in `collisionCandidate` breaks one of its checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks! These are VCVio's first standard-model domain-extension theorems for MACs and signatures, covering both UF and SUF for both primitives. They handle the two cases that make the strong version subtle. A new message whose digest collides with a queried one goes to the collision term. A queried message with a new tag is either a collision or a forgery against the underlying MAC or signature. The hash key is handled as in Katz–Lindell (part of the MAC key, and part of the public key for signatures), the reductions are named, and "one common run, then a pointwise union bound" keeps the proofs short. I pushed a few commits, plus a merge of current
Approved. Follow-up suggestions, none of them blocking:
|
Summary
This PR adds the domain-extension constructions for MACs and signatures through a keyed
collision-resistant hash (Boneh–Shoup v0.6 §8.2, Theorem 8.1; Katz–Lindell 3rd ed. §6.3.1 and §13.3).
Each security bound is stated for a named reduction.
VCVio/Schemes/HashAndMac.leanHashAndMac.scheme mac H: the key is(k, s)andtag (k, s) msg = mac.tag k (H.hash s msg).macReduction: samplessand forwards each tagging querymsgasH.hash s msg.crReduction: samplesk, runs the forger honestly and returnsQueryLog.collisionCandidate.strongUnforgeableAdvantage_le:Adv^{SUF-CMA}(scheme, A) ≤ Adv^{SUF-CMA}(mac, macReduction A) + keyedCRAdvantage H (crReduction A).unforgeableAdvantage_le: the same bound for UF-CMA.VCVio/Schemes/HashAndSign.leanHashAndSign.scheme sig H: the hash key is part of the public key, as in Katz–Lindell.sigReduction/strongSigReductionandcrReduction/strongCRReduction.unforgeableAdvantage_le(EUF-CMA) andstrongUnforgeableAdvantage_le(SUF-CMA), with the samebound shape.
VCVio/OracleComp/QueryTracking/LoggingOracle/Relabel.lean(generic)QueryImpl.translate fforwards each(M →ₒ T)querymsgas the(D →ₒ T)queryf msg.QueryImpl.run_simulateQ_withLogging_translate: a translated run againstwithLogging tagFnisthe run against
withLogging (tagFn ∘ f)with its log relabelled byf(
QueryLog.relabel). It is derived fromQueryImpl.run_simulateQ_map_log, which says twologging handlers whose per-query logs agree up to
List.map eproduce runs that agree up toList.map e.QueryLog.collisionCandidate/hasCollision, withmem_of_mem_relabelandmem_map_fst_of_mem_map_fst_relabel: when there is no collision, a relabelled entry atf msgcomes from an entry at
msg. This covers both the SUF (exact pair) and the UF (message only)freshness conditions.
QueryImpl.run_simulateQ_passthrough_add_liftM: a lifted ambient computation runs with anempty log.
Proof structure
Each security bound is proved the same way:
forgeryRun) followed by differentfinal tests. The keyed-CR experiment needs one
OracleComp.evalDist_bind_bind_swapto reorderthe two independent key samplings.
OracleComp.evalDist_bind_apply_le_add_of_supportgives the union bound pointwise.Scope choices:
ProbCompwithProbCompRuntime.probComp, likeMacFromPRF. The CR adversary has to run the MAC/signature key generation, andKeyedCRAdversarylives inProbComp.classicalinternally, becauseSignatureAlg.strongUnforgeableExperimentis defined underopen scoped Classical.No existing declaration changes.
VCVio.leangains the three imports generated by./scripts/update-lib.sh.Verification
lake build VCVio.OracleComp.QueryTracking.LoggingOracle.Relabel VCVio.Schemes.HashAndMac VCVio.Schemes.HashAndSign:0 errors, 0 warnings.
lake exe axiomsweep --check --root <module>on the three new modules (40 declarations): zerosorryandzero non-standard axioms.
./scripts/update-lib.sh, thenscripts/check-imports.sh.lake lint -- --style-only.lake exe runLinter --no-build <module>for each of the three modules.scripts/check-expose-boundary.sh,check-extern-isolation.sh,check-interop-isolation.sh,check-polyfun-boundary.sh.uv run --no-project --python 3.12 python scripts/check-agent-docs.py,test-agent-docs.py,extract-doc-fragments.py --check,check-doc-names.py,check-comment-fences.py,test-lint.py.I did not run a full
lake buildorlake lint -- --env-onlylocally. CI runs both.Checklist
CONTRIBUTING.md, AttributionAnd File Headers); docstrings are intrinsic, with no change history or "renamed from" wording.
public sectionwith per-declaration@[expose](Module Scopes), andthe expose-boundary baseline was lowered in this PR if a file was converted.
./scripts/update-lib.shleaves the umbrella files unchanged, andlake exe axiomsweep --checkpasses: nosorryand no non-standard axiom.(
axiomsweep --checkrun with--rooton the three new modules (40 declarations); CI runs the whole-library sweep.)set_option linter.* false, no deprecated aliases (docs/agents/gotchas.md§18, §23),and no native FFI test executables on the PR path.
uv run --no-project --python 3.12 python scripts/check-agent-docs.pypasses.
VCVioTest/gained one-callentries, no proof gained a second tactic call outside a dated gap pair, and the before/after
line counts of the touched proofs are listed above. (N/A: no simp set changed.)