diff --git a/cmd/unlynx/client.go b/cmd/unlynx/client.go index 6be3528..7709fff 100644 --- a/cmd/unlynx/client.go +++ b/cmd/unlynx/client.go @@ -98,7 +98,7 @@ func parseQuery(el *onet.Roster, sum string, count bool, where, predicate, group whereRegex := "{(w[0-9]+(,\\s*[0-9]+))*(,\\s*w[0-9]+(,\\s*[0-9]+))*}" groupByRegex := "{g[0-9]+(,\\s*g[0-9]+)*}" - if checkRegex(sum, sumRegex) == false { + if !checkRegex(sum, sumRegex) { return nil, false, nil, "", nil, fmt.Errorf("error parsing the sum parameter(s)") } sum = strings.Replace(sum, " ", "", -1) @@ -114,12 +114,12 @@ func parseQuery(el *onet.Roster, sum string, count bool, where, predicate, group } } - if check == false { + if !check { return nil, false, nil, "", nil, fmt.Errorf("no 'count' attribute in the sum variables") } } - if checkRegex(where, whereRegex) == false { + if !checkRegex(where, whereRegex) { return nil, false, nil, "", nil, fmt.Errorf("error parsing the where parameter(s)") } where = strings.Replace(where, " ", "", -1) @@ -144,7 +144,7 @@ func parseQuery(el *onet.Roster, sum string, count bool, where, predicate, group } } - if checkRegex(groupBy, groupByRegex) == false { + if !checkRegex(groupBy, groupByRegex) { return nil, false, nil, "", nil, fmt.Errorf("error parsing the groupBy parameter(s)") } groupBy = strings.Replace(groupBy, " ", "", -1) diff --git a/data/handle_data.go b/data/handle_data.go index 61d1fc7..913b07f 100644 --- a/data/handle_data.go +++ b/data/handle_data.go @@ -82,7 +82,7 @@ func GenerateData(numDPs, numEntries, numEntriesFiltered, numGroupsClear, numGro testData := make(map[string][]libunlynx.DpClearResponse) - if randomGroups == false { + if !randomGroups { numElem := 1 for _, el := range numType { numElem = numElem * int(el) @@ -362,7 +362,7 @@ func CompareClearResponses(x []libunlynx.DpClearResponse, y []libunlynx.DpClearR } } - if test == false { + if !test { break } } diff --git a/lib/crypto.go b/lib/crypto.go index 665b4cc..9b85049 100644 --- a/lib/crypto.go +++ b/lib/crypto.go @@ -343,9 +343,9 @@ func discreteLog(P kyber.Point, checkNeg bool) (int64, error) { guessIntMinus := int64(0) start := true - for i := guessInt; i < MaxHomomorphicInt && foundPos == false && foundNeg == false; i = i + 1 { + for i := guessInt; i < MaxHomomorphicInt && !foundPos && !foundNeg; i = i + 1 { // check for 0 first - if start == false { + if !start { guess = SuiTe.Point().Add(guess, B) } start = false @@ -365,7 +365,7 @@ func discreteLog(P kyber.Point, checkNeg bool) (int64, error) { foundNeg = true } } - if foundNeg == false && guess.Equal(P) { + if !foundNeg && guess.Equal(P) { foundPos = true } } @@ -373,7 +373,7 @@ func discreteLog(P kyber.Point, checkNeg bool) (int64, error) { currentGreatestInt = guessInt mutex.Unlock() - if foundPos == false && foundNeg == false { + if !foundPos && !foundNeg { log.Error("out of bound encryption, bound is ", MaxHomomorphicInt) return 0, nil } @@ -451,7 +451,7 @@ func (cv *CipherVector) Equal(cv2 *CipherVector) bool { } for i := range *cv2 { - if (*cv)[i].Equal(&(*cv2)[i]) == false { + if !(*cv)[i].Equal(&(*cv2)[i]) { return false } } @@ -490,7 +490,7 @@ func (dcv *DeterministCipherVector) Equal(dcv2 *DeterministCipherVector) bool { } for i := range *dcv2 { - if (*dcv)[i].Equal(&(*dcv2)[i]) == false { + if !(*dcv)[i].Equal(&(*dcv2)[i]) { return false } } diff --git a/lib/crypto_test.go b/lib/crypto_test.go index 74f1382..14e0d0d 100644 --- a/lib/crypto_test.go +++ b/lib/crypto_test.go @@ -119,7 +119,7 @@ func TestNullCipherVector(t *testing.T) { nullVectDec := libunlynx.DecryptIntVector(secKey, &nullVectEnc) target := []int64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - if reflect.DeepEqual(nullVectDec, target) == false { + if !reflect.DeepEqual(nullVectDec, target) { t.Fatal("Null vector of dimension 4 should be ", target, "got", nullVectDec) } @@ -127,7 +127,7 @@ func TestNullCipherVector(t *testing.T) { twoTimesNullEnc.Add(nullVectEnc, nullVectEnc) twoTimesNullDec := libunlynx.DecryptIntVector(secKey, twoTimesNullEnc) - if reflect.DeepEqual(twoTimesNullDec, target) == false { + if !reflect.DeepEqual(twoTimesNullDec, target) { t.Fatal("Null vector + Null vector should be ", target, "got", twoTimesNullDec) } } @@ -198,7 +198,7 @@ func TestAbstractPointsConverter(t *testing.T) { } for i, el := range aps { - if reflect.DeepEqual(el.String(), newAps[i].String()) == false { + if !reflect.DeepEqual(el.String(), newAps[i].String()) { t.Fatal("Wrong results, expected", el, "but got", newAps[i]) } } diff --git a/lib/shuffle/shuffle.go b/lib/shuffle/shuffle.go index a4af8cb..2044f7a 100644 --- a/lib/shuffle/shuffle.go +++ b/lib/shuffle/shuffle.go @@ -183,7 +183,7 @@ func PrecomputationWritingForShuffling(appFlag bool, gobFile, serverName string, // ReadPrecomputedFile reads the precomputation data from a .gob file func ReadPrecomputedFile(fileName string) ([]CipherVectorScalar, error) { - if _, err := os.Stat(fileName); os.IsNotExist(err) == false { + if _, err := os.Stat(fileName); !os.IsNotExist(err) { var encoded []CipherVectorScalarBytes err := libunlynxtools.ReadFromGobFile(fileName, &encoded) if err != nil { diff --git a/lib/store/store.go b/lib/store/store.go index 490ffd2..98bdc10 100644 --- a/lib/store/store.go +++ b/lib/store/store.go @@ -53,7 +53,7 @@ func proccessParameters(data []string, clear map[string]int64, encrypted map[str // all where and group by attributes are in clear if noEnc { containerClear = append(containerClear, clear[v]) - } else if noEnc == false { + } else if !noEnc { if value, ok := encrypted[v]; ok { containerEnc = append(containerEnc, value) } else { @@ -80,7 +80,7 @@ func (s *Store) InsertDpResponse(cr libunlynx.DpResponse, proofsB bool, groupBy, clearWhr, newResp.WhereEnc = proccessParameters(whereStrings, cr.WhereClear, cr.WhereEnc, noEnc) _, newResp.AggregatingAttributes = proccessParameters(sum, cr.AggregatingAttributesClear, cr.AggregatingAttributesEnc, false) - if noEnc == false { + if !noEnc { s.DpResponses = append(s.DpResponses, newResp) } else { value, ok := s.DpResponsesAggr[GroupingKeyTuple{libunlynx.Key(clearGrp), libunlynx.Key(clearWhr)}] @@ -199,7 +199,7 @@ func AddInClear(s []libunlynx.DpClearResponse) []libunlynx.DpClearResponse { cpy = append(cpy, libunlynxtools.ConvertMapToData(elem.AggregatingAttributesClear, "s", 0)...) cpy = append(cpy, libunlynxtools.ConvertMapToData(elem.AggregatingAttributesEnc, "s", len(elem.AggregatingAttributesClear))...) - if _, ok := dataMap[key]; ok == false { + if _, ok := dataMap[key]; !ok { dataMap[key] = cpy } else { for i := 0; i < len(dataMap[key]); i = i + libunlynx.VPARALLELIZE { @@ -272,7 +272,7 @@ func (s *Store) PullCothorityAggregatedFilteredResponses(diffPri bool, noise lib s.GroupedDeterministicFilteredResponses = make(map[libunlynx.GroupingKey]libunlynx.FilteredResponse) - if diffPri == true { + if diffPri { for _, v := range aggregatedResults { for _, aggr := range v.AggregatingAttributes { aggr.Add(aggr, noise) @@ -293,7 +293,7 @@ func (s *Store) PullDeliverableResults(diffPri bool, noise libunlynx.CipherText) results := s.DeliverableResults s.DeliverableResults = s.DeliverableResults[:0] - if diffPri == true { + if diffPri { for _, v := range results { for _, aggr := range v.AggregatingAttributes { aggr.Add(aggr, noise) diff --git a/lib/structs.go b/lib/structs.go index af99a0e..0e1a733 100644 --- a/lib/structs.go +++ b/lib/structs.go @@ -102,7 +102,7 @@ func (cv *FilteredResponse) Add(cv1, cv2 FilteredResponse) *FilteredResponse { // AddInMap permits to add a filtered response with its deterministic tag in a map func AddInMap(s map[GroupingKey]FilteredResponse, key GroupingKey, added FilteredResponse) { - if localResult, ok := s[key]; ok == false { + if localResult, ok := s[key]; !ok { s[key] = added } else { nfr := NewFilteredResponse(len(added.GroupByEnc), len(added.AggregatingAttributes)) diff --git a/lib/tools/tools.go b/lib/tools/tools.go index 4b57898..0aa8f29 100644 --- a/lib/tools/tools.go +++ b/lib/tools/tools.go @@ -16,7 +16,7 @@ import ( func SendISMOthers(s *onet.ServiceProcessor, el *onet.Roster, msg interface{}) error { var errStrs []string for _, e := range el.List { - if e.ID.Equal(s.ServerIdentity().ID) == false { + if !e.ID.Equal(s.ServerIdentity().ID) { log.Lvl3("Sending to", e) err := s.SendRaw(e, msg) if err != nil { diff --git a/protocols/collective_aggregation_protocol.go b/protocols/collective_aggregation_protocol.go index 599b830..40fb36b 100644 --- a/protocols/collective_aggregation_protocol.go +++ b/protocols/collective_aggregation_protocol.go @@ -151,7 +151,7 @@ func (p *CollectiveAggregationProtocol) Dispatch() error { } // 1. Aggregation announcement phase - if p.IsRoot() == false { + if !p.IsRoot() { err := p.aggregationAnnouncementPhase() if err != nil { return err @@ -211,7 +211,7 @@ func (p *CollectiveAggregationProtocol) aggregationAnnouncementPhase() error { func (p *CollectiveAggregationProtocol) ascendingAggregationPhase(cvMap map[libunlynx.GroupingKey][]libunlynx.CipherVector) (*map[libunlynx.GroupingKey]libunlynx.FilteredResponse, error) { roundTotComput := libunlynx.StartTimer(p.Name() + "_CollectiveAggregation(ascendingAggregation)") - if p.IsLeaf() == false { + if !p.IsLeaf() { length := make([]cadmbLengthStruct, 0) for _, v := range <-p.LengthNodeChannel { length = append(length, v) @@ -257,7 +257,7 @@ func (p *CollectiveAggregationProtocol) ascendingAggregationPhase(cvMap map[libu libunlynx.EndTimer(roundTotComput) - if p.IsRoot() == false { + if !p.IsRoot() { detAggrResponses := make([]libunlynx.FilteredResponseDet, len(*p.GroupedData)) count := 0 for i, v := range *p.GroupedData { diff --git a/protocols/deterministic_tagging_test.go b/protocols/deterministic_tagging_test.go index 77c811d..7f1fbbd 100644 --- a/protocols/deterministic_tagging_test.go +++ b/protocols/deterministic_tagging_test.go @@ -81,7 +81,7 @@ func TestDeterministicTagging(t *testing.T) { present = true } } - if present == false { + if !present { t.Fatal("DP responses changed and shouldn't") } } diff --git a/protocols/key_switching_protocol.go b/protocols/key_switching_protocol.go index 0e17607..a774605 100644 --- a/protocols/key_switching_protocol.go +++ b/protocols/key_switching_protocol.go @@ -191,7 +191,7 @@ func (p *KeySwitchingProtocol) Dispatch() error { defer p.Done() // 1. Key switching announcement phase - if p.IsRoot() == false { + if !p.IsRoot() { targetPublicKey, rbs, err := p.announcementKSPhase() if err != nil { return err @@ -253,7 +253,7 @@ func (p *KeySwitchingProtocol) ascendingKSPhase() (*libunlynx.CipherVector, erro keySwitchingAscendingAggregation := libunlynx.StartTimer(p.Name() + "_KeySwitching(ascendingAggregation)") - if p.IsLeaf() == false { + if !p.IsLeaf() { length := make([]LengthStruct, 0) for _, v := range <-p.LengthChannel { length = append(length, v) @@ -278,7 +278,7 @@ func (p *KeySwitchingProtocol) ascendingKSPhase() (*libunlynx.CipherVector, erro } libunlynx.EndTimer(keySwitchingAscendingAggregation) - if p.IsRoot() == false { + if !p.IsRoot() { if err := p.SendToParent(&LengthMessage{Length: libunlynxtools.UnsafeCastIntsToBytes([]int{len(*p.NodeContribution)})}); err != nil { return nil, fmt.Errorf("Node "+p.ServerIdentity().String()+" failed to broadcast LengthMessage: %v", err) } diff --git a/protocols/key_switching_protocol_test.go b/protocols/key_switching_protocol_test.go index c43dc60..c9a4a47 100644 --- a/protocols/key_switching_protocol_test.go +++ b/protocols/key_switching_protocol_test.go @@ -74,7 +74,7 @@ func TestCTKS(t *testing.T) { res := libunlynx.DecryptIntVector(clientPrivate, &cv1) log.Lvl2("Received results (attributes) ", res) - if reflect.DeepEqual(res, append(data1, data2...)) == false { + if !reflect.DeepEqual(res, append(data1, data2...)) { t.Fatal("Wrong results, expected", data1, "but got", res) } else { t.Log("Good results") diff --git a/protocols/shuffling_protocol.go b/protocols/shuffling_protocol.go index ebb1aff..acc6fc7 100644 --- a/protocols/shuffling_protocol.go +++ b/protocols/shuffling_protocol.go @@ -224,7 +224,7 @@ func (p *ShufflingProtocol) Dispatch() error { var pi []int var beta [][]kyber.Scalar - if p.IsRoot() == false { + if !p.IsRoot() { shufflingDispatchNoProof := libunlynx.StartTimer(p.Name() + "_Shuffling(DISPATCH-noProof)") shuffledData, pi, beta = libunlynxshuffle.ShuffleSequence(shuffleTarget, libunlynx.SuiTe.Point().Base(), collectiveKey, p.Precomputed) diff --git a/services/service.go b/services/service.go index 91a6c51..dddecc0 100644 --- a/services/service.go +++ b/services/service.go @@ -237,7 +237,7 @@ func (s *Service) HandleSurveyCreationQuery(recq *SurveyCreationQuery) (network. log.Lvl1(s.ServerIdentity().String(), " received a Survey Creation Query") // if this server is the one receiving the query from the client - if recq.IntraMessage == false { + if !recq.IntraMessage { id := uuid.NewV4() newID := SurveyID(id.String()) recq.SurveyID = newID @@ -271,7 +271,7 @@ func (s *Service) HandleSurveyCreationQuery(recq *SurveyCreationQuery) (network. } log.Lvl1(s.ServerIdentity(), " initiated the survey ", recq.SurveyID) - if recq.IntraMessage == false { + if !recq.IntraMessage { recq.IntraMessage = true recq.Source = s.ServerIdentity() // broadcasts the query @@ -318,7 +318,7 @@ func (s *Service) HandleSurveyCreationQuery(recq *SurveyCreationQuery) (network. survey.DpChannel <- 1 } - if recq.IntraMessage == false { + if !recq.IntraMessage { survey, err := s.getSurvey(recq.SurveyID) if err != nil { return nil, err @@ -362,7 +362,7 @@ func (s *Service) HandleSurveyResultsQuery(resq *SurveyResultsQuery) (network.Me return nil, err } - if resq.IntraMessage == false { + if !resq.IntraMessage { resq.IntraMessage = true err := libunlynxtools.SendISMOthers(s.ServiceProcessor, &survey.Query.Roster, resq) @@ -556,7 +556,7 @@ func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfi if tn.IsRoot() { var coaggr []libunlynx.FilteredResponse - if libunlynx.DIFFPRI == true { + if libunlynx.DIFFPRI { coaggr = survey.PullCothorityAggregatedFilteredResponses(true, survey.Noise) } else { coaggr = survey.PullCothorityAggregatedFilteredResponses(false, libunlynx.CipherText{}) @@ -671,7 +671,7 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error { libunlynx.EndTimer(start) // Aggregation Phase - if root == true { + if root { start := libunlynx.StartTimer(s.ServerIdentity().String() + "_AggregationPhase") err = s.AggregationPhase(target.Query.SurveyID) @@ -683,7 +683,7 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error { } // DRO Phase - if root == true && libunlynx.DIFFPRI == true { + if root && libunlynx.DIFFPRI { start := libunlynx.StartTimer(s.ServerIdentity().String() + "_DROPhase") err := s.DROPhase(target.Query.SurveyID) @@ -695,7 +695,7 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error { } // Key Switch Phase - if root == true { + if root { start := libunlynx.StartTimer(s.ServerIdentity().String() + "_KeySwitchingPhase") err := s.KeySwitchingPhase(target.Query.SurveyID) diff --git a/services/service_test.go b/services/service_test.go index 59cb5cf..ae8fcd1 100644 --- a/services/service_test.go +++ b/services/service_test.go @@ -198,7 +198,7 @@ func TestServiceClearAttr(t *testing.T) { grpTab[ind] = v } data, ok := expectedResults[grpTab] - if ok == false || reflect.DeepEqual(data, (*aggr)[i]) == false { + if !ok || !reflect.DeepEqual(data, (*aggr)[i]) { t.Error("Not expected results, got ", (*aggr)[i], " when expected ", data) } } @@ -302,7 +302,7 @@ func TestServiceClearGrpEncWhereAttr(t *testing.T) { grpTab[ind] = v } data, ok := expectedResults[grpTab] - if ok == false || reflect.DeepEqual(data, (*aggr)[i]) == false { + if !ok || !reflect.DeepEqual(data, (*aggr)[i]) { t.Error("Not expected results, got ", (*aggr)[i], " when expected ", data) } } @@ -407,7 +407,7 @@ func TestServiceEncGrpClearWhereAttr(t *testing.T) { grpTab[ind] = v } data, ok := expectedResults[grpTab] - if ok == false || reflect.DeepEqual(data, (*aggr)[i]) == false { + if !ok || !reflect.DeepEqual(data, (*aggr)[i]) { t.Error("Not expected results, got ", (*aggr)[i], " when expected ", data) } } @@ -515,7 +515,7 @@ func TestServiceEncGrpAndWhereAttr(t *testing.T) { grpTab[ind] = v } data, ok := expectedResults[grpTab] - if ok == false || reflect.DeepEqual(data, (*aggr)[i]) == false { + if !ok || !reflect.DeepEqual(data, (*aggr)[i]) { t.Error("Not expected results, got ", (*aggr)[i], " when expected ", data) } } @@ -619,7 +619,7 @@ func TestServiceEverything(t *testing.T) { grpTab[ind] = v } data, ok := expectedResults[grpTab] - if ok == false || reflect.DeepEqual(data, (*aggr)[i]) == false { + if !ok || !reflect.DeepEqual(data, (*aggr)[i]) { t.Error("Not expected results, got ", (*aggr)[i], " when expected ", data) } } @@ -723,7 +723,7 @@ func TestServiceEncGrpAndWhereAttrWithCount(t *testing.T) { grpTab[ind] = v } data, ok := expectedResults[grpTab] - if ok == false || reflect.DeepEqual(data, (*aggr)[i]) == false { + if !ok || !reflect.DeepEqual(data, (*aggr)[i]) { t.Error("Not expected results, got ", (*aggr)[i], " when expected ", data) } } @@ -833,7 +833,7 @@ func TestAllServersNoDPs(t *testing.T) { grpTab[ind] = v } data, ok := expectedResults[grpTab] - if ok == false || reflect.DeepEqual(data, (*aggr)[i]) == false { + if !ok || !reflect.DeepEqual(data, (*aggr)[i]) { t.Error("Not expected results, got ", (*aggr)[i], " when expected ", data) } } @@ -947,7 +947,7 @@ func TestAllServersRandomDPs(t *testing.T) { grpTab[ind] = v } data, ok := expectedResults[grpTab] - if ok == false || reflect.DeepEqual(data, (*aggr)[i]) == false { + if !ok || !reflect.DeepEqual(data, (*aggr)[i]) { t.Error("Not expected results, got ", (*aggr)[i], " when expected ", data) } } @@ -1072,7 +1072,7 @@ func TestConcurrentSurveys(t *testing.T) { grpTab[ind] = v } data, ok := expectedResults[grpTab] - if ok == false || reflect.DeepEqual(data, (*aggr)[i]) == false { + if !ok || !reflect.DeepEqual(data, (*aggr)[i]) { t.Error("Not expected results, got ", (*aggr)[i], " when expected ", data) } } diff --git a/simul/proofs_verification_simul.go b/simul/proofs_verification_simul.go index faf6fff..f2e75a4 100644 --- a/simul/proofs_verification_simul.go +++ b/simul/proofs_verification_simul.go @@ -237,17 +237,17 @@ func (sim *ProofsVerificationSimulation) Run(config *onet.SimulationConfig) erro log.Lvl1(len(results), " proofs verified") - if results[0] == false { + if !results[0] { return fmt.Errorf("key switching proofs failed") - } else if results[1] == false { + } else if !results[1] { return fmt.Errorf("deterministic tagging (creation) proofs failed") - } else if results[2] == false { + } else if !results[2] { return fmt.Errorf("deterministic tagging (addition) proofs failed") - } else if results[3] == false { + } else if !results[3] { return fmt.Errorf("local aggregation proofs failed") - } else if results[4] == false { + } else if !results[4] { return fmt.Errorf("shuffling proofs failed") - } else if results[5] == false { + } else if !results[5] { return fmt.Errorf("collective aggregation proofs failed") } case <-time.After(libunlynx.TIMEOUT): diff --git a/simul/test_data/time_data/parse_time_data.go b/simul/test_data/time_data/parse_time_data.go index 3862ca0..f97de1b 100644 --- a/simul/test_data/time_data/parse_time_data.go +++ b/simul/test_data/time_data/parse_time_data.go @@ -56,7 +56,7 @@ func ReadTomlSetup(filename string, setupNbr int) (map[string]string, error) { c := strings.Split(line, ", ") - if flag == true { + if flag { if pos == setupNbr { for i, el := range c { setup[parameters[i]] = el