/
start.sh
33 lines (26 loc) · 1.97 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/zsh
set -e
# --------------------------------------------------------------------------------
# Phase 1
# ... non-circuit-specific stuff
# Starts Powers Of Tau ceremony, creating the file pot12_0000.ptau
snarkjs powersoftau new bn128 14 ./zk/pot12_0000.ptau -v
# Contribute to ceremony a few times...
# As we want this to be non-interactive we'll just write something random-ish for entropy
snarkjs powersoftau contribute ./zk/pot12_0000.ptau ./zk/pot12_0001.ptau --name="First contribution" -v -e="$(head -n 4096 /dev/urandom | openssl sha1)"
snarkjs powersoftau contribute ./zk/pot12_0001.ptau ./zk/pot12_0002.ptau --name="Second contribution" -v -e="$(head -n 4096 /dev/urandom | openssl sha1)"
snarkjs powersoftau contribute ./zk/pot12_0002.ptau ./zk/pot12_0003.ptau --name="Third contribution" -v -e="$(head -n 4096 /dev/urandom | openssl sha1)"
# Verify
snarkjs powersoftau verify ./zk/pot12_0003.ptau
# Apply random beacon to finalised this phase of the setup.
# For more information about random beacons see here: https://eprint.iacr.org/2017/1050.pdf
# For the purposes, the beacon is essentially a delayed hash function evaluated on 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
# (in practice this value will be some form of high entropy and publicly available data of your choice)
snarkjs powersoftau beacon ./zk/pot12_0003.ptau ./zk/pot12_beacon.ptau 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 10 -n="Final Beacon"
# Prepare phase 2...
# Under the hood, the prepare phase2 command calculates the encrypted evaluation of the Lagrange polynomials at tau for
# tau, alpha*tau and beta*tau. It takes the beacon ptau file we generated in the previous step, and outputs a final pta
# file which will be used to generate the circuit proving and verification keys.
snarkjs powersoftau prepare phase2 ./zk/pot12_beacon.ptau ./zk/pot12_final.ptau -v
# Verify the final ptau file. Creates the file pot12_final.ptau
snarkjs powersoftau verify ./zk/pot12_final.ptau