arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
census changes + state tree updates
bellesmarta belles.mm@gmail.com
Thu, 22 Jan 2026 05:32:02 +0100
commit

e4657eb38e03a8818eb4aef48a8b8e315eb6bedd

parent

ced7f0af443cd3c681e40953ffbf8e3f49987fa4

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

@@ -442,6 +442,15 @@ url = {https://eips.ethereum.org/EIPS/eip-4844},

month = {February}, year = 2022} + +@misc{reuters2024india, + author = {{Reuters}}, + title = {India’s 2024 General Election Sees Record Participation with 642 Million Votes Cast}, + year = {2024}, + howpublished = {\url{https://www.reuters.com/world/india/india-poll-panel-says-642-mln-voters-cast-ballots-general-election-2024-06-03/}}, + note = {Accessed 2026-01-22} +} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% No year %%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M v2/build/main.tex → v2/build/main.tex

@@ -89,10 +89,6 @@ \section{Protocol intuition}

\label{sec:protocol-intuition} \input{\secs/protocol-intuition} -\section{Cryptographic primitives} %building blocks -\label{sec:cryptographic-primitives} -\input{\secs/cryptographic-primitives} - \section{Voting protocol} \label{sec:vocdoni-protocol} \input{\secs/vocdoni-protocol}

@@ -134,6 +130,12 @@ % ---- Bibliography ----

\bibliographystyle{splncs04} \bibliography{\bib/bibtex} + +\appendix + +\section{Cryptographic primitives} %building blocks +\label{sec:cryptographic-primitives} +\input{\secs/cryptographic-primitives} % READS % 1. Benaloh (2006), “Simple Verifiable Elections.” Classic formulation of end-to-end verifiability ideas. (USENIX/EVT proceedings). https://www.usenix.org/legacy/event/evt06/tech/full_papers/benaloh/benaloh.pdf
M v2/build/preamble-macros.tex → v2/build/preamble-macros.tex

@@ -178,6 +178,7 @@ \newcommand{\stateproof}{\variablestyle{stateProof}}

\newcommand{\merkleproofs}{\variablestyle{merkleProofs}} \newcommand{\merkleInclusionPf}{\variablestyle{merkleInclusionProof}} \newcommand{\merkleNInclusionPf}{\variablestyle{merkleNonInclusionProof}} +\newcommand{\configmax}{\variablestyle{configMax}} % State Merkle tree \newcommand{\censusroot}{\variablestyle{censusRoot}}

@@ -206,6 +207,7 @@ \newcommand{\new}{\texttt{new}\xspace}

% Hyperlinks \newcommand{\hlset}[1]{\hypertarget{\detokenize{#1}}{#1}} \newcommand{\hlget}[1]{\hyperlink{\detokenize{#1}}{#1}} +\newcommand{\idx}{\variablestyle{idx}} % Smart contracts \newcommand{\smartcontractstyle}[1]{{\sf{#1}}\xspace}
M v2/figures/mt-state-mermaid.mmd → v2/figures/mt-state-mermaid.mmd

@@ -27,8 +27,8 @@ SIA -- 0x2 --> P2

SIA -- 0x3 --> P3 SIB -- 0x4 --> P4 SIB -- 0x5 --> P5 - NInt -- addresses --> EB - n1 -- voteIDs --> V + NInt -- encPath --> EB + n1 -- voteID --> V n2[" "] n1@{ shape: rect} n2@{ shape: text}
M v2/sections/background.tex → v2/sections/background.tex

@@ -6,9 +6,9 @@ \subsection{Interplanetary file system}

\label{sec:background:ipfs} The \acf{IPFS} is a peer-to-peer distributed storage network designed to make the web more resilient, permanent, and decentralized. Unlike traditional client-server architectures that retrieve data from a specific location (e.g., a URL pointing to a server), \ac{IPFS} retrieves data based on its content. Every file stored in \ac{IPFS} is split into blocks, each block is hashed, and the resulting cryptographic hash is used as its unique identifier. This property, known as content addressing, ensures that data is tamper-evident: if the file changes, so does its hash. -\ac{IPFS} also provides deduplication (the same content is only stored once across the network), versioning (content identifiers can point to immutable snapshots of data), and distributed availability (data can be fetched from any node that stores it)\roger{doesn't this clash with deduplication?}. Together, these features allow IPFS to function as a decentralized content delivery network. +\ac{IPFS} also provides deduplication (the same content is only stored once across the network), versioning (content identifiers can point to immutable snapshots of data), and distributed availability (data can be fetched from any node that stores it). Together, these features allow IPFS to function as a decentralized content delivery network. -In the context of the \davinci voting protocol, \ac{IPFS} is particularly useful for off-chain data distribution\pau{Consider removing IPFS}. Large datasets such as the full census (eligible voters and their weights) and election metadata (which may include questions, options, images, etc.) do not need to be stored directly on Ethereum. Instead, they are stored in \ac{IPFS}, and only their content hashes are published on-chain. This approach ensures transparency and verifiability—anyone can fetch the dataset from \ac{IPFS} and recompute the hash to confirm its integrity—while keeping on-chain storage costs low. That is, election participants can therefore rely on \ac{IPFS} to access the data without burdening the blockchain with large amounts of data. +In the context of the \davinci voting protocol, \ac{IPFS} is particularly useful for off-chain data distribution. Large datasets such as the full census (eligible voters and their weights) and election metadata (which may include questions, options, images, etc.) do not need to be stored directly on Ethereum. Instead, they are stored in \ac{IPFS}, and only their content hashes are published on-chain. This approach ensures transparency and verifiability, as anyone can fetch the dataset from \ac{IPFS} and recompute the hash to confirm its integrity, while keeping on-chain storage costs low. That is, election participants can therefore rely on \ac{IPFS} to access the data without burdening the blockchain with large amounts of data. \subsection{Ethereum} \label{sec:background:ethereum}

@@ -25,15 +25,15 @@ \label{sec:background:mt}

Merkle trees~\cite{merkle1987digital} are cryptographic hash trees that enable compact proofs of data inclusion. Formally, a Merkle tree is a binary tree structure where each leaf node represents the cryptographic hash of a set of data and every non-leaf node is derived from the hash of its children. The apex of the tree, the \textit{Merkle root}, acts as a succinct cryptographic commitment to the entire dataset. %This structure allows for efficient membership verification. -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 a lean incremental Merkle tree for the voter registry (census). +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. -\paragraph{Lean incremental Merkle trees.} +\paragraph{Incremental Merkle trees.} -The census (voter registry) is maintained with a lean \ac{IMT}, a binary Merkle tree designed for efficient sequential updates~\cite{todocitation}. Unlike a sparse tree, the lean \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 a lean \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 lean \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 sparse Merkle structure in this context. +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. \subsection{Zero-knowledge proofs} \label{sec:background:zkp}
M v2/sections/census.tex → v2/sections/census.tex

@@ -3,21 +3,24 @@

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 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}. - \item \textit{Merkle-tree-based membership proofs}: the census is organized as a lean incremental Merkle tree (see Section~\ref{sec:cryptographic-primitives:merkle-trees}) and denoted by $\hlset{\censusTree}$. Each voter is assigned a sequential index 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. + \item \textit{Merkle-tree-based membership proofs}: the census is organized as an incremental Merkle tree (see Section~\ref{sec:cryptographic-primitives:merkle-trees}) and denoted by $\hlset{\censusTree}$. Each voter is assigned a sequential index 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. \end{itemize} % To support different census models, the \hlget{\electionregistry} smart contract stores the following three 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. - \item \censusroot: the on-chain commitment used for membership verification. Its interpretation depends on the type of census. In the \ac{CSP} model, this parameter corresponds to the \ac{CSP}’s public key, and in the case of Merkle trees, it corresponds to a Merkle root (off-chain static/dynamic) or a census contract address (on-chain dynamic). + \item \censusroot: the on-chain commitment used for membership verification. Its interpretation depends on the \censusorigin. In the \ac{CSP} model, this parameter corresponds to the \textbf{hash of the \ac{CSP}’s public key}, and in the case of Merkle trees, it corresponds to a Merkle root (off-chain static/dynamic) or a census contract address (on-chain dynamic). \end{itemize} % -Organizers are free to construct the census from various data sources, such as private membership registries, self-sovereign identity credentials, or Ethereum-based tokens (e.g. ERC-20 or NFTs) whose balances define eligibility. Token-based censuses may be built from an optimistic snapshot at a chosen block or via a ZK proof that validates balances using Ethereum storage proofs. This flexibility supports a broad range of use cases and governance scenarios. +Organizers are free to construct the census from various data sources, such as private membership registries, self-sovereign identity credentials, or Ethereum-based tokens (e.g. ERC-20 or NFTs) whose balances define eligibility. +%Token-based censuses may be built from an optimistic snapshot at a chosen block or via a ZK proof that validates balances using Ethereum storage proofs. +%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-based census.} 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. In this case, \censusroot stores 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{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. In this case, \censusroot stores 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, its 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.

@@ -38,7 +41,7 @@ Membership proof \\

\hline \multicolumn{2}{|P{3.5cm}|}{Credential service provider (\ac{CSP})} - & \multirow{2}{*}{\ac{CSP}'s public key} + & \textbf{Hash of the {\ac{CSP}'s public key}} & Endpoint to obtain an eligibility credential & \multirow{2}{*}{Digital signature verification}\\ \hline

@@ -68,3 +71,9 @@ \vspace{0.5cm}

\caption{Summary of census configurations supported by the \davinci protocol.} \label{tab:census-models} \end{table} + +%CENSUS ORIGIN +%MerkleTreeOffchainStaticV1 +%MerkleTreeOffchainDynamicV1 +%MerkleTreeOnchainDynamicV1 +%CSPEdDSABabyJubJubV1
M v2/sections/circuits.tex → v2/sections/circuits.tex

@@ -222,7 +222,7 @@ \hlget{\SVer}_{\censusroot}\big((\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.} - \item Otherwise, if the census is represented by a lean \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\}$: + \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. \]
M v2/sections/introduction.tex → v2/sections/introduction.tex

@@ -3,24 +3,21 @@

Online voting remains one of the most studied yet elusive applications in applied cryptography. As digital services expand across both public and private sectors, secure and universally verifiable online voting systems have become an increasingly desirable goal. Remote electronic voting promises scalability, accessibility, and administrative efficiency; yet the design of systems that simultaneously ensure privacy, integrity, coercion resistance, and transparency under realistic adversarial models remains a formidable challenge. Numerous deployments have revealed deep-rooted usability flaws and security gaps, particularly when verifiability mechanisms are either poorly understood by users or reliant on centralized infrastructure. -Against this backdrop, the Vocdoni project was initiated in 2018 with the aim of rethinking online voting from first principles. The name Voĉdoni, meaning “to give voice” in Esperanto, reflects the project’s foundational goal: to empower collectives—from small associations to millions of citizens—to engage in secure and verifiable decision-making, regardless of technological or institutional barriers. Central to this vision was the idea that voting is not limited to formal governmental elections but serves as a more general-purpose mechanism for collective signaling. Vocdoni introduced a fully anonymous end-to-end verifiable voting system designed to operate efficiently on a range of devices, including smartphones. To support these goals, the team deployed a custom infrastructure emphasizing resilience, neutrality, and transparency. +Against this backdrop, the Vocdoni project was initiated in 2018 with the aim of rethinking online voting from first principles. The name Voĉdoni, meaning \textit{to give voice} in Esperanto, reflects the project’s foundational goal: to empower collectives, from small associations to millions of citizens, to engage in secure and verifiable decision-making, regardless of technological or institutional barriers. Central to this vision was the idea that voting is not limited to formal governmental elections but serves as a more general-purpose mechanism for collective signaling. Vocdoni introduced a fully anonymous end-to-end verifiable voting system designed to operate efficiently on a range of devices, including smartphones. To support these goals, the team deployed a custom infrastructure emphasizing resilience, neutrality, and transparency. Technically, the architecture of Vocdoni was based on a bespoke \ac{BFT} layer-1 blockchain, named Vochain. At the time, efficient zero-knowledge (ZK) proof systems were emerging, but not yet practical for most deployments. Vochain provided a performant and low-cost environment (achieving approximately 700 transactions per second) in which advanced cryptographic tools could be used without the constraints imposed by general-purpose blockchains based on the \ac{EVM}. The ability to issue voting transactions without requiring user fees enabled broader accessibility. Over several years of development and deployment, this architecture proved both viable and valuable in practice. However, broader adoption as a universal voting protocol highlighted the need for further architectural refinements and stronger formal guarantees. -In this work, we introduce \davinci, a new protocol that builds upon the lessons and conceptual groundwork laid by Vocdoni. \Davinci adopts a modular design and integrates state-of-the-art cryptographic tools, including succinct ZK proofs, improved bulletin board constructions, and robust coercion resistance mechanisms—reflecting the most recent advances in academic research. Unlike monolithic designs, \davinci is conceived as a composable primitive: a foundational layer intended to support secure and verifiable voting in diverse contexts, from blockchain governance to institutional elections. This shift in design philosophy aims to address long-standing challenges in the field, offering a cleaner abstraction with clearer security boundaries and formal underpinnings.\\ +In this work, we introduce \davinci, a new protocol that builds upon the lessons and conceptual groundwork laid by Vocdoni. \Davinci adopts a modular design and integrates state-of-the-art cryptographic tools, including succinct ZK proofs, improved bulletin board constructions, and robust coercion resistance mechanisms, reflecting the most recent advances in academic research. Unlike monolithic designs, \davinci is conceived as a composable primitive: a foundational layer intended to support secure and verifiable voting in diverse contexts, from blockchain governance to institutional elections. This shift in design philosophy aims to address long-standing challenges in the field, offering a cleaner abstraction with clearer security boundaries and formal underpinnings.\\ \subsection{Contributions} \label{sec:introduction:contributions} This work introduces \davinci, a modular and verifiable protocol for digital voting, designed to support privacy-preserving, auditable, and adaptable election processes across diverse governance contexts. The protocol \textit{models voting as a constrained state machine}, in which each valid operation is expressed as a formally defined state transition, enforced through succinct \ac{ZK} proofs. That is, at the core of the system lies a set of reusable arithmetic circuits that implement voter authentication, encrypted ballot validation, state transitions, and tally finalization. These circuits are optimized for off-chain proving and are compatible with modern \ac{ZK-SNARK} protocols. Application-layer state is maintained off-chain and committed on-chain using Merkle trees as cryptographic accumulators. %The protocol defines two such trees: one for the voter registry (the census) and one for the voting state. These trees enable voters and verifiers to produce efficient inclusion and transition proofs, while minimizing on-chain storage and computation. + +A key contribution of this work is the introduction of a generic ballot protocol that abstracts a wide range of voting systems into a unified, parameterized representation. Instead of designing specialized circuits for each voting rule, ballots are expressed as fixed-length vectors subject to configurable constraints, enabling support for approval, ranking, quadratic, single-choice, and multiple-choice elections within the same circuit framework. This design significantly reduces circuit complexity while allowing different tallying and counting rules to be enforced efficiently inside \ac{ZK} proofs. To coordinate protocol execution over a decentralized network of nodes, \davinci includes a set of Ethereum smart contracts that mediate the setup of elections, manage finalization procedures, and verify submitted proofs of correctness. A standardized transaction and data encoding format supports all stages of the process, including vote casting, ballots aggregation, and result publication. This approach ensures that protocol interactions remain deterministic and interoperable across clients and backends. The system also introduces the Vocdoni token, which is used to align incentives between participants. Altogether, the design aims to balance auditability and privacy while reducing trust assumptions on infrastructure providers. By cleanly separating functionalities and providing modular interfaces, the protocol is intended to serve as a foundation for both practical deployments and future extensions, such as integration with alternative identity systems, off-chain data availability layers, or other consensus backends. - -\begin{itemize} - \item The Vocdoni voting protocol. - \item The Vocdoni ballot protocol. -\end{itemize} \subsection{Related work} \label{sec:introduction:sota}
M v2/sections/protocol-intuition.tex → v2/sections/protocol-intuition.tex

@@ -2,7 +2,6 @@ % !TeX root = ../build/main.tex

The following section provides an overview of the DAVINCI protocol, describing its main phases and actors without delving into technical details. The election process is governed by smart contracts deployed on Ethereum, which ensure transparency, enforce rules, and verify proofs. As shown in Figure~\ref{fig:protocol-intuition}, the protocol consists of five main phases, from the setup of the election to the publication and verification of final results. %All the voting process is governed by the rules encoded in three smart contracts: the \textit{process management}, the \textit{sequencer registry}, and the \textit{results verification} smart contract. All these three contracts are deployed on the Ethereum blockchain, and ensure that the execution of all steps is transparent and unalterable. The protocol consists of five phases, as illustrated in Figure~\ref{fig:protocol-intuition} and described below. The first two occur during the preparation period, the subsequent two during the voting period, and the final one takes place in the tally period. -\rogeri{a rough explanation about how double-spending (i.e. double vote-count) is prevented should be included somewhere in this section (as it is explained how coercion and vote-buying is mitigated).} \begin{figure}[h] \centerline{\includegraphics[width=320pt,draft=false]{\figs/protocol-intuition-flow.pdf}}
M v2/sections/smart-contracts.tex → v2/sections/smart-contracts.tex

@@ -27,13 +27,6 @@ \subsubsection{Results verifier}

The \hlset{\resultsverifier} contract validates the proof of correct tally computation. It contains the verification key for the results circuit (see Section~\ref{sec:vocdoni-protocol:circuits:results}) and ensures that the final results submitted by the organizer match the commitments from the final state. Once verified, the results and their proof are permanently recorded on-chain, providing a tamper-proof reference for the election outcome.\\ -\martai{\\ - 1. \orgregistry only for transparency purposes, right? Any EOA can call \electionregistry?\\ - 2. Once EPK is created, does a kew warden uploaded it to \dkgmanagement and that triggers a call to \electionregistry that records it?\\ - 3. What is the relation with \electionregistry and \dkgmanagement, because the organizer sets the security parameters for the DKG, what is the interaction between contracts?\\ - 4. Does \electionregistry call the other two verifier contracts? Or the sequencers need to call the other two?} - -% %1. OrganizationRegistry: se utiliza para crear una organización (que asocia la address del creador con un nombre y una URL a sus metadatos). No tiene ningún otro rol de momento. %2. ProcessRegistry: registra como dices todo el proceso de una election, desde su creación hasta registrar los resultados (incluyendo el stateroot en cada momento). En resumen: %Genera el state root inicial (aun no, pero lo hará).
M v2/sections/state-tree.tex → v2/sections/state-tree.tex

@@ -2,35 +2,58 @@ % !TeX root = ../build/main.tex

% \noi Merkle trees are used to create a cryptographic representation of both the voter census registry and the election state. -{\color{blue}\textbf{TODO:} this section is outdated -- update it to the tree with namespaces.}\\ +The state Merkle tree, denoted by $\hlset{\stateTree}$, represents the evolving global state of an election in \davinci. It is implemented as a \ac{SMT} of fixed depth $D = 64$, as described in Section~\ref{sec:cryptographic-primitives:merkle-trees}. The state tree acts as a cryptographic accumulator that compactly commits to all relevant election data, including configuration parameters, vote identifiers, and encrypted ballots. +By organizing the election state in a single \ac{SMT}, \davinci supports efficient membership and update proofs that can be verified inside \ac{ZK} circuits, enabling succinct and verifiable state transitions. -The state Merkle tree, denoted by $\hlset{\stateTree}$, represents the evolving state of the election. It is implemented as a \ac{SMT} of fixed depth, as described in Section~\ref{sec:cryptographic-primitives:merkle-trees}, and is dynamic: it is updated throughout the election as new votes are cast, validated, and incorporated by the sequencers. The leaves of the state tree store the global election parameters, the encrypted ballots, and the set of vote identifiers, as illustrated in Figure~\ref{fig:mt-state} and described below. +The root of the state tree, denoted $\stateroot$, is committed on-chain and serves as the authoritative reference to the current election state. Each state transition performed by a sequencer updates the tree and produces a new root. The correctness of this update, namely, that it follows the protocol rules and correctly incorporates new votes, is attested by a \ac{ZK-SNARK} proof, which is verified by the $\hlget{\statetransitionverifier}$ smart contract before the new root is accepted. -\paragraph{Reserved addresses for metadata.} The first six addresses are reserved for the process parameters as follows: + +\paragraph{Namespaced key space.} +The state tree operates over keys in the range $[0, 2^{64}-1] \subset \mathbb{F}_p$ and uses a SNARK-friendly hash function (Poseidon, see Section~\ref{sec:cryptographic-primitives:hash}) to enable efficient in-circuit verification. To prevent collisions between different categories of data stored in the state, the 64-bit key space is partitioned into three disjoint numeric namespaces using a fixed thershold $N$. We define +\[ N = 3 \cdot 2^{D-2},\] +which splits the address space into a lower region for configuration parameters, followed by a region for vote identifiers, and an upper region for encrypted ballot storage. This strict separation ensures that configuration entries, vote identifiers, and ballots can never collide. The structure of the tree is depicted in Figure~\ref{fig:mt-state}. + +\begin{figure}[h] + \centerline{\includegraphics[width=450pt,draft=false]{\figs/mt-state-mermaid}} + \caption{Structure of the state Merkle tree. The first leaves are reserved for global election parameters while subsequent leaves store vote identifiers and encrypted ballots.} + \label{fig:mt-state} +\end{figure} + +\paragraph{Configuration namespace.} + +The lowest indices of the tree are reserved for fixed process parameters that define the election rules. These keys are deterministic and occupy a negligible portion of the address space. Typical entries include: \begin{itemize} - \item \texttt{0x0}: it stores a unique identifier for the election (\processid). - \item \texttt{0x1}: it stores the census origin (\censusorigin). %and \type, a field in case the organization was using a different structure for the census than a MT. - \item \texttt{0x2}: it stores the ballot mode configuration, which is the set of rules for validating votes (\ballotmode). - \item \texttt{0x3}: it stores the encryption public key used to encrypt the votes (\epk). - \item \texttt{0x4}: it stores an accumulator of the encrypted votes that need to be added to the tally (\addaccumulator). - \item \texttt{0x5}: it stores an accumulator of the encrypted votes that need to be substracted from the tally because they have been overwritten (\substractaccumulator). + \item \texttt{0x0}: the election identifier (\processid). + \item \texttt{0x1}: the census origin (\censusorigin). %and \type, a field in case the organization was using a different structure for the census than a MT. + \item \texttt{0x2}: the ballot mode configuration, which is the set of rules for validating votes (\ballotmode). + \item \texttt{0x3}: the encryption public key used to encrypt the ballots (\epk). + \item \texttt{0x4}: an accumulator of the encrypted votes that need to be added to the tally (\addaccumulator). + \item \texttt{0x5}: an accumulator of the encrypted votes that have been overwritten (\substractaccumulator). \end{itemize} +Let $\configmax$ denote the largest index reserved for configuration parameters. -\paragraph{Encrypted ballots.} Each voter’s encrypted ballot is stored in the state tree at a leaf whose path corresponds to their Ethereum address (or another unique identifier). The leaf value is the ciphertext corresponding to the ballot encrypted under the election’s encryption public key. If the voter later overwrites their ballot, the same path is updated with the new ciphertext. +\paragraph{Vote identifier namespace.} -\paragraph{Vote identifiers.} In addition to storing ballots, the state tree also tracks the set of vote identifiers. Each vote identifier \voteid, which is derived from the \processid, the voter’s address, and fresh randomness, determines the path to a dedicated leaf. Initially empty, these leaves are filled when the corresponding \voteid is used, thereby recording that it has been consumed. This enables efficient non-membership proofs: before accepting a new ballot, the sequencer checks that the corresponding \voteid path is still empty, and upon inclusion, the leaf is marked as used to prevent reuse. \\ +The interval $[\configmax + 1, N - 1]$ is reserved for \emph{vote identifiers} (\voteid), which allows voters to verify that their vote has been included in the election state, without revealing or linking to the corresponding encrypted ballot. Vote identifiers are derived by hashing the process identifier, the voter’s address, and fresh randomness, and then mapping the result into the allowed range via modular reduction: +\[ +\voteid = \texttt{voteIDMin} + \bigl(\text{Hash}(\processid,\address,k) \bmod (N - \texttt{voteIDMin})\bigr), +\] +where $\texttt{voteIDMin} = \texttt{configMax} + 1$. The \hlget{\statetransitioncircuit} recomputes this derivation and enforces that $\texttt{voteIDMin} \le \voteid < N$, guaranteeing that vote identifiers cannot overlap with configuration entries or ballot storage. -%Figure~\ref{fig:mt-state} illustrates the structure of the state tree, showing the reserved slots for process parameters as well as the leaves used for ballots and vote identifiers. +Unlike classical nullifiers, vote identifiers are not used to prevent duplicate voting directly. Instead, correctness is enforced at the circuit level: the state transition circuit guarantees that a vote identifier can only be inserted if the corresponding leaf in the state tree is empty. This emptiness check is enforced inside the ZK circuit. Since the vote identifier depends on a fresh random value $k$, if a collision occurs (i.e., the computed leaf is already occupied), the circuit will reject the transition. In that case, the voter must resample $k$ and recompute a new vote identifier until an unused leaf is obtained. As a result, collisions do not compromise correctness or liveness, but merely require retrying the identifier derivation. -\begin{figure}[h] - \centerline{\includegraphics[width=400pt,draft=false]{\figs/mt-state-mermaid}} - \caption{Structure of the state Merkle tree. The first leaves are reserved for global election parameters while subsequent leaves store encrypted ballots indexed by voter addresses and vote identifiers.} - \label{fig:mt-state} -\end{figure} +Note that the maximum number of vote identifiers that can be stored is bounded by the size of this namespace ($\approx 3\cdot 2^{62}$), +which upper-bounds the total number of votes and overwrites that can be processed throughout the election. +%This capacity is orders of magnitude larger than any realistic deployment, ensuring that identifier exhaustion is practically impossible. +This capacity is orders of magnitude larger than any realistic election workload: historical elections peak at $\approx 10^{9}$ votes~\cite{reuters2024india}, ensuring that identifier exhaustion is practically impossible. -\paragraph{Initial state.} At the beginning of the election, the state tree is initialized with the election parameters and empty accumulators, {\color{blue}and its census root ($\stateroot$) is published on-chain}. +\paragraph{Encrypted ballot namespace.} -\paragraph{State transitions.} As the voting progresses, sequencers update the tree whenever new votes are received, producing a new root for each transition. To guarantee correctness, each update is accompanied by a \ac{ZK-SNARK} proof attesting that the transition from the previous root to the new root respects all protocol constraints: ballots are well-formed and comply with the voting rules, voters are eligible according to the census, the \voteid non-membership condition prevents double voting (or overwrites are handled correctly), and encrypted results are aggregated consistently. In addition, sequencers reencrypt stored ciphertexts, including both newly submitted and already included ballots. This mechanism refreshes the randomness of the encrypted votes without altering their underlying content, ensuring receipt-freeness and concealing whether a particular ballot has been overwritten or simply re-randomized. +The upper portion of the tree, $[N,\,2^{64}-1]$, is reserved for storing encrypted ballots. In contrast to vote identifiers, ballot storage locations are deterministic and derived from the voter's position in the census. Let $\idx$ denote the voter's census index, proven via a census membership proof. The storage path for the encrypted ballot is computed as +\[ +\text{encPath} = N + 1 + \bigl(\idx \cdot 2^{16} + (\address \bmod 2^{16})\bigr). +\] +This construction assigns each eligible voter a unique, reserved leaf in the state tree. Because the index $\idx$ is authenticated by the census, a voter can only write to their own slot. This enables efficient \emph{last-vote-wins} semantics: if a voter overwrites their ballot, the new ciphertext replaces the previous one at the same path, while the tally is updated by subtracting the old contribution and adding the new one. -This way, the state tree provides a compact and tamper-proof commitment to the current status of the election. At the end of the election, the final state root together with the on-chain verification of all transitions serves as a complete cryptographic record of the election, encapsulating both the tally and the integrity of the entire voting procedure.+Together, the state tree provides a compact and tamper-proof commitment to the current status of the election. At the end of the election, the final state root together with the on-chain verification of all transitions serves as a complete cryptographic record of the election, encapsulating both the tally and the integrity of the entire voting procedure.
M v2/sections/vocdoni-protocol.tex → v2/sections/vocdoni-protocol.tex

@@ -1,6 +1,6 @@

% !TeX root = ../build/main.tex -This section outlines the \davinci voting protocol. We introduce the parties involved in the process in Section~\ref{sec:vocdoni-protocol:parties}. In Section~\ref{sec:vocdoni-protocol:census}, we describe the census data structure and in Section~\ref{sec:vocdoni-protocol:state-tree} the state Merkle trees. Then, in Section~\ref{sec:vocdoni-protocol:smart-contracts} we present the Ethereum smart contracts that rule the \davinci protocol. In Section~\ref{sec:vocdoni-protocol:circuits}, we present the 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. +This section outlines the \davinci voting protocol. We introduce the parties involved in the process in Section~\ref{sec:vocdoni-protocol:parties}. In Section~\ref{sec:vocdoni-protocol:census}, we describe the census data structures and in Section~\ref{sec:vocdoni-protocol:state-tree} the state Merkle trees. Then, in Section~\ref{sec:vocdoni-protocol:smart-contracts} we present the Ethereum smart contracts that rule the \davinci protocol. In Section~\ref{sec:vocdoni-protocol:circuits}, we present the 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. \subsection{Parties involved} \label{sec:vocdoni-protocol:parties}