-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add r < p check to FpMul #226
Conversation
packages/circuits/lib/fp.circom
Outdated
@@ -41,6 +41,7 @@ template FpMul(n, k) { | |||
component q_range_check[k]; | |||
signal r[k]; | |||
component r_range_check[k]; | |||
component r_p_range_check = BigLessThan(n,k); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r_p_range_check
can be renamed to r_p_lt_check
(or similar) as we usually use "range check" for checking bit length range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Added a minor comment.
Description
This PR fixes a potential attack vector in the
FpMul
circom template such that a remainderr
larger than or equal to a modulep
can pass constraints.Example:
a=4
,b=4
,p=5
,q=2
,r=6
.To fix this vulnerability, I added a range check
r < p
to theFpMul
circom template.Type of Change
Please delete options that are not relevant.
Checklist: