Skip to content

Commit

Permalink
More linter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
K1li4nL committed Feb 26, 2024
1 parent 265c47c commit 41e2730
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
14 changes: 10 additions & 4 deletions proof/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.
Expand All @@ -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
}
}

Expand Down
1 change: 0 additions & 1 deletion share/vss/rabin/vss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions shuffle/pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion shuffle/shuffle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 2 additions & 8 deletions shuffle/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions suites/suites.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 41e2730

Please sign in to comment.