-
Notifications
You must be signed in to change notification settings - Fork 239
feat: add div-mod constraints #646
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #646 +/- ##
==========================================
+ Coverage 96.08% 96.14% +0.05%
==========================================
Files 331 331
Lines 58897 59607 +710
==========================================
+ Hits 56593 57307 +714
+ Misses 2304 2300 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Can you make a PR with a LaTeX document with the constraints here:
https://github.com/spaceandtimelabs/sxt-proof-of-sql/tree/main/docs/protocols
We can then reference that in this PR.
)?; | ||
|
||
// (r - b) * (r + b) * t' - b = 0 | ||
let t = builder.try_consume_final_round_mle_evaluation()?; |
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.
Can you put all of these together? That way the order is clear, and separated from the constraints.
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.
Should I do this on the prove side as well? Put the constraints after the commitments?
2, | ||
)?; | ||
|
||
// (r - b) * (r + b) * t' - b = 0 |
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.
There should be some comments indicating
// r - remainder
// t' - t
// u - b_div_q
// etc.
Perhaps t
should be t_prime
.
let sqrt_min_plus_s = verifier_evaluate_sign(builder, min_sqrt_eval + s, one_eval, None)?; | ||
let sqrt_min_less_s = verifier_evaluate_sign(builder, min_sqrt_eval - s, one_eval, None)?; | ||
|
||
// MIN < q < -MIN |
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.
This isn't quite the constraint that is being enforced here.
It is actually
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.
Aren't we making the assumption that MIN = -2^B for some B for all our supported data types?
// sign(sqrt(-min) + s) = 1 | ||
// sign(sqrt(-min) - s) = 1 |
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.
Could we get away with
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.
We already need to show that
Additionally, we know that
So, as long as
This is true for all integer types (except u128, which I want to deprecate).
It is not true for all decimal types. (But is true for some of them.)
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.
What's the smallest order field we would ever use for our scalar type? Is i128 the biggest type we will use long term? Are decimals with high precision something that might be relevant here?
2, | ||
)?; | ||
|
||
// (q′ − q) * (q + MIN) = 0 |
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.
NIT: ′
is not '
. −
is not -
.
2, | ||
)?; | ||
|
||
// (q' - MIN) * (q + MIN) * v - (q' - MIN) = 0 |
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.
This does the same thing. The definition of v
changes, but it's just a hint anyway.
// (q' - MIN) * (q + MIN) * v - (q' - MIN) = 0 | |
// (q + MIN) * v - (q' - MIN) = 0 |
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.
Slightly prefer
(q + MIN) * v + (q' - MIN) = 0
2, | ||
)?; | ||
|
||
// (r - b) * (r + b) * t' - b = 0 |
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.
Slightly prefer
(r - b) * (r + b) * t' + b = 0
let sqrt_min_less_s = verifier_evaluate_sign(builder, min_sqrt_eval - s, one_eval, None)?; | ||
|
||
// MIN < q < -MIN | ||
// We need at least an extra bit to allow for -MIN |
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.
We could avoid this extra bit if we do
This, paired with
3a6baac
to
c65f130
Compare
4bebbc0
to
0354b02
Compare
0354b02
to
2ab2ab6
Compare
Please be sure to look over the pull request guidelines here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md#submit-pr.
Please go through the following checklist
!
is used if and only if at least one breaking change has been introduced.source scripts/run_ci_checks.sh
.source scripts/check_commits.sh
, and the commit history is certified to follow clean commit guidelines as described here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/COMMIT_GUIDELINES.mdmain
have been incorporated to this PR by simple rebase if possible, if not, then conflicts are resolved appropriately.Rationale for this change
The constraints for div and mod expr need to be added. This will allow it to be a fully secure gadget.
What changes are included in this PR?
All the constraints for div-and-mod-expr.
Are these changes tested?
Yes. There is a tamperproof test for each constraint, demonstrating that each constraint is necessary.