SLH-DSA (SPHINCS+, NIST FIPS 205) ist ein hash-basiertes Post-Quantum-Signaturverfahren. Die Sicherheit beruht ausschließlich auf der Kollisionsresistenz von SHA-256 — keine gittertheoretischen Annahmen wie bei ML-DSA.
Klassifikation: Asymmetrisches, hash-basiertes Signaturverfahren. Zustandslos (stateless) — keine Signaturzähler nötig wie bei XMSS/LMS.
import std.crypto.pqc.slhdsa;
→ std.crypto.pqc · std.crypto.pqc.pqc (High-Level API) · std.crypto
| Parametersatz | n | h | Quantensicherheit | SK | PK | Signatur | Empfehlung |
|---|---|---|---|---|---|---|---|
| SLH-DSA-SHA2-128s | 16 | 63 | ~128-Bit | 64 B | 32 B | 7856 B | Standardwahl |
| SLH-DSA-SHA2-256s | 32 | 64 | ~256-Bit | 128 B | 64 B | 29792 B | Höchste Sicherheit |
| Mini (nicht FIPS) | 16 | 4 | — | 64 B | 32 B | 1392 B | Nur für Tests |
Vergleich mit ML-DSA: SLH-DSA erzeugt größere Signaturen (7856 B vs. 3293 B für ~128-Bit), hat aber kleinere Schlüssel (PK nur 32 B). Vorteil: rein hash-basierte Sicherheitsannahmen, breit konservativ.
| Konstante | Wert | Bedeutung |
|---|---|---|
SLH_128S_SK | 64 | SK-Größe SLH-DSA-128s in Bytes |
SLH_128S_PK | 32 | PK-Größe SLH-DSA-128s in Bytes |
SLH_128S_SIG | 7856 | Signaturlänge SLH-DSA-128s in Bytes |
SLH_256S_SK | 128 | SK-Größe SLH-DSA-256s in Bytes |
SLH_256S_PK | 64 | PK-Größe SLH-DSA-256s in Bytes |
SLH_256S_SIG | 29792 | Signaturlänge SLH-DSA-256s in Bytes |
SLH_MINI_SIG | 1392 | Signaturlänge Mini-Params (nicht FIPS) |
SLH_PS | 96 | Größe des Parameter-Blocks in Bytes |
ADRS-Typ-Codes (intern, für eigene ADRS-Konstruktionen):
SLH_WOTS=0, SLH_WOTS_PK=1, SLH_TREE=2, SLH_FORS_TREE=3, SLH_FORS_ROOTS=4, SLH_WOTS_PRF=5, SLH_FORS_PRF=6
Parameter-Initialisierung (muss vor KeyGen/Sign/Verify aufgerufen werden):
| Funktion | Beschreibung |
|---|---|
SLHParams128s(ps) | Füllt 96-Byte-Parameterblock ps für SLH-DSA-SHA2-128s |
SLHParams256s(ps) | Füllt 96-Byte-Parameterblock ps für SLH-DSA-SHA2-256s |
SLHParamsMini(ps) | Füllt Parameterblock für Mini-Satz (n=16, h=4 — nur Tests, nicht FIPS-konform) |
Schlüssel und Signatur:
| Funktion | Beschreibung |
|---|---|
SLHDSAKeyGen(ps, skseed, skprf, pkseed, sk, pk) | Erzeugt Schlüsselpaar aus drei Seeds (je n Bytes). sk: SLH_xxx_SK Bytes; pk: SLH_xxx_PK Bytes. |
SLHDSASign(ps, sk, msg, mlen, optrand, sig): int64 | Signiert msg (mlen Bytes). optrand: 0 für deterministische Signatur (empfohlen). sig: caller-alloziert mit SLH_xxx_SIG Bytes. Gibt tatsächliche Signaturlänge zurück. |
SLHDSAVerify(ps, pk, msg, mlen, sig): int64 | Verifiziert Signatur. Gibt 1 bei gültig, 0 bei ungültig. |
import std.crypto.pqc.slhdsa;
import std.crypto.rand;
import std.alloc;
fn main(): int64 {
// Parameter-Block initialisieren (SLH-DSA-128s)
var ps: int64 := alloc(SLH_PS);
SLHParams128s(ps);
// Seeds: skseed[16], skprf[16], pkseed[16] (n=16 für 128s)
var seeds: int64 := alloc(48);
RandBytesExact(seeds, 48);
// Schlüsselpaar erzeugen
var sk: int64 := alloc(SLH_128S_SK);
var pk: int64 := alloc(SLH_128S_PK);
SLHDSAKeyGen(ps, seeds, seeds + 16, seeds + 32, sk, pk);
// Signieren
var msg: pchar := "Hello, SLH-DSA!"c;
var m_len: int64 := 15;
var sig: int64 := alloc(SLH_128S_SIG);
var sig_len: int64 := SLHDSASign(ps, sk, msg as int64, m_len, 0, sig);
// Verifizieren
var ok: int64 := SLHDSAVerify(ps, pk, msg as int64, m_len, sig);
// ok == 1 wenn gültig
free(ps, SLH_PS); free(seeds, 48);
free(sk, SLH_128S_SK); free(pk, SLH_128S_PK);
free(sig, SLH_128S_SIG);
return 0;
}
Hinweis: Für den einfachsten Einstieg → std.crypto.pqc.pqc verwenden (kein manuelles Parameter-Block-Management).
| Eigenschaft | Ergebnis |
|---|---|
| NIST-Standard | FIPS 205 (2024) — offiziell standardisiert |
| Sicherheitsannahme | Nur SHA-256-Kollisionsresistenz (konservativste aller PQC-Optionen) |
| Quantensicherheit | ~128-Bit (128s) / ~256-Bit (256s) |
| Signatur-Overhead | 7856 B (128s) — größer als ML-DSA, aber kleinster Public Key (32 B) |
| Zustandslos | Ja — keine Signaturzähler nötig (anders als XMSS/LMS) |
Letzte Aktualisierung: 2026-06-08