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 Bundle
- type Cert
- type CertBundle
- type Client
- type CompressedWitness
- type Config
- type HybridSignature
- type Precomp
- type PublicKey
- type QBlock
- type Quasar
- func (q *Quasar) ComputeCanonicalOrder() []VertexID
- func (q *Quasar) EstablishHorizon(ctx context.Context, checkpoint VertexID, validators []string) (*dag.EventHorizon[VertexID], error)
- func (q *Quasar) GetLatestHorizon() *dag.EventHorizon[VertexID]
- func (q *Quasar) Initialize(_ context.Context, blsKey, pqKey []byte) error
- func (q *Quasar) IsBeyondHorizon(vertex VertexID) bool
- func (q *Quasar) SetFinalizedCallback(cb func(QBlock))
- 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 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 CertBundle ¶
type CertBundle struct {
BLSAgg []byte // BLS aggregate signature
PQCert []byte // Post-quantum certificate
}
CertBundle contains both classical and quantum certificates
func (*CertBundle) Verify ¶
func (c *CertBundle) Verify(_ []string) bool
Verify checks both BLS and PQ certificates
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 HybridSignature ¶
HybridSignature contains both BLS and Ringtail signatures
type Precomp ¶
type Precomp = []byte
Type aliases for cleaner API
func Precompute ¶
Precompute generates a precomputed share
type QBlock ¶
type QBlock struct {
Height uint64
Hash string
Timestamp time.Time
Cert *CertBundle
}
QBlock represents a quantum-finalized block
type Quasar ¶
type Quasar struct {
// Configuration
K int
Alpha float64
Beta uint32
// contains filtered or unexported fields
}
Quasar implements P-Chain post-quantum consensus with event horizon finality
func (*Quasar) ComputeCanonicalOrder ¶
ComputeCanonicalOrder returns the canonical order of finalized vertices
func (*Quasar) EstablishHorizon ¶
func (q *Quasar) EstablishHorizon(ctx context.Context, checkpoint VertexID, validators []string) (*dag.EventHorizon[VertexID], error)
EstablishHorizon creates a new event horizon for P-Chain finality
func (*Quasar) GetLatestHorizon ¶
func (q *Quasar) GetLatestHorizon() *dag.EventHorizon[VertexID]
GetLatestHorizon returns the most recent event horizon
func (*Quasar) Initialize ¶
Initialize sets up keys for Quasar
func (*Quasar) IsBeyondHorizon ¶
IsBeyondHorizon checks if a vertex is beyond the event horizon (finalized)
func (*Quasar) SetFinalizedCallback ¶
SetFinalizedCallback sets the callback for finalized blocks
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 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