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

AssertIsLessOrEqual panics when first argument is an int literal #509

Closed
akirillo opened this issue Mar 1, 2023 · 1 comment · Fixed by #511
Closed

AssertIsLessOrEqual panics when first argument is an int literal #509

akirillo opened this issue Mar 1, 2023 · 1 comment · Fixed by #511
Assignees
Labels
bug Something isn't working
Milestone

Comments

@akirillo
Copy link

akirillo commented Mar 1, 2023

One of my circuits attempts to do the following:

api.AssertIsLessOrEqual(0, v)

But when I try to test this, it panics with the message:

interface conversion: frontend.Variable is uint, not expr.LinearExpression

Exact message depends on the way the circuit is compiled (e.g. r1cs or scs, groth16 or plonk, which curve, etc), e.g. may say:

interface conversion: frontend.Variable is int, not expr.TermToRefactor

For (R1CS, Groth16, BN254), I tracked this down to the mustBeLessOrEqVar function in frontend/cs/r1cs/api_assertions.go, on line 131, where we attempt to do a type assertion of aBits[i].(expr.LinearExpression). When I was debugging this, it seemed that aBits[i] was a frontend.Variable wrapped around a uint, not a expr.LinearExpression.

Please let me know what other info I can provide to help with this, I'm not much of a Go guru so I'm not sure why this type assertion is failing, or what the fix should be

@gbotrel gbotrel added the bug Something isn't working label Mar 1, 2023
@gbotrel gbotrel self-assigned this Mar 1, 2023
@gbotrel gbotrel added this to the v0.9.0 milestone Mar 1, 2023
gbotrel added a commit that referenced this issue Mar 1, 2023
gbotrel added a commit that referenced this issue Mar 2, 2023
… as first param (#511)

* fix: closes #509 api did not handle AssertIsLessOrEqual with constant as first param

* style: remove useless MarkBoolean on non-returned bits
@akirillo
Copy link
Author

akirillo commented Mar 3, 2023

@gbotrel Should we close this since #511 got merged, or only when it makes it to the next release?

@gbotrel gbotrel closed this as completed Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants