mirror of
https://github.com/luxfi/crypto.git
synced 2026-07-27 01:54:50 +00:00
Adds Provenance() on slhdsa/mldsa packages so reviewers can ask the running binary "which dispatch tier is live right now?" instead of trusting a static claim. Honest by construction: a release build without the SLH-DSA / ML-DSA backend plugin reports TierAccelCPUFallback or TierGoroutineParallelCPU, never TierGPUSubstrate. The strong-symbol observation is recorded by batchVerifyGPU / batchSignGPU after a successful C ABI dispatch; subsequent GetProvenance() calls report TierGPUSubstrate. The cache only goes 0 -> 1 so transient tensor allocation failures cannot regress provenance to "no plugin". mldsa/batch.go: 3-tier dispatch (GPU -> goroutine-parallel CPU -> serial CPU), mirroring slhdsa. concurrentBatchThreshold=8 tuned for the FIPS 204 verify cost. ML-DSA-44 and ML-DSA-87 batch tests pin KAT replay + CPU/GPU equivalence + tamper rejection across the dispatch tiers. Previously only ML-DSA-65 had this coverage. Removed dead pq/slhdsa/gpu/gpu.go (replaced by the live dispatcher in slhdsa/gpu.go).
30 lines
1008 B
Go
30 lines
1008 B
Go
// Copyright (C) 2020-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package mldsa
|
|
|
|
import "testing"
|
|
|
|
func TestProvenance_NonEmpty(t *testing.T) {
|
|
p := GetProvenance()
|
|
if p.Tier == TierUnknown {
|
|
t.Fatal("GetProvenance returned TierUnknown — dispatcher cannot determine its own state")
|
|
}
|
|
if p.BatchThresholdN <= 0 {
|
|
t.Errorf("BatchThresholdN = %d", p.BatchThresholdN)
|
|
}
|
|
if p.ConcurrentThresholdN <= 0 {
|
|
t.Errorf("ConcurrentThresholdN = %d", p.ConcurrentThresholdN)
|
|
}
|
|
t.Logf("ML-DSA dispatch provenance: tier=%s accel=%v device=%v plugin_strong=%v batch_threshold=%d concurrent_threshold=%d",
|
|
p.Tier, p.AccelInitialised, p.DeviceAvailable, p.PluginStrongSymbol,
|
|
p.BatchThresholdN, p.ConcurrentThresholdN)
|
|
}
|
|
|
|
func TestProvenance_NoFalseGPUClaim(t *testing.T) {
|
|
p := GetProvenance()
|
|
if p.Tier == TierGPUSubstrate && !p.PluginStrongSymbol {
|
|
t.Fatalf("Provenance reports TierGPUSubstrate but PluginStrongSymbol=false — false GPU claim")
|
|
}
|
|
}
|