From 41e2730cb67f7117a44bf07d003edb89940f4f54 Mon Sep 17 00:00:00 2001 From: lauener Date: Mon, 26 Feb 2024 10:28:34 +0100 Subject: [PATCH] More linter fix --- proof/proof.go | 14 ++++++++++---- share/vss/rabin/vss_test.go | 1 - shuffle/pair.go | 2 ++ shuffle/shuffle_test.go | 1 - shuffle/simple.go | 10 ++-------- suites/suites.go | 6 ++++-- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/proof/proof.go b/proof/proof.go index 1ff9580cc..6d4fada82 100644 --- a/proof/proof.go +++ b/proof/proof.go @@ -484,7 +484,8 @@ func (op *orPred) commit(prf *proof, w kyber.Scalar, pv []kyber.Scalar) error { prf.pp[op] = pp // Choose pre-challenges for our subs. - if w == nil { + switch { + case w == nil: // We're on a proof-obligated branch; // choose random pre-challenges for only non-obligated subs. choice, ok := prf.choice[op] @@ -501,7 +502,7 @@ func (op *orPred) commit(prf *proof, w kyber.Scalar, pv []kyber.Scalar) error { } } // else wi[i] == nil for proof-obligated sub } - } else { + default: // Since w != nil, we're in a non-obligated branch, // so choose random pre-challenges for all subs // such that they add up to the master pre-challenge w. @@ -515,14 +516,19 @@ func (op *orPred) commit(prf *proof, w kyber.Scalar, pv []kyber.Scalar) error { } wl.Sub(wl, wi[i]) } + wi[last] = wl } + return commitmentProducer(prf, wi, sub) +} + +func commitmentProducer(prf *proof, wi []kyber.Scalar, sub []Predicate) error { // Now recursively choose commitments within each sub for i := 0; i < len(sub); i++ { // Fresh variable-blinding secrets for each pre-commitment - if e := sub[i].commit(prf, wi[i], nil); e != nil { - return e + if err := sub[i].commit(prf, wi[i], nil); err != nil { + return err } } diff --git a/share/vss/rabin/vss_test.go b/share/vss/rabin/vss_test.go index 95443c681..544541211 100644 --- a/share/vss/rabin/vss_test.go +++ b/share/vss/rabin/vss_test.go @@ -367,7 +367,6 @@ func TestVSSAggregatorVerifyResponse(t *testing.T) { dealer, verifiers := genAll() v := verifiers[0] deal := dealer.deals[0] - //goodSec := deal.SecShare.V wrongSec, _ := genPair() deal.SecShare.V = wrongSec encD, _ := dealer.EncryptedDeal(0) diff --git a/shuffle/pair.go b/shuffle/pair.go index 8fa2861ea..61733b243 100644 --- a/shuffle/pair.go +++ b/shuffle/pair.go @@ -124,6 +124,8 @@ func (ps *PairShuffle) Init(grp kyber.Group, k int) *PairShuffle { } // Prove returns an error if the shuffle is not correct. +// +//nolint:funlen func (ps *PairShuffle) Prove( pi []int, g, h kyber.Point, beta []kyber.Scalar, x, y []kyber.Point, rand cipher.Stream, diff --git a/shuffle/shuffle_test.go b/shuffle/shuffle_test.go index c91af2f20..3c1f476cb 100644 --- a/shuffle/shuffle_test.go +++ b/shuffle/shuffle_test.go @@ -60,7 +60,6 @@ func pairShuffleTest(suite Suite, k, n int) { if err != nil { panic("Shuffle proof failed: " + err.Error()) } - //fmt.Printf("proof:\n%s\n",hex.Dump(prf)) // Check it verifier := Verifier(suite, nil, H, X, Y, Xbar, Ybar) diff --git a/shuffle/simple.go b/shuffle/simple.go index 1573fe135..535e6a44c 100644 --- a/shuffle/simple.go +++ b/shuffle/simple.go @@ -86,6 +86,8 @@ func (ss *SimpleShuffle) Init(grp kyber.Group, k int) *SimpleShuffle { // Neff, "Verifiable Mixing (Shuffling) of ElGamal Pairs", 2004. // The Scalar vector y must be a permutation of Scalar vector x // but with all elements multiplied by common Scalar gamma. +// +//nolint:funlen // 51 statement instead of authorized 50 func (ss *SimpleShuffle) Prove(g kyber.Point, gamma kyber.Scalar, x, y []kyber.Scalar, _ cipher.Stream, ctx proof.ProverContext) error { @@ -100,14 +102,6 @@ func (ss *SimpleShuffle) Prove(g kyber.Point, gamma kyber.Scalar, panic("mismatched vector lengths") } - // // Dump input vectors to show their correspondences - // for i := 0; i < k; i++ { - // println("x",grp.Scalar().Mul(gamma,x[i]).String()) - // } - // for i := 0; i < k; i++ { - // println("y",y[i].String()) - // } - // Step 0: inputs for i := 0; i < k; i++ { // (4) ss.p0.X[i] = grp.Point().Mul(x[i], g) diff --git a/suites/suites.go b/suites/suites.go index ab95395c4..4e7997b6a 100644 --- a/suites/suites.go +++ b/suites/suites.go @@ -25,7 +25,6 @@ var suites = map[string]Suite{} var requireConstTime = false // register is called by suites to make themselves known to Kyber. -// func register(s Suite) { suites[strings.ToLower(s.String())] = s } @@ -38,7 +37,10 @@ var ErrUnknownSuite = errors.New("unknown suite") func Find(name string) (Suite, error) { if s, ok := suites[strings.ToLower(name)]; ok { if requireConstTime && strings.ToLower(s.String()) != "ed25519" { - return nil, errors.New("requested suite exists but is not implemented with constant time algorithms as required by suites.RequireConstantTime") + return nil, errors.New( + "requested suite exists but is not implemented " + + "with constant time algorithms as required by " + + "suites.RequireConstantTime") } return s, nil }