当前位置:网站首页>使用 Zokrates 在 BSV 上创建您的第一个 zkSNARK 证明
使用 Zokrates 在 BSV 上创建您的第一个 zkSNARK 证明
2022-08-01 21:48:00 【sCrypt 智能合约】
这个 ZoKratesFork库 是 BSV 上 zkSNARKs 的工具箱。它可以帮助您在应用程序中使用可验证的计算,从高级语言的编写的电路到生成计算证明,再到在 sCrypt 中验证这些证明。
安装
下载并使用我们发布的二进制包:
https://github.com/sCrypt-Inc/zokrates/releases/latest
或者从源码编译:
git clone https://github.com/sCrypt/ZoKrates
./build_release.sh
cd target/release
工作流程
整个工作流程与原始 ZoKrates 相同,除了验证部分。
- 编写电路程序,创建文本文件
root.zok
并实现以下的程序。在这个例子中,我们将证明知道数字b
的平方根为a
:
def main(private field a, field b) {
assert(a * a == b);
return;
}
- 编译电路
zokrates compile -i root.zok
- 执行设置
zokrates setup
- 计算见证人
zokrates compute-witness -a 337 113569
- 生成证明
zokrates generate-proof
- 导出验证者智能合约
verifier.scrypt
, 同时会提供一个verifier.js
文件
zokrates export-verifier-scrypt
- 执行
verifier.js
验证 zkSNARK 证明1。如果本地验证成功,则会将verifier.scrypt
验证者合约部署到测试网2,并调用部署的验证者合约
node --max-old-space-size=8192 verifier.js
[1] 在此之前,你需要确保安装了
scryptlib
和axios
nodejs 模块。 由于验证者合约较大,增加--max-old-space-size=8192
确保 nodejs 内存充足[2] 需要填写测试网私钥
边栏推荐
- 0DFS Medium LeetCode6134. Find the closest node to the given two nodes
- NFT的10种实际用途(NFT系统开发)
- Upload markdown documents to blog garden
- Based on php online examination management system acquisition (php graduation design)
- MySQL相关知识
- render-props和高阶组件
- 游戏元宇宙发展趋势展望分析
- [ASM] Bytecode Operation MethodWriter
- LeetCode952三部曲之一:解题思路和初级解法(137ms,超39%)
- 工程建筑行业数据中台指标分析
猜你喜欢
Based on php Xiangxi tourism website management system acquisition (php graduation design)
【建议收藏】ヾ(^▽^*)))全网最全输入输出格式符整理
小程序--分包
【Jmeter常用断言组件】
小程序--独立分包&分包预下载
SOM网络2: 代码的实现
HCIP---Architecture of Enterprise Network
Based on php tourism website management system acquisition (php graduation design)
Recycling rental system 100% open source without encryption Mall + recycling + rental
基于php影视资讯网站管理系统获取(php毕业设计)
随机推荐
用户体验 | 如何度量用户体验?
程序员必备的 “ 摸鱼神器 ” 来了 !
上传markdown文档到博客园
groupByKey和reduceBykey的区别
Scala practice questions + answers
[Mobile Web] Mobile terminal adaptation
Unity Shader 常规光照模型代码整理
回收租凭系统100%开源无加密 商城+回收+租赁
Image fusion GANMcC study notes
Upload markdown documents to blog garden
第3讲:MySQL数据库中常见的几种表字段数据类型
C语言必杀技3行代码把运行速度提升4倍
Based on php tourism website management system acquisition (php graduation design)
Anacoda的用途
SOM网络2: 代码的实现
Yizhou Financial Analysis | The intelligent transformation of bank ATM machines is accelerated; the new Internet loan regulations bring challenges
AI应用第一课:支付宝刷脸登录
【C语言实现】整数排序-四种方法,你都会了吗、
RecycleView的使用
Advanced Algebra_Proof_The algebraic multiplicity of any eigenvalue of a matrix is greater than or equal to its geometric multiplicity