forked from wl-buildingtools/nightfall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nightfall-generate-trusted-setup
executable file
·115 lines (105 loc) · 3.27 KB
/
nightfall-generate-trusted-setup
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
set -e
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
setups=()
setupList=""
completedSetups=()
completedSetupList=""
selectedSetupsIndexes=""
setupCmd=setup
setupAllCmd=setupAll
declare -i index=0
mkdir zkp/code/gm17 || true
read -p $'\n''Do you want to use MiMC hashing? (y/n) : ' yn
case $yn in
[Yy]* ) printf "\nDon't forgot to specify docker-compose.override.mimc.yml\n"
setupCmd=setup-mimc
setupAllCmd=setupAll-mimc
mimc=yes
mkdir zkp/code/gm17/ft-batch-transfer zkp/code/gm17/ft-burn zkp/code/gm17/ft-consolidation-transfer zkp/code/gm17/ft-mint zkp/code/gm17/ft-transfer zkp/code/gm17/nft-burn zkp/code/gm17/nft-mint zkp/code/gm17/nft-transfer || true
cp docker-compose.override.mimc.yml docker-compose.override.yml
;;
[Nn]* )
;;
* ) printf "Please answer yes or no.\n"
;;
esac
if [ ${setupCmd} != "setup-mimc" ]
then
read -p 'Do you want to use the compliance version? (y/n) : ' yn
case $yn in
[Yy]* ) printf "\nOnly fungible token proofs will be used\n"
setupCmd=setup-rc
setupAllCmd=setupAll-rc
mkdir zkp/code/gm17/ft-burn zkp/code/gm17/ft-mint zkp/code/gm17/ft-transfer || true
cp docker-compose.override.compliance.yml docker-compose.override.yml
;;
[Nn]* ) mkdir zkp/code/gm17/ft-batch-transfer zkp/code/gm17/ft-burn zkp/code/gm17/ft-mint zkp/code/gm17/ft-transfer zkp/code/gm17/nft-burn zkp/code/gm17/nft-mint zkp/code/gm17/nft-transfer || true
;;
* ) printf "Please answer yes or no.\n"
;;
esac
fi
# Get available trusted setup names, excluding the 'common' directory and deployment-specific directories
pushd zkp/code/gm17
for d in *
do
if [ -d "$d" ] && [ "$d" != "common" ]
then
if [ "$d" == "ft-consolidation-transfer" ] && [ ${setupCmd} == "setup" ]
then
continue
fi
if [ "$d" == "ft-consolidation-transfer" ] || [ "$d" == "ft-batch-transfer" ] || [ "$d" == "nft-transfer" ] || [ "$d" == "nft-burn" ] || [ "$d" == "nft-mint" ] && [ ${setupCmd} == "setup-rc" ]
then
continue
fi
index+=1
setupList+="${index} $d\n"
setups+=($d)
fi
done
# filter completed trusted setups
for i in "${!setups[@]}"
do
# check directory have required files
if [[ -f ${setups[$i]}/proving.key && -f ${setups[$i]}/verification.key ]]
then
completedSetups+=${setups[$i]}
completedSetupList+="${setups[$i]} "
fi
done
popd
# this function will generate setup which user seleceted
generateSetups(){
selectedSetupsIndexes=$(echo $selectedSetupsIndexes | tr "," "\n")
for i in $selectedSetupsIndexes
do
npm run ${setupCmd} -- -f ${setups[$i-1]}
done
}
printf "${GREEN}*** List of trusted setups ***${NC}\n"
printf "${setupList}"
if [[ ${#completedSetups[@]} != 0 ]]
then
printf "${GREEN}Completed trusted setups are: ${NC}"
printf "${completedSetupList}"
fi
while true
do
read -p $'\n''Do you want to generate all trusted setups? (y/n) : ' yn
case $yn in
[Yy]* ) npm run ${setupAllCmd}
exit
;;
[Nn]* ) printf "\nType the number of each trusted setup seperated by a comma\n"
read -p "(E.g. type "1,2" to run the trusted setups for ${setups[0]} & ${setups[1]}) : " selectedSetupsIndexes
generateSetups
exit
;;
* ) printf "Please answer yes or no.\n"
;;
esac
done