-
Notifications
You must be signed in to change notification settings - Fork 4
/
mpc_ctx_factory.go
40 lines (33 loc) · 1.2 KB
/
mpc_ctx_factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package storemanmpc
import (
"github.com/wanchain/schnorr-mpc/log"
mpcprotocol "github.com/wanchain/schnorr-mpc/storeman/storemanmpc/protocol"
)
type MpcCtxFactory struct {
}
func (*MpcCtxFactory) CreateContext(ctxType int,
mpcID uint64,
peers []mpcprotocol.PeerInfo,
preSetValue ...MpcValue) (MpcInterface, error) {
log.Info("============================ CreateContext=====================")
log.Info("CreateContext", "ctxType", ctxType)
for i := 0; i < len(preSetValue); i++ {
if preSetValue[i].Value != nil {
log.Info("preSetValue", "key", preSetValue[i].Key, "value", preSetValue[i].Value)
} else if preSetValue[i].ByteValue != nil {
log.Info("preSetValue", "key", preSetValue[i].Key, "bytevalue", preSetValue[i].ByteValue)
}
}
log.Info("============================ CreateContext=====================")
switch ctxType {
case mpcprotocol.MpcGPKLeader:
return reqGPKMpc(mpcID, peers, preSetValue...)
case mpcprotocol.MpcGPKPeer:
return ackGPKMpc(mpcID, peers, preSetValue...)
case mpcprotocol.MpcSignLeader:
return reqSignMpc(mpcID, peers, preSetValue...)
case mpcprotocol.MpcSignPeer:
return ackSignMpc(mpcID, peers, preSetValue...)
}
return nil, mpcprotocol.ErrContextType
}