diff --git a/app/client.go b/app/client.go index 686e916..3fe022a 100644 --- a/app/client.go +++ b/app/client.go @@ -1,7 +1,7 @@ package appunlynx import ( - "errors" + "fmt" "os" "regexp" "strconv" @@ -32,7 +32,7 @@ func startQuery(el *onet.Roster, proofs bool, sum []string, count bool, whereQue grp, aggr, err := client.SendSurveyResultsQuery(*surveyID) if err != nil { - return errors.New("service could not output the results: " + err.Error()) + return fmt.Errorf("service could not output the results: %v", err) } // Print Output @@ -77,7 +77,7 @@ func openGroupToml(tomlFileName string) (*onet.Roster, error) { } if len(el.Roster.List) <= 0 { - return nil, errors.New("empty or invalid unlynx group file:" + tomlFileName) + return nil, fmt.Errorf("empty or invalid unlynx group file: %v", tomlFileName) } return el.Roster, nil @@ -91,7 +91,7 @@ func checkRegex(input, expression string) bool { func parseQuery(el *onet.Roster, sum string, count bool, where, predicate, groupBy string) ([]string, bool, []libunlynx.WhereQueryAttribute, string, []string, error) { if sum == "" || (where != "" && predicate == "") || (where == "" && predicate != "") { - return nil, false, nil, "", nil, errors.New("wrong query! please check the sum, where and the predicate parameters") + return nil, false, nil, "", nil, fmt.Errorf("wrong query! please check the sum, where and the predicate parameters") } sumRegex := "{s[0-9]+(,\\s*s[0-9]+)*}" @@ -99,7 +99,7 @@ func parseQuery(el *onet.Roster, sum string, count bool, where, predicate, group groupByRegex := "{g[0-9]+(,\\s*g[0-9]+)*}" if !checkRegex(sum, sumRegex) { - return nil, false, nil, "", nil, errors.New("error parsing the sum parameter(s)") + return nil, false, nil, "", nil, fmt.Errorf("error parsing the sum parameter(s)") } sum = strings.Replace(sum, " ", "", -1) sum = strings.Replace(sum, "{", "", -1) @@ -115,12 +115,12 @@ func parseQuery(el *onet.Roster, sum string, count bool, where, predicate, group } if !check { - return nil, false, nil, "", nil, errors.New("no 'count' attribute in the sum variables") + return nil, false, nil, "", nil, fmt.Errorf("no 'count' attribute in the sum variables") } } if !checkRegex(where, whereRegex) { - return nil, false, nil, "", nil, errors.New("error parsing the where parameter(s)") + return nil, false, nil, "", nil, fmt.Errorf("error parsing the where parameter(s)") } where = strings.Replace(where, " ", "", -1) where = strings.Replace(where, "{", "", -1) @@ -145,7 +145,7 @@ func parseQuery(el *onet.Roster, sum string, count bool, where, predicate, group } if !checkRegex(groupBy, groupByRegex) { - return nil, false, nil, "", nil, errors.New("error parsing the groupBy parameter(s)") + return nil, false, nil, "", nil, fmt.Errorf("error parsing the groupBy parameter(s)") } groupBy = strings.Replace(groupBy, " ", "", -1) groupBy = strings.Replace(groupBy, "{", "", -1) diff --git a/app/unlynx.go b/app/unlynx.go index 913e24d..3faf968 100644 --- a/app/unlynx.go +++ b/app/unlynx.go @@ -1,7 +1,7 @@ package appunlynx import ( - "errors" + "fmt" "os" "github.com/ldsec/unlynx/lib" @@ -123,7 +123,7 @@ func main() { Usage: "Start unlynx server", Action: func(c *cli.Context) error { if err := runServer(c); err != nil { - return errors.New("error during runServer(): " + err.Error()) + return fmt.Errorf("error during runServer(): %v", err) } return nil }, @@ -135,10 +135,10 @@ func main() { Usage: "Setup server configuration (interactive)", Action: func(c *cli.Context) error { if c.String(optionConfig) != "" { - return errors.New("[-] Configuration file option cannot be used for the 'setup' command") + return fmt.Errorf("[-] configuration file option cannot be used for the 'setup' command") } if c.GlobalIsSet("debug") { - return errors.New("[-] Debug option cannot be used for the 'setup' command") + return fmt.Errorf("[-] debug option cannot be used for the 'setup' command") } app.InteractiveConfig(libunlynx.SuiTe, BinaryName) return nil diff --git a/data/handle_data.go b/data/handle_data.go index ee7d852..913b07f 100644 --- a/data/handle_data.go +++ b/data/handle_data.go @@ -2,7 +2,6 @@ package dataunlynx import ( "bufio" - "errors" "fmt" "math" "math/rand" @@ -78,7 +77,7 @@ func GenerateData(numDPs, numEntries, numEntriesFiltered, numGroupsClear, numGro numWhereClear, numWhereEnc, numAggrClear, numAggrEnc int64, numType []int64, randomGroups bool) (map[string][]libunlynx.DpClearResponse, error) { if int64(len(numType)) != (numGroupsClear + numGroupsEnc) { - return nil, errors.New("specify the correct number of group types for each grouping attribute") + return nil, fmt.Errorf("specify the correct number of group types for each grouping attribute") } testData := make(map[string][]libunlynx.DpClearResponse) @@ -94,7 +93,7 @@ func GenerateData(numDPs, numEntries, numEntriesFiltered, numGroupsClear, numGro group := make([]int64, 0) AllPossibleGroups(numType[:], group, 0, &groups) } else { - return nil, errors.New("the number of groups is different from the number of entries") + return nil, fmt.Errorf("the number of groups is different from the number of entries") } } diff --git a/lib/add_rm/add_rm_proofs.go b/lib/add_rm/add_rm_proofs.go index 1b0c4c5..817cafd 100644 --- a/lib/add_rm/add_rm_proofs.go +++ b/lib/add_rm/add_rm_proofs.go @@ -1,7 +1,7 @@ package libunlynxaddrm import ( - "errors" + "fmt" "math" "sync" @@ -65,7 +65,7 @@ func AddRmProofCreation(cBef, cAft libunlynx.CipherText, K kyber.Point, k kyber. proofTmp, err := proof.HashProve(libunlynx.SuiTe, "proofTest", prover) if err != nil { - return PublishedAddRmProof{}, errors.New("---------Prover:" + err.Error()) + return PublishedAddRmProof{}, fmt.Errorf("---------prover: %v", err) } return PublishedAddRmProof{Proof: proofTmp, CtBef: cBef, CtAft: cAft, RB: rB}, nil diff --git a/lib/crypto.go b/lib/crypto.go index 69306aa..9b85049 100644 --- a/lib/crypto.go +++ b/lib/crypto.go @@ -3,7 +3,6 @@ package libunlynx import ( "encoding" "encoding/base64" - "errors" "fmt" "math/big" "strings" @@ -635,7 +634,7 @@ func (c *CipherText) Serialize() (string, error) { func (c *CipherText) Deserialize(b64Encoded string) error { decoded, err := base64.URLEncoding.DecodeString(b64Encoded) if err != nil { - return errors.New("Invalid CipherText (decoding failed): " + err.Error()) + return fmt.Errorf("invalid ciphertext (decoding failed): %v", err) } err = (*c).FromBytes(decoded) if err != nil { @@ -648,7 +647,7 @@ func (c *CipherText) Deserialize(b64Encoded string) error { func SerializeElement(el encoding.BinaryMarshaler) (string, error) { bytes, err := el.MarshalBinary() if err != nil { - return "", errors.New("Error marshalling element: " + err.Error()) + return "", fmt.Errorf("error marshalling element: %v", err) } return base64.URLEncoding.EncodeToString(bytes), nil } @@ -665,15 +664,15 @@ func SerializeScalar(scalar encoding.BinaryMarshaler) (string, error) { // DeserializePoint deserializes a point using base64 encoding func DeserializePoint(encodedPoint string) (kyber.Point, error) { - decoded, errD := base64.URLEncoding.DecodeString(encodedPoint) - if errD != nil { - return nil, errors.New("Error decoding point: " + errD.Error()) + decoded, err := base64.URLEncoding.DecodeString(encodedPoint) + if err != nil { + return nil, fmt.Errorf("error decoding point: %v", err) } point := SuiTe.Point() - errM := point.UnmarshalBinary(decoded) - if errM != nil { - return nil, errors.New("Error unmarshalling point: " + errM.Error()) + err = point.UnmarshalBinary(decoded) + if err != nil { + return nil, fmt.Errorf("error unmarshalling point: %v", err) } return point, nil @@ -681,15 +680,15 @@ func DeserializePoint(encodedPoint string) (kyber.Point, error) { // DeserializeScalar deserializes a scalar using base64 encoding func DeserializeScalar(encodedScalar string) (kyber.Scalar, error) { - decoded, errD := base64.URLEncoding.DecodeString(encodedScalar) - if errD != nil { - return nil, errors.New("Error decoding scalar: " + errD.Error()) + decoded, err := base64.URLEncoding.DecodeString(encodedScalar) + if err != nil { + return nil, fmt.Errorf("error decoding scalar: %v", err) } scalar := SuiTe.Scalar() - errM := scalar.UnmarshalBinary(decoded) - if errM != nil { - return nil, errors.New("Error unmarshalling scalar: " + errM.Error()) + err = scalar.UnmarshalBinary(decoded) + if err != nil { + return nil, fmt.Errorf("error unmarshalling scalar: %v", err) } return scalar, nil diff --git a/lib/deterministic_tag/deterministic_tag_proofs.go b/lib/deterministic_tag/deterministic_tag_proofs.go index 81822a2..09bea34 100644 --- a/lib/deterministic_tag/deterministic_tag_proofs.go +++ b/lib/deterministic_tag/deterministic_tag_proofs.go @@ -1,7 +1,7 @@ package libunlynxdetertag import ( - "errors" + "fmt" "math" "reflect" "sync" @@ -82,7 +82,7 @@ func DeterministicTagCrProofCreation(ctBef, ctAft libunlynx.CipherText, K kyber. prover := predicate.Prover(libunlynx.SuiTe, sval, pval, nil) // computes: commitment, challenge, response Proof, err := proof.HashProve(libunlynx.SuiTe, "proofTest", prover) if err != nil { - return PublishedDDTCreationProof{}, errors.New("---------Prover: " + err.Error()) + return PublishedDDTCreationProof{}, fmt.Errorf("---------prover: %v", err) } return PublishedDDTCreationProof{Proof: Proof, Ciminus11Si: ciminus11Si, CTbef: ctBef, CTaft: ctAft}, nil @@ -191,7 +191,7 @@ func DeterministicTagAdditionProofCreation(c1 kyber.Point, s kyber.Scalar, c2 ky prover := predicate.Prover(libunlynx.SuiTe, sval, pval, nil) // computes: commitment, challenge, response Proof, err := proof.HashProve(libunlynx.SuiTe, "proofTest", prover) if err != nil { - return PublishedDDTAdditionProof{}, errors.New("---------Prover: " + err.Error()) + return PublishedDDTAdditionProof{}, fmt.Errorf("---------prover: %v", err) } return PublishedDDTAdditionProof{Proof: Proof, C1: c1, C2: c2, R: r}, nil diff --git a/lib/key_switch/key_switch_proofs.go b/lib/key_switch/key_switch_proofs.go index 3f03845..ff5ae54 100644 --- a/lib/key_switch/key_switch_proofs.go +++ b/lib/key_switch/key_switch_proofs.go @@ -1,7 +1,7 @@ package libunlynxkeyswitch import ( - "errors" + "fmt" "math" "sync" @@ -68,7 +68,7 @@ func KeySwitchProofCreation(K, Q kyber.Point, k kyber.Scalar, viB, ks2, rBNeg ky prover := predicate.Prover(libunlynx.SuiTe, sval, pval, nil) // computes: commitment, challenge, response proofKS, err := proof.HashProve(libunlynx.SuiTe, "proofTest", prover) if err != nil { - return PublishedKSProof{}, errors.New("---------Prover: " + err.Error()) + return PublishedKSProof{}, fmt.Errorf("---------prover: %v", err) } return PublishedKSProof{Proof: proofKS, K: K, ViB: viB, Ks2: ks2, RbNeg: rBNeg, Q: Q}, nil diff --git a/lib/shuffle/shuffle_proofs.go b/lib/shuffle/shuffle_proofs.go index 956d0af..78be8fa 100644 --- a/lib/shuffle/shuffle_proofs.go +++ b/lib/shuffle/shuffle_proofs.go @@ -1,7 +1,7 @@ package libunlynxshuffle import ( - "errors" + "fmt" "math" "sync" @@ -84,7 +84,7 @@ func ShuffleProofCreation(originalList, shuffledList []libunlynx.CipherVector, g // do k-shuffle of ElGamal on the (Xhat,Yhat) and check it k = len(Xhat) if k != len(Yhat) { - return PublishedShufflingProof{}, errors.New("X,Y vectors have inconsistent lengths") + return PublishedShufflingProof{}, fmt.Errorf("X,Y vectors have inconsistent lengths") } ps := shuffleKyber.PairShuffle{} ps.Init(libunlynx.SuiTe, k) @@ -95,7 +95,7 @@ func ShuffleProofCreation(originalList, shuffledList []libunlynx.CipherVector, g prf, err := proof.HashProve(libunlynx.SuiTe, "PairShuffle", prover) if err != nil { - return PublishedShufflingProof{}, errors.New("Shuffle proof failed: " + err.Error()) + return PublishedShufflingProof{}, fmt.Errorf("shuffle proof failed: %v", err) } return PublishedShufflingProof{originalList, shuffledList, g, h, prf}, nil } @@ -293,7 +293,7 @@ func compressCipherVector(ciphervector libunlynx.CipherVector, e []kyber.Scalar) // check that e and cipher vectors have the same size if len(e) != k { - return libunlynx.CipherText{}, errors.New("e is not the right size") + return libunlynx.CipherText{}, fmt.Errorf("e is not the right size") } ciphertext := *libunlynx.NewCipherText() diff --git a/lib/tools/tools.go b/lib/tools/tools.go index fed6829..0aa8f29 100644 --- a/lib/tools/tools.go +++ b/lib/tools/tools.go @@ -3,7 +3,6 @@ package libunlynxtools import ( "encoding/binary" "encoding/gob" - "errors" "fmt" "os" "strconv" @@ -27,7 +26,7 @@ func SendISMOthers(s *onet.ServiceProcessor, el *onet.Roster, msg interface{}) e } var err error if len(errStrs) > 0 { - err = errors.New(strings.Join(errStrs, "\n")) + err = fmt.Errorf(strings.Join(errStrs, "\n")) } return err } @@ -119,7 +118,7 @@ func WriteToGobFile(path string, object interface{}) error { return err } } else { - return errors.New("Could not write Gob file:" + err.Error()) + return fmt.Errorf("could not write Gob file: %v", err) } return nil @@ -137,7 +136,7 @@ func ReadFromGobFile(path string, object interface{}) error { return err } } else { - return errors.New("Could not read Gob file:" + err.Error()) + return fmt.Errorf("could not read Gob file: %v", err) } return nil diff --git a/protocols/collective_aggregation_protocol.go b/protocols/collective_aggregation_protocol.go index 9a3f21c..3694262 100644 --- a/protocols/collective_aggregation_protocol.go +++ b/protocols/collective_aggregation_protocol.go @@ -8,7 +8,7 @@ package protocolsunlynx import ( - "errors" + "fmt" "sync" "time" @@ -118,16 +118,16 @@ func NewCollectiveAggregationProtocol(n *onet.TreeNodeInstance) (onet.ProtocolIn err := pap.RegisterChannel(&pap.DataReferenceChannel) if err != nil { - return nil, errors.New("couldn't register data reference channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register data reference channel: %v", err) } err = pap.RegisterChannel(&pap.ChildDataChannel) if err != nil { - return nil, errors.New("couldn't register child-data channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register child-data channel: %v", err) } if err := pap.RegisterChannel(&pap.LengthNodeChannel); err != nil { - return nil, errors.New("couldn't register data reference channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register data reference channel: %v", err) } return pap, nil @@ -200,7 +200,7 @@ func (p *CollectiveAggregationProtocol) aggregationAnnouncementPhase() error { p.SendToChildren(&dataReferenceMessage.DataReferenceMessage) } case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } return nil } @@ -281,10 +281,10 @@ func (p *CollectiveAggregationProtocol) ascendingAggregationPhase(cvMap map[libu } if err := p.SendToParent(&CADBLengthMessage{gacbLength, aabLength, dtbLength}); err != nil { - return nil, errors.New("Error sending :" + err.Error()) + return nil, fmt.Errorf("error sending : %v", err) } if err := p.SendToParent(&message); err != nil { - return nil, errors.New("Error sending :" + err.Error()) + return nil, fmt.Errorf("error sending : %v", err) } } @@ -295,10 +295,10 @@ func (p *CollectiveAggregationProtocol) ascendingAggregationPhase(cvMap map[libu func (p *CollectiveAggregationProtocol) checkData() error { // If no data is passed to the collection protocol if p.GroupedData == nil && p.SimpleData == nil { - return errors.New("no data reference is provided") + return fmt.Errorf("no data reference is provided") // If both data entry points are used } else if p.GroupedData != nil && p.SimpleData != nil { - return errors.New("two data references are given in the struct") + return fmt.Errorf("two data references are given in the struct") // If we are using the GroupedData keep everything as is } else if p.GroupedData != nil { return nil diff --git a/protocols/deterministic_tagging_protocol.go b/protocols/deterministic_tagging_protocol.go index b70d78b..047ed20 100644 --- a/protocols/deterministic_tagging_protocol.go +++ b/protocols/deterministic_tagging_protocol.go @@ -7,7 +7,7 @@ package protocolsunlynx import ( - "errors" + "fmt" "sync" "time" @@ -101,10 +101,10 @@ func NewDeterministicTaggingProtocol(n *onet.TreeNodeInstance) (onet.ProtocolIns } if err := dsp.RegisterChannel(&dsp.PreviousNodeInPathChannel); err != nil { - return nil, errors.New("couldn't register data reference channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register data reference channel: %v", err) } if err := dsp.RegisterChannel(&dsp.LengthNodeChannel); err != nil { - return nil, errors.New("couldn't register data reference channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register data reference channel: %v", err) } var i int @@ -125,10 +125,10 @@ func (p *DeterministicTaggingProtocol) Start() error { roundTotalStart := libunlynx.StartTimer(p.Name() + "_DetTagging(START)") if p.TargetOfSwitch == nil { - return errors.New("no data on which to do a deterministic tagging") + return fmt.Errorf("no data on which to do a deterministic tagging") } if p.SurveySecretKey == nil { - return errors.New("no survey secret key given") + return fmt.Errorf("no survey secret key given") } p.ExecTime = 0 @@ -159,7 +159,7 @@ func (p *DeterministicTaggingProtocol) Dispatch() error { select { case deterministicTaggingTargetBytesBef = <-p.PreviousNodeInPathChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the (first round) on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the (first round) on time") } deterministicTaggingTargetBef := DeterministicTaggingMessage{Data: make([]libunlynx.CipherText, 0)} @@ -212,7 +212,7 @@ func (p *DeterministicTaggingProtocol) Dispatch() error { select { case deterministicTaggingTargetBytes = <-p.PreviousNodeInPathChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the (second round) on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the (second round) on time") } deterministicTaggingTarget := DeterministicTaggingMessage{Data: make([]libunlynx.CipherText, 0)} diff --git a/protocols/key_switching_protocol.go b/protocols/key_switching_protocol.go index 7230808..102841b 100644 --- a/protocols/key_switching_protocol.go +++ b/protocols/key_switching_protocol.go @@ -7,7 +7,7 @@ package protocolsunlynx import ( - "errors" + "fmt" "time" "github.com/ldsec/unlynx/lib" @@ -125,16 +125,16 @@ func NewKeySwitchingProtocol(n *onet.TreeNodeInstance) (onet.ProtocolInstance, e err := pap.RegisterChannel(&pap.DownChannel) if err != nil { - return nil, errors.New("couldn't register down channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register down channel: %v", err) } err = pap.RegisterChannel(&pap.ChildDataChannel) if err != nil { - return nil, errors.New("couldn't register child-data channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register child-data channel: %v", err) } if err := pap.RegisterChannel(&pap.LengthChannel); err != nil { - return nil, errors.New("couldn't register length channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register length channel: %v", err) } return pap, nil @@ -146,11 +146,11 @@ func (p *KeySwitchingProtocol) Start() error { keySwitchingStart := libunlynx.StartTimer(p.Name() + "_KeySwitching(START)") if p.TargetOfSwitch == nil { - return errors.New("no ciphertext given as key switching target") + return fmt.Errorf("no ciphertext given as key switching target") } if p.TargetPublicKey == nil { - return errors.New("no new public key to be switched on provided") + return fmt.Errorf("no new public key to be switched on provided") } log.Lvl2("[KEY SWITCHING PROTOCOL] Server", p.ServerIdentity(), " started a Key Switching Protocol") @@ -178,7 +178,7 @@ func (p *KeySwitchingProtocol) Start() error { } if err := p.SendToChildren(&DownMessageBytes{Data: data}); err != nil { - return errors.New("Root " + p.ServerIdentity().String() + " failed to broadcast DownMessageBytes: " + err.Error()) + return fmt.Errorf("Root "+p.ServerIdentity().String()+" failed to broadcast DownMessageBytes: %v", err) } libunlynx.EndTimer(keySwitchingStart) @@ -234,12 +234,12 @@ func (p *KeySwitchingProtocol) announcementKSPhase() (kyber.Point, []kyber.Point select { case dataReferenceMessage = <-p.DownChannel: case <-time.After(libunlynx.TIMEOUT): - return nil, nil, errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return nil, nil, fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } if !p.IsLeaf() { if err := p.SendToChildren(&dataReferenceMessage.DownMessageBytes); err != nil { - return nil, nil, errors.New("Node " + p.ServerIdentity().String() + " failed to broadcast DownMessageBytes: " + err.Error()) + return nil, nil, fmt.Errorf("Node "+p.ServerIdentity().String()+" failed to broadcast DownMessageBytes: %v", err) } } message, err := libunlynx.FromBytesToAbstractPoints(dataReferenceMessage.Data) @@ -282,7 +282,7 @@ func (p *KeySwitchingProtocol) ascendingKSPhase() (*libunlynx.CipherVector, erro if !p.IsRoot() { if err := p.SendToParent(&LengthMessage{Length: libunlynxtools.UnsafeCastIntsToBytes([]int{len(*p.NodeContribution)})}); err != nil { - return nil, errors.New("Node " + p.ServerIdentity().String() + " failed to broadcast LengthMessage ( " + err.Error() + " )") + return nil, fmt.Errorf("Node "+p.ServerIdentity().String()+" failed to broadcast LengthMessage: %v", err) } message, _, err := (*p.NodeContribution).ToBytes() if err != nil { @@ -290,7 +290,7 @@ func (p *KeySwitchingProtocol) ascendingKSPhase() (*libunlynx.CipherVector, erro } if err := p.SendToParent(&UpBytesMessage{Data: message}); err != nil { - return nil, errors.New("Node " + p.ServerIdentity().String() + " failed to broadcast UpBytesMessage: " + err.Error()) + return nil, fmt.Errorf("Node "+p.ServerIdentity().String()+" failed to broadcast UpBytesMessage: %v", err) } } diff --git a/protocols/shuffling+ddt_protocol.go b/protocols/shuffling+ddt_protocol.go index 8966dea..20759fd 100644 --- a/protocols/shuffling+ddt_protocol.go +++ b/protocols/shuffling+ddt_protocol.go @@ -1,7 +1,7 @@ package protocolsunlynx import ( - "errors" + "fmt" "sync" "time" @@ -92,11 +92,11 @@ func NewShufflingPlusDDTProtocol(n *onet.TreeNodeInstance) (onet.ProtocolInstanc } if err := pi.RegisterChannel(&pi.PreviousNodeInPathChannel); err != nil { - return nil, errors.New("couldn't register data reference channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register data reference channel: %v", err) } if err := pi.RegisterChannel(&pi.LengthNodeChannel); err != nil { - return nil, errors.New("couldn't register data reference channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register data reference channel: %v", err) } // choose next node in circuit @@ -114,7 +114,7 @@ func NewShufflingPlusDDTProtocol(n *onet.TreeNodeInstance) (onet.ProtocolInstanc func (p *ShufflingPlusDDTProtocol) Start() error { if p.TargetData == nil { - return errors.New("no data is given") + return fmt.Errorf("no data is given") } nbrSqCVs := len(*p.TargetData) log.Lvl1("["+p.Name()+"]", " started a Shuffling+DDT Protocol (", nbrSqCVs, " responses)") @@ -157,14 +157,14 @@ func (p *ShufflingPlusDDTProtocol) Dispatch() error { select { case shufflingPlusDDTBytesMessageLength = <-p.LengthNodeChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } var tmp shufflingPlusDDTBytesStruct select { case tmp = <-p.PreviousNodeInPathChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } readData := libunlynx.StartTimer(p.Name() + "_ShufflingPlusDDT(ReadData)") diff --git a/protocols/shuffling_protocol.go b/protocols/shuffling_protocol.go index 245def7..3bc90d2 100644 --- a/protocols/shuffling_protocol.go +++ b/protocols/shuffling_protocol.go @@ -4,7 +4,7 @@ package protocolsunlynx import ( - "errors" + "fmt" "time" "github.com/ldsec/unlynx/lib" @@ -101,11 +101,11 @@ func NewShufflingProtocol(n *onet.TreeNodeInstance) (onet.ProtocolInstance, erro } if err := dsp.RegisterChannel(&dsp.PreviousNodeInPathChannel); err != nil { - return nil, errors.New("couldn't register data reference channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register data reference channel: %v", err) } if err := dsp.RegisterChannel(&dsp.LengthNodeChannel); err != nil { - return nil, errors.New("couldn't register data reference channel: " + err.Error()) + return nil, fmt.Errorf("couldn't register data reference channel: %v", err) } // choose next node in circuit @@ -126,7 +126,7 @@ func (p *ShufflingProtocol) Start() error { shufflingStart := libunlynx.StartTimer(p.Name() + "_Shuffling(START)") if p.ShuffleTarget == nil { - return errors.New("no map given as shuffling target") + return fmt.Errorf("no map given as shuffling target") } p.ExecTimeStart = 0 @@ -191,14 +191,14 @@ func (p *ShufflingProtocol) Dispatch() error { select { case shufflingBytesMessageLength = <-p.LengthNodeChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } var tmp shufflingBytesStruct select { case tmp = <-p.PreviousNodeInPathChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } sm := ShufflingMessage{} diff --git a/protocols/tools_protocol.go b/protocols/tools_protocol.go index 7474180..b882ecb 100644 --- a/protocols/tools_protocol.go +++ b/protocols/tools_protocol.go @@ -3,7 +3,7 @@ package protocolsunlynx import ( - "errors" + "fmt" "github.com/ldsec/unlynx/lib" ) @@ -13,7 +13,7 @@ import ( // RetrieveSimpleDataFromMap extract the data from a map into an array func RetrieveSimpleDataFromMap(groupedData map[libunlynx.GroupingKey]libunlynx.FilteredResponse) ([]libunlynx.CipherText, error) { if len(groupedData) != 1 { - return nil, errors.New("the map given in arguments is empty or have more than one key") + return nil, fmt.Errorf("the map given in arguments is empty or have more than one key") } filteredResp, present := groupedData[EMPTYKEY] @@ -25,7 +25,7 @@ func RetrieveSimpleDataFromMap(groupedData map[libunlynx.GroupingKey]libunlynx.F return result, nil } - return nil, errors.New("the map element doesn't have key with value EMPTYKEY") + return nil, fmt.Errorf("the map element doesn't have key with value EMPTYKEY") } // _____________________ DETERMINISTIC_TAGGING PROTOCOL _____________________ diff --git a/protocols/utils/addrm_server_protocol.go b/protocols/utils/addrm_server_protocol.go index da62a8b..ec192c7 100644 --- a/protocols/utils/addrm_server_protocol.go +++ b/protocols/utils/addrm_server_protocol.go @@ -4,7 +4,7 @@ package protocolsunlynxutils import ( - "errors" + "fmt" "sync" "time" @@ -79,7 +79,7 @@ func (p *AddRmServerProtocol) Start() error { roundProof = libunlynx.StartTimer(p.Name() + "_AddRmServer(PROOFSVerif)") if p.Proofs && len(proofs.List) == 0 { - return errors.New("something went wrong during the creation of the add/rm proofs") + return fmt.Errorf("something went wrong during the creation of the add/rm proofs") } libunlynxaddrm.AddRmListProofVerification(proofs, 1.0) @@ -97,7 +97,7 @@ func (p *AddRmServerProtocol) Dispatch() error { select { case finalResultMessage = <-finalResultAddrm: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } p.FeedbackChannel <- finalResultMessage diff --git a/protocols/utils/local_aggregation_protocol.go b/protocols/utils/local_aggregation_protocol.go index c48870d..665cb3b 100644 --- a/protocols/utils/local_aggregation_protocol.go +++ b/protocols/utils/local_aggregation_protocol.go @@ -3,7 +3,7 @@ package protocolsunlynxutils import ( - "errors" + "fmt" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/lib/aggregation" "go.dedis.ch/onet/v3" @@ -88,7 +88,7 @@ func (p *LocalAggregationProtocol) Dispatch() error { select { case finalResultMessage = <-finalResultAggr: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } p.FeedbackChannel <- finalResultMessage diff --git a/protocols/utils/local_clear_aggregation_protocol.go b/protocols/utils/local_clear_aggregation_protocol.go index bf5eeb9..9e73549 100644 --- a/protocols/utils/local_clear_aggregation_protocol.go +++ b/protocols/utils/local_clear_aggregation_protocol.go @@ -3,7 +3,7 @@ package protocolsunlynxutils import ( - "errors" + "fmt" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/lib/store" "go.dedis.ch/onet/v3" @@ -62,7 +62,7 @@ func (p *LocalClearAggregationProtocol) Dispatch() error { select { case finalResultMessage = <-finalResultClearAggr: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } p.FeedbackChannel <- finalResultMessage diff --git a/protocols/utils/proofs_verification_protocol.go b/protocols/utils/proofs_verification_protocol.go index 64a642e..7cbf169 100644 --- a/protocols/utils/proofs_verification_protocol.go +++ b/protocols/utils/proofs_verification_protocol.go @@ -5,7 +5,7 @@ package protocolsunlynxutils import ( - "errors" + "fmt" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/lib/aggregation" "github.com/ldsec/unlynx/lib/deterministic_tag" @@ -113,7 +113,7 @@ func (p *ProofsVerificationProtocol) Dispatch() error { select { case finalResultMessage = <-finalResult: case <-time.After(libunlynx.TIMEOUT): - return errors.New(p.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(p.ServerIdentity().String() + " didn't get the on time") } p.FeedbackChannel <- finalResultMessage diff --git a/services/service.go b/services/service.go index 6c03a81..f703fe3 100644 --- a/services/service.go +++ b/services/service.go @@ -1,7 +1,7 @@ package servicesunlynx import ( - "errors" + "fmt" "strconv" "time" @@ -133,10 +133,10 @@ type Service struct { func (s *Service) getSurvey(sid SurveyID) (Survey, error) { surv, err := s.Survey.Get(string(sid)) if err != nil { - return Survey{}, errors.New("Error" + err.Error() + "while getting surveyID" + string(sid)) + return Survey{}, fmt.Errorf("error while getting surveyID "+string(sid)+": %v", err) } if surv == nil { - return Survey{}, errors.New("Empty map entry while getting surveyID" + string(sid)) + return Survey{}, fmt.Errorf("empty map entry while getting surveyID " + string(sid)) } return surv.(Survey), nil } @@ -154,19 +154,19 @@ func NewService(c *onet.Context) (onet.Service, error) { } var cerr error if cerr = newUnLynxInstance.RegisterHandler(newUnLynxInstance.HandleSurveyCreationQuery); cerr != nil { - return nil, errors.New("Wrong Handler." + cerr.Error()) + return nil, fmt.Errorf("wrong Handler: %v", cerr) } if cerr = newUnLynxInstance.RegisterHandler(newUnLynxInstance.HandleSurveyResponseQuery); cerr != nil { - return nil, errors.New("Wrong Handler." + cerr.Error()) + return nil, fmt.Errorf("wrong Handler: %v", cerr) } if cerr = newUnLynxInstance.RegisterHandler(newUnLynxInstance.HandleSurveyResultsQuery); cerr != nil { - return nil, errors.New("Wrong Handler." + cerr.Error()) + return nil, fmt.Errorf("wrong Handler: %v", cerr) } if cerr = newUnLynxInstance.RegisterHandler(newUnLynxInstance.HandleDDTfinished); cerr != nil { - return nil, errors.New("Wrong Handler." + cerr.Error()) + return nil, fmt.Errorf("wrong Handler: %v", cerr) } if cerr = newUnLynxInstance.RegisterHandler(newUnLynxInstance.HandleQueryBroadcastFinished); cerr != nil { - return nil, errors.New("Wrong Handler." + cerr.Error()) + return nil, fmt.Errorf("wrong Handler: %v", cerr) } c.RegisterProcessor(newUnLynxInstance, msgTypes.msgSurveyCreationQuery) @@ -574,7 +574,7 @@ func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfi } } default: - return nil, errors.New("Service attempts to start an unknown protocol: " + tn.ProtocolName() + ".") + return nil, fmt.Errorf("service attempts to start an unknown protocol: " + tn.ProtocolName()) } return pi, nil } @@ -594,7 +594,7 @@ func (s *Service) StartProtocol(name string, targetSurvey SurveyID) (onet.Protoc pi, err := s.NewProtocol(tn, &conf) if err != nil { - return nil, errors.New("Error running " + name + " :" + err.Error()) + return nil, fmt.Errorf("error running "+name+" : %v", err) } err = s.RegisterProtocolInstance(pi) @@ -647,7 +647,7 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error { err = s.ShufflingPhase(survey.Query.SurveyID) if err != nil { - return errors.New("Error in the Shuffling Phase: " + err.Error()) + return fmt.Errorf("error in the Shuffling Phase: %v", err) } libunlynx.EndTimer(start) @@ -656,7 +656,7 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error { err = s.TaggingPhase(target.Query.SurveyID) if err != nil { - return errors.New("Error in the Tagging Phase: " + err.Error()) + return fmt.Errorf("error in the Tagging Phase: %v", err) } // broadcasts the query to unlock waiting channel @@ -674,7 +674,7 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error { err = s.AggregationPhase(target.Query.SurveyID) if err != nil { - return errors.New("Error in the Aggregation Phase: " + err.Error()) + return fmt.Errorf("error in the Aggregation Phase: %v", err) } libunlynx.EndTimer(start) @@ -686,7 +686,7 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error { err := s.DROPhase(target.Query.SurveyID) if err != nil { - return errors.New("Error in the DRO Phase: " + err.Error()) + return fmt.Errorf("error in the DRO Phase: %v", err) } libunlynx.EndTimer(start) @@ -698,7 +698,7 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error { err := s.KeySwitchingPhase(target.Query.SurveyID) if err != nil { - return errors.New("Error in the Key Switching Phase: " + err.Error()) + return fmt.Errorf("error in the Key Switching Phase: %v", err) } libunlynx.EndTimer(start) @@ -728,7 +728,7 @@ func (s *Service) ShufflingPhase(targetSurvey SurveyID) error { select { case tmpShufflingResult = <-pi.(*protocolsunlynx.ShufflingProtocol).FeedbackChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(s.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(s.ServerIdentity().String() + " didn't get the on time") } survey, err = s.getSurvey(targetSurvey) @@ -763,7 +763,7 @@ func (s *Service) TaggingPhase(targetSurvey SurveyID) error { select { case tmpDeterministicTaggingResult = <-pi.(*protocolsunlynx.DeterministicTaggingProtocol).FeedbackChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(s.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(s.ServerIdentity().String() + " didn't get the on time") } survey, err = s.getSurvey(targetSurvey) @@ -802,7 +802,7 @@ func (s *Service) AggregationPhase(targetSurvey SurveyID) error { select { case cothorityAggregatedData = <-pi.(*protocolsunlynx.CollectiveAggregationProtocol).FeedbackChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(s.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(s.ServerIdentity().String() + " didn't get the on time") } survey, err := s.getSurvey(targetSurvey) @@ -831,7 +831,7 @@ func (s *Service) DROPhase(targetSurvey SurveyID) error { select { case tmpShufflingResult = <-pi.(*protocolsunlynx.ShufflingProtocol).FeedbackChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(s.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(s.ServerIdentity().String() + " didn't get the on time") } shufflingResult := protocolsunlynx.MatrixCipherTextToProcessResponse(tmpShufflingResult, survey.Lengths) @@ -857,7 +857,7 @@ func (s *Service) KeySwitchingPhase(targetSurvey SurveyID) error { select { case tmpKeySwitchedAggregatedResponses = <-pi.(*protocolsunlynx.KeySwitchingProtocol).FeedbackChannel: case <-time.After(libunlynx.TIMEOUT): - return errors.New(s.ServerIdentity().String() + " didn't get the on time.") + return fmt.Errorf(s.ServerIdentity().String() + " didn't get the on time") } keySwitchedAggregatedResponses := protocolsunlynx.CipherVectorToFilteredResponse(tmpKeySwitchedAggregatedResponses, survey.Lengths) diff --git a/simul/addrm_server_simul.go b/simul/addrm_server_simul.go index 78e96fa..512a7ac 100644 --- a/simul/addrm_server_simul.go +++ b/simul/addrm_server_simul.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "github.com/BurntSushi/toml" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/protocols/utils" @@ -91,7 +91,7 @@ func (sim *AddRmSimulation) Run(config *onet.SimulationConfig) error { log.Lvl1("Number of aggregated lines: ", len(results)) libunlynx.EndTimer(round) case <-time.After(libunlynx.TIMEOUT): - return errors.New("simulation didn't finish in time") + return fmt.Errorf("simulation didn't finish in time") } } diff --git a/simul/collective_aggregation_simul.go b/simul/collective_aggregation_simul.go index 5a0fe40..aa65aff 100644 --- a/simul/collective_aggregation_simul.go +++ b/simul/collective_aggregation_simul.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "github.com/BurntSushi/toml" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/lib/aggregation" @@ -86,7 +86,7 @@ func (sim *CollectiveAggregationSimulation) Node(config *onet.SimulationConfig) func(tni *onet.TreeNodeInstance) (onet.ProtocolInstance, error) { return NewAggregationProtocolSimul(tni, sim) }); err != nil { - return errors.New("Error while registering :" + err.Error()) + return fmt.Errorf("error while registering : %v", err) } return sim.SimulationBFTree.Node(config) diff --git a/simul/deterministic_tagging_simul.go b/simul/deterministic_tagging_simul.go index 4af5050..9b8ac02 100644 --- a/simul/deterministic_tagging_simul.go +++ b/simul/deterministic_tagging_simul.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "github.com/BurntSushi/toml" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/protocols" @@ -60,7 +60,7 @@ func (sim *DeterministicTaggingSimulation) Node(config *onet.SimulationConfig) e func(tni *onet.TreeNodeInstance) (onet.ProtocolInstance, error) { return NewDeterministicTaggingSimul(tni, sim) }); err != nil { - return errors.New("Error while registering :" + err.Error()) + return fmt.Errorf("error while registering : %v", err) } return sim.SimulationBFTree.Node(config) diff --git a/simul/local_aggregation_simul.go b/simul/local_aggregation_simul.go index ce2af5c..3ec5ce4 100644 --- a/simul/local_aggregation_simul.go +++ b/simul/local_aggregation_simul.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "github.com/BurntSushi/toml" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/protocols" @@ -121,7 +121,7 @@ func (sim *LocalAggregationSimulation) Run(config *onet.SimulationConfig) error log.Lvl1("Number of aggregated lines: ", len(results)) libunlynx.EndTimer(round) case <-time.After(libunlynx.TIMEOUT): - return errors.New("simulation didn't finish in time") + return fmt.Errorf("simulation didn't finish in time") } } diff --git a/simul/local_clear_aggregation_simul.go b/simul/local_clear_aggregation_simul.go index 9c685e6..6fd7ef4 100644 --- a/simul/local_clear_aggregation_simul.go +++ b/simul/local_clear_aggregation_simul.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "github.com/BurntSushi/toml" "github.com/ldsec/unlynx/data" libunlynx "github.com/ldsec/unlynx/lib" @@ -98,7 +98,7 @@ func (sim *LocalClearAggregationSimulation) Run(config *onet.SimulationConfig) e } round.Record() case <-time.After(libunlynx.TIMEOUT): - return errors.New("simulation didn't finish in time") + return fmt.Errorf("simulation didn't finish in time") } } diff --git a/simul/proofs_verification_simul.go b/simul/proofs_verification_simul.go index f9baab9..6d3f758 100644 --- a/simul/proofs_verification_simul.go +++ b/simul/proofs_verification_simul.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "github.com/BurntSushi/toml" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/lib/aggregation" @@ -238,20 +238,20 @@ func (sim *ProofsVerificationSimulation) Run(config *onet.SimulationConfig) erro log.Lvl1(len(results), " proofs verified") if results[0] == false { - return errors.New("key switching proofs failed") + return fmt.Errorf("key switching proofs failed") } else if results[1] == false { - return errors.New("deterministic tagging (creation) proofs failed") + return fmt.Errorf("deterministic tagging (creation) proofs failed") } else if results[2] == false { - return errors.New("deterministic tagging (addition) proofs failed") + return fmt.Errorf("deterministic tagging (addition) proofs failed") } else if results[3] == false { - return errors.New("local aggregation proofs failed") + return fmt.Errorf("local aggregation proofs failed") } else if results[4] == false { - return errors.New("shuffling proofs failed") + return fmt.Errorf("shuffling proofs failed") } else if results[5] == false { - return errors.New("collective aggregation proofs failed") + return fmt.Errorf("collective aggregation proofs failed") } case <-time.After(libunlynx.TIMEOUT): - return errors.New("simulation didn't finish in time") + return fmt.Errorf("simulation didn't finish in time") } } return nil diff --git a/simul/shuffling+ddt_simul.go b/simul/shuffling+ddt_simul.go index 9927471..2552fdc 100644 --- a/simul/shuffling+ddt_simul.go +++ b/simul/shuffling+ddt_simul.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "github.com/BurntSushi/toml" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/lib/shuffle" @@ -54,7 +54,7 @@ func (sim *ShufflingPlusDDTSimulation) Node(config *onet.SimulationConfig) error func(tni *onet.TreeNodeInstance) (onet.ProtocolInstance, error) { return NewShufflingPlusDDTSimul(tni, sim) }); err != nil { - return errors.New("Error while registering :" + err.Error()) + return fmt.Errorf("error while registering : %v", err) } return sim.SimulationBFTree.Node(config) diff --git a/simul/shuffling_simul.go b/simul/shuffling_simul.go index d1f60c5..b0be658 100644 --- a/simul/shuffling_simul.go +++ b/simul/shuffling_simul.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "github.com/BurntSushi/toml" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/lib/shuffle" @@ -56,7 +56,7 @@ func (sim *ShufflingSimulation) Node(config *onet.SimulationConfig) error { func(tni *onet.TreeNodeInstance) (onet.ProtocolInstance, error) { return NewShufflingSimul(tni, sim) }); err != nil { - return errors.New("Error while registering :" + err.Error()) + return fmt.Errorf("error while registering : %v", err) } return sim.SimulationBFTree.Node(config) diff --git a/simul/unlynx_simul.go b/simul/unlynx_simul.go index dcbdfc3..12053b0 100644 --- a/simul/unlynx_simul.go +++ b/simul/unlynx_simul.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "github.com/ldsec/unlynx/data" "github.com/ldsec/unlynx/lib" "github.com/ldsec/unlynx/lib/tools" @@ -74,7 +74,7 @@ func (sim *SimulationUnLynx) Run(config *onet.SimulationConfig) error { // Does not make sense to have more servers than clients!! if nbrHosts > sim.NbrDPs { - return errors.New("hosts: " + strconv.FormatInt(int64(nbrHosts), 10) + " must be the same or lower as num_clients " + strconv.FormatInt(int64(sim.NbrDPs), 10)) + return fmt.Errorf("hosts: " + strconv.FormatInt(int64(nbrHosts), 10) + " must be the same or lower as num_clients " + strconv.FormatInt(int64(sim.NbrDPs), 10)) } el := (*config.Tree).Roster @@ -155,7 +155,7 @@ func (sim *SimulationUnLynx) Run(config *onet.SimulationConfig) error { client = servicesunlynx.NewUnLynxClient(server, strconv.Itoa(i+1)) if tmpErr := client.SendSurveyResponseQuery(*surveyID, dataCollection, el.Aggregate, sim.DataRepetitions, count); tmpErr != nil { mutex.Lock() - err = errors.New("Error while sending DP (" + client.String() + ") responses:" + err.Error()) + err = fmt.Errorf("Error while sending DP ("+client.String()+") responses: %v", err) log.Error(err) mutex.Unlock() } @@ -174,7 +174,7 @@ func (sim *SimulationUnLynx) Run(config *onet.SimulationConfig) error { grp, aggr, err := client.SendSurveyResultsQuery(*surveyID) if err != nil { - return errors.New("Service could not output the results: " + err.Error()) + return fmt.Errorf("service could not output the results: %v", err) } libunlynx.EndTimer(start)