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

LessThan(n) is unsafe with n = 254 #116

Closed
wanseob opened this issue Oct 5, 2020 · 0 comments · Fixed by #124
Closed

LessThan(n) is unsafe with n = 254 #116

wanseob opened this issue Oct 5, 2020 · 0 comments · Fixed by #124

Comments

@wanseob
Copy link
Member

wanseob commented Oct 5, 2020

  • LessThan(n) is unsafe with n = 254, and there are multiple uses of it. this is because it uses under the hood Num2Bits(2*n+1), which is only safe for 2*n+1 < 254, since after that you can overflow.

    here's a script that shows a concrete problem: https://github.com/kobigurk/circom-less-than/blob/master/tester.js

    same inputs, same constraints but two satisfying witnesses where in one the output of LessThan is 0 and for the other it's 1.

    After checking with Jordi, LessThan will be fixed to work up until n=252, and then we can use it with n=252 which should be enough. This is the fix: fix: improve LessThan and adds assert iden3/circomlib#48.

    We also need to assert that the inputs are indeed less than or equal to 252 bits using Num2Bits.

    An alternative way is to just use Num2Bits with, let's say, 245 on the inputs to assert their size. This is my suggested way.

by @kobigurk

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

Successfully merging a pull request may close this issue.

1 participant