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.AssertIsLessOrEqual incorrect behavior on R1CS with constant variable #1227

Closed
gbotrel opened this issue Jul 25, 2024 · 0 comments · Fixed by #1228
Closed

bug: api.AssertIsLessOrEqual incorrect behavior on R1CS with constant variable #1227

gbotrel opened this issue Jul 25, 2024 · 0 comments · Fixed by #1228
Assignees
Labels
bug Something isn't working fuzzing Issue found using a fuzzing tool

Comments

@gbotrel
Copy link
Collaborator

gbotrel commented Jul 25, 2024


import (
	"testing"

	"github.com/consensys/gnark/frontend"
	"github.com/consensys/gnark/test"
)

type Circuit struct {
	X frontend.Variable
}

func (circuit *Circuit) Define(api frontend.API) error {
	api.AssertIsLessOrEqual(1, circuit.X)
	return nil
}

func TestConstantPath(t *testing.T) {
	assert := test.NewAssert(t)
	assert.CheckCircuit(&Circuit{},
		test.WithValidAssignment(&Circuit{X: 1}),   // 1 <= 1 --> true
		test.WithInvalidAssignment(&Circuit{X: 0})) // 1 <= 0 --> false
}

thanks to @wuestholz for reporting

Fails because of a bug in the R1CS compiler when the first parameter to api.AssertIsLessOrEqual is a constant.

@gbotrel gbotrel added the bug Something isn't working label Jul 25, 2024
@gbotrel gbotrel self-assigned this Jul 25, 2024
@ivokub ivokub added the fuzzing Issue found using a fuzzing tool label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fuzzing Issue found using a fuzzing tool
Projects
None yet
2 participants