Skip to content

feat(sdk): optional second post-quantum signature with SLH-DSA - #587

Open
Eras256 wants to merge 1 commit into
mainfrom
feat/sdk-slh-dsa-second-signature
Open

Eras256 wants to merge 1 commit into
mainfrom
feat/sdk-slh-dsa-second-signature

Conversation

@Eras256

@Eras256 Eras256 commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

A receipt can already carry pq, an ML-DSA-65 signature (lattice-based, FIPS 204). This adds an optional slh block: SLH-DSA-SHA2-128s (FIPS 205), whose security rests only on SHA-256. Both sign the same nirium-audit-v1:<content_sha256> statement as agent, so if a weakness ever shows up in one family of math, the other signature still holds.

What's in it:

  • slhKeygen() (48-byte seed), attestSlh(), verifySlh()
  • slhKeyRegistrationOperation(): the public key is only 32 bytes, so manage_data nirium-slh-v1 holds the key itself, not a hash
  • checkSlhKeyRegistration() / findFirstSlhKeyRegistration(): same "only the first key the account registered counts" rule as pq
  • the Horizon lookup moved to pq-registry.ts (not exported) and is shared with pq.ts; pq behaviour and its tests are unchanged

Limits, on purpose:

  • Checked off chain only. Protocol 30 / CAP-87 adds verify_sig_ml_dsa_{44,65,87} and nothing for SLH-DSA, so there is no contract for this one.
  • Signing takes ~1 s on a laptop (verify ~2 ms). Measured with @noble/post-quantum 0.7.1, already a dependency.
  • The node and nirium-cli don't read slh yet; those are separate PRs. No version bump, nothing published.

Tests: npm run build && npm test in packages/sdk: jest 108/108, node:test 199/199. New test/pq-slh.test.ts covers sizes, same statement as agent/pq, changed record, flipped bits at the start/middle/end of the signature, another key, an ML-DSA block in the wrong field, malformed input, the registration op, first-key-only, and that slh and pq registrations are separate entries.

🤖 Generated with Claude Code

A receipt can already carry an ML-DSA-65 signature (lattices). This adds an
optional `slh` block signed with SLH-DSA-SHA2-128s (FIPS 205), which rests
only on SHA-256, over the same nirium-audit-v1 statement. If one family of
math breaks, the other still holds.

The 32-byte public key is registered as-is on the payer's account
(manage_data nirium-slh-v1), with the same first-key-only rule as pq. The
Horizon lookup is shared with pq.ts; pq behaviour is unchanged.

Off-chain check only: CAP-87 (Protocol 30) verifies ML-DSA, not SLH-DSA.
Node and CLI support come in separate PRs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Eras256
Eras256 requested a review from M0nsxx as a code owner December 5, 2026 20:32
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.

1 participant