diff --git a/ecc/bls12-377/shplonk/marshal.go b/ecc/bls12-377/shplonk/marshal.go index 9e03a86d0..c2b805a8b 100644 --- a/ecc/bls12-377/shplonk/marshal.go +++ b/ecc/bls12-377/shplonk/marshal.go @@ -29,7 +29,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/ecc/bls12-377/shplonk/shplonk_test.go b/ecc/bls12-377/shplonk/shplonk_test.go index 602ee3f9d..933349955 100644 --- a/ecc/bls12-377/shplonk/shplonk_test.go +++ b/ecc/bls12-377/shplonk/shplonk_test.go @@ -23,8 +23,10 @@ import ( "testing" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bls12-377" "github.com/consensys/gnark-crypto/ecc/bls12-377/fr" "github.com/consensys/gnark-crypto/ecc/bls12-377/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -45,6 +47,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := bls12377.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t) diff --git a/ecc/bls12-378/shplonk/marshal.go b/ecc/bls12-378/shplonk/marshal.go index 6774448de..bbe0b8d9e 100644 --- a/ecc/bls12-378/shplonk/marshal.go +++ b/ecc/bls12-378/shplonk/marshal.go @@ -29,7 +29,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/ecc/bls12-378/shplonk/shplonk_test.go b/ecc/bls12-378/shplonk/shplonk_test.go index 34e4127cc..4b73e50e4 100644 --- a/ecc/bls12-378/shplonk/shplonk_test.go +++ b/ecc/bls12-378/shplonk/shplonk_test.go @@ -23,8 +23,10 @@ import ( "testing" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bls12-378" "github.com/consensys/gnark-crypto/ecc/bls12-378/fr" "github.com/consensys/gnark-crypto/ecc/bls12-378/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -45,6 +47,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := bls12378.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t) diff --git a/ecc/bls12-381/shplonk/marshal.go b/ecc/bls12-381/shplonk/marshal.go index b609b7326..e013c2d3e 100644 --- a/ecc/bls12-381/shplonk/marshal.go +++ b/ecc/bls12-381/shplonk/marshal.go @@ -29,7 +29,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/ecc/bls12-381/shplonk/shplonk_test.go b/ecc/bls12-381/shplonk/shplonk_test.go index 05fb93a3f..b007b7559 100644 --- a/ecc/bls12-381/shplonk/shplonk_test.go +++ b/ecc/bls12-381/shplonk/shplonk_test.go @@ -23,8 +23,10 @@ import ( "testing" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bls12-381" "github.com/consensys/gnark-crypto/ecc/bls12-381/fr" "github.com/consensys/gnark-crypto/ecc/bls12-381/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -45,6 +47,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := bls12381.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t) diff --git a/ecc/bls24-315/shplonk/marshal.go b/ecc/bls24-315/shplonk/marshal.go index a57a90679..a936f40bb 100644 --- a/ecc/bls24-315/shplonk/marshal.go +++ b/ecc/bls24-315/shplonk/marshal.go @@ -29,7 +29,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/ecc/bls24-315/shplonk/shplonk_test.go b/ecc/bls24-315/shplonk/shplonk_test.go index a8d35f5c0..c97b6dda8 100644 --- a/ecc/bls24-315/shplonk/shplonk_test.go +++ b/ecc/bls24-315/shplonk/shplonk_test.go @@ -23,8 +23,10 @@ import ( "testing" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bls24-315" "github.com/consensys/gnark-crypto/ecc/bls24-315/fr" "github.com/consensys/gnark-crypto/ecc/bls24-315/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -45,6 +47,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := bls24315.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t) diff --git a/ecc/bls24-317/shplonk/marshal.go b/ecc/bls24-317/shplonk/marshal.go index b69c0946c..f3f4520ac 100644 --- a/ecc/bls24-317/shplonk/marshal.go +++ b/ecc/bls24-317/shplonk/marshal.go @@ -29,7 +29,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/ecc/bls24-317/shplonk/shplonk_test.go b/ecc/bls24-317/shplonk/shplonk_test.go index 9e6d76ded..bd89089b7 100644 --- a/ecc/bls24-317/shplonk/shplonk_test.go +++ b/ecc/bls24-317/shplonk/shplonk_test.go @@ -23,8 +23,10 @@ import ( "testing" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bls24-317" "github.com/consensys/gnark-crypto/ecc/bls24-317/fr" "github.com/consensys/gnark-crypto/ecc/bls24-317/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -45,6 +47,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := bls24317.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t) diff --git a/ecc/bn254/shplonk/marshal.go b/ecc/bn254/shplonk/marshal.go index 050e1d6fd..5da8c732a 100644 --- a/ecc/bn254/shplonk/marshal.go +++ b/ecc/bn254/shplonk/marshal.go @@ -29,7 +29,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/ecc/bn254/shplonk/shplonk_test.go b/ecc/bn254/shplonk/shplonk_test.go index d0e4ce069..88fa11fc0 100644 --- a/ecc/bn254/shplonk/shplonk_test.go +++ b/ecc/bn254/shplonk/shplonk_test.go @@ -23,8 +23,10 @@ import ( "testing" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bn254" "github.com/consensys/gnark-crypto/ecc/bn254/fr" "github.com/consensys/gnark-crypto/ecc/bn254/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -45,6 +47,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := bn254.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t) diff --git a/ecc/bw6-633/shplonk/marshal.go b/ecc/bw6-633/shplonk/marshal.go index 2c44c28a6..80661c53d 100644 --- a/ecc/bw6-633/shplonk/marshal.go +++ b/ecc/bw6-633/shplonk/marshal.go @@ -29,7 +29,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/ecc/bw6-633/shplonk/shplonk_test.go b/ecc/bw6-633/shplonk/shplonk_test.go index ea171cbef..dcb46ffee 100644 --- a/ecc/bw6-633/shplonk/shplonk_test.go +++ b/ecc/bw6-633/shplonk/shplonk_test.go @@ -23,8 +23,10 @@ import ( "testing" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bw6-633" "github.com/consensys/gnark-crypto/ecc/bw6-633/fr" "github.com/consensys/gnark-crypto/ecc/bw6-633/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -45,6 +47,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := bw6633.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t) diff --git a/ecc/bw6-756/shplonk/marshal.go b/ecc/bw6-756/shplonk/marshal.go index e7b0bf4ed..8977a5725 100644 --- a/ecc/bw6-756/shplonk/marshal.go +++ b/ecc/bw6-756/shplonk/marshal.go @@ -29,7 +29,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/ecc/bw6-756/shplonk/shplonk_test.go b/ecc/bw6-756/shplonk/shplonk_test.go index 4643d8760..ce1c48046 100644 --- a/ecc/bw6-756/shplonk/shplonk_test.go +++ b/ecc/bw6-756/shplonk/shplonk_test.go @@ -23,8 +23,10 @@ import ( "testing" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bw6-756" "github.com/consensys/gnark-crypto/ecc/bw6-756/fr" "github.com/consensys/gnark-crypto/ecc/bw6-756/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -45,6 +47,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := bw6756.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t) diff --git a/ecc/bw6-761/shplonk/marshal.go b/ecc/bw6-761/shplonk/marshal.go index f931b1dd5..6e03808ee 100644 --- a/ecc/bw6-761/shplonk/marshal.go +++ b/ecc/bw6-761/shplonk/marshal.go @@ -29,7 +29,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/ecc/bw6-761/shplonk/shplonk_test.go b/ecc/bw6-761/shplonk/shplonk_test.go index ca08b62e5..1e4ecc2d8 100644 --- a/ecc/bw6-761/shplonk/shplonk_test.go +++ b/ecc/bw6-761/shplonk/shplonk_test.go @@ -23,8 +23,10 @@ import ( "testing" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/bw6-761" "github.com/consensys/gnark-crypto/ecc/bw6-761/fr" "github.com/consensys/gnark-crypto/ecc/bw6-761/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -45,6 +47,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := bw6761.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t) diff --git a/internal/generator/shplonk/template/marshal.go.tmpl b/internal/generator/shplonk/template/marshal.go.tmpl index 316f852ef..98f11f61a 100644 --- a/internal/generator/shplonk/template/marshal.go.tmpl +++ b/internal/generator/shplonk/template/marshal.go.tmpl @@ -11,7 +11,7 @@ func (proof *OpeningProof) ReadFrom(r io.Reader) (int64, error) { toDecode := []interface{}{ &proof.W, &proof.WPrime, - proof.ClaimedValues, + &proof.ClaimedValues, } for _, v := range toDecode { diff --git a/internal/generator/shplonk/template/shplonk.test.go.tmpl b/internal/generator/shplonk/template/shplonk.test.go.tmpl index 7d642ed8f..775995c03 100644 --- a/internal/generator/shplonk/template/shplonk.test.go.tmpl +++ b/internal/generator/shplonk/template/shplonk.test.go.tmpl @@ -5,8 +5,10 @@ import ( "math/rand" "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark-crypto/ecc/{{ .Name }}" "github.com/consensys/gnark-crypto/ecc/{{ .Name }}/fr" "github.com/consensys/gnark-crypto/ecc/{{ .Name }}/kzg" + "github.com/consensys/gnark-crypto/utils/testutils" "github.com/stretchr/testify/require" ) @@ -28,6 +30,24 @@ func init() { } } +func TestSerialization(t *testing.T) { + + _, _, g, _ := {{ .CurvePackage }}.Generators() + var proof OpeningProof + proof.W.Set(&g) + proof.WPrime.Set(&g) + nbClaimedValues := 10 + proof.ClaimedValues = make([][]fr.Element, nbClaimedValues) + for i := 0; i < nbClaimedValues; i++ { + proof.ClaimedValues[i] = make([]fr.Element, i+2) + for j := 0; j < i+2; j++ { + proof.ClaimedValues[i][j].SetRandom() + } + } + + t.Run("opening proof round trip", testutils.SerializationRoundTrip(&proof)) +} + func TestOpening(t *testing.T) { assert := require.New(t)