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%\noi \sequencers
13%Sequencers 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. \\
14
15\noi For each new election, the organizer performs the following steps:
16\begin{enumerate}
17 \item Prepare the census data \censusdata\ and generate the census Merkle tree $\censusTree$ with that data.
18 \item Compute the census commitment $\censusroot = \censusTree.\hlget{\MTRoot}()$.
19 \item Prepare the voting form (ballot / set of questions), upload it to IPFS, compute commitment.
20 \item Define the election details, including duration, options, and the ballot rules $\ballotmode$ (see Section~\ref{sec:ballot-protocol}).
21 \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.
22 \item Set security parameters for the %forthcoming
23 DKG ceremony (e.g., timeout, minimum number of sequencers).
24 \item Submit all this information in a transaction to the \hlget{\electionregistry} smart contract {\color{blue}(pay tx fees)}:
25 \[ tx_{org} = (\censusroot, ballotCommitment, \ballotmode, electionMetadata, \processid, dkgParameters).\]
26\end{enumerate}
27
28\subsubsection{Encryption key generation}
29\label{sec:vocdoni-protocol:keygen}
30
31In this phase, \keywardens collectively generate the public encryption key.\\
32
33\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)}.\\
34
35\noi {\color{blue} Alternatively, generate a SNARK proving the EPK has been generated correctly and the contract verifies it.}
36
37\subsubsection{Voting period}
38\label{sec:vocdoni-protocol:votes}
39
40In this phase, voters cast their ballots and send them to the sequencers, who collect and process them. \\
41
42\noi \textbf{(a) Vote casting.} To cast a ballot, a voter does the following:
43
44\begin{enumerate}
45 {\color{red}
46 \item Select a sequencer from the sequencer registry smart contract.}
47 \item Retrieve their census membership proof $\censusproof$ to prove eligibility.
48 \item Fetch parameters $\epk$, $\ballotmode$, and $\processid$ from the \hlget{\electionregistry} smart contract.
49 \item Select their ballot choice $\ballot$ according to the rules of $\ballotmode$.
50 \item Sample fresh randomness $k \in \F$ and encrypt the ballot using $\epk$:
51 \begin{equation}
52 \label{eq-ciphertext}
53 \encryptedballot = \hlget{\Enc}_{\epk}(\ballot; k).
54 \end{equation}
55 \item Use their Ethereum address $\address$ and the previous $k$ to compute a unique vote identifier:
56 \begin{equation}
57 \label{eq-voteid}
58 \voteid = \hlget{\Multimimc}(\processid \conc \address \conc k).
59 \end{equation}
60 \item Use the \ballotcircuit from 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 the ballot protocol rules according to $\ballotmode$:
61 \begin{align*}
62 \voteproof = & \hlget{\PProve}(
63 \hlget{\ballotcircuit},
64 \witness = (\ballot, k),
65 \publicinputs = (\processid, \ballotmode,\\
66 &\epk, \address, \weight, \encryptedballot, \voteid)).
67 \end{align*}
68 \item Sign the vote identifier with their Ethereum secret key $\sk$ to authenticate the vote and ensure that was cast by a legitimate voter:
69 \[ \signature = \hlget{\SSign}_{\sk}(\voteid).\]
70 \item Submits the package
71 \[\vote = [\processid, \voteid, \encryptedballot, \censusproof, \voteproof, \signature]\]
72 to the chosen sequencer.
73\end{enumerate}
74
75%\item Sign $\voteid$ using the user's secret key $\sk$ to authenticates the vote and ensure that was cast by a legitimate voter:
76%\[ \signature = \hlget{\SSign}_{\sk}(\voteid).\]
77%\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:
78%\[ \vote = [ \processid, \voteid, \encryptedballot, \censuspf, \voteproof, \signature ]. \]
79
80\noi \textbf{(b) Vote batching.} Upon receiving votes, a sequencer does the following:
81
82\begin{enumerate}
83 \item Retrieve election identifier $\processid$, current state root $\stateroot$, and census root $\censusroot$ from the \hlget{\electionregistry} smart contract and the associated data from the Ethereum data blobs.
84 \item Upon receiving a vote
85 \[\vote_i = [\processid, \voteid, \encryptedballot, \censusproof, \voteproof, \signature],\]
86 extract the voter's public key $\pk_i = \hlget{\SPubKey}(\signature)$.
87 \item For each $\vote_i$ received, use \verifiercircuit from Section~\ref{sec:vocdoni-protocol:circuits:verifier} to generate a proof
88 \begin{align*}
89 \authenticationproof_i = & \hlget{\PProve}(\hlget{\verifiercircuit},
90 \witness = (\ballotproof, \weight, \censusproof, \signature),\\
91 & \publicinputs = (\processid, \ballotmode, \epk, \encryptedballot, \voteid, \\
92 & \censusroot, \pk)).
93 \end{align*}
94 This proof ensures that the voter’s \voteproof, the \signature, and the \censusproof are all valid.
95 \item Batch a set of $n$ proofs $\{\authenticationproof_i\}_{i = 1}^n$ and batch verify them together using \aggregationcircuit from Section~\ref{sec:vocdoni-protocol:circuits:aggregation}:
96 \begin{align*}
97 \aggregationproof = &\hlget{\PProve}(\hlget{\aggregationcircuit},
98 \witness = (\{\authenticationproof_i\}_{i = 1}^n),\\
99 &\publicinputs = (\encryptedballot, \{\voteid_i\}_{i = 1}^n),
100 \{\pk_i\}_{i = 1}^n,
101 \processid,
102 \ballotmode,\\
103 &
104 \epk,
105 \censusroot
106 ).
107 \end{align*}
108 This proof ensures that the public inputs corresponding to the global process parameters ($\processid$, $\ballotmode$, $\epk$, $\censusroot$) are correct and that all $\authenticationproof_i$ are valid.
109
110 \item Prepare the state transition data that will be stored in an Ethereum blob: pack votes/results into a 4096-cell blob \blobdata.
111 \begin{itemize}
112 \item Compute data commitment $\blobcom = \hlget{\CCommit}(\blobdata)$.
113 \item Derive evaluation point $\evalpoint = \hlget{\Poseidon}(\processid, oldRoot, batchNum, nonce).$
114 \item Prepare polynomial $P$ from $\blobdata$.
115 \item Evaluate $y = P(\evalpoint)$.
116 \item Generate opening proof $\openproof$ from $...$.
117 \item The following step (circuit) will prove that $y = P(\evalpoint)$.
118 \end{itemize}
119
120 \item {\color{blue}Before doing state transitions, we need to prepare the data that will be stored on chain as a blob. Hence, collect xxxx, create commitment. In circuit (next step), we will prove that... .}
121
122 \item Finally, prove that all transitions are correct .... with circuit from Section~\ref{sec:vocdoni-protocol:circuits:state-transition}.
123 consistency between data blobs and the on-chain state:
124
125 \begin{align*}
126 \stateproof = \hlget{\PProve}(\hlget{\statetransitioncircuit},
127 \witness = (), \publicinputs = ()).
128 \end{align*}
129
130 \item Verify each $\vote$ submission received by generating a state transition proof (see Section~\ref{sec:vocdoni-protocol:circuits:state-transition}), ensuring:
131 \begin{itemize}
132 \item correct accumulation of encrypted votes via ElGamal’s homomorphic properties,
133 \item eligibility of voters (via census Merkle proofs),
134 \item absence of double voting (or correct handling of overwrites via nullifiers),
135 \end{itemize}
136 \item Compute blob commitment TAL.
137 \item Submit the updated state root to the smart contract, while the full data are stored in Ethereum blobs.
138 \martai{If \stateroot changed, repeat last circuit.}
139\end{enumerate}
140
141Sequencers repeat this process until the voting deadline set by the organizer.
142
143Upon receiving a valid transaction, the \electionregistry smart contract does the following checks:
144
145\subsubsection{Decryption key generation}
146\label{sec:vocdoni-protocol:deckey-gen}
147
148\subsubsection{Tally finalization}
149\label{sec:vocdoni-protocol:results}
150
151{\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.
152
153Rewards 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).
154
155At this point:
156\begin{itemize}
157 \item Anyone can verify the correctness of the final results by checking the \ac{ZK-SNARK} state proofs and on-chain commitments.
158 \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.
159\end{itemize}
160
161The 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.}
162
163\begin{figure}%[H]
164 \centerline{\includegraphics[width=370pt,draft=false]{\figs/protocol-flow.pdf}}
165 \caption{Vocdoni voting process overview. {\color{blue}Figure is OUTDATED.}}
166 \label{fig:protocol-flow}
167\end{figure}