-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
84 lines (62 loc) · 3.65 KB
/
Makefile
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
.PHONY: circuits/nzcp.circom circuits/cbor.circom test clean phase1 phase2
all: node_modules circuits/nzcp.circom circuits/nzcp_example.wasm circuits/nzcp_live.wasm
circuits/nzcp_exampleTest.wasm:
circom circuits/nzcp_exampleTest.circom --r1cs --wasm
circuits/nzcp_liveTest.wasm:
circom circuits/nzcp_liveTest.circom --r1cs --wasm
circuits/nzcp_example.wasm:
circom circuits/nzcp_example.circom --r1cs --wasm --O2 --sym
circuits/nzcp_live.wasm:
circom circuits/nzcp_live.circom --r1cs --wasm --O2 --sym
test: node_modules circuits/nzcp.circom
yarn exec mocha
sha256-var-circom.zip:
curl -Lo $@ https://github.com/noway/sha256-var-circom/archive/refs/heads/main.zip
sha256-var-circom-main/: sha256-var-circom.zip
unzip $<
cd $@ && make
sha512.zip:
curl -Lo $@ https://github.com/Electron-Labs/sha512/archive/refs/heads/master.zip
sha512-master/: sha512.zip
unzip $<
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(ShR)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(SigmaPlus)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(SmallSigma)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(BigSigma)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(RotR)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(Xor3)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(T2)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(Maj_t)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(T1)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(Ch_t)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(H)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
cd $@/circuits/sha512 && sed -i '' -E 's/([^[:alnum:]_])(K)([^[:alnum:]_])/\1Sha512_\2\3/g' *.circom
circuits/nzcp.circom: circuits/cbor.circom sha256-var-circom-main sha512-master
cpp -P circuits/nzcptpl.circom > $@
circuits/cbor.circom: sha256-var-circom-main
cpp -P circuits/cbortpl.circom > $@
node_modules/:
yarn
plonk_example:
NODE_OPTIONS=--max-old-space-size=16384 snarkjs plonk setup nzcp_example.r1cs powersOfTau28_hez_final_21.ptau nzcp_example_final.zkey
snarkjs zkey export verificationkey nzcp_example_final.zkey verification_key.json
snarkjs zkey export solidityverifier nzcp_example_final.zkey contracts/VerifierExample.sol
plonk_live:
NODE_OPTIONS=--max-old-space-size=16384 snarkjs plonk setup nzcp_live.r1cs powersOfTau28_hez_final_21.ptau nzcp_live_final.zkey
snarkjs zkey export verificationkey nzcp_live_final.zkey verification_key.json
snarkjs zkey export solidityverifier nzcp_live_final.zkey contracts/VerifierLive.sol
phase1:
snarkjs powersoftau new bn128 21 pot21_0000.ptau -v
snarkjs powersoftau contribute pot21_0000.ptau pot21_0001.ptau --name="First contribution" -v
snarkjs powersoftau prepare phase2 pot21_0001.ptau pot21_final.ptau -v
phase2:
snarkjs groth16 setup nzcp_example.r1cs pot21_final.ptau nzcp_example_0000.zkey
snarkjs zkey contribute nzcp_example_0000.zkey nzcp_example_0001.zkey --name="1st Contributor Name" -v
snarkjs zkey export verificationkey nzcp_example_0001.zkey verification_key.json
snarkjs zkey export solidityverifier nzcp_example_0001.zkey contracts/VerifierExample.sol
clean:
rm -rf sha256-var-circom.zip
rm -rf sha256-var-circom-main
rm -rf sha512.zip
rm -rf sha512-master
rm -rf node_modules