threshold

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 tchain provides T-Chain (Teleport) adapter for DAG indexing. T-Chain handles MPC threshold signatures for cross-chain teleportation.

Index

Constants

View Source
const (
	// DefaultRPCEndpoint for T-Chain on port 4700
	DefaultRPCEndpoint = "http://localhost:9650/ext/bc/T/rpc"
	// DefaultHTTPPort for T-Chain indexer API
	DefaultHTTPPort = 4700
)

Variables

This section is empty.

Functions

func ComputeThreshold

func ComputeThreshold(totalShares uint32) uint32

ComputeThreshold computes required threshold for given parameters. Uses t-of-n threshold where t = (n * 2 / 3) + 1 for Byzantine fault tolerance.

func DefaultConfig

func DefaultConfig() dag.Config

DefaultConfig returns default configuration for T-Chain indexer

func ValidateSignature

func ValidateSignature(_, _, _ string) (bool, error)

ValidateSignature validates a threshold signature. Threshold signature verification requires the T-Chain node; it cannot be done client-side.

Types

type Adapter

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

Adapter implements dag.Adapter for T-Chain MPC operations

func New

func New(rpcEndpoint string) *Adapter

NewAdapter creates a new T-Chain adapter

func (*Adapter) GetActiveKeyShares

func (a *Adapter) GetActiveKeyShares(ctx context.Context, publicKey string) ([]KeyShare, error)

GetActiveKeyShares fetches active key shares for a public key

func (*Adapter) GetKeyGeneration

func (a *Adapter) GetKeyGeneration(ctx context.Context, keyGenID string) (*KeyGeneration, error)

GetKeyGeneration fetches a key generation ceremony by ID

func (*Adapter) GetRecentVertices

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

GetRecentVertices fetches recent vertices via RPC

func (*Adapter) GetSigningSession

func (a *Adapter) GetSigningSession(ctx context.Context, sessionID string) (*SigningSession, error)

GetSigningSession fetches a signing session by ID

func (*Adapter) GetStats

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

GetStats returns T-Chain specific statistics

func (*Adapter) GetVertexByID

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

GetVertexByID fetches a specific vertex

func (*Adapter) InitSchema

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

InitSchema creates T-Chain specific database tables

func (*Adapter) ParseVertex

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

ParseVertex parses T-Chain vertex from RPC response

func (*Adapter) StoreKeyGeneration

func (a *Adapter) StoreKeyGeneration(ctx context.Context, store storage.Store, kg *KeyGeneration) error

StoreKeyGeneration stores a key generation ceremony

func (*Adapter) StoreKeyShare

func (a *Adapter) StoreKeyShare(ctx context.Context, store storage.Store, k *KeyShare) error

StoreKeyShare stores a key share

func (*Adapter) StoreMessage

func (a *Adapter) StoreMessage(ctx context.Context, store storage.Store, m *TeleportMessage) error

StoreMessage stores a teleport message

func (*Adapter) StoreSession

func (a *Adapter) StoreSession(ctx context.Context, store storage.Store, s *SigningSession) error

StoreSession stores a signing session

type KeyGeneration

type KeyGeneration struct {
	ID           string     `json:"id"`
	Threshold    uint32     `json:"threshold"`
	TotalShares  uint32     `json:"totalShares"`
	PublicKey    string     `json:"publicKey"` // combined public key
	Participants []string   `json:"participants"`
	Status       string     `json:"status"`
	CreatedAt    time.Time  `json:"createdAt"`
	CompletedAt  *time.Time `json:"completedAt,omitempty"`
}

KeyGeneration represents a distributed key generation ceremony

type KeyShare

type KeyShare struct {
	ID         string         `json:"id"`
	PublicKey  string         `json:"publicKey"`
	ShareIndex uint32         `json:"shareIndex"`
	NodeID     string         `json:"nodeId"`
	KeyGenID   string         `json:"keyGenId"` // key generation ceremony ID
	Status     KeyShareStatus `json:"status"`
	CreatedAt  time.Time      `json:"createdAt"`
	RotatedAt  *time.Time     `json:"rotatedAt,omitempty"`
	ExpiresAt  *time.Time     `json:"expiresAt,omitempty"`
}

KeyShare represents a distributed key share for MPC

type KeyShareStatus

type KeyShareStatus string

KeyShareStatus for distributed key shares

const (
	SharePending KeyShareStatus = "pending"
	ShareActive  KeyShareStatus = "active"
	ShareRevoked KeyShareStatus = "revoked"
	ShareRotated KeyShareStatus = "rotated"
)

type SessionStatus

type SessionStatus string

SessionStatus for MPC signing sessions

const (
	SessionPending   SessionStatus = "pending"
	SessionActive    SessionStatus = "active"
	SessionCompleted SessionStatus = "completed"
	SessionFailed    SessionStatus = "failed"
	SessionExpired   SessionStatus = "expired"
)

type SigningSession

type SigningSession struct {
	ID           string        `json:"id"`
	Threshold    uint32        `json:"threshold"`          // t of n threshold
	TotalShares  uint32        `json:"totalShares"`        // total participants
	MessageHash  string        `json:"messageHash"`        // hash being signed
	Participants []string      `json:"participants"`       // node IDs participating
	Signatures   []string      `json:"signatures"`         // partial signatures collected
	FinalSig     string        `json:"finalSig,omitempty"` // combined signature
	Status       SessionStatus `json:"status"`
	CreatedAt    time.Time     `json:"createdAt"`
	CompletedAt  *time.Time    `json:"completedAt,omitempty"`
	ExpiresAt    time.Time     `json:"expiresAt"`
	SourceChain  string        `json:"sourceChain,omitempty"`
	DestChain    string        `json:"destChain,omitempty"`
}

SigningSession represents an MPC threshold signing session

type TeleportMessage

type TeleportMessage struct {
	ID          string          `json:"id"`
	SourceChain string          `json:"sourceChain"`
	DestChain   string          `json:"destChain"`
	Sender      string          `json:"sender"`
	Receiver    string          `json:"receiver"`
	Payload     json.RawMessage `json:"payload"`
	Nonce       uint64          `json:"nonce"`
	SessionID   string          `json:"sessionId,omitempty"`
	Status      string          `json:"status"`
	CreatedAt   time.Time       `json:"createdAt"`
	SignedAt    *time.Time      `json:"signedAt,omitempty"`
	DeliveredAt *time.Time      `json:"deliveredAt,omitempty"`
}

TeleportMessage represents a cross-chain teleport message

type VertexData

type VertexData struct {
	Session  *SigningSession  `json:"session,omitempty"`
	KeyShare *KeyShare        `json:"keyShare,omitempty"`
	KeyGen   *KeyGeneration   `json:"keyGen,omitempty"`
	Message  *TeleportMessage `json:"message,omitempty"`
}

VertexData contains T-Chain specific vertex data

Jump to

Keyboard shortcuts

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