-
Notifications
You must be signed in to change notification settings - Fork 149
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 Constraint
and Selector
types
#606
Conversation
30a49d5
to
c2ddec4
Compare
Codecov Report
@@ Coverage Diff @@
## add_lookups #606 +/- ##
===============================================
+ Coverage 97.76% 97.80% +0.04%
===============================================
Files 52 53 +1
Lines 4076 4105 +29
===============================================
+ Hits 3985 4015 +30
+ Misses 91 90 -1
Continue to review full report at Codecov.
|
c2ddec4
to
ed3edbb
Compare
Selector
for gate API polynomialsConstraint
and Selector
types
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.
LGTM. Love the simplification in appending gates.
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.
Few nits, plus we should add the documentation also to internal methods, not only public ones.
self | ||
} | ||
|
||
fn copy_public_selectors(mut self, rhs: &Self) -> Self { |
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.
I know this is only for internal use, but I still don't like it much. Also, if it's just used internally, it might be very well be an associated function instead of a method, since it looks like to me we always use in conjunction with Self::default()
, e.g.:
pub(crate) fn range(s: &Self) -> Self {
Self::default()
.copy_public_selectors(s)
.set(Selector::Range, 1)
}
So what about having something like:
pub(crate) fn range(s: &Self) -> Self {
Self::from_public_selectors(s)
.set(Selector::Range, 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.
I think this would conflict with the idea of creating the arithmetic constraint exclusively from Self::arithmetic
.
ed3edbb
to
b217133
Compare
`Constraint` will introduce a fail-safe type that can be used to describe a circuit. It will replace any composer argument that takes the circuit description/selector polynomials. Resolves #608
|
||
use dusk_bls12_381::BlsScalar; | ||
|
||
/// Index the coefficients in a polynomial description of the circuit |
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.
/// Selectors use to address a coefficient inside a [Constraint
]
|
||
// Compute the inverse | ||
let inv_x_denom = | ||
composer.evaluate_witness(&x_denominator).invert().unwrap(); | ||
let inv_x_denom = composer.append_witness(inv_x_denom); | ||
|
||
let constraint = Constraint::new().mul(1).constant(-BlsScalar::one()); |
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.
x = (1, a, b)
y = (1, c)
enum Wire {
Mult(BlsScalar, Witness, Witness),
Left(BlsScalar, Witness),
}
Constraint::new()
.set(Wire::Mult(x, a, b))
.set(Wire::Left(y, c))
.constant(z);
qM * a * b + qL * c + z = 0
Constraint::new().mul(x, a, b).left(y, c).constant(-BlsScalar::one());
`Constraint` will introduce a fail-safe type that can be used to describe a circuit. It will replace any composer argument that takes the circuit description/selector polynomials. Resolves #608
Constraint
will introduce a fail-safe type that can be used todescribe a circuit. It will replace any composer argument that takes the
circuit description/selector polynomials.
Selector
will allow the user to extract specific coefficients from theconstraint representation.
Resolves #608