mirror of
https://github.com/luxfi/crypto.git
synced 2026-10-30 16:59:13 +00:00
Adds the SLH-DSA / Magnetar (FIPS 205) batched sign fast path and the
canonical FIPS 205 parameter table.
Three tier dispatch ladder for SignBatch:
1. GPU substrate via accel.LatticeOps.SLHDSASignBatch
2. Goroutine-parallel CPU sign across GOMAXPROCS workers
3. Serial CPU sign (cloudflare/circl, FIPS 205-conformant)
FIPS 205 SignDeterministic has no per-call randomness, so all three
tiers produce byte-identical signatures for any fixed (sk, msg). KAT
replay holds across the ladder.
New files
pq/slhdsa/doc.go - canonical entry point pointer (mirrors pq/mldsa)
pq/slhdsa/gpu/params.go - FIPS 205 §10 parameter table (12 sets)
pq/slhdsa/gpu/dispatch.go - mode-driven SignBatch / VerifyBatch
pq/slhdsa/gpu/gpu_test.go - catalogue + roundtrip + tamper-reject + bench
slhdsa/gpu_sign_test.go - canonical SignBatch round-trip + determinism
Modified
slhdsa/gpu.go - SignBatch + SignBatchGPU + signBatchConcurrent
(412 line expansion of the existing verify-only file)
slhdsa/slhdsa.go - GetPrivateKeySize accessor (FIPS 205 sk = 4n)
Deleted
pq/slhdsa/gpu/gpu.go - the "Available() bool { return false }" stub.
The replacement params.go + dispatch.go cover the
same surface with real semantics.
Bench (Apple M1 Max, CGO_ENABLED=0, batch SLH-DSA-SHA2-192f sign):
serial single-sig 69.0 ms/op
parallel n=1 150.9 ms/op (1 worker, fork overhead)
parallel n=2 (canon) 25.6 ms/sig (2.7x serial)
parallel n=8 (canon) 17.1 ms/sig (4.0x serial)
parallel n=21 (Lux quorum) 20.7 ms/sig (3.3x serial)
parallel n=32 22.9 ms/sig (3.0x serial)
Asymptotic speedup ~2.75x — bottlenecked by cloudflare/circl's scalar
SHA-256/SHAKE-256 (49% CPU time per pprof). Two routes to break 5x are
documented in gpu.go:
- Sloth / SHA-NI fork drops per-sign cost ~7x
- Metal/CUDA kernel substrate via luxcpp/crypto/slhdsa/gpu/{metal,cuda}/
The Go-side dispatch ladder routes through the GPU substrate as soon as
the C-API gains the strong symbol — no code change needed here.
Canonical Magnetar profile pinned: SLH-DSA-SHA2-192f (NIST L3).
CGO_ENABLED=0 go test -timeout 300s ./slhdsa/... -> 35s PASS
CGO_ENABLED=0 go test -timeout 300s ./pq/slhdsa/... -> 0.4s PASS (9 tests)
CGO_ENABLED=1 go test -timeout 300s ./slhdsa/... -> 97s PASS
CGO_ENABLED=1 go test -timeout 300s ./pq/slhdsa/... -> 0.3s PASS (9 tests)
30 lines
1.4 KiB
Go
30 lines
1.4 KiB
Go
// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
// Package slhdsa is the canonical Lux entry point for SLH-DSA
|
|
// (Stateless Hash-Based Digital Signature Algorithm, FIPS 205).
|
|
//
|
|
// The package is structured along two axes:
|
|
//
|
|
// 1. The full Mode catalogue (twelve parameter sets per FIPS 205 §10)
|
|
// lives in the github.com/luxfi/crypto/slhdsa subpackage. That is the
|
|
// canonical entry point for keygen, sign, verify, and KAT-replay.
|
|
//
|
|
// 2. The GPU/CPU-batched fast path lives in
|
|
// github.com/luxfi/crypto/pq/slhdsa/gpu. That package exposes the
|
|
// FIPS 205 §10 parameter table and a SignBatch / VerifyBatch dispatch
|
|
// that forwards into the canonical SignBatch / VerifyBatch with the
|
|
// full GPU → goroutine-parallel → serial fallback ladder.
|
|
//
|
|
// Canonical parameter sets used by the Lux validator quorum:
|
|
//
|
|
// - SLH-DSA-SHA2-192f (NIST Level 3, "fast" / Magnetar recovery profile)
|
|
// - SLH-DSA-SHA2-256f (NIST Level 5, "fast" / high-value tier)
|
|
//
|
|
// FIPS 205 SignDeterministic has no per-call randomness, so all three
|
|
// dispatch tiers (GPU substrate, goroutine-parallel CPU, serial CPU)
|
|
// produce byte-identical signatures for any fixed (sk, msg). KAT-level
|
|
// equivalence is asserted in the gpu/ test suite and in the canonical
|
|
// slhdsa package's kat_test.go.
|
|
package slhdsa
|