arnaucube / go-snark-study

zkSNARK library implementation in Go from scratch (compiler, setup, prover, verifier)
GNU General Public License v3.0
255 stars 57 forks source link

Question, how to start #12

Closed KimiWu123 closed 4 years ago

KimiWu123 commented 4 years ago

Hi,

We want to use your lib to build our own client which could generate and verify proofs. What is your suggestion to write circuits? Embedding the circuit logic in the code and then parsing it like your example or using functions directly (no idea you provide this way or not). If I use functions directly, I didn't see any gadgets like libsnark. I'm willing to build some gadgets if necessary.

Thanks.

arnaucube commented 4 years ago

Hi, honestly I wrote go-snark to learn about zkSnarks, but I don't have time to optimize all the things that need to be optimized for production, also this has not been audited, and I don't have time to maintain it. So I would not recommend it to be used for production. There are other options to use zkSnarks Pinocchio and Groth16 protocols):

As extra I've added to go-snark a verifier adapter to verify zkproofs generated from snarkjs/websnark, so you can use circom/snarkjs/websnark to do circuits, generate proofs, etc, and if you need to verify that from a Go code you can use this verifier directly from Go: https://github.com/arnaucube/go-snark/tree/master/externalVerif

KimiWu123 commented 4 years ago

Hi, We know the risk and our goal is to know how to use snark libs to write a zk app. It's more like practice purpose, just like you write this lib. We also know the options you listed, but unfortunately we're more familiar with Go. In addition, we want to verify by our app instead of smart contracts so circom and zokrates are not our choices. Btw, what is the biggest different between circom and zokrates, it looks very similar.

What is your suggestion if we want to do what I said above? Using circom/snarkjs to write and generate proof and then verify by go-snark? We'd like to learn something by doing this PoC. And I'm willing to contribute more to help other developers like me.

Thanks.

arnaucube commented 4 years ago

Ok, With go-snark the circuit language that I did is very simple and limited, better with circom where you have a more complete language, and also lot of templates already implemented for crypto primitives in circomlib https://github.com/iden3/circomlib You can then use circom to write and compile the circuits, and then generate the proofs with websnark (much much faster than snarkjs in the browser), and then you can verify the proofs from go-snark, but also from snarkjs and also with snarkjs you can generate the solidity smart contract that verifies the zkproof onchain.

To compile circom circuits & to generate & verify proofs there is also another experimental tool, that is in this repo: https://github.com/iden3/za is an experimental of circom compiler written in Rust, and also has parsers from circom to bellman, that allows to get a circom circuit and use it to generate & verify proofs using the bellman library.

KimiWu123 commented 4 years ago

Thank you so much!