Skip to content

Commit ea6beb7

Browse files
committed
add zk rollup task
1 parent 1f0b010 commit ea6beb7

File tree

9 files changed

+108
-70
lines changed

9 files changed

+108
-70
lines changed

basic/22-zk-snarkjs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ circuit_js/
55
circuit.circom
66
circuit.r1cs
77
circuit.sym
8+
circuit.json
89
powersOfTau28_hez_final_10.ptau
910
circuit_0000.zkey
1011
verification_key.json
1112
input.json
1213
witness.wtns
1314
witness.json
1415
proof.json
16+
proving_key.json
1517
public.json
1618
verifier.sol
1719
circuit_final.zkey

basic/36-nft-ipfs/README.md

Lines changed: 0 additions & 67 deletions
This file was deleted.

basic/36-zk-rollup/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Zk-rollup
2+
3+
4+
## 执行步骤
5+
1. compile
6+
```
7+
circom sample_circuit.circom -o circuit.json
8+
```
9+
10+
2. Generate your input for the circuit
11+
```
12+
node generate_circuit_input.js
13+
```
14+
15+
3. Calculate the witness for the circuit
16+
```
17+
snarkjs calculatewitness -c circuit.json -i input.json
18+
19+
```
20+
21+
4. Perform trusted setup
22+
```
23+
snarkjs setup -c circuit.json --protocol groth
24+
```
25+
26+
5. Generate the proof
27+
```
28+
snarkjs proof -w witness.json --pk proving_key.json
29+
```
30+
31+
6. Verify the proof
32+
33+
```
34+
snarkjs verify
35+
```
36+
## 参考文档
37+
- ZkRollup Tutorial: https://keen-noyce-c29dfa.netlify.app/#3
38+
39+

basic/36-zk-rollup/RollupNC_tutorial

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 7c67b63fc046d93400cf80f104c9cc8396cf3ff8
File renamed without changes.
File renamed without changes.
File renamed without changes.

basic/65-ZK-NFT/readme.md

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,68 @@
1-
#
1+
# 简介
22

3+
数据存储在 ipfs 上后, 在 Dapp 前端就可以通过 api 进行访问, 达到去中心化的目的.
4+
我们可以使用两种方式进行
5+
//todo
6+
FileCoin
37

4-
## 参考链接
5-
- zknft: https://medium.com/centrifuge/bringing-privacy-to-non-fungible-tokens-a-recap-from-the-zokrates-workshop-at-zcon1-6d9ea8a74b7f
8+
## 测试 nft.storage 流程
9+
10+
- 账户注册
11+
注册https://nft.storage/, 获得 nft.storage API Key, 写入.env
12+
- 安装 nft.storage 以及其他依赖
13+
14+
```shell
15+
npm install
16+
```
17+
18+
- 运行 js 文件
19+
20+
```shell
21+
node scripts/nftStorage-uploadfile
22+
```
23+
24+
## 测试 ipfs.infura 流程
25+
26+
- 在 infura 上创建 ipfs 工程
27+
登陆 infura, 然后进入 Dashboard, 之后在 "IPFS" 标签页中创建 IPFS 工程
28+
<center><img src="https://github.com/Dapp-Learning-DAO/Dapp-Learning-Arsenal/blob/main/images/basic/36-nft-ipfs/ipfs-infura.png?raw=true" /></center>
29+
30+
- 获取 "PROJECT ID" 和 "PROJECT SECRET"
31+
点击刚才创建的 IPFS 工程, 然后获取其中的 "PROJECT ID" 和 "PROJECT SECRET"
32+
33+
- 上传文件
34+
替换如下命令中的 PROJECT_ID, PROJECT_SECRET.
35+
36+
```shell
37+
cd data;
38+
curl -X POST -F [email protected] \
39+
-u "<PROJECT_ID>:<PROJECT_SECRET>" \
40+
"https://ipfs.infura.io:5001/api/v0/add"
41+
```
42+
43+
之后可以看到如下输出:
44+
45+
```shell
46+
{
47+
"Name":"ipfs_file_docs_getting_started_demo.txt",
48+
"Hash":"QmeGAVddnBSnKc1DLE7DLV9uuTqo5F7QbaveTjr45JUdQn",
49+
"Size":"44"
50+
}
51+
```
52+
53+
- 获取文件 && 验证
54+
替换如下命令中的 Hash 参数, 然后执行如下命令, 之后检查 matic.jpeg 文件.
55+
56+
```shell
57+
rm matic.jpeg
58+
curl -X POST -u "PROJECT_ID:PROJECT_SECRET" \
59+
"https://ipfs.infura.io:5001/api/v0/pin/add?arg=<Hash>" -o matic.jpeg
60+
```
61+
62+
## 参考文档
63+
64+
- <https://www.bilibili.com/video/BV1j5411w7MH>
65+
- <https://pinata.cloud/pinmanager>
66+
- <https://nft.storage>
67+
- https://infura.io/docs/ipfs#section/Authentication/Using-Javascript
68+
- zknft: https://medium.com/centrifuge/bringing-privacy-to-non-fungible-tokens-a-recap-from-the-zokrates-workshop-at-zcon1-6d9ea8a74b7f

0 commit comments

Comments
 (0)