Quasar upgrades traditional consensus mechanisms with a Quantum Finality engine. Quasar combines traditional BLS signature aggregation with parallel lattice encryption to deliver 2-round finality with both classical and quantum security. Every chain in the Lux primary network - Q, C, X - run Quasar, reaching Quantum Finality, in < 1 second.
Traditional consensus engines have limitations:
- Different engines for different chain types
- No native post-quantum security
- Complex multi-layer architecture
Quasar solves all these with "One engine to rule them all":
- Unified Protocol: Same engine for DAG, linear, EVM, MPC chains
- Quantum Finality: Every block requires post quantum certificates
- 2-Round Total: BLS Signatures (1 round) + Lattice Signatures (2 phases) = quantum finality
- Zero Leaders: Fully decentralized, leaderless, highly secure
- Sub-Second Performance: <1s finality with quantum security
- NEW: Complete package restructure with shallow, obvious paths
- NEW: Single-import convenience for all SDKs (Go, Python, Rust)
- NEW: Unified
consensus.ChainAPI replacing complex factory patterns - NEW: Type aliases for zero-friction development
- BREAKING: Migrated from deep nested paths to clean root exports
- NEW: Complete C implementation with optimized hash tables (9M+ blocks/sec)
- NEW: Rust FFI bindings with safe wrappers and Criterion benchmarks
- NEW: Python SDK via Cython with Pythonic API (6.7M blocks/sec)
- NEW: Go CGO integration for seamless C/Go switching
- NEW: Quantum-resistant OP Stack integration example
- 100% test parity across all 4 language implementations
- 15 comprehensive test categories with full coverage
- Performance benchmarks exceeding all targets
- Replaced
Sampler/Samplepattern with light-themedEmitter/Emit - Implemented luminance tracking (10-1000 lux range) for node selection
- Performance-based weighting adjusts selection probability
- 96%+ test coverage maintained
- CI fully green with all lint checks passing
go get github.com/luxfi/consensus@v1.22.0cd consensus/c
make && sudo make install
# Enable with: CGO_ENABLED=1 USE_C_CONSENSUS=1# Add to Cargo.toml
[dependencies]
lux-consensus = "1.22.0"cd consensus/python
python3 setup.py install
# Or: pip install lux-consensusimport "github.com/luxfi/consensus" // Single clean import!
// Create chain with default config
chain := consensus.NewChain(consensus.DefaultConfig())
// Start the chain
ctx := context.Background()
if err := chain.Start(ctx); err != nil {
panic(err)
}
defer chain.Stop()
// Add a block
block := &consensus.Block{
ID: consensus.NewID(),
ParentID: consensus.GenesisID,
Height: 1,
Payload: []byte("Hello, Lux!"),
}
if err := chain.Add(ctx, block); err != nil {
panic(err)
}# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run benchmarks
go test -bench=. ./...consensus/
โโโ photon/ # ๐ K-of-N committee selection (NEW)
โ โโโ emitter.go # Light emission-based peer selection
โ โโโ luminance.go # Node brightness tracking (lux units)
โ
โโโ core/
โ โโโ wave/ # ๐ Wave consensus mechanism
โ โ โโโ engine.go # Threshold voting (ฮฑ, ฮฒ parameters)
โ โโโ dag/ # ๐ DAG structure & ordering
โ โ โโโ flare/ # Certificate generation
โ โ โโโ horizon/ # Frontier management
โ โโโ focus/ # ๐ฏ Confidence tracking
โ
โโโ protocol/
โ โโโ quasar/ # โ๏ธ Post-quantum security
โ โ โโโ ringtail.go # Quantum-resistant signatures
โ โโโ nebula/ # โ๏ธ State sync protocol
โ โโโ nova/ # โญ Parallel chain support
โ
โโโ qzmq/ # ๐ Post-quantum transport
โ โโโ session.go # Hybrid key exchange
โ โโโ messages.go # Wire protocol
โ
โโโ engine/ # ๐ฎ Consensus engines
โโโ chain/ # Linear blockchain
โโโ dag/ # DAG-based chains
Quasar is built on two core components that provide both classical and quantum finality:
- Sampling: k-peer sampling for vote collection
- Confidence: Build confidence d(T) through repeated sampling
- Thresholds: ฮฒโ for early preference, ฮฒโ for decision
- Time: ~600-700ms to classical finality
- Phase I - Propose: Sample DAG frontier, propose highest confidence
- Phase II - Commit: Aggregate threshold signatures if > ฮฑ๐ agree
- Certificates: Lattice-based post-quantum certificates
- Time: ~200-300ms additional for quantum finality
Every block header now contains:
type CertBundle struct {
BLSAgg []byte // 96B BLS aggregate signature
PQCert []byte // ~3KB lattice certificate
}
// Block is only final when BOTH certificates are valid
isFinal := verifyBLS(blsAgg, quorum) && verifyPQ(pqCert, quorum)| Layer | Key Type | Purpose | Storage |
|---|---|---|---|
| Node-ID | ed25519 | P2P transport auth | $HOME/.lux/node.key |
| Validator-BLS | bls12-381 | Fast finality votes | $HOME/.lux/bls.key |
| Validator-PQ | lattice | PQ finality shares | $HOME/.lux/rt.key |
| Wallet (EVM) | secp256k1 or Lamport | User tx signatures | In wallet |
| Wallet (X-Chain) | secp256k1 or Dilithium | UTXO locking | In wallet |
The same rt.key registered on Q-Chain is reused by all chains - no extra onboarding.
package main
import (
"context"
"log"
"github.com/luxfi/consensus/config"
"github.com/luxfi/consensus/engine/quasar"
"github.com/luxfi/ids"
)
func main() {
// 1. Configure Quasar parameters
cfg := config.Parameters{
K: 21, // Validators to sample
AlphaPreference: 15, // Preference threshold
AlphaConfidence: 18, // Confidence threshold
Beta: 8, // Finalization rounds
QRounds: 2, // Quantum rounds
}
// 2. Create Quasar engine
nodeID := ids.GenerateNodeID()
engine := quasar.NewQuasar(cfg, nodeID)
// 3. Initialize with both BLS and PQ keys
engine.Initialize(ctx, blsKey, pqKey)
// 4. Process vertices/blocks
engine.AddVertex(ctx, vertex)
// 5. Dual-certificate finality
engine.SetFinalizedCallback(func(qBlock QBlock) {
log.Printf("Q-block %d finalized with quantum certificates\n", qBlock.Height)
})
}| Network | Validators | Finality | Block Time | Configuration |
|---|---|---|---|---|
| Mainnet | 21 | 9.63s | 200ms | Production ready |
| Testnet | 11 | 6.3s | 100ms | Testing network |
| Local | 5 | 3.69s | 10ms | Development |
| X-Chain | 5 | 5ms | 1ms | 100Gbps networks |
| Component | Operation | Time/Op | Memory | Allocations |
|---|---|---|---|---|
| Wave Consensus | Vote Round | 3.38ฮผs | 2.3KB | 8 allocs |
| Photon Emitter | K-of-N Selection | 3.03ฮผs | 3.0KB | 2 allocs |
| Luminance | Brightness Update | 72ns | 0B | 0 allocs |
| Quasar | Phase I | 0.33ns | 0B | 0 allocs |
| Quasar | Phase II | 40.7ns | 0B | 0 allocs |
Both BLS and post-quantum certificates complete within one consensus slot.
- Pre-quantum: Attacker must corrupt โฅโ stake to fork
- Q-day (BLS broken): Attacker can forge BLS but not lattice
- Block fails quantum check
- Consensus halts rather than accepting unsafe fork
- Post-quantum: Security rests on lattice SVP (2ยนโถโฐ ops)
Attack window โค PQ round time (โค50ms mainnet).
| Chain | Integration | Rule |
|---|---|---|
| Q-Chain | Q-blocks as internal txs | All chains read Q-blocks |
| C-Chain | Every block has CertBundle | Invalid without quantum certs |
| X-Chain | Vertex metadata references Q-block | Epoch sealed by quantum cert |
| M-Chain | MPC rounds reference Q-block height | Custody requires PQ proof |
- Lamport-XMSS multisig contracts
- Gas: ~300k for VERIFY_LAMPORT
- EIP-4337 AA wrapper available
- New LatticeOutput type with PQ pubkey
- Spend verifies single RT signature (~1.8KB)
- CLI:
lux-wallet generate --pq
# Interactive parameter tuning
consensus params tune
# Distributed benchmark with Quasar
consensus bench --engine quasar
# Simulate quantum state progression
consensus sim --quantum
# Analyze quantum-certificate safety
consensus check --quantum-cert| Priority | Task | Status |
|---|---|---|
| P0 | Quasar engine core (Nova + Quasar) | โ Complete |
| P0 | Quantum-certificate block headers | โ Complete |
| P0 | Quantum key generation & registration | In Progress |
| P1 | Quasar service with precompute | Planned |
| P1 | PQ account options (Lamport) | โ Complete |
| P1 | PQ account options (Dilithium) | Planned |
# Unit tests with quantum scenarios
go test ./engine/quasar/...
# Benchmark dual-certificate performance
go test -bench=QuantumCert ./lattice/
# Fuzz test certificate aggregation
go test -fuzz=Certificate ./testing/Quasar is not an add-on or extra layer - it IS the consensus engine for Lux. By combining Nova DAG with Quasar PQ in a unified protocol, Quasar delivers:
- 2-round finality with both classical and quantum security
- Dual certificates required for every block
- One engine for all chain types
- Sub-second performance even with PQ security
Welcome to the quantum era of consensus.
BSD 3-Clause โ free for academic & commercial use. See LICENSE.