separate census and state tree sections
@@ -72,7 +72,7 @@ \item \textbf{Important change:} sequencers do not register in any smart contract.
\end{itemize} }}} -\setcounter{tocdepth}{2} +\setcounter{tocdepth}{3} \makeatletter \renewcommand*\l@author[2]{} \renewcommand*\l@title[2]{}
@@ -42,7 +42,7 @@ \item $\minvaluesum \leq \sum_{i=1}^n v_i^{\costexponent} \leq \maxvaluesum$.
\end{itemize} \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. 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). +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: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). \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.
@@ -0,0 +1,18 @@
+% !TeX root = ../build/main.tex + +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 election 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.
@@ -202,9 +202,9 @@ \item $\tree.\hlset{\MTNonMembershipProof}(\leaf)$: it returns a proof that the given leaf is not included in the tree.
\item $\tree.\hlset{\MTVerify}(\leaf, proof, root)$: it verifies that the given proof corresponds to the claimed root and leaf. \end{itemize} -These functions are used by sequencers to construct proofs that certify the validity of state transitions. In particular, they allow for off-chain state evolution that is independently verifiable on-chain and within ZK circuits. Additional details on the structure of the census and state trees, as well as the encoding of their leaves, are provided in Section~\ref{sec:vocdoni-protocol:merkle-trees}. +These functions are used by sequencers to construct proofs that certify the validity of state transitions. In particular, they allow for off-chain state evolution that is independently verifiable on-chain and within ZK circuits. Additional details on the structure of the census and state trees, as well as the encoding of their leaves, are provided in Sections~\ref{sec:vocdoni-protocol:census} and~\ref{sec:vocdoni-protocol:state-tree}. -\subsection{Commitments} +\subsection{Commitment schemes} \label{sec:cryptographic-primitives:commitments} {\color{blue} Description of KZG~\cite{kate2010constant} with SRS, $\hlset{\CCommit}()$, and $\hlset{\CVerify}()$.}\\
@@ -1,66 +1,3 @@
-% !TeX root = ../build/main.tex - -{\color{blue}Consider removing this section and creating new sections \textbf{1. Census} and \textbf{2. State tree}.}\\ - -\noi Merkle trees are used to create a cryptographic representation of both the voter census registry and the election 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 election 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 election. 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 election as new votes are cast, validated, and incorporated by the sequencers. - -The leaves of the state tree store the global election 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 election (\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 encrypted under the election’s encryption public 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 election parameters while subsequent leaves store encrypted ballots indexed by voter addresses and vote identifiers.} - \label{fig:mt-state} -\end{figure} - -\paragraph{Initial state.} At the beginning of the election, the state tree is initialized with the election parameters and empty accumulators, and its root ($\stateroot$) is published on-chain. - -\paragraph{State transitions.} 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 \ac{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 election, 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.
@@ -6,7 +6,9 @@ \paragraph{Organizer.} The organizer is the entity responsible for defining and setting up the election. 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{\Keywardens.} \Keywardens are a set of decentralized parties that collaboratively generate a public encryption key that voters use to encrypt their votes. -\paragraph{Voters.} Voters are the participants that belong the census and are allowed to cast their votes in the election. +\paragraph{Voters.} Voters are the participants that belong the census and are allowed to cast their votes in the election. \\ + +\noi {\color{blue}\textbf{TODO}: we need to add that each voter has a secret $\sk$ and public $\pk$ key and an associated Ethereum address. Maybe add something about the weight as well? Consider adding a public-key scheme in Section~\ref{sec:cryptographic-primitives}.} \paragraph{Sequencers.} Sequencers are a set of parties that during the voting period receive and verify encrypted ballots from voters, reencrypt votes to prevent coercion, and update the shared public state accordingly.
@@ -42,9 +42,10 @@
\noi \textbf{(a) Vote casting.} To cast a ballot, a voter does the following: \begin{enumerate} - \item Select a sequencer from the sequencer registry smart contract. + {\color{red} + \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 Fetch parameters $\epk$, $\ballotmode$, and $\processid$ from the \hlget{\electionregistry} smart 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}@@ -56,7 +57,7 @@ \begin{equation}
\label{eq-voteid} \voteid = \hlget{\Multimimc}(\processid \conc \address \conc k). \end{equation} - \item Use the \ballotcircuit from Section~\ref{sec:vocdoni-protocol:circuits:ballot} to generate a ZK-SNARK proof to prove that Eqs.~\labelcref{eq-ciphertext,eq-voteid} are correctly computed and that $\ballot$ satisfies ballot protocol rules according to $\ballotmode$: + \item Use the \ballotcircuit from Section~\ref{sec:vocdoni-protocol:circuits:ballot} to generate a ZK-SNARK proof to prove that Eqs.~\labelcref{eq-ciphertext,eq-voteid} are correctly computed and that $\ballot$ satisfies the ballot protocol rules according to $\ballotmode$: \begin{align*} \voteproof = & \hlget{\PProve}( \hlget{\ballotcircuit},@@ -64,7 +65,7 @@ \witness = (\ballot, k),
\publicinputs = (\processid, \ballotmode,\\ &\epk, \address, \weight, (C_1, C_2), \voteid)). \end{align*} - \item Sign the vote identifier with their Ethereum secret key to authenticate the vote and ensure that was cast by a legitimate voter: + \item Sign the vote identifier with their Ethereum secret key $\sk$ 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]\]@@ -122,7 +123,7 @@ consistency between data blobs and the on-chain state:
\begin{align*} \stateproof = \hlget{\PProve}(\hlget{\statetransitioncircuit}, - \witness = (), \publicinputs = (). + \witness = (), \publicinputs = ()). \end{align*} \item Verify each $\vote$ submission received by generating a state transition proof (see Section~\ref{sec:vocdoni-protocol:circuits:state-transition}), ensuring:
@@ -0,0 +1,37 @@
+% !TeX root = ../build/main.tex + +% \noi Merkle trees are used to create a cryptographic representation of both the voter census registry and the election state. + + +The state Merkle tree, denoted by $\hlget{\stateTree}$, represents the evolving state of the election. 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 election as new votes are cast, validated, and incorporated by the sequencers. + +The leaves of the state tree store the global election 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 election (\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 encrypted under the election’s encryption public 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 election parameters while subsequent leaves store encrypted ballots indexed by voter addresses and vote identifiers.} + \label{fig:mt-state} +\end{figure} + +\paragraph{Initial state.} At the beginning of the election, the state tree is initialized with the election parameters and empty accumulators, and its root ($\stateroot$) is published on-chain. + +\paragraph{State transitions.} 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 \ac{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 election, 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.
@@ -1,14 +1,18 @@
% !TeX root = ../build/main.tex -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. +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:census}, we describe the census data structure and in Section~\ref{sec:vocdoni-protocol:state-tree} the state Merkle trees. Then, 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} \input{\secs/parties.tex} -\subsection{Merkle trees} -\label{sec:vocdoni-protocol:merkle-trees} -\input{\secs/merkle-trees.tex} +\subsection{Census} +\label{sec:vocdoni-protocol:census} +\input{\secs/census.tex} + +\subsection{State tree} +\label{sec:vocdoni-protocol:state-tree} +\input{\secs/state-tree.tex} \subsection{Smart contracts} \label{sec:vocdoni-protocol:smart-contracts}