github.com/consensys/gnark@v0.11.0/internal/generator/backend/template/zkpschemes/groth16/mpcsetup/marshal_test.go.tmpl (about) 1 import ( 2 "testing" 3 4 gnarkio "github.com/consensys/gnark/io" 5 6 {{- template "import_curve" . }} 7 {{- template "import_backend_cs" . }} 8 "github.com/consensys/gnark/frontend" 9 "github.com/consensys/gnark/frontend/cs/r1cs" 10 "github.com/stretchr/testify/require" 11 ) 12 13 func TestContributionSerialization(t *testing.T) { 14 if testing.Short() { 15 t.Skip("skipping test in short mode.") 16 } 17 assert := require.New(t) 18 19 // Phase 1 20 srs1 := InitPhase1(9) 21 srs1.Contribute() 22 23 assert.NoError(gnarkio.RoundTripCheck(&srs1, func() interface{} { return new(Phase1) })) 24 25 var myCircuit Circuit 26 ccs, err := frontend.Compile(curve.ID.ScalarField(), r1cs.NewBuilder, &myCircuit) 27 assert.NoError(err) 28 29 r1cs := ccs.(*cs.R1CS) 30 31 // Phase 2 32 srs2, _ := InitPhase2(r1cs, &srs1) 33 srs2.Contribute() 34 35 assert.NoError(gnarkio.RoundTripCheck(&srs2, func() interface{} { return new(Phase2) })) 36 } 37