Repository navigation
slh-dsa: add hazmat module exposing the XMSS layer and message hashes - #1504
Open
jonesmarvin8 wants to merge 1 commit into
Open
jonesmarvin8 wants to merge 1 commit into
jonesmarvin8 wants to merge 1 commit into
Conversation
Adds an off-by-default `hazmat` feature with byte-level wrappers around the crate's own FIPS 205 code: `xmss_root`, `xmss_sign` and `xmss_pk_from_sig` (Algorithms 9-11, at any layer and tree), `prf_msg` and `h_msg` (section 4.1), and size helpers. No existing item changes visibility or behavior. Wrong-length slices from the caller panic; a malformed signature or leaf index passed to `xmss_pk_from_sig` returns an error. With `zeroize`, the wrappers clear their copies of SK.seed and SK.prf.
jonesmarvin8
added a commit
to logos-blockchain/logos-execution-zone
that referenced
this pull request
Nov 12, 2026
The wots_tree crate moves into lee as signature::wots::tree, with its spec beside it, and lee depends on slh-dsa's hazmat feature alone, at the commit proposed upstream in RustCrypto/signatures#1504. Keys, signatures and the fixed-seed vectors are unchanged. A malformed signature passed to hazmat's xmss_pk_from_sig is now an error, which verification reports as malformed.
This branch has not been deployed
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.
Adds an off-by-default
hazmatfeature toslh-dsawith byte-level wrappers around the crate's existing FIPS 205 code, so other hash-based constructions can be built on it without reimplementing WOTS+ and the XMSS layer:xmss_root,xmss_sign,xmss_pk_from_sig: Algorithms 9–11, at any layer and tree addressprf_msg,h_msg: the message hashes of section 4.1n,m,tree_height,xmss_sig_len: sizes for a parameter setThe module only calls existing
pub(crate)code; no existing item changes visibility or behavior, and nothing is compiled without the feature.This complements #1439, which proposes sharing the WOTS+ one-time signature between
xmss,lmsandslh-dsa. That would cover the chains and checksum, but not the XMSS tree or the message hashes exposed here. Ifslh-dsalater moves to a shared WOTS+ implementation, these wrappers would call it instead, without changing their API.Safety notes, also in the module docs:
SigningKeymust not be used here: its hypertree's XMSS leaves are the same WOTS+ key pairs, so signing with them would reuse keys and break the SLH-DSA key.xmss_pk_from_sigmay come from anyone, so they return an error instead.zeroize, the wrappers clear their copies ofSK.seedandSK.prf, wiping before any later length check can panic. Temporaries inside the existing XMSS code are not cleared, as elsewhere in the crate.Tests: the XMSS wrappers reproduce the existing
xmssKAT vectors (from slh-dsa-py), the top layer's root matches an SLH-DSA key's public root, every leaf signs and verifies, and the message hashes match thehashesvectors. Also covered: wrong-length signing buffers panic, and malformed signatures and out-of-range leaves are rejected without writing the root. Checked with--no-default-features --features hazmat,--features hazmat,zeroizeand--all-featuresin debug and release, pluscargo fmt --check,cargo docwith-D warnings, andcargo clippy --all-features --all-targets -D warnings. Clippy's remaining findings on 1.94 and stable are in existing files (fors.rs,util.rs,signature_encoding.rs,verifying_key.rs), not inhazmat.rs.