Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
belenios
belenios
Commits
c9ce96af
Commit
c9ce96af
authored
Feb 05, 2014
by
Stephane Glondu
Browse files
Add a bash script to simulate a whole election
parent
34eab2cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
demo/demo.sh
0 → 100755
View file @
c9ce96af
#!/bin/bash
set
-e
BELENIOS
=
${
BELENIOS
:-
$PWD
}
alias
belenios-tool
=
$BELENIOS
/_build/belenios-tool
header
()
{
echo
echo
"=-=-=
$1
=-=-="
echo
}
header
"Setup election"
UUID
=
`
uuidgen
`
echo
"UUID of the election is
$UUID
"
DIR
=
$BELENIOS
/demo/data/
$UUID
mkdir
$DIR
cd
$DIR
# Generate credentials
belenios-tool credgen
--uuid
$UUID
--count
3
mv
*
.pubcreds public_creds.txt
mv
*
.privcreds private_creds.txt
# Generate trustee keys
belenios-tool trustee-keygen
belenios-tool trustee-keygen
belenios-tool trustee-keygen
cat
*
.pubkey
>
public_keys.jsons
# Generate election parameters
belenios-tool mkelection
--uuid
$UUID
--group
$BELENIOS
/demo/groups/default.json
--template
$BELENIOS
/demo/templates/election.json
# Generate election metadata
BDATE
=
"
$(
date
-u
+
'%F %T.000'
)
"
EDATE
=
"
$(
date
-u
-d
tomorrow +
'%F %T.000'
)
"
printf
'{"voting_starts_at":"%s","voting_ends_at":"%s"}\n'
"
$BDATE
"
"
$EDATE
"
>
metadata.json
header
"Simulate votes"
cat
private_creds.txt |
while
read
cred
;
do
belenios-tool election
--privkey
<
(
echo
$cred
)
vote <
(
printf
"[[0,0,0,0,0],[0,1,0,1,1,0],[0,0,1]]"
)
echo
>
&2
done
>
ballots.tmp
mv
ballots.tmp ballots.jsons
header
"Perform decryption"
for
u
in
*
.privkey
;
do
belenios-tool election
--privkey
$u
decrypt
echo
>
&2
done
>
partial_decryptions.tmp
mv
partial_decryptions.tmp partial_decryptions.jsons
header
"Finalize tally"
belenios-tool election finalize
echo
echo
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
echo
echo
"The simulated election was successful! Its result can be seen in"
echo
"
$DIR
/result.json"
echo
echo
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
echo
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment