Skip to content

Commit

Permalink
chore!: update minimum golang version (#58)
Browse files Browse the repository at this point in the history
* update readme about MSGV

* update to 1.20

* fix deprecated method

* remove deprecated rand.Read method

* run: `gofumpt -w .`

* update CI to run against minimum, current and latest

* update readme
  • Loading branch information
kevaundray authored Oct 9, 2023
1 parent 1f338ec commit 2536295
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- macos-latest
- windows-latest
go-version:
- 1.18.x
- 1.19.x
- 1.20.x
- 1.18.x # Minimmum version
- 1.20.x # Current version
- 1.21.x # Latest version

steps:
- uses: actions/checkout@v3
Expand Down
27 changes: 17 additions & 10 deletions bench_test.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
package gokzg4844_test

import (
"bytes"
"crypto/sha256"
"encoding/binary"
"fmt"
// We do not require crypto/rand in tests
"math/rand"
"log"
"testing"

"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
gokzg4844 "github.com/crate-crypto/go-kzg-4844"
"github.com/stretchr/testify/require"
)

// / Returns a serialized random field element in big-endian
func GetRandFieldElement(seed int64) [32]byte {
rand.Seed(seed)

bytes := make([]byte, 32)
_, err := rand.Read(bytes)
func deterministicRandomness(seed int64) [32]byte {
// Converts an int64 to a byte slice
buf := new(bytes.Buffer)
err := binary.Write(buf, binary.BigEndian, seed)
if err != nil {
panic("failed to get random field element")
log.Fatalf("Failed to write int64 to bytes buffer: %v", err)
}
bytes := buf.Bytes()

return sha256.Sum256(bytes)
}

// Returns a serialized random field element in big-endian
func GetRandFieldElement(seed int64) [32]byte {
bytes := deterministicRandomness(seed)
var r fr.Element
r.SetBytes(bytes)
r.SetBytes(bytes[:])

return gokzg4844.SerializeScalar(r)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/crate-crypto/go-kzg-4844

go 1.18
go 1.20

require (
github.com/consensys/gnark-crypto v0.10.0
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ to only panic on startup; only methods which are called when we create the

## Minimum Supported Golang Version

Because we use generics, the minimum golang version is 1.18, which seems to be
fairly conservative. However, if a lower version is needed, replacing the
generics is fairly straightforward.
Because we use generics, the minimum golang version needs to be 1.18 or above. Since Golang only back ports security fixes to the latest version and one version behind latest, this library will at most be one version behind latest.

Tests are ran against the 1.18, the current version and the latest version. If support for 1.18 is broken, we will update the CI to reflect this with a given reason.

## License

Expand Down

0 comments on commit 2536295

Please sign in to comment.