quantum

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package qchain provides the Q-Chain (Quantum) adapter for the DAG indexer. Q-Chain handles quantum-resistant finality proofs using lattice-based cryptography.

Index

Constants

View Source
const (
	// DefaultRPCEndpoint is the default Q-Chain RPC endpoint
	DefaultRPCEndpoint = "http://localhost:9650/ext/bc/Q/rpc"
	// DefaultHTTPPort is the default API port for Q-Chain indexer
	DefaultHTTPPort = 4300
)

Variables

This section is empty.

Functions

func NewConfig

func NewConfig() dag.Config

NewConfig creates a default Q-Chain indexer configuration

Types

type Adapter

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

Adapter implements dag.Adapter for Q-Chain

func New

func New(rpcEndpoint string) *Adapter

New creates a new Q-Chain adapter

func (*Adapter) GetActiveKeys

func (a *Adapter) GetActiveKeys(ctx context.Context, store storage.Store, owner string) ([]CoronaKey, error)

GetActiveKeys retrieves active Corona keys for an owner

func (*Adapter) GetQuasarCert

func (a *Adapter) GetQuasarCert(ctx context.Context, store storage.Store, vertexID string) (*QuasarCert, error)

GetQuasarCert retrieves a QuasarCert by vertex ID

func (*Adapter) GetRecentQuasarCerts

func (a *Adapter) GetRecentQuasarCerts(ctx context.Context, store storage.Store, limit int) ([]QuasarCert, error)

GetRecentQuasarCerts returns recent QuasarCerts ordered by epoch descending

func (*Adapter) GetRecentVertices

func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)

GetRecentVertices fetches recent vertices from Q-Chain

func (*Adapter) GetStampsByChain

func (a *Adapter) GetStampsByChain(ctx context.Context, store storage.Store, chainID string, limit int) ([]QuantumStamp, error)

GetStampsByChain retrieves quantum stamps for a specific chain

func (*Adapter) GetStats

func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)

GetStats returns Q-Chain specific statistics

func (*Adapter) GetVertexByID

func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)

GetVertexByID fetches a specific vertex by ID

func (*Adapter) InitSchema

func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error

InitSchema creates Q-Chain specific database tables

func (*Adapter) ParseVertex

func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)

ParseVertex parses raw RPC data into a DAG vertex

func (*Adapter) StoreCoronaKey added in v1.4.1

func (a *Adapter) StoreCoronaKey(ctx context.Context, store storage.Store, key *CoronaKey, vertexID string) error

StoreCoronaKey stores a quantum-resistant signing key

func (*Adapter) StoreProof

func (a *Adapter) StoreProof(ctx context.Context, store storage.Store, proof *FinalityProof) error

StoreProof stores a finality proof in the database

func (*Adapter) StoreQuasarCert

func (a *Adapter) StoreQuasarCert(ctx context.Context, store storage.Store, cert *QuasarCert) error

StoreQuasarCert stores a triple consensus certificate in the database

func (*Adapter) StoreStamp

func (a *Adapter) StoreStamp(ctx context.Context, store storage.Store, stamp *QuantumStamp) error

StoreStamp stores a quantum stamp for cross-chain finality

func (*Adapter) UpdateExtendedStats

func (a *Adapter) UpdateExtendedStats(ctx context.Context, store storage.Store) error

UpdateExtendedStats updates Q-Chain specific statistics

func (*Adapter) VerifyProof

func (a *Adapter) VerifyProof(ctx context.Context, proof *FinalityProof) (bool, error)

VerifyProof performs quantum-resistant proof verification Returns true if the proof is valid under the specified lattice parameters

type CoronaKey added in v1.4.1

type CoronaKey struct {
	ID          string    `json:"id"`
	PublicKey   []byte    `json:"publicKey"`
	KeyType     ProofType `json:"keyType"`       // dilithium, falcon, sphincs+
	Algorithm   string    `json:"algorithm"`     // Specific algorithm variant
	SecurityLvl int       `json:"securityLevel"` // NIST security level 1-5
	Owner       string    `json:"owner"`         // Key owner address
	ValidFrom   time.Time `json:"validFrom"`
	ValidUntil  time.Time `json:"validUntil"`
	Revoked     bool      `json:"revoked"`
	CreatedAt   time.Time `json:"createdAt"`
}

CoronaKey represents a quantum-resistant signing key (Corona is LUX's post-quantum signature scheme)

type FinalityProof

type FinalityProof struct {
	ID            string    `json:"id"`
	VertexID      string    `json:"vertexId"`
	ProofType     ProofType `json:"proofType"`
	LatticeParams Lattice   `json:"latticeParams"`
	Signature     []byte    `json:"signature"`
	PublicKey     []byte    `json:"publicKey"`
	Timestamp     time.Time `json:"timestamp"`
	Verified      bool      `json:"verified"`
}

FinalityProof represents a quantum-resistant finality proof (legacy lattice-level detail).

type Lattice

type Lattice struct {
	Dimension   int    `json:"dimension"`   // Lattice dimension (n)
	Modulus     int64  `json:"modulus"`     // Modulus (q)
	ErrorBound  int    `json:"errorBound"`  // Error distribution bound
	SecurityLvl int    `json:"securityLvl"` // NIST security level (1-5)
	Algorithm   string `json:"algorithm"`   // Specific algorithm variant
}

Lattice contains lattice-based cryptography parameters

type ProofType

type ProofType string

ProofType identifies the quantum-resistant algorithm used

const (
	ProofDilithium ProofType = "dilithium" // NIST PQC standard
	ProofKyber     ProofType = "kyber"     // Key encapsulation
	ProofFalcon    ProofType = "falcon"    // Fast lattice-based
	ProofSphincsh  ProofType = "sphincs+"  // Hash-based
)

type QuantumStamp

type QuantumStamp struct {
	ID          string    `json:"id"`
	VertexID    string    `json:"vertexId"`
	ChainID     string    `json:"chainId"`     // Which chain this stamp is for
	BlockHeight uint64    `json:"blockHeight"` // Block height being stamped
	BlockHash   []byte    `json:"blockHash"`   // Block hash being certified
	Entropy     []byte    `json:"entropy"`     // Quantum random entropy
	KeyID       string    `json:"keyId"`       // Corona key used for signing
	Signature   []byte    `json:"signature"`   // Quantum-resistant signature
	Timestamp   time.Time `json:"timestamp"`
	Certified   bool      `json:"certified"` // Whether stamp has been verified
}

QuantumStamp represents a quantum-certified timestamp for finality

type QuantumVertex

type QuantumVertex struct {
	dag.Vertex
	QuasarCert    *QuasarCert    `json:"quasarCert,omitempty"`
	FinalityProof *FinalityProof `json:"finalityProof,omitempty"`
	ProofCount    int            `json:"proofCount"`
	Finalized     bool           `json:"finalized"`
}

QuantumVertex extends DAG vertex with quantum-specific data

type QuasarCert

type QuasarCert struct {
	ID         string    `json:"id"`
	VertexID   string    `json:"vertexId"`
	BLS        []byte    `json:"bls"`     // BLS aggregate signature (48 bytes)
	PQProof    []byte    `json:"pqProof"` // STARK proof aggregating N ML-DSA sigs (~200 bytes)
	Epoch      uint64    `json:"epoch"`
	Finality   time.Time `json:"finality"`
	Validators int       `json:"validators"` // Count of validators proven by PQProof
}

QuasarCert is the dual consensus finality certificate. Matches github.com/luxfi/consensus/protocol/quasar.QuasarCert.

Two verification paths:

  1. BLS aggregate (48 bytes) — classical fast-path consensus (BLS12-381)
  2. PQ proof (variable) — post-quantum certificate (ML-DSA-65 or Corona)

Jump to

Keyboard shortcuts

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