-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable linter in the CI #527
Conversation
🔒 Could not start CI tests due to missing safe PR label. Please contact a DEDIS maintainer. |
1 similar comment
🔒 Could not start CI tests due to missing safe PR label. Please contact a DEDIS maintainer. |
7cd82b7
to
bb528f3
Compare
65139ba
to
704ecd1
Compare
2f7e39e
to
539bc4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chances this could be rebased against drandmerge
without including the x86 changes from Matteo branch ? (might have to do some git cherry-picking)
Now CI does the x86 checks in there already I think.
pairing/circl_bls12381/suite_test.go
Outdated
//p = g.Point().Mul(g.Scalar().Pick(rand), nil) | ||
//return | ||
// p = g.Point().Mul(g.Scalar().Pick(rand), nil) | ||
// return | ||
/*}*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems weird that it would all be commented. Has Pick
been implemented for GT now maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at their repo, it seems they didn't, should we remove that code ?
proof/dleq/dleq.go
Outdated
g kyber.Point, | ||
h kyber.Point, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to stick to the convention that points are using Capital letters. Can you add an exception for that linter for kyber.Point
elements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far I couldn't find anyway to add such exceptions, either we disable this check or add //nolint:...
everywhere it is needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted these changes
proof/dleq/dleq.go
Outdated
g []kyber.Point, | ||
h []kyber.Point, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups, used the wrong button.
edda608
to
5689ca1
Compare
5689ca1
to
f71a11f
Compare
digest[0] &= 0xf8 | ||
digest[31] &= 0x7f | ||
digest[31] |= 0x40 | ||
|
||
secret := c.Scalar().(*scalar) | ||
secret := c.Scalar().(*scalar) //nolint:errcheck // V4 may bring better error handling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like either a TODO, or an issue that should be created, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group/edwards25519/point.go
Outdated
@@ -31,48 +31,48 @@ type point struct { | |||
varTime bool | |||
} | |||
|
|||
func (P *point) String() string { | |||
func (p *point) String() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Points should be capitalized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
group/edwards25519/point_vartime.go
Outdated
@@ -4,6 +4,6 @@ package edwards25519 | |||
// but variable time implementation can be used. Set this only on Points | |||
// which represent public information. Using variable time algorithms to | |||
// operate on private information can result in timing side-channels. | |||
func (P *point) AllowVarTime(varTime bool) { | |||
P.varTime = varTime | |||
func (p *point) AllowVarTime(varTime bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Points should be capitalized
group/p256/curve.go
Outdated
@@ -99,10 +98,9 @@ func (p *curvePoint) Pick(rand cipher.Stream) kyber.Point { | |||
return p.Embed(nil, rand) | |||
} | |||
|
|||
// Pick a curve point containing a variable amount of embedded data. | |||
// Embed pick a curve point containing a variable amount of embedded data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Embed pick a curve point containing a variable amount of embedded data. | |
// Embed picks a curve point containing a variable amount of embedded data. |
group/p256/curve.go
Outdated
@@ -121,7 +119,7 @@ func (p *curvePoint) Embed(data []byte, rand cipher.Stream) kyber.Point { | |||
} | |||
} | |||
|
|||
// Extract embedded data from a curve point | |||
// Data extract embedded data from a curve point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Data extract embedded data from a curve point | |
// Data extracts embedded data from a curve point |
group/p256/curve.go
Outdated
func (p *curvePoint) Set(P kyber.Point) kyber.Point { | ||
p.x = P.(*curvePoint).x | ||
p.y = P.(*curvePoint).y | ||
func (p *curvePoint) Set(a kyber.Point) kyber.Point { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kyber.Point should be capitalized, arguably curvePoint too.
group/var_ed25519/curve.go
Outdated
@@ -267,22 +269,19 @@ func (c *curve) onCurve(x, y *mod.Int) bool { | |||
|
|||
// Sanity-check a point to ensure that it is on the curve | |||
// and within the appropriate subgroup. | |||
func (c *curve) validPoint(P point) bool { | |||
func (c *curve) validPoint(p point) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
point P
group/var_ed25519/curve.go
Outdated
@@ -295,7 +294,7 @@ func (c *curve) embedLen() int { | |||
|
|||
// Pick a [pseudo-]random curve point with optional embedded data, | |||
// filling in the point's x,y coordinates | |||
func (c *curve) embed(P point, data []byte, rand cipher.Stream) { | |||
func (c *curve) embed(p point, data []byte, rand cipher.Stream) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
point P
shuffle/simple.go
Outdated
@@ -50,7 +50,7 @@ type SimpleShuffle struct { | |||
} | |||
|
|||
// Simple helper to compute G^{ab-cd} for Theta vector computation. | |||
func thenc(grp kyber.Group, G kyber.Point, | |||
func thenc(grp kyber.Group, g kyber.Point, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
point G
56524c5
to
ecba6df
Compare
proof/dleq/dleq.go
Outdated
if len(G) != len(H) || len(H) != len(secrets) { | ||
return nil, nil, nil, errorDifferentLengths | ||
return nil, nil, nil, errDifferentLengths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is an error return by a public method, the error should be exported as well to allow wrapping and unwrapping of error.
proof/dleq/dleq.go
Outdated
@@ -131,7 +169,7 @@ func (p *Proof) Verify(suite Suite, G kyber.Point, H kyber.Point, xG kyber.Point | |||
a := suite.Point().Add(rG, cxG) | |||
b := suite.Point().Add(rH, cxH) | |||
if !(p.VG.Equal(a) && p.VH.Equal(b)) { | |||
return errorInvalidProof | |||
return errInvalidProof |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, please export this error
pairing/bn254/test_vectors.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move these to a proper test file? Maybe test_vectors_test.go
?
pairing/bn256/point.go
Outdated
p = p.Clone().(*pointG1) | ||
p, ok := p.Clone().(*pointG1) | ||
if !ok { | ||
return nil, errors.New("invalid type cast") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it an exported error ErrTypeCast
since you re-use it multiple times.
proof/dleq/dleq.go
Outdated
var errDifferentLengths = errors.New("inputs of different lengths") | ||
var errInvalidProof = errors.New("invalid proof") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see below about exporting errors that are returned by exported methods.
share/pvss/pvss.go
Outdated
@@ -152,16 +184,22 @@ func DecShareBatch(suite Suite, H kyber.Point, X []kyber.Point, sH []kyber.Point | |||
// log_{G}(X) == log_{sG}(sX). Note that X = xG and sX = s(xG) = x(sG). | |||
func VerifyDecShare(suite Suite, G kyber.Point, X kyber.Point, encShare *PubVerShare, decShare *PubVerShare) error { | |||
if err := decShare.P.Verify(suite, G, decShare.S.V, X, encShare.S.V); err != nil { | |||
return errorDecVerification | |||
return errDecVerification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the signature of this function to have a bool?
Using errors to Verify cryptography is a bad idea:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the other option would be to export that error and them wrap it with fmt.Errorf("invalid: %w", ErrDecVerification)
so that the error cannot be "bypassed" but it's still possible to match on it.
ac0ecb3
to
c4d497b
Compare
c69a232
to
5a15399
Compare
Quality Gate failedFailed conditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm like 108/110 files through... Will just have to test a few extra things wrt to logging changes I guess.
b0 = b1.Mod(b1, prime) | ||
b1 = b1.Mod(b1, prime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch. Would have been nicer to have a new test vector to detect it ;)
d.c.Info(append([]interface{}{"generator"}, keyvals...)) | ||
d.c.Info("generator", keyvals) | ||
} | ||
|
||
func (d *DistKeyGenerator) Error(keyvals ...interface{}) { | ||
d.c.Info(append([]interface{}{"generator"}, keyvals...)) | ||
d.c.Info("generator", keyvals) | ||
} | ||
|
||
func (c *Config) Info(keyvals ...interface{}) { | ||
if c.Log != nil { | ||
c.Log.Info(append([]interface{}{"dkg-log"}, keyvals...)) | ||
c.Log.Info("dkg-log", keyvals) | ||
} | ||
} | ||
|
||
func (c *Config) Error(keyvals ...interface{}) { | ||
if c.Log != nil { | ||
c.Log.Error(append([]interface{}{"dkg-log"}, keyvals...)) | ||
c.Log.Error("dkg-log", keyvals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I remember adding these at some point because our logger weren't working properly otherwise.
I'll need to test this locally actually with a couple loggers I guess T.T
No description provided.