Snarkjs-Circom Tuturial

本文主要侧重于使用snarkjs和circom在工程上跑通Trusted setup以及由circom电路生成对应的solidity验证文件Verifier

Phase 1:

  • Power tau contributions

  • Third-party challenge

  • Apply a random beacon to finalize phase 1 of the trusted setup

Phase 2:

  • Create the circuit

  • Compile the circuit

  • Set up input and calculate the witness

  • Groth16 setup or PLONK setup

  • Create the proof

  • Turn the verifier into a smart contract

  • Simulate a verification call

1. 依赖安装:snarkjs, circom

npm install -g snarkjs
npm install -g circom

snarkjs是zkSnark和PLONK方案的JavaScript和纯web Assembly实现,使用growth16协议和PLONK,包含了执行多方可信设置所需的工具。snarkjs需要与circom生成的电路配合使用

circom是零知识证明系统的电路编译器,关于其更多介绍,可以参考:

http://kimiwublog.blogspot.com/2020/01/circom.html

工程上的snark可以分为两个步骤,这里作简单介绍:

  • Trusted setup

Reference:

https://github.com/iden3/snarkjs

https://learnblockchain.cn/article/1078