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

本文探讨了使用中间装配语言进行电路设计,以便于将电路导入libsnark。介绍了prover witness wires的概念,包括其默认的秘密性质以及如何在特定情况下作为公共声明的一部分。讨论了在电路设计中引入prover witness wires的效率优势,并通过具体示例说明了其在zk-SNARKs中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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文件。
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值