arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
resolved most comments and todos
bellesmarta belles.mm@gmail.com
Wed, 08 Jul 2026 09:47:12 +0200
commit

a5bc4bdfe1af94b210ec97f90f4f49a91e818457

parent

76a6c6d9ebeea9a41feb7f31d6d319acd2758600

M v2/bibliography/bibtex.bib → v2/bibliography/bibtex.bib

@@ -529,6 +529,16 @@ author = {Glaeser, Noemi and Seres, Istv{\'a}n Andr{\'a}s and Zhu, Michael and Bonneau, Joseph},

title = {{Cicada}: A Framework for Private Non-Interactive On-Chain Auctions and Voting}, howpublished= {Cryptology {ePrint} Archive, Paper 2023/1473}, year = 2023} + +@article{belles2023circom, + author = {Bellés-Muñoz, Marta and Isabel, Miguel and Muñoz-Tapia, Jose Luis + and Rubio, Albert and Baylina, Jordi}, + title = {{Circom}: A Circuit Description Language for Building + Zero-Knowledge Applications}, + journal = {{IEEE} Transactions on Dependable and Secure Computing}, + year = {2023}, + doi = {10.1109/TDSC.2022.3232813} +} @inproceedings{doan2024, author = {Doan, Thi Van Thao and Pereira, Olivier and Peters, Thomas},

@@ -586,3 +596,28 @@ author = {Bowe, Sean and Ogilvie-Wigley, Eirik and and Grigg, Jack},

title = {Implementation of the {J}ubjub elliptic curve group}, note = {Available online: \url{https://github.com/zkcrypto/jubjub} (accessed on 1 June 2022)} } + +@misc{gnark, + author = {Botrel, Gautam and Piellard, Thomas and {El Housni}, Youssef + and Kubjas, Ivo and Tabaie, Arya}, + title = {{Consensys/gnark}}, + publisher = {Zenodo}, + doi = {10.5281/zenodo.5819104}, + url = {https://doi.org/10.5281/zenodo.5819104} +} + +@misc{davinci-node, + author = {{Vocdoni}}, + title = {{DAVINCI} Node: Sequencer Implementation}, + howpublished = {GitHub repository}, + year = {2025}, + url = {https://github.com/vocdoni/davinci-node} +} + +@misc{davinci-contracts, + author = {{Vocdoni}}, + title = {{DAVINCI} Contracts: {EVM} Smart Contracts}, + howpublished = {GitHub repository}, + year = {2025}, + url = {https://github.com/vocdoni/davinci-contracts} +}
M v2/build/main.tex → v2/build/main.tex

@@ -90,9 +90,9 @@ \section{Ballot protocol}

\label{sec:ballot-protocol} \input{\secs/ballot-protocol} -\section{Incentive mechanisms} %Protocol incentives -\label{sec:token} -\input{\secs/token} +%\section{Incentive mechanisms} %Protocol incentives +%\label{sec:token} +%\input{\secs/token} \section{Analysis} \label{sec:analysis}

@@ -102,9 +102,9 @@ \section{Conclusions}

\label{sec:conclusions} \input{\secs/conclusions} -\section{Future work} -\label{sec:future-work} -\input{\secs/future-work} +%\section{Future work} +%\label{sec:future-work} +%\input{\secs/future-work} \section*{Acknowledgments} \addcontentsline{toc}{section}{\protect\numberline{}Acknowledgments}
M v2/build/preamble-macros.tex → v2/build/preamble-macros.tex

@@ -187,6 +187,9 @@ \newcommand{\merkleproofs}{\variablestyle{merkleProofs}}

\newcommand{\merkleInclusionPf}{\variablestyle{inclusionProof}} \newcommand{\merkleNInclusionPf}{\variablestyle{nonInclusionProof}} \newcommand{\configmax}{\variablestyle{configMax}} +\newcommand{\electionmetadata}{\variablestyle{electionMetadata}} +\newcommand{\starttime}{\variablestyle{startTime}} +\newcommand{\duration}{\variablestyle{duration}} % State Merkle tree \newcommand{\censusroot}{\variablestyle{censusRoot}}
M v2/sections/analysis.tex → v2/sections/analysis.tex

@@ -1,27 +1,24 @@

% !TeX root = ../build/main.tex -The \davinci protocol was designed according to a set of guiding principles: cryptography is the sole source of truth; no single entity must be trusted; the system should be modular, open source, and resilient; and it should remain scalable, automated, and accessible to a wide range of users. Building on these principles, we now discuss the concrete security properties of the protocol, followed by implementation details and performance results. -- {\color{blue}This whole section is still [WIP]}.\\ - -\noi {\color{blue}$\rightarrow$ check \scriptsize - \url{https://ethresear.ch/t/vocdoni-protocol-enabling-decentralized-voting-for-the-masses-with-zk-technology/21036}.} - \subsection{Security discussion} \label{sec:analysis:security} -Based on the above principles, the protocol provides a number of concrete security properties that ensure the integrity, confidentiality, and verifiability of voting events. In what follows we discuss how \davinci achieves these properties, with particular emphasis on receipt-freeness, privacy, unlinkability, and robustness against quantum threats. +Based on the above principles, the protocol provides a number of concrete security properties that ensure the integrity, confidentiality, and verifiability of voting events. In what follows we discuss how \davinci achieves these properties, with particular emphasis on integrity, receipt-freeness, and ballot privacy, before turning to data availability, end-to-end verifiability, and robustness against quantum threats. + +\paragraph{Integrity and soundness.} The integrity of the election rests on the knowledge soundness of the \ac{ZK-SNARK} proofs rather than on trust in any operator. No party (including a malicious sequencer) can advance the state from $S_i$ to $S_{i+1}$ without supplying a valid state transition proof, since the settlement contract rejects any update not accompanied by such a proof. Consequently, every counted ballot originates from an eligible census member and every accumulator update follows the protocol rules. Double voting is prevented \emph{without} nullifiers: each voter is bound to a unique, census-authenticated slot in the state tree, so a second submission by the same voter overwrites their previous ballot at that slot rather than adding a new contribution to the tally. Vote identifiers, by contrast, are derived per ballot and therefore differ across submissions, which is precisely what enables individual verifiability without linking a voter to their ciphertext. \paragraph{Receipt-freeness.} Receipt-freeness prevents voters from proving to others how they voted, thereby mitigating coercion and vote-buying. In \davinci this is achieved through re-encryption, ballot overwrites, and randomized state updates. \begin{itemize} - \item \textit{Ballot re-encryption}: since our encryption scheme supports re-randomization, that is, a ciphertext can be refreshed with new randomness without changing the underlying message, sequencers exploit this by re-encrypting the received ballots before committing them to the state Merkle tree, making it computationally infeasible to link a submitted ciphertext with the stored one {\color{blue}(give details of what does \textit{computationally infeasible} mean here)}. - \item \textit{Handling receipts}: because ballots are re-randomized, voters cannot generate a receipt by revealing the randomness $r$ used in encryption, since the ciphertext on-chain no longer corresponds to their $r$. This blocks vote-selling and coercion. - \item \textit{Overwrites}: voters may cast a new ballot at any time, replacing their earlier submission. This ensures that even if coercion occurs, a voter can subsequently change their vote as many times as desired, preserving their ability to express their true choice. When an overwrite occurs, the sequencer substracts the previous ballot from the subtractive accumulator, adds the new ballot to the additive accumulator, and re-encrypts the updated ballot before storing it in the state tree. - \item \textit{Concealing overwrites}: to prevent observers from distinguishing overwrites from routine re-randomizations, sequencers periodically re-encrypt a random subset of stored ballots. This obfuscation ensures that overwrites remain indistinguishable from normal re-randomizations, strengthening receipt-freeness. + \item \textit{Ballot re-encryption}: since our encryption scheme supports re-randomization, that is, a ciphertext can be refreshed with new randomness without changing the underlying message, sequencers re-encrypt the received ballots before committing them to the state Merkle tree. Under the decisional Diffie--Hellman (DDH) assumption on BabyJubjub, a re-randomized ciphertext is indistinguishable from a fresh encryption, so linking a submitted ciphertext to its stored counterpart is as hard as solving DDH. + \item \textit{Handling receipts}: because ballots are re-randomized, voters cannot generate a receipt by revealing the randomness $k$ used in encryption, since the ciphertext on-chain no longer corresponds to their $k$. This blocks vote-selling and coercion. + \item \textit{Overwrites}: voters may cast a new ballot at any time, replacing their earlier submission. This ensures that even if coercion occurs, a voter can subsequently change their vote as many times as desired, preserving their ability to express their true choice. When an overwrite occurs, the sequencer subtracts the previous ballot and adds the new one to the results accumulator, and re-encrypts the updated ballot before storing it in the state tree. + \item \textit{Concealing overwrites}: to prevent observers from distinguishing overwrites from routine re-randomizations, sequencers periodically re-encrypt a random subset of stored ballots. This obfuscation ensures that overwrites remain indistinguishable from normal re-randomizations, + strengthening receipt-freeness. \end{itemize} - -\paragraph{Privacy.} Ballots remain secret even though encrypted ballots are publicly stored and processed. Ballot secrecy is preserved through ElGamal encryption, which allows votes to be aggregated without decryption. Encrypted ballots are stored in public repositories (e.g., Ethereum blobs). Because of \ac{DKG} sequencers cannot decrypt individual ballots themselves. {\color{blue}The protocol does not reveal the ballot but it does reveal if someone has voted or not.} Individual ballots remain private because the protocol only invokes threshold decryption on the final aggregate, not on each ballot separately. +\paragraph{Privacy.} Ballots remain secret even though encrypted ballots are publicly stored and processed. Ballot secrecy is preserved through ElGamal encryption, which allows votes to be aggregated without decryption. Because the encryption key is generated through a \ac{DKG} and its secret counterpart is never reconstructed, no single party can decrypt individual ballots: the protocol only invokes threshold decryption on the final aggregate, never on each ballot separately. Under the assumption that at most $t-1$ key wardens are compromised, the shared secret key cannot be reconstructed and no individual ballot ciphertext can be decrypted. Note that, while the content of a ballot stays hidden, the protocol does reveal whether a given voter has cast a vote, that is, turnout is public, but the choice is not. -\paragraph{Quantum resistance.} Quantum computers threaten discrete-logarithm-based cryptography such as ECDSA and ElGamal. For this reason, \davinci is designed in a modular way that would allow to migrate to post-quantum primitives in the longer term. For example,use CRYSTALS-Dilithium, Falcon, or Rainbow, for signature schemes, Brakerski-Gentry-Vaikuntanathan (BGV) or Brakerski/Fan-Vercauteren (BFV) which are lattice-based homomorphic encryption schemes, and ZK-STARKs for post-quantum zero-knowledge proofs. {\color{blue} Add citations to protocols.} +\paragraph{Quantum resistance.} Quantum computers threaten discrete-logarithm-based cryptography such as ECDSA and ElGamal. For this reason, \davinci is designed in a modular way that would allow migration to post-quantum primitives in the longer term. Candidate replacements include lattice-based signature schemes such as CRYSTALS-Dilithium (ML-DSA) and Falcon, and the hash-based SPHINCS+ (SLH-DSA); lattice-based homomorphic encryption such as BGV or BFV; and ZK-STARKs for transparent, post-quantum ZK proofs. \paragraph{Data availability.} Ballots and state updates are stored in Ethereum blobs. Since these blobs may eventually be pruned from the blockchain, ensuring long-term data availability is an open problem. Possible solutions include decentralized storage networks or dedicated data-availability layers. This remains an active area of research.

@@ -30,19 +27,32 @@

\subsection{Implementation} \label{sec:analysis:implementation} -{\color{blue} The system is modular, consisting of interchangeable components that can be rearranged or integrated with external systems via adaptable interfaces. This allows for redundancy, flexibility, and seamless integration with third-party applications, exemplified by our voting-as-a-service APIs. Vocdoni’s voting platform (App) is open source, universally available and user-friendly. The interface is intuitive for all users, including those less familiar with technology, and accommodates voters that use assistive technologies like screen readers. By releasing our code openly, we invite anyone to audit and contribute, enhancing security and fostering community engagement. Transparency prevents security through obscurity and accelerates innovation. We minimize human intervention through smart contracts and cryptographic protocols, reducing costs and human error. Automation ensures consistent operation and frees resources for voter support and auditing. Add link to repositories and details of the software used.} +\Davinci is implemented as a modular, fully open-source system: the smart contracts, the sequencer node, and the circuits are all publicly available at \url{https://github.com/vocdoni} (in particular \texttt{davinci-contracts}, \texttt{davinci-node}, and \texttt{davinci-circom}). Its components can be recombined or integrated with external services through adaptable interfaces, enabling redundancy and integration with third-party applications such as our voting-as-a-service APIs. -\paragraph{Circuits.} -\begin{itemize} - \item Circuit 1: circom/snarkJS, $\sim 53.000$ constraints. - \item Circuit 2: gnark, $\sim 3.1$ million constraints. - \item Circuit 3: gnark, 40.000 $\times$ (number of votes) constraints. - \item Circuit 4: gnark, $\sim 16$ million constraints. -\end{itemize} +\paragraph{Technological stack and circuit compilation.} +The \davinci circuits are implemented with Circom~\cite{belles2023circom} and gnark~\cite{gnark}, and all use +the Groth16 proof system~\cite{groth2016size} for its minimal proof size and constant-time verification. Each circuit is compiled over the elliptic curve best suited to its role (see Appendix~\ref{sec:cryptographic-primitives:elliptic-curves}). The ballot circuit is compiled with Circom over BN254 for compatibility with Ethereum's precompiles; its threshold-ElGamal operations run over BabyJubjub, whose base field matches the BN254 scalar field. Ballot authentication and census membership are verified in the verifier circuit over BLS12-377, where the voter's ECDSA +signature is checked through emulated SECP256K1 arithmetic, so the protocol can reuse standard Ethereum wallet keys. The resulting proofs are recursively combined in the aggregation circuit over BW6-761 before being verified back inside the BN254 state transition circuit. The final tally proof is likewise produced over BN254, since it is verified on-chain by the \resultsverifier\ contract. -\paragraph{MPC for CRS.} Explain the trusted setup ceremony. +\paragraph{Circuit sizes.} Concrete circuit sizes range from approximately $65$K constraints for the ballot circuit to around $16$M constraints for the state transition circuit, with the aggregation circuit dimensioned for batches of $60$ ballots per transition. + +\paragraph{Trusted setup.} Because Groth16 relies on a circuit-specific common reference string (\ac{CRS}, see Appendix~\ref{sec:cryptographic-primitives:zkp}), the parameters for each circuit are generated through an \ac{MPC} ceremony: a universal powers-of-tau phase, followed by a per-circuit phase that binds the parameters to each constraint system. As long as at least one participant in each ceremony discards their secret contribution, the resulting \ac{CRS} is secure. + +\paragraph{Implementation status.} The current implementation includes all five circuits, the Ethereum smart contracts, and the complete state-transition pipeline. The \ac{DKG} component is implemented but not yet integrated into the live protocol. The codebase has not yet undergone an independent security audit. +% and the design is under peer review for publication. \subsection{Performance evaluation} \label{sec:analysis:performance-evaluation} -{\color{blue} Work in progress.} +We evaluate \davinci along three axes: voter-side proving, sequencer proving, and on-chain verification, together with the data-availability savings from EIP-4844. All benchmarks use the protocol batch size of $60$ ballots per state transition. + +\paragraph{Voter proving.} On consumer hardware (a modern laptop or smartphone), generating a ballot proof takes roughly $10$ seconds in a browser, well within the latency a voter tolerates at casting time and without any specialized hardware. + +\paragraph{Sequencer proving.} The recursive aggregation and state transition circuits were benchmarked on batches of $60$ ballots. A single sequencer running on a server with a consumer-grade GPU and at least $16$GiB of RAM produces the final settlement proof in under $3$ minutes; the same proof can be generated on a standard CPU with at least $32$GiB of RAM in roughly $2.5\times$ the time, keeping the sequencer entry barrier low. Proving parallelizes in two ways: about $85\%$ of the per-batch work can be split across worker processes within a single sequencer, and multiple sequencers can advance independent batches concurrently. With $10$ workers behind one GPU sequencer, the settlement proof is generated in under $32$ seconds; two sequencers with $10$ workers each fsustain a throughput of $200$ settled votes per minute. + +\paragraph{On-chain verification.} Thanks to Groth16's succinctness, verifying the final settlement proof on Ethereum costs an essentially constant ${\approx}\,480$K gas, independent of the number of ballots in the batch. + +\paragraph{Data availability.} \Davinci publishes the data needed to reconstruct each state transition through EIP-4844 blobs. Compared with calldata, blobs substantially reduce data-availability costs by separating large protocol data from permanent Ethereum state. In our +implementation, the data behind a batch of $60$ votes fits into a single $128$KiB blob, the payload unit defined by EIP-4844.\\ + +Together, these results indicate that \davinci scales to large elections at predictable settlement costs and practical proving times. Deploying on an Ethereum L2 or an EVM-compatible sidechain would further reduce per-election cost and raise throughput, since the dominant bottleneck on sequencer parallelization is the block time at which successive state transitions can be settled.
M v2/sections/background.tex → v2/sections/background.tex

@@ -17,7 +17,7 @@ Ethereum is a decentralized blockchain platform that supports programmable transactions through its built-in execution environment, the \acf{EVM}. All interactions with the Ethereum network take the form of transactions, which must be broadcast to the network, validated by consensus, and permanently recorded on-chain. Every transaction requires the payment of a fee (measured in units of gas), denominated in ETH, to compensate validators for computation and storage. This fee model ensures that resources are used efficiently and prevents denial-of-service attacks by making large or complex operations costly. In the context of \davinci, Ethereum serves as the settlement layer where critical commitments are published, ensuring transparency and immutability.

\paragraph{Smart contracts.} Smart contracts are programs deployed on the Ethereum blockchain that execute deterministically in response to transactions. Once deployed, they cannot be altered, and their execution is guaranteed by the consensus of the network. In \davinci, smart contracts orchestrate the election by managing state transitions and storing critical data such as the current state root and the encryption public key. They enforce the protocol rules in a trustless environment, ensuring that no single participant can manipulate the election. By anchoring these rules in Ethereum smart contracts, \davinci guarantees that the election logic is applied consistently and verifiably across all participants. -\paragraph{Data blobs.} Data availability is a key requirement for decentralized protocols. Ethereum’s recent EIP-4844~\cite{eip4844} introduces data blobs as a mechanism for publishing large volumes of off-chain data alongside transactions at a lower cost than traditional storage. These blobs are kept on-chain for 4096 epochs, approximately 18 days, after which they are pruned. For longer election periods, third-party solutions based on EIP-4844 can be used to extend data availability~\cite{todocitation}. In \davinci, sequencers use data blobs to share state transition data efficiently. By publishing state updates in blobs, sequencers allow other participants to reconstruct and verify the evolution of the election without overloading Ethereum’s permanent storage. This ensures scalable, decentralized data availability while retaining verifiability. +\paragraph{Data blobs.} Data availability is a key requirement for decentralized protocols. Ethereum’s recent EIP-4844~\cite{eip4844} introduces data blobs as a mechanism for publishing large volumes of off-chain data alongside transactions at a lower cost than traditional storage. These blobs are kept on-chain for 4096 epochs, approximately 18 days, after which they are pruned. For longer election periods, third-party solutions based on EIP-4844 can be used to extend data availability. In \davinci, sequencers use data blobs to share state transition data efficiently. By publishing state updates in blobs, sequencers allow other participants to reconstruct and verify the evolution of the election without overloading Ethereum’s permanent storage. This ensures scalable, decentralized data availability while retaining verifiability. \subsection{Merkle trees}

@@ -29,11 +29,11 @@ To prove that a specific element $x$ exists within the set, a prover provides a Merkle path consisting of the sibling nodes along the path from the leaf to the root. A verifier can reconstruct the root in logarithmic time $O(\log n)$ and check it against the committed state, without requiring access to the full dataset. In \davinci, we use two specialized variants of this structure to commit critical data: a sparse Merkle tree for the voting state and an incremental Merkle tree for the voter registry (census).

\paragraph{Sparse Merkle trees.} -A \ac{SMT} represents a key-value map where each leaf is the hash of a (key, value) pair and each parent node is the hash of its two children. In an \ac{SMT}, every possible key maps to a unique leaf position (with empty slots defaulting to a zero value), yielding a fixed-height binary tree. This property is circuit-friendly, since the proof of a leaf’s membership or non-membership has a consistent length and can be efficiently verified inside a \ac{ZK-SNARK} circuit using a SNARK-optimized hash. In \davinci, the state tree is implemented as an \ac{SMT} of fixed depth. In particular, configuration parameters occupy reserved leaf addresses, each voter’s encrypted ballot is stored at a leaf indexed by their unique identifier, and each one-time vote identifier is recorded at a dedicated leaf path. Because the \ac{SMT} covers a vast key space, a user or sequencer can prove that a given key is present in the state (or conversely, that it remains empty) by providing a short Merkle proof against the tree’s root, rather than revealing the entire state. This enables compact proofs of state correctness. For instance, showing in ZK that a vote identifier has not appeared before or that a new ballot’s ciphertext is correctly inserted into the state. The \ac{SMT} used in \davinci follows the circomlib Merkle tree specification (Poseidon-based)~\cite{todocitation}, ensuring that state updates can be verified succinctly on-chain via the Merkle root and proof. +A \ac{SMT} represents a key-value map where each leaf is the hash of a (key, value) pair and each parent node is the hash of its two children. In an \ac{SMT}, every possible key maps to a unique leaf position (with empty slots defaulting to a zero value), yielding a fixed-height binary tree. This property is circuit-friendly, since the proof of a leaf’s membership or non-membership has a consistent length and can be efficiently verified inside a \ac{ZK-SNARK} circuit using a SNARK-optimized hash. In \davinci, the state tree is implemented as an \ac{SMT} of fixed depth. In particular, configuration parameters occupy reserved leaf addresses, each voter’s encrypted ballot is stored at a leaf indexed by their unique identifier, and each one-time vote identifier is recorded at a dedicated leaf path. Because the \ac{SMT} covers a vast key space, a user or sequencer can prove that a given key is present in the state (or conversely, that it remains empty) by providing a short Merkle proof against the tree’s root, rather than revealing the entire state. This enables compact proofs of state correctness. For instance, showing in ZK that a vote identifier has not appeared before or that a new ballot’s ciphertext is correctly inserted into the state. The \ac{SMT} used in \davinci follows the circomlib Merkle tree specification (Poseidon-based), ensuring that state updates can be verified succinctly on-chain via the Merkle root and proof. \paragraph{Incremental Merkle trees.} -The census (voter registry) is maintained with an \ac{IMT}, a binary Merkle tree designed for efficient sequential updates~\cite{todocitation}. Unlike a sparse tree, the \ac{IMT} grows in height only as needed with the number of leaves and eliminates the overhead of hashing dummy ``zero'' siblings. In this scheme, voters are assigned sequential leaf indices in a continuously evolving tree, rather than being placed at cryptographic key-derived positions. In \davinci, the census Merkle tree is built as an \ac{IMT}: each eligible voter’s identifier (or a commitment to it) and voting weight are stored in the next available leaf, and only the Merkle root of this tree (the \censusroot) is published on-chain. This design makes membership updates and proof generation extremely low-cost for the census. Appending a new voter requires recomputing hashes only along the single path from the new leaf to the root, and the tree’s depth adjusts optimally (e.g. a tree of $N$ voters has height $\approx \log_2{N}$, instead of a fixed large height). Consequently, proving one’s inclusion in the voter list is more efficient than it would be with an SMT: the Merkle proof is shorter and involves no unnecessary default nodes. A voter can thus obtain a small proof of their membership in the census (their leaf’s existence under the known root) without revealing their index or identity, and include this in a \ac{ZK-SNARK} to demonstrate eligibility. In summary, the \ac{IMT}’s focus on sequential insertion and minimal hashing overhead makes it well-suited for the frequently-updated census tree, offering better update performance and smaller circuits for verification than a traditional \ac{SMT} structure in this context. +The census (voter registry) is maintained with an \ac{IMT}, a binary Merkle tree designed for efficient sequential updates. Unlike a sparse tree, the \ac{IMT} grows in height only as needed with the number of leaves and eliminates the overhead of hashing dummy ``zero'' siblings. In this scheme, voters are assigned sequential leaf indices in a continuously evolving tree, rather than being placed at cryptographic key-derived positions. In \davinci, the census Merkle tree is built as an \ac{IMT}: each eligible voter’s identifier (or a commitment to it) and voting weight are stored in the next available leaf, and only the Merkle root of this tree (the \censusroot) is published on-chain. This design makes membership updates and proof generation extremely low-cost for the census. Appending a new voter requires recomputing hashes only along the single path from the new leaf to the root, and the tree’s depth adjusts optimally (e.g. a tree of $N$ voters has height $\approx \log_2{N}$, instead of a fixed large height). Consequently, proving one’s inclusion in the voter list is more efficient than it would be with an SMT: the Merkle proof is shorter and involves no unnecessary default nodes. A voter can thus obtain a small proof of their membership in the census (their leaf’s existence under the known root) without revealing their index or identity, and include this in a \ac{ZK-SNARK} to demonstrate eligibility. In summary, the \ac{IMT}’s focus on sequential insertion and minimal hashing overhead makes it well-suited for the frequently-updated census tree, offering better update performance and smaller circuits for verification than a traditional \ac{SMT} structure in this context. \subsection{Zero-knowledge proofs} \label{sec:background:zkp}

@@ -47,7 +47,9 @@ Informally, while a \ac{ZK} proof convinces the verifier that a valid witness exists, an argument of knowledge additionally ensures that the prover actually knows such a witness, except with negligible probability. \acsp{ZK-SNARK} extend this notion with two crucial properties: they are non-interactive, requiring only a single message from prover to verifier, and succinct, meaning that proof size and verification cost remain small regardless of the size of the underlying statement. For instance, Groth16 proofs~\cite{groth2016size}, which rely on pairing-based cryptography over elliptic curves, %to achieve short proofs and fast verification [Gro16, GWC19].

are only about 200 bytes long and can be verified in a few milliseconds. These properties make \acsp{ZK-SNARK} particularly well-suited for blockchain applications, where verification cost and data size are critical. In \davinci, \acsp{ZK-SNARK} are used at multiple stages of the protocol: voters generate proofs to show that their encrypted ballots are correct and sequencers use recursive \acsp{ZK-SNARK} to allow multiple proofs to be aggregated efficiently and generate proofs to attest to valid state transitions. In essence, \acsp{ZK-SNARK} enable both voters and sequencers to produce compact proofs that can be checked on-chain, ensuring that all protocol rules are followed without requiring trust in any party. \paragraph{Trusted setup.} -A limitation of some \ac{ZK-SNARK} protocols is their reliance on a \ac{CRS} generated during a so-called trusted setup. The \ac{CRS} is built from random values that must not be known to either the prover or the verifier. To achieve this, the \ac{CRS} can be created by a trusted third party or, more robustly, via a secure \ac{MPC} protocol \cite{canetti2001universally}. In an MPC setup, it suffices that at least one participant discards their secret contribution to ensure the integrity of the whole ceremony. {\color{blue}For \davinci, we run an \ac{MPC} for each of the circuits, see Section~\ref{sec:analysis:implementation} and Section~\ref{sec:cryptographic-primitives:zkp}.} +A limitation of some \ac{ZK-SNARK} protocols is their reliance on a \ac{CRS} generated during a so-called trusted setup. The \ac{CRS} is built from random values that must not be known to either the prover or the verifier. To achieve this, the \ac{CRS} can be created by a trusted third party or, more robustly, via a secure \ac{MPC} protocol \cite{canetti2001universally}. In an MPC setup, it suffices that at least one participant discards their secret contribution to ensure the integrity of the whole ceremony. + +\marta{For \davinci, we run an \ac{MPC} for each of the circuits, see Section~\ref{sec:analysis:implementation} and Section~\ref{sec:cryptographic-primitives:zkp}.} % By anchoring these proofs on Ethereum, the protocol ensures that every step of the voting process is publicly verifiable, while preserving voter privacy. %In general, zk-SNARKs for circuit satisfiability (CSAT) require arithmetic circuits to be expressed in a more algebraic form. A common representation is the rank-1 constraint system (R1CS) [GGPR13], which encodes computations as a set of quadratic constraints. A zk-SNARK proof then demonstrates, without revealing any private values, that the prover knows an assignment to all wires of the circuit that satisfies the R1CS. Tooling such as circom provides a high-level language to write arithmetic circuits while still exposing full control over the signals and constraints of the resulting R1CS.

@@ -57,7 +59,7 @@ An arithmetic circuit (from now on also called circuit or \ac{ZK} circuit) is a directed acyclic graph where nodes represent addition or multiplication gates over a finite field. The inputs and outputs of the circuit correspond to the public inputs and private witnesses of the computation, while the intermediate wires carry intermediate values. Any deterministic computation, from verifying an encryption to checking Merkle proofs, can be compiled into an arithmetic circuit \cite{gennaro2013quadratic}.

%The most widely studied language in the context of ZK-SNARK proofs is the NP-complete language of circuit satisfiability [BCC+ 16, PHGR13, BSCTV14b]. %zk-SNARKs prove statements about the satisfiability of arithmetic circuits. An arithmetic circuit is a directed acyclic graph consisting of addition and multiplication gates defined over a finite field. Such circuits are a convenient model for computation: any program or verification logic can be compiled into an arithmetic circuit, with its inputs, outputs, and intermediate constraints expressed as field operations. In practice, proving with \acsp{ZK-SNARK} means showing knowledge of a secret witness (e.g., a plaintext ballot or encryption randomness) that satisfies all the equations encoded in the circuit. For example, the ballot circuit in \davinci encodes the constraints that a ciphertext is well-formed, that the vote identifier is correctly derived, and that the ballot complies with the rules of the voting mode. The prover generates a proof of satisfiability, while the verifier only checks the proof against the public inputs, without learning the secret witness. -By building complex protocol logic from arithmetic circuits, and using \acsp{ZK-SNARK} to prove their satisfiability, \davinci ensures that every step of the election process, from ballot submission to state transitions, is enforced cryptographically and publicly verifiable. % is verifiable in zero-knowledge. +By building complex protocol logic from arithmetic circuits and using \acsp{ZK-SNARK} to prove their satisfiability, \davinci ensures that every step of the election process, from ballot submission to state transitions, is enforced cryptographically and publicly verifiable. % is verifiable in zero-knowledge. %In \davinci, arithmetic circuits form the backbone of all zk-SNARK proofs: voters use them to generate ballot proofs, sequencers use them to prove state transitions, and aggregation circuits recursively combine multiple proofs. Together, these circuits ensure that every step of the protocol is enforced cryptographically and can be verified succinctly on-chain.
M v2/sections/census.tex → v2/sections/census.tex

@@ -2,14 +2,15 @@ % !TeX root = ../build/main.tex

The census defines the set of eligible voters and their associated voting weights. At its core, a census is simply a dataset that, for each voter, contains a unique identifier (typically an Ethereum address), a sequential index, a voting weight, and a means to produce a membership proof that can be verified inside a \ac{ZK} circuit. \Davinci supports two mechanisms for generating such proofs: \begin{itemize} - \item \textit{Credential-based membership proofs}: eligibility is certified by a digital signature issued by a \ac{CSP}. The CSP assigns a unique index ($\idx$) to each voter and includes it in the signed credential alongside the voter's identifier (\address) and weight (\weight). - \item \textit{Merkle-tree-based membership proofs}: the census is organized as an incremental Merkle tree (see Appendix~\ref{sec:cryptographic-primitives:merkle-trees}) and denoted by $\hlset{\censusTree}$. Each voter is assigned a unique sequential index ($\idx$) in the tree, and their identifier and weight are stored in the corresponding leaf. Only the Merkle root is kept on-chain, and sequencers supply Merkle proofs to attest membership. Each voter is assigned a unique sequential index ($\idx$) at the time of registration, and their identifier ($\address$) and weight ($\weight$) are stored as a leaf at position $\idx$ in the tree. A membership proof ($\censuspf$) for voter $i$ is a Merkle path attesting that the tuple $(\address_i,\weight_i)$ is stored at position $\idx$ under the committed census tree root. + \item \textit{Credential-based membership proofs}. Eligibility is certified by a digital signature issued by a \ac{CSP}. The \ac{CSP} assigns a unique index ($\idx$) to each voter and includes it in the signed credential alongside the voter's identifier (\address), their weight (\weight), and the process identifier (\processid). + \item \textit{Merkle-tree-based membership proofs}. The census is organized as an \ac{IMT} (see Appendix~\ref{sec:cryptographic-primitives:merkle-trees}) and denoted by $\hlset{\censusTree}$. + Each voter is assigned a unique sequential index ($\idx$) at the time of registration, and their identifier ($\address$) and weight ($\weight$) are stored as a leaf at position $\idx$ in the tree. A membership proof ($\censuspf$) for voter $i$ is a Merkle path attesting that the tuple $(\address_i,\weight_i)$ is stored at position $\idx_i$ under the committed census tree root. Sequencers supply these Merkle proofs to attest voters' membership to the census and the index $\idx$ is used to derive the voter's reserved storage slot in the state tree (see Section~\ref{sec:vocdoni-protocol:state-tree}). \end{itemize} % -To support different census models, the \hlget{\electionregistry} smart contract stores the following three parameters: +To support the different census models, the \hlget{\electionregistry} smart contract stores the following parameters: \begin{itemize} \item \censusorigin: the deployment model (off-chain static, off-chain dynamic, on-chain dynamic, or \ac{CSP}). \item \censusuri: a \ac{URI} pointing to an external reference (URL, GraphQL endpoint, CDN path, IPFS/IPNS, etc.) from which sequencers can download or query the census data.

@@ -22,6 +23,14 @@ %This is correct, but it is not the way DAVINCI is designed to support token-based censuses. In the case of token-based, there must be a smart-contract that builds a Merkle-Tree onchain. Then we declare a census Root the address of that contract.

This flexibility supports a broad range of use cases and governance scenarios. % The supported census models are summarized in Table~\ref{tab:census-models} and described in detail below. + +\paragraph{Credential service provider.} Voter eligibility is certified by a digital signature issued by a \ac{CSP}. A voter obtains a signed credential from the \ac{CSP}, and sequencers verify the signature inside the \ac{ZK} circuits. The credential is issued over the tuple $(\processid,\idx,\address,\weight)$ where $\idx$ is a unique index assigned by the CSP to each voter. This index will be used by the state transition circuit to derive the voter's reserved storage slot in the state tree (see Section~\ref{sec:vocdoni-protocol:state-tree}). In this case, \censusroot stores the hash of the \ac{CSP}’s public key, and \censusuri specifies the endpoint where voters obtain their credential. This model is suitable when eligibility is managed externally through attested identities rather than by maintaining a Merkle-tree dataset. + +\paragraph{Off-chain static census.} The organizer constructs a fixed census prior to the election. The Merkle tree is built locally and the resulting root is stored in \censusroot, and \censusuri specifies the endpoint from which sequencers can retrieve the full tree. Since the census is static, no updates occur during the voting period. + +\paragraph{Off-chain dynamic census.} The Merkle tree remains off-chain, but the organizer may append new voters during the voting period (never deleting voters or modifying weights, as this would enable double voting). Each new insertion produces a new Merkle root, which the organizer must publish to the \hlget{\electionregistry} contract by updating the \censusroot parameter. As in the static model, \censusuri provides the endpoint from which sequencers can download the current version of the tree. Sequencers verify membership proofs against the most recently published root. + +\paragraph{On-chain dynamic census.} In this configuration, the census is managed by a dedicated on-chain contract (\hlget{\censusmanagement}) that supports adding new members during the voting period. The address of this contract is stored in \censusroot, while \censusuri points to an external representation of the tree. The \hlget{\censusmanagement} contract maintains a history of valid Merkle roots. Sequencers may therefore generate membership proofs using older roots, and during state transitions the \hlget{\electionregistry} contract queries the \hlget{\censusmanagement} contract to verify that the root used in the proof is still valid. As in all dynamic models, only additions to the census are permitted during the voting period. \begin{table}[H] \centering

@@ -66,14 +75,6 @@ \vspace{0.5cm}

\caption{Summary of census configurations supported by the \davinci protocol.} \label{tab:census-models} \end{table} - -\paragraph{Credential service provider.} Voter eligibility is certified by a digital signature issued by a \ac{CSP}. A voter obtains a signed credential from the \ac{CSP}, and sequencers verify the signature inside the \ac{ZK} circuits. The credential is issued over the tuple $(\processid,\idx,\address,\weight)$ where $\idx$ is a unique index assigned by the CSP to each voter. This index plays the same role as in the Merkle-tree census models: it is used by the state transition circuit to derive the voter's reserved storage slot in the state tree (see Section~\ref{sec:vocdoni-protocol:state-tree}). In this case, \censusroot stores the hash of the \ac{CSP}’s public key, and \censusuri specifies the endpoint where voters obtain their credential. This model is suitable when eligibility is managed externally through attested identities rather than by maintaining a Merkle-tree dataset. - -\paragraph{Off-chain static census.} The organizer constructs a fixed census prior to the election. The Merkle tree is built locally and the resulting root is stored in \censusroot, and \censusuri specifies the endpoint from which sequencers can retrieve the full tree. Since the census is static, no updates occur during the voting period. - -\paragraph{Off-chain dynamic census.} The Merkle tree remains off-chain, but the organizer may append new voters during the voting period (never deleting voters or modifying weights, as this would enable double voting). Each new insertion produces a new Merkle root, which the organizer must publish to the \hlget{\electionregistry} contract by updating the \censusroot parameter. As in the static model, \censusuri provides the endpoint from which sequencers can download the current version of the tree. Sequencers verify membership proofs against the most recently published root. - -\paragraph{On-chain dynamic census.} In this configuration, the census is managed by a dedicated on-chain contract (\hlget{\censusmanagement}) that supports adding new members during the voting period. The address of this contract is stored in \censusroot, while \censusuri points to an external representation of the tree. The \hlget{\censusmanagement} contract maintains a history of valid Merkle roots. Sequencers may therefore generate membership proofs using older roots, and during state transitions the \hlget{\electionregistry} contract queries the \hlget{\censusmanagement} contract to verify that the root used in the proof is still valid. As in all dynamic models, only additions to the census are permitted during the voting period. %CENSUS ORIGIN %MerkleTreeOffchainStaticV1
M v2/sections/circuits.tex → v2/sections/circuits.tex

@@ -4,7 +4,7 @@ At the core of \davinci lie a set of arithmetic circuits that enforce the correctness of every step of the election. 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 the voter's proof; the \emph{aggregation circuit} (Section~\ref{sec:vocdoni-protocol:circuits:aggregation}) combines multiple authenticated votes into a single proof; the \emph{state transition circuit} (Section~\ref{sec:vocdoni-protocol:circuits:state-transition}) updates the global state root and produces the \ac{ZK-SNARK} proof that is verified on-chain; and the \textit{results circuit} (Section~\ref{sec:vocdoni-protocol:circuits:results}) proves that the election results were computed correctly. The flow of these circuits and their interactions is shown in Fig.~\ref{fig:circuits-flow}.

\begin{figure}[h] \centerline{\includegraphics[width=\linewidth,draft=false]{\figs/circuits-flow.pdf}} \caption{ - Overview of the circuit flow in \davinci. {\color{blue}\textit{Results circuit} is missing.}} + Flow of the voter and sequencers circuits.} \label{fig:circuits-flow} \end{figure}

@@ -19,7 +19,7 @@ \label{sec:vocdoni-protocol:circuits:ballot}

The ballot circuit (\hlset{\ballotcircuit}), illustrated in Fig.~\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 \ac{ZK} proof generated using the \ac{ZK-SNARK} protocol described in Appendix~\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} +%\begin{spacing}{1.25} \vspace{0.3cm} \noi \textbf{Public inputs} \begin{itemize}

@@ -46,7 +46,7 @@ % \[\voteid = \text{Hash} (\processid \conc \address \conc k).\]

\[\voteid = N + \bigl(\hlget{\Poseidon}(\processid,\address,k) \bmod N\bigr).\] \end{itemize} \vspace{-0.3cm} -\end{spacing} +%\end{spacing} \begin{figure}[H] \centerline{\includegraphics[width=380pt,draft=false]{\figs/circuit1.pdf}}

@@ -59,7 +59,7 @@ \label{sec:vocdoni-protocol:circuits:verifier}

The verifier circuit (\hlset{\verifiercircuit}), illustrated in Fig.~\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 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. -\begin{spacing}{1.25} +%\begin{spacing}{1.25} \vspace{0.3cm} \noi \textbf{Public inputs} \begin{itemize}

@@ -101,7 +101,7 @@ $$\hlget{\PVerify}(\ballotproof, \publicinputs) = \true.$$

\end{itemize} \end{itemize} \vspace{-0.3cm} -\end{spacing} +%\end{spacing} \begin{figure}[H] \centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit2.pdf}}

@@ -114,7 +114,7 @@ \label{sec:vocdoni-protocol:circuits:aggregation}

The aggregation circuit (\hlset{\aggregationcircuit}), illustrated in Fig.~\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 election. The batch size ($\batchsize$), 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 \ac{ZK-SNARK} protocol described in Appendix~\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} +%\begin{spacing}{1.25} \vspace{0.3cm} \noi \textbf{Public inputs} \begin{itemize}

@@ -144,7 +144,7 @@ \end{itemize}

\item \emph{Shared public inputs.} All authentication proofs are verified using the same public inputs \processid, \ballotmode, and \epk. \end{itemize} \vspace{-0.3cm} -\end{spacing} +%\end{spacing} \begin{figure}[h] \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit3.pdf}}

@@ -160,7 +160,7 @@ The state transition circuit (\hlset{\statetransitioncircuit}), illustrated in Fig.~\ref{fig:circuit-state-transition-v2}, is generated by the sequencer to update the global state of the election. 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, that the accumulators of encrypted results are updated accordingly, that each included vote corresponds to an eligible voter included in the census, and that the state transition data used by the sequencer matches the data made available through Ethereum data blobs. The correctness of this circuit is attested by a \ac{ZK} proof generated using the \ac{ZK-SNARK} protocol described in Appendix~\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}$. It is submitted on-chain and verified by the process management smart contract, ensuring that every accepted state transition complies with the protocol rules.

To formalize the setting, let the sequencer collect a batch of $N$ votes ($N\leq60$), of which $n$ are new vote submissions and $m = N-n$ are overwrites of previously cast ballots. Without loss of generality, we assume that the batch is ordered such that the first $n$ votes correspond to new submissions, and the remaining $m$ votes correspond to overwrites. In the following, we describe the inputs and constraints of the state transition circuit in detail. -\begin{spacing}{1.25} +%\begin{spacing}{1.25} \vspace{0.3cm} \noi \textbf{Public inputs} \begin{itemize}

@@ -220,13 +220,13 @@ \item \emph{Census membership.} Each processed vote must correspond to an eligible voter, according to the census configuration specified by the parameter \texttt{censusOrigin}.

\begin{itemize} \item If \texttt{censusOrigin} = CSP, then verify a signature issued by the CSP. Concretely, for all $i \in \{1,\dots,N\}$: \[ - \hlget{\SVer}_{\censusroot}\big((\address_i, \weight_i), \censuspf_i\big) = \true, + \hlget{\SVer}_{\censusroot}\big((\processid, \idx_i, \address_i, \weight_i), \censuspf_i\big) = \true, \] - where \(\censusroot\) contains the CSP public key and \(\censuspf_i\) is the eligibility signature attesting that voter \(i\) belongs to the census with the given weight. {\color{blue}Missing parameters in the message being signed, e.g. $\processid$.} + where \(\censusroot\) contains the CSP public key and \(\censuspf_i\) is the eligibility signature attesting that voter \(i\) belongs to the census with the given weight. \item Otherwise, if the census is represented by an \ac{IMT}, the circuit verifies a Merkle membership proof showing that the pair \((\address_i, \weight_i)\) is included in the committed census. For all $i \in \{1,\dots,N\}$: \[ - \hlget{\censusTree}.\hlget{\MTVerify}\big((\address_i, \weight_i), \censuspf_i, \censusroot\big) = \true. + \hlget{\censusTree}.\hlget{\MTVerify}\big((\address_i, \weight_i), \idx_i, \censuspf_i, \censusroot\big) = \true. \] \end{itemize} %

@@ -274,7 +274,7 @@ \end{enumerate}

\end{itemize} \item After all previous state transitions are done, recompute new tree root: \[\stateroot^\new = \hlget{\stateTree}.\hlget{\MTRoot}().\] - \item {\color{blue} Reencrypt a set of old leafs from the tree: first, very their Merkle tree inclusion proofs, then reencrypt them, and finally update each leaf's content.} + \item Reencrypt a set of old leafs from the tree: first, very their Merkle tree inclusion proofs, then reencrypt them, and finally update each leaf's content. \end{itemize} \item \emph{Data blob}. \begin{itemize}

@@ -289,7 +289,7 @@ \(\hlget{\CVerify}(z, y, C, \openproof) = \true.\)\\

\end{itemize} \end{itemize} \vspace{-0.3cm} -\end{spacing} +%\end{spacing} \begin{remark} Splitting the sequencer computation into three circuits provides an important efficiency benefit. If the global $\stateroot$ changes while a sequencer is preparing a proof, only the last circuit must be re-run to reflect the updated state, avoiding the need to recompute all previous proofs.

@@ -299,17 +299,49 @@ \begin{landscape}

\centering {\setkeys{Gin}{draft=false}%shows image even in draft mode \includegraphics[width=\linewidth]{\figs/circuit4.pdf}} - \captionof{figure}{State transition circuit. All public values are framed in green. {\color{blue}\textbf{Missing inputs:} old encryptedBallots.}} + \captionof{figure}{State transition circuit. All public values are framed in green.} \label{fig:circuit-state-transition-v2} \end{landscape} \subsubsection{Results circuit} \label{sec:vocdoni-protocol:circuits:results} -The results circuit (\hlset{\resultscircuit}) proves that... . +%The results circuit (\hlset{\resultscircuit}), illustrated in Fig.~\ref{fig:circuit-results}, is +The results circuit (\hlset{\resultscircuit}) is generated at the end of the election, by the organizer or a sequencer, to prove that the published tally was correctly obtained from the encrypted results committed in the final state. Crucially, the circuit does not take the decryption key as input, nor does it decrypt inside the circuit: instead, for each ballot field it verifies a proof of correct decryption against the encryption public key that is committed in the state tree. The correctness of this circuit is attested by a \ac{ZK} proof generated using the \ac{ZK-SNARK} protocol described in Appendix~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BN254 curve, so that it can be verified on-chain by the \hlget{\resultsverifier}\ contract using Ethereum's native precompiles. We call the resulting proof the \textit{results proof} and denote it as $\hlset{\resultsproof}$. We detail below the inputs and constraints of the results circuit. -\begin{figure}[h] - \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit5.pdf}} - \caption{Aggregation circuit. All public values are framed in green. \color{red}Circuit is not correct.} - \label{fig:circuit-results} -\end{figure} +%\begin{spacing}{1.25} + \vspace{0.3cm} + \noi \textbf{Public inputs} + \begin{itemize} + \item \public $\stateroot$: final root of the state tree. + \item \public $\{\text{results}_j\}_{j=1}^{n_f}$: decrypted tally, one entry per ballot field. + \end{itemize} + \textbf{Private inputs} + \begin{itemize} + \item \private $\encresults$: encrypted results accumulator stored in the state ($n_f$ ElGamal ciphertexts). + \item \private $\epk$: encryption public key. + \item \private $\merkleInclusionPf^{\encresults}$: proof that $\encresults$ is stored in leaf $\texttt{0x4}$ of the state tree. + \item \private $\merkleInclusionPf^{\epk}$: proof that $\epk$ is stored in leaf $\texttt{0x3}$ of the state tree. + \item \private $\{\pi^{\mathrm{dec}}_j\}_{j=1}^{n_f}$: per-field proofs of correct decryption. + \end{itemize} + \textbf{Constraints} + \begin{itemize} + \item \emph{State commitment}. The encrypted results and the encryption public key match the values committed in the final state: + \[\stateTree.\hlget{\MTVerify}(\encresults, \texttt{0x4}, \merkleInclusionPf^{\encresults}, \stateroot),\] + \[\stateTree.\hlget{\MTVerify}(\epk, \texttt{0x3}, \merkleInclusionPf^{\epk}, \stateroot).\] + \item \emph{Correct decryption}. For every ballot field $j \in \{1, \dots, n_f\}$, the public result $\text{results}_j$ is the decryption of the encrypted accumulator $\encresults_j$ under $\epk$, as attested by $\pi^{\mathrm{dec}}_j$: + \[\mathsf{DecVerify}_{\epk}\bigl(\encresults_j,\ \text{results}_j,\ \pi^{\mathrm{dec}}_j\bigr) = \true.\] + \item \emph{Results range}. Each result lies in the valid plaintext range: + \[0 \le \text{results}_j \le t - 1, \qquad j = 1, \dots, n_f,\] + where $t$ is the order of the BabyJubjub prime-order subgroup (see Appendix~\ref{sec:cryptographic-primitives:elliptic-curves}) and $n_f$ denotes the number of ballot fields (see Section~\ref{sec:ballot-protocol}). + \end{itemize} + \vspace{-0.3cm} +%\end{spacing} +% +The per-field decryption proofs $\pi^{\mathrm{dec}}_j$ are produced during the tally decryption phase, where the key wardens jointly decrypt the aggregated results and attest, through a discrete-log-equality proof, that the decryption was performed correctly under the threshold key. By checking these proofs against the public key committed at leaf $\texttt{0x3}$, the circuit guarantees that the released tally corresponds exactly to the encrypted results accumulated in the final state, without ever exposing the decryption key inside the circuit. + +%\begin{figure}[h] +% \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit5.pdf}} +% \caption{Aggregation circuit. All public values are framed in green. \color{red}Circuit is not correct.} +% \label{fig:circuit-results} +%\end{figure}
M v2/sections/conclusions.tex → v2/sections/conclusions.tex

@@ -1,1 +1,7 @@

% !TeX root = ../build/main.tex + +We presented \davinci, a decentralized, E2E-verifiable voting protocol implemented as a specialized ZK rollup. By modeling elections as ZK-verified state transitions settled on Ethereum, \davinci combines public auditability with scalable off-chain execution while minimizing reliance on any single party. Ballot secrecy is achieved through threshold ElGamal encryption under a DKG-generated key, while ciphertext re-randomization and silent revoting strengthen protection against coercion and vote-selling. + +To our knowledge, \davinci is the first system to combine a universal ballot abstraction, an open sequencer set, and fully proof-enforced election execution within a single rollup architecture. This enables a reusable voting infrastructure in which elections with different ballot formats and organizers can share the same settlement layer, verifier contracts, and proving pipeline. + +Several directions remain open for future work. An important long-term direction is post-quantum migration, particularly through STARK-based proving systems and post-quantum signature and encryption schemes. Another is simplifying the proving architecture through general-purpose zkVM-based implementations, which may reduce development complexity and support larger proving batches. We also plan to integrate with real-world credential providers and conduct large-scale deployment experiments in realistic electoral settings
M v2/sections/cryptographic-primitives.tex → v2/sections/cryptographic-primitives.tex

@@ -160,7 +160,7 @@

\subsection{Hash functions} \label{sec:cryptographic-primitives:hash} -\Davinci uses different hash functions. On the one side, we use Keccak256~\cite{bertoni2011keccak} for Ethereum address derivation, and Poseidon~\cite{grassi2021poseidon}, MiMC and MiMC-7~\cite{albrecht2016mimc} for arithmetic circuits within zero-knowledge proofs. +\Davinci uses tow hash functions. On the one side, we use Keccak256~\cite{bertoni2011keccak} for Ethereum address derivation and Poseidon~\cite{grassi2021poseidon} for everywhere else. \paragraph{Keccak256.} Keccak256 is the standard hash function used by Ethereum and is employed in \davinci to compress messages for signing and deriving Ethereum addresses from public keys over $\SEC{\G}$. Keccak256 takes arbitrary-length bitstrings and outputs 256-bit digests: $\hlset{\Keccak} : \{0,1\}^* \rightarrow \{0,1\}^{256}$. This function is not SNARK-friendly and it is used exclusively in the authentication circuit, where the verification of Ethereum-compatible signatures requires reproducing the original message hash computed by Ethereum clients (see Section~\ref{sec:vocdoni-protocol:circuits:verifier}).

@@ -328,7 +328,7 @@

\subsection{Distributed key generation scheme} \label{sec:cryptographic-primitives:dkg} -To ensure that no single entity controls the decryption key, DAVINCI employs a \ac{DKG} protocol to jointly derive the ElGamal encryption key pair used for ballots encryption~\cite{todocitation}. Participants who contribute to the \ac{DKG} ceremony are called \emph{\keywardens}, and they are each identified by a unique index~$i$. The outcome is a collective public key (\epk) that is published on-chain and used by voters to encrypt their ballots, while the corresponding private key is secret-shared among the \keywardens. Only a threshold number $t$ out of $n$ \keywardens can later collaborate to decrypt the tally. Unlike classical \ac{DKG} protocols where shares are exchanged in the clear, our construction uses encrypted shares and \ac{ZK-SNARK} proofs of correctness. This allows the Ethereum smart contract to verify compliance without learning any of the underlying secrets, ensuring both security and verifiability in a fully decentralized setting. +To ensure that no single entity controls the decryption key, DAVINCI employs a \ac{DKG} protocol to jointly derive the ElGamal encryption key pair used for ballots encryption. Participants who contribute to the \ac{DKG} ceremony are called \emph{\keywardens}, and they are each identified by a unique index~$i$. The outcome is a collective public key (\epk) that is published on-chain and used by voters to encrypt their ballots, while the corresponding private key is secret-shared among the \keywardens. Only a threshold number $t$ out of $n$ \keywardens can later collaborate to decrypt the tally. Unlike classical \ac{DKG} protocols where shares are exchanged in the clear, our construction uses encrypted shares and \ac{ZK-SNARK} proofs of correctness. This allows the Ethereum smart contract to verify compliance without learning any of the underlying secrets, ensuring both security and verifiability in a fully decentralized setting. {\color{blue} Let $t$ be the threshold parameter and $n$ the number of \keywardens, with $t\leq n$. Let $G$ be a generator of the elliptic curve group of order $q$. Each participant $P_i$ runs the following procedure.

@@ -391,7 +391,7 @@ }

\end{itemize} \end{mdframed} -This approach ensures that the encryption public key is securely generated in a decentralized way, that each \keywarden learns only their own secret share, and that the correctness of the entire \ac{DKG} procedure is verifiable on-chain. Misbehavior, such as submitting invalid shares, can be detected and penalized through the slashing mechanism enforced by the smart contract (see Section~\ref{sec:token}). +This approach ensures that the encryption public key is securely generated in a decentralized way, that each \keywarden learns only their own secret share, and that the correctness of the entire \ac{DKG} procedure is verifiable on-chain. Misbehavior, such as submitting invalid shares, can be detected and penalized through the slashing mechanisms that may be enforced by the smart contract.% (see Section~\ref{sec:token}). \subsection{Zero-knowledge proof systems} \label{sec:cryptographic-primitives:zkp}
M v2/sections/future-work.tex → v2/sections/future-work.tex

@@ -1,7 +1,3 @@

% !TeX root = ../build/main.tex -\begin{itemize} - \item Voter: they do circuit1 + circuit2 themselves (instead of the sequencer doing circuit2). - \item Post-quantum. - \item Support to xxx. -\end{itemize}+Several directions remain open for future work. An important long-term direction is post-quantum migration, particularly through STARK-based proving systems and post-quantum signature and encryption schemes. Another is simplifying the proving architecture through general-purpose zkVM–based implementations, which may reduce development complexity and support larger proving batches. We also plan to integrate with real-world credential providers and conduct large-scale deployment experiments in realistic electoral settings
M v2/sections/introduction.tex → v2/sections/introduction.tex

@@ -52,4 +52,6 @@ \subsection{Paper organization}

\label{sec:introduction:organization} The rest of the paper is organized as follows. In Section~\ref{sec:background} we introduce the necessary background. -In Section~\ref{sec:protocol-intuition} we provide a high-level overview of a voting process, omitting technical details for clarity. In Section~\ref{sec:vocdoni-protocol} we describe the full voting process in detail and in Section~\ref{sec:ballot-protocol} we focus on the ballot protocol. In Section~\ref{sec:token} we discuss the role of the Vocdoni token within the incentive structure of the system. In Section~\ref{sec:analysis} we analyze the protocol, covering its security properties, implementation details, and performance evaluation. In Section~\ref{sec:conclusions} we conclude the paper with final remarks and future work. Finally, we include Appendix~\ref{sec:cryptographic-primitives} with the concrete instantiations of all the cryptographic primitives used in the protocol. +In Section~\ref{sec:protocol-intuition} we provide a high-level overview of a voting process, omitting technical details for clarity. In Section~\ref{sec:vocdoni-protocol} we describe the full voting process in detail and in Section~\ref{sec:ballot-protocol} we focus on the ballot protocol. +%In Section~\ref{sec:token} we discuss the role of the Vocdoni token within the incentive structure of the system. +In Section~\ref{sec:analysis} we analyze the protocol, covering its security properties, implementation details, and performance evaluation. In Section~\ref{sec:conclusions} we conclude the paper with final remarks and future work. Finally, we include Appendix~\ref{sec:cryptographic-primitives} with the concrete instantiations of all the cryptographic primitives used in the protocol.
M v2/sections/parties.tex → v2/sections/parties.tex

@@ -6,11 +6,11 @@ \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. The corresponding secret key is secret-shared among them so that a threshold of key wardens can later collaborate to decrypt the final tally. %Individual ballots remain private because the protocol only invokes threshold decryption on the final aggregate, not on each ballot separately. -\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 Appendix~\ref{sec:cryptographic-primitives}.} +%\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 Appendix~\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. +\paragraph{Sequencers.} Sequencers are a set of parties that during the voting period receive and verify encrypted ballots from voters, reencrypt votes, and update the shared public state accordingly. %Sequencers are a set of decentralized parties that facilitate the election during the voting period. They receive and verify encrypted ballots from voters, reencrypt votes to prevent coercion, and update the shared public state accordingly.
M v2/sections/protocol-flow.tex → v2/sections/protocol-flow.tex

@@ -1,14 +1,14 @@

% !TeX root = ../build/main.tex -In this section we describe the overall flow of the \davinci voting protocol. An election is structured into five main phases: election setup, encryption key generation, voting period, tally decryption, and election finalization. Each phase specifies the interactions between the organizer, \keywardens, voters, sequencers, and the smart contracts that coordinate the election. An overview of the complete process is shown in Fig.~\ref{fig:protocol-flow}. +In this section we describe the overall flow of the \davinci voting protocol. An election is structured into five main phases: election setup, encryption key generation, voting period, tally decryption, and election finalization. Each phase specifies the interactions between the organizer, \keywardens, voters, sequencers, and the smart contracts that coordinate the election. %An overview of the complete process is shown in Fig.~\ref{fig:protocol-flow}. \subsubsection{Election setup} \label{sec:election-setup} -Before any election can begin, sequencers must register by staking \token tokens in the -{\color{blue}sequencer-registry} smart contract (see Section~\ref{sec:token}). This registration -is a one-time operation per sequencer and is independent of any particular election; only -registered sequencers are eligible to participate in the \ac{DKG} phase and to process votes. +%Before any election can begin, sequencers must register in the \hlget{\electionregistry} smart contract. This registration is a one-time +%operation per sequencer and is independent of any particular election. +%; only registered +%sequencers are eligible to participate in the processing of votes. % For each new election, the organizer performs the following steps:

@@ -19,188 +19,251 @@ $\censusTree$ from it. Publish the full tree to IPFS, and record the resulting URI as $\censusuri$.

\item Compute the census commitment $\censusroot = \censusTree.\hlget{\MTRoot}()$. - \item Define the election details, including duration, the census model $\censusorigin$ + \item Define the election details: the start time (\starttime), the duration of the voting period (\duration), the census model $\censusorigin$ (see Section~\ref{sec:vocdoni-protocol:census}), and the ballot rules $\ballotmode$ - (see Section~\ref{sec:ballot-protocol}). + (see Section~\ref{sec:ballot-protocol}). - \item Upload the election metadata (questions, options, description, etc.)\ to IPFS to obtain {\color{blue}electionMetadata}. + \item Upload the election metadata (questions, options, description, etc.)\ to IPFS and + record the resulting URI as $\electionmetadata$. - \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 Determine the process identifier $\processid$, a 32-byte value derived + deterministically from the organizer's Ethereum address, the account nonce, and a prefix + encoding the chain identifier and the \hlget{\electionregistry} smart contract. Being deterministic, it can be + computed in advance by the organizer, although it is ultimately recomputed and assigned by + the contract upon registration. - \item Initialize the state Merkle tree $\stateTree$ by inserting the election configuration - parameters into the reserved configuration namespace (see Section~\ref{sec:vocdoni-protocol:state-tree}): - $\processid$ at leaf $\mathtt{0x0}$, $\ballotmode$ at leaf $\mathtt{0x2}$, - $\censusorigin$ at leaf $\mathtt{0x6}$, and zero-valued accumulators $\addaccumulator$ and - $\substractaccumulator$ at leaves $\mathtt{0x4}$ and $\mathtt{0x5}$, respectively. {\color{blue}Compute the - initial state root -- is this done by the SC?} - \[ - \stateroot = \stateTree.\hlget{\MTRoot}(). - \] + \item Obtain the encryption public key $\epk$ for this process. The key is produced by the + key wardens through the \ac{DKG} protocol + run for the identifier $\processid$, so that no single party knows the corresponding secret key. - \item Set security parameters for the \ac{DKG} ceremony (e.g.\ timeout, minimum number - of sequencers) {\color{blue}DKG}. - - \item Submit all this information in a transaction to the \hlget{\electionregistry} smart - contract: + \item Register the process on-chain by submitting a transaction to the + \hlget{\electionregistry} smart contract with the election parameters: \begin{align*} - tx_{\mathit{org}} = \big( - &\processid,\ \censusroot,\ \censusorigin,\ \censusuri, \\ - &\ballotmode,\ {\color{blue}electionMetadata},\ \stateroot,\ {\color{blue}dkgParameters} - \big). + \mathsf{tx} = \big( + &\censusorigin,\ \censusroot,\ \censusuri,\ \electionmetadata, \\ + &\ballotmode,\ \epk,\ \starttime,\ \duration\big). \end{align*} - + Upon accepting this transaction, the \hlget{\electionregistry} contract initializes the reserved configuration leaves + of the state tree $\stateTree$ as % + $\processid$ at $\mathtt{0x0}$, $\ballotmode$ at $\mathtt{0x2}$, $\epk$ at $\mathtt{0x3}$, + $\censusorigin$ at $\mathtt{0x6}$, and the results accumulator $\encresults$ at + $\mathtt{0x4}$ initialized to the encryption of zero (see Section~\ref{sec:vocdoni-protocol:state-tree}) and computes the initial state root + \[ + \stateroot = \stateTree.\hlget{\MTRoot}(). + \] \end{enumerate} % -Once this transaction is accepted, the election is publicly registered on-chain and the -\ac{DKG} phase can begin. +Once this transaction is accepted, the election is publicly registered on-chain and, at its +scheduled start time, the voting period can begin. +% +%Before any election can begin, key wardens must register in the \hlget{\dkgmanagement} smart contract. This registration +%is a one-time operation per key warden and is independent of any particular election; only +%registered parties are eligible to participate in the \ac{DKG} phase. +%% +%For each new election, the organizer performs the following steps: +% +%\begin{enumerate} +% +% \item Prepare the census data \censusdata\ and build the \ac{IMT} +% $\censusTree$ from it. Publish the full tree to IPFS, and record the resulting URI as $\censusuri$. +% +% \item Compute the census commitment $\censusroot = \censusTree.\hlget{\MTRoot}()$. +% +% \item Define the election details, including duration, the census model $\censusorigin$ +% (see Section~\ref{sec:vocdoni-protocol:census}), and the ballot rules $\ballotmode$ +% (see Section~\ref{sec:ballot-protocol}). +% +% \item Upload the election metadata (questions, options, description, etc.)\ to IPFS to obtain {\color{blue}electionMetadata}. +% +% \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 Initialize the state Merkle tree $\stateTree$ by inserting the election configuration +% parameters into the reserved configuration namespace (see Section~\ref{sec:vocdoni-protocol:state-tree}): +% $\processid$ at leaf $\mathtt{0x0}$, $\ballotmode$ at leaf $\mathtt{0x2}$, +% $\censusorigin$ at leaf $\mathtt{0x6}$, and zero-valued accumulators $\addaccumulator$ and +% $\substractaccumulator$ at leaves $\mathtt{0x4}$ and $\mathtt{0x5}$, respectively. {\color{blue}Compute the +% initial state root -- is this done by the SC?} +% \[ +% \stateroot = \stateTree.\hlget{\MTRoot}(). +% \] +% +% \item Set security parameters for the \ac{DKG} ceremony (e.g.\ timeout, minimum number +% of sequencers) {\color{blue}DKG}. +% +% \item Submit all this information in a transaction to the \hlget{\electionregistry} smart +% contract: +% \begin{align*} +% tx_{\mathit{org}} = \big( +% &\processid,\ \censusroot,\ \censusorigin,\ \censusuri, \\ +% &\ballotmode,\ {\color{blue}electionMetadata},\ \stateroot,\ {\color{blue}dkgParameters} +% \big). +% \end{align*} +% +%\end{enumerate} +%% +%Once this transaction is accepted, the election is publicly registered on-chain and the +%\ac{DKG} phase can begin. \subsubsection{Encryption key generation} \label{sec:vocdoni-protocol:keygen} -In this phase, \keywardens collectively generate the public encryption key.\\ +In this phase, the \keywardens\ collectively generate the public encryption key ($\epk$) that voters will use to encrypt their ballots. Since the process identifier $\processid$ is derived deterministically (see Section~\ref{sec:election-setup}), it is known in advance, so the \ac{DKG} ceremony for the election can be carried out before the process is registered on-chain. -\noi \Keywardens fetch the process parameters ($\processid$, $\ballotmode$, $\censusroot$) from the \hlget{\electionregistry} smart contract and participate in a \ac{DKG} protocol before the timeout set by the organizer expires. If the minimum number of contributions is reached, the public encryption key $\epk$ is derived and made available on-chain. This ensures that no single party controls the secret key, and that decryption later requires threshold participation {\color{blue}(give more details)}.\\ - -\noi {\color{blue} Alternatively, generate a SNARK proving the EPK has been generated correctly and the contract verifies it.} +Each \keywarden\ contributes to the ceremony and publishes a proof that its contribution is well-formed. The \hlget{\dkgmanagement} smart contract verifies these proofs, so that correct participation can be checked without revealing any secret. Once a threshold of valid contributions is collected, the joint public key $\epk$ is derived, while the corresponding secret key remains secret-shared among the wardens. In this way, no single party can decrypt on its own, and later tally decryption requires the collaboration of a threshold of wardens (see Section~\ref{sec:vocdoni-protocol:tally}). The resulting $\epk$ is the key that the organizer includes when registering the election (see Section~\ref{sec:election-setup}). The concrete \ac{DKG} construction is given in Appendix~\ref{sec:cryptographic-primitives:dkg}. \subsubsection{Voting period} \label{sec:vocdoni-protocol:votes} In this phase, voters cast their ballots and send them to the sequencers, who collect and process them. \\ -\noi \textbf{(a) Vote casting.} To cast a ballot, a voter does the following: \textit{\color{blue}-- mention that the voter has a (sk, pk, address) as described in Section~\ref{}.} +\noi \textbf{(a) Vote casting.} Each voter holds an Ethereum key pair $(\sk, \pk)$ with +associated address $\address$ (see Appendix~\ref{sec:cryptographic-primitives:signatures}). +To cast a ballot, a voter does the following: \begin{enumerate} - \item Select a sequencer. - \item Retrieve their census membership proof $\censusproof$ to prove eligibility. - \item Fetch parameters $\epk$, $\ballotmode$, and $\processid$ from the \hlget{\electionregistry} smart contract. - \item Select their ballot choice $\ballot$ following the rules of $\ballotmode$. - \item Sample fresh randomness $k \in \F$ and encrypt the ballot using $\epk$: - \begin{equation} - \label{eq-ciphertext} - \encryptedballot ={ }\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 = N + \bigl(\hlget{\Poseidon}(\processid,\address,k) \bmod N\bigr), - \end{equation} - where $N$ is defined by the protocol as described in Section~\ref{sec:vocdoni-protocol:circuits:state-transition}. - \item Use the \ballotcircuit from Section~\ref{sec:vocdoni-protocol:circuits:ballot} to generate a \ac{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}, - \witness = (\ballot, k), - \publicinputs = (\processid, \ballotmode,\\ - &\epk, \address, \weight, \encryptedballot, \voteid)). - \end{align*} - \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 Submit the package - \[\vote = [\processid, \voteid, \encryptedballot, \voteproof, \signature]\] - to the chosen sequencer. + \item Retrieve the census membership proof $\censusproof$ to prove eligibility. + \item Fetch the parameters $\epk$, $\ballotmode$, and $\processid$ from the + \hlget{\electionregistry} contract. + \item Select their ballot choice $\ballot$ following the rules of $\ballotmode$. + \item Sample fresh randomness $k \in \F$ and encrypt the ballot using $\epk$: + \begin{equation}\label{eq-ciphertext} + \encryptedballot = \hlget{\Enc}_{\epk}(\ballot; k). + \end{equation} + \item Use their address $\address$ and the randomness $k$ to compute a unique vote + identifier, mapped into the reserved vote-identifier namespace + (see Section~\ref{sec:vocdoni-protocol:state-tree}): + \begin{equation}\label{eq-voteid} + \voteid = N + \bigl(\hlget{\Poseidon}(\processid, \address, k) \bmod N\bigr). + \end{equation} + \item Use the \ballotcircuit from Section~\ref{sec:vocdoni-protocol:circuits:ballot} to + generate a \ac{ZK-SNARK} proof that Eqs.~\labelcref{eq-ciphertext,eq-voteid} are correctly + computed and that $\ballot$ satisfies the ballot rules of $\ballotmode$: + \begin{align*} + \ballotproof = {} & \hlget{\PProve}(\hlget{\ballotcircuit}, \witness = (\ballot, k), \\ + & \publicinputs = (\processid, \ballotmode, \epk, \address, \weight, + \encryptedballot, \voteid)). + \end{align*} + \item Sign the vote identifier with their Ethereum secret key $\sk$ to authenticate the vote: + \[ \signature = \hlget{\SSign}_{\sk}(\voteid). \] + \item Select a sequencer and submit the package + \[ \vote = [\processid, \voteid, \encryptedballot, \censusproof, \ballotproof, \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 \textbf{(b) Vote batching.} Upon receiving votes, a sequencer does the following: \begin{enumerate} - \item Retrieve election identifier $\processid$, current state root $\stateroot$, and census root $\censusroot$ from the \hlget{\electionregistry} smart contract and the associated data from the Ethereum data blobs. + \item Retrieve the election identifier $\processid$, the current state root $\stateroot$, and + the census root $\censusroot$ from the \hlget{\electionregistry} smart contract, together with + the associated data from the Ethereum data blobs. \item Upon receiving a vote - \[\vote_i = [\processid, \voteid, \encryptedballot, \voteproof, \signature],\] - extract the voter's public key $\pk_i = \hlget{\SPubKey}(\signature)$. -- {\color{blue}Add this function to Appendix.} - \item For each $\vote_i$ received, use \verifiercircuit from Section~\ref{sec:vocdoni-protocol:circuits:verifier} to generate a proof + \[ \vote_i = [\processid, \voteid_i, \encryptedballot_i, \censusproof_i, \ballotproof_i, \signature_i], \] + recover the voter's public key $\pk_i = \hlget{\SPubKey}(\signature_i)$. + \item For each $\vote_i$, use the \verifiercircuit from + Section~\ref{sec:vocdoni-protocol:circuits:verifier} to generate a proof \begin{align*} - \authenticationproof_i ={ } & \hlget{\PProve}(\hlget{\verifiercircuit}, - \witness = (\ballotproof, \pk, \signature),\\ - & \publicinputs = (\processid, \ballotmode, \epk, \encryptedballot, \voteid, \\ - & \address, \weight)). + \authenticationproof_i = {} & \hlget{\PProve}(\hlget{\verifiercircuit}, + \witness = (\pk_i, \signature_i, \ballotproof_i), \\ + & \publicinputs = (\processid, \ballotmode, \epk, \encryptedballot_i, \voteid_i,\\ + &\address_i, \weight_i)). \end{align*} - This proof ensures that the voter’s \voteproof and \signature are valid. - \item Batch a set of $n$ proofs $\{\authenticationproof_i\}_{i = 1}^n$ and batch verify them together using \aggregationcircuit from Section~\ref{sec:vocdoni-protocol:circuits:aggregation}: + This proof ensures that $\ballotproof_i$ and $\signature_i$ are valid and that $\address_i$ + is correctly derived from $\pk_i$. The census membership proof $\censusproof_i$ is not + used here; it is retained for the state transition circuit + (Section~\ref{sec:vocdoni-protocol:circuits:state-transition}), where eligibility is enforced. + \item Batch a set of $n$ authentication proofs $\{\authenticationproof_i\}_{i=1}^{n}$ and verify + them together using the \aggregationcircuit from + Section~\ref{sec:vocdoni-protocol:circuits:aggregation}: \begin{align*} - \aggregationproof = { } &\hlget{\PProve}(\hlget{\aggregationcircuit}, - \witness = (\{\authenticationproof_i\}_{i = 1}^n),\\ - &\publicinputs = (\{\encryptedballot\}_{i = 1}^n, \{\voteid_i\}_{i = 1}^n), - \{\address_i\}_{i = 1}^n, - \processid,\\ - & - \ballotmode, - \epk - ). + \aggregationproof = {} & \hlget{\PProve}(\hlget{\aggregationcircuit}, + \witness = (\{\authenticationproof_i\}_{i=1}^{n}), \\ + & \publicinputs = (\{\encryptedballot_i\}_{i=1}^{n}, \{\voteid_i\}_{i=1}^{n}, + \{\address_i\}_{i=1}^{n}, \processid, \\ + &\ballotmode, \epk)). \end{align*} - This proof ensures that public inputs corresponding to the global process parameters ($\processid$, $\ballotmode$, $\epk$) are correct and that all $\authenticationproof_i$ are valid. - - \item Prepare the state transition data that will be stored in an Ethereum blob: pack votes/results into a 4096-cell blob \blobdata. - \begin{itemize} - \item Compute data commitment $\blobcom = \hlget{\CCommit}(\blobdata)$. - \item Derive evaluation point $\evalpoint = \hlget{\Poseidon}(\processid, \stateroot^\old, \blobcom).$ - \item Prepare polynomial $P$ from $\blobdata$. - \item Evaluate $y = P(\evalpoint)$. - \item Generate opening proof $\openproof$ from $...$. - \item The following step (circuit) will prove that $y = P(\evalpoint)$. - \end{itemize} - - \item {\color{blue}Before doing state transitions, we need to prepare the data that will be stored on chain as a blob. Hence, collect xxxx, create commitment. In circuit (next step), we will prove that... .} - - \item {\color{blue}The sequencer must retrieve the voter's membership proof. Add as a footnote that this can be done by the voter and sent to the sequencer, who verifies it, but we want to minimize the actions of the voter.} - - \item Finally, prove that all transitions are correct .... with circuit from Section~\ref{sec:vocdoni-protocol:circuits:state-transition}. - consistency between data blobs and the on-chain state: - + This proof ensures that all $\authenticationproof_i$ are valid and share the same global + parameters $\processid$, $\ballotmode$, and $\epk$. + \item Prepare the state transition data to be published in an Ethereum blob: pack the votes and + results into a 4096-cell blob $\blobdata$ and + \begin{itemize} + \item compute the data commitment $\blobcom = \hlget{\CCommit}(\blobdata)$, + \item derive the evaluation point $\evalpoint = \hlget{\Poseidon}(\processid, \stateroot^{\old}, \blobcom)$, + \item build the polynomial $P$ from $\blobdata$ and evaluate $y = P(\evalpoint)$, + \item produce the opening proof $\openproof$ for the evaluation $(\evalpoint, y)$. + \end{itemize} + The consistency $y = P(\evalpoint)$ between the blob and the on-chain state is proven inside + the state transition circuit. + \item Generate the state transition proof with the \statetransitioncircuit from + Section~\ref{sec:vocdoni-protocol:circuits:state-transition}: \begin{align*} - \stateproof ={ } \hlget{\PProve}(\hlget{\statetransitioncircuit}, - \witness = (), \publicinputs = ()). + \stateproof = {} & \hlget{\PProve}(\hlget{\statetransitioncircuit}, + \witness = (\aggregationproof, \{\censusproof_i\}_{i=1}^{n},\\ + &\{\encryptedballot_i\}_{i=1}^{n}, k, \openproof, \dots), \\ + & \publicinputs = (\censusroot, \stateroot^{\old}, \stateroot^{\new}, \blobcom, \dots)). \end{align*} - - \item Verify each $\vote$ submission received by generating a state transition proof (see Section~\ref{sec:vocdoni-protocol:circuits:state-transition}), ensuring: - \begin{itemize} - \item correct accumulation of encrypted votes via ElGamal’s homomorphic properties, - \item eligibility of voters (via census Merkle proofs), - \end{itemize} - \item Submit the updated state root to the smart contract, while the full data are stored in Ethereum blobs. - \martai{If \stateroot changed, repeat last circuit.} + The complete input list is given in + Section~\ref{sec:vocdoni-protocol:circuits:state-transition}. This proof attests that the + encrypted votes are correctly accumulated via ElGamal's homomorphic properties, that every + processed vote corresponds to an eligible voter (via the census membership proofs), that vote + overwrites are handled consistently, and the blob data matches the committed on-chain state. + \item Submit the state transition proof $\stateproof$ and the new state root $\stateroot^{\new}$ + to the \hlget{\electionregistry} smart contract, while the full data is published in the + Ethereum blobs. \end{enumerate} -Sequencers repeat this process until the voting deadline set by the organizer. - -Upon receiving a valid transaction, the \electionregistry smart contract does the following checks: +\noi Upon receiving the transaction, the smart contract checks that the submitted previous root +matches the current on-chain state root and that $\stateproof$ is valid before updating the state +root to $\stateroot^{\new}$. If the on-chain state root changed while the sequencer was preparing +the batch (because another sequencer committed first), only the state transition proof must be +regenerated, as noted in Section~\ref{sec:vocdoni-protocol:circuits:state-transition}. Sequencers +repeat this process until the voting deadline set by the organizer. \subsubsection{Tally decryption} -\label{sec:vocdoni-protocol:deckey-gen} +\label{sec:vocdoni-protocol:tally} -{\color{blue} After the voting period expires, $t$ out of $n$ sequencers share their decryption shares of the election private key \textbf{to whom?}. 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 (see Seciton~\ref{sec:token} for details on incentivation mechanisms.)} +After the voting period expires, the \hlget{\electionregistry} smart contract stops accepting new state updates, fixing the final state root and thus the aggregated encrypted results. A threshold of $t$ out of $n$ \keywardens\ then cooperate to decrypt this aggregate: rather than reconstructing the election secret key, each participating warden publishes a partial decryption of the encrypted results together with a proof that its contribution is correct with respect to its key share. Once $t$ valid partial decryptions are available, they are combined to recover the plaintext tally. Because only the aggregated results are decrypted and never the individual ballots, voter privacy is preserved throughout the election, and the secret key is never reconstructed by any single party. +% +The resulting tally, together with a proof of correct decryption, is published on-chain during the finalization phase (see Section~\ref{sec:vocdoni-protocol:finalization}), where it is checked by the \resultscircuit\ and the \hlget{\resultsverifier} contract. %\Keywardens\ that fail to provide a valid partial decryption may be penalized; the incentive and slashing mechanisms are described in Section~\ref{sec:token}. \subsubsection{Election finalization} -\label{sec:vocdoni-protocol:results} +\label{sec:vocdoni-protocol:finalization} -In this final phase, the organizer/a sequencer computes the tally and publishes the result, together with a proof of its correct computation, on-chain. +In this final phase, the organizer (or a sequencer) publishes the election results, together with +a proof of their correct computation, on-chain. \begin{enumerate} - \item Retrieve $\decryptionkey$ from \dots. - \item ... - \item Use \resultscircuit from Section~\ref{sec:vocdoni-protocol:circuits:results} to generate a proof + \item Obtain the plaintext results $\{\text{results}_j\}_{j=1}^{n_f}$ and the corresponding + decryption proofs $\{\pi^{\mathrm{dec}}_j\}_{j=1}^{n_f}$ from the tally decryption phase + (Section~\ref{sec:vocdoni-protocol:tally}), i.e.\ the combination of the \keywardens' + partial decryptions of the aggregated encrypted results. + \item Retrieve the encrypted results accumulator $\encresults$ and the encryption key $\epk$ + from the final state, together with their Merkle inclusion proofs against the final state + root $\stateroot$. + \item Use the \resultscircuit from Section~\ref{sec:vocdoni-protocol:circuits:results} to + generate the results proof: \begin{align*} - \resultsproof = { } \hlget{\PProve}(\hlget{\resultscircuit}, - \witness = (...), - \publicinputs = (...)). + \resultsproof = {} & \hlget{\PProve}(\hlget{\resultscircuit}, + \witness = (\encresults, \epk,\\ &\merkleInclusionPf^{\encresults}, + \merkleInclusionPf^{\epk}, \{\pi^{\mathrm{dec}}_j\}_{j=1}^{n_f}), \\ + & \publicinputs = (\stateroot, \{\text{results}_j\}_{j=1}^{n_f})). \end{align*} + \item Submit the results and $\resultsproof$ to the \hlget{\electionregistry} smart contract. + The contract verifies the proof with the \hlget{\resultsverifier}, checks that the state root + committed in the proof matches the current on-chain state root, and records the results, + marking the process as finalized. \end{enumerate} -The election is considered finalized once the decrypted tally is available on-chain. At this stage, both the election results and the complete integrity of the process are permanently recorded and publicly auditable. +\noi The election is considered finalized once the decrypted results are available on-chain. At +this stage, both the results and the complete integrity of the process are permanently recorded +and publicly auditable: anyone can recompute the on-chain commitments and check the \ac{ZK-SNARK} +proofs. In particular, the combination of the final state root, the verified decryption of the +aggregated results, and the publicly verifiable \ac{ZK-SNARK} state and results proofs guarantees +the integrity of the entire election. -{\color{blue} Note that, anyone can verify the correctness of the final results by checking the \ac{ZK-SNARK} state proofs and on-chain commitments. Moreover, the combination of the final state root, the decryption of the accumulators, and the publicly verifiable \ac{ZK-SNARK} proofs guarantees the integrity of the entire election.} - -\begin{figure}%[H] - \centerline{\includegraphics[width=370pt,draft=false]{\figs/protocol-flow.pdf}} - \caption{Vocdoni voting process overview. {\color{blue}Figure is OUTDATED.}} - \label{fig:protocol-flow} -\end{figure}+%\begin{figure}%[H] +% \centerline{\includegraphics[width=370pt,draft=false]{\figs/protocol-flow.pdf}} +% \caption{Vocdoni voting process overview. {\color{blue}Figure is OUTDATED.}} +% \label{fig:protocol-flow} +%\end{figure}
M v2/sections/smart-contracts.tex → v2/sections/smart-contracts.tex

@@ -8,7 +8,7 @@ The \hlset{\orgregistry} smart contract is used to create and manage organizations within the system. Each organization is identified by the Ethereum address of its creator and is associated with a name and a URL pointing to its metadata. At this stage, the contract serves only as a registration mechanism, but it lays the foundation for future extensions, such as managing multiple elections under the same organization.

\paragraph{Census management.} -This contract is only used by the on-chain dynamic census model (see Section~\ref{sec:vocdoni-protocol:census}), the off-chain and \ac{CSP} models store the +This contract is only used by the on-chain dynamic census model (see Section~\ref{sec:vocdoni-protocol:census}), since the off-chain and \ac{CSP} models store the census commitment directly as a parameter and require no such contract. This contract maintains the census as an on-chain \ac{IMT} and exposes (i) the current census root, (ii) the total voting power recorded for a given root, and (iii) the validity of a root, returning the last block at which it was valid. %To bound storage, only a recent window of roots is retained. During each state transition, the \electionregistry\ contract queries the census contract to confirm that the \censusroot\ used in the membership proof is still valid---and no older than the election's creation block---rejecting the transition otherwise. This lets the census grow during the voting period while ensuring sequencers can only prove membership against roots the contract recognizes.
M v2/sections/vocdoni-protocol.tex → v2/sections/vocdoni-protocol.tex

@@ -3,7 +3,7 @@

This section outlines the \davinci voting protocol. First, we introduce the parties involved in the process in Section~\ref{sec:vocdoni-protocol:parties}. In Section~\ref{sec:vocdoni-protocol:smart-contracts} we present the Ethereum smart contracts that rule the \davinci protocol. -Then, in Section~\ref{sec:vocdoni-protocol:census}, we describe the census data structures and in Section~\ref{sec:vocdoni-protocol:state-tree} the state Merkle trees. +Then, in Section~\ref{sec:vocdoni-protocol:census}, we describe the census data structures and in Section~\ref{sec:vocdoni-protocol:state-tree} the state Merkle tree. In Section~\ref{sec:vocdoni-protocol:circuits}, we present the \ac{ZK} circuits used to enforce vote validity, authentication, aggregation, state transitions, and results computation. 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.