Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/gofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Go Fix Check
on:
pull_request:
push:
branches: [main]

jobs:
gofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Download Go modules
run: go mod download

- name: Check for go fix suggestions
run: |
OUTPUT=$(go fix -diff ./... 2>&1)
if [ -n "$OUTPUT" ]; then
echo "::error::go fix found modernization opportunities"
echo ""
echo "$OUTPUT"
echo ""
echo "Run 'go fix ./...' locally and commit the changes."
exit 1
fi
echo "✓ No go fix suggestions - code is up to date."
2 changes: 1 addition & 1 deletion driver/gurvy/bls12381/bipool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
var bigIntPool biPool

var _bigIntPool = sync.Pool{
New: func() interface{} {
New: func() any {
return new(big.Int)
},
}
Expand Down
5 changes: 1 addition & 4 deletions driver/gurvy/bls12381/bls12-381.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,10 +911,7 @@ func JointScalarMultiplication(p *bls12381.G1Jac, a1, a2 *bls12381.G1Affine, s1,
s[0] = s[0].SetBigInt(&k1).Bits()
s[1] = s[1].SetBigInt(&k2).Bits()

maxBit := k1.BitLen()
if k2.BitLen() > maxBit {
maxBit = k2.BitLen()
}
maxBit := max(k2.BitLen(), k1.BitLen())
hiWordIndex := (maxBit - 1) / 64

for i := hiWordIndex; i >= 0; i-- {
Expand Down
2 changes: 1 addition & 1 deletion driver/gurvy/bls12381/g1pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
var G1Jacs g1JacPool

var _g1JacPool = sync.Pool{
New: func() interface{} {
New: func() any {
return new(bls12381.G1Jac)
},
}
Expand Down
8 changes: 0 additions & 8 deletions driver/gurvy/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ func toGurvyAffine(p *G1Affine) *bls12381.G1Affine {
return (*bls12381.G1Affine)(unsafe.Pointer(p))
}

func min(a, b int) int {
if a < b {
return a
}

return b
}

// ExpandMsgXmd expands msg to a slice of lenInBytes bytes.
// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06#section-5
// https://tools.ietf.org/html/rfc8017#section-4.1 (I2OSP/O2ISP)
Expand Down
5 changes: 1 addition & 4 deletions driver/kilic/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ var swuParamsForG1 = struct {
}

func (fe *Fe) setBytes(in []byte) *Fe {
l := len(in)
if l >= fpByteSize {
l = fpByteSize
}
l := min(len(in), fpByteSize)
padded := make([]byte, fpByteSize)
copy(padded[fpByteSize-l:], in[:])
var a int
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/IBM/mathlib

go 1.25.7
go 1.26.3

require (
github.com/consensys/gnark-crypto v0.20.1
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2
github.com/stretchr/testify v1.11.1
golang.org/x/crypto v0.49.0
golang.org/x/crypto v0.52.0
)

require (
Expand All @@ -16,6 +16,6 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
golang.org/x/sys v0.42.0
golang.org/x/sys v0.45.0
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
Loading