feat(xmss): validate XmssConfig fields at construction - #1123
Merged
tcoratger merged 2 commits intoJun 17, 2026
Conversation
Add Field(gt=0) positivity constraints to every numeric XmssConfig field, matching the style used by PoseidonParams. Extend the existing model validator to reject an odd LOG_LIFETIME, since the key splits into a top tree and bottom trees that each cover LOG_LIFETIME / 2 levels. Previously a non-positive field or an odd lifetime exponent only failed deep in tree-building with a cryptic error. Now misconfiguration is caught at construction with a clear message. Defaults are unchanged and all three shipped configs still construct. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts: # src/lean_spec/spec/crypto/xmss/constants.py
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.
Problem
XmssConfigdeclared its numeric fields as bareintwith no positivity constraints, unlikePoseidonParamswhich usesField(gt=0, ...). In addition,LOG_LIFETIMEmust be even (the key splits into a top tree and bottom trees that each coverLOG_LIFETIME / 2levels), but evenness was only enforced deep in tree-building. A misconfiguredXmssConfigtherefore failed late and cryptically.Fix
Field(gt=0)to every logically positive numericXmssConfigfield (LOG_LIFETIME, DIMENSION, BASE, Z, Q, TARGET_SUM, MAX_TRIES, PARAMETER_LENGTH, the field-element lengths, and CAPACITY).LOG_LIFETIMEwith a clear full-sentence message, consistent with the existing decomposition check.LOG_LIFETIME, asserting the full exception message.🤖 Generated with Claude Code