gnark icon indicating copy to clipboard operation
gnark copied to clipboard

Test fails without unnecessary dummy constraint for PlonkFRI backend

Open tiagofneto opened this issue 2 years ago • 3 comments

Description

I encountered a bug where a seemingly unnecessary dummy constraint (e.g., a == a) must be added for my circuit test to pass when using the PlonkFRI backend, even though the constraint is always true and should not affect the test result. If I do not include this constraint, the test fails. However, this issue does not occur when using other backends such as PLONK and Groth16.

Code Example

Here's a code snippet that demonstrates the issue. Uncommenting the commented line is required for the test to pass:

type testCircuitBasic struct {
    A frontend.Variable
    B frontend.Variable
    Expected frontend.Variable
}

func (circuit *testCircuitBasic) Define(api frontend.API) error {
    mulRes := api.Mul(circuit.A, circuit.B)
    api.AssertIsEqual(mulRes, circuit.Expected)

    // Uncomment the following line to make the test pass
    // api.AssertIsEqual(circuit.A, circuit.A)

    return nil
}

func TestMainBasic(t *testing.T) {
    assert := test.NewAssert(t)

    var circuit testCircuitBasic

    assert.ProverSucceeded(&circuit, &testCircuitBasic{
        A: "42",
        B: "24",
        Expected: "1008",
    }, test.WithCurves(ecc.BN254))
}

Output

Running this test will result in the following error:

Error:          plonkFRI(bn254): one round of interaction failed
                                witness:{"A":42,"B":24,"Expected":1008}
Test:           TestMainBasic/bn254/plonkFRI

Uncommenting the commented line makes the test pass as expected.

tiagofneto avatar May 08 '23 09:05 tiagofneto

Just as a remark - I also encountered the same bug very recently. I checked very briefly and seems that this bug is propagated from gnark-crypto, but have to debug more closely.

Setting low priority as PLONK+FRI is very experimental right now. Are you particularly interested in PLONK+FRI?

ivokub avatar May 09 '23 00:05 ivokub

I'm not particularly interested in PLONK+FRI, it's just that the tester by default will iterate through the various backends and will fail (because of PLONK+FRI), meaning that I have to specify some backend when testing now.

tiagofneto avatar May 09 '23 06:05 tiagofneto

I'm not particularly interested in PLONK+FRI, it's just that the tester by default will iterate through the various backends and will fail (because of PLONK+FRI), meaning that I have to specify some backend when testing now.

The option for setting backends in testing accepts multiple backends. But I agree, it is definitely nuisance. Will propose to the team omitting PLONK+FRI as one of the default backends to test against.

ivokub avatar May 17 '23 13:05 ivokub

We have omitted PLONK+FRI backend by default: #1075

ivokub avatar Apr 05 '24 09:04 ivokub