Skip to content

In stateful signature private keys, cache intermediate states - #6164

Open
randombit wants to merge 2 commits into
masterfrom
jack/stateful-sig-tree-cache
Open

randombit wants to merge 2 commits into
masterfrom
jack/stateful-sig-tree-cache

Conversation

@randombit

Copy link
Copy Markdown
Owner

For both HSS and XMSS very significant gains can come from storing various intermediate values in the Merkle tree. These must be rewritten as part of the private key after the next index, but we already require this in order to increment the index itself.

These changes improve performance of XMSS and HSS signature generation by several orders of magnitude (eg HSS-LMS-SHA-256,HW(10,1) signing goes from 85 sign/s to 23000 sign/s). In general HSS-LMS and XMSS signing were roughly the same cost as keygen, and this change decouples this. Now even XMSS H=20 signatures take under 1ms.

As a precaution, HSS and XMSS hash signatures are verified before release.

@randombit
randombit requested a review from FAlbertDev November 25, 2026 03:16
@randombit
randombit force-pushed the jack/stateful-sig-tree-cache branch from 862cbab to 1c474f5 Compare November 25, 2026 12:08

@FAlbertDev FAlbertDev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I have no time for an extensive review of this entire merge request.

I like the new private key format and the time-memory trade-of. LGTM.

The private key is now encoded under a new OID (HSS-LMS-Private-Key, with
the old OID renamed to HSS-LMS-Private-Key-legacy) and additionally holds
the root of the top tree, plus for each level the tree nodes and parent
signature needed for the next signature. Keys in the old format are still
accepted, but the new format is always written.

Signing with HW(10,1) goes from 10.95 ms to 0.05 ms, and with three
levels from 89.9 ms to 0.10 ms. Loading a key no longer recomputes the
top tree. Each signature is verified before it is returned.

The speed tool now switches to a fresh key when the current one is exhausted.

Add tests for the encoding and for concurrent signing.
The XMSS private key is now encoded under a new OID (XMSS-Private-Key)
and additionally holds 1024 nodes of the tree, so that signing does not
recompute it. Keys in the old format are still accepted, but the new
format is always written. XMSS and LMS now share the code computing and
storing the tree nodes.

Signing with XMSS-SHA2_10_256 goes from 40.9 ms to 0.16 ms, and with
XMSS-SHAKE_10_512 from 376 ms to 1.11 ms. Key generation is unchanged.
Each signature is verified before it is returned.

Add tests for the encoding, for concurrent signing, and for the shared
tree code.
@randombit
randombit force-pushed the jack/stateful-sig-tree-cache branch from 1c474f5 to 2d86868 Compare December 1, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants