davinci-paper/v2/sections/protocol-flow.tex
v2/sections/protocol-flow.texRaw
1% !TeX root = ../build/main.tex
2
3In this section we describe the overall flow of the \davinci voting protocol. An election is structured into five main phases: election setup, encryption key generation, voting period, decryption key generation, and tally finalization. Each phase specifies the interactions between the organizer, \keywardens, voters, sequencers, and the smart contracts that coordinate the election. An overview of the complete process is shown in Figure~\ref{fig:protocol-flow}.
4
5\subsubsection{Election setup}
6\label{sec:vocdoni-protocol:setup}
7
8In this phase, sequencers register and the organizer sets the election up.\\
9
10\rogeri{I'd put this outside of the "voting process". I think adding a section "System setup and operation"-like before this one and rename this one as "voting process flow" (or simply "voting process") could ease the explanation.}
11
12\martai{This section is outdated. Sequencers do not register, and we should remove the colours and boxes.}
13
14\noi \sequencers
15Sequencers must first register in the sequencer registry smart contract, a process that remains open continuously. Registration involves publishing their identity, network endpoint (e.g., URI), and a collateral deposit to ensure honest participation. The collateral can later be slashed in case of misbehavior. \\
16
17\noi \organizer For each new election, the organizer performs the following steps:
18\begin{enumerate}
19 \item Prepare the census data \censusdata\ and generate the census Merkle tree $\censusTree$ with that data.
20 \item Compute the census commitment $\censusroot = \censusTree.\hlget{\MTRoot}()$.
21 \item Prepare the voting form (ballot / set of questions), upload it to IPFS, compute commitment.
22 \item Define the election details, including duration, options, and the ballot rules $\ballotmode$ (see Section~\ref{sec:ballot-protocol}).
23 \item Compute a unique process identifier $\processid$, which is a 32-byte number derived from the organizer’s Ethereum address, nonce, and the chain ID.
24 \item Set security parameters for the %forthcoming
25 DKG ceremony (e.g., timeout, minimum number of sequencers).
26 \item Submit all this information in a transaction to the process management smart contract {\color{blue}(pay tx fees)}:
27 \[ tx_{org} = (\censusroot, ballotCommitment, \ballotmode, electionMetadata, \processid, dkgParameters).\]
28\end{enumerate}
29
30\subsubsection{Encryption key generation}
31\label{sec:vocdoni-protocol:keygen}
32
33In this phase, \keywardens collectively generate the public encryption key.\\
34
35\noi \Keywardens fetch the process parameters ($\processid$, $\ballotmode$, $\censusroot$) from the process management smart contract and participate in a DKG protocol before the timeout set by the organizer expires. If the minimum number of contributions is reached, the public encryption key $\epk$ is derived and made available on-chain. This ensures that no single party controls the secret key, and that decryption later requires threshold participation {\color{blue}(give more details)}.\\
36
37\noi {\color{blue} Alternatively, generate a SNARK proving the EPK has been generated correctly and the contract verifies it.}
38
39\subsubsection{Voting period}
40\label{sec:vocdoni-protocol:votes}
41
42In this phase, voters cast their ballots and send them to the sequencers, who collect and process them. \\
43
44\noi \textbf{(a) Vote casting.} To cast a ballot, a voter does the following:
45
46\begin{enumerate}
47 \item Select a sequencer from the sequencer registry smart contract.
48 \item Retrieve their census membership proof $\censusproof$ to prove eligibility.
49 \item Fetch parameters $\epk$, $\ballotmode$, and $\processid$ from the process management contract.
50 \item Select their ballot choice $\ballot$ according to the rules of $\ballotmode$.
51 \item Sample fresh randomness $k \in \F$ and encrypt the ballot using $\epk$:
52 \begin{equation}
53 \label{eq-ciphertext}
54 (C_1, C_2) = \hlget{\Enc}_{\epk}(\ballot; k).
55 \end{equation}
56 \item Use their Ethereum address $\address$ and the previous $k$ to compute a unique vote identifier:
57 \begin{equation}
58 \label{eq-voteid}
59 \voteid = \hlget{\Multimimc}(\processid \conc \address \conc k).
60 \end{equation}
61 \item Use the ballot circuit (Section~\ref{sec:vocdoni-protocol:circuits:ballot}) to generate a ZK-SNARK proof to prove that Eqs.~\labelcref{eq-ciphertext,eq-voteid} are correctly computed and that $\ballot$ satisfies ballot protocol rules according to $\ballotmode$:
62 \[ {\color{blue}\voteproof = \text{\hlget{Prove}(Circuit, PI = ())}.}\]
63 \item Sign the vote identifier with their Ethereum secret key to authenticate the vote and ensure that was cast by a legitimate voter:
64 \[ \signature = \hlget{\SSign}_{\sk}(\voteid).\]
65 \item Submits the package
66 \[\vote = [\processid, \voteid, \encryptedballot, \censusproof, \voteproof, \signature]\]
67 to the chosen sequencer.
68\end{enumerate}
69
70%\item Sign $\voteid$ using the user's secret key $\sk$ to authenticates the vote and ensure that was cast by a legitimate voter:
71%\[ \signature = \hlget{\SSign}_{\sk}(\voteid).\]
72%\item Send the following data, which includes the encrypted vote, census membership proof, signature\footnote{Note that the address is not send because it can be recomputed from the signature.} and vote proof, to the selected sequencer:
73%\[ \vote = [ \processid, \voteid, \encryptedballot, \censuspf, \voteproof, \signature ]. \]
74
75\noi \textbf{(b) Vote batching.} Upon receiving votes, a sequencer does the following:
76
77\begin{enumerate}
78 {\color{blue}
79 \item Retrieve the current state root $\stateroot$ and census root $\censusroot$ from the process management smart contract and the associated data from the Ethereum data blobs.
80 \item Verify each submission by generating a state transition proof (see Section~\ref{sec:vocdoni-protocol:circuits:state-transition}), ensuring:
81 \begin{itemize}
82 \item the validity of the voter’s zkSNARK proof,
83 \item correct accumulation of encrypted votes via ElGamal’s homomorphic properties,
84 \item eligibility of voters (via census Merkle proofs),
85 \item absence of double voting (or correct handling of overwrites via nullifiers),
86 \item consistency between data blobs and the on-chain state.
87 \end{itemize}
88 \item Submit the updated state root to the smart contract, while the full data are stored in Ethereum blobs.
89 }
90 \martai{If \stateroot changed, repeat last circuit.}
91\end{enumerate}
92
93Sequencers repeat this process until the voting deadline set by the organizer.
94
95\subsubsection{Decryption key generation}
96\label{sec:vocdoni-protocol:deckey-gen}
97
98\subsubsection{Tally finalization}
99\label{sec:vocdoni-protocol:results}
100
101{\color{blue} After the voting period expires, $t$ out of $n$ sequencers publish their decryption shares of the election private key. Once the threshold is reached, the election secret key can be reconstructed (on-chain or off-chain), enabling the decryption of the aggregated tally.
102
103Rewards and penalties for sequencers are managed according to their correct participation: sequencers are rewarded proportionally to the number of votes sequenced, and may be slashed for failing to provide a valid decryption share (INCENTIVATION MECHANISM).
104
105At this point:
106\begin{itemize}
107 \item Anyone can verify the correctness of the final results by checking the \ac{ZK-SNARK} state proofs and on-chain commitments.
108 \item The combination of the final state root, the decryption of the accumulators, and the publicly verifiable \ac{ZK-SNARK} proofs guarantees the integrity of the entire election.
109\end{itemize}
110
111The election is considered finalized once the decrypted tally is available and all state transition proofs have been verified on-chain. At this stage, both the election results and the complete integrity of the process are permanently recorded and publicly auditable.}
112
113\begin{figure}%[H]
114 \centerline{\includegraphics[width=370pt,draft=false]{\figs/protocol-flow}}
115 \caption{Vocdoni voting process overview. {\color{blue}Figure is OUTDATED.}}
116 \label{fig:protocol-flow}
117\end{figure}