Jsnark building circuits for preprocessing zk-SNARKs 学习笔记

The jsnark project uses an intermediate assembly-ish language to allow the circuits to be imported into libsnark:
https://github.com/akosba/libsnark/blob/fde8599fc047e9d681ee8f8325913c76de389b55/src/interface/CircuitReader.cpp
https://github.com/akosba/libsnark/blob/fde8599fc047e9d681ee8f8325913c76de389b55/src/interface/run_libsnark.cpp

Prover witness wires are secret by default (similar to Pinocchio’s NIZKInput) and are not revealed to the verifier, unless the programmer chooses to make them part of the public statement (the FieldDivision example), or of course in the case that the verifier can figure their values out by running the computation itself if possible.
In the division example, secrecy is not important, and the verifier can figure out the witness value as long as the inputs are public. The purpose of introducing a prover witness wire here was to show how to do some things in a more efficient way when you are writing circuits for zk-SNARKs. In cases like this, the programmer does not have to compute the result in the circuit, but it’s possible to introduce the solution as a witness and just verify one or more constraints about it.
On the other hand, if you give a look to the example here: you will see prover witness wires created in the beginning. These are going to remain secret in this example, and what will only be public are their hashes as computed by the gadgets. In other words, the circuit here proves the knowledge of SHA-2 preimages in this example among other things.

修改sandbox中的相应main函数的设置,可在指定的目录下输出指定的circuit .arith和.in文件。
Jsnark building circuits for preprocessing zk-SNARKs 学习笔记_第1张图片
在这里插入图片描述

你可能感兴趣的:(Jsnark building circuits for preprocessing zk-SNARKs 学习笔记)