Documentation ¶
Index ¶
- Variables
- func AcceptLockOut(account string, groupid string, nonce string, dcrmfrom string, ...) (string, error)
- func AcceptReqAddr(account string, cointype string, groupid string, nonce string, ...) (string, error)
- func Call(msg interface{}, enode string)
- func ClearChan(ch chan string)
- func Compress(c []byte) (string, error)
- func DcrmCall(msg interface{}, enode string) <-chan string
- func DcrmCallRet(msg interface{}, enode string)
- func Decode2(s string, datatype string) (interface{}, error)
- func DecryptMsg(cm string) (string, error)
- func DefaultDataDir() string
- func DisMsg(msg string)
- func DoubleHash(id string, cointype string) *big.Int
- func EdVerify(input InputVerify) bool
- func Encode2(obj interface{}) (string, error)
- func EncryptMsg(msg string, enodeID string) (string, error)
- func Find(l *list.List, msg string) bool
- func GetAcceptLockOutDir() string
- func GetAcceptLockOutRes(account string, groupid string, nonce string, dcrmfrom string, ...) (string, bool)
- func GetAcceptReqAddrDir() string
- func GetAcceptReqAddrRes(account string, cointype string, groupid string, nonce string, ...) (string, bool)
- func GetAccounts(gid, mode string) (interface{}, string, error)
- func GetAllPubKeyDataFromDb()
- func GetChannelValue(t int, obj interface{}) (string, string, error)
- func GetDbDir() string
- func GetEnodesByUid(uid *big.Int, cointype string, groupid string) string
- func GetEnodesInfo(GroupId string)
- func GetEosDbDir() string
- func GetGroupDir() string
- func GetIds(cointype string, groupid string) sortableIDSSlice
- func GetLockOutNonce(account string, cointype string, dcrmaddr string) (string, string, error)
- func GetLockOutReply() (string, string, error)
- func GetLockOutStatus(key string) (string, string, error)
- func GetPaillierPk(save string, index int) *ec2.PublicKey
- func GetPaillierSk(save string, index int) *ec2.PrivateKey
- func GetRandomInt(length int) *big.Int
- func GetRandomIntFromZn(n *big.Int) *big.Int
- func GetReqAddrNonce(account string) (string, string, error)
- func GetReqAddrReply() (string, string, error)
- func GetReqAddrStatus(key string) (string, string, error)
- func GetRetErr(err string) error
- func GetRetErrJsonStr(code int, err string) string
- func GetSignString(r *big.Int, s *big.Int, v int32, i int) string
- func GetZkFactProof(save string, index int) *ec2.ZkFactProof
- func InitChan()
- func InitDev(keyfile string, groupId string)
- func IsCurNode(enodes string, cur string) bool
- func IsInGroup(enode string, groupId string) bool
- func KeyGenerate_ec2(msgprex string, ch chan interface{}, id int, cointype string) bool
- func KeyGenerate_ed(msgprex string, ch chan interface{}, id int, cointype string) bool
- func ReadBits(bigint *big.Int, buf []byte)
- func RegDcrmGetEosAccountCallBack(f func() (string, string, string))
- func RegP2pBroadcastInGroupOthersCallBack(f func(string, string) (string, error))
- func RegP2pGetGroupCallBack(f func(string) (int, string))
- func RegP2pGetSelfEnodeCallBack(f func() string)
- func RegP2pParseNodeCallBack(f func(string) string)
- func RegP2pSendMsgToPeerCallBack(f func(string, string) error)
- func RegP2pSendToGroupAllNodesCallBack(f func(string, string) (string, error))
- func SaveAcceptLockOutData(ac *AcceptLockOutData) error
- func SaveAcceptReqAddrData(ac *AcceptReqAddrData) error
- func SavePubKeyDataToDb()
- func SendMsgToDcrmGroup(msg string, groupid string)
- func SendMsgToPeer(enodes string, msg string)
- func SendReqToGroup(msg string, rpctype string) (string, string, error)
- func SetLockOutNonce(account string, cointype string, dcrmaddr string, nonce string) (string, error)
- func SetReqAddrNonce(account string, nonce string) (string, error)
- func SetUpMsgList(msg string)
- func Sign_ec2(msgprex string, save string, message string, cointype string, pkx *big.Int, ...) string
- func Sign_ed(msgprex string, save string, message string, cointype string, pk string, ...) string
- func Tool_DecimalByteSlice2HexString(DecimalSlice []byte) string
- func UnCompress(s string) (string, error)
- func Verify(r *big.Int, s *big.Int, v int32, message string, pkx *big.Int, pky *big.Int) bool
- func Verify2(r *big.Int, s *big.Int, v int32, message string, pkx *big.Int, pky *big.Int) bool
- type AcceptLockOutData
- type AcceptReqAddrData
- type AccountsList
- type DcrmHash
- type ECDSASignature
- func (this *ECDSASignature) GetR() *big.Int
- func (this *ECDSASignature) GetRecoveryParam() int32
- func (this *ECDSASignature) GetRoudFiveAborted() bool
- func (this *ECDSASignature) GetS() *big.Int
- func (this *ECDSASignature) New()
- func (this *ECDSASignature) New2(r *big.Int, s *big.Int)
- func (this *ECDSASignature) New3(r *big.Int, s *big.Int, recoveryParam int32)
- func (this *ECDSASignature) SetR(r *big.Int)
- func (this *ECDSASignature) SetRecoveryParam(recoveryParam int32)
- func (this *ECDSASignature) SetRoudFiveAborted(roudFiveAborted bool)
- func (this *ECDSASignature) SetS(s *big.Int)
- type Err
- type ErrorRet
- type GetLockOutReplySendMsgToDcrm
- type GetReqAddrReplySendMsgToDcrm
- type InputVerify
- type KeyData
- type LockOutReply
- type LockOutReplys
- type LockOutSendMsgToDcrm
- type LockOutStatus
- type PubAccounts
- type PubKeyData
- type RecvMsg
- type ReqAddrSendMsgToDcrm
- type ReqDispatcher
- type RpcDcrmRes
- type RpcReq
- type RpcReqWorker
- type SendMsg
- type WorkReq
Constants ¶
This section is empty.
Variables ¶
var ( //err code 1 ErrEncodeSendMsgFail = `{Code:1,Error:"encode send msg fail."}` ErrParamError = `{Code:2,Error:"parameters error."}` ErrGetOtherNodesDataFail = `{Code:3,Error:"NetWork Error,Get Data From Other Node Fail."}` ErrUnknownChType = `{Code:4,Error:"unknown channel type."}` ErrGetChValueFail = `{Code:5,Error:"get channel value fail."}` ErrNoFindWorker = `{Code:7,Error:"can not find worker."}` ErrGetWorkerIdError = `{Code:10,Error:"get worker id error."}` ErrGetPrexDataError = `{Code:11,Error:"get msg prefix data error."}` ErrSendDataToGroupFail = `{Code:15,Error:"send data to group fail."}` ErrInternalMsgFormatError = `{Code:16,Error:"msg data format error."}` ErrGetNoResFromGroupMem = `{Code:17,Error:"no get any result from other group node."}` ErrCoinTypeNotSupported = `{Code:18,Error:"coin type is not supported."}` ErrGroupNotReady = `{Code:23,Error:"the group is not ready.please try again."}` ErrGetGenPubkeyFail = `{Code:24,Error:"get generate pubkey fail."}` ErrGetGenSaveDataFail = `{Code:25,Error:"get generate save data fail."}` ErrCreateDbFail = `{Code:26,Error:"create db fail."}` ErrDcrmSigWrongSize = `{Code:28,Error:"wrong size for dcrm sig."}` ErrDcrmSigFail = `{Code:29,Error:"dcrm sign fail."}` ErrInvalidDcrmAddr = `{Code:30,Error:"invalid dcrm address."}` ErrGetRealEosUserFail = `{Code:27,Error:"cannot get real eos account."}` ErrSendTxToNetFail = `{Code:14,Error:"send tx to outside net fail."}` ErrGetC1Timeout = `{Code:31,Error:"get C1 timeout."}` ErrGetEnodeByUIdFail = `{Code:32,Error:"can not find proper enodes by uid."}` ErrGetD1Timeout = `{Code:33,Error:"get D1 timeout."}` ErrGetSHARE1Timeout = `{Code:34,Error:"get SHARE1 timeout."}` ErrGetAllSHARE1Fail = `{Code:35,Error:"get all SHARE1 msg fail."}` ErrGetAllD1Fail = `{Code:36,Error:"get all D1 msg fail."}` ErrVerifySHARE1Fail = `{Code:37,Error:"verify SHARE1 fail."}` ErrGetAllC1Fail = `{Code:38,Error:"get all C1 msg fail."}` ErrKeyGenVerifyCommitFail = `{Code:39,Error:"verify commit in keygenerate fail."}` ErrGetZKFACTPROOFTimeout = `{Code:40,Error:""get ZKFACTPROOF timeout."}` ErrGetZKUPROOFTimeout = `{Code:41,Error:""get ZKUPROOF timeout."}` ErrGetAllZKFACTPROOFFail = `{Code:42,Error:"get all ZKFACTPROOF msg fail."}` ErrVerifyZKFACTPROOFFail = `{Code:43,Error:"verify ZKFACTPROOF fail."}` ErrGetAllZKUPROOFFail = `{Code:44,Error:"get all ZKUPROOF msg fail."}` ErrVerifyZKUPROOFFail = `{Code:45,Error:"verify ZKUPROOF fail."}` ErrGetC11Timeout = `{Code:46,Error:"get C11 timeout."}` ErrGetMTAZK1PROOFTimeout = `{Code:47,Error:"get MTAZK1PROOF timeout."}` ErrGetKCTimeout = `{Code:48,Error:"get KC timeout."}` ErrGetAllKCFail = `{Code:49,Error:"get all KC msg fail."}` ErrGetAllMTAZK1PROOFFail = `{Code:50,Error:"get all MTAZK1PROOF msg fail."}` ErrVerifyMTAZK1PROOFFail = `{Code:51,Error:"verify MTAZK1PROOF fail.""}` ErrGetMKGTimeout = `{Code:52,Error:"get MKG timeout."}` ErrGetAllMKGFail = `{Code:53,Error:"get all MKG msg fail."}` ErrGetMKWTimeout = `{Code:54,Error:"get MKW timeout."}` ErrGetAllMKWFail = `{Code:55,Error:"get all MKW msg fail."}` ErrVerifyMKGFail = `{Code:56,Error:"verify MKG fail.""}` ErrVerifyMKWFail = `{Code:57,Error:"verify MKW fail.""}` ErrGetPaillierPrivKeyFail = `{Code:58,Error:"get paillier privkey fail.""}` ErrGetDELTA1Timeout = `{Code:59,Error:"get DELTA1 timeout."}` ErrGetAllDELTA1Fail = `{Code:60,Error:"get all DELTA1 msg fail."}` ErrGetD11Timeout = `{Code:61,Error:"get D11 timeout."}` ErrGetAllD11Fail = `{Code:62,Error:"get all D11 msg fail."}` ErrGetAllC11Fail = `{Code:63,Error:"get all C11 msg fail."}` ErrSignVerifyCommitFail = `{Code:64,Error:"verify commit in dcrm sign fail."}` ErrREqualZero = `{Code:65,Error:"sign error: r equal zero."}` ErrGetS1Timeout = `{Code:66,Error:"get S1 timeout."}` ErrGetAllS1Fail = `{Code:67,Error:"get all S1 msg fail."}` ErrVerifySAllFail = `{Code:68,Error:"verify SAll != m*G + r*PK in dcrm sign ec2."}` ErrGetSS1Timeout = `{Code:69,Error:"get SS1 timeout."}` ErrGetAllSS1Fail = `{Code:70,Error:"get all SS1 msg fail."}` ErrSEqualZero = `{Code:71,Error:"sign error: s equal zero."}` ErrDcrmSignVerifyFail = `{Code:72,Error:"dcrm sign verify fail."}` )
dcrm erros
var ( Sep = "dcrmparm" SepSave = "dcrmsepsave" SepSg = "dcrmmsg" SepDel = "dcrmsepdel" PaillierKeyLength = 2048 //callback GetGroup func(string) (int, string) SendToGroupAllNodes func(string, string) (string, error) GetSelfEnode func() string BroadcastInGroupOthers func(string, string) (string, error) SendToPeer func(string, string) error ParseNode func(string) string GetEosAccount func() (string, string, string) PubKeyDataChan = make(chan KeyData, 1000) GetPubKeyDataChan = make(chan chan []*PubKeyData, 1000) KeyFile string AllAccounts = make([]*PubKeyData, 0) LdbReqAddr = make(map[string][]byte) LdbLockOut = make(map[string][]byte) LdbPubKeyData = make(map[string][]byte) )
var ( //rpc-req //dcrm node RpcMaxWorker = 2000 RpcMaxQueue = 2000 RpcReqQueue chan RpcReq Enode_cnts int NodeCnt = 3 ThresHold = 3 )
//////////////////////dcrm///////////////////////////////
Functions ¶
func AcceptLockOut ¶
func AcceptReqAddr ¶
func AcceptReqAddr(account string, cointype string, groupid string, nonce string, threshold string, mode string, deal bool, accept string, status string, pubkey string, tip string, errinfo string, allreply string) (string, error)
if accept == "",don't set Accept if status == "",don't set Status if pubkey == "",don't set PubKey if tip == "",don't set Tip if errinfo == "",don't set ErrInfo if allreply == "",don't set AllReply
func AcceptReqAddr(account string,cointype string,groupid string,nonce string,threshold string,mode string,deal bool,accept string,status string,pubkey string,tip string,errinfo string,allreply string) (string,error) { lock5.Lock() dir := GetAcceptReqAddrDir() db,err := ethdb.NewLDBDatabase(dir, 0, 0) //bug if err != nil { for i:=0;i<1000;i++ { db,err = ethdb.NewLDBDatabase(dir, 0, 0) if err == nil { break } time.Sleep(time.Duration(1000000)) } } // if err != nil { lock5.Unlock() return "dcrm back-end internal error:open level db fail",err } key := Keccak256Hash([]byte(strings.ToLower(account + ":" + cointype + ":" + groupid + ":" + nonce + ":" + threshold + ":" + mode))).Hex() da,err := db.Get([]byte(key)) /////// if err != nil { db.Close() lock5.Unlock() return "dcrm back-end internal error:get accept data fail from db",err } ds,err := UnCompress(string(da)) if err != nil { db.Close() lock5.Unlock() return "dcrm back-end internal error:uncompress accept data fail",err } dss,err := Decode2(ds,"AcceptReqAddrData") if err != nil { db.Close() lock5.Unlock() return "dcrm back-end internal error:decode accept data fail",err } ac := dss.(*AcceptReqAddrData) ac.Deal = deal if accept != "" { ac.Accept = accept } if pubkey != "" { ac.PubKey = pubkey } if tip != "" { ac.Tip = tip } if errinfo != "" { ac.Error = errinfo } if status != "" { ac.Status = status } if allreply != "" { ac.AllReply = allreply } e,err := Encode2(ac) if err != nil { db.Close() lock5.Unlock() return "dcrm back-end internal error:encode accept data fail",err } es,err := Compress([]byte(e)) if err != nil { db.Close() lock5.Unlock() return "dcrm back-end internal error:compress accept data fail",err } db.Put([]byte(key),[]byte(es)) db.Close() lock5.Unlock() acceptReqAddrChan <- account return "",nil }
func DcrmCallRet ¶
func DcrmCallRet(msg interface{}, enode string)
func DecryptMsg ¶
func DefaultDataDir ¶
func DefaultDataDir() string
func EdVerify ¶
func EdVerify(input InputVerify) bool
func GetAcceptLockOutDir ¶
func GetAcceptLockOutDir() string
func GetAcceptLockOutRes ¶
func GetAcceptReqAddrDir ¶
func GetAcceptReqAddrDir() string
func GetAcceptReqAddrRes ¶
func GetAccounts ¶
func GetAllPubKeyDataFromDb ¶
func GetAllPubKeyDataFromDb()
func GetEnodesInfo ¶
func GetEnodesInfo(GroupId string)
func GetEosDbDir ¶
func GetEosDbDir() string
eos_init---> eos account key: crypto.Keccak256Hash([]byte("eossettings")) value: pubkey+eos account
func GetGroupDir ¶
func GetGroupDir() string
func GetLockOutNonce ¶
func GetLockOutReply ¶
func GetPaillierSk ¶
func GetPaillierSk(save string, index int) *ec2.PrivateKey
func GetRandomInt ¶
func GetReqAddrReply ¶
func GetRetErrJsonStr ¶
func GetZkFactProof ¶
func GetZkFactProof(save string, index int) *ec2.ZkFactProof
func InitChan ¶
func InitChan()
workers,RpcMaxWorker,RpcReqWorker,RpcReqQueue,RpcMaxQueue,ReqDispatcher
func KeyGenerate_ec2 ¶
ec2 msgprex = hash
func KeyGenerate_ed ¶
ed msgprex = hash
func ReadBits ¶
ReadBits encodes the absolute value of bigint as big-endian bytes. Callers must ensure that buf has enough space. If buf is too short the result will be incomplete.
func RegP2pGetGroupCallBack ¶
func RegP2pGetSelfEnodeCallBack ¶
func RegP2pGetSelfEnodeCallBack(f func() string)
func RegP2pParseNodeCallBack ¶
func SaveAcceptLockOutData ¶
func SaveAcceptLockOutData(ac *AcceptLockOutData) error
func SaveAcceptReqAddrData ¶
func SaveAcceptReqAddrData(ac *AcceptReqAddrData) error
func SavePubKeyDataToDb ¶
func SavePubKeyDataToDb()
func SendMsgToDcrmGroup ¶
func SendMsgToPeer ¶
func SetLockOutNonce ¶
func SetUpMsgList ¶
func SetUpMsgList(msg string)
func Sign_ec2 ¶
func Sign_ec2(msgprex string, save string, message string, cointype string, pkx *big.Int, pky *big.Int, ch chan interface{}, id int) string
msgprex = hash return value is the backup for the dcrm sig
func Sign_ed ¶
func Sign_ed(msgprex string, save string, message string, cointype string, pk string, ch chan interface{}, id int) string
msgprex = hash return value is the backup for the dcrm sig
Types ¶
type AcceptLockOutData ¶
type AcceptReqAddrData ¶
type AccountsList ¶
type DcrmHash ¶
type DcrmHash [32]byte
func Keccak256Hash ¶
Keccak256Hash calculates and returns the Keccak256 hash of the input data, converting it to an internal Hash data structure.
type ECDSASignature ¶
type ECDSASignature struct {
// contains filtered or unexported fields
}
func (*ECDSASignature) GetR ¶
func (this *ECDSASignature) GetR() *big.Int
func (*ECDSASignature) GetRecoveryParam ¶
func (this *ECDSASignature) GetRecoveryParam() int32
func (*ECDSASignature) GetRoudFiveAborted ¶
func (this *ECDSASignature) GetRoudFiveAborted() bool
func (*ECDSASignature) GetS ¶
func (this *ECDSASignature) GetS() *big.Int
func (*ECDSASignature) New ¶
func (this *ECDSASignature) New()
func (*ECDSASignature) SetR ¶
func (this *ECDSASignature) SetR(r *big.Int)
func (*ECDSASignature) SetRecoveryParam ¶
func (this *ECDSASignature) SetRecoveryParam(recoveryParam int32)
func (*ECDSASignature) SetRoudFiveAborted ¶
func (this *ECDSASignature) SetRoudFiveAborted(roudFiveAborted bool)
func (*ECDSASignature) SetS ¶
func (this *ECDSASignature) SetS(s *big.Int)
type GetLockOutReplySendMsgToDcrm ¶
type GetLockOutReplySendMsgToDcrm struct { }
func (*GetLockOutReplySendMsgToDcrm) Run ¶
func (self *GetLockOutReplySendMsgToDcrm) Run(workid int, ch chan interface{}) bool
type GetReqAddrReplySendMsgToDcrm ¶
type GetReqAddrReplySendMsgToDcrm struct { }
func (*GetReqAddrReplySendMsgToDcrm) Run ¶
func (self *GetReqAddrReplySendMsgToDcrm) Run(workid int, ch chan interface{}) bool
type InputVerify ¶
type LockOutReply ¶
type LockOutReplys ¶
type LockOutReplys struct {
Replys []LockOutReply
}
type LockOutSendMsgToDcrm ¶
type LockOutSendMsgToDcrm struct { Account string DcrmFrom string DcrmTo string Value string Cointype string GroupId string Nonce string LimitNum string Mode string }
msg = fusionaccount:dcrmaddr:dcrmto:value:cointype:groupid:nonce:threshold
func (*LockOutSendMsgToDcrm) Run ¶
func (self *LockOutSendMsgToDcrm) Run(workid int, ch chan interface{}) bool
type LockOutStatus ¶
type PubAccounts ¶
type PubAccounts struct {
Group []AccountsList
}
type PubKeyData ¶
type ReqAddrSendMsgToDcrm ¶
type ReqAddrSendMsgToDcrm struct { Account string Cointype string GroupId string Nonce string LimitNum string Mode string }
func (*ReqAddrSendMsgToDcrm) Run ¶
func (self *ReqAddrSendMsgToDcrm) Run(workid int, ch chan interface{}) bool
type ReqDispatcher ¶
type ReqDispatcher struct { // A pool of workers channels that are registered with the dispatcher WorkerPool chan chan RpcReq }
rpc-req
func NewReqDispatcher ¶
func NewReqDispatcher(maxWorkers int) *ReqDispatcher
func (*ReqDispatcher) Run ¶
func (d *ReqDispatcher) Run()
type RpcDcrmRes ¶
func GetGroupRes ¶
func GetGroupRes(wid int) RpcDcrmRes
type RpcReqWorker ¶
type RpcReqWorker struct { RpcReqWorkerPool chan chan RpcReq RpcReqChannel chan RpcReq // contains filtered or unexported fields }
func FindWorker ¶
func FindWorker(sid string) (*RpcReqWorker, error)
func NewRpcReqWorker ¶
func NewRpcReqWorker(workerPool chan chan RpcReq) *RpcReqWorker
func (*RpcReqWorker) Clear ¶
func (w *RpcReqWorker) Clear()
func (*RpcReqWorker) Clear2 ¶
func (w *RpcReqWorker) Clear2()
func (*RpcReqWorker) Start ¶
func (w *RpcReqWorker) Start()
func (*RpcReqWorker) Stop ¶
func (w *RpcReqWorker) Stop()