Files
consensus/protocol/quasar/horizon_test.go
zeekay b4bb89df97 quasar: complete Ringtail purge — Corona (production R-LWE) + Nasua (academic upstream)
Followup to the QuasarCert field rename (commit 9b9bdda2). This sweeps
the remaining Ringtail identifiers and prose out of the consensus repo
entirely:

  - Identifiers (Go code):
    ringtailThreshold   → coronaThreshold      (import alias)
    ringtailGroupKey    → coronaGroupKey
    ringtailSigners     → coronaSigners
    ringtailShares      → coronaShares
    ringtailGobEncode   → coronaGobEncode
    ringtailGobDecode   → coronaGobDecode
    decodeRingtailSig   → decodeCoronaSig
    EncodeRingtailSig   → EncodeCoronaSig
    RingtailRound1{,Data,State} → CoronaRound1{,Data,State}
    RingtailGroupKey/Pub/Shares → Corona*

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

  - PQMode constants:
    PQModeRingtail            → PQModeNasua
    SigSchemeRingtailAcademic → SigSchemeNasua
    "ringtail" / "ringtail-academic" string forms → "nasua"

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

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

180 lines
3.5 KiB
Go

//go:build e2e
package quasar
import (
"context"
"testing"
"time"
)
func TestQuasar(t *testing.T) {
// Create event horizon
eh, err := New(1)
if err != nil {
t.Fatal(err)
}
// Add validator
if err := eh.hybrid.AddValidator("validator1", 100); err != nil {
t.Fatal(err)
}
// Start
ctx := context.Background()
if err := eh.Start(ctx); err != nil {
t.Fatal(err)
}
// Submit blocks from all chains
blocks := []*Block{
{Chain: "P-Chain", ID: [32]byte{1}, Height: 100, Data: []byte("p-data")},
{Chain: "X-Chain", ID: [32]byte{2}, Height: 200, Data: []byte("x-data")},
{Chain: "C-Chain", ID: [32]byte{3}, Height: 300, Data: []byte("c-data")},
}
for _, b := range blocks {
b.Timestamp = time.Now()
eh.Submit(b)
}
time.Sleep(100 * time.Millisecond)
// Check metrics
height, processed, _ := eh.Stats()
if processed != 3 {
t.Errorf("want 3 blocks, got %d", processed)
}
if height != 3 {
t.Errorf("want height 3, got %d", height)
}
// Verify finality using computed hash
hash := computeBlockHash(blocks[0])
if !eh.Verify(hash) {
t.Error("block not finalized")
}
t.Logf("✓ All chains processed: height=%d blocks=%d", height, processed)
}
func TestAutoRegister(t *testing.T) {
eh, err := New(1)
if err != nil {
t.Fatal(err)
}
if err := eh.hybrid.AddValidator("validator1", 100); err != nil {
t.Fatal(err)
}
ctx := context.Background()
if err := eh.Start(ctx); err != nil {
t.Fatal(err)
}
// Submit from unregistered chain - should auto-register
bridge := &Block{
Chain: "Bridge",
ID: [32]byte{0xFF},
Height: 1,
Timestamp: time.Now(),
Data: []byte("bridge-tx"),
}
eh.Submit(bridge)
time.Sleep(100 * time.Millisecond)
// Check chain registered
chains := eh.Chains()
found := false
for _, c := range chains {
if c == "Bridge" {
found = true
}
}
if !found {
t.Error("Bridge not auto-registered")
}
t.Logf("✓ Bridge auto-registered: %v", chains)
}
func TestQuantumSignatures(t *testing.T) {
eh, err := New(1)
if err != nil {
t.Fatal(err)
}
if err := eh.hybrid.AddValidator("validator1", 100); err != nil {
t.Fatal(err)
}
ctx := context.Background()
if err := eh.Start(ctx); err != nil {
t.Fatal(err)
}
// Submit block
block := &Block{
Chain: "C-Chain",
ID: [32]byte{0xAA},
Height: 1,
Timestamp: time.Now(),
Data: []byte("test"),
}
eh.Submit(block)
time.Sleep(100 * time.Millisecond)
// Get finalized block hash
hash := computeBlockHash(block)
// Verify the block is finalized
if !eh.Verify(hash) {
t.Fatal("block not finalized")
}
t.Log("✓ Block finalized with hybrid signatures (BLS + Corona)")
}
func TestMultiChain(t *testing.T) {
eh, err := New(1)
if err != nil {
t.Fatal(err)
}
if err := eh.hybrid.AddValidator("validator1", 100); err != nil {
t.Fatal(err)
}
ctx := context.Background()
if err := eh.Start(ctx); err != nil {
t.Fatal(err)
}
// Submit from many chains
chains := []string{"Bridge", "Oracle", "Gaming", "DeFi", "ZK"}
for i, name := range chains {
block := &Block{
Chain: name,
ID: [32]byte{byte(i)},
Height: uint64(i + 1),
Timestamp: time.Now(),
Data: []byte(name),
}
eh.Submit(block)
}
time.Sleep(500 * time.Millisecond)
// All chains should be registered
registered := eh.Chains()
if len(registered) < 8 { // 3 primary + 5 external
t.Errorf("want ≥8 chains, got %d", len(registered))
}
t.Logf("✓ %d chains in event horizon: %v", len(registered), registered)
}