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
- func NewConfig() dag.Config
- type Adapter
- func (a *Adapter) GetActiveKeys(ctx context.Context, store storage.Store, owner string) ([]CoronaKey, error)
- func (a *Adapter) GetQuasarCert(ctx context.Context, store storage.Store, vertexID string) (*QuasarCert, error)
- func (a *Adapter) GetRecentQuasarCerts(ctx context.Context, store storage.Store, limit int) ([]QuasarCert, error)
- func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)
- func (a *Adapter) GetStampsByChain(ctx context.Context, store storage.Store, chainID string, limit int) ([]QuantumStamp, error)
- func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
- func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)
- func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error
- func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)
- func (a *Adapter) StoreCoronaKey(ctx context.Context, store storage.Store, key *CoronaKey, vertexID string) error
- func (a *Adapter) StoreProof(ctx context.Context, store storage.Store, proof *FinalityProof) error
- func (a *Adapter) StoreQuasarCert(ctx context.Context, store storage.Store, cert *QuasarCert) error
- func (a *Adapter) StoreStamp(ctx context.Context, store storage.Store, stamp *QuantumStamp) error
- func (a *Adapter) UpdateExtendedStats(ctx context.Context, store storage.Store) error
- func (a *Adapter) VerifyProof(ctx context.Context, proof *FinalityProof) (bool, error)
- type CoronaKey
- type FinalityProof
- type Lattice
- type ProofType
- type QuantumStamp
- type QuantumVertex
- type QuasarCert
Constants ¶
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 ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements dag.Adapter for Q-Chain
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 ¶
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 ¶
GetVertexByID fetches a specific vertex by ID
func (*Adapter) InitSchema ¶
InitSchema creates Q-Chain specific database tables
func (*Adapter) ParseVertex ¶
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 ¶
StoreProof stores a finality proof in the database
func (*Adapter) StoreQuasarCert ¶
StoreQuasarCert stores a triple consensus certificate in the database
func (*Adapter) StoreStamp ¶
StoreStamp stores a quantum stamp for cross-chain finality
func (*Adapter) UpdateExtendedStats ¶
UpdateExtendedStats updates Q-Chain specific statistics
func (*Adapter) VerifyProof ¶
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 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:
- BLS aggregate (48 bytes) — classical fast-path consensus (BLS12-381)
- PQ proof (variable) — post-quantum certificate (ML-DSA-65 or Corona)