quasar

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

README

Quasar - Quantum-Secure Consensus Protocol Family

Overview

The Quasar consensus protocol family is Lux Network's quantum-secure consensus implementation. Like Avalanche's Snow family, Quasar provides a modular consensus framework that can be adapted for different blockchain architectures.

Protocol Family

Quasar builds upon our existing consensus stages:

Photon → Wave → Focus → Beam/Flare → Nova → Quasar

Each stage provides specific functionality:

  • Photon: Binary consensus on single bit
  • Wave: Multi-bit consensus
  • Focus: Confidence aggregation
  • Beam: Linear chain consensus (Snowman++ equivalent)
  • Flare: State synchronization
  • Nova: DAG-based consensus
  • Quasar: Quantum-secure overlay with dual-certificate finality

Core Innovation: Dual-Certificate Finality

Quasar achieves quantum security through dual-certificate finality:

// Block is final IFF both certificates are valid
isFinal = verifyBLS(blsAgg, Q) && verifyRT(rtCert, Q)
  • BLS Certificate: Classical security using BLS12-381 aggregated signatures
  • Ringtail Certificate: Post-quantum security using lattice-based threshold signatures

Architecture

/quasar/
├── choices/          # Consensus decision states
├── consensus/        # Core consensus algorithms
│   ├── beam/        # Linear chain consensus
│   └── nova/        # DAG consensus
├── crypto/          # Cryptographic primitives
│   ├── bls/         # BLS signatures
│   └── ringtail/    # Post-quantum signatures
├── engine/          # Consensus engines
│   ├── common/      # Shared engine code
│   ├── beam/        # Beam consensus engine
│   └── nova/        # Nova consensus engine
├── networking/      # Network layer
│   ├── handler/     # Message handlers
│   ├── router/      # Message routing
│   └── sender/      # Message sending
├── validators/      # Validator management
└── uptime/         # Validator uptime tracking

Flow of a Single Blockchain

1. Transaction Submission

Users submit transactions to any node in the network. These transactions are gossiped to all nodes using the P2P layer.

2. Block Proposal

When a validator's turn comes (based on VRF or round-robin), they:

  1. Collect transactions from mempool
  2. Create a new block
  3. Sign with BLS private key
  4. Generate Ringtail share using precomputed data
  5. Broadcast block proposal
3. Share Collection

Other validators:

  1. Verify the proposed block
  2. Generate their own Ringtail shares
  3. Send shares to the proposer
4. Certificate Aggregation

The proposer:

  1. Collects BLS signatures (happens automatically)
  2. Collects Ringtail shares until threshold reached
  3. Aggregates into dual certificates
  4. Attaches certificates to block
5. Consensus

Validators poll each other:

  1. Verify both BLS and Ringtail certificates
  2. Vote accept/reject based on dual-cert validity
  3. Achieve consensus through repeated sampling
6. Finalization
  • Block is finalized when supermajority agrees
  • Finality requires both certificates valid
  • Missing Ringtail = proposer slashed

Performance Characteristics

Mainnet (21 validators)
  • Block time: 500ms
  • Dual-cert finality: <350ms
  • BLS aggregation: ~295ms
  • Ringtail aggregation: ~7ms
  • Network overhead: ~50ms
Quantum Security
  • Attack window: <50ms (Quasar timeout)
  • Lattice security: 128-bit post-quantum
  • Automatic slashing for quantum attacks

Components

P2P Layer

Handles all inter-node communication:

  • Handshake: Version negotiation
  • State Sync: Fast sync to current state
  • Bootstrapping: Full chain synchronization
  • Consensus: Voting and certificate exchange
  • App Messages: VM-specific communication
Router

Routes messages to appropriate chains using ChainID. Handles timeouts adaptively based on network conditions.

Handler

Processes incoming messages:

  • Sync queue: State sync, bootstrapping, consensus
  • Async queue: App messages
  • Manages message ordering and delivery
Sender

Builds and sends outbound messages:

  • Registers timeouts for responses
  • Benches unresponsive nodes
  • Tracks message reliability
Consensus Engine

Implements the Quasar protocol:

  • Proposes blocks with dual certificates
  • Polls network for decisions
  • Manages state transitions
  • Enforces slashing rules

Blockchain Creation

The Manager bootstraps blockchains:

  1. P-Chain starts first
  2. P-Chain bootstraps C-Chain and X-Chain
  3. Dynamic chain creation via subnet transactions
  4. Each chain gets its own Quasar consensus instance

Configuration

Mainnet Parameters
MainnetConfig = Config{
    K:               21,     // Sample size
    AlphaPreference: 13,     // Preference threshold
    AlphaConfidence: 18,     // Confidence threshold
    Beta:            8,      // Decision threshold
    QThreshold:      15,     // Ringtail threshold
    QuasarTimeout:   50ms,   // Certificate timeout
}
Testnet Parameters
TestnetConfig = Config{
    K:               11,
    AlphaPreference: 7,
    AlphaConfidence: 9,
    Beta:            6,
    QThreshold:      8,
    QuasarTimeout:   100ms,
}

Usage

Enable Quasar
luxd --quasar-enabled
Monitor Performance
tail -f ~/.luxd/logs/quasar.log
Expected Logs
[QUASAR] RT shares collected (15/21) @height=42 latency=48ms
[QUASAR] aggregated cert 2.9KB
[CONSENSUS] Block 42 dual-cert finalised ltcy=302ms
[QUASAR] Quantum-secure finality achieved ✓

Security Guarantees

  1. Classical Security: BLS12-381 provides 128-bit classical security
  2. Quantum Security: Ringtail provides 128-bit post-quantum security
  3. Dual Requirement: Both must be valid for finality
  4. Slashing: Automatic punishment for protocol violations
  5. Physical Limits: 50ms window makes quantum attacks impossible

Future Improvements

  • Dynamic validator sets
  • Cross-subnet atomic swaps
  • Light client proofs
  • Mobile validator support
  • Hardware security module integration

The Quasar protocol family ensures Lux Network remains secure against both classical and quantum adversaries, providing the foundation for decades of secure blockchain operation.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when an element is not found
	ErrNotFound = errors.New("not found")

	// ErrAlreadyExists is returned when an element already exists
	ErrAlreadyExists = errors.New("already exists")

	// ErrInvalidStatus is returned when a status transition is invalid
	ErrInvalidStatus = errors.New("invalid status transition")

	// ErrMissingCertificate is returned when a required certificate is missing
	ErrMissingCertificate = errors.New("missing certificate")
)

Functions

This section is empty.

Types

type Acceptor

type Acceptor interface {
	Accept(*ConsensusContext, ids.ID, []byte) error
}

Acceptor is a function that is called when an element is accepted

type BCLookup

type BCLookup interface {
	Lookup(alias string) (ids.ID, error)
	PrimaryAlias(id ids.ID) (string, error)
}

BCLookup is the interface for looking up chain IDs by alias

type Block

type Block interface {
	Decidable

	// Parent returns the ID of this block's parent
	Parent() ids.ID

	// Verify that the state transition this block would make is valid
	Verify() error

	// Bytes returns the binary representation of this block
	Bytes() []byte

	// Height returns the height of this block
	Height() uint64

	// Timestamp returns the timestamp of this block
	Timestamp() int64
}

Block represents a block that can be decided by consensus

type ConsensusContext

type ConsensusContext struct {
	// PrimaryAlias is the primary alias of the chain this context is for
	PrimaryAlias string

	// Registerer is used to register metrics
	Registerer prometheus.Registerer

	// Context is the context this consensus is running in
	*Context

	// BlockAcceptor is called when a block is accepted
	BlockAcceptor Acceptor
	// TxAcceptor is called when a transaction is accepted
	TxAcceptor Acceptor
	// VertexAcceptor is called when a vertex is accepted
	VertexAcceptor Acceptor
}

ConsensusContext is the minimum information a consensus engine needs to run

func (*ConsensusContext) IsBootstrapped

func (ctx *ConsensusContext) IsBootstrapped() bool

IsBootstrapped returns true if the chain is done bootstrapping

type Context

type Context struct {

	// NetworkID is the ID of the network this node is connected to
	NetworkID uint32
	// SubnetID is the ID of the subnet this node validates
	SubnetID ids.ID
	// ChainID is the ID of the chain this node validates
	ChainID ids.ID
	// NodeID is the ID of this node
	NodeID ids.NodeID
	// PublicKey is the BLS public key of this node
	PublicKey *bls.PublicKey

	// XChainID is the ID of the X-Chain
	XChainID ids.ID
	// CChainID is the ID of the C-Chain
	CChainID ids.ID
	// LUXAssetID is the ID of the LUX asset
	LUXAssetID ids.ID

	// Log is the logger for this consensus
	Log log.Logger
	// Lock is a general-purpose lock for consensus
	Lock sync.RWMutex

	// Keystore is the keystore for this node
	Keystore Keystore
	// SharedMemory is the shared memory for cross-chain communication
	SharedMemory SharedMemory
	// BCLookup maps aliases to chain IDs
	BCLookup BCLookup
	// Metrics is the metrics registry
	Metrics prometheus.Gatherer

	// SubnetTracker tracks subnet membership
	SubnetTracker SubnetTracker

	// ValidatorState is the validator set state
	// The primary network's validator set is the union of all subnets' validator sets
	ValidatorState validators.State

	// ChainDataDir is the directory where chain data is stored
	ChainDataDir string

	// Quantum-specific fields
	QuasarEnabled bool
	RingtailSK    []byte // Ringtail secret key
	RingtailPK    []byte // Ringtail public key
}

Context is the shared context for Quasar consensus

type Decidable

type Decidable interface {
	// ID returns the unique ID of this element
	ID() ids.ID

	// Accept marks this element as accepted
	Accept() error

	// Reject marks this element as rejected
	Reject() error

	// Status returns the current status
	Status() choices.Status
}

Decidable represents an element that can be decided by consensus

type EngineState

type EngineState struct {
	Type  EngineType
	State EngineStateType
}

EngineState is the state of a consensus engine

type EngineStateManager

type EngineStateManager struct {
	// contains filtered or unexported fields
}

EngineStateManager manages consensus state

func (*EngineStateManager) Get

Get returns the current state

func (*EngineStateManager) Set

func (s *EngineStateManager) Set(state EngineState)

Set sets the current state

type EngineStateType

type EngineStateType uint8

EngineStateType is the state of the consensus engine

const (
	// Bootstrapping means the engine is bootstrapping
	Bootstrapping EngineStateType = iota
	// NormalOp means the engine is operating normally
	NormalOp
)

type EngineType

type EngineType uint8

EngineType is the type of consensus engine

const (
	// EngineTypeUnknown is an unknown engine type
	EngineTypeUnknown EngineType = iota
	// EngineTypeBeam is the Beam linear consensus engine
	EngineTypeBeam
	// EngineTypeNova is the Nova DAG consensus engine
	EngineTypeNova
	// EngineTypeQuasar is the Quasar quantum-secure engine
	EngineTypeQuasar
)

type Keystore

type Keystore interface {
	GetUser(username string) (string, error)
	AddUser(username string, password string) error
}

Keystore is the interface for the keystore

type MemoryState

type MemoryState struct {
	// contains filtered or unexported fields
}

MemoryState is an in-memory implementation of State

func NewMemoryState

func NewMemoryState() *MemoryState

NewMemoryState creates a new in-memory state

func (*MemoryState) AddBlock

func (s *MemoryState) AddBlock(blk Block) error

AddBlock adds a block to the state

func (*MemoryState) AddVertex

func (s *MemoryState) AddVertex(vtx Vertex) error

AddVertex adds a vertex to the state

func (*MemoryState) GetBlock

func (s *MemoryState) GetBlock(blkID ids.ID) (Block, error)

GetBlock returns the block with the given ID

func (*MemoryState) GetVertex

func (s *MemoryState) GetVertex(vtxID ids.ID) (Vertex, error)

GetVertex returns the vertex with the given ID

func (*MemoryState) IsAccepted

func (s *MemoryState) IsAccepted(id ids.ID) (bool, error)

IsAccepted returns true if the block/vertex is accepted

func (*MemoryState) IsQuantum

func (s *MemoryState) IsQuantum(id ids.ID) (bool, error)

IsQuantum returns true if the block/vertex has quantum finality

func (*MemoryState) LastAccepted

func (s *MemoryState) LastAccepted() (ids.ID, error)

LastAccepted returns the last accepted block/vertex

func (*MemoryState) Preference

func (s *MemoryState) Preference() []ids.ID

Preference returns the current preferred frontier

func (*MemoryState) RemoveBlock

func (s *MemoryState) RemoveBlock(blkID ids.ID) error

RemoveBlock removes a block from the state

func (*MemoryState) RemoveVertex

func (s *MemoryState) RemoveVertex(vtxID ids.ID) error

RemoveVertex removes a vertex from the state

func (*MemoryState) SetLastAccepted

func (s *MemoryState) SetLastAccepted(id ids.ID) error

SetLastAccepted sets the last accepted block/vertex

func (*MemoryState) SetPreference

func (s *MemoryState) SetPreference(ids []ids.ID) error

SetPreference sets the preferred frontier

func (*MemoryState) SetQuantum

func (s *MemoryState) SetQuantum(id ids.ID) error

SetQuantum marks a block/vertex as having quantum finality

type QuasarBlock

type QuasarBlock interface {
	Block

	// HasDualCert returns true if both BLS and RT certificates are present
	HasDualCert() bool

	// BLSSignature returns the aggregated BLS signature
	BLSSignature() []byte

	// RTCertificate returns the Ringtail certificate
	RTCertificate() []byte

	// SetQuantum marks this block as having quantum-secure finality
	SetQuantum() error
}

QuasarBlock extends Block with quantum-secure features

type QuasarVertex

type QuasarVertex interface {
	Vertex

	// HasDualCert returns true if both BLS and RT certificates are present
	HasDualCert() bool

	// BLSSignature returns the aggregated BLS signature
	BLSSignature() []byte

	// RTCertificate returns the Ringtail certificate
	RTCertificate() []byte

	// SetQuantum marks this vertex as having quantum-secure finality
	SetQuantum() error
}

QuasarVertex extends Vertex with quantum-secure features

type SharedMemory

type SharedMemory interface {
	Get(peerChainID ids.ID, keys [][]byte) ([][]byte, error)
	Indexed(peerChainID ids.ID, values [][]byte) error
}

SharedMemory is the interface for shared memory

type State

type State interface {
	// GetBlock returns the block with the given ID
	GetBlock(blkID ids.ID) (Block, error)

	// AddBlock adds a block to the state
	AddBlock(blk Block) error

	// RemoveBlock removes a block from the state
	RemoveBlock(blkID ids.ID) error

	// GetVertex returns the vertex with the given ID
	GetVertex(vtxID ids.ID) (Vertex, error)

	// AddVertex adds a vertex to the state
	AddVertex(vtx Vertex) error

	// RemoveVertex removes a vertex from the state
	RemoveVertex(vtxID ids.ID) error

	// SetPreference sets the preferred frontier
	SetPreference(ids []ids.ID) error

	// Preference returns the current preferred frontier
	Preference() []ids.ID

	// IsAccepted returns true if the block/vertex is accepted
	IsAccepted(id ids.ID) (bool, error)

	// LastAccepted returns the last accepted block/vertex
	LastAccepted() (ids.ID, error)

	// SetLastAccepted sets the last accepted block/vertex
	SetLastAccepted(id ids.ID) error

	// IsQuantum returns true if the block/vertex has quantum finality
	IsQuantum(id ids.ID) (bool, error)

	// SetQuantum marks a block/vertex as having quantum finality
	SetQuantum(id ids.ID) error
}

State represents the consensus state

type SubnetTracker

type SubnetTracker interface {
	Tracked(subnetID ids.ID) bool
	OnFinishedBootstrapping(subnetID ids.ID) chan struct{}
}

SubnetTracker tracks subnet membership

type Vertex

type Vertex interface {
	Decidable

	// Parents returns the IDs of this vertex's parents
	Parents() []ids.ID

	// Verify that the state transition this vertex would make is valid
	Verify() error

	// Bytes returns the binary representation of this vertex
	Bytes() []byte

	// Height returns the height of this vertex
	Height() uint64

	// Epoch returns the epoch of this vertex
	Epoch() uint32

	// Txs returns the transactions in this vertex
	Txs() [][]byte
}

Vertex represents a vertex in a DAG that can be decided by consensus

Directories

Path Synopsis
consensus
crypto
bls

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL