This pull request will allow people to call into external gadgets (e.g. libsnark's sha256_two_to_one_hash_gadget) by providing an executable that can respond to three commands
gadgetN size: returns the number of intermediate variables the gadget requires
gadgetN constraints a|b|c: returns the constraints for the a|b|c matrix in the form row column value
gadgetN witness [inputs]: given the inputs, generate a fulfilling assignment for the constraints in the gadget and return it as a list of values.
This will allow you to use highly optimized gadget for expensive operations (e.g. hashing) while still using the convenience pepper offers for iterations, conditionals and other high level processing code. An example .c file using the ext_gadget call can be seen here: https://pastebin.com/kMExVe3L
The pull request will contain out of three steps:
Add support for an ext_gadget function call in the frontend (similar to exo_compute)
In the backend, when reading the ext_gadget command insert the external R1CS into the R1CS we are currently building.
In the prover, when trying to process the ext_gadget command call into the gadget to get the witness instead of letting the prover run
I am planning to break this PR up into multiple commits to make it easier to review. Please feel free to comment with suggestions already now.
I'm more than happy to redesign or iterate on the approach if you think there is a better one.
This pull request will allow people to call into external gadgets (e.g. libsnark's
sha256_two_to_one_hash_gadget
) by providing an executable that can respond to three commandsgadgetN size
: returns the number of intermediate variables the gadget requiresgadgetN constraints a|b|c
: returns the constraints for the a|b|c matrix in the formrow column value
gadgetN witness [inputs]
: given the inputs, generate a fulfilling assignment for the constraints in the gadget and return it as a list of values.This will allow you to use highly optimized gadget for expensive operations (e.g. hashing) while still using the convenience pepper offers for iterations, conditionals and other high level processing code. An example .c file using the ext_gadget call can be seen here: https://pastebin.com/kMExVe3L
The pull request will contain out of three steps:
I am planning to break this PR up into multiple commits to make it easier to review. Please feel free to comment with suggestions already now. I'm more than happy to redesign or iterate on the approach if you think there is a better one.