-
Notifications
You must be signed in to change notification settings - Fork 1
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 circuits and padding #2
Conversation
Remove unnecessary `PhantomData` Co-authored-by: Antonio Mejías Gil <[email protected]> Progress until 08/03 Co-authored-by: Antonio Mejías Gil <[email protected]> constructing range check, wip working on padding println nightmare, issue apparently fixed Remove redundant padding. Fix import. code cleanup further cleanup found better way to fix padding the 'better way' to fix padding actually broke other tests - reverted This reverts commit d4727ba. moved example to examples folder, refactored, tested many cases
…tead of unsigned integers.
2825ea0
to
eb2843e
Compare
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.
Also, shouldn't there be an analogous modification for the verifier?
RIght now, there are two padding-related modifications:
The verfier doesn't receive the latter vector, and their circuit is padded during |
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, PR away to upstream!
This PR adds two example circuits to verify
a < b
, wherea
is a private witness held by the prover andb
is a public constant fixed at set-up. The two circuits rely on a fixed bit length thata
is supposed to fit in (when regarded as an unsigned integer, even though in reality it lies in some finite field).LessThanCircuitSafe
performs the aforementioned bit length verification.LessThanCircuitUnsafe
does not. This leads to constraint savings when the circuit is used as a component in a larger circuit which already ensures the bit length meets the required bound.In the course of writing the examples, we encountered the issue that the existing Spartan machinery did not pad the matrices to power-of-two row and column lengths, as necessitated by the proof system. This caused compilation errors in our examples. Since it seemed like a good idea for this need for padding to be abstracted away from the user, we have implemented padding in the Spartan internals - that is the other significant contribution in this PR. Note that a
R1CSShape
method.pad()
already existed here, but after some experimentation we convinced ourselves that it could not be used to pad the circuit in the cases where it was necessary.Other minor changes:
<F>
generic on the existingCubicCircuit
example, which in turn allowed us to remove thePhantomData
therein and didn't require any further code modifications.