arkworks-rs / groth16

A Rust implementation of the Groth16 zkSNARK
https://www.arkworks.rs
Apache License 2.0
242 stars 97 forks source link

doc: add a simple membership circuit example #62

Open tdelabro opened 2 months ago

tdelabro commented 2 months ago

Description

Add a e2e example of a circuit being setup, proven and verified. It has the advantage to use UInt8 as public input and therefore to showcase how to pass them as input to the verifier (btw, is there no pre-defined methods and traits to do this?)

closes: #XXXX


Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why.

weikengchen commented 2 months ago

There is a high chance that this would not be added... you can see that groth16 used to have examples, but they are mostly removed (due to the cost of maintenance at that time). The mimc test (https://github.com/arkworks-rs/groth16/blob/master/tests/mimc.rs) should serve as a good reference though.

After that removal, if one wants to find circuit examples, since they are not specific to groth16 but also work for other proof systems in this organization such as gemini and marlin, they are usually found in r1cs-std.

tdelabro commented 1 month ago

I can understand the burden of maintaining those examples, and it may be sensible to have examples using types like UInt8 live in the r1cs-std.

This being said, the examples in r1cs-std are not enough. There are tests, but no examples. They are limited in their scope and don't showcase a full e2e (setup, prove, verify) flow.

Also, it took me ages to discover that using UInt8 as public input involves passing 8 bools as arguments to the verifier. It's not showcased in any test, nor documented (afaik).

Do you want me to move my example to r1cs-std instead?