Files
zeekay 0142367b60 consensus: route corona + pulsar through threshold/protocols alias
Replaces every direct import of luxfi/corona/* and luxfi/pulsar/ref/go
in consensus with the canonical luxfi/threshold/protocols/{corona,pulsar}
alias surface. Pure import swap + go.mod bump; no behaviour change.

Files touched (16):

  bench/pq_modes_bench_test.go
  engine/pq/crypto.go
  engine/pq/engine.go
  pkg/wire/policies.go
  protocol/quasar/cert_size_compare_test.go
  protocol/quasar/corona_gob.go
  protocol/quasar/dual_threshold_test.go
  protocol/quasar/epoch.go
  protocol/quasar/epoch_test.go
  protocol/quasar/gpu_accel.go
  protocol/quasar/grouped_threshold.go
  protocol/quasar/quasar.go
  protocol/quasar/types.go
  protocol/quasar/wave_signer.go
  protocol/quasar/wave_signer_test.go
  protocol/quasar/witness.go
  protocol/quasar/witness_pulsar_test.go

Import path swaps:

  luxfi/corona/threshold        -> luxfi/threshold/protocols/corona
  luxfi/corona/keyera           -> luxfi/threshold/protocols/corona/keyera
  luxfi/corona/primitives       -> luxfi/threshold/protocols/corona/primitives
  luxfi/corona/reshare          -> luxfi/threshold/protocols/corona/reshare
  luxfi/corona/sign             -> luxfi/threshold/protocols/corona/sign
  luxfi/corona/gpu              -> luxfi/threshold/protocols/corona/gpu
  luxfi/pulsar/ref/go/pkg/pulsar -> luxfi/threshold/protocols/pulsar

The aliased package name "coronaThreshold" used by quasar / engine/pq /
pkg/wire identifiers is preserved at the call sites (it now refers to
the threshold/protocols/corona alias package). engine/pq/crypto.go is
the only file where the package was bare-imported as `threshold`; that
identifier was renamed to `corona` to match the new alias path.

go.mod:

  - luxfi/threshold bumped to a branch pseudo-version that carries the
    new alias subpackages; will pin to a stable tag once threshold's
    companion commit lands and a release is cut.
  - luxfi/corona and luxfi/pulsar drop to indirect (consensus now
    reaches them only via threshold/protocols).
  - luxfi/math v1.4.0 -> v1.4.1 and luxfi/metric v1.5.0 -> v1.5.7 are
    transitive minimum-version bumps pulled by the new threshold
    requirement; they are no-op for consensus call sites.

Comment-only references to "github.com/luxfi/corona/..." in bls.go,
round_digest.go, reshare_epoch.go, comprehensive_test.go,
engine_test.go, quasar_bench_test.go and config/pq_mode.go are
documentation pointers to where the underlying implementation lives;
they are accurate either way and are left unchanged (out of refactor
scope).

Layering shape after:

  consensus -> threshold/protocols/{corona,pulsar}  (stable alias)
                 |
                 v
              luxfi/corona, luxfi/pulsar  (primitive implementations)

Closes the 22-file layering violation flagged by the 2026-05-31
integration audit. Tests pass: ./engine/pq/..., ./pkg/wire/...,
./protocol/quasar/... (all key cases — TestEpochManager*,
TestRoundSigner*, TestVerifyPQFinality*, TestBLSThreshold*,
TestDualSigningFlow, TestCoronaCertSize* — green; the pre-existing
TestGroupedEpochManager_ParallelKeygen perf-bound flake on slow
machines was reproduced on unmodified main, so it is not a
regression).
2026-05-31 12:39:47 -07:00

60 lines
2.3 KiB
Go

// Copyright (C) 2025-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package quasar
// gpu_accel.go — opt corona's R-LWE threshold signing into the
// lattice GPU NTT dispatch path.
//
// The corona/gpu package owns ALL build-tag plumbing for the GPU NTT
// dispatcher. quasar speaks to it through a single function call. On a
// pure-Go build the call is harmless: corona/gpu.MaybeRegister becomes
// a no-op and the existing CPU path runs.
//
// Wired here (rather than in NewSigner) because:
// 1. UseAccelerator() is idempotent and global — once is enough.
// 2. Subsequent coronaThreshold.NewParams calls (which build the
// rings) consult the global flag via corona/gpu.MaybeRegister and
// bind their SubRings into the lattice GPU registry.
// 3. Tests that exercise the CPU path do so by calling
// DisableCoronaGPUAccelerator() in a t.Cleanup hook.
import (
cgpu "github.com/luxfi/threshold/protocols/corona/gpu"
)
// UseCoronaGPUAccelerator opts every subsequent coronaThreshold
// signer into the lattice GPU NTT dispatch path. Idempotent. Safe to
// call from package init or from boot configuration before any signer
// is constructed.
//
// Returns the corona/gpu UseAccelerator error verbatim — currently
// always nil; reserved for future surface that might fail (e.g. an
// explicit Metal device probe).
//
// Defaults to a conservative SubRing dispatch threshold that excludes
// corona's production N=256 ring (see corona/gpu.UseAccelerator for
// rationale). Operators can lower the threshold via
// corona/gpu.SetThreshold once a batched GPU path is plumbed through.
func UseCoronaGPUAccelerator() error {
return cgpu.UseAccelerator()
}
// DisableCoronaGPUAccelerator clears the opt-in flag and resets the
// SubRing dispatch threshold to 0. Subsequent NewParams() calls in
// corona will leave their rings on the CPU NTT path.
func DisableCoronaGPUAccelerator() {
cgpu.DisableAccelerator()
}
// CoronaGPUAcceleratorEnabled reports whether the opt-in flag is set.
func CoronaGPUAcceleratorEnabled() bool {
return cgpu.Enabled()
}
// CoronaGPUBackend returns the active GPU backend name ("Metal",
// "CUDA", or a CPU descriptor) for diagnostic logging.
func CoronaGPUBackend() string {
return cgpu.Backend()
}