aggregated

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatedSignature

type AggregatedSignature struct {
	Type           SignatureType         `json:"type"`
	Signature      []byte                `json:"signature"`
	SignerIDs      []ids.NodeID          `json:"signerIds,omitempty"`
	SignerCount    int                   `json:"signerCount"`
	RingPublicKeys []*ringtail.PublicKey `json:"ringPublicKeys,omitempty"` // For Ringtail
	AggregateKey   []byte                `json:"aggregateKey,omitempty"`   // For BLS
	Threshold      int                   `json:"threshold,omitempty"`      // For CGGMP21
	TotalFee       uint64                `json:"totalFee"`
}

AggregatedSignature represents an aggregated signature with metadata

type AggregationSession

type AggregationSession struct {
	SessionID     string
	Message       []byte
	SignatureType SignatureType

	// Collected signatures
	BLSSignatures      []*bls.Signature
	BLSPublicKeys      []*bls.PublicKey
	RingtailSignatures []*ringtail.RingSignature
	RingtailRing       []*ringtail.PublicKey

	// Signers
	Signers     map[ids.NodeID]bool
	SignerCount int

	// Status
	StartTime int64
	Completed bool
	Result    *AggregatedSignature
}

AggregationSession represents an active signature aggregation

type BLSManager

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

BLSManager manages BLS signature operations

func NewBLSManager

func NewBLSManager(log logging.Logger) *BLSManager

NewBLSManager creates a new BLS manager

func (*BLSManager) CreateKeyPair

func (m *BLSManager) CreateKeyPair() (*bls.SecretKey, *bls.PublicKey, error)

CreateKeyPair generates a new BLS key pair

func (*BLSManager) Sign

func (m *BLSManager) Sign(sk *bls.SecretKey, message []byte) (*bls.Signature, error)

Sign creates a BLS signature

type CGGMP21Manager

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

CGGMP21Manager manages CGGMP21 threshold signature operations

func NewCGGMP21Manager

func NewCGGMP21Manager(log logging.Logger) *CGGMP21Manager

NewCGGMP21Manager creates a new CGGMP21 manager

func (*CGGMP21Manager) GetParty

func (m *CGGMP21Manager) GetParty(index int) (*cggmp21.Party, error)

GetParty retrieves a CGGMP21 party by index

func (*CGGMP21Manager) InitializeParty

func (m *CGGMP21Manager) InitializeParty(
	partyID ids.NodeID,
	index int,
	config *cggmp21.Config,
) error

InitializeParty creates a new CGGMP21 party

type FeeCollector

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

FeeCollector manages fee collection for signature operations

func NewFeeCollector

func NewFeeCollector() FeeCollector

NewFeeCollector creates a new fee collector

func (*FeeCollector) CollectFee

func (fc *FeeCollector) CollectFee(sigType SignatureType, amount uint64)

CollectFee records a fee collection

func (*FeeCollector) GetCollectedFees

func (fc *FeeCollector) GetCollectedFees() map[SignatureType]uint64

GetCollectedFees returns total collected fees by type

func (*FeeCollector) GetTotalFees

func (fc *FeeCollector) GetTotalFees() uint64

GetTotalFees returns the total of all collected fees

func (*FeeCollector) ResetFees

func (fc *FeeCollector) ResetFees() map[SignatureType]uint64

ResetFees resets the fee collection

type RingtailManager

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

RingtailManager manages Ringtail signature operations

func NewRingtailManager

func NewRingtailManager(log logging.Logger) *RingtailManager

NewRingtailManager creates a new Ringtail manager

func (*RingtailManager) CreateKeyPair

func (m *RingtailManager) CreateKeyPair() (*ringtail.PrivateKey, *ringtail.PublicKey, error)

CreateKeyPair generates a new Ringtail key pair

func (*RingtailManager) Sign

func (m *RingtailManager) Sign(
	sk *ringtail.PrivateKey,
	message []byte,
	ring []*ringtail.PublicKey,
) (*ringtail.RingSignature, error)

Sign creates a Ringtail ring signature

type SignatureAggregator

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

SignatureAggregator manages network-wide signature aggregation

func NewSignatureAggregator

func NewSignatureAggregator(config SignatureConfig, log logging.Logger) (*SignatureAggregator, error)

NewSignatureAggregator creates a new signature aggregator

func (*SignatureAggregator) AddSignature

func (sa *SignatureAggregator) AddSignature(
	sessionID string,
	signerID ids.NodeID,
	signature []byte,
	publicKey []byte,
) error

AddSignature adds a signature to an aggregation session

func (*SignatureAggregator) Cleanup

func (sa *SignatureAggregator) Cleanup(maxAge int64)

Cleanup removes old sessions

func (*SignatureAggregator) FinalizeAggregation

func (sa *SignatureAggregator) FinalizeAggregation(
	sessionID string,
	requiredSigners int,
) (*AggregatedSignature, error)

FinalizeAggregation completes the aggregation and returns the result

func (*SignatureAggregator) GetSessionStatus

func (sa *SignatureAggregator) GetSessionStatus(sessionID string) (map[string]interface{}, error)

GetSessionStatus returns the status of an aggregation session

func (*SignatureAggregator) StartAggregation

func (sa *SignatureAggregator) StartAggregation(
	sessionID string,
	message []byte,
	sigType SignatureType,
	expectedSigners int,
) error

StartAggregation starts a new signature aggregation session

func (*SignatureAggregator) VerifyAggregatedSignature

func (sa *SignatureAggregator) VerifyAggregatedSignature(
	message []byte,
	aggSig *AggregatedSignature,
) error

VerifyAggregatedSignature verifies an aggregated signature

type SignatureConfig

type SignatureConfig struct {
	// Network-wide signature type preference
	PreferredType SignatureType `json:"preferredType"`

	// Enable specific signature types
	EnableBLS      bool `json:"enableBLS"`
	EnableRingtail bool `json:"enableRingtail"`
	EnableCGGMP21  bool `json:"enableCGGMP21"`

	// Fee configuration (in nLUX - nano LUX)
	BLSFee      uint64 `json:"blsFee"`      // 0 = free
	RingtailFee uint64 `json:"ringtailFee"` // Premium for enhanced privacy
	CGGMP21Fee  uint64 `json:"cggmp21Fee"`  // Premium for threshold signatures

	// Performance settings
	ParallelAggregation bool `json:"parallelAggregation"`
	MaxSignersPerRound  int  `json:"maxSignersPerRound"`

	// Security settings
	MinSigners     int     `json:"minSigners"`
	ThresholdRatio float64 `json:"thresholdRatio"` // e.g., 0.67 for 2/3
}

SignatureConfig contains configuration for signature aggregation

type SignatureType

type SignatureType uint8

SignatureType represents the type of aggregated signature

const (
	SignatureTypeBLS SignatureType = iota
	SignatureTypeRingtail
	SignatureTypeCGGMP21
)

Jump to

Keyboard shortcuts

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