-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlaunch_server.sh
More file actions
executable file
·71 lines (58 loc) · 1.42 KB
/
launch_server.sh
File metadata and controls
executable file
·71 lines (58 loc) · 1.42 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
68
69
70
#!/bin/sh
# Launch cusnarks server
#
# Args :
#
# $1 : Proving key file
# $2 : Verification key file
set -ex
SCRIPT=$(readlink -f "$0")
CUSNARKS_HOME=$(dirname "$SCRIPT")
DBPATH="/tmp"
SERVER="cusnarks"
TABLE="cusnarks_table"
cd "${CUSNARKS_HOME}/src/python"
export LD_LIBRARY_PATH="${CUSNARKS_HOME}/lib:$LD_LIBRARY_PATH"
if [ -z $1] || [ "$#" -ne 2 ]; then
PKF="${CUSNARKS_HOME}/circuits/test_cusnarks_pk.bin"
VKF="${CUSNARKS_HOME}/circuits/test_cusnarks_vk.json"
else
PKF="$1"
VKF="$2"
fi
runpsql() {
sudo -u postgres psql -c "${1}"
}
clean_postgres() {
oldpwd="`pwd`"
cd "${DBPATH}"
runpsql "DROP TABLE IF EXISTS ${TABLE};"
runpsql "DROP DATABASE IF EXISTS ${SERVER};"
runpsql "DROP ROLE IF EXISTS ${SERVER};"
cd "${oldpwd}"
}
init_postgres() {
oldpwd="`pwd`"
cd "${DBPATH}"
runpsql "CREATE ROLE ${SERVER};"
runpsql "CREATE DATABASE ${SERVER} OWNER ${SERVER};"
cd "${oldpwd}"
}
create_table() {
oldpwd="`pwd`"
cd "${DBPATH}"
runpsql "CREATE TABLE ${TABLE} (
id int PRIMARY KEY,
result int NOT NULL,
prooft float NOT NULL,
evalt float NOT NULL,
ht float NOT NULL,
mexp1t float NOT NULL,
mexp2t float NOT NULL );"
cd "${oldpwd}"
}
clean_postgres
init_postgres
create_table
SEED=$(od -A n -t d -N 1 /dev/urandom)
python3 pysnarks.py -m p -pk ${PKF} -vk ${VKF} -v 1 -seed ${SEED} -server 1