Skip to content

Commit

Permalink
Merge pull request #541 from dedis/update-golangci
Browse files Browse the repository at this point in the history
Update golangci-lint workflow
  • Loading branch information
pierluca authored Sep 4, 2024
2 parents b172e02 + 8146944 commit 89decc8
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 35 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.56.2
version: v1.60.3

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand All @@ -51,4 +51,4 @@ jobs:
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
# install-mode: "goinstall"
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ linters-settings:
excludes:
- G107 # variables in URLs
- G404 # use of weak random generator
- G115 # Disable for now due to the *many* warnings

gocritic:
disabled-checks:
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ generate: tidy

# Coding style static check.
lint: tidy
@echo "Please setup a linter!"
#golangci-lint run
#staticcheck go list ./...
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.3
@go mod tidy
golangci-lint run

vet: tidy
go vet ./...
Expand Down
16 changes: 8 additions & 8 deletions group/mod/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,13 @@ func (i *Int) UnmarshalFrom(r io.Reader) (int, error) {
// BigEndian encodes the value of this Int into a big-endian byte-slice
// at least min bytes but no more than max bytes long.
// Panics if max != 0 and the Int cannot be represented in max bytes.
func (i *Int) BigEndian(min, max int) []byte {
func (i *Int) BigEndian(minBytes, maxBytes int) []byte {
act := i.MarshalSize()
pad, ofs := act, 0
if pad < min {
pad, ofs = min, min-act
if pad < minBytes {
pad, ofs = minBytes, minBytes-act
}
if max != 0 && pad > max {
if maxBytes != 0 && pad > maxBytes {
panic("Int not representable in max bytes")
}
buf := make([]byte, pad)
Expand All @@ -392,18 +392,18 @@ func (i *Int) SetBytes(a []byte) kyber.Scalar {
// LittleEndian encodes the value of this Int into a little-endian byte-slice
// at least min bytes but no more than max bytes long.
// Panics if max != 0 and the Int cannot be represented in max bytes.
func (i *Int) LittleEndian(min, max int) []byte {
func (i *Int) LittleEndian(minByte, maxBytes int) []byte {
act := i.MarshalSize()
vBytes := i.V.Bytes()
vSize := len(vBytes)
if vSize < act {
act = vSize
}
pad := act
if pad < min {
pad = min
if pad < minByte {
pad = minByte
}
if max != 0 && pad > max {
if maxBytes != 0 && pad > maxBytes {
panic("Int not representable in max bytes")
}
buf := make([]byte, pad)
Expand Down
8 changes: 4 additions & 4 deletions pairing/bls12381/bls12381_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ func testGroup(t *testing.T, g kyber.Group, rand cipher.Stream) []kyber.Point {
buf.Reset()
s := g.Scalar().Pick(rand)
if _, err := s.MarshalTo(buf); err != nil {
t.Fatalf("encoding of secret fails: " + err.Error())
t.Fatalf("encoding of secret fails: %s", err.Error())
}
if _, err := stmp.UnmarshalFrom(buf); err != nil {
t.Fatalf("decoding of secret fails: " + err.Error())
t.Fatalf("decoding of secret fails: %s", err.Error())
}
if !stmp.Equal(s) {
t.Fatalf("decoding produces different secret than encoded")
Expand All @@ -368,10 +368,10 @@ func testGroup(t *testing.T, g kyber.Group, rand cipher.Stream) []kyber.Point {
buf.Reset()
p := pick(rand)
if _, err := p.MarshalTo(buf); err != nil {
t.Fatalf("encoding of point fails: " + err.Error())
t.Fatalf("encoding of point fails: %s", err)
}
if _, err := ptmp.UnmarshalFrom(buf); err != nil {
t.Fatalf("decoding of point fails: " + err.Error())
t.Fatalf("decoding of point fails: %s", err.Error())
}

if !ptmp.Equal(p) {
Expand Down
2 changes: 1 addition & 1 deletion pairing/bn254/gfp_decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
//nolint:unused // maybe useful
var hasBMI2 = cpu.X86.HasBMI2

// go:noescape
//go:noescape
func gfpNeg(c, a *gfP)

//go:noescape
Expand Down
5 changes: 3 additions & 2 deletions pairing/bn254/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,11 @@ func mapToPoint(domain []byte, u *gfP) kyber.Point {
// Borrowed from: https://github.com/kilic/bls12-381/blob/master/hash_to_field.go
func expandMsgXmdKeccak256(domain, msg []byte, outLen int) []byte {
h := sha3.NewLegacyKeccak256()
domainLen := uint8(len(domain))
if domainLen > 255 {
if len(domain) > 255 {
panic("invalid domain length")
}
domainLen := uint8(len(domain))

// DST_prime = DST || I2OSP(len(DST), 1)
// b_0 = H(Z_pad || msg || l_i_b_str || I2OSP(0, 1) || DST_prime)
_, _ = h.Write(make([]byte, h.BlockSize()))
Expand Down
7 changes: 0 additions & 7 deletions pairing/bn254/point_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,3 @@ func gnarkExpandMsgXmd(msg, dst []byte, lenInBytes int) ([]byte, error) {
}
return res, nil
}

func min(a, b int) int {
if a < b {
return a
}
return b
}
8 changes: 4 additions & 4 deletions util/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ func testEncodingDecoding(t *testing.T, g kyber.Group, ptmp kyber.Point, stmp ky
buf.Reset()
s := g.Scalar().Pick(rand)
if _, err := s.MarshalTo(buf); err != nil {
t.Errorf("encoding of secret fails: " + err.Error())
t.Errorf("encoding of secret fails: %s", err.Error())
}
if _, err := stmp.UnmarshalFrom(buf); err != nil {
t.Errorf("decoding of secret fails: " + err.Error())
t.Errorf("decoding of secret fails: %s", err.Error())
}
if !stmp.Equal(s) {
t.Errorf("decoding produces different secret than encoded")
Expand All @@ -309,10 +309,10 @@ func testEncodingDecoding(t *testing.T, g kyber.Group, ptmp kyber.Point, stmp ky
buf.Reset()
p := g.Point().Pick(rand)
if _, err := p.MarshalTo(buf); err != nil {
t.Errorf("encoding of point fails: " + err.Error())
t.Errorf("encoding of point fails: %s", err.Error())
}
if _, err := ptmp.UnmarshalFrom(buf); err != nil {
t.Errorf("decoding of point fails: " + err.Error())
t.Errorf("decoding of point fails: %s", err.Error())
}
if !ptmp.Equal(p) {
t.Errorf("decoding produces different point than encoded")
Expand Down

0 comments on commit 89decc8

Please sign in to comment.