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 ReleaseHybridSignature(sig *HybridSignature)
- func Verify(pk []byte, msg []byte, cert []byte) bool
- func VerifyShare(pk []byte, msg []byte, share []byte) bool
- type AggregatedSignature
- type BLS
- func (q *BLS) ComputeCanonicalOrder() []VertexID
- func (q *BLS) EstablishHorizon(ctx context.Context, checkpoint VertexID, validators []string) (*dag.EventHorizon[VertexID], error)
- func (q *BLS) GetLatestHorizon() *dag.EventHorizon[VertexID]
- func (q *BLS) Initialize(_ context.Context, blsKey, pqKey []byte) error
- func (q *BLS) IsBeyondHorizon(vertex VertexID) bool
- func (q *BLS) SetFinalizedCallback(cb func(*Block))
- type Block
- type BlockCert
- type Bundle
- type Cert
- type CertBundle
- type ChainBlock
- type Client
- type CompressedWitness
- type Config
- type Core
- type Engine
- type Hybrid
- func (q *Hybrid) AddValidator(id string, weight uint64) error
- func (q *Hybrid) AggregateSignatures(message []byte, signatures []*HybridSignature) (*AggregatedSignature, error)
- func (q *Hybrid) AggregateSignaturesWithContext(ctx context.Context, message []byte, signatures []*HybridSignature) (*AggregatedSignature, error)
- func (q *Hybrid) GetActiveValidatorCount() int
- func (q *Hybrid) GetThreshold() int
- func (q *Hybrid) SignMessage(validatorID string, message []byte) (*HybridSignature, error)
- func (q *Hybrid) SignMessageWithContext(ctx context.Context, validatorID string, message []byte) (*HybridSignature, error)
- func (q *Hybrid) VerifyAggregatedSignature(message []byte, aggSig *AggregatedSignature) bool
- func (q *Hybrid) VerifyAggregatedSignatureWithContext(ctx context.Context, message []byte, aggSig *AggregatedSignature) bool
- func (q *Hybrid) VerifyHybridSignature(message []byte, sig *HybridSignature) bool
- func (q *Hybrid) VerifyHybridSignatureWithContext(ctx context.Context, message []byte, sig *HybridSignature) bool
- type HybridConsensus
- type HybridSignature
- type PChain
- type Precomp
- type PublicKey
- type QBlock
- type QuantumBlock
- type Quasar
- func (q *Quasar) GetMetrics() (processedBlocks, quantumProofs uint64)
- func (q *Quasar) GetQuantumHeight() uint64
- func (q *Quasar) GetRegisteredChains() []string
- func (q *Quasar) ProcessDynamicChains(ctx context.Context)
- func (q *Quasar) RegisterChain(chainName string) error
- func (q *Quasar) Start(ctx context.Context) error
- func (q *Quasar) SubmitBlock(block *ChainBlock) error
- func (q *Quasar) SubmitCChainBlock(block *ChainBlock)
- func (q *Quasar) SubmitPChainBlock(block *ChainBlock)
- func (q *Quasar) SubmitXChainBlock(block *ChainBlock)
- func (q *Quasar) VerifyQuantumFinality(blockHash string) bool
- func (q *Quasar) VerifyQuantumFinalityWithContext(ctx context.Context, blockHash string) bool
- type QuasarCore
- type QuasarHybridConsensus
- 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
var NewPChain = NewBLS
NewPChain is a deprecated alias for backward compatibility. Deprecated: Use NewBLS instead.
var NewQuasarHybridConsensus = NewHybrid
NewQuasarHybridConsensus is a deprecated alias for backward compatibility. Deprecated: Use NewHybrid instead.
Functions ¶
func ReleaseHybridSignature ¶ added in v1.22.23
func ReleaseHybridSignature(sig *HybridSignature)
ReleaseHybridSignature returns a HybridSignature to the pool. Call this when done with signatures from SignMessage/SignMessageWithContext.
Types ¶
type AggregatedSignature ¶
type AggregatedSignature struct {
BLSAggregated []byte
RingtailSigs []RingtailSignature
SignerCount int
}
AggregatedSignature contains aggregated BLS and individual Ringtail signatures
type BLS ¶ added in v1.22.22
type BLS struct {
// Configuration
K int
Alpha float64
Beta uint32
// contains filtered or unexported fields
}
BLS implements BLS signature aggregation with event horizon finality
func (*BLS) ComputeCanonicalOrder ¶ added in v1.22.22
ComputeCanonicalOrder returns the canonical order of finalized vertices
func (*BLS) EstablishHorizon ¶ added in v1.22.22
func (q *BLS) EstablishHorizon(ctx context.Context, checkpoint VertexID, validators []string) (*dag.EventHorizon[VertexID], error)
EstablishHorizon creates a new event horizon for BLS finality
func (*BLS) GetLatestHorizon ¶ added in v1.22.22
func (q *BLS) GetLatestHorizon() *dag.EventHorizon[VertexID]
GetLatestHorizon returns the most recent event horizon
func (*BLS) Initialize ¶ added in v1.22.22
Initialize sets up keys for Quasar
func (*BLS) IsBeyondHorizon ¶ added in v1.22.22
IsBeyondHorizon checks if a vertex is beyond the event horizon (finalized)
func (*BLS) SetFinalizedCallback ¶ added in v1.22.22
SetFinalizedCallback sets the callback for finalized blocks.
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 = Quasar
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 Hybrid ¶ added in v1.22.22
type Hybrid struct {
// contains filtered or unexported fields
}
Hybrid implements parallel BLS+Ringtail for PQ-safe consensus
func (*Hybrid) AddValidator ¶ added in v1.22.22
AddValidator adds a validator to the consensus
func (*Hybrid) AggregateSignatures ¶ added in v1.22.22
func (q *Hybrid) AggregateSignatures(message []byte, signatures []*HybridSignature) (*AggregatedSignature, error)
AggregateSignatures aggregates signatures for a message. For long-running operations, use AggregateSignaturesWithContext.
func (*Hybrid) AggregateSignaturesWithContext ¶ added in v1.22.23
func (q *Hybrid) AggregateSignaturesWithContext(ctx context.Context, message []byte, signatures []*HybridSignature) (*AggregatedSignature, error)
AggregateSignaturesWithContext aggregates signatures for a message, respecting context cancellation.
func (*Hybrid) GetActiveValidatorCount ¶ added in v1.22.22
GetActiveValidatorCount returns the number of active validators
func (*Hybrid) GetThreshold ¶ added in v1.22.22
GetThreshold returns the consensus threshold
func (*Hybrid) SignMessage ¶ added in v1.22.22
func (q *Hybrid) SignMessage(validatorID string, message []byte) (*HybridSignature, error)
SignMessage signs a message with both BLS and Ringtail. For long-running operations, use SignMessageWithContext.
func (*Hybrid) SignMessageWithContext ¶ added in v1.22.23
func (q *Hybrid) SignMessageWithContext(ctx context.Context, validatorID string, message []byte) (*HybridSignature, error)
SignMessageWithContext signs a message with both BLS and Ringtail, respecting context cancellation.
func (*Hybrid) VerifyAggregatedSignature ¶ added in v1.22.22
func (q *Hybrid) VerifyAggregatedSignature(message []byte, aggSig *AggregatedSignature) bool
VerifyAggregatedSignature verifies an aggregated signature. For long-running operations, use VerifyAggregatedSignatureWithContext.
func (*Hybrid) VerifyAggregatedSignatureWithContext ¶ added in v1.22.23
func (q *Hybrid) VerifyAggregatedSignatureWithContext(ctx context.Context, message []byte, aggSig *AggregatedSignature) bool
VerifyAggregatedSignatureWithContext verifies an aggregated signature, respecting context cancellation.
func (*Hybrid) VerifyHybridSignature ¶ added in v1.22.22
func (q *Hybrid) VerifyHybridSignature(message []byte, sig *HybridSignature) bool
VerifyHybridSignature verifies both BLS and Ringtail signatures. For long-running operations, use VerifyHybridSignatureWithContext.
func (*Hybrid) VerifyHybridSignatureWithContext ¶ added in v1.22.23
func (q *Hybrid) VerifyHybridSignatureWithContext(ctx context.Context, message []byte, sig *HybridSignature) bool
VerifyHybridSignatureWithContext verifies both BLS and Ringtail signatures, respecting context cancellation.
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 PChain ¶ added in v1.22.22
type PChain = BLS
PChain is a deprecated alias for backward compatibility. Deprecated: Use BLS instead.
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 Quasar ¶
type Quasar struct {
// contains filtered or unexported fields
}
Quasar 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 NewQuasar ¶ added in v1.22.22
NewQuasar creates the supermassive black hole at the center of the blockchain galaxy
func (*Quasar) GetMetrics ¶ added in v1.22.22
GetMetrics returns aggregator metrics
func (*Quasar) GetQuantumHeight ¶ added in v1.22.22
GetQuantumHeight returns the current quantum finalized height
func (*Quasar) GetRegisteredChains ¶ added in v1.22.22
GetRegisteredChains returns all chains currently in the event horizon
func (*Quasar) ProcessDynamicChains ¶ added in v1.22.22
ProcessDynamicChains starts processors for all dynamically registered chains This runs alongside the legacy P/X/C chain processors
func (*Quasar) RegisterChain ¶ added in v1.22.22
RegisterChain dynamically registers a new chain/subnet for automatic quantum security All new subnets are automatically protected by the event horizon
func (*Quasar) Start ¶ added in v1.22.1
Start begins drawing blocks into the Quasar's gravitational pull
func (*Quasar) SubmitBlock ¶ added in v1.22.22
func (q *Quasar) 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 (*Quasar) SubmitCChainBlock ¶ added in v1.22.22
func (q *Quasar) SubmitCChainBlock(block *ChainBlock)
SubmitCChainBlock submits a C-Chain block for quantum consensus
func (*Quasar) SubmitPChainBlock ¶ added in v1.22.22
func (q *Quasar) SubmitPChainBlock(block *ChainBlock)
SubmitPChainBlock submits a P-Chain block for quantum consensus
func (*Quasar) SubmitXChainBlock ¶ added in v1.22.22
func (q *Quasar) SubmitXChainBlock(block *ChainBlock)
SubmitXChainBlock submits an X-Chain block for quantum consensus
func (*Quasar) VerifyQuantumFinality ¶ added in v1.22.22
VerifyQuantumFinality checks if a block has quantum finality. For context-aware verification, use VerifyQuantumFinalityWithContext.
type QuasarCore ¶ added in v1.22.1
type QuasarCore = Quasar
QuasarCore is a deprecated alias for backward compatibility. Deprecated: Use Quasar or Core instead.
type QuasarHybridConsensus ¶
type QuasarHybridConsensus = Hybrid
QuasarHybridConsensus is a deprecated alias for backward compatibility. Deprecated: Use Hybrid instead.
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