mpc

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KEYGEN1          = "KGRound1Message"
	KEYGEN2aUnicast  = "KGRound2Message1"
	KEYGEN2b         = "KGRound2Message2"
	KEYGEN3          = "KGRound3Message"
	KEYSIGN1aUnicast = "SignRound1Message1"
	KEYSIGN1b        = "SignRound1Message2"
	KEYSIGN2Unicast  = "SignRound2Message"
	KEYSIGN3         = "SignRound3Message"
	KEYSIGN4         = "SignRound4Message"
	KEYSIGN5         = "SignRound5Message"
	KEYSIGN6         = "SignRound6Message"
	KEYSIGN7         = "SignRound7Message"
	KEYSIGN8         = "SignRound8Message"
	KEYSIGN9         = "SignRound9Message"
	TSSKEYGENROUNDS  = 4
	TSSKEYSIGNROUNDS = 10
)
View Source
const (
	EDDSA_KEYGEN1          = "KGRound1Message"
	EDDSA_KEYGEN2aUnicast  = "KGRound2Message1"
	EDDSA_KEYGEN2b         = "KGRound2Message2"
	EDDSA_KEYSIGN1         = "SignRound1Message"
	EDDSA_KEYSIGN2         = "SignRound2Message"
	EDDSA_KEYSIGN3         = "SignRound3Message"
	EDDSA_TSSKEYGENROUNDS  = 3
	EDDSA_TSSKEYSIGNROUNDS = 3
)
View Source
const (
	PurposeKeygen string = "keygen"
	PurposeSign   string = "sign"
)
View Source
const (
	ReadinessCheckPeriod = 1 * time.Second
)
View Source
const (
	TypeGenerateWalletSuccess = "mpc.mpc_keygen_success.%s"
)

Variables

View Source
var (
	ErrNotEnoughParticipants = errors.New("Not enough participants to sign")
)

Functions

func ComparePartyIDs

func ComparePartyIDs(x, y *tss.PartyID) bool

func ComposeReadyKey

func ComposeReadyKey(nodeID string) string

func CreatePartyID

func CreatePartyID(nodeID string, label string) *tss.PartyID

func NewRegistry

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

func PartyIDToNodeID

func PartyIDToNodeID(partyID *tss.PartyID) string

Types

type EDDSAKeygenSession

type EDDSAKeygenSession struct {
	Session
	// contains filtered or unexported fields
}

func NewEDDSAKeygenSession

func NewEDDSAKeygenSession(
	walletID string,
	pubSub messaging.PubSub,
	direct messaging.DirectMessaging,
	participantPeerIDs []string,
	selfID *tss.PartyID,
	partyIDs []*tss.PartyID,
	threshold int,
	kvstore kvstore.KVStore,
	keyinfoStore keyinfo.Store,
	resultQueue messaging.MessageQueue,
	identityStore identity.Store,
) *EDDSAKeygenSession

func (*EDDSAKeygenSession) GenerateKey

func (s *EDDSAKeygenSession) GenerateKey(done func())

func (*EDDSAKeygenSession) Init

func (s *EDDSAKeygenSession) Init()

type EDDSAKeygenSuccessEvent

type EDDSAKeygenSuccessEvent struct {
	WalletID string `json:"wallet_id"`
	PubKey   []byte `json:"pub_key"`
}

type EDDSASigningSession

type EDDSASigningSession struct {
	Session
	// contains filtered or unexported fields
}

func NewEDDSASigningSession

func NewEDDSASigningSession(
	walletID string,
	txID string,
	networkInternalCode string,
	pubSub messaging.PubSub,
	direct messaging.DirectMessaging,
	participantPeerIDs []string,
	selfID *tss.PartyID,
	partyIDs []*tss.PartyID,
	threshold int,
	kvstore kvstore.KVStore,
	keyinfoStore keyinfo.Store,
	resultQueue messaging.MessageQueue,
	identityStore identity.Store,
) *EDDSASigningSession

func (*EDDSASigningSession) Init

func (s *EDDSASigningSession) Init(tx *big.Int) error

func (*EDDSASigningSession) Sign

func (s *EDDSASigningSession) Sign(onSuccess func(data []byte))

type GetRoundFunc

type GetRoundFunc func(msg []byte, partyID *tss.PartyID, isBroadcast bool) (RoundInfo, error)

type ID

type ID string

type ISession

type ISession interface {
	ErrChan() <-chan error
	ListenToIncomingMessageAsync()
}

type ISigningSession

type ISigningSession interface {
	ISession

	Init(tx *big.Int) error
	Sign(onSuccess func(data []byte))
}

type KeyComposerFn

type KeyComposerFn func(id string) string

type KeyType

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

type KeygenSession

type KeygenSession struct {
	Session
	// contains filtered or unexported fields
}

func NewKeygenSession

func NewKeygenSession(
	walletID string,
	pubSub messaging.PubSub,
	direct messaging.DirectMessaging,
	participantPeerIDs []string,
	selfID *tss.PartyID,
	partyIDs []*tss.PartyID,
	threshold int,
	preParams *keygen.LocalPreParams,
	kvstore kvstore.KVStore,
	keyinfoStore keyinfo.Store,
	resultQueue messaging.MessageQueue,
	identityStore identity.Store,
) *KeygenSession

func (*KeygenSession) GenerateKey

func (s *KeygenSession) GenerateKey(done func())

func (*KeygenSession) Init

func (s *KeygenSession) Init()

type KeygenSuccessEvent

type KeygenSuccessEvent struct {
	WalletID    string `json:"wallet_id"`
	ECDSAPubKey []byte `json:"ecdsa_pub_key"`
	EDDSAPubKey []byte `json:"eddsa_pub_key"`
}

type Node

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

func NewNode

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

func (*Node) Close

func (p *Node) Close()

func (*Node) CreateEDDSAKeyGenSession

func (p *Node) CreateEDDSAKeyGenSession(walletID string, threshold int, successQueue messaging.MessageQueue) (*EDDSAKeygenSession, error)

func (*Node) CreateEDDSASigningSession

func (p *Node) CreateEDDSASigningSession(
	walletID string,
	txID string,
	networkInternalCode string,
	threshold int,
	resultQueue messaging.MessageQueue,
) (*EDDSASigningSession, error)

func (*Node) CreateKeyGenSession

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

func (*Node) CreateSigningSession

func (p *Node) CreateSigningSession(
	walletID string,
	txID string,
	networkInternalCode string,
	threshold int,
	resultQueue messaging.MessageQueue,
) (*SigningSession, error)

func (*Node) ID

func (p *Node) ID() string

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
}

type RoundInfo

type RoundInfo struct {
	Index         int
	RoundMsg      string
	MsgIdentifier string
}

func GetEcdsaMsgRound

func GetEcdsaMsgRound(msg []byte, partyID *tss.PartyID, isBroadcast bool) (RoundInfo, error)

func GetEddsaMsgRound

func GetEddsaMsgRound(msg []byte, partyID *tss.PartyID, isBroadcast bool) (RoundInfo, error)

type Session

type Session struct {
	ErrCh chan error
	// contains filtered or unexported fields
}

func (*Session) Close

func (s *Session) Close() error

func (*Session) ErrChan

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

func (*Session) GetPubKeyResult

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

func (*Session) ListenToIncomingMessageAsync

func (s *Session) ListenToIncomingMessageAsync()

func (*Session) PartyCount

func (s *Session) PartyCount() int

func (*Session) PartyID

func (s *Session) PartyID() *tss.PartyID

func (*Session) PartyIDs

func (s *Session) PartyIDs() []*tss.PartyID

func (*Session) SendReplySignSuccess

func (s *Session) SendReplySignSuccess(natMsg *nats.Msg)

type SessionType

type SessionType string
const (
	SessionTypeEcdsa SessionType = "session_ecdsa"
	SessionTypeEddsa SessionType = "session_eddsa"
)

type SigningSession

type SigningSession struct {
	Session
	// contains filtered or unexported fields
}

Ecdsa signing session

func NewSigningSession

func NewSigningSession(
	walletID string,
	txID string,
	networkInternalCode string,
	pubSub messaging.PubSub,
	direct messaging.DirectMessaging,
	participantPeerIDs []string,
	selfID *tss.PartyID,
	partyIDs []*tss.PartyID,
	threshold int,
	preParams *keygen.LocalPreParams,
	kvstore kvstore.KVStore,
	keyinfoStore keyinfo.Store,
	resultQueue messaging.MessageQueue,
	identityStore identity.Store,
) *SigningSession

func (*SigningSession) Init

func (s *SigningSession) Init(tx *big.Int) error

func (*SigningSession) Sign

func (s *SigningSession) Sign(onSuccess func(data []byte))

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