forked from celo-org/snark-setup
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathphase2_chunked.sh
More file actions
67 lines (55 loc) · 3.81 KB
/
phase2_chunked.sh
File metadata and controls
67 lines (55 loc) · 3.81 KB
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
#!/bin/bash -e
rm -f challenge* response* new_challenge* new_response* new_new_challenge_* processed* initial_ceremony* response_list* combined* seed* chunk*
export RUSTFLAGS="-C target-feature=+bmi2,+adx"
CARGO_VER=""
PROVING_SYSTEM=groth16
POWER=18
BATCH=131072
CHUNK_SIZE=131072
CURVE="bw6"
PATH_PHASE1="../../phase1-cli/scripts/combined"
SEED1=$(tr -dc 'A-F0-9' < /dev/urandom | head -c32)
echo $SEED1 > seed1
SEED2=$(tr -dc 'A-F0-9' < /dev/urandom | head -c32)
echo $SEED2 > seed2
function check_hash() {
test "`xxd -p -c 64 $1.hash`" = "`b2sum $1 | awk '{print $1}'`"
}
cargo $CARGO_VER build --release --bin setup2
phase2_new="cargo run --release --features cli -- new --curve-type $CURVE --chunk-size $CHUNK_SIZE --batch-size $BATCH --contribution-mode full"
phase2_chunked="cargo run --release --bin setup2 --features cli -- --curve-type $CURVE --chunk-size $CHUNK_SIZE --batch-size $BATCH --contribution-mode full --proving-system $PROVING_SYSTEM"
phase2_1="cargo run --release --bin setup2 --features cli -- --curve-type $CURVE --batch-size $BATCH --contribution-mode chunked --chunk-size $CHUNK_SIZE --seed seed1 --proving-system $PROVING_SYSTEM"
phase2_2="cargo run --release --bin setup2 --features cli -- --curve-type $CURVE --batch-size $BATCH --contribution-mode chunked --chunk-size $CHUNK_SIZE --seed seed2 --proving-system $PROVING_SYSTEM"
####### Phase 2
MAX_CHUNK_INDEX=1
pwd
ls $PATH_PHASE1
$phase2_new --challenge-fname challenge --challenge-hash-fname challenge.verified.hash --phase1-fname $PATH_PHASE1 --phase1-powers $POWER --num-validators 1 --num-epochs 1
for i in $(seq 0 $(($MAX_CHUNK_INDEX/2))); do
echo "Contributing and verifying chunk $i..."
$phase2_1 --chunk-index $i contribute --challenge-fname challenge.$i --challenge-hash-fname challenge.$i.hash --response-fname response_$i --response-hash-fname response_$i.hash
check_hash challenge.$i
check_hash response_$i
$phase2_1 --chunk-index $i verify --challenge-fname challenge.$i --challenge-hash-fname challenge_$i.verified.hash --response-fname response_$i --response-hash-fname response_$i.verified.hash
rm response_$i.hash
$phase2_2 --chunk-index $i contribute --challenge-fname response_$i --challenge-hash-fname response_$i.hash --response-fname new_response_$i --response-hash-fname new_response_$i.hash
check_hash new_response_$i
$phase2_2 --chunk-index $i verify --challenge-fname response_$i --challenge-hash-fname response_$i.verified.hash --response-fname new_response_$i --response-hash-fname new_response_$i.verified.hash
rm challenge.$i response_$i # no longer needed
echo new_response_$i >> response_list
done
for i in $(seq $(($MAX_CHUNK_INDEX/2 + 1)) $MAX_CHUNK_INDEX); do
echo "Contributing and verifying chunk $i..."
$phase2_2 --chunk-index $i contribute --challenge-fname challenge.$i --challenge-hash-fname challenge.$i.hash --response-fname response_$i --response-hash-fname response_$i.hash
check_hash challenge.$i
check_hash response_$i
$phase2_2 --chunk-index $i verify --challenge-fname challenge.$i --challenge-hash-fname challenge_$i.verified.hash --response-fname response_$i --response-hash-fname response_$i.verified.hash
rm response_$i.hash
$phase2_1 --chunk-index $i contribute --challenge-fname response_$i --challenge-hash-fname response_$i.hash --response-fname new_response_$i --response-hash-fname new_response_$i.hash
check_hash new_response_$i
$phase2_1 --chunk-index $i verify --challenge-fname response_$i --challenge-hash-fname response_$i.verified.hash --response-fname new_response_$i --response-hash-fname new_response_$i.verified.hash
rm challenge.$i response_$i # no longer needed
echo new_response_$i >> response_list
done
$phase2_chunked combine --response-list-fname response_list --initial-query-fname challenge.query --initial-full-fname challenge.full --combined-fname combined
echo "Done!"