mpc

package
v3.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package mpc is a client of mpc server, doing the sign and accept tasks.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGetSignStatusTimeout     = errors.New("getSignStatus timeout")
	ErrGetSignStatusFailed      = errors.New("getSignStatus failure")
	ErrGetSignStatusHasDisagree = errors.New("getSignStatus has disagree")
)

get mpc sign status error

Functions

func BuildMPCRawTx

func BuildMPCRawTx(nonce uint64, payload []byte, keyWrapper *keystore.Key) (string, error)

BuildMPCRawTx build mpc raw tx

func Init

func Init(isServer bool)

Init init mpc

Types

type AcceptData

type AcceptData struct {
	TxType     string
	Key        string
	Accept     string
	MsgHash    []string
	MsgContext []string
	TimeStamp  string
}

AcceptData accpet data

type Config added in v3.6.0

type Config struct {
	IsFastMPC bool

	GetAcceptListLoopInterval  uint64
	GetAcceptListRetryInterval uint64
	MaxAcceptSignTimeInterval  int64
	PendingInvalidAccept       bool
	// contains filtered or unexported fields
}

Config mpc config

func GetMPCConfig added in v3.6.0

func GetMPCConfig(isFastMPC bool) *Config

GetMPCConfig get mpc config

func InitConfig added in v3.6.0

func InitConfig(mpcParams *params.MPCConfig, isServer bool) *Config

InitConfig init mpc config

func (*Config) AcceptSign added in v3.6.0

func (c *Config) AcceptSign(raw string) (string, error)

AcceptSign call acceptSign

func (*Config) DoAcceptSign added in v3.6.0

func (c *Config) DoAcceptSign(keyID, agreeResult string, msgHash, msgContext []string) (string, error)

DoAcceptSign accept sign

func (*Config) DoSign added in v3.6.0

func (c *Config) DoSign(signType, signPubkey string, msgHash, msgContext []string) (keyID string, rsvs []string, err error)

DoSign mpc sign msgHash with context msgContext

func (*Config) DoSignOne added in v3.6.0

func (c *Config) DoSignOne(signType, signPubkey, msgHash, msgContext string) (keyID string, rsvs []string, err error)

DoSignOne mpc sign single msgHash with context msgContext

func (*Config) DoSignOneEC added in v3.6.0

func (c *Config) DoSignOneEC(signPubkey, msgHash, msgContext string) (keyID string, rsvs []string, err error)

DoSignOneEC mpc sign single msgHash with context msgContext

func (*Config) DoSignOneED added in v3.6.0

func (c *Config) DoSignOneED(signPubkey, msgHash, msgContext string) (keyID string, rsvs []string, err error)

DoSignOneED mpc sign single msgHash with context msgContext

func (*Config) GetAllEnodes added in v3.6.0

func (c *Config) GetAllEnodes() []string

GetAllEnodes get all enodes

func (*Config) GetAllInitiatorNodes added in v3.6.0

func (c *Config) GetAllInitiatorNodes() []*NodeInfo

GetAllInitiatorNodes get all initiator mpc node info

func (*Config) GetCurNodeSignInfo added in v3.6.0

func (c *Config) GetCurNodeSignInfo(expiredInterval int64) ([]*SignInfoData, error)

GetCurNodeSignInfo call getCurNodeSignInfo filter out invalid sign info and filter out expired sign info if `expiredInterval` is greater than 0

func (*Config) GetEnode added in v3.6.0

func (c *Config) GetEnode(rpcAddr string) (string, error)

GetEnode call getEnode

func (*Config) GetGroupByID added in v3.6.0

func (c *Config) GetGroupByID(groupID, rpcAddr string) (*GroupInfo, error)

GetGroupByID call getGroupByID

func (*Config) GetGroupID added in v3.6.0

func (c *Config) GetGroupID() string

GetGroupID return mpc group id

func (*Config) GetSelfEnode added in v3.6.0

func (c *Config) GetSelfEnode() string

GetSelfEnode get self enode

func (*Config) GetSignNonce added in v3.6.0

func (c *Config) GetSignNonce(mpcUser, rpcAddr string) (uint64, error)

GetSignNonce call getSignNonce

func (*Config) GetSignStatus added in v3.6.0

func (c *Config) GetSignStatus(key, rpcAddr string) (*SignStatus, error)

GetSignStatus call getSignStatus

func (*Config) GetSignStatusByKeyID added in v3.6.0

func (c *Config) GetSignStatusByKeyID(keyID string) (rsvs []string, err error)

GetSignStatusByKeyID get sign status by keyID

func (*Config) IsMPCInitiator added in v3.6.0

func (c *Config) IsMPCInitiator(account string) bool

IsMPCInitiator is initiator of mpc sign

func (*Config) IsSwapServer added in v3.6.0

func (c *Config) IsSwapServer() bool

IsSwapServer returns if this mpc user is the swap server

func (*Config) Sign added in v3.6.0

func (c *Config) Sign(raw, rpcAddr string) (string, error)

Sign call sign

type DataEnode

type DataEnode struct {
	Enode string
}

DataEnode enode

type DataResult

type DataResult struct {
	Result string `json:"result"`
}

DataResult result

type DataResultResp

type DataResultResp struct {
	Status string
	Tip    string
	Error  string
	Data   *DataResult
}

DataResultResp result response

type GetEnodeResp

type GetEnodeResp struct {
	Status string
	Tip    string
	Error  string
	Data   *DataEnode
}

GetEnodeResp enode response

type GetGroupByIDResp

type GetGroupByIDResp struct {
	Status string
	Tip    string
	Error  string
	Data   *GroupInfo
}

GetGroupByIDResp group response

type GroupInfo

type GroupInfo struct {
	GID    string
	Count  int
	Enodes []string
}

GroupInfo group info

type NodeInfo

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

NodeInfo mpc node info

func (*NodeInfo) GetMPCRPCAddress

func (ni *NodeInfo) GetMPCRPCAddress() string

GetMPCRPCAddress get mpc node rpc address

func (*NodeInfo) GetMPCUser

func (ni *NodeInfo) GetMPCUser() common.Address

GetMPCUser returns the mpc user of specified keystore

func (*NodeInfo) LoadKeyStore

func (ni *NodeInfo) LoadKeyStore(keyfile, passfile string) (common.Address, error)

LoadKeyStore load keystore

type SignData

type SignData struct {
	TxType     string
	PubKey     string
	MsgHash    []string
	MsgContext []string
	Keytype    string
	GroupID    string
	ThresHold  string
	Mode       string
	TimeStamp  string
}

SignData sign data

type SignInfoData

type SignInfoData struct {
	Account    string
	GroupID    string
	Key        string
	KeyType    string
	Mode       string
	MsgHash    []string
	MsgContext []string
	Nonce      string
	PubKey     string
	ThresHold  string
	TimeStamp  string
	// contains filtered or unexported fields
}

SignInfoData sign info

func (*SignInfoData) HasValidSignature added in v3.5.0

func (s *SignInfoData) HasValidSignature() bool

HasValidSignature has valid signature

func (*SignInfoData) IsValid added in v3.4.0

func (s *SignInfoData) IsValid(verifySignature bool) bool

IsValid is valid

type SignInfoResp

type SignInfoResp struct {
	Status string
	Tip    string
	Error  string
	Data   []*SignInfoData
}

SignInfoResp sign info response

type SignInfoSortedSlice added in v3.4.0

type SignInfoSortedSlice []*SignInfoData

SignInfoSortedSlice weighted string slice

func (SignInfoSortedSlice) Len added in v3.4.0

func (s SignInfoSortedSlice) Len() int

Len impl Sortable

func (SignInfoSortedSlice) Less added in v3.4.0

func (s SignInfoSortedSlice) Less(i, j int) bool

Less impl Sortable

func (SignInfoSortedSlice) Swap added in v3.4.0

func (s SignInfoSortedSlice) Swap(i, j int)

Swap impl Sortable

type SignReply

type SignReply struct {
	Enode     string
	Status    string
	TimeStamp string
	Initiator string
}

SignReply sign reply

type SignStatus

type SignStatus struct {
	Status    string
	Rsv       []string
	Tip       string
	Error     string
	AllReply  []*SignReply
	TimeStamp string
}

SignStatus sign status

func (*SignStatus) HasDisagree added in v3.4.0

func (s *SignStatus) HasDisagree() bool

HasDisagree has disagree reply

Jump to

Keyboard shortcuts

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