Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: api.Select does not enforce condition to be bool on PlonK frontend #1246

Closed
gbotrel opened this issue Aug 13, 2024 · 0 comments
Closed

Comments

@gbotrel
Copy link
Collaborator

gbotrel commented Aug 13, 2024

Following test fails:

// Circuit definition
// here we aim to catch the case where the API doesn't enforce the condition to be a boolean
type notBoolCond struct {
	Condition, Y1, Y2 frontend.Variable
}

func (circuit *notBoolCond) Define(api frontend.API) error {
	d := api.Select(circuit.Condition, circuit.Y1, circuit.Y2)

	// per api definition, d should hold either Y1 or Y2.
	// we have y1 = 2, y2 = 4, condition = 2 (non boolean)
	// r = condition(y1-y2) + y2
	api.AssertIsEqual(d, 0)

	return nil
}

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

	assert.CheckCircuit(&notBoolCond{},
		test.WithInvalidAssignment(&notBoolCond{
			Condition: 2,
			Y1:        2,
			Y2:        4,
		}),
	)
}

Thanks to Least Authority for the report --

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant