work on the ballot protocol and protocol-flow
@@ -1,39 +1,44 @@
% !TeX root = ../build/main.tex -The ballot protocol provides a unified and parametric way to represent a wide range of voting systems within \davinci. Instead of designing a separate circuit for each voting rule, the protocol defines ballots as fixed-length arrays of integers, subject to a small set of configurable parameters. These parameters constrain the values that can appear in each field of the ballot and the aggregate properties of the ballot as a whole. By adjusting these parameters, the same circuit can implement approval voting, ranking, quadratic voting, multiple choice, and many other schemes. - -This abstraction has two key advantages. First, it allows a broad variety of voting systems to be supported with a minimal circuit design, avoiding conditional logic that would otherwise increase constraint counts. Second, it provides a common interface for tallying, since all ballots are aggregated into a single results array regardless of the voting mode. +The ballot protocol provides a unified and parametric way to represent a wide range of voting systems within \davinci. Instead of designing a separate circuit for each voting rule, the protocol defines ballots as fixed-length arrays of integers, subject to a small set of configurable parameters. These parameters constrain the values that can appear in each field of the ballot and the aggregate properties of the ballot as a whole. By adjusting these parameters, the same circuit can implement approval voting, ranking, quadratic voting, multiple choice, and many other schemes. In the protocol we refer to the different configurations as the \emph{ballot mode} ($\ballotmode$). This abstraction has two key advantages. First, it allows a broad variety of voting systems to be supported with a minimal circuit design, avoiding conditional logic that would otherwise increase constraint counts. Second, it provides a common interface for tallying, since all ballots are aggregated into a single results array regardless of the voting mode. \paragraph{Definition of parameters.} -Each ballot is defined as an array of integer values subject to the following configurable parameters: +%Each ballot is defined as an array of integer values subject to the following configurable parameters: +Each ballot is defined as an array of integer values subject to a set of configurable parameters. These parameters are defined as follows: \begin{itemize} - \item \numfields: the maximum number of fields (i.e., options) in the ballot. - \item \minvalue, \maxvalue: the allowable range for each field value. - \item \uniquevalues: a Boolean flag specifying whether all field values must be distinct (as in ranking systems). - \item \costexponent: the exponent applied when computing the cost of casting votes in a field; this parameter enables quadratic or higher-order voting rules. - \item \minvaluesum, \maxvaluesum: bounds on the total sum of all field values in a ballot (e.g., to enforce a budget of credits). + \item \numfields: the maximum number of fields (i.e., options) in the ballot. + \item \minvalue: the minimum value that each field in the ballot can take. + \item \maxvalue: the maximum value that each field in the ballot can take. + \item \uniquevalues: a Boolean flag indicating whether all field values must be distinct (as in ranking systems). + \item \costexponent: the exponent applied when computing the cost of casting votes in a field. This parameter enables quadratic or higher-order voting rules. + \item \minvaluesum: the minimum total sum of all field values in a ballot. + \item \maxvaluesum: the maximum total sum of all field values in a ballot (e.g., to enforce a budget of credits). \end{itemize} +%\begin{itemize} +% \item \numfields: the maximum number of fields (i.e., options) in the ballot. +% \item \minvalue, \maxvalue: the allowable range for each field value. +% \item \uniquevalues: a Boolean flag specifying whether all field values must be distinct (as in ranking systems). +% \item \costexponent: the exponent applied when computing the cost of casting votes in a field; this parameter enables quadratic or higher-order voting rules. +% \item \minvaluesum, \maxvaluesum: bounds on the total sum of all field values in a ballot (e.g., to enforce a budget of credits). +%\end{itemize} \begin{figure}[H] \centering \fbox{ \includegraphics[scale = 0.4, draft = false]{\figs/ballot-variables.png}} + \caption{Schematic representation of the parameters that define a ballot in \davinci{ }{\color{blue}(variable names are outdated)}.} \end{figure} \paragraph{General mechanism.} -A ballot is valid if and only if all the above constraints are satisfied. Invalid ballots are rejected at the circuit level and do not contribute to the tally. Valid ballots are aggregated into a results array, where each entry is the sum of all votes cast for the corresponding field across all voters. This unified representation ensures that tallying can be performed efficiently, independently of the chosen voting system, and that verification inside zero-knowledge circuits remains simple. - -Figure~\ref{fig:ballot-modes} illustrates several concrete instantiations of this protocol, showing how different voting systems can be realized by selecting appropriate parameter values. -%The examples in Table~\ref{tab:ballot-modes} are not exhaustive. Other systems, such as cumulative voting, weighted scoring, or variations of ranked-choice voting, can be instantiated within the same framework by adjusting the protocol parameters accordingly. This flexibility illustrates the expressiveness of the ballot protocol and its suitability as a general-purpose abstraction for representing diverse voting rules in a unified way. +A ballot is valid if and only if all the above constraints are satisfied. Invalid ballots are rejected at the circuit level and do not contribute to the tally. Valid ballots are aggregated into a results array, where each entry is the sum of all votes cast for the corresponding field across all voters. Voter weights, defined in the census tree (see Section~\ref{sec:vocdoni-protocol:merkle-trees:census}), are taken into account when computing these sums. By default, all voters have the same weight, but the protocol also supports weighted voting, where different participants may contribute proportionally to their assigned voting power. In this case, \maxvaluesum\ reflects the maximum weight assigned to each voter, and the ballot and verifier circuits enforce that the correct weight is being used (see Sections~\ref{sec:vocdoni-protocol:circuits:ballot} and~\ref{sec:vocdoni-protocol:circuits:verifier} for further details). -\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.} +\paragraph{Ballot modes.} +Ballot modes correspond to different voting systems, each adjusted with the variables above ballot configurations. For usability, the organizer does not need to set every parameter manually: instead, they simply select one of the predefined ballot modes (e.g., quadratic voting, ranking, approval), each corresponding to a fixed parameter configuration. Some representative modes are shown in Figure~\ref{fig:ballot-modes}, which illustrate the expressiveness of the ballot protocol. For example, in \emph{approval voting}, each field is binary and voters can approve or reject multiple options simultaneously. In \emph{ranking}, fields must form a permutation of the integers from $1$ to $N$, enforcing uniqueness of values. In \emph{quadratic voting}, voters allocate credits across options, and the cost is quadratic in the number of credits used, captured by setting \costexponent$=2$. Other systems such as single-choice or multiple-choice elections are special cases of the same framework. The figure also illustrates examples of voters' ballots, with the last column indicating whether each ballot is valid or invalid under the rules of the selected mode. %\begin{landscape} \begin{figure}[h] \centerline{\includegraphics[width=\textwidth,draft=false]{\figs/ballot-protocol-table.png}} - \caption{Table showing various voting models using different ballot configurations.} + \caption{Table showing various voting models using different ballot configurations. Each row corresponds to a voting system specified by a fixed configuration of the ballot parameters (\numfields, \minvalue, \maxvalue, \uniquevalues, \costexponent, \minvaluesum, \maxvaluesum). The table also includes example ballots for each mode, illustrating how the constraints are enforced in practice. The last column indicates whether a ballot is valid (1) or invalid (0) under the rules of the selected mode.} \label{fig:ballot-modes} \end{figure} -%\end{landscape} - -\martai{Mention the weight! Which is maxValueSum!}+%\end{landscape}
@@ -0,0 +1,272 @@
+% !TeX root = ../build/main.tex + +At the core of \davinci lie a set of arithmetic circuits that enforce the correctness of every step of the voting process. Each circuit corresponds to a distinct task and, taken together, they guarantee that all protocol rules are satisfied without revealing any private information. Specifically, the \emph{ballot circuit} (Section~\ref{sec:vocdoni-protocol:circuits:ballot}) ensures that encrypted votes are valid and well-formed, the \emph{verifier circuit} (Section~\ref{sec:vocdoni-protocol:circuits:verifier}) verifies voter eligibility and census membership; the \emph{aggregation circuit} (Section~\ref{sec:vocdoni-protocol:circuits:aggregation}) combines multiple authenticated votes into a single proof; and the \emph{state transition circuit} (Section~\ref{sec:vocdoni-protocol:circuits:state-transition}) updates the global state root and produces the ZK-SNARK proof that is verified on-chain. The flow of these circuits and their interactions is shown in Figure~\ref{fig:circuits-flow}. + +\begin{figure}[h] + \centerline{\includegraphics[width=\linewidth,draft=false]{\figs/circuits-flow-v2}} + \caption{ + Overview of the circuit flow in \davinci.} + \label{fig:circuits-flow} +\end{figure} + +For clarity, the circuits are described in this section with their full set of public inputs explicitly listed. In the actual implementation, however, we apply an optimization: rather than exposing all public inputs individually, we compute a single commitment $h = Hash(PI)$ and use $h$ as the only public input. The proof verifier then checks that $Hash(PI) = h$, ensuring that the original public inputs are consistent while reducing both proof size and verification cost. In \davinci, this commitment is computed using the MiMC-7 hash function {\color{blue}(use hlget to point "Hash" to MiMC-7)}. Note that this optimization does not alter the semantics of the circuits but significantly reduces verifier complexity and on-chain verification costs. Other implementation aspects such as the exact number of constraints and the proving frameworks used are deferred to Section~\ref{sec:analysis:implementation}. + +% 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. + +\subsubsection{Ballot circuit} +\label{sec:vocdoni-protocol:circuits:ballot} + +The ballot circuit, illustrated in Figure~\ref{fig:circuit-ballot}, is generated locally by the voter at the time of casting a ballot. Its purpose is twofold: first, to prove that the encrypted ballot is valid and complies with the protocol rules defined by the organizer; and second, to prove that the vote identifier (\voteid) has been correctly derived. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BN254 curve. We call the resulting proof \textit{ballot proof} and denote it as $\hlset{\ballotproof}$. We detail below the inputs and constraints of the ballot circuit. + +\begin{spacing}{1.25} + \vspace{0.3cm} + \noi \textbf{Public inputs} + \begin{itemize} + \item $\public$ $\processid$: voting process identifier. + \item $\public$ $\ballotmode$: ballot protocol configuration.S + \item $\public$ $\epk$ ($EPK$): encryption public key. + \item $\public$ $\address$: voter's address. + \item $\public$ $\weight$: voter's weight. + \item $\public$ $(C_1, C_2)$: encrypted ballot. + \item $\public$ $\voteid$: vote's unique identifier. + \end{itemize} + \textbf{Private inputs} + \begin{itemize} + \item \private $\ballot$: plaintext voter's voting choice. + \item \private $k$: random scalar. + \end{itemize} + \textbf{Constraints} + \begin{itemize} + \item \emph{Vote encryption}. Correct encryption of the ballot: $(C_1, C_2) = \hlget{\Enc}_{\epk}(\ballot; k).$ + \item \emph{Protocol rules compliance}. The ballot meets the protocol rules (number of valid choices, etc.): $... + \weight$. + \item \emph{Vote identifier}. The vote's identifier is correctly computed: $\voteid = \text{Hash} (\processid \conc \address \conc k).$ + \end{itemize} + \vspace{-0.3cm} +\end{spacing} + +\begin{figure}[H] + \centerline{\includegraphics[width=420pt,draft=false]{\figs/circuit-voter}} + \caption{Ballot circuit. All public values are framed in green.} + \label{fig:circuit-ballot} +\end{figure} + +\subsubsection{Verifier circuit} +\label{sec:vocdoni-protocol:circuits:verifier} + +The verifier circuit, illustrated in Figure~\ref{fig:circuit-verifier}, is generated by the sequencer when processing a vote. This circuit verifies the ballot's proof generated by the voter and it also validates the voter’s eligibility in the census and the correctness of their digital signature. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BLS12-377 curve. We call the resulting proof the \textit{authentication proof} and denote it as $\hlset{\authenticationproof}$. We detail below the inputs and constraints of this circuit. {\color{blue}-- Authentication of verification proof?} + +\begin{spacing}{1.25} + \vspace{0.3cm} + \noi \textbf{Public inputs} + \begin{itemize} + \item \public $\processid$: process identifier. + \item \public $\ballotmode$: ballot protocol configuration. + \item \public $\epk$ ($EPK$): encryption public key. + \item \public $(C_1, C_2)$: encrypted ballot. + \item \public $\voteid$: voter's identifier. + \item \public $\censusroot$: census Merkle tree root. + \item \public $\pk$: voter's public key. + \end{itemize} + \textbf{Private inputs} + \begin{itemize} + \item \private $\ballotproof$: voter's ballot proof. + \item \private $\weight$: voter's weight. + \item \private $\censuspf$: census membership proof. + \item \private $\signature$: voter's signature. + \end{itemize} + \textbf{Constraints} + \begin{itemize} + \item \emph{Voter's proof verification.} The vote zkProof is valid for the inputs provided: + $$\hlget{\PVerify}\left(\ballotproof, PI = (\processid, \ballotmode, \epk, (C_1, C_2), \voteid, \weight)\right).$$ + \item \emph{Census membership.} The address derived from the user's public key is part of the census, and verifies the census proof with the user's weight provided: + $$ \hlget{\censusTree}.\hlget{\MTMembershipProof}(\weight, \address = \hlget{\Keccak}(\pk), \censuspf, \censusroot). $$ + \item \emph{Authentication + non-malleability.} The signature of the vote's identifier is valid for the given public key: + $$ \hlget{\SVer}_{\pk}(\voteid, \signature). $$ + \end{itemize} + \vspace{-0.3cm} +\end{spacing} + +\begin{figure}[H] + \centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-authentication}} + \caption{Authentication circuit. All public values are framed in green.} + \label{fig:circuit-verifier} +\end{figure} + +\subsubsection{Aggregation circuit} +\label{sec:vocdoni-protocol:circuits:aggregation} + +The aggregation circuit, illustrated in Figure~\ref{fig:circuit-aggregate}, is generated by the sequencer to combine multiple authenticated votes into a single proof. Its purpose is to reduce verification overhead by recursively aggregating individual authentication proofs, while ensuring that all aggregated votes belong to the same voting process. The batch size, i.e., the maximum number of proofs aggregated in a single execution, is a fixed parameter (currently set to 60). If fewer proofs are available, the sequencer pads the batch with dummy proofs so that the circuit always operates on a fixed-size input. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BW6-761 curve. We call the resulting proof the \textit{aggregation proof} and denote it as $\hlset{\aggregationproof}$. We detail below the inputs and constraints of the aggregation circuit. + +\begin{spacing}{1.25} + \vspace{0.3cm} + \noi \textbf{Public inputs} + \begin{itemize} + \item \public $(C_1, C_2)_i$: list of voters' encrypted ballots. + \item \public $\voteid_i$: set of vote's identifiers. + \item \public $\pk_i$: list of voters' public keys. + \item \public $\processid$: process identifier. + \item \public $\ballotmode$: ballot protocol configuration. + \item \public $EPK$: encryption public key. + \item \public $\censusroot$: census Merkle tree root. + \end{itemize} + \textbf{Private inputs} + \begin{itemize} + \item \private $\authenticationproof_i$: set of authentication proofs. + \end{itemize} + \textbf{Constraints} \\ \vspace{-0.4cm} + \begin{itemize} + \item \emph{Votes aggregation.} The accumulated authentication proofs are valid (for the given inputs). For every $i$: + $$\hlget{\PVerify}(\authenticationproof, PI = ((C_1, C_2)_i, \voteid_i, \pk_i, \processid, \ballotmode, EPK, \censusroot)).$$ + \item \emph{Shared public inputs.} The public inputs \processid, \ballotmode, \epk, and \censusroot are the same for all proofs. + \end{itemize} + \vspace{-0.3cm} +\end{spacing} + +\begin{figure}[h] + \centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-aggregate}} + \caption{Aggregation circuit. All public values are framed in green.} + \label{fig:circuit-aggregate} +\end{figure} + +\subsubsection{State transition circuit} +\label{sec:vocdoni-protocol:circuits:state-transition} + +The state transition circuit, illustrated in Figure~\ref{fig:circuit-state-transition-v2}, is generated by the sequencer to update the global state of the voting process. Its purpose is to verify that a batch of aggregated votes has been correctly incorporated into the state Merkle tree, that overwrites and vote identifiers are handled consistently, and that the accumulators of encrypted results are updated accordingly. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BN254 curve, which is supported by Ethereum’s native precompiles for proof verification. We call the resulting proof the \textit{state proof} and denote it as $\hlset{\stateproof}$. This proof is submitted on-chain and verified by the process management smart contract, ensuring that every accepted state transition complies with the protocol rules. + +\begin{spacing}{1.25} + \vspace{0.3cm} + \noi \textbf{Public inputs} + \begin{itemize} + \item \public $\stateroot^{old}$: most recent state tree root. + \item \public $\stateroot^{new}$: most recent state tree root. + \item \public $numOverwrites^{old}$: + \item \public $numOverwrites^{new}$: + \item \public $numVotes^{old}$: + \item \public $numVotes^{new}$: + \end{itemize} + \textbf{Private inputs} + \begin{itemize} + \item \private $\{\aggregationproof_i\}$: set of aggregation proofs. + \item \private $\censusroot$: census Merkle tree root. + \item \private $\ballotmode$: ballot protocol configuration. + \item \private $EPK$: encryption public key. + \item \private $\processid$: process identifier. + \item \private $\{\voteid_i\}$: set of vote's identifiers. + \item \private $\{(C_1, C_2)_i\}$: set of vote's identifiers. + \item \private $\{\pk_i\}$: list of voters' public keys. + \item \private $\{MerkleProofs_i\}$: list of voters' public keys. + \item \private $\{resultsAdd^{old}\}$: list of voters' public keys. + \item \private $\{resultsSub^{old}\}$: list of voters' public keys. + \item \private $k$: random scalar. + \end{itemize} + \textbf{Constraints} \\ \vspace{-0.4cm} + \begin{itemize} + \item \emph{Aggregation verification.} The accumulated authentication proofs are valid (for the given inputs). For every $i$: + $$\hlget{\PVerify}(\authenticationproof, PI = ((C_1, C_2)_i, \voteid_i, \pk_i, \processid, \ballotmode, EPK, \censusroot)).$$ + \item \emph{Transition verification.} The public inputs \processid, \ballotmode, \epk, and \censusroot are the same for all proofs. + \end{itemize} + \vspace{-0.3cm} +\end{spacing} + +-------------------------------------------------------- + +\newpage + +\paragraph{Assertions.} + +\begin{itemize} + \item \emph{Aggregation verification}: The agreggated zkProof is valid. + \item \emph{Transition verification}: The MerkleTree transition witness proves every change between Root1 and Root2. + \item \emph{Public inputs integrity}: ProcessID, BallotMode, CensusRoot, EncryptionKey remain unchanged. + \item \emph{Votes counting}: Ballots are correctly counted as new or overwrites, and added to results accumulators. +\end{itemize} + +When 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. + +For 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. + +This 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. + +\paragraph{Maintaining the Chain.} + +The 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. + +\begin{itemize} + \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. + \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. + \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. + \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. +\end{itemize} + +\paragraph{State Transition} + +To 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. + +\begin{figure}[H] + \centering + \fbox{ + \includegraphics[scale = 0.12, draft = false]{\figs/state-transition.png}} +\end{figure} + +%\begin{figure}[H] +% \centering +% \fbox{ + % \includegraphics[scale = 0.3, draft = false]{\figs/circuit-inputs.png}} +%\end{figure} +% +%\begin{figure}[H] +% \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-state-transition}} +% \caption{State transition circuit. All public values are framed in green.} +% \label{fig:circuit-state-transition} +%\end{figure} + +\begin{mdframed} + \begin{minipage}[H]{1\textwidth} + \begin{spacing}{1.25} + \vspace{0.3cm} + \begin{center}{STATE TRANSITION CIRCUIT}\end{center} + \textbf{Public inputs} + \begin{itemize} + \item \public $root_{old}$: Merkle tree root before the state transition. + \item \public $root_{new}$: Meklre tree root after the state transition. + \item \public $blobCommitment$: the commitment to the data blob containing the new votes. + \end{itemize} + \item \textbf{Private inputs} + \begin{itemize} + \item \private Votes: The list of new votes being processed, including census proofs and authentication data. + \item \private Merkle Proofs of nullifier inclusion: Proofs that each voter nullifier is included in the census. + \item \private Merkle Proofs of results update: Proofs that the process results have been correctly updated. + \item \private Merkle Tree Update Witnesses: Necessary data (e.g., Merkle paths) to update the Merkle tree from Root1 to Root2. + \item \private Process Parameters: Retrieved from Root1 within the circuit. + \end{itemize} + \textbf{Constraints} \\ \vspace{-0.4cm} + \begin{itemize} + \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. + \item \textbf{Vote validity}: Validate that each vote proof is correct. + \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`. + \item \textbf{Nullifier non-existence}: Ensure that the nullifier for each vote does not exist in the current state (`Root1`), preventing double voting. + \item \textbf{Nullifier addition}: Correctly add each new nullifier to the state, resulting in `Root2`, updating the Merkle tree accordingly. + \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`. + \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. + \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. + \end{itemize} + \vspace{-0.3cm} + \end{spacing} + \end{minipage} +\end{mdframed} + +\martai{STATE TRANSITION CIRCUIT: a potential problem is that a sequencer may know if one of their votes has been overwritten, for this reason, sequencers reencrypt a certain amount of ballots every time (already existing ballots I mean). So, the circuit should include the reencryptions: both for existing ballots and also for the new votes, which should be reencrypted (for receipt-freeness).} + +\begin{landscape} + %\thispagestyle{empty} % removes the page number + \begin{figure}[H] + \centerline{\includegraphics[width=560pt,draft=false]{\figs/circuit-state-transition-v2}} + \caption{State transition circuit. All public values are framed in green.} + \label{fig:circuit-state-transition-v2} + \end{figure} +\end{landscape} + +\subsubsection{Results circuit} +\label{sec:vocdoni-protocol:circuits:results} + +{\color{blue}{It needs to be done.}}
@@ -383,6 +383,6 @@
\subsection{Zero-knowledge proof systems} \label{sec:cryptographic-primitives:zkp} -{Zero-knowledge succinct non-interactive arguments of knowledge (ZK-SNARKs)} are a crucial component in ensuring the integrity of the voting process. Voters generate ZK-SNARK proofs to demonstrate that their encrypted ballots comply with the rules and constraints defined by the election parameters, without revealing any information about their choices. Similarly, sequencers produce proofs to certify the correctness of vote aggregation and state transitions throughout the protocol. {\color{blue}\hlset{\PProve}(), \hlset{\PVerify}().} +{Zero-knowledge succinct non-interactive arguments of knowledge (ZK-SNARKs)} are a crucial component in ensuring the integrity of the voting process. Voters generate ZK-SNARK proofs to demonstrate that their encrypted ballots comply with the rules and constraints defined by the election parameters, without revealing any information about their choices. Similarly, sequencers produce proofs to certify the correctness of vote aggregation and state transitions throughout the protocol. {\color{blue}\hlset{\PProve}(), \hlset{\PVerify}(proof, PI) -- pkey, vkey.} All ZK circuits in \davinci are compiled using the Groth16 proof system~\cite{groth2016size}, a widely adopted ZK-SNARK construction known for its succinctness, efficient verification, and minimal proof size. Although all circuits rely on the same proving system, they are instantiated with different elliptic curves depending on the cryptographic requirements of each phase. Specifically, the vote validity circuit is compiled over the BN254 curve, the census-related circuit uses BLS12-377, and the aggregation circuit is instantiated over BW6-761. Finally, the last circuit used by the sequencer—responsible for generating the final proof of correct tallying and result—is compiled over BN254 as well, since this is the proof that is verified on-chain by the smart contract using Ethereum’s native precompiles. Further details on the circuits are provided in Section~\ref{sec:vocdoni-protocol:circuits} and a summary of the instantiations can be found in Figure~\ref{fig:circuits-flow}.
@@ -0,0 +1,62 @@
+% !TeX root = ../build/main.tex + +Merkle trees are used to create a cryptographic representation of both the voter census registry and the voting process state. + +%\begin{itemize} +% \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. +% \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. +%\end{itemize}} + +\subsubsection{Census tree} +\label{sec:vocdoni-protocol:merkle-trees:census} + +The census Merkle tree, denoted by $\hlget{\censusTree}$ encodes the list of eligible voters and their associated voting weights. Formally, it is implemented as a sparse Merkle tree (SMT) of fixed depth\footnote{In the present work, all circuits are instantiated using sparse Merkle trees as described above. However, the protocol does not strictly depend on this structure: any authenticated data structure that supports efficient commitments and membership proofs verifiable inside zero-knowledge circuits could be employed. Adapting the protocol to such alternatives would only require modifying the corresponding circuits, while the overall flow of the voting process would remain unchanged.}, as described in Section~\ref{sec:cryptographic-primitives:merkle-trees}. Each voter is mapped to a unique path in the tree, typically derived from their Ethereum address or another unique identifier, and the corresponding leaf stores the voting weight of that address. While the default weight is usually one, the system also supports weighted voting, where different participants may have different levels of influence. + +To construct the census, the organizer collects the dataset of eligible voters and their weights, computes the corresponding tree, and publishes its root (\censusroot) on-chain. The full dataset does not need to be stored on-chain; instead, it is distributed off-chain (e.g., via IPFS or another content-addressed storage system), enabling verifiers and sequencers to independently reconstruct the tree and produce membership proofs when needed. This design ensures transparency and verifiability while minimizing on-chain storage requirements. + +The census tree plays a central role during the voting phase. Voters must provide a Merkle proof showing that their address and weight are included in the tree committed by the organizer. These proofs are then verified within ZK circuits, which guarantees that only eligible participants can cast ballots without requiring the disclosure of the entire census. In this way, the census Merkle tree provides a compact, cryptographically verifiable commitment to voter eligibility that supports both privacy and scalability. + +Although the protocol does not mandate a specific method for constructing the census tree, different instantiations are possible depending on the application context: +% +\begin{itemize} + \item \emph{Private datasets}. Organizations maintaining internal voter registries (e.g., membership databases or CSV files) can directly convert them into the Merkle format. This approach keeps the registry confidential, with only the root hash made public. + \item \emph{Self-sovereign identity (SSI)}. If voters manage identities through SSI systems, the organizer can aggregate these identities and build + the tree accordingly. This enables participation without requiring centralized identity management. + \item \textit{Ethereum-based tokens}. Token balances (e.g., ERC-20 or NFTs) may also define eligibility. In this setting, the census can either be created via the optimistic approach, taking a snapshot of token balances and allowing a dispute period for fraud proofs, or through a ZK-SNARK that proves correctness directly from Ethereum storage proofs and ensures that both individual balances and the token’s total supply are consistent. +\end{itemize} +% +This flexibility allows the protocol to accommodate a wide range of use cases, from private associations to decentralized communities, while maintaining the same security and verifiability guarantees. + +\subsubsection{State tree} +\label{sec:vocdoni-protocol:merkle-trees:state} + +The state Merkle tree, denoted by $\hlget{\stateTree}$, represents the evolving state of the voting process. Like the census tree, it is implemented as a SMT of fixed depth, as described in Section~\ref{sec:cryptographic-primitives:merkle-trees}. In contrast to the census tree, which remains static once the election begins, the state tree is dynamic: it is updated throughout the process as new votes are cast, validated, and incorporated by the sequencers. + +The leaves of the state tree store the global process parameters, the encrypted ballots, and the set of vote identifiers, as illustrated in Figure~\ref{fig:mt-state}. More specifically: + +\paragraph{Reserved addresses for metadata.} The first six addresses are reserved for the process parameters as follows: + +\begin{itemize} + \item \texttt{0x0}: it stores a unique identifier for the voting process (\processid). + \item \texttt{0x1}: it stores the committed census root (\censusroot). %and \type, a field in case the organization was using a different structure for the census than a MT. + \item \texttt{0x2}: it stores the ballot mode configuration, which is the set of rules for validating votes (\ballotmode). + \item \texttt{0x3}: it stores the encryption public key used to encrypt the votes (\epk). + \item \texttt{0x4}: it stores an accumulator of the encrypted votes that need to be added to the tally (\addaccumulator). + \item \texttt{0x5}: it stores an accumulator of the encrypted votes that need to be substracted from the tally because they have been overwritten (\substractaccumulator). +\end{itemize} + +\paragraph{Encrypted ballots.} Each voter’s encrypted ballot is stored in the state tree at a leaf whose path corresponds to their Ethereum address (or another unique identifier). The leaf value is the ciphertext corresponding to the ballot generated under the election’s public encryption key. If the voter later overwrites their ballot, the same path is updated with the new ciphertext. + +\paragraph{Vote identifiers.} In addition to storing ballots, the state tree also tracks the set of vote identifiers. Each vote identifier \voteid, which is derived from the \processid, the voter’s address, and fresh randomness, determines the path to a dedicated leaf. Initially empty, these leaves are filled when the corresponding \voteid is used, thereby recording that it has been consumed. This enables efficient non-membership proofs: before accepting a new ballot, the sequencer checks that the corresponding \voteid path is still empty, and upon inclusion, the leaf is marked as used to prevent reuse. \\ + +%Figure~\ref{fig:mt-state} illustrates the structure of the state tree, showing the reserved slots for process parameters as well as the leaves used for ballots and vote identifiers. + +\begin{figure}[h] + \centerline{\includegraphics[width=400pt,draft=false]{\figs/mt-state-mermaid}} + \caption{Structure of the state Merkle tree. The first leaves are reserved for global process parameters while subsequent leaves store encrypted ballots indexed by voter addresses and vote identifiers.} + \label{fig:mt-state} +\end{figure} + +At the beginning of the election, the state tree is initialized with the process parameters and empty accumulators, and its root ($\stateroot$) is published on-chain. As the voting progresses, sequencers update the tree whenever new votes are received, producing a new root for each transition. To guarantee correctness, each update is accompanied by a ZK-SNARK proof attesting that the transition from the previous root to the new root respects all protocol constraints: ballots are well-formed and comply with the voting rules, voters are eligible according to the census, the \voteid non-membership condition prevents double voting (or overwrites are handled correctly), and encrypted results are aggregated consistently. In addition, sequencers reencrypt stored ciphertexts, including both newly submitted and already included ballots. This mechanism refreshes the randomness of the encrypted votes without altering their underlying content, ensuring receipt-freeness and concealing whether a particular ballot has been overwritten or simply re-randomized. + +In this way, the state tree provides a compact and tamper-proof commitment to the current status of the election. At the end of the process, the final state root together with the on-chain verification of all transitions serves as a complete cryptographic record of the election, encapsulating both the tally and the integrity of the entire voting procedure.
@@ -0,0 +1,10 @@
+% !TeX root = ../build/main.tex + +A voting process involves three types of participants: the organizer, the sequencer, and the voters. + +\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. + +\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. +%Old text: the Sequencer is a specialized component designed to handle the voting process using zero-knowledge proof mechanisms. It ensures that all transactions related to this process are validated and sequenced. The Sequencers periodically commit the state of the voting process to Ethereum. + +\paragraph{Voter.} Voters are the participants that belong the census that cast their votes in the election.
@@ -0,0 +1,105 @@
+% !TeX root = ../build/main.tex + +In this section we describe the overall flow of the \davinci voting protocol. The process is structured into four main phases: voting setup, encryption key generation, votes collection, and results validation. Each phase specifies the interactions between the organizer, voters, sequencers, and the smart contracts that coordinate the voting process. An overview of the complete process is shown in Figure~\ref{fig:protocol-flow}. + +\subsubsection{Voting setup} +\label{sec:vocdoni-protocol:setup} + +In this phase, sequencers register and the organizer sets the election up.\\ + +\noi \sequencers +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. \\ + +\noi \organizer For each new election, the organizer performs the following steps: +\begin{enumerate} + \item Prepare the census data \censusdata\ and generate the census Merkle tree $\censusTree$ with that data. + \item Compute the census commitment $\censusroot = \censusTree.\hlget{\MTRoot}()$. + \item Define the election details, including duration, options, and the ballot mode $\ballotmode$. + \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. + \item Set security parameters for the %forthcoming + DKG ceremony (e.g., timeout, minimum number of sequencers). + \item Submit all this information in a transaction to the process management smart contract {\color{blue}(pay tx fees)}. +\end{enumerate} + +\subsubsection{Encryption key generation} +\label{sec:vocdoni-protocol:keygen} + +In this phase, sequencers collectively generate the public encryption key.\\ + +\noi \sequencers +Sequencers 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 sequencer 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)}.\\ + +\noi {\color{blue} Alternatively, generate a SNARK proving the EPK has been generated correctly and the contract verifies it.} + +\subsubsection{Votes collection} +\label{sec:vocdoni-protocol:votes} + +In this phase, voters cast their ballots and send them to the sequencers, who collect them. \\ + +\noi \voter To cast a ballot, a voter does the following: +\begin{enumerate} + \item Select a sequencer from the sequencer registry smart contract. + \item Retrieve their census membership proof $\censusproof$ to prove eligibility. + \item Fetch parameters $\epk$, $\ballotmode$, and $\processid$ from the process management contract. + \item Select their ballot choice $\ballot$ according to the rules of $\ballotmode$. + \item Sample fresh randomness $k \in \F$ and encrypt the ballot using $\epk$: + \begin{equation} + \label{eq-ciphertext} + (C_1, C_2) = \hlget{\Enc}_{\epk}(\ballot; k). + \end{equation} + \item Use their Ethereum address $\address$ and the previous $k$ to compute a unique vote identifier: + \begin{equation} + \label{eq-voteid} + \voteid = \hlget{\Multimimc}(\processid \conc \address \conc k). + \end{equation} + \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$: + \[ {\color{blue}\voteproof = \text{\hlget{Prove}(Circuit, PI = ())}.}\] + \item Sign the vote identifier with their Ethereum secret key to authenticate the vote and ensure that was cast by a legitimate voter: + \[ \signature = \hlget{\SSign}_{\sk}(\voteid).\] + \item Submits the package + \[\vote = [\processid, \voteid, \encryptedballot, \censusproof, \voteproof, \signature]\] + to the chosen sequencer. +\end{enumerate} + +%\item Sign $\voteid$ using the user's secret key $\sk$ to authenticates the vote and ensure that was cast by a legitimate voter: +%\[ \signature = \hlget{\SSign}_{\sk}(\voteid).\] +%\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: +%\[ \vote = [ \processid, \voteid, \encryptedballot, \censuspf, \voteproof, \signature ]. \] + + +\noi \sequencers Upon receiving votes, a sequencer does the following: +\begin{enumerate} + \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. + \item Verify each submission by generating a state transition proof (see Section~\ref{sec:vocdoni-protocol:circuits:state-transition}), ensuring: + \begin{itemize} + \item the validity of the voter’s zkSNARK proof, + \item correct accumulation of encrypted votes via ElGamal’s homomorphic properties, + \item eligibility of voters (via census Merkle proofs), + \item absence of double voting (or correct handling of overwrites via nullifiers), + \item consistency between data blobs and the on-chain state. + \end{itemize} + \item Submit the updated state root to the smart contract, while the full data are stored in Ethereum blobs. +\end{enumerate} + +Sequencers repeat this process until the voting deadline set by the organizer. + +\subsubsection{Results validation} +\label{sec:vocdoni-protocol:results} + +{\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. + +Rewards 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. + +At this point: +\begin{itemize} + \item Anyone can verify the correctness of the final results by checking the zkSNARK state proofs and on-chain commitments. + \item The combination of the final state root, the decryption of the accumulators, and the publicly verifiable zkSNARK proofs guarantees the integrity of the entire voting process. +\end{itemize} + +The process 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.} + +\begin{figure}%[H] + \centerline{\includegraphics[width=370pt,draft=false]{\figs/protocol-flow}} + \caption{Vocdoni voting process overview.} + \label{fig:protocol-flow} +\end{figure}
@@ -0,0 +1,9 @@
+% !TeX root = ../build/main.tex + +An Ethereum compatible network is used as the source of truth for the voting system. By leveraging an Ethereum virutal machine (EVM) blockchain, the voting process management ensures that all transitions are immutable and verifiable by all participants. To this end, we implement the following three smart contracts. + +\paragraph{Process management smart contract.} It is responsible for the life-cycle management of voting processes. It includes the initiation, monitoring, execution, and closure of voting events. + +\paragraph{Sequencer registry smart contract.} It 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. + +\paragraph{Results verification smart contract.} 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.\\
@@ -4,470 +4,20 @@ This section outlines the \davinci voting protocol. We introduce the parties involved in the process in Section~\ref{sec:vocdoni-protocol:parties}. In Section~\ref{sec:vocdoni-protocol:merkle-trees}, we describe the census and state Merkle trees, and in Section~\ref{sec:vocdoni-protocol:smart-contracts} the Ethereum smart contracts. In Section~\ref{sec:vocdoni-protocol:circuits}, we present the ZK circuits used to enforce vote validity, authentication, aggregation, and state transitions. Finally, in Section~\ref{sec:vocdoni-protocol:flow}, we detail the full protocol flow step by step, from the voting setup to the results validation and process finalization.
\subsection{Parties involved} \label{sec:vocdoni-protocol:parties} - -A voting process involves three types of participants: the organizer, the sequencer, and the voters. - -\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. - -\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. -%Old text: the Sequencer is a specialized component designed to handle the voting process using zero-knowledge proof mechanisms. It ensures that all transactions related to this process are validated and sequenced. The Sequencers periodically commit the state of the voting process to Ethereum. - -\paragraph{Voter.} Voters are the participants that belong the census that cast their votes in the election. +\input{\secs/parties.tex} \subsection{Merkle trees} \label{sec:vocdoni-protocol:merkle-trees} - -Merkle trees are used to create a cryptographic representation of both the voter census registry and the voting process state. - -%\begin{itemize} -% \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. -% \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. -%\end{itemize}} - -\subsubsection{Census tree} - -The census Merkle tree, denoted by $\hlget{\censusTree}$ encodes the list of eligible voters and their associated voting weights. Formally, it is implemented as a sparse Merkle tree (SMT) of fixed depth\footnote{In the present work, all circuits are instantiated using sparse Merkle trees as described above. However, the protocol does not strictly depend on this structure: any authenticated data structure that supports efficient commitments and membership proofs verifiable inside zero-knowledge circuits could be employed. Adapting the protocol to such alternatives would only require modifying the corresponding circuits, while the overall flow of the voting process would remain unchanged.}, as described in Section~\ref{sec:cryptographic-primitives:merkle-trees}. Each voter is mapped to a unique path in the tree, typically derived from their Ethereum address or another unique identifier, and the corresponding leaf stores the voting weight of that address. While the default weight is usually one, the system also supports weighted voting, where different participants may have different levels of influence. - -To construct the census, the organizer collects the dataset of eligible voters and their weights, computes the corresponding tree, and publishes its root (\censusroot) on-chain. The full dataset does not need to be stored on-chain; instead, it is distributed off-chain (e.g., via IPFS or another content-addressed storage system), enabling verifiers and sequencers to independently reconstruct the tree and produce membership proofs when needed. This design ensures transparency and verifiability while minimizing on-chain storage requirements. - -The census tree plays a central role during the voting phase. Voters must provide a Merkle proof showing that their address and weight are included in the tree committed by the organizer. These proofs are then verified within ZK circuits, which guarantees that only eligible participants can cast ballots without requiring the disclosure of the entire census. In this way, the census Merkle tree provides a compact, cryptographically verifiable commitment to voter eligibility that supports both privacy and scalability. - -Although the protocol does not mandate a specific method for constructing the census tree, different instantiations are possible depending on the application context: -% -\begin{itemize} - \item \emph{Private datasets}. Organizations maintaining internal voter registries (e.g., membership databases or CSV files) can directly convert them into the Merkle format. This approach keeps the registry confidential, with only the root hash made public. - \item \emph{Self-sovereign identity (SSI)}. If voters manage identities through SSI systems, the organizer can aggregate these identities and build - the tree accordingly. This enables participation without requiring centralized identity management. - \item \textit{Ethereum-based tokens}. Token balances (e.g., ERC-20 or NFTs) may also define eligibility. In this setting, the census can either be created via the optimistic approach, taking a snapshot of token balances and allowing a dispute period for fraud proofs, or through a ZK-SNARK that proves correctness directly from Ethereum storage proofs and ensures that both individual balances and the token’s total supply are consistent. -\end{itemize} -% -This flexibility allows the protocol to accommodate a wide range of use cases, from private associations to decentralized communities, while maintaining the same security and verifiability guarantees. - -\subsubsection{State tree} - -The state Merkle tree, denoted by $\hlget{\stateTree}$, represents the evolving state of the voting process. Like the census tree, it is implemented as a SMT of fixed depth, as described in Section~\ref{sec:cryptographic-primitives:merkle-trees}. In contrast to the census tree, which remains static once the election begins, the state tree is dynamic: it is updated throughout the process as new votes are cast, validated, and incorporated by the sequencers. - -The leaves of the state tree store the global process parameters, the encrypted ballots, and the set of vote identifiers, as illustrated in Figure~\ref{fig:mt-state}. More specifically: - -\paragraph{Reserved addresses for metadata.} The first six addresses are reserved for the process parameters as follows: - -\begin{itemize} - \item \texttt{0x0}: it stores a unique identifier for the voting process (\processid). - \item \texttt{0x1}: it stores the committed census root (\censusroot). %and \type, a field in case the organization was using a different structure for the census than a MT. - \item \texttt{0x2}: it stores the ballot mode configuration, which is the set of rules for validating votes (\ballotmode). - \item \texttt{0x3}: it stores the encryption public key used to encrypt the votes (\epk). - \item \texttt{0x4}: it stores an accumulator of the encrypted votes that need to be added to the tally (\addaccumulator). - \item \texttt{0x5}: it stores an accumulator of the encrypted votes that need to be substracted from the tally because they have been overwritten (\substractaccumulator). -\end{itemize} - -\paragraph{Encrypted ballots.} Each voter’s encrypted ballot is stored in the state tree at a leaf whose path corresponds to their Ethereum address (or another unique identifier). The leaf value is the ciphertext corresponding to the ballot generated under the election’s public encryption key. If the voter later overwrites their ballot, the same path is updated with the new ciphertext. - -\paragraph{Vote identifiers.} In addition to storing ballots, the state tree also tracks the set of vote identifiers. Each vote identifier \voteid, which is derived from the \processid, the voter’s address, and fresh randomness, determines the path to a dedicated leaf. Initially empty, these leaves are filled when the corresponding \voteid is used, thereby recording that it has been consumed. This enables efficient non-membership proofs: before accepting a new ballot, the sequencer checks that the corresponding \voteid path is still empty, and upon inclusion, the leaf is marked as used to prevent reuse. \\ - -%Figure~\ref{fig:mt-state} illustrates the structure of the state tree, showing the reserved slots for process parameters as well as the leaves used for ballots and vote identifiers. - -\begin{figure}[h] - \centerline{\includegraphics[width=400pt,draft=false]{\figs/mt-state-mermaid}} - \caption{Structure of the state Merkle tree. The first leaves are reserved for global process parameters while subsequent leaves store encrypted ballots indexed by voter addresses and vote identifiers.} - \label{fig:mt-state} -\end{figure} - -At the beginning of the election, the state tree is initialized with the process parameters and empty accumulators, and its root ($\stateroot$) is published on-chain. As the voting progresses, sequencers update the tree whenever new votes are received, producing a new root for each transition. To guarantee correctness, each update is accompanied by a ZK-SNARK proof attesting that the transition from the previous root to the new root respects all protocol constraints: ballots are well-formed and comply with the voting rules, voters are eligible according to the census, the \voteid non-membership condition prevents double voting (or overwrites are handled correctly), and encrypted results are aggregated consistently. In addition, sequencers reencrypt stored ciphertexts, including both newly submitted and already included ballots. This mechanism refreshes the randomness of the encrypted votes without altering their underlying content, ensuring receipt-freeness and concealing whether a particular ballot has been overwritten or simply re-randomized. - -In this way, the state tree provides a compact and tamper-proof commitment to the current status of the election. At the end of the process, the final state root together with the on-chain verification of all transitions serves as a complete cryptographic record of the election, encapsulating both the tally and the integrity of the entire voting procedure. +\input{\secs/merkle-trees.tex} \subsection{Smart contracts} \label{sec:vocdoni-protocol:smart-contracts} - -An Ethereum compatible network is used as the source of truth for the voting system. By leveraging an Ethereum virutal machine (EVM) blockchain, the voting process management ensures that all transitions are immutable and verifiable by all participants. To this end, we implement the following three smart contracts. - -\paragraph{Process management smart contract.} It is responsible for the life-cycle management of voting processes. It includes the initiation, monitoring, execution, and closure of voting events. - -\paragraph{Sequencer registry smart contract.} It 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. - -\paragraph{Results verification smart contract.} 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.\\ +\input{\secs/smart-contracts.tex} \subsection{Circuits} \label{sec:vocdoni-protocol:circuits} - -At the core of \davinci lie a set of arithmetic circuits that enforce the correctness of every step of the voting process. Each circuit corresponds to a distinct task and, taken together, they guarantee that all protocol rules are satisfied without revealing any private information. Specifically, the \emph{ballot circuit} (Section~\ref{sec:vocdoni-protocol:circuits:ballot}) ensures that encrypted votes are valid and well-formed, the \emph{verifier circuit} (Section~\ref{sec:vocdoni-protocol:circuits:verifier}) verifies voter eligibility and census membership; the \emph{aggregation circuit} (Section~\ref{sec:vocdoni-protocol:circuits:aggregation}) combines multiple authenticated votes into a single proof; and the \emph{state transition circuit} (Section~\ref{sec:vocdoni-protocol:circuits:state-transition}) updates the global state root and produces the ZK-SNARK proof that is verified on-chain. The flow of these circuits and their interactions is shown in Figure~\ref{fig:circuits-flow}. - -\begin{figure}[h] - \centerline{\includegraphics[width=\linewidth,draft=false]{\figs/circuits-flow-v2}} - \caption{ - Overview of the circuit flow in \davinci.} - \label{fig:circuits-flow} -\end{figure} - -For clarity, the circuits are described in this section with their full set of public inputs explicitly listed. In the actual implementation, however, we apply an optimization: rather than exposing all public inputs individually, we compute a single commitment $h = Hash(PI)$ and use $h$ as the only public input. The proof verifier then checks that $Hash(PI) = h$, ensuring that the original public inputs are consistent while reducing both proof size and verification cost. In \davinci, this commitment is computed using the MiMC-7 hash function {\color{blue}(use hlget to point "Hash" to MiMC-7)}. Note that this optimization does not alter the semantics of the circuits but significantly reduces verifier complexity and on-chain verification costs. Other implementation aspects such as the exact number of constraints and the proving frameworks used are deferred to Section~\ref{sec:analysis:implementation}. - -% 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. - -\subsubsection{Ballot circuit} -\label{sec:vocdoni-protocol:circuits:ballot} - -The ballot circuit, illustrated in Figure~\ref{fig:circuit-ballot}, is generated locally by the voter at the time of casting a ballot. Its purpose is twofold: first, to prove that the encrypted ballot is valid and complies with the protocol rules defined by the organizer; and second, to prove that the vote identifier (\voteid) has been correctly derived. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BN254 curve. We call the resulting proof \textit{ballot proof} and denote it as $\hlset{\ballotproof}$. We detail below the inputs and constraints of the ballot circuit. - -\begin{spacing}{1.25} - \vspace{0.3cm} - \noi \textbf{Public inputs} - \begin{itemize} - \item $\public$ $\processid$: voting process identifier. - \item $\public$ $\ballotmode$: ballot protocol configuration.S - \item $\public$ $\epk$ ($EPK$): encryption public key. - \item $\public$ $\address$: voter's address. - \item $\public$ $\weight$: voter's weight. - \item $\public$ $(C_1, C_2)$: encrypted ballot. - \item $\public$ $\voteid$: vote's unique identifier. - \end{itemize} - \textbf{Private inputs} - \begin{itemize} - \item \private $\ballot$: plaintext voter's voting choice. - \item \private $k$: random scalar. - \end{itemize} - \textbf{Constraints} - \begin{itemize} - \item \emph{Vote encryption}. Correct encryption of the ballot: $(C_1, C_2) = \hlget{\Enc}_{\epk}(\ballot; k).$ - \item \emph{Protocol rules compliance}. The ballot meets the protocol rules (number of valid choices, etc.): $... + \weight$. - \item \emph{Vote identifier}. The vote's identifier is correctly computed: $\voteid = \text{Hash} (\processid \conc \address \conc k).$ - \end{itemize} - \vspace{-0.3cm} -\end{spacing} - -\begin{figure}[H] - \centerline{\includegraphics[width=420pt,draft=false]{\figs/circuit-voter}} - \caption{Ballot circuit. All public values are framed in green.} - \label{fig:circuit-ballot} -\end{figure} - -\subsubsection{Verifier circuit} -\label{sec:vocdoni-protocol:circuits:verifier} - -The verifier circuit, illustrated in Figure~\ref{fig:circuit-verifier}, is generated by the sequencer when processing a vote. This circuit verifies the ballot's proof generated by the voter and it also validates the voter’s eligibility in the census and the correctness of their digital signature. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BLS12-377 curve. We call the resulting proof the \textit{authentication proof} and denote it as $\hlset{\authenticationproof}$. We detail below the inputs and constraints of this circuit. {\color{blue}-- Authentication of verification proof?} - -\begin{spacing}{1.25} - \vspace{0.3cm} - \noi \textbf{Public inputs} - \begin{itemize} - \item \public $\processid$: process identifier. - \item \public $\ballotmode$: ballot protocol configuration. - \item \public $\epk$ ($EPK$): encryption public key. - \item \public $(C_1, C_2)$: encrypted ballot. - \item \public $\voteid$: voter's identifier. - \item \public $\censusroot$: census Merkle tree root. - \item \public $\pk$: voter's public key. - \end{itemize} - \textbf{Private inputs} - \begin{itemize} - \item \private $\ballotproof$: voter's ballot proof. - \item \private $\weight$: voter's weight. - \item \private $\censuspf$: census membership proof. - \item \private $\signature$: voter's signature. - \end{itemize} - \textbf{Constraints} - \begin{itemize} - \item \emph{Voter's proof verification.} The vote zkProof is valid for the inputs provided: - $$\hlget{\PVerify}\left(\ballotproof, PI = (\processid, \ballotmode, \epk, (C_1, C_2), \voteid, \weight)\right).$$ - \item \emph{Census membership.} The address derived from the user's public key is part of the census, and verifies the census proof with the user's weight provided: - $$ \hlget{\censusTree}.\hlget{\MTMembershipProof}(\weight, \address = \hlget{\Keccak}(\pk), \censuspf, \censusroot). $$ - \item \emph{Authentication + non-malleability.} The signature of the vote's identifier is valid for the given public key: - $$ \hlget{\SVer}_{\pk}(\voteid, \signature). $$ - \end{itemize} - \vspace{-0.3cm} -\end{spacing} - -\begin{figure}[H] - \centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-authentication}} - \caption{Authentication circuit. All public values are framed in green.} - \label{fig:circuit-verifier} -\end{figure} - -\subsubsection{Aggregation circuit} -\label{sec:vocdoni-protocol:circuits:aggregation} - -The aggregation circuit, illustrated in Figure~\ref{fig:circuit-aggregate}, is generated by the sequencer to combine multiple authenticated votes into a single proof. Its purpose is to reduce verification overhead by recursively aggregating individual authentication proofs, while ensuring that all aggregated votes belong to the same voting process. The batch size, i.e., the maximum number of proofs aggregated in a single execution, is a fixed parameter (currently set to 60). If fewer proofs are available, the sequencer pads the batch with dummy proofs so that the circuit always operates on a fixed-size input. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BW6-761 curve. We call the resulting proof the \textit{aggregation proof} and denote it as $\hlset{\aggregationproof}$. We detail below the inputs and constraints of the aggregation circuit. - -\begin{spacing}{1.25} - \vspace{0.3cm} - \noi \textbf{Public inputs} - \begin{itemize} - \item \public $(C_1, C_2)_i$: list of voters' encrypted ballots. - \item \public $\voteid_i$: set of vote's identifiers. - \item \public $\pk_i$: list of voters' public keys. - \item \public $\processid$: process identifier. - \item \public $\ballotmode$: ballot protocol configuration. - \item \public $EPK$: encryption public key. - \item \public $\censusroot$: census Merkle tree root. - \end{itemize} - \textbf{Private inputs} - \begin{itemize} - \item \private $\authenticationproof_i$: set of authentication proofs. - \end{itemize} - \textbf{Constraints} \\ \vspace{-0.4cm} - \begin{itemize} - \item \emph{Votes aggregation.} The accumulated authentication proofs are valid (for the given inputs). For every $i$: - $$\hlget{\PVerify}(\authenticationproof, PI = ((C_1, C_2)_i, \voteid_i, \pk_i, \processid, \ballotmode, EPK, \censusroot)).$$ - \item \emph{Shared public inputs.} The public inputs \processid, \ballotmode, \epk, and \censusroot are the same for all proofs. - \end{itemize} - \vspace{-0.3cm} -\end{spacing} - -\begin{figure}[h] - \centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-aggregate}} - \caption{Aggregation circuit. All public values are framed in green.} - \label{fig:circuit-aggregate} -\end{figure} - -\subsubsection{State transition circuit} -\label{sec:vocdoni-protocol:circuits:state-transition} - -The state transition circuit, illustrated in Figure~\ref{fig:circuit-state-transition-v2}, is generated by the sequencer to update the global state of the voting process. Its purpose is to verify that a batch of aggregated votes has been correctly incorporated into the state Merkle tree, that overwrites and vote identifiers are handled consistently, and that the accumulators of encrypted results are updated accordingly. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BN254 curve, which is supported by Ethereum’s native precompiles for proof verification. We call the resulting proof the \textit{state proof} and denote it as $\hlset{\stateproof}$. This proof is submitted on-chain and verified by the process management smart contract, ensuring that every accepted state transition complies with the protocol rules. - -\pagebreak - -\paragraph{Assertions.} - -\begin{itemize} - \item \emph{Aggregation verification}: The agreggated zkProof is valid. - \item \emph{Transition verification}: The MerkleTree transition witness proves every change between Root1 and Root2. - \item \emph{Public inputs integrity}: ProcessID, BallotMode, CensusRoot, EncryptionKey remain unchanged. - \item \emph{Votes counting}: Ballots are correctly counted as new or overwrites, and added to results accumulators. -\end{itemize} - -When 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. - -For 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. - -This 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. - -\paragraph{Maintaining the Chain.} - -The 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. - -\begin{itemize} - \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. - \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. - \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. - \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. -\end{itemize} - -\paragraph{State Transition} - -To 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. - -\begin{figure}[H] - \centering - \fbox{ - \includegraphics[scale = 0.12, draft = false]{\figs/state-transition.png}} -\end{figure} - -%\begin{figure}[H] -% \centering -% \fbox{ -% \includegraphics[scale = 0.3, draft = false]{\figs/circuit-inputs.png}} -%\end{figure} -% -%\begin{figure}[H] -% \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-state-transition}} -% \caption{State transition circuit. All public values are framed in green.} -% \label{fig:circuit-state-transition} -%\end{figure} - -\begin{mdframed} - \begin{minipage}[H]{1\textwidth} - \begin{spacing}{1.25} - \vspace{0.3cm} - \begin{center}{STATE TRANSITION CIRCUIT}\end{center} - \textbf{Public inputs} - \begin{itemize} - \item \public $root_{old}$: Merkle tree root before the state transition. - \item \public $root_{new}$: Meklre tree root after the state transition. - \item \public $blobCommitment$: the commitment to the data blob containing the new votes. - \end{itemize} - \item \textbf{Private inputs} - \begin{itemize} - \item \private Votes: The list of new votes being processed, including census proofs and authentication data. - \item \private Merkle Proofs of nullifier inclusion: Proofs that each voter nullifier is included in the census. - \item \private Merkle Proofs of results update: Proofs that the process results have been correctly updated. - \item \private Merkle Tree Update Witnesses: Necessary data (e.g., Merkle paths) to update the Merkle tree from Root1 to Root2. - \item \private Process Parameters: Retrieved from Root1 within the circuit. - \end{itemize} - \textbf{Constraints} \\ \vspace{-0.4cm} - \begin{itemize} - \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. - \item \textbf{Vote validity}: Validate that each vote proof is correct. - \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`. - \item \textbf{Nullifier non-existence}: Ensure that the nullifier for each vote does not exist in the current state (`Root1`), preventing double voting. - \item \textbf{Nullifier addition}: Correctly add each new nullifier to the state, resulting in `Root2`, updating the Merkle tree accordingly. - \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`. - \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. - \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. - \end{itemize} - \vspace{-0.3cm} - \end{spacing} - \end{minipage} -\end{mdframed} - -\martai{STATE TRANSITION CIRCUIT: a potential problem is that a sequencer may know if one of their votes has been overwritten, for this reason, sequencers reencrypt a certain amount of ballots every time (already existing ballots I mean). So, the circuit should include the reencryptions: both for existing ballots and also for the new votes, which should be reencrypted (for receipt-freeness).} - -\begin{landscape} -%\thispagestyle{empty} % removes the page number -\begin{figure}[H] - \centerline{\includegraphics[width=560pt,draft=false]{\figs/circuit-state-transition-v2}} - \caption{State transition circuit. All public values are framed in green.} - \label{fig:circuit-state-transition-v2} -\end{figure} -\end{landscape} - -\subsubsection{Results circuit} -\label{sec:vocdoni-protocol:circuits:results} - -TBA. +\input{\secs/circuits.tex} \subsection{Protocol flow} \label{sec:vocdoni-protocol:flow} - -\martai{Rename steps: 1. voting setup, 2. encryption key generation, 3. votes collection, 4. results validation.} - -In Figure~\ref{fig:protocol-flow} we describe the protocol flow. - -\begin{figure}%[H] - \centerline{\includegraphics[width=370pt,draft=false]{\figs/protocol-flow}} - \caption{Vocdoni voting process overview.} - \label{fig:protocol-flow} -\end{figure} - -\subsubsection{Prior to voting (only once)} -\label{sec:vocdoni-protocol:prior-steps} - -%\martai{Remove the first step, we assume contracts are already deployed or at least, the logic is available.} -% -%This is done only once. Then every voting will start its process from step in Section~\ref{sec:vocdoni-protocol:start}. -% -%Vocdoni: -%\begin{enumerate} -% \item Deployment of the 3 smart contracts. -% \item Sequencers registry starts (it doesn't end). -%\end{enumerate} - -\sequencers -- this process is always open: -\begin{enumerate} - \item Register this and that way. - \item Public keys? 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. - \item PROVIDE COLLATERAL. What happens to the collateral? If done only once, then you lose it? Do you need to send a new tx with more collateral? - \item Send transaction to Sequencer registry smart contract (pay for tx fee). -\end{enumerate} - -\subsubsection{Start of the voting process} -\label{sec:vocdoni-protocol:start} - -\organizer -\begin{enumerate} - \item Prepares the census data \censusdata and generates census Merkle tree $\hlget{\censusTree}$. - \item Generates the census commitment: $\censusroot = \hlget{\censusTree}.\hlget{\MTRoot}()$. - \martai{Additionally, after this step, the organizer should make a Merkle proof available to all eligible voters.} - \item Set voting details: {\color{blue}duration, options, type, etc. + CENSUS MT ROOT.} - \item Compute the process identifier \processid, which is a unique 32-byte number derived from the organizer's Ethereum address and nonce, and the chain ID. - %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. - \item Set security factors for DKG: a timeout for the DKG ceremony + minimum number of sequencers. - \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. The transaction includes the fields: - \[\processid, etc.\] -\end{enumerate} - -\subsubsection{Encryption key generation process} %Voting key generation -\label{sec:vocdoni-protocol:dkg} - -\sequencers -\begin{enumerate} - \item Fetch the \processid, \ballotmode, and \censusroot from the process management smart contract. - \item Make contributions to DKG ceremony before the timeout set by the organizer. -\end{enumerate} - -\noi After the timeout, all contributions to DKG are done. The smart contract checks if minimum number of sequencers is reached. If so, the \epk ``becomes available". - -\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. It is not clear to me if it is sent to SR or PM. } - -\subsubsection{Voting process} -\label{sec:vocdoni-protocol:voting} -\voter - -\begin{itemize} - \item Choose any of the available sequencers from the sequencer registry smart contract. - \item Fetch from the census registry their membership proof $\censusproof$ to prove eligibility. - \item Collect %the process data - the $\epk$, $\ballotmode$, $\processid$ from the process management smart contract. - \item Select their voting choice $\ballot$ according to the election rules specified by the $\ballotmode$ parameter. \item Sample a fresh random $k \in \F$ and encrypt the selected choice using the public key $\epk$: - \begin{equation} - \label{eq-ciphertext} - (C_1, C_2) = \hlget{\Enc}_{\epk}(\ballot; k). - \end{equation} - \item Use the user's own Ethereum address $\address$ and the previous $k$ to compute the $\voteid$: - \begin{equation} - \label{eq-voteid} - \voteid = \hlget{\Multimimc}(\processid \conc \address \conc k). - \end{equation} - \item Generate ZK-SNARK of satisfiability of circuit from Fig.~\ref{fig:circuit-voter} with the proof system from Section~\ref{sec:cryptographic-primitives:zkp} to prove that Eqs.~\labelcref{eq-ciphertext,eq-voteid} are correctly computed, and that $\ballot$ satisfies ballot protocol rules according to $\ballotmode$. - \[ \voteproof = \text{Prove(), Circuit(), PublicInputs}.\] - \item Sign $\voteid$ using the user's secret key $\sk$ to authenticates the vote and ensure that was cast by a legitimate voter: - \[ \signature = \hlget{\SSign}_{\sk}(\voteid).\] - \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: - \[ \vote = [ \processid, \voteid, \encryptedballot, \censuspf, \voteproof, \signature ]. \] -\end{itemize} - -\noi \sequencers - -\begin{itemize} - \item Fetch current state: retrieve the current valid process state root from the process management smart contract and the associated data from Ethereum blobs. - \item $\censusroot = \hlget{\censusTree}.\hlget{\MTRoot}()$. - \item $\stateroot = \hlget{\stateTree}.\hlget{\MTRoot}()$. - \item Generate a SK-SNARK proof of state transition proving: - \begin{itemize} - \item the validity of the ZK-SNARK proof provided by the voter, - \item the correct accumulation of votes from users, adding them to the process state, - \item the correct sum of the new encrypted votes using the homomorphic properties of ElGamal, - \item the new votes are from eligible users by checking the census Merkle proofs, - \item the new voters have not already voted by checking their nullifiers, or it is a correct vote overwrite, - \item the data blob hash matches the data used to verify the transition. - \end{itemize} - \item Submit updated state: send the new state root to the smart contract and store the updated data in Ethereum blobs. -\end{itemize} - -Sequencers keep accumulating votes and create state transition until the finalization of the process. - -\martai{I understand this finalization is a deadline set by the organizer.} - -SC: - -\begin{itemize} - \item Upon receiving a sequencer's transaction, the SC verifies the zk-SNARK proof provided byt he sequencer. - \item Ensure the origin root corresponds to the current stored state root. - \item Confirm that the blob hash matches the one stored in Ethereum. -\end{itemize} - -\subsubsection{Results validation} -\label{sec:vocdoni-protocol:validation} - -Once the voting is completed (I understand the timeout set by the organizer expires), the following things happen. - -\noi \sequencers - -\begin{itemize} - \item $t$ out of $n$ sequencers publish their shares corresponding to the EPK to the Ethereum smart contract. - \martai{specify which SC.} - \item When the threshold of shares is reached, the results can be decrypted by anyone. - \martai{mention that the SC computes the corresponding ESK, or that can be computed by anyone off-chain, since all info is public.} - \item Sequencers receive reward for their correct participants depending on the number of sequenced votes. - \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?} -\end{itemize} - -This way: - -\begin{itemize} - \item After the voting period ends and the results are decrypted, anyone can verify the correctness of the final result. - \martai{explain how.} - \item Use the zkSNARK state proof and publicly available data on-chain to ensure the integrity and correctness of the entire voting process. - \martai{elaborate on this.} -\end{itemize} - -\subsubsection{Finalization of the voting process} -\label{sec:vocdoni-protocol:finalization} +\input{\secs/protocol-flow.tex}