mpcrpc

package
v0.0.0-...-dd9cbf8 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package mpcrpc 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")
	ErrGetDKGStatusTimeout  = errors.New("getDKGStatus timeout")
	ErrGetDKGStatusFailed   = errors.New("getDKGStatus failure")
)

get mpc sign status error

Functions

func AcceptReqAddr

func AcceptReqAddr(raw string) (string, error)

AcceptReqAddr call acceptReqAddr

func AcceptSign

func AcceptSign(raw string) (string, error)

AcceptSign call acceptSign

func BuildMPCRawTx

func BuildMPCRawTx(nonce uint64, payload []byte) (string, error)

BuildMPCRawTx build mpc raw tx

func DoAcceptReqAddr

func DoAcceptReqAddr(keyID, agreeResult string) (string, error)

DoAcceptReqAddr accept request address

func DoAcceptSign

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

DoAcceptSign accept sign

func DoDKG

func DoDKG(enodeSigs []string) (keyID string, pubkey string, err error)

DoDKG mpc pubkic key generation

func DoSign

func DoSign(signPubkey string, msgHash, msgContext []string) (keyID string, rsvs []string, err error)

DoSign mpc sign msgHash with context msgContext

func DoSignOne

func DoSignOne(signPubkey, msgHash, msgContext string) (keyID string, rsvs []string, err error)

DoSignOne mpc sign single msgHash with context msgContext

func GetBigIntFromStr

func GetBigIntFromStr(str string) (*big.Int, error)

GetBigIntFromStr new big int from string.

func GetEnode

func GetEnode(rpcAddr string) (string, error)

GetEnode call getEnode

func GetReqAddrNonce

func GetReqAddrNonce(mpcUser, rpcAddr string) (uint64, error)

GetReqAddrNonce call getReqAddrNonce

func GetSignNonce

func GetSignNonce(mpcUser, rpcAddr string) (uint64, error)

GetSignNonce call getSignNonce

func GetSignStatusByKeyID

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

GetSignStatusByKeyID get sign status by keyID

func GetUint64FromStr

func GetUint64FromStr(str string) (uint64, error)

GetUint64FromStr get uint64 from string.

func Init

func Init(mpcConfig *MPCConfig, isSign bool)

Init init mpc

func NowMilliStr

func NowMilliStr() string

NowMilliStr returns now timestamp in miliseconds of string format.

func ParseUint64

func ParseUint64(s string) (uint64, bool)

ParseUint64 parses s as an integer in decimal or hexadecimal syntax. Leading zeros are accepted. The empty string parses as zero.

func ReqDcrmAddr

func ReqDcrmAddr(raw, rpcAddr string) (string, error)

ReqDcrmAddr call reqDcrmAddr

func Sign

func Sign(raw, rpcAddr string) (string, error)

Sign call sign

func SignContent

func SignContent(content []byte) (signature []byte, err error)

SignContent sign content

func SignWithKey

func SignWithKey(message []byte) ([]byte, error)

SignWithKey sign by mpc node user with private key

Types

type AcceptData

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

AcceptData accpet data

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

func GetGroupByID

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

GetGroupByID call getGroupByID

type MPCConfig

type MPCConfig struct {
	APIPrefix    string
	RPCAddress   string
	RPCTimeout   uint64
	KeystoreFile string `json:"-"`
	PasswordFile string `json:"-"`

	NeedKeyStore bool `json:"-"`
	IsDKG        bool `json:"-"`

	SignTimeout uint64
	SignType    string // eg. ECDSA
	SignGroup   string
	Threshold   string
	Mode        *uint64 // 0:managed 1:private
}

MPCConfig mpc related config

type ReqAddrData

type ReqAddrData struct {
	TxType    string
	GroupID   string
	ThresHold string
	Mode      string
	TimeStamp string
	Sigs      string
}

ReqAddrData request address data

type ReqAddrInfoData

type ReqAddrInfoData struct {
	Account   string
	Cointype  string
	GroupID   string
	Key       string
	Mode      string
	Nonce     string
	ThresHold string
	TimeStamp string
	// contains filtered or unexported fields
}

ReqAddrInfoData request address info data

func GetCurNodeReqAddrInfo

func GetCurNodeReqAddrInfo(expiredInterval int64) ([]*ReqAddrInfoData, error)

GetCurNodeReqAddrInfo call getCurNodeReqAddrInfo

func GetDKGAcceptList

func GetDKGAcceptList(user string, expiredInterval int64) ([]*ReqAddrInfoData, error)

GetDKGAcceptList get dkg accept list

func (*ReqAddrInfoData) IsValid

func (signInfo *ReqAddrInfoData) IsValid() bool

IsValid is valid

type ReqAddrInfoResp

type ReqAddrInfoResp struct {
	Status string
	Tip    string
	Error  string
	Data   []*ReqAddrInfoData
}

ReqAddrInfoResp request address info response

type ReqAddrInfoSortedSlice

type ReqAddrInfoSortedSlice []*ReqAddrInfoData

ReqAddrInfoSortedSlice sorted slice

func (ReqAddrInfoSortedSlice) Len

func (s ReqAddrInfoSortedSlice) Len() int

Len impl Sortable

func (ReqAddrInfoSortedSlice) Less

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

Less impl Sortable

func (ReqAddrInfoSortedSlice) Swap

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

Swap impl Sortable

type ReqAddrStatus

type ReqAddrStatus struct {
	Status    string
	PubKey    string
	Tip       string
	Error     string
	AllReply  []*SignReply
	TimeStamp string
}

ReqAddrStatus request address status

func GetReqAddrStatus

func GetReqAddrStatus(key, rpcAddr string) (*ReqAddrStatus, error)

GetReqAddrStatus call getReqAddrStatus

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 GetAcceptList

func GetAcceptList(user string, expiredInterval int64) ([]*SignInfoData, error)

GetAcceptList get accept list of 'user'

func GetCurNodeSignInfo

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

GetCurNodeSignInfo call getCurNodeSignInfo

func (*SignInfoData) IsValid

func (signInfo *SignInfoData) IsValid() bool

IsValid is valid

type SignInfoResp

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

SignInfoResp sign info response

type SignInfoSortedSlice

type SignInfoSortedSlice []*SignInfoData

SignInfoSortedSlice sorted slice

func (SignInfoSortedSlice) Len

func (s SignInfoSortedSlice) Len() int

Len impl Sortable

func (SignInfoSortedSlice) Less

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

Less impl Sortable

func (SignInfoSortedSlice) Swap

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 GetSignStatus

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

GetSignStatus call getSignStatus

Directories

Path Synopsis
Package client provides methods to do http GET / POST request.
Package client provides methods to do http GET / POST request.

Jump to

Keyboard shortcuts

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