github.com/consensys/gnark@v0.11.0/backend/groth16/bn254/mpcsetup/marshal_test.go (about) 1 // Copyright 2020 ConsenSys Software Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Code generated by gnark DO NOT EDIT 16 17 package mpcsetup 18 19 import ( 20 "testing" 21 22 curve "github.com/consensys/gnark-crypto/ecc/bn254" 23 cs "github.com/consensys/gnark/constraint/bn254" 24 "github.com/consensys/gnark/frontend" 25 "github.com/consensys/gnark/frontend/cs/r1cs" 26 gnarkio "github.com/consensys/gnark/io" 27 "github.com/stretchr/testify/require" 28 ) 29 30 func TestContributionSerialization(t *testing.T) { 31 if testing.Short() { 32 t.Skip("skipping test in short mode.") 33 } 34 assert := require.New(t) 35 36 // Phase 1 37 srs1 := InitPhase1(9) 38 srs1.Contribute() 39 40 assert.NoError(gnarkio.RoundTripCheck(&srs1, func() interface{} { return new(Phase1) })) 41 42 var myCircuit Circuit 43 ccs, err := frontend.Compile(curve.ID.ScalarField(), r1cs.NewBuilder, &myCircuit) 44 assert.NoError(err) 45 46 r1cs := ccs.(*cs.R1CS) 47 48 // Phase 2 49 srs2, _ := InitPhase2(r1cs, &srs1) 50 srs2.Contribute() 51 52 assert.NoError(gnarkio.RoundTripCheck(&srs2, func() interface{} { return new(Phase2) })) 53 }