arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
davinci-paper/v2/sections/vocdoni-protocol.tex
v2/sections/vocdoni-protocol.texRaw
  1% !TeX root = ../build/main.tex
  2
  3\martai{Is the process called voting? Election, poll?}
  4
  5\subsection{Parties involved}
  6\label{sec:vocdoni-protocol:parties}
  7
  8A voting process involves three types of participants: the organizer, the sequencer, and the voters.
  9
 10\paragraph{Organizer.} The organizer is the entity responsible for defining and setting up the voting process. Its key responsibilities include defining the voting parameters and gathering the census data. The organizer ensures that the election is structured correctly but does not participate in vote collection or tallying.
 11
 12\paragraph{Sequencer.} Sequencers are a set of decentralized parties that facilitate the voting process. On the one hand, they collaboratively generate a public encryption key that voters use to encrypt their votes. Then, during the voting phase, they receive and verify encrypted votes from voters and reencrypt votes to prevent coercion.
 13 
 14\paragraph{Voter.} Voters are the participants that belong the census that cast their votes in the election. 
 15
 16\subsection{Components}
 17\label{sec:vocdoni-protocol:components}
 18
 19\subsubsection{Merkle trees} 
 20
 21\textit{Old text: Merkle trees are employed to create a cryptographic representation of both the voter registry (census) and the voting process state:
 22	\begin{itemize}
 23		\item \textbf{Census}: Each voter is assigned a Merkle proof, which they use to prove their eligibility to vote. This mechanism ensures efficient and secure verification of voter eligibility.
 24		\item \textbf{State}: The voting process state is represented as a Merkle tree, with new votes being added to the tree. The root of this Merkle tree is stored on Ethereum, allowing multiple sequencers to participate in the voting phase and ensuring consistency. 
 25\end{itemize}}
 26
 27\paragraph{Census Merkle tree.} Explain what it is. \\
 28
 29\martai{It could actually be another type of data structure. We only need to be able to get a commitment and a membership proof that can be proven in-circuit. Mention it in some way.}
 30
 31\paragraph{State Merkle tree.} Explain what it is and the structure. Below, the original text:\\
 32
 33The State tree contains some special addresses (indices) for storing some required data regarding the voting process:
 34
 35\begin{itemize}
 36	\item Address \texttt{0x0}: it stores \processid, a unique identifier for the voting process.
 37	\item Address \texttt{0x1}: it stores \censusroot and \type, which contains the necessary information to validate vote proofs.
 38	\item Address \texttt{0x2}: it stores \ballotmode, which encodes rules for validating votes, such as the maximum number of selectable options.
 39	\item Address \texttt{0x3}: it stores the \epk, which is the public key used to encrypt the votes.
 40	\item Address \texttt{0x4}: it stores the \addaccumulator. That is, the aggregated encrypted voting results that need to be added.
 41	\item Address \texttt{0x5}: it stores the \substractaccumulator. That is, it stores the aggregated encrypted voting results that need to be subtracted.
 42	\item Any address: vote \addresses: are stored within the State tree pointing to a voter's identity commitment. Each commitment is a 32-byte hash derived from the voter's unique information and a secret.
 43	\item Any address: vote \nullifiers: are stored within the State tree to prevent double voting and to allow vote overwrite. Each nullifier is a 32-byte hash derived from the voter's commitment and a secret.
 44\end{itemize}
 45
 46\begin{figure}[h]
 47sd	\centerline{\includegraphics[width=400pt,draft=false]{\figs/mt-state}}
 48	\caption{Structure of the state Merkle tree (FIGURE SHOULD BE POLISHED).}
 49	\label{fig:mt-state}
 50\end{figure}
 51
 52\textbf{The Initial State}: The voting process begins with an initial state where the Merkle Tree Root is established and published on the Process Management smart contract. Predefined parameters are included, but the results are initialized to zero, and no nullifiers are present. The Process Organizer transaction, contains the initial root and the necessary Merkle proofs. These proofs verify that the initial parameters are correct according to the voting process information and that no additional information is stored. Since the `ProcessId` of the initial state is a unique identifier, there won't be duplicate roots for different processes.
 53
 54
 55\subsubsection{Smart contracts}
 56
 57\paragraph{Process management.} This smart contract is responsible for the life-cycle management of voting processes. It includes the initiation, monitoring, execution, and closure of voting events.
 58
 59\paragraph{Sequencer registry.} For each voting process, this smart contract maintains the integrity of the cast votes and process life cycle. It verifies that each state transition committed by a sequencer adheres to the predefined rules.
 60
 61\paragraph{Results verification.} This smart contract keeps track of the existing available sequencers, stores the collateral of the sequencers to ensure (that incentivizes) good behaviour, and is used to coordinate the distributed key generation when a new voting process is created.\\
 62
 63\martai{This is wrong. Explanation of SR and RV smart contracts are mixed, I don't know what I was thinking when I wrote it. We should also include a sentence about the management of sequencers.}
 64
 65
 66\begin{figure}[h]
 67	\centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-inputs}}
 68	\caption{Caption.}
 69	\label{fig:circuit-inputs}
 70\end{figure}
 71
 72
 73\subsubsection{Votes [I don't think this is the right place]}
 74
 75In the \davinci system, a vote comprises several components that work together to ensure secure, private, and verifiable voting. These components are:
 76\begin{align*}
 77		\vote = [	\processid, \censuspf, \commitment, \nullifier,	
 78				 	\encryptedballot, \zkproof, \signature ].
 79\end{align*}
 80\martai{In the code, the struct is just: address, commitment, nullifier and ballot. Check!}
 81
 82\martai{In the code, they call it vote, verifierVote. Alternative: envelope.}
 83
 84Below, we detail each component and its role in the voting process:
 85\begin{itemize}
 86	\item \processid: the process identifier is a unique 32-byte number that uniquely identifies a specific voting process. This variable encapsulates essential information about the voting, such as the rules and constraints for ballots and the unique identifier of the \davinci blockchain instance.
 87	\martai{what does the identifier (blockchain instance) mean?}
 88	%
 89	\item \censuspf: the census proof serves as the voter's identity verification mechanism, ensuring that only eligible voters can participate. Depending on the process configuration, the voter provides either a Merkle tree-based proof showing inclusion in the census true, or a credential issued by a trusted third party (e.g. from a credential service provider).
 90	%
 91	\item \commitment: the identity commitment is used to prevent a voter from registering multiple nullifiers and avoid collisions if different voters choose the same secret. The commitment is computed the following way:
 92	\[ \commitment = \hlget{\Hash}(\address \conc \processid \conc s)\]
 93	\martai{Link Hash function to function in Section\ref{sec:cryptographic-primitives}.}
 94	{\it Old text:
 95	\begin{itemize}
 96		\item Stored in state Merkle tree (SMT): indexed by the voter's address.
 97		\item Prevents multiple registrations: each address can have only one commitment, ensuring a voter cannot register multiple secrets.
 98		\item Collision resistance: including the address in $\commitment$ ensures that commitments are unique even if voters choose the same secret $s$.
 99	\end{itemize}
100	
101	The secret $s$ can be implemented from different ways or a combination of them, such as:
102	
103	\begin{itemize}
104		\item A secure enough password introduced by the user.
105		\item A signature of a specific text.
106		\item A random input that the user must store to allow potential vote overwrite.\\
107	\end{itemize}}
108	%
109	\item \nullifier: the nullifier is a 32-byte hash used to prevent double voting. It is computed the following way:
110	\[\nullifier = \hlget{\Hash}(\commitment || s) \]
111	\martai{Link Hash function to function in Section\ref{sec:cryptographic-primitives}.}
112	That is, it ensures that each voter can either cast only one vote or overwrite their previous vote. By means of nullifiers, voters can submit a new vote with the same nullifier to replace their previous vote. Moreover, nullifiers provide users' anonymity, since nullifiers cannot be linked back to the voter's identity without knowledge of the secret $s$.
113	%
114	\item \encryptedballot: it contains the voter's selections encoded according to the ballot protocol rules. To ensure privacy, the ballot is encrypted using an homomorphic encryption scheme, which allows homomorphic combination of encrypted votes. More specifically, given the voter's choice $m$, the vote is encoded as follows:
115	\[ \encryptedballot = \hlget{\Enc}(m). \]
116	%
117	\item \zkproof: the voter generates a ZK proof to prove the correctness of the ballot and encryption process:
118	\[ \zkproof = \text{Prove(), Circuit()}. \]
119	This proof proves the correct computation of the vote encryption, the nullifier, the commitment, and the compliance with the ballot protocol rules.
120	%
121	\item \signature: the signature authenticates the vote and ensure that was cast by a legitimate voter. The voter signs necessary components using their private key, depending on the census configuration (e.g., ECDSA, EdDSA, RSA).	
122	\[ \signature = \text{Sign(xxx)}. \]
123\end{itemize}
124
125\subsection{Circuits}
126\label{sec:vocdoni-protocol:circuits}
127
128\martai{The idea of this section is to describe the circuits. Then, in Section~\ref{sec:analysis:implementation} we give the details such as of the number of constants, framework used, etc. I haven't done this split yet.}
129
130\textit{Old text: By structuring the process this way, we ensure that voting can be performed from any device-including smartphones and web browsers-while keeping the sequencer's computational requirements within the capabilities of accessible, CPU-based machines with 64 GiB of memory.}
131
132\martai{I don't follow the above paragraph.}
133
134\martai{It is called Ballot Mode because we define some modes (like quadratic, etc.) that can be chosen by the organizer. Essentially, each of this modes has a special configuration, but in order to make it easier, the organizer only needs to choose which of the modes (configs) to apply.}
135
136\martai{It's convenient to name the proof associated to each circuit: a proof for this circuit is called [...].\\
137Answer: 1. ballotProof, 2. voteVerifier, 3. aggregator, 4. stateTransition.}
138
139\newpage
140\subsubsection{Voter circuit} 
141
142Figure~\ref{fig:circuit-voter} -- BN254.\\
143
144\noi Generated by the user when casting a vote, this circuit proves that the encrypted ballot is valid (i.e. follows the protocol rules) and that the nullifier and commitment are correctly generated.
145
146\begin{figure}[H]
147	\centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-voter}}
148	\caption{Voter circuit. All public values are framed in green.}
149	\label{fig:circuit-voter}
150\end{figure}
151
152\begin{mdframed}
153	\begin{minipage}[H]{1\textwidth}
154		\begin{spacing}{1.25}
155			\vspace{0.3cm}
156			\begin{center}{VOTER CIRCUIT}\end{center}
157			\textbf{Public inputs}
158				\begin{itemize}
159					\item $\public$ $\processid$: voting process identifier. 
160					\item $\public$ $\ballotmode$: ballot protocol configuration.
161					\item $\public$ $\epk$ ($EPK$): encryption public key.
162					\item $\public$ $\weight$: voter's weight.
163					\item $\public$ $C$: commitment.
164					\item $\public$ $N$: nullifier.
165					\item $\public$ $(C_1, C_2)$: encrypted ballot. 
166				\end{itemize}
167			\textbf{Private inputs}
168				\begin{itemize}								
169					\item \private $\address$: voter's address.
170					\item \private $\ballot$: plaintext voter's voting choice.
171					\item \private $s$: blinder factor (secret).
172					\item \private $k$: random scalar.
173				\end{itemize}
174			\textbf{Constraints} \\ \vspace{-0.4cm}		
175				
176				\emph{Vote encryption}. 
177				\begin{itemize}								
178					\item Correct encryption of the ballot: $(C_1, C_2) = \hlget{\Enc}_{\epk}(\ballot, k).$
179				\end{itemize}
180				\emph{Rules compliance}. 
181				\begin{itemize}								
182					\item The ballot meets the protocol rules (number of valid choices, etc.): $... + \weight$.
183				\end{itemize}
184				\emph{Vote commitment + nullification}. 
185				\begin{itemize}								
186					\item The commitment is correctly computed: $C = \text{Hash} (\address \conc \processid \conc s)$.
187					\item The nullifier is correctly computed: $N = \text{Hash}(C \conc s)$.
188					\item The voter knows the shared secret $s$.
189				\end{itemize}
190				\vspace{-0.3cm}
191		\end{spacing}
192	\end{minipage}
193\end{mdframed}
194
195\newpage
196\subsubsection{Authentication circuit}
197
198Figure~\ref{fig:circuit-authentication} -- BLS12-377.\\
199
200\noi Generated by the sequencer, this circuit transforms the vote proof to the BLS12-377 curve for native recursion and validates the user's eligibility in the census, as well as their signature.
201
202\begin{figure}[H]
203	\centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-authentication}}
204	\caption{Authentication circuit. All public values are framed in green.}
205	\label{fig:circuit-authentication}
206\end{figure}
207
208\begin{mdframed}
209	\begin{minipage}[H]{1\textwidth}
210		\begin{spacing}{1.25}
211			\vspace{0.3cm}
212			\begin{center}{AUTHENTICATION CIRCUIT}\end{center}
213			\textbf{Public inputs}
214			\begin{itemize}
215				\item \public $\voteproof$: voter's proof.
216				\item \public $\processid$: process identifier.
217				\item \public $\ballotmode$: ballot protocol configuration.
218				\item \public $\epk$ ($EPK$): encryption public key.
219				\item \public $(C_1, C_2)$: encrypted ballot.
220				\item \public $C$: commitment.
221				\item \public $N$: nullifier.		
222				\item \public $\weight$: voter's weight.
223				\item \public $\censuspf$: census membership proof.
224				\item \public $\censusroot$: census Merkle tree root.
225				\item \public $pk$: voter's address.
226				\item \public $\signature$: voter's signature.
227			\end{itemize}
228				\textbf{Constraints} \\ \vspace{-0.4cm}		
229			
230			\emph{Voter's proof verification.} 
231			\begin{itemize}
232				\item The vote zkProof is valid for the inputs provided: $P.Verify().$
233			\end{itemize}
234			\emph{Authentication + non-malleability.}
235			\begin{itemize}
236				\item The signature of the inputs provided is valid for the public key of the voter.
237			\end{itemize} 
238			\emph{Census membership.}
239			\begin{itemize}								
240				\item The address derived from the user public key is part of the census, and verifies the census proof with the user weight provided.
241			\end{itemize}
242			\vspace{-0.3cm}
243		\end{spacing}
244	\end{minipage}
245\end{mdframed}
246
247\newpage
248\subsubsection{Aggregation circuit}
249
250Figure~\ref{fig:circuit-aggregate} -- BW6-761.\\
251
252\noi This circuit accumulates multiple authenticated votes into a single proof. It also verifies that all accumulated votes belong to the same voting process.
253
254\begin{figure}[h]
255	\centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-aggregate}}
256	\caption{Aggregation circuit. All public values are framed in green.}
257	\label{fig:circuit-aggregate}
258\end{figure}
259
260\begin{mdframed}
261	\begin{minipage}[H]{1\textwidth}
262		\begin{spacing}{1.25}
263			\vspace{0.3cm}
264			\begin{center}{AGGREGATION CIRCUIT}\end{center}
265			\textbf{Public inputs}
266			\begin{itemize}
267				\item \public $\text{authenticationProof}$: set of authentication proofs.
268				\item \public $C_i$: set of commitments.
269				\item \public $N_i$: set of nullifiers.		
270				\item \public $\address_i$: list of voters' addresses.
271				\item \public $(C_1, C_2)$: list of voters' encrypted ballots.
272				\item \public $\weight_i$: Voters' weights.
273				\item \public $\processid$: process identifier.
274				\item \public $EPK$: encryption public key.
275				\item \public $\ballotmode$: ballot protocol configuration.
276				\item \public $\text{censusRoot}$: census Merkle tree root.
277			\end{itemize}
278			\textbf{Constraints} \\ \vspace{-0.4cm}		
279			
280			\emph{Votes aggregation.} 
281			\begin{itemize}
282				\item The accumulated zkProofs are valid.
283			\end{itemize}
284			\emph{Shared public inputs.}
285			\begin{itemize}
286				\item The ProcessId, CensusRoot, BallotMode and EPK is the same for all of them.
287			\end{itemize}
288			\vspace{-0.3cm}
289		\end{spacing}
290	\end{minipage}
291\end{mdframed}
292
293\newpage
294\subsubsection{State transition circuit} -- BN254. \\
295
296\noi Given the aggregated votes proof, this circuit verifies the correct inclusion of all new votes into the process's state Merkle tree. It generates the final state transition proof that will be validated by the Ethereum smart contract.
297
298\paragraph{Assertions.}
299
300\begin{itemize}
301	\item \emph{Aggregation verification}: The agreggated zkProof is valid.
302	\item \emph{Transition verification}: The MerkleTree transition witness proves every change between Root1 and Root2.
303	\item \emph{Public inputs integrity}: ProcessID, BallotMode, CensusRoot, EncryptionKey remain unchanged.
304	\item \emph{Votes counting}: Ballots are correctly counted as new or overwrites, and added to results accumulators.
305\end{itemize}
306
307\martai{The corresponding circuit figure is not done yet.}
308
309\noi \textit{Old original text, I think it will help here:}
310
311When a new voting process begins, the Sequencer initializes a new State, represented by the root hash of a Merkle tree. This tree encapsulates all essential information about the voting process, including process parameters, voter registry (census), ballot configurations, and initial results.
312
313For each new batch of votes, the Sequencer updates the state by generating a zkSNARK proof that \textbf{validates the state transition from the current Root to a new Root}. This proof is submitted on-chain for settlement. By doing so, we maintain an immutable and verifiable record of the voting process on the blockchain.
314
315This approach allows anyone to access the latest verified state of the voting process from the Results Verification smart contract, along with the necessary data to process subsequent state updates. The system's design enables multiple Sequencers to participate in tallying votes. They can take the current State Root and its associated data to construct the next state, incorporating new votes into the tally. This decentralization of Sequencers helps prevent potential censorship and reinforces the robustness of the voting process.
316
317\paragraph{Maintaining the Chain.}
318
319The chain of integrity is maintained through a combination of smart contract enforcement and strict zkSNARK circuit constraints. This ensures that each state transition is valid and builds upon the last accepted state without requiring additional mechanisms.
320
321\begin{itemize}
322	\item \textbf{Sequential state roots}: Each state transition updates the Merkle tree from a previous root (`Root1`) to a new root (`Root2`) after processing a batch of votes.
323	\item \textbf{Smart contract enforcement}: The smart contract verifies that the `Root1` provided in the zkSNARK proof matches the last committed state root stored on-chain. This guarantees that all transitions are sequential and based on the latest accepted state.
324	\item \textbf{Proof validation}: The smart contract uses the zkSNARK verification key to validate the submitted proof. A valid proof confirms that the transition from `Root1` to `Root2` adheres to all protocol rules enforced by the circuit.
325	\item \textbf{State update}: Upon successful verification, the smart contract updates the stored state root hash to`Root2`, ensuring an immutable and continuous chain of states.
326\end{itemize}
327
328\paragraph{State Transition}
329
330To validate and process state transitions, \textbf{we employ a zkSNARK circuit that enforces all protocol constraints}. This circuit proves that the transition from the previous state Root to the new state Root is valid based on the newly processed votes.
331
332\begin{figure}[H]
333	\centering
334	\fbox{
335		\includegraphics[scale = 0.12, draft = false]{\figs/state-transition.png}}
336\end{figure}
337
338\begin{figure}[H]
339	\centering
340	\fbox{
341		\includegraphics[scale = 0.3, draft = false]{\figs/circuit-inputs.png}}
342\end{figure}
343
344\begin{figure}[H]
345	\centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-state-transition}}
346	\caption{State transition circuit. All public values are framed in green.}
347	\label{fig:circuit-state-transition}
348\end{figure}
349
350\begin{mdframed}
351	\begin{minipage}[H]{1\textwidth}
352		\begin{spacing}{1.25}
353			\vspace{0.3cm}
354			\begin{center}{STATE TRANSITION CIRCUIT}\end{center}
355			\textbf{Public inputs}
356			\begin{itemize}
357				\item \public $root_{old}$: Merkle tree root before the state transition.
358				\item \public $root_{new}$: Meklre tree root after the state transition.
359				\item \public $blobCommitment$: the commitment to the data blob containing the new votes.
360				\end{itemize}
361				\item \textbf{Private inputs}
362				\begin{itemize}
363				\item \private Votes: The list of new votes being processed, including census proofs and authentication data.
364				\item \private Merkle Proofs of nullifier inclusion: Proofs that each voter nullifier is included in the census.
365				\item \private Merkle Proofs of results update: Proofs that the process results have been correctly updated.
366				\item \private Merkle Tree Update Witnesses: Necessary data (e.g., Merkle paths) to update the Merkle tree from Root1 to Root2.
367				\item \private Process Parameters: Retrieved from Root1 within the circuit.
368			\end{itemize}
369			\textbf{Constraints} \\ \vspace{-0.4cm}		
370			\begin{itemize}
371				\item \textbf{Immutable process parameters}: Ensure that critical process parameters (such as `censusRoot` or `processId`) retrieved from `Root1` remain consistent and are not altered in the transition.
372				\item \textbf{Vote validity}: Validate that each vote proof is correct.
373				\item \textbf{Voter eligibility}: Confirm that each voter is included in the census by verifying Merkle proofs of inclusion against the `censusRoot` retrieved from `Root1`.
374				\item \textbf{Nullifier non-existence}: Ensure that the nullifier for each vote does not exist in the current state (`Root1`), preventing double voting.
375				\item \textbf{Nullifier addition}: Correctly add each new nullifier to the state, resulting in `Root2`, updating the Merkle tree accordingly.
376				\item \textbf{Results update}: Ensure that the voting results are accurately updated by adding the new votes to the previous results retrieved from `Root1`, so that `results2 = results1 + votes`.
377				\item \textbf{Blob data integrity}: Confirm that the data used in the circuit (votes, nullifiers) corresponds to the `blobCommitment` provided as a public input, ensuring that the votes processed are exactly those published in the data blob.
378				\item \textbf{State transition validity}: Ensure that the new state root (`Root2`) is correctly computed from `Root1` by applying the validated votes and updates to the Merkle tree.
379			\end{itemize}
380			\vspace{-0.3cm}
381		\end{spacing}
382	\end{minipage}
383\end{mdframed}
384
385\subsection{Protocol flow}
386\label{sec:vocdoni-protocol:flow}
387
388In Figure~\ref{fig:protocol-flow} we describe the protocol flow.
389
390\martai{About the figure: layout should be fixed. In addition, the icons for the different parties are missing.}
391
392\begin{figure}[H]
393	\centerline{\includegraphics[width=400pt,draft=false]{\figs/protocol-flow}}
394	\caption{Vocdoni voting process overview.}
395	\label{fig:protocol-flow}
396\end{figure}
397
398\subsubsection{Prior to voting (only once)}
399\label{sec:vocdoni-protocol:prior-steps}
400
401\martai{Remove the first step, we assume contracts are already deployed or at least, the logic is available.}
402
403This is done only once. Then every voting will start its process from step in Section~\ref{sec:vocdoni-protocol:start}.
404
405Vocdoni:
406\begin{enumerate}
407	\item Deployment of the 3 smart contracts.
408	\item Sequencers registry starts (it doesn't end).
409\end{enumerate}
410
411Sequencers (nodes validadors) -- this process is always open:
412\begin{enumerate}
413	\item Register this and that way.
414	\item Public keys?
415	\martai{Sequencers must also publish how they can be reached (either when they register or when they contribute to the DKG). They can use a URI: Uniform Resource Identifier.}
416	\item PROVIDE COLLATERAL.
417	\martai{What happens to the collateral? If done only once, then you lose it? Do you need to send a new tx with more collateral?}
418	\item Send transaction to Sequencer registry smart contract (pay for tx fee).
419\end{enumerate}
420
421\subsubsection{Start of the voting process}
422\label{sec:vocdoni-protocol:start}
423
424The organizer:
425\begin{enumerate}
426	\item Prepares the census data \texttt{census\_data}.
427	\item Generates the census commitment \texttt{MT\_census.root = Com(census\_data)}.
428	\martai{In general, make use (link) to the functions defined in Section~\ref{sec:cryptographic-primitives}. For example, here the \texttt{MT.root()}.}
429	\martai{Additionally, after this step, the organizer should make a Merkle proof available to all eligible voters.}
430	\item Set voting details: duration, options, type, etc. + CENSUS MT ROOT.
431	\item Also a timeout for the DKG ceremony + minimum number of sequencers.
432	\item Send transaction to the Ethereum process management smart contract with all data. Note this transaction has a cost (Eth tx fees) that needs to be covered by the organizer.
433\end{enumerate}
434
435\subsubsection{Key generation process} %Voting key generation
436\label{sec:vocdoni-protocol:dkg}
437
438The sequencer:
439\begin{enumerate}
440	\item Download all required data from the PM smart contract which includes the census MT root to handle the new vote.
441	\item Make contributions to DKG ceremony.
442\end{enumerate}
443
444After XXX time (set by the organizer in the PM contract?): all contributions to DKG are done.
445
446\martai{The organizer decides a minimum number of sequencers (security factor).}
447	
448\begin{itemize}
449	\item EPK ``becomes available".
450	\martai{I understand EPK becomes available in the SR smart contract, and that key is sent to the PM contract?}
451	\martai{The idea here is that some sequencer makes EPK available (a.k.a. sends a transaction). Alternatively, generate a SNARK proving the EPK has been generated correctly and the SC verifies it.}
452\end{itemize}
453
454\subsubsection{Voting process}
455\label{sec:vocdoni-protocol:voting}
456
457Voter:
458
459\begin{itemize}
460	\item Choose any of the available sequencers (from?? -- from the SR SC).
461	\item Fetch their census \textbf{Merkle proof} to prove eligibility (from the census registry).
462	\item Use the EPK to encrypt the voting choice.
463	\item Generate ZK-SNARK of satisfiability of circuit from Fig.~\ref{fig:circuit-voter} with protocol from Section~\ref{sec:cryptographic-primitives:zkp} to prove the validity of the encrypted vote and adherence to ballot protocol rules. We call this proof \textbf{vote proof}.
464	\item Send the encrypted vote, Merkle proof, validity proof, and identity proof to the sequencer.
465	\martai{I understand Validity proof refers to ``voter circuit"? Merkle proof is for inclusion, right? And identity proof is for example a signature??}
466\end{itemize}
467
468Sequencer:
469
470\begin{itemize}
471	\item Fetch current state: retrieve the current valid process state root from the Etherem smart contract and the associated data from Ethereum blobs.
472	\martai{specify which SC.}
473	\item Generate a SK-SNARK proof of state transition proving:
474		\begin{itemize}
475			\item the validity of the ZK-SNARK proof provided by the voter,
476			\item the correct accumulation of votes from users, adding them to the process state,
477			\item the correct sum of the new encrypted votes using the homomorphic properties of ElGamal,
478			\item the new votes are from eligible users by checking the census Merkle proofs,
479			\item the new voters have not already voted by checking their nullifiers, or it is a correct vote overwrite,
480			\item the data blob hash matches the data used to verify the transition.
481		\end{itemize}
482	\item Submit updated state: send the new state root to the smart contract and store the updated data in Ethereum blobs.
483\end{itemize}
484
485Sequencers keep accumulating votes and create state transition until the finalization of the process.
486
487\martai{I understand this finalization is a deadline set by the organizer.}
488
489SC:
490
491\begin{itemize}
492	\item Upon receiving a sequencer's transaction, the SC verifies the zk-SNARK proof provided byt he sequencer.
493	\item Ensure the origin root corresponds to the current stored state root.
494	\item Confirm that the blob hash matches the one stored in Ethereum.
495\end{itemize}
496
497\subsubsection{Results validation}
498\label{sec:vocdoni-protocol:validation}
499
500Once the voting is completed (I understand the timeout set by the organizer expires), the following things happen.
501
502Sequencer:
503
504\begin{itemize}
505	\item $t$ out of $n$ sequencers publish their shares corresponding to the EPK to the Ethereum smart contract.
506	\martai{specify which SC.}
507	\item When the threshold of shares is reached, the results can be decrypted by anyone.
508	\martai{mention that the SC computes the corresponding ESK, or that can be computed by anyone off-chain, since all info is public.}
509	\item Sequencers receive reward for their correct participants depending on the number of sequenced votes.
510	\martai{slash if they don't provide the right share? reward only dependent of sequenced votes? any relation to their participation in the computation of either EPK or ESK?}
511\end{itemize}
512
513This way:
514
515\begin{itemize}
516	\item After the voting period ends and the results are decrypted, anyone can verify the correctness of the final result.
517	\martai{explain how.}
518	\item Use the zkSNARK state proof and publicly available data on-chain to ensure the integrity and correctness of the entire voting process.
519	\martai{elaborate on this.}
520\end{itemize}
521
522\subsubsection{Finalization of the voting process}
523\label{sec:vocdoni-protocol:finalization}