func IsSolved(r1cs frontend.CompiledConstraintSystem, witness frontend.Circuit, opts ...func(opt *backend.ProverOption) error) error {
	opt, err := backend.NewProverOption(opts...)
	if err != nil {
		return err
	}
	switch _r1cs := r1cs.(type) {
	case *backend_bls12377.R1CS:
		w := witness_bls12377.Witness{}
		if err := w.FromFullAssignment(witness); err != nil {
			return err
		}
		return _r1cs.IsSolved(w, opt)
	case *backend_bls12381.R1CS:
		w := witness_bls12381.Witness{}
		if err := w.FromFullAssignment(witness); err != nil {
			return err
		}
		return _r1cs.IsSolved(w, opt)
	case *backend_bn254.R1CS:
		w := witness_bn254.Witness{}
		if err := w.FromFullAssignment(witness); err != nil {
			return err
		}
		return _r1cs.IsSolved(w, opt)
	case *backend_bw6761.R1CS:
		w := witness_bw6761.Witness{}
		if err := w.FromFullAssignment(witness); err != nil {
			return err
		}
		return _r1cs.IsSolved(w, opt)
	case *backend_bls24315.R1CS:
		w := witness_bls24315.Witness{}
		if err := w.FromFullAssignment(witness); err != nil {
			return err
		}
		return _r1cs.IsSolved(w, opt)
	default:
		panic("unrecognized R1CS curve type")
	}
}
IsSolved attempts to solve the constraint system with provided witness
returns nil if it succeeds, error otherwise.
package groth16
import (
	"bytes"
	"io"
	"reflect"
	"testing"
	"github.com/consensys/gnark/backend"
	"github.com/consensys/gnark/frontend"
	backend_bls12377 "github.com/consensys/gnark/internal/backend/bls12-377/cs"
	witness_bls12377 "github.com/consensys/gnark/internal/backend/bls12-377/witness"
	backend_bls12381 "github.com/consensys/gnark/internal/backend/bls12-381/cs"
	witness_bls12381 "github.com/consensys/gnark/internal/backend/bls12-381/witness"
	backend_bls24315 "github.com/consensys/gnark/internal/backend/bls24-315/cs"
	witness_bls24315 "github.com/consensys/gnark/internal/backend/bls24-315/witness"
	backend_bn254 "github.com/consensys/gnark/internal/backend/bn254/cs"
	witness_bn254 "github.com/consensys/gnark/internal/backend/bn254/witness"
	backend_bw6761 "github.com/consensys/gnark/internal/backend/bw6-761/cs"
	witness_bw6761 "github.com/consensys/gnark/internal/backend/bw6-761/witness"
	gnarkio "github.com/consensys/gnark/io"
	"github.com/stretchr/testify/require"
)
type Assert struct {
	*require.Assertions
}
func NewAssert(t *testing.T) *Assert {
	return &Assert{require.New(t)}
}
func (assert *Assert) ProverFailed(r1cs frontend.CompiledConstraintSystem, witness frontend.Circuit, opts ...func(opt *backend.ProverOption) error) {
	pk, err := DummySetup(r1cs)
	assert.NoError(err)
	_, err = Prove(r1cs, pk, witness, opts...)
	assert.Error(err, "proving with bad witness should output an error")
}
func (assert *Assert) ProverSucceeded(r1cs frontend.CompiledConstraintSystem, witness frontend.Circuit, opts ...func(opt *backend.ProverOption) error) {
	pk, vk, err := Setup(r1cs)
	assert.NoError(err)
	{
		pk2, vk2, err := Setup(r1cs)
		assert.NoError(err)
		assert.True(pk2.IsDifferent(pk), "groth16 setup with same witness should produce different outputs ")
		assert.True(vk2.IsDifferent(vk), "groth16 setup with same witness should produce different outputs ")
	}
	assert.SolvingSucceeded(r1cs, witness, opts...)
	proof, err := Prove(r1cs, pk, witness, opts...)
	assert.NoError(err, "proving with good witness should not output an error")
	{
		proof2, err := Prove(r1cs, pk, witness, opts...)
		assert.NoError(err, "proving with good witness should not output an error")
		assert.False(reflect.DeepEqual(proof, proof2), "calling prove twice with same input should produce different proof")
	}
	{
		err := Verify(proof, vk, witness)
		assert.NoError(err, "verifying proof with good witness should not output an error")
	}
}
func (assert *Assert) SerializationSucceeded(from io.WriterTo, to io.ReaderFrom) {
	var buf bytes.Buffer
	written, err := from.WriteTo(&buf)
	assert.NoError(err, "serializing to buffer failed")
	read, err := to.ReadFrom(&buf)
	assert.NoError(err, "desererializing from buffer failed")
	assert.EqualValues(written, read, "number of bytes read and written don't match")
}
func (assert *Assert) SerializationRawSucceeded(from gnarkio.WriterRawTo, to io.ReaderFrom) {
	var buf bytes.Buffer
	written, err := from.WriteRawTo(&buf)
	assert.NoError(err, "serializing raw to buffer failed")
	read, err := to.ReadFrom(&buf)
	assert.NoError(err, "desererializing raw from buffer failed")
	assert.EqualValues(written, read, "number of bytes read and written don't match")
}
func (assert *Assert) SolvingSucceeded(r1cs frontend.CompiledConstraintSystem, witness frontend.Circuit, opts ...func(opt *backend.ProverOption) error) {
	assert.NoError(IsSolved(r1cs, witness, opts...))
}
func (assert *Assert) SolvingFailed(r1cs frontend.CompiledConstraintSystem, witness frontend.Circuit, opts ...func(opt *backend.ProverOption) error) {
	assert.Error(IsSolved(r1cs, witness, opts...))
}