pq

package
v1.22.25 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package pq implements the post-quantum consensus engine that combines classical and quantum-resistant consensus mechanisms.

Package pq implements post-quantum hardened consensus.

PQ uses quantum-safe cryptographic primitives throughout the consensus pipeline: ML-KEM for key exchange, ML-DSA for signatures, and hybrid certificates from the quasar overlay. The topology can be linear or DAG, but all operations are quantum-resistant for long-term security.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTestKeys added in v1.21.3

func GenerateTestKeys() (blsKey []byte, pqKey []byte)

GenerateTestKeys generates test keys for development DO NOT use in production

func VerifyBLSAggregate added in v1.21.3

func VerifyBLSAggregate(blockID ids.ID, votes map[string]int, signature []byte, blsPublicKeys [][]byte) error

VerifyBLSAggregate verifies a BLS aggregate signature

func VerifyPQCertificate added in v1.21.3

func VerifyPQCertificate(blockID ids.ID, votes map[string]int, certificate []byte, pqPublicKeys [][]byte) error

VerifyPQCertificate verifies a post-quantum certificate

Types

type CertificateGenerator added in v1.21.3

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

CertificateGenerator generates real cryptographic certificates

func NewCertificateGenerator added in v1.21.3

func NewCertificateGenerator(blsKey, pqKey []byte) *CertificateGenerator

NewCertificateGenerator creates a new certificate generator

func (*CertificateGenerator) GenerateBLSAggregate added in v1.21.3

func (cg *CertificateGenerator) GenerateBLSAggregate(blockID ids.ID, votes map[string]int) ([]byte, error)

GenerateBLSAggregate generates a BLS aggregate signature This is a simplified version - in production it would use real BLS aggregation

func (*CertificateGenerator) GeneratePQCertificate added in v1.21.3

func (cg *CertificateGenerator) GeneratePQCertificate(blockID ids.ID, votes map[string]int) ([]byte, error)

GeneratePQCertificate generates a post-quantum certificate using Ringtail This creates a quantum-resistant signature

type ConsensusEngine

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

ConsensusEngine implements post-quantum consensus combining classical and quantum-resistant security

func NewConsensus

func NewConsensus(params config.Parameters) *ConsensusEngine

NewConsensus creates a new post-quantum consensus engine

func (*ConsensusEngine) FinalityChannel

func (e *ConsensusEngine) FinalityChannel() <-chan FinalityEvent

FinalityChannel returns the channel for finality events

func (*ConsensusEngine) Height

func (e *ConsensusEngine) Height() uint64

Height returns the current finalized height

func (*ConsensusEngine) Initialize

func (e *ConsensusEngine) Initialize(ctx context.Context, blsKey, pqKey []byte) error

Initialize sets up the PQ engine with keys

func (*ConsensusEngine) IsFinalized

func (e *ConsensusEngine) IsFinalized(blockID ids.ID) bool

IsFinalized checks if a block has achieved PQ finality

func (*ConsensusEngine) Metrics

func (e *ConsensusEngine) Metrics() map[string]interface{}

Metrics returns engine metrics

func (*ConsensusEngine) ProcessBlock

func (e *ConsensusEngine) ProcessBlock(ctx context.Context, blockID ids.ID, votes map[string]int) error

ProcessBlock processes a block through PQ consensus

func (*ConsensusEngine) SetFinalizedCallback

func (e *ConsensusEngine) SetFinalizedCallback(cb func(FinalityEvent))

SetFinalizedCallback sets a callback for finalized blocks

type Engine

type Engine interface {
	// Start starts the engine
	Start(context.Context, uint32) error

	// Stop stops the engine
	Stop(context.Context) error

	// HealthCheck performs a health check
	HealthCheck(context.Context) (interface{}, error)

	// IsBootstrapped returns whether the engine is bootstrapped
	IsBootstrapped() bool

	// VerifyQuantumSignature verifies a post-quantum signature
	VerifyQuantumSignature([]byte, []byte, []byte) error

	// GenerateQuantumProof generates a quantum-resistant proof
	GenerateQuantumProof(context.Context, ids.ID) ([]byte, error)
}

Engine defines the post-quantum consensus engine

type FinalityEvent

type FinalityEvent struct {
	Height    uint64
	BlockID   ids.ID
	Timestamp time.Time
	PQProof   []byte // Post-quantum proof
	BLSProof  []byte // Classical BLS proof
}

FinalityEvent represents a finalized block with quantum-resistant proofs

type PostQuantum

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

PostQuantum implements post-quantum consensus engine

func New

func New() *PostQuantum

New creates a new post-quantum consensus engine

func (*PostQuantum) GenerateQuantumProof

func (pq *PostQuantum) GenerateQuantumProof(ctx context.Context, blockID ids.ID) ([]byte, error)

GenerateQuantumProof generates a quantum-resistant proof

func (*PostQuantum) HealthCheck

func (pq *PostQuantum) HealthCheck(ctx context.Context) (interface{}, error)

HealthCheck performs a health check

func (*PostQuantum) IsBootstrapped

func (pq *PostQuantum) IsBootstrapped() bool

IsBootstrapped returns whether the engine is bootstrapped

func (*PostQuantum) Start

func (pq *PostQuantum) Start(ctx context.Context, requestID uint32) error

Start starts the engine

func (*PostQuantum) Stop

func (pq *PostQuantum) Stop(ctx context.Context) error

Stop stops the engine

func (*PostQuantum) VerifyQuantumSignature

func (pq *PostQuantum) VerifyQuantumSignature(message, signature, publicKey []byte) error

VerifyQuantumSignature verifies a post-quantum signature

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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