protocol

package
v0.0.0-...-23aeb14 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MpcCreateLockAccountLeader = iota + 0
	MpcCreateLockAccountPeer
	MpcTXSignLeader
	MpcTXSignPeer
	MpcReady
)
View Source
const (
	StatusCode = iota + 0 // used by storeman protocol
	KeepaliveCode
	KeepaliveOkCode
	MSG_MPCError
	MSG_RequestPrepare
	MSG_RequestMPC // ask for a new mpc Context
	MSG_MPCMessage // get a message for a Context
	MSG_MPCFinish

	KeepaliveCycle
	NumberOfMessageCodes

	MPCDegree = 2
	//MPCDegree          = 1
	MPCTimeOut         = time.Second * 30
	ProtocolName       = "storeman"
	ProtocolVersion    = uint64(1)
	ProtocolVersionStr = "1.0"
)
View Source
const (
	MpcSeed          = "Seed"
	MpcPrivateShare  = "PrivateShare"
	MpcPrivateKey    = "PrivateKey"
	MpcPublicShare   = "PublicShare"
	MpcPointPart     = "PointPart"
	MpcSignASeed     = "SignASeed"
	MpcSignA         = "SignA"
	MpcSignA0        = "SignA0"
	MpcSignRSeed     = "SignRSeed"
	MpcSignR         = "SignR"
	MpcSignR0        = "SignR0"
	MpcSignB         = "SignB"
	MpcSignBSeed     = "SignBSeed"
	MpcSignC         = "SignC"
	MpcSignCSeed     = "SignCSeed"
	MpcSignARSeed    = "SignARSeed"
	MpcSignARResult  = "SignARResult"
	MpcTxSignSeed    = "TxSignSeed"
	MpcTxSignResultR = "TxSignResultR"
	MpcTxSignResultV = "TxSignResultV"
	MpcTxSignResult  = "TxSignResult"
	MpcContextResult = "ContextResult"

	PublicKeyResult = "PublicKeyResult"
	MpcSignAPoint   = "SignAPoint"
	MpcTxHash       = "TxHash"
	MpcLagrange     = "Lagrange"
	MpcTransaction  = "Transaction"
	MpcChainType    = "ChainType"
	MpcSignType     = "SignType"
	MpcChainID      = "ChainID"
	MpcAddress      = "Address"
	MPCAction       = "Action"
	MPCPolyvalue    = "Polyvalue"
	MPCSignedFrom   = "SignedFrom"
	MpcStmAccType   = "StmAccType"
)

Variables

View Source
var (
	ErrQuit              = errors.New("Quit")
	ErrMpcRequest        = errors.New("Mpc Request is not exist")
	ErrMpcResultExist    = errors.New("Mpc Result is not exist")
	ErrContextType       = errors.New("Err Context Type is error")
	ErrTimeOut           = errors.New("Mpc Requst is TimeOut")
	ErrAddress           = errors.New("Mpc Address is not found")
	ErrChainID           = errors.New("Mpc ChainID is not Defined")
	ErrPointZero         = errors.New("Mpc Point is zero")
	ErrChainTypeError    = errors.New("Mpc transaction chaintype error")
	ErrMpcSeedOutRange   = errors.New("Mpc seeds are out range")
	ErrMpcSeedDuplicate  = errors.New("Mpc seeds have duplicate")
	ErrDecrypt           = errors.New("could not decrypt key with given passphrase")
	ErrTooLessStoreman   = errors.New("Mpc alived Storeman is not enough")
	ErrTooMoreStoreman   = errors.New("Mpc alived Storeman is too more")
	ErrFailedTxVerify    = errors.New("Mpc signing transaction verify failed")
	ErrMpcContextExist   = errors.New("Mpc Context ID is already exist")
	ErrInvalidMPCAddr    = errors.New("Invalid mpc account address")
	ErrFailSignRetVerify = errors.New("Mpc signing result verify failed")
	ErrInvalidStmAccType = errors.New("invalid storeman account type! please input 'WAN' or 'ETH' or 'BTC' ")
	ErrMpcFinish         = errors.New("Mpc Context has been Finished")
)
View Source
var TLog = &TestLogger{
	LogMap: make(map[string]int),
}

Functions

func CheckAccountType

func CheckAccountType(accType string) bool

func GetPreSetKeyArr

func GetPreSetKeyArr(keySeed string, num int) []string

Types

type GetMessageInterface

type GetMessageInterface interface {
	HandleMessage(*StepMessage) bool
}

type MpcData

type MpcData struct {
	Key  string
	Data interface{}
}

func (*MpcData) DecodeRLP

func (md *MpcData) DecodeRLP(s *rlp.Stream) error

func (*MpcData) EncodeRLP

func (md *MpcData) EncodeRLP(w io.Writer) error

type MpcDataTemp

type MpcDataTemp struct {
	Key  string
	Data interface{}
}

type MpcLogger

type MpcLogger struct {
	Log bool
}

func (*MpcLogger) Debug

func (pl *MpcLogger) Debug(args ...interface{})

func (*MpcLogger) Debugf

func (pl *MpcLogger) Debugf(msg string, args ...interface{})

func (*MpcLogger) Debugln

func (pl *MpcLogger) Debugln(args ...interface{})

func (*MpcLogger) Error

func (pl *MpcLogger) Error(args ...interface{})

func (*MpcLogger) Errorf

func (pl *MpcLogger) Errorf(msg string, args ...interface{})

func (*MpcLogger) Errorln

func (pl *MpcLogger) Errorln(args ...interface{})

func (*MpcLogger) Fatal

func (pl *MpcLogger) Fatal(args ...interface{})

func (*MpcLogger) Fatalf

func (pl *MpcLogger) Fatalf(msg string, args ...interface{})

func (*MpcLogger) Fatalln

func (pl *MpcLogger) Fatalln(args ...interface{})

func (*MpcLogger) Info

func (pl *MpcLogger) Info(args ...interface{})

func (*MpcLogger) Infof

func (pl *MpcLogger) Infof(msg string, args ...interface{})

func (*MpcLogger) Infoln

func (pl *MpcLogger) Infoln(args ...interface{})

func (*MpcLogger) SetFormat

func (pl *MpcLogger) SetFormat(string) error

func (*MpcLogger) SetLevel

func (pl *MpcLogger) SetLevel(string) error

func (*MpcLogger) Warn

func (pl *MpcLogger) Warn(args ...interface{})

func (*MpcLogger) Warnf

func (pl *MpcLogger) Warnf(msg string, args ...interface{})

func (*MpcLogger) Warnln

func (pl *MpcLogger) Warnln(args ...interface{})

type MpcManager

type MpcManager interface {
	P2pMessage(*discover.NodeID, uint64, interface{}) error
	BoardcastMessage([]*discover.NodeID, uint64, interface{}) error
	SelfNodeId() *discover.NodeID
	CreateKeystore(MpcResultInterface, MpcNodeInterface) error
	SignTransaction(MpcResultInterface) error
}

type MpcMessage

type MpcMessage struct {
	ContextID common.Hash
	StepID    uint64
	Peers     []byte
	Data      []*MpcData
	Error     string
}

type MpcNodeInterface

type MpcNodeInterface interface {
	NeedQuorum() int
	Address() *common.MpcAddress
	Hash() *common.Hash
	Leader() *discover.NodeID
	FetchQuorum() bool
	RunNode(uint64, *discover.NodeID) MpcState
	AddNode(seed uint64, nodeId *discover.NodeID) error
	GetSeedsNum(seed uint64, nodeId *discover.NodeID) int
	SetState(MpcState)
	GetState() MpcState
	GetSeed(nodeId *discover.NodeID) uint64
	GetNodeId(seed uint64) *discover.NodeID
	GetPeers() []PeerInfo
	GetPeerIDs() []*discover.NodeID
}

type MpcResult

type MpcResult struct {
	Hash   common.Hash
	Result []byte
}

type MpcResultInterface

type MpcResultInterface interface {
	Initialize(preSetValue ...MpcValue)
	SetValue(key string, value interface{}) error
	GetValue(key string) (interface{}, error)
}

type MpcState

type MpcState int
const (
	MpcCollection MpcState = iota + 0
	MpcWaiting
	MpcRunning
	MpcFinish
	MpcNotFound
)

type MpcStepFunc

type MpcStepFunc interface {
	GetMessageInterface
	InitMessageLoop(GetMessageInterface) error
	Quit(error)
	InitStep() error
	CreateMessage() []StepMessage
	FinishStep(MpcManager) error
	GetMessageChan() chan *StepMessage
}

type MpcValue

type MpcValue struct {
	Key   string
	Value interface{}
}

type PeerInfo

type PeerInfo struct {
	PeerID *discover.NodeID
	Seed   uint64
}

type PeerMessage

type PeerMessage struct {
	From    discover.NodeID
	Message *p2p.Msg
}

type SlicePeers

type SlicePeers []*discover.NodeID

func (SlicePeers) Len

func (s SlicePeers) Len() int

func (SlicePeers) Less

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

func (SlicePeers) Swap

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

type StepMessage

type StepMessage struct {
	Msgcode uint64 //message code
	PeerID  *discover.NodeID
	Peers   []PeerInfo
	Data    []*MpcData
}

type TestLogger

type TestLogger struct {
	LogMap map[string]int
	// contains filtered or unexported fields
}

func (*TestLogger) Error

func (lg *TestLogger) Error(format string, ctx ...interface{})

Jump to

Keyboard shortcuts

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