11 Commits
Author SHA1 Message Date
zeekayandHanzo Dev 65e1e36f78 test(bench): fix pq-modes build break — bench-local trusted-dealer fixture
`bench` (external package) referenced quasar.GenerateDualKeys, but the H-1
corona-genesis hardening (98fa4d04d) relocated that trusted-dealer keygen to a
package-private _test.go so no production code can route epoch/genesis keying
through a trusted dealer. Go's internal-test import-cycle rule leaves the
external bench unable to reach it, so `go test ./...` failed:

  bench/pq_modes_bench_test.go:321: undefined: quasar.GenerateDualKeys

Add a bench-local benchDualKeys fixture (also _test.go → still structurally
unreachable from production, H-1 preserved) and point pq_modes at it. No
production surface touched; re-exporting the helper would have regressed the
hardening. Full `go test ./...` now green (28 pkg, 0 fail).

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-03 15:44:04 -07:00
zeekay f3ab32c26c fix(bench): corona Signer.Round1 now returns (data, error) — handle the error (threshold v1.9.9 API) 2026-06-26 19:11:33 -07:00
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
zeekay faf3f78756 gofmt: cleanup after Corona purge identifier renames 2026-05-12 14:53:30 -07:00
zeekay f6753f3b53 quasar: complete Corona purge — Corona (production R-LWE) + Nasua (academic upstream)
Followup to the QuasarCert field rename (commit d1c8a2cc). This sweeps
the remaining Corona identifiers and prose out of the consensus repo
entirely:

  - Identifiers (Go code):
    coronaThreshold   → coronaThreshold      (import alias)
    coronaGroupKey    → coronaGroupKey
    coronaSigners     → coronaSigners
    coronaShares      → coronaShares
    coronaGobEncode   → coronaGobEncode
    coronaGobDecode   → coronaGobDecode
    decodeCoronaSig   → decodeCoronaSig
    EncodeCoronaSig   → EncodeCoronaSig
    CoronaRound1{,Data,State} → CoronaRound1{,Data,State}
    CoronaGroupKey/Pub/Shares → Corona*

  - File rename:
    protocol/quasar/corona_gob.go → corona_gob.go

  - PQMode constants:
    PQModeCorona            → PQModeNasua
    SigSchemeCoronaAcademic → SigSchemeNasua
    "corona" / "corona-academic" string forms → "nasua"

  - Prose & comments throughout the repo: "Corona" → "Corona" when
    naming the production Ring-LWE library, "Nasua" when naming the
    historical academic upstream (luxfi/nasua, formerly luxfi/corona).

Canonical Pulsar family taxonomy after this rename:

  Nasua  — academic R-LWE 2-round threshold sig (Boschini et al,
           ePrint 2024/1113); trusted-dealer DKG; kept as historical
           reference fork only. NOT for an open public chain.
  Corona — production Ring-LWE threshold ML-DSA (Pedersen DKG over R_q
           + proactive resharing); `github.com/luxfi/corona`. The
           Ring-LWE leg of QuasarCert.
  Pulsar — production Module-LWE threshold ML-DSA (FIPS 204
           byte-equal); `github.com/luxfi/pulsar`. The Module-LWE
           leg of QuasarCert. Pure-PQ pair = Corona + Pulsar.

Wire-format unchanged. Tests: 28/28 packages green (-short suite,
quasar 29s, integration 58s, no regressions).
2026-05-12 08:58:51 -07:00
zeekay d1c8a2cc28 quasar: rename Corona→Corona, MLDSAProof→MLDSARollup, drop "triple"
The Quasar cert layers are the right cardinality of "Double Lattice +
Identity Rollup + optional Classical Fast-path", not "Triple Quantum":

  BLS-12-381  classical fast-path (pairing) — empty in pure-PQ
  Corona      Ring-LWE  threshold ML-DSA (luxfi/corona; production R-LWE)
  Pulsar      Module-LWE threshold ML-DSA (luxfi/pulsar; Class N1 byte-equal
                                            to FIPS 204)
  MLDSARollup per-validator ML-DSA-65 rolled into one STARK / Groth16 proof
                                            (Z-Chain → P3Q)

"Triple Quantum" misled because BLS is classical — at most one of three
legs was quantum in the historic BLS+Corona+ZK shape. The honest PQ
cardinality is **Double Lattice** (Ring + Module). Pure-PQ profiles
drop BLS entirely and rely on Corona + Pulsar.

Corona is the academic R-LWE construction with trusted-dealer DKG;
it stays out of any open public-chain path. Corona is the production
Ring-LWE library (Pedersen DKG over R_q + proactive resharing).

Surface (in protocol/quasar/types.go):
  QuasarCert.BLS         → unchanged (classical fast-path, optional)
  QuasarCert.Corona    → QuasarCert.Corona       (Ring-LWE threshold sig)
  QuasarCert.MLDSAProof  → QuasarCert.MLDSARollup  (succinct identity rollup)
  QuasarCert            now also has a Pulsar field (Module-LWE threshold sig,
                                                     populated when wired)

  QuasarSig.Corona     → QuasarSig.Corona  (also added Pulsar []byte)
  FinalityEvent.Corona / MLDSAProof → Corona / Pulsar / MLDSARollup

  New predicates:
    QuasarCert.IsDoubleLattice()       — Corona ∧ Pulsar (honest PQ count)
    QuasarCert.HasClassicalFastPath()  — len(BLS) > 0
    QuasarCert.HasIdentityRollup()     — len(MLDSARollup) > 0

The wire byte layout is unchanged (length-prefixed slots). Callers that
read the bytes don't notice. Source-level references that compiled
before the rename now compile against the new identifiers; bulk
rename swept the consensus repo (22 files, 219 insertions, 151
deletions) plus the engine/pq facing FinalityEvent.

Tests: GOWORK=off go test -short -count=1 ./... → all 28 packages green
(quasar suite 32s; integration 60s; no regressions).
2026-05-12 08:40:06 -07:00
zeekay 9555ccb19c consensus: flip pulsar (R-LWE) imports to corona
Cross-cutting family-rename consumer update. consensus's R-LWE
threshold path now imports github.com/luxfi/corona/{hash,keyera,
reshare,threshold} (was github.com/luxfi/pulsar/*). The M-LWE
github.com/luxfi/pulsar-m import is untouched -- that path stays
until pulsar-m archives in favour of luxfi/pulsar v0.2.0 (next
phase).

go.mod adds replace directives for the local-dev family:
  github.com/luxfi/pulsar     => ../pulsar    (R-LWE legacy, kept for transitive deps)
  github.com/luxfi/corona     => ../corona    (R-LWE post-rename)
  github.com/luxfi/threshold  => ../threshold (locally-flipped)

protocol/quasar + protocol/zchain test suites green.
2026-05-11 15:02:15 -07:00
zeekay a96db628c1 bench: rename to current PQMode constants (BLS / MLDSA / Corona / Quasar)
config/pq_mode.go was renamed some time ago to the canonical
component-named constants (PQModeBLS, PQModeCorona, PQModePulsar,
PQModeQuasar, PQModeMLDSA) but bench/pq_modes_bench_test.go still
referenced the older surface (BLSOnly, BLSPlusMLDSA, BLSPlusCorona,
BLSPlusGroth16, TripleQuantum), which broke `go test ./...` package
compilation in CI.

Mapping applied:

  PQModeBLSOnly          -> PQModeBLS
  PQModeBLSPlusMLDSA     -> PQModeMLDSA
  PQModeBLSPlusCorona  -> PQModeCorona
  PQModeBLSPlusGroth16   -> PQModeQuasar   (Z-Chain Groth16 row)
  PQModeTripleQuantum    -> PQModeQuasar   (full BLS + Pulsar + Groth16)

Both Groth16-row and TripleQuantum bench cases now bucket under
PQModeQuasar - that matches the current model where Quasar IS the
BLS + Pulsar + Z-Chain Groth16 over ML-DSA stack. The two separate
bench functions still exist and produce distinct rows in the summary
because they exercise different sub-paths; only the printed mode label
collapses.

Pure rename of test-side identifiers; no production-code change.
2026-05-10 17:48:05 -07:00
zeekay f651395f50 Wire consensus PQ end-to-end: real BLS+Corona+ML-DSA
- protocol/quasar/types.go: QuasarCert MarshalBinary/UnmarshalBinary
  (length-prefixed wire layout, leading byte CertSchemeQuasar=0x04),
  VerifyWithRealKeys cryptographic verification, EncodeMLDSASigs helper
- protocol/quasar/corona_gob.go: gob serializer for pulsar/threshold
  Signature
- protocol/quasar/engine.go: Certifier.AttachSigner; generateCert drives
  signer.TripleSignRound1 (real BLS share + MLDSAProof). Falls back to
  legacy SHA-256 only when no signer attached
- engine/pq/engine.go: AttachSigner/AttachVerifyKeys; VerifyQuantumSignature
  decodes QuasarCert + runs VerifyWithRealKeys; GenerateQuantumProof
  emits serialized QuasarCert
- engine/pq/crypto.go: ML-DSA-65 keypair; real GeneratePQSignature
- engine/pq/consensus.go: PQMode field; resolves via config.PQModeFromEnv
- config/pq_mode.go: PQMode enum (BLSOnly | BLSPlusMLDSA | BLSPlusCorona
  | BLSPlusGroth16 | TripleQuantum), LUX_CONSENSUS_PQ_MODE env support
- pkg/wire/policies.go: QuantumPolicy serializes real QuasarCert into
  cert.Proof; Verify decodes via UnmarshalBinary; VerifyWithKeys does
  cryptographic verification
- engine/gpu_batch_pipeline.go: gpuAvailable() wired to accel.Available();
  verifyBLSBatchGPU calls accel.BLSBatchVerify
- bench/pq_modes_bench_test.go: 5 PQ mode benches with real BLS aggregate,
  real ML-DSA-65, real Corona 2-round threshold. Storage projection
  comparison.

1237 tests pass.

Bench results (Apple M1, n=21):
  Mode             Sign     Agg      Verify   Cert     Storage 10K
  bls              312µs    8.6ms    714µs    123 B    1.17 MB
  bls-mldsa        369µs    8.5ms    3.4ms    69 KB    665 MB
  bls-rt           39ms     3.3s     1.6ms    33 KB    318 MB
  triple           40ms     3.3s     4.3ms    102 KB   981 MB
2026-05-05 10:14:09 -07:00
zeekay 0222a14240 ai: add comprehensive model state and utility tests (35.0% coverage)
Added tests for previously untested model functions:
- ValidateProposal (91.7% coverage)
- UpdateWeights with gradient validation
- GetState (full coverage)
- LoadState (90.0% coverage)
- Utility functions (hashComplexity, addressEntropy, versionEntropy)
- Edge cases for feature extractors

Test count: 86 tests total
Coverage improved: 31.3% → 35.0%

Remaining low coverage:
- engine.go: RemoveModule, GetModule (simple accessors)
- modules.go: processProposal, processVote (require full integration)
- specialized.go, integration.go, bridge.go, xchain.go (integration heavy)
2025-11-06 04:13:15 -08:00
zeekay d729e2c629 fix: remove unused math/rand import from bench tool
- Remove unused math/rand import that was left after removing rand.Seed
- Keep rand import in sim tool since rand.Float64() is still used
- Fix build error in bench package
2025-08-22 04:58:43 -05:00