Repository navigation
refactor(hashsig): move the monad-map lemmas to the shared modules - #901
Merged
Merged
Conversation
tcoratger
force-pushed
the
hashsig-map-monad
branch
2 times, most recently
from
November 6, 2026 11:44
da56d96 to
720d362
Compare
Two lemmas say that a map of monads that keeps pure and bind commutes with the shared vector builder and with the WOTS hash chain. They sat in a leanSPHINCS proof file, which leanXMSS may not import. They now live in the shared proof modules of those helpers, so both schemes can use them. The statements are unchanged, and the names move to the HashSig and Wots namespaces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tcoratger
force-pushed
the
hashsig-map-monad
branch
from
November 6, 2026 11:45
720d362 to
6665ca5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two lemmas about the helpers that leanXMSS and leanSPHINCS share move out of a leanSPHINCS proof file and into the shared proof modules of those helpers.
Their statements are unchanged, and leanXMSS can now use them.
The problem
A map of monads here is a function
φ : m β → n β, for every typeβ, that keepspureandbind.The leanSPHINCS bridge uses two facts about such maps:
φcommutes with building a vector in order, the sharedHashSig.ofFnInOrder.φcommutes with a hash-chain walk, the sharedWots.chain.Both facts are about shared helpers, but they were proved in
Proofs/Sphincs/Unforgeability/VerifyQueries.lean.The two schemes never import each other's files (decision HS-1, checked by
check_layers.py), so a leanXMSS proof could not use them.The XMSS stack under review (#855) proved both again under other names.
The idea
Put each lemma next to the helper it describes:
HashSig.ofFnInOrder_map_monadgoes inProofs/HashSig.lean, after the identity-monad lemma of the same builder.Wots.chain_map_monadgoes inProofs/Wots.lean, at the end of its section on chains.The leanSPHINCS callers in
VerifyQueries.leanandHonestQueries.leannow use these names.VerifyQueries.leanimportsProofs.HashSigfor the first lemma.Decision 90 forbids deprecated aliases, so the old names go away.
Example
The leanSPHINCS message digest is
ofFnInOrder DIGEST_CALLS (fun call => thFull H …).To show that a monad map
φsends the digest computed withHto the digest computed withφ ∘ H, the proof rewrites withThe proof is the same as before, and only the name changes.
For reviewers
The statements before and after, from
#check:Only the order of the implicit arguments of the chain lemma changes: the section variables of
Proofs/Wots.leancome first.The explicit arguments keep their order, so every call site keeps its arguments.
No other declaration moves.
The private copies in #855 (
collect_natural,chain_natural) are not on master, so this pull request cannot remove them.Checks
lake build --wfailofProofs.Sphincs,Proofs.Xmss,Proofs.QueryAvoidanceandProofs.Wots.Binding: 5547 jobs, passed. These cover every importer of the four changed modules.leancheckerreplays at 8 GB, one module at a time:Proofs.HashSig(8.5 s, 2.7 GB),Proofs.Wots(8.9 s, 3.1 GB),VerifyQueries(5.6 s, 3.2 GB) andHonestQueries(4.3 s, 3.2 GB) passed.lake exe check-declsonProofs.HashSig,Proofs.Wots,Proofs.SphincsandProofs.Xmss: 18909 declarations, 0 findings.git grepfinds no use of the old names.check_writing.py --base, the commit check,check_lean_layout.py --base,check_layers.pyandsoundness_facts.py --check: clean.🤖 Generated with Claude Code