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

Mux1.circom doesn't check that selector is either 0 or 1 #24

Open
poma opened this issue Nov 6, 2019 · 3 comments
Open

Mux1.circom doesn't check that selector is either 0 or 1 #24

poma opened this issue Nov 6, 2019 · 3 comments

Comments

@poma
Copy link
Contributor

poma commented Nov 6, 2019

In circomlib/circuits/mux1.circom it is possible to specify an input that is not equal 0 or 1 and get an arbitrary output instead of one of inputs. The following check should be added at line 24:

s * (1 - s) === 0

Possibly other multiplexer implementations are also affected

@HarryR
Copy link

HarryR commented Nov 6, 2019

This would also work:

s*s === s

@khovratovich
Copy link

This might be suboptimal because a caller may already have input of proper type (for example, output of num2bits), and an extra constraint will increase the complexity for nothing.

@poma
Copy link
Contributor Author

poma commented Nov 20, 2019

if the constraint is the same as in num2bits, the optimizer will remove it as duplicate

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

3 participants