Skip to content

Commit

Permalink
test: add regression test for zero mul duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokub committed Mar 5, 2024
1 parent e2072ae commit 742120e
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions frontend/cs/scs/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,43 @@ func TestExistDiv0(t *testing.T) {
Res7: 0, Res8: 55,
}, ecc.BN254.ScalarField())
assert.NoError(err)
solution, err := ccs.Solve(w)
_, err = ccs.Solve(w)
assert.NoError(err)
}

type IssueDiv0Circuit2 struct {
A1, B1 frontend.Variable

Res1, Res2 frontend.Variable
}

func (c *IssueDiv0Circuit2) Define(api frontend.API) error {
// case 1
b1 := api.Mul(0, c.A1)
b2 := api.Mul(4, c.B1)
t1 := api.Mul(b1, b2)

b3 := api.Mul(2, c.A1)
b4 := api.Mul(5, c.B1)
t2 := api.Mul(b3, b4)

// test solver
api.AssertIsEqual(t1, c.Res1)
api.AssertIsEqual(t2, c.Res2)
return nil
}

func TestExistDiv02(t *testing.T) {
assert := test.NewAssert(t)
ccs, err := frontend.Compile(ecc.BN254.ScalarField(), scs.NewBuilder, &IssueDiv0Circuit2{})
assert.NoError(err)
w, err := frontend.NewWitness(&IssueDiv0Circuit2{
A1: 11, B1: 21,
Res1: 0, Res2: 2310,
}, ecc.BN254.ScalarField())
assert.NoError(err)
_, err = ccs.Solve(w)
assert.NoError(err)
_ = solution
}

type mulAccFastTrackCircuit struct {
Expand Down

0 comments on commit 742120e

Please sign in to comment.