veko doc
Self-Contained API Reference • Gradual Types • Capabilities • Wasm Sandbox

crypto/slhdsa

lib/crypto/slhdsa.vk

lib/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
signature
KeyPair = struct { param enum, pk bytes, sk bytes }

Key pair produced by slhdsa/keygen or slhdsa/keygen-deterministic.

signature
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
veko
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 ]
signature
keygen = fn [param enum] KeyPair

Generates a fresh SLH-DSA key pair using the OS/hardware CSPRNG.

signature
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
signature
sign = fn [param enum, sk bytes, msg bytes] bytes

Signs msg with SLH-DSA using fresh hedged CSPRNG randomness.

signature
verify = fn [param enum, pk bytes, msg bytes, sig bytes] bool

Verifies a FIPS 205 SLH-DSA signature against pk and msg.