-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.sql
More file actions
43 lines (38 loc) · 1.15 KB
/
db.sql
File metadata and controls
43 lines (38 loc) · 1.15 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
CREATE TYPE election_state AS ENUM (
'init', -- invisible to voters
'voting', -- voting is open
'counting', -- voting is closed, results visible only to admin
'results' -- voting is closed, results visible to everybody
);
CREATE TABLE elections (
election_id serial PRIMARY KEY,
ident text UNIQUE NOT NULL,
state election_state NOT NULL DEFAULT 'init',
config jsonb NOT NULL,
election_key text NOT NULL,
verify_key text NOT NULL,
"order" int NOT NULL DEFAULT 0
);
-- H2 hashes of valid credentials
CREATE TABLE cred_hashes (
election_id int NOT NULL REFERENCES elections(election_id),
hash text NOT NULL,
UNIQUE (election_id, hash)
);
CREATE TABLE ballots (
election_id int NOT NULL REFERENCES elections(election_id),
receipt text NOT NULL,
nonce text NOT NULL,
-- ranks of individual options (only order matters)
ranks smallint[] NOT NULL,
UNIQUE (election_id, receipt)
);
CREATE TABLE verifiers (
election_id int NOT NULL REFERENCES elections(election_id),
verifier text NOT NULL,
UNIQUE (election_id, verifier)
);
CREATE TABLE results (
election_id int NOT NULL REFERENCES elections(election_id),
result jsonb NOT NULL
);