crypto/slhdsa
lib/crypto/slhdsa.vklib/crypto/slhdsa.vk
Pure-Veko FIPS 205 SLH-DSA (Stateless Hash-Based Digital Signature Algorithm, SPHINCS+):
Supports SLH-DSA-SHAKE-128f and SLH-DSA-SHAKE-128s over FIPS 202 SHAKE256 (crypto/sha3).
Zero capabilities required.
KeyPair = struct { param enum, pk bytes, sk bytes }
Key pair produced by slhdsa/keygen or slhdsa/keygen-deterministic.
keygen-deterministic = fn [param enum, sk_seed bytes, sk_prf bytes, pk_seed bytes] KeyPair
Deterministic FIPS 205 SLH-DSA key generation from three n-byte seeds (sk_seed, sk_prf, pk_seed).
Executable Example
use [slh = crypto/slhdsa]
s1 = bytes/fill 16 0x01
s2 = bytes/fill 16 0x02
s3 = bytes/fill 16 0x03
kp = slh/keygen-deterministic .shake_128f s1 s2 s3
msg = bytes/from-str 'stateless hash-based veko signature'
sig = slh/sign-deterministic .shake_128f kp.sk msg (bytes/fill 16 0)
ok = slh/verify .shake_128f kp.pk msg sig
bad = slh/verify .shake_128f kp.pk (bytes/from-str 'bad') sig
if (not ok) or bad or (len kp.pk) != 32 [ err 'slhdsa-shake-128f failed' ] else [ .ok ]
keygen = fn [param enum] KeyPair
Generates a fresh SLH-DSA key pair using the OS/hardware CSPRNG.
sign-deterministic = fn [param enum, sk bytes, msg bytes, opt_rand bytes] bytes
Deterministic FIPS 205 SLH-DSA signing (empty pure-mode context) with explicit 16-byte opt_rand.
sign = fn [param enum, sk bytes, msg bytes] bytes
Signs msg with SLH-DSA using fresh hedged CSPRNG randomness.
verify = fn [param enum, pk bytes, msg bytes, sig bytes] bool
Verifies a FIPS 205 SLH-DSA signature against pk and msg.