From ed65d3c0ef2cc0ae76b9f74afd5eedafd986b58f Mon Sep 17 00:00:00 2001 From: Jean Date: Wed, 14 Jan 2026 09:30:27 +0100 Subject: [PATCH 1/6] add Scalar encoding/decoding --- encoding_test.go | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/encoding_test.go b/encoding_test.go index a65b2e4..4dcf1c0 100644 --- a/encoding_test.go +++ b/encoding_test.go @@ -227,7 +227,7 @@ func TestArrayKey(t *testing.T) { assert.False(t, t1.M[k3]) } -func TestInterface(t *testing.T) { +func TestPointInterface(t *testing.T) { type Points struct { P1 kyber.Point P2 kyber.Point @@ -254,6 +254,35 @@ func TestInterface(t *testing.T) { require.Equal(t, pp.P2.String(), dpp.P2.String()) } +func TestScalarInterface(t *testing.T) { + ed25519 := suites.MustFind("ed25519") + + RegisterInterface(func() interface{} { return ed25519.Scalar() }) + // RegisterInterface(func() interface{} { return ed25519.ScalarLen() }) + + type BasicSig struct { + C kyber.Scalar + R kyber.Scalar + } + + pseudoRand := ed25519.XOF([]byte("test scalar interface")) + + sig := BasicSig{ + C: ed25519.Scalar().Pick(pseudoRand), + R: ed25519.Scalar().Pick(pseudoRand), + } + + buf, err := Encode(&sig) + require.NoError(t, err) + + var dsig BasicSig + err = Decode(buf, &dsig) + require.NoError(t, err) + + require.Equal(t, sig.C.String(), dsig.C.String()) + require.Equal(t, sig.R.String(), dsig.R.String()) +} + type dummyInterface interface { String() string encoding.BinaryUnmarshaler From 01be173db252d2523b5b5a327686b4b4bba597a3 Mon Sep 17 00:00:00 2001 From: Jean Date: Wed, 14 Jan 2026 09:53:26 +0100 Subject: [PATCH 2/6] add github action --- .github/workflows/tests.yml | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b183fed --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,69 @@ +name: Go Tests + +on: + pull_request: + push: + branches: + - master + +concurrency: + group: ci-${{ github.ref }}-test + cancel-in-progress: true + +jobs: + test: + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + size: ['64b', '32b'] + golang: ['1.13.15', '1.25.4'] + exclude: + - os: windows-latest + size: '32b' + - os: macos-latest + size: '32b' + + runs-on: ${{ matrix.os }} + env: + DBGSYNCLOG: trace + DBGSYNCON: true + + steps: + - name: Set up Go ${{ matrix.golang }} + uses: actions/setup-go@v6 + if: ${{ matrix.size == '64b' }} + with: + go-version: ${{ matrix.golang }} + check-latest: false + + - name: Check out code into the Go module directory + uses: actions/checkout@v5 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Setup Alpine Linux + uses: jirutka/setup-alpine@v1 + if: ${{ matrix.size == '32b' }} + with: + arch: x86 + packages: > + make + git + gcc + musl-dev + + - name: Test without coverage (Windows, MacOS) + if: ${{ matrix.os == 'macos-latest' || matrix.os == 'windows-latest' }} + run: make test + + - name: Test without coverage (Ubuntu x86) + if: ${{ matrix.size == '32b' }} + run: | + cd .. + wget -O go.tgz -nv https://go.dev/dl/go${{matrix.golang}}.linux-386.tar.gz + tar -xzf go.tgz + export PATH=$PATH:$(pwd)/go/bin + cd kyber + make test + shell: alpine.sh {0} From 2cc703175d861cf5ffecd68cc13a0835b4a595d2 Mon Sep 17 00:00:00 2001 From: Jean Date: Wed, 14 Jan 2026 10:00:55 +0100 Subject: [PATCH 3/6] fix github action tests --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b183fed..b76a762 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -64,6 +64,6 @@ jobs: wget -O go.tgz -nv https://go.dev/dl/go${{matrix.golang}}.linux-386.tar.gz tar -xzf go.tgz export PATH=$PATH:$(pwd)/go/bin - cd kyber + cd protobuf make test shell: alpine.sh {0} From 99d2e156c95eb5f6e21cdbd56837c2b494d37ec1 Mon Sep 17 00:00:00 2001 From: Jean Date: Wed, 14 Jan 2026 10:05:11 +0100 Subject: [PATCH 4/6] remove macos tests --- .github/workflows/tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b76a762..728479c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,14 +14,12 @@ jobs: test: strategy: matrix: - os: [windows-latest, ubuntu-latest, macos-latest] + os: [ubuntu-latest, windows-latest] size: ['64b', '32b'] golang: ['1.13.15', '1.25.4'] exclude: - os: windows-latest size: '32b' - - os: macos-latest - size: '32b' runs-on: ${{ matrix.os }} env: From 40f2f86682bb35040d98d5a490bcb84ff62c79f5 Mon Sep 17 00:00:00 2001 From: Jean Date: Wed, 14 Jan 2026 10:44:25 +0100 Subject: [PATCH 5/6] add missing Makefile --- .gitignore | 4 ++-- Makefile | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index d45bb56..4b514c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -*~ protobuf-fuzz.zip -workdir \ No newline at end of file +workdir +.idea/** diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..59dc857 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +tidy: + go mod tidy + +# Coding style static check. +lint: tidy + # keep this in sync with .github/workflows/golangci-lint.yml + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.1 + go mod tidy + golangci-lint run + +test: tidy + go test ./... + +# target to run all the possible checks; it's a good habit to run it before +# pushing code +check: lint test + echo "check done" From 0ec7fae5fdcfcc83d4540d293fc7b577362a86c5 Mon Sep 17 00:00:00 2001 From: Jean Date: Wed, 14 Jan 2026 11:04:28 +0100 Subject: [PATCH 6/6] github actions for 64b and 32b --- .github/workflows/tests.yml | 59 ++++++++++--------------------------- Makefile | 3 +- array_test.go | 3 +- go.sum | 1 - 4 files changed, 20 insertions(+), 46 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 728479c..7f26a2c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,11 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - size: ['64b', '32b'] - golang: ['1.13.15', '1.25.4'] - exclude: - - os: windows-latest - size: '32b' + golang: ['1.13.15', '1.25.5'] runs-on: ${{ matrix.os }} env: @@ -27,41 +23,18 @@ jobs: DBGSYNCON: true steps: - - name: Set up Go ${{ matrix.golang }} - uses: actions/setup-go@v6 - if: ${{ matrix.size == '64b' }} - with: - go-version: ${{ matrix.golang }} - check-latest: false - - - name: Check out code into the Go module directory - uses: actions/checkout@v5 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - - - name: Setup Alpine Linux - uses: jirutka/setup-alpine@v1 - if: ${{ matrix.size == '32b' }} - with: - arch: x86 - packages: > - make - git - gcc - musl-dev - - - name: Test without coverage (Windows, MacOS) - if: ${{ matrix.os == 'macos-latest' || matrix.os == 'windows-latest' }} - run: make test - - - name: Test without coverage (Ubuntu x86) - if: ${{ matrix.size == '32b' }} - run: | - cd .. - wget -O go.tgz -nv https://go.dev/dl/go${{matrix.golang}}.linux-386.tar.gz - tar -xzf go.tgz - export PATH=$PATH:$(pwd)/go/bin - cd protobuf - make test - shell: alpine.sh {0} + - name: Check out code into the Go module directory + uses: actions/checkout@v5 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Set up Go ${{ matrix.golang }} + uses: actions/setup-go@v6 + with: + go-version: ${{ matrix.golang }} + check-latest: false + + - name: Run tests + run: | + make test diff --git a/Makefile b/Makefile index 59dc857..8a20a91 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,8 @@ lint: tidy golangci-lint run test: tidy - go test ./... + export GOARCH='amd64' && go test ./... + export GOARCH='386' && go test ./... # target to run all the possible checks; it's a good habit to run it before # pushing code diff --git a/array_test.go b/array_test.go index d57c62f..9d69115 100644 --- a/array_test.go +++ b/array_test.go @@ -2,6 +2,7 @@ package protobuf import ( "encoding/hex" + "math" "reflect" "testing" @@ -26,7 +27,7 @@ type ArrayTest3 struct { func TestArray(t *testing.T) { // largest int32 is 2147483647 - var large int = 3147483647 + var large int = math.MaxInt32 - 1 a0 := ArrayTest0{[]int{1, 1, large}} a1 := ArrayTest1{[]int64{1, 1, 1}} diff --git a/go.sum b/go.sum index ccb5242..d283601 100644 --- a/go.sum +++ b/go.sum @@ -7,7 +7,6 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs= go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw= -go.dedis.ch/kyber/v3 v3.0.4 h1:FDuC/S3STkvwxZ0ooo3gcp56QkUKsN7Jy7cpzBxL+vQ= go.dedis.ch/kyber/v3 v3.0.4/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= go.dedis.ch/kyber/v3 v3.0.9 h1:i0ZbOQocHUjfFasBiUql5zVeC7u/vahFd96DFA8UOWk= go.dedis.ch/kyber/v3 v3.0.9/go.mod h1:rhNjUUg6ahf8HEg5HUvVBYoWY4boAafX8tYxX+PS+qg=