mpc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PurposeKeygen  string = "keygen"
	PurposeSign    string = "sign"
	PurposeReshare string = "reshare"

	DefaultVersion int = 1
)
View Source
const (
	ReadinessCheckPeriod = 1 * time.Second
)

Variables

View Source
var (
	ErrNotEnoughParticipants = errors.New("Not enough participants to sign")
	ErrNotInParticipantList  = errors.New("Node is not in the participant list")
)

Functions

func ComposeReadyKey

func ComposeReadyKey(nodeID string) string

func NewRegistry

func NewRegistry(
	nodeID string,
	peerNodeIDs []string,
	consulKV infra.ConsulKV,
) *registry

func PartyIDToRoutingDest

func PartyIDToRoutingDest(partyID party.ID) string

Helper function to get party routing destination

Types

type BaseReshareSession

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

BaseReshareSession provides common functionality for reshare sessions

func (*BaseReshareSession) ErrChan

func (s *BaseReshareSession) ErrChan() <-chan error

func (*BaseReshareSession) GetPubKeyResult

func (s *BaseReshareSession) GetPubKeyResult() []byte

GetPubKeyResult returns the public key after successful resharing

func (*BaseReshareSession) IsNewPeer

func (s *BaseReshareSession) IsNewPeer() bool

IsNewPeer returns true if this node is joining as a new peer

func (*BaseReshareSession) ListenToIncomingMessageAsync

func (s *BaseReshareSession) ListenToIncomingMessageAsync()

func (*BaseReshareSession) ProcessInboundMessage

func (s *BaseReshareSession) ProcessInboundMessage(msgBytes []byte)

func (*BaseReshareSession) ProcessOutboundMessage

func (s *BaseReshareSession) ProcessOutboundMessage()

func (*BaseReshareSession) Stop

func (s *BaseReshareSession) Stop()

type ID

type ID string

type KMSEnabledKVStore

type KMSEnabledKVStore struct {
	kvstore.KVStore
	// contains filtered or unexported fields
}

KMSEnabledKVStore wraps a regular KVStore with KMS encryption

func NewKMSEnabledKVStore

func NewKMSEnabledKVStore(store kvstore.KVStore, nodeID string) (*KMSEnabledKVStore, error)

NewKMSEnabledKVStore creates a new KMS-enabled KV store

func (*KMSEnabledKVStore) Delete

func (k *KMSEnabledKVStore) Delete(key string) error

Delete removes a value and its KMS entry if applicable

func (*KMSEnabledKVStore) Get

func (k *KMSEnabledKVStore) Get(key string) ([]byte, error)

Get retrieves a value with KMS decryption if needed

func (*KMSEnabledKVStore) Put

func (k *KMSEnabledKVStore) Put(key string, value []byte) error

Put stores a value with KMS encryption if enabled

type KeyComposerFn

type KeyComposerFn func(id string) string

type KeyGenSession

type KeyGenSession interface {
	Session
}

type KeyType

type KeyType string
const (
	KeyTypeSecp256k1 KeyType = "secp256k1"
	KeyTypeEd25519   KeyType = "ed25519"
)

type Node

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

func NewNode

func NewNode(
	nodeID string,
	peerIDs []string,
	pubSub messaging.PubSub,
	kvstore kvstore.KVStore,
	keyinfoStore keyinfo.Store,
	peerRegistry PeerRegistry,
	identityStore identity.Store,
) *Node

func (*Node) CreateKeyGenSession

func (p *Node) CreateKeyGenSession(
	walletID string,
	threshold int,
	resultQueue messaging.MessageQueue,
) (KeyGenSession, error)

func (*Node) CreateReshareSession

func (p *Node) CreateReshareSession(
	sessionType SessionType,
	walletID string,
	threshold int,
	newThreshold int,
	newNodeIDs []string,
	isNewPeer bool,
	resultQueue messaging.MessageQueue,
) (ReshareSession, error)

func (*Node) CreateSignSession

func (p *Node) CreateSignSession(
	sessionID string,
	walletID string,
	messageHash []byte,
	signerPeerIDs []string,
	resultQueue messaging.MessageQueue,
	useBroadcast bool,
) (SignSession, error)

func (*Node) ID

func (p *Node) ID() string

func (*Node) KeyInfoStore

func (p *Node) KeyInfoStore() keyinfo.Store

type PeerRegistry

type PeerRegistry interface {
	Ready() error
	ArePeersReady() bool
	WatchPeersReady()
	// Resign is called by the node when it is going to shutdown
	Resign() error
	GetReadyPeersCount() int64
	GetReadyPeersIncludeSelf() []string // get ready peers include self
	GetTotalPeersCount() int64
}

type ReshareSession

type ReshareSession interface {
	Session

	// Reshare starts the resharing protocol
	Reshare(done func())

	// GetPubKeyResult returns the public key after successful resharing
	GetPubKeyResult() []byte

	// IsNewPeer returns true if this node is joining as a new peer
	IsNewPeer() bool
}

ReshareSession represents a threshold signature resharing session

type Session

type Session interface {
	ListenToIncomingMessageAsync()
	ErrChan() <-chan error
	Init()
	ProcessOutboundMessage()
	WaitForFinish() string
}

type SessionType

type SessionType string
const (
	TypeGenerateWalletResultFmt = "mpc.mpc_keygen_result.%s"
	TypeReshareWalletResultFmt  = "mpc.mpc_reshare_result.%s"

	SessionTypeCGGMP21 SessionType = "session_cggmp21"
	SessionTypeECDSA   SessionType = "ecdsa"
	SessionTypeEDDSA   SessionType = "eddsa"
)

type SignSession

type SignSession interface {
	Session
}

type TopicComposer

type TopicComposer struct {
	ComposeBroadcastTopic func() string
	ComposeDirectTopic    func(nodeID string) string
}

Jump to

Keyboard shortcuts

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