coordinator

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateThreshold

func CalculateThreshold(numParticipants int) int

CalculateThreshold calculates the threshold as > 2/3 of participants. Formula: threshold = floor((2 * n) / 3) + 1 This ensures threshold > 2/3 * n

Types

type Coordinator

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

Coordinator handles coordinator logic for TSS events.

func NewCoordinator

func NewCoordinator(
	eventStore *eventstore.Store,
	pushCore *pushcore.Client,
	keyshareManager *keyshare.Manager,
	chains *chains.Chains,
	validatorAddress string,
	coordinatorRange uint64,
	pollInterval time.Duration,
	send SendFunc,
	logger zerolog.Logger,
) *Coordinator

NewCoordinator creates a new coordinator.

func (*Coordinator) GetCurrentTSSKey added in v0.0.13

func (c *Coordinator) GetCurrentTSSKey(ctx context.Context) (string, string, error)

GetCurrentTSSKey gets the current TSS key ID and public key from pushCore.

func (*Coordinator) GetEligibleUV

func (c *Coordinator) GetEligibleUV(protocolType string) []*types.UniversalValidator

GetEligibleUV returns eligible validators for the given protocol type. Uses cached allValidators for performance. For sign: returns ALL eligible validators (Active + Pending Leave), not a random subset. This is used for validation - the random subset selection happens only in processEventAsCoordinator.

func (*Coordinator) GetLatestBlockNum

func (c *Coordinator) GetLatestBlockNum(ctx context.Context) (uint64, error)

GetLatestBlockNum gets the latest block number from pushCore.

func (*Coordinator) GetMultiAddrsFromPeerID

func (c *Coordinator) GetMultiAddrsFromPeerID(ctx context.Context, peerID string) ([]string, error)

GetMultiAddrsFromPeerID gets the multiaddrs for a given peerID. Uses cached allValidators for performance.

func (*Coordinator) GetPartyIDFromPeerID

func (c *Coordinator) GetPartyIDFromPeerID(ctx context.Context, peerID string) (string, error)

GetPartyIDFromPeerID gets the partyID (validator address) for a given peerID. Uses cached allValidators for performance.

func (*Coordinator) GetPeerIDFromPartyID

func (c *Coordinator) GetPeerIDFromPartyID(ctx context.Context, partyID string) (string, error)

GetPeerIDFromPartyID gets the peerID for a given partyID (validator address). Uses cached allValidators for performance.

func (*Coordinator) GetTSSAddress added in v0.0.13

func (c *Coordinator) GetTSSAddress(ctx context.Context) (string, error)

GetTSSAddress returns the current TSS ECDSA address derived from the current TSS public key. This is a thin exported wrapper around the internal derivation logic so other packages can reuse it.

func (*Coordinator) HandleACK

func (c *Coordinator) HandleACK(ctx context.Context, senderPeerID string, eventID string) error

HandleACK processes an ACK message from a participant. This is called by the session manager when coordinator receives an ACK.

func (*Coordinator) IsPeerCoordinator

func (c *Coordinator) IsPeerCoordinator(ctx context.Context, peerID string) (bool, error)

IsPeerCoordinator checks if the given peerID is the coordinator for the current block. Uses cached allValidators for performance.

func (*Coordinator) Start

func (c *Coordinator) Start(ctx context.Context)

Start starts the coordinator loop.

func (*Coordinator) Stop

func (c *Coordinator) Stop()

Stop stops the coordinator loop.

type Message

type Message struct {
	Type         string   `json:"type"` // "setup", "ack", "begin", "step"
	EventID      string   `json:"eventId"`
	Payload      []byte   `json:"payload"`
	Participants []string `json:"participants"` // Array of PartyIDs (validator addresses) participating in this process

	// UnSignedOutboundTxReq is included for SIGN protocol setup messages.
	// Participants use this to verify the signing hash before proceeding.
	UnSignedOutboundTxReq *common.UnSignedOutboundTxReq `json:"unsigned_outbound_tx_req,omitempty"`
}

Message represents a simple message with type, eventId, payload, and participants.

type ProtocolType

type ProtocolType string

ProtocolType enumerates the supported DKLS protocol flows.

const (
	ProtocolKeygen       ProtocolType = "KEYGEN"
	ProtocolKeyrefresh   ProtocolType = "KEYREFRESH"
	ProtocolQuorumChange ProtocolType = "QUORUM_CHANGE"
	ProtocolSign         ProtocolType = "SIGN"
)

type SendFunc

type SendFunc func(ctx context.Context, peerID string, data []byte) error

SendFunc is a function type for sending messages to participants. peerID: The peer ID of the recipient data: The message bytes

Jump to

Keyboard shortcuts

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