Documentation
¶
Overview ¶
Package quasar provides post-quantum overlay: dual BLS + ring certificates.
Quasar prepares for the quantum age by running both BLS (fast, classical) and ring signatures (quantum-safe, larger) in parallel. The system can seamlessly transition when quantum computers arrive, making the consensus future-proof. Quasars are among the most energetic objects in the universe.
Package ringtail provides post-quantum cryptographic primitives for the Lux consensus. This is a stub implementation that forwards to the actual implementation in github.com/luxfi/crypto/ringtail.
Index ¶
- Variables
- func KeyGen(seed []byte) ([]byte, []byte, error)
- func Verify(pk []byte, msg []byte, cert []byte) bool
- func VerifyShare(pk []byte, msg []byte, share []byte) bool
- type AggregatedSignature
- type Block
- type BlockCert
- type Bundle
- type Cert
- type CertBundle
- type ChainBlock
- type Client
- type CompressedWitness
- type Config
- type Core
- type Engine
- type HybridConsensus
- type HybridSignature
- type PChainQuasar
- func (q *PChainQuasar) ComputeCanonicalOrder() []VertexID
- func (q *PChainQuasar) EstablishHorizon(ctx context.Context, checkpoint VertexID, validators []string) (*dag.EventHorizon[VertexID], error)
- func (q *PChainQuasar) GetLatestHorizon() *dag.EventHorizon[VertexID]
- func (q *PChainQuasar) Initialize(_ context.Context, blsKey, pqKey []byte) error
- func (q *PChainQuasar) IsBeyondHorizon(vertex VertexID) bool
- func (q *PChainQuasar) SetFinalizedCallback(cb func(*Block))
- type Precomp
- type PublicKey
- type QBlock
- type QuantumBlock
- type QuasarCore
- func (q *QuasarCore) GetMetrics() (processedBlocks, quantumProofs uint64)
- func (q *QuasarCore) GetQuantumHeight() uint64
- func (q *QuasarCore) GetRegisteredChains() []string
- func (q *QuasarCore) ProcessDynamicChains(ctx context.Context)
- func (q *QuasarCore) RegisterChain(chainName string) error
- func (q *QuasarCore) Start(ctx context.Context) error
- func (q *QuasarCore) SubmitBlock(block *ChainBlock) error
- func (q *QuasarCore) SubmitCChainBlock(block *ChainBlock)
- func (q *QuasarCore) SubmitPChainBlock(block *ChainBlock)
- func (q *QuasarCore) SubmitXChainBlock(block *ChainBlock)
- func (q *QuasarCore) VerifyQuantumFinality(blockHash string) bool
- type QuasarHybridConsensus
- func (q *QuasarHybridConsensus) AddValidator(id string, weight uint64) error
- func (q *QuasarHybridConsensus) AggregateSignatures(message []byte, signatures []*HybridSignature) (*AggregatedSignature, error)
- func (q *QuasarHybridConsensus) GetActiveValidatorCount() int
- func (q *QuasarHybridConsensus) GetThreshold() int
- func (q *QuasarHybridConsensus) SignMessage(validatorID string, message []byte) (*HybridSignature, error)
- func (q *QuasarHybridConsensus) VerifyAggregatedSignature(message []byte, aggSig *AggregatedSignature) bool
- func (q *QuasarHybridConsensus) VerifyHybridSignature(message []byte, sig *HybridSignature) bool
- type RingtailEngine
- type RingtailKeyPair
- type RingtailPQ
- type RingtailSignature
- type SecretKey
- type SecurityLevel
- type Share
- type Signature
- type Stats
- type Validator
- type VerkleWitness
- func (v *VerkleWitness) BatchVerify(witnesses []*WitnessProof) error
- func (v *VerkleWitness) CreateWitness(stateRoot []byte, blsAgg *bls.Signature, ringtailSigners []bool, height uint64) (*WitnessProof, error)
- func (v *VerkleWitness) GetCachedWitness(stateRoot []byte) (*WitnessProof, bool)
- func (v *VerkleWitness) VerifyCompressed(cw *CompressedWitness) error
- func (v *VerkleWitness) VerifyStateTransition(witness *WitnessProof) error
- type VertexID
- type WitnessProof
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidCertificate = errors.New("invalid certificate") ErrMissingCertificate = errors.New("missing certificate") ErrCertificateMismatch = errors.New("certificate mismatch") )
Error variables
var DefaultConfig = Config{QThreshold: 3, QuasarTimeout: 30}
DefaultConfig for quasar protocol
Functions ¶
Types ¶
type AggregatedSignature ¶
type AggregatedSignature struct {
BLSAggregated []byte
RingtailSigs []RingtailSignature
SignerCount int
}
AggregatedSignature contains aggregated BLS and individual Ringtail signatures
type Block ¶ added in v1.22.1
type Block struct {
ID [32]byte // Unique block identifier
ChainID [32]byte // Chain this block belongs to
ChainName string // Human-readable chain name (e.g., "P-Chain", "X-Chain", "C-Chain")
Height uint64 // Block height
Hash string // Block hash
Timestamp time.Time // Block timestamp
Data []byte // Block payload data
Cert *BlockCert // Quantum certificate (nil if not finalized)
}
Block represents a finalized block in the Quasar consensus. This is the primary block type used throughout the system.
type BlockCert ¶ added in v1.22.4
type BlockCert struct {
BLS []byte // BLS aggregate signature
PQ []byte // Post-quantum certificate (ML-DSA/Ringtail)
Sigs map[string][]byte // Individual validator signatures
Epoch uint64 // Epoch number
Finality time.Time // Time of finality
}
BlockCert contains cryptographic certificates for quantum finality.
type CertBundle ¶
type CertBundle struct {
BLSAgg []byte // BLS aggregate signature
PQCert []byte // Post-quantum certificate
}
CertBundle contains both BLS and PQ certificates for a block.
func (*CertBundle) Verify ¶
func (c *CertBundle) Verify(_ []string) bool
Verify checks both BLS and PQ certificates.
type ChainBlock ¶ added in v1.22.1
type ChainBlock = Block
ChainBlock is an alias for Block for backward compatibility. Deprecated: Use Block instead.
type Client ¶
type Client interface {
SubmitCheckpoint(epoch uint64, root []byte, attest []byte) error
FetchBundle(epoch uint64) (Bundle, error)
Verify(Bundle) bool
}
Client interface for Quasar operations
type CompressedWitness ¶
type CompressedWitness struct {
CommitmentAndProof []byte // Combined commitment + proof
Metadata uint64 // Packed height + timestamp
Validators uint32 // Validator bitfield (up to 32 validators)
}
CompressedWitness creates an even smaller witness for network transmission
func (*CompressedWitness) Size ¶
func (c *CompressedWitness) Size() int
Size returns size of compressed witness
type Core ¶ added in v1.22.4
type Core = QuasarCore
Core is an alias for the aggregator implementation. Use NewCore() to create a new instance.
type Engine ¶ added in v1.22.4
type Engine interface {
// Start begins the consensus engine
Start(ctx context.Context) error
// Stop gracefully shuts down the consensus engine
Stop() error
// Submit adds a block to the consensus pipeline
Submit(block *Block) error
// Finalized returns a channel of finalized blocks
Finalized() <-chan *Block
// IsFinalized checks if a block is finalized
IsFinalized(blockID [32]byte) bool
// Stats returns consensus metrics
Stats() Stats
}
Engine is the main interface for quantum consensus.
type HybridConsensus ¶ added in v1.22.4
type HybridConsensus struct {
// contains filtered or unexported fields
}
HybridConsensus handles BLS + PQ certificate generation.
func (*HybridConsensus) AddValidator ¶ added in v1.22.4
func (h *HybridConsensus) AddValidator(id string, weight int)
AddValidator adds a validator to the consensus.
func (*HybridConsensus) RemoveValidator ¶ added in v1.22.4
func (h *HybridConsensus) RemoveValidator(id string)
RemoveValidator removes a validator from the consensus.
type HybridSignature ¶
HybridSignature contains both BLS and Ringtail signatures
type PChainQuasar ¶ added in v1.22.1
type PChainQuasar struct {
// Configuration
K int
Alpha float64
Beta uint32
// contains filtered or unexported fields
}
PChainQuasar implements P-Chain post-quantum consensus with event horizon finality
func NewPChainQuasar ¶ added in v1.22.1
func NewPChainQuasar(cfg config.Parameters, store dag.Store[VertexID]) *PChainQuasar
NewPChainQuasar creates a new PChainQuasar P-Chain instance
func (*PChainQuasar) ComputeCanonicalOrder ¶ added in v1.22.1
func (q *PChainQuasar) ComputeCanonicalOrder() []VertexID
ComputeCanonicalOrder returns the canonical order of finalized vertices
func (*PChainQuasar) EstablishHorizon ¶ added in v1.22.1
func (q *PChainQuasar) EstablishHorizon(ctx context.Context, checkpoint VertexID, validators []string) (*dag.EventHorizon[VertexID], error)
EstablishHorizon creates a new event horizon for P-Chain finality
func (*PChainQuasar) GetLatestHorizon ¶ added in v1.22.1
func (q *PChainQuasar) GetLatestHorizon() *dag.EventHorizon[VertexID]
GetLatestHorizon returns the most recent event horizon
func (*PChainQuasar) Initialize ¶ added in v1.22.1
func (q *PChainQuasar) Initialize(_ context.Context, blsKey, pqKey []byte) error
Initialize sets up keys for Quasar
func (*PChainQuasar) IsBeyondHorizon ¶ added in v1.22.1
func (q *PChainQuasar) IsBeyondHorizon(vertex VertexID) bool
IsBeyondHorizon checks if a vertex is beyond the event horizon (finalized)
func (*PChainQuasar) SetFinalizedCallback ¶ added in v1.22.1
func (q *PChainQuasar) SetFinalizedCallback(cb func(*Block))
SetFinalizedCallback sets the callback for finalized blocks.
type Precomp ¶
type Precomp = []byte
Type aliases for cleaner API
func Precompute ¶
Precompute generates a precomputed share
type QBlock ¶
type QBlock = Block
QBlock is an alias for Block for backward compatibility. Deprecated: Use Block instead.
type QuantumBlock ¶ added in v1.22.1
type QuantumBlock struct {
Height uint64
SourceBlocks []*Block
QuantumHash string
BLSSignature []byte
RingtailProof []byte // ML-DSA signature
Timestamp time.Time
ValidatorSigs map[string]*HybridSignature
}
QuantumBlock represents a quantum-finalized aggregate block.
type QuasarCore ¶ added in v1.22.1
type QuasarCore struct {
// contains filtered or unexported fields
}
QuasarCore is the supermassive black hole at the center of the blockchain galaxy It collects blocks from ALL chains (P, X, C, + any new subnets) and applies quantum consensus External systems (bridges, contracts) can use RPC to add blocks to the event horizon
func NewQuasarCore ¶ added in v1.22.1
func NewQuasarCore(threshold int) (*QuasarCore, error)
NewQuasar creates the supermassive black hole at the center of the blockchain galaxy
func (*QuasarCore) GetMetrics ¶ added in v1.22.1
func (q *QuasarCore) GetMetrics() (processedBlocks, quantumProofs uint64)
GetMetrics returns aggregator metrics
func (*QuasarCore) GetQuantumHeight ¶ added in v1.22.1
func (q *QuasarCore) GetQuantumHeight() uint64
GetQuantumHeight returns the current quantum finalized height
func (*QuasarCore) GetRegisteredChains ¶ added in v1.22.1
func (q *QuasarCore) GetRegisteredChains() []string
GetRegisteredChains returns all chains currently in the event horizon
func (*QuasarCore) ProcessDynamicChains ¶ added in v1.22.1
func (q *QuasarCore) ProcessDynamicChains(ctx context.Context)
ProcessDynamicChains starts processors for all dynamically registered chains This runs alongside the legacy P/X/C chain processors
func (*QuasarCore) RegisterChain ¶ added in v1.22.1
func (q *QuasarCore) RegisterChain(chainName string) error
RegisterChain dynamically registers a new chain/subnet for automatic quantum security All new subnets are automatically protected by the event horizon
func (*QuasarCore) Start ¶ added in v1.22.1
func (q *QuasarCore) Start(ctx context.Context) error
Start begins drawing blocks into the Quasar's gravitational pull
func (*QuasarCore) SubmitBlock ¶ added in v1.22.1
func (q *QuasarCore) SubmitBlock(block *ChainBlock) error
SubmitBlock is the universal RPC endpoint for ANY chain/contract to add blocks External systems (bridge, contracts) use this to enter the event horizon
func (*QuasarCore) SubmitCChainBlock ¶ added in v1.22.1
func (q *QuasarCore) SubmitCChainBlock(block *ChainBlock)
SubmitCChainBlock submits a C-Chain block for quantum consensus
func (*QuasarCore) SubmitPChainBlock ¶ added in v1.22.1
func (q *QuasarCore) SubmitPChainBlock(block *ChainBlock)
SubmitPChainBlock submits a P-Chain block for quantum consensus
func (*QuasarCore) SubmitXChainBlock ¶ added in v1.22.1
func (q *QuasarCore) SubmitXChainBlock(block *ChainBlock)
SubmitXChainBlock submits an X-Chain block for quantum consensus
func (*QuasarCore) VerifyQuantumFinality ¶ added in v1.22.1
func (q *QuasarCore) VerifyQuantumFinality(blockHash string) bool
VerifyQuantumFinality checks if a block has quantum finality
type QuasarHybridConsensus ¶
type QuasarHybridConsensus struct {
// contains filtered or unexported fields
}
QuasarHybridConsensus implements parallel BLS+Ringtail for PQ-safe consensus
func NewQuasarHybridConsensus ¶
func NewQuasarHybridConsensus(threshold int) (*QuasarHybridConsensus, error)
NewQuasarHybridConsensus creates a new hybrid consensus engine
func (*QuasarHybridConsensus) AddValidator ¶
func (q *QuasarHybridConsensus) AddValidator(id string, weight uint64) error
AddValidator adds a validator to the consensus
func (*QuasarHybridConsensus) AggregateSignatures ¶
func (q *QuasarHybridConsensus) AggregateSignatures(message []byte, signatures []*HybridSignature) (*AggregatedSignature, error)
AggregateSignatures aggregates signatures for a message
func (*QuasarHybridConsensus) GetActiveValidatorCount ¶
func (q *QuasarHybridConsensus) GetActiveValidatorCount() int
GetActiveValidatorCount returns the number of active validators
func (*QuasarHybridConsensus) GetThreshold ¶
func (q *QuasarHybridConsensus) GetThreshold() int
GetThreshold returns the consensus threshold
func (*QuasarHybridConsensus) SignMessage ¶
func (q *QuasarHybridConsensus) SignMessage(validatorID string, message []byte) (*HybridSignature, error)
SignMessage signs a message with both BLS and Ringtail
func (*QuasarHybridConsensus) VerifyAggregatedSignature ¶
func (q *QuasarHybridConsensus) VerifyAggregatedSignature(message []byte, aggSig *AggregatedSignature) bool
VerifyAggregatedSignature verifies an aggregated signature
func (*QuasarHybridConsensus) VerifyHybridSignature ¶
func (q *QuasarHybridConsensus) VerifyHybridSignature(message []byte, sig *HybridSignature) bool
VerifyHybridSignature verifies both BLS and Ringtail signatures
type RingtailEngine ¶
type RingtailEngine interface {
// Initialize the engine with security parameters
Initialize(level SecurityLevel) error
// Sign a message with the secret key
Sign(msg []byte, sk SecretKey) (Signature, error)
// Verify a signature
Verify(msg []byte, sig Signature, pk PublicKey) bool
// Generate a new key pair
GenerateKeyPair() (SecretKey, PublicKey, error)
// KEM operations for post-quantum key exchange
Encapsulate(pk PublicKey) ([]byte, []byte, error)
Decapsulate(ct []byte, sk SecretKey) ([]byte, error)
// Shared secret operations
DeriveKey(secret []byte, length int) []byte
}
RingtailEngine represents the post-quantum consensus engine
type RingtailKeyPair ¶
type RingtailKeyPair struct {
PrivateKey *mldsa.PrivateKey
PublicKey *mldsa.PublicKey
}
RingtailKeyPair holds a post-quantum key pair
type RingtailPQ ¶
type RingtailPQ struct {
// contains filtered or unexported fields
}
RingtailPQ provides real post-quantum signatures using ML-DSA
type RingtailSignature ¶
RingtailSignature represents a post-quantum signature
type SecurityLevel ¶
type SecurityLevel int
SecurityLevel represents the post-quantum security level
const ( SecurityLow SecurityLevel = 0 SecurityMedium SecurityLevel = 1 SecurityHigh SecurityLevel = 2 )
type Signature ¶
type Signature = []byte // Alias for Share or Cert depending on context
Type aliases for cleaner API
type Stats ¶ added in v1.22.4
type Stats struct {
Height uint64 // Current finalized height
ProcessedBlocks uint64 // Total blocks processed
FinalizedBlocks uint64 // Total blocks finalized
PendingBlocks int // Blocks awaiting finality
Validators int // Active validator count
Uptime time.Duration // Time since start
}
Stats contains consensus metrics.
type Validator ¶
type Validator struct {
ID string
BLSPubKey *bls.PublicKey
RingtailPub *mldsa.PublicKey
Weight uint64
Active bool
}
Validator represents a consensus validator
type VerkleWitness ¶
type VerkleWitness struct {
// contains filtered or unexported fields
}
VerkleWitness provides hyper-efficient state verification Assumes every block is PQ-final via BLS+Ringtail threshold
func NewVerkleWitness ¶
func NewVerkleWitness(threshold int) *VerkleWitness
NewVerkleWitness creates a lightweight Verkle witness verifier
func (*VerkleWitness) BatchVerify ¶
func (v *VerkleWitness) BatchVerify(witnesses []*WitnessProof) error
BatchVerify verifies multiple witnesses in parallel (hyper-efficient)
func (*VerkleWitness) CreateWitness ¶
func (v *VerkleWitness) CreateWitness( stateRoot []byte, blsAgg *bls.Signature, ringtailSigners []bool, height uint64, ) (*WitnessProof, error)
CreateWitness creates a minimal witness for a state transition
func (*VerkleWitness) GetCachedWitness ¶
func (v *VerkleWitness) GetCachedWitness(stateRoot []byte) (*WitnessProof, bool)
GetCachedWitness retrieves a cached witness if available
func (*VerkleWitness) VerifyCompressed ¶
func (v *VerkleWitness) VerifyCompressed(cw *CompressedWitness) error
VerifyCompressed verifies a compressed witness (ultra-fast)
func (*VerkleWitness) VerifyStateTransition ¶
func (v *VerkleWitness) VerifyStateTransition(witness *WitnessProof) error
VerifyStateTransition verifies state transition with minimal overhead Assumes PQ finality via BLS+Ringtail threshold already met
type WitnessProof ¶
type WitnessProof struct {
// Verkle proof components
Commitment []byte // 32 bytes banderwagon point
Path []byte // Compressed path in tree
OpeningProof []byte // IPA opening proof
// PQ finality certificate (lightweight)
BLSAggregate []byte // Aggregated BLS signature
RingtailBits []byte // Bitfield of Ringtail signers
ValidatorSet []byte // Compressed validator set hash
// Block metadata
BlockHeight uint64
StateRoot []byte
Timestamp uint64
}
WitnessProof contains the minimal proof for state verification
func (*WitnessProof) Compress ¶
func (w *WitnessProof) Compress() *CompressedWitness
Compress creates a compressed witness (< 200 bytes)
func (*WitnessProof) IsLightweight ¶
func (w *WitnessProof) IsLightweight() bool
IsLightweight checks if witness is under 1KB (hyper-efficient)
func (*WitnessProof) Size ¶
func (w *WitnessProof) Size() int
WitnessSize returns the size of a witness in bytes