arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
update state tree section
bellesmarta belles.mm@gmail.com
Sat, 28 Feb 2026 20:27:34 +0100
commit

10b2c75e2aa8f2cefd364d47b4942d2f2d275756

parent

cd199d695eb4f4ae3990f2b1777619ba2c2ea532

M v2/build/main.tex → v2/build/main.tex

@@ -93,13 +93,6 @@ \section{Voting protocol}

\label{sec:vocdoni-protocol} \input{\secs/vocdoni-protocol} -%Voting setup -%Encryption key generation -%Voting phase -%Votes collection -%Results verification - -\newpage \section{Ballot protocol} \label{sec:ballot-protocol} \input{\secs/ballot-protocol}
M v2/build/preamble-macros.tex → v2/build/preamble-macros.tex

@@ -1,11 +1,13 @@

% !TeX root = main.tex -% Doc sytle +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% DOCUMENT STYLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Document sytle \setcounter{secnumdepth}{3} %enumerate sections up to depth 3 (subsubsection) -% Set the first-level itemize label to use math mode \bullet -\setlist[itemize,1]{label=$\bullet$} -% The second-level enumerates (enumerate,2) should only show (a) when referenced (not (3a)). -\setlist[enumerate,2]{label=(\alph*),ref=\alph*} +\setlist[itemize,1]{label=$\bullet$} %set the first-level itemize label to use math mode \bullet +\setlist[enumerate,2]{label=(\alph*),ref=\alph*} %the second-level enumerates (enumerate,2) should only show (a) when referenced (not (3a)). % Working directory \newcommand{\definedir}[2]{\newcommand{#1}{#2}}

@@ -13,22 +15,19 @@ \definedir{\secs}{../sections}

\definedir{\figs}{../figures} \definedir{\bib}{../bibliography} +% Colours +\definecolor{cred}{rgb}{1, 0.5, 0.5} +\definecolor{cgreen}{rgb}{0.5, 1, 0.5} +\definecolor{cblue}{rgb}{0.5, 0.5, 1} + % Hyperref setup %\hypersetup{ -% final=true, -% colorlinks=true, -% linkcolor=blue, -% urlcolor=blue, -% citecolor=blue, -%} - -% Comments -\newcommand{\marta}[1]{\todo[size=\small, color=red!40]{\textbf{Marta}: #1}} -\newcommand{\martai}[1]{\todo[inline, size=\small, color=red!40]{\textbf{Marta}: #1}} -\newcommand{\pau}[1]{\todo[size=\small, color=green!40]{\textbf{Pau}: #1}} -\newcommand{\paui}[1]{\todo[inline, size=\small, color=green!40]{\textbf{Pau}: #1}} -\newcommand{\roger}[1]{\todo[size=\small, color=blue!40]{\textbf{Roger}: #1}} -\newcommand{\rogeri}[1]{\todo[inline, size=\small, color=blue!40]{\textbf{Roger}: #1}} + % final=true, + % colorlinks=true, + % linkcolor=cblue, + % urlcolor=black, + % citecolor=cblue, + %} % Freefootnote \let\svthefootnote\thefootnote

@@ -39,8 +38,13 @@ \let\thefootnote\svthefootnote%

} % Footnote spaces -\setlength{\skip\footins}{20pt} % space between text and footnotes -\setlength{\footnotesep}{1em} % space between individual footnotes +\setlength{\skip\footins}{20pt} %space between text and footnotes +\setlength{\footnotesep}{1em} %space between individual footnotes + +% New foonote referencing a previous footmark +\makeatletter +\newcommand\footnoteref[1]{\protected@xdef\@thefnmark{\ref{#1}}\@footnotemark} +\makeatother % Table of contents style \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}} % it works like p{} but centered

@@ -67,50 +71,54 @@ {4\p@ \@plus 2\p@ \@minus 2\p@}% % After skip

{\normalfont\normalsize\bfseries}} % Font style \makeatother -% Colours -\definecolor{cred}{rgb}{1, 0.5, 0.5} -\definecolor{cgreen}{rgb}{0.5, 1, 0.5} -\definecolor{cblue}{rgb}{0.5, 0.5, 1} +% Draft watermark +%\ifdraft{\SetWatermarkScale{4}}{\SetWatermarkScale{0}} -% Hyperref setup -%\hypersetup{ -% final=true, -% colorlinks=true, -% linkcolor=cblue, -% urlcolor=black, -% citecolor=cblue, -%} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% COMMENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcommand{\marta}[1]{\todo[size=\small, color=red!40]{\textbf{Marta}: #1}} +\newcommand{\martai}[1]{\todo[inline, size=\small, color=red!40]{\textbf{Marta}: #1}} +\newcommand{\pau}[1]{\todo[size=\small, color=green!40]{\textbf{Pau}: #1}} +\newcommand{\paui}[1]{\todo[inline, size=\small, color=green!40]{\textbf{Pau}: #1}} +\newcommand{\roger}[1]{\todo[size=\small, color=blue!40]{\textbf{Roger}: #1}} +\newcommand{\rogeri}[1]{\todo[inline, size=\small, color=blue!40]{\textbf{Roger}: #1}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% NOMENCLATURE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Mathbb -\newcommand{\N}{\ensuremath{\mathbb{N}}\xspace} -\newcommand{\Z}{\ensuremath{\mathbb{Z}}\xspace} -\newcommand{\G}{\ensuremath{\mathbb{G}}\xspace} -\newcommand{\F}{\ensuremath{\mathbb{F}}\xspace} -\newcommand{\J}{\ensuremath{\mathbb{J}}\xspace} +\newcommand{\N}{\mathbb{N}\xspace} +\newcommand{\Z}{\mathbb{Z}\xspace} +\newcommand{\G}{\mathbb{G}\xspace} +\newcommand{\F}{\mathbb{F}\xspace} +\newcommand{\J}{\mathbb{J}\xspace} % Elliptic curves -\newcommand{\BW}[1]{\ensuremath{{#1}^{\text{\tiny \sf BW}}}\xspace} -\newcommand{\BLS}[1]{\ensuremath{{#1}^{\text{\tiny \sf BLS}}}\xspace} -\newcommand{\BN}[1]{\ensuremath{{#1}^{\text{\tiny \sf BN}}}\xspace} -\newcommand{\BJ}[1]{\ensuremath{{#1}^{\text{\tiny \sf BJ}}}\xspace} -\newcommand{\SEC}[1]{\ensuremath{{#1}^{\text{\tiny \sf SEC}}}\xspace} +\newcommand{\BW}[1]{{#1}^{\text{\tiny \sf BW}}\xspace} +\newcommand{\BLS}[1]{{#1}^{\text{\tiny \sf BLS}}\xspace} +\newcommand{\BN}[1]{{#1}^{\text{\tiny \sf BN}}\xspace} +\newcommand{\BJ}[1]{{#1}^{\text{\tiny \sf BJ}}\xspace} +\newcommand{\SEC}[1]{{#1}^{\text{\tiny \sf SEC}}\xspace} % Trees -\newcommand{\tree}[1][]{\sf{MT}^{\sf{#1}}} +\newcommand{\tree}[1][]{{\sf MT}^{{\sf #1}}} \renewcommand{\root}[1][]{\sf{root}^{\sf{#1}}} -\newcommand{\recentroots}{\sf{recentRoots}} -\newcommand{\leaf}{\sf{leaf}} -\newcommand{\leaves}{\sf{leaves}} -\newcommand{\MTGenerate}{\sf{Generate}} -\newcommand{\MTRoot}{\sf{Root}} -\newcommand{\MTInsert}{\sf{Insert}} -\newcommand{\MTProof}{\sf{Proof}} -\newcommand{\MTMembershipProof}{\sf{MembershipProof}} -\newcommand{\MTNonMembershipProof}{\sf{NonMembershipProof}} +\newcommand{\recentroots}{{\sf recentRoots}} +\newcommand{\leaf}{{\sf leaf}} +\newcommand{\leaves}{{\sf leaves}} +\newcommand{\MTGenerate}{{\sf Generate}} +\newcommand{\MTRoot}{{\sf Root}} +\newcommand{\MTInsert}{{\sf Insert}} +\newcommand{\MTProof}{{\sf Proof}} +\newcommand{\MTMembershipProof}{{\sf MembershipProof}} +\newcommand{\MTNonMembershipProof}{\text{\sf{NonMembershipProof}}} \newcommand{\MTRemove}{\sf{Remove}} \newcommand{\MTOpen}{\sf{Open}} \newcommand{\MTUpdate}{\sf{Update}} -\newcommand{\MTVerify}{\sf{Verify}} +\newcommand{\MTVerify}{\text{\sf{Verify}}} \newcommand{\censusTree}{\sf{MT^{\census}}} \newcommand{\stateTree}{\sf{MT^{\state}}}

@@ -293,12 +301,4 @@ \newcommand{\Davinci}{DAVINCI\xspace}

\newcommand{\keywarden}{key warden\xspace} \newcommand{\Keywarden}{Key warden\xspace} \newcommand{\keywardens}{key wardens\xspace} -\newcommand{\Keywardens}{Key wardens\xspace} - -% Draft watermark -%\ifdraft{\SetWatermarkScale{4}}{\SetWatermarkScale{0}} - -% New foonote referencing a previous footmark -\makeatletter -\newcommand\footnoteref[1]{\protected@xdef\@thefnmark{\ref{#1}}\@footnotemark} -\makeatother+\newcommand{\Keywardens}{Key wardens\xspace}
M v2/build/preamble-packages.tex → v2/build/preamble-packages.tex

@@ -15,7 +15,6 @@

\usepackage[nolist]{acronym} %consider `[printonlyused]` option \usepackage{float} - \usepackage[english]{babel} \usepackage[utf8]{inputenc}

@@ -33,14 +32,12 @@ \usepackage{xspace} %list of punctuation marks

\usepackage{enumitem} \usepackage{multirow} \usepackage{ifdraft} -%\usepackage{draftwatermark} \usepackage{setspace} - \usepackage{cleveref} %ref multiple equations - \usepackage{mdframed} %frame figures +%\usepackage{draftwatermark} %\ifdraft{ % % \usepackage[color = {[rgb]{0.9, 0.9, 0.9}}]{draftwatermark} % \usepackage{draftwatermark}
D v2/sections/census-old.tex

@@ -1,123 +0,0 @@

-% !TeX root = ../build/main.tex - -The census Merkle tree, denoted by $\hlget{\censusTree}$ encodes the list of eligible voters and their associated voting weights. Formally, it is implemented as a sparse Merkle tree (SMT) of fixed depth\footnote{In the present work, all circuits are instantiated using sparse Merkle trees as described above. However, the protocol does not strictly depend on this structure: any authenticated data structure that supports efficient commitments and membership proofs verifiable inside zero-knowledge circuits could be employed. Adapting the protocol to such alternatives would only require modifying the corresponding circuits, while the overall flow of the election process would remain unchanged.}, as described in Section~\ref{sec:cryptographic-primitives:merkle-trees}. Each voter is mapped to a unique path in the tree, typically derived from their Ethereum address or another unique identifier, and the corresponding leaf stores the voting weight of that address. While the default weight is usually one, the system also supports weighted voting, where different participants may have different levels of influence. - -To construct the census, the organizer collects the dataset of eligible voters and their weights, computes the corresponding tree, and publishes its root (\censusroot) on-chain. The full dataset does not need to be stored on-chain; instead, it is distributed off-chain (e.g., via IPFS or another content-addressed storage system), enabling verifiers and sequencers to independently reconstruct the tree and produce membership proofs when needed. This design ensures transparency and verifiability while minimizing on-chain storage requirements. - -The census tree plays a central role during the voting phase. Voters must provide a Merkle proof showing that their address and weight are included in the tree committed by the organizer. These proofs are then verified within ZK circuits, which guarantees that only eligible participants can cast ballots without requiring the disclosure of the entire census. In this way, the census Merkle tree provides a compact, cryptographically verifiable commitment to voter eligibility that supports both privacy and scalability. - -Although the protocol does not mandate a specific method for constructing the census tree, different instantiations are possible depending on the application context: -% -\begin{itemize} - \item \emph{Private datasets}. Organizations maintaining internal voter registries (e.g., membership databases or CSV files) can directly convert them into the Merkle format. This approach keeps the registry confidential, with only the root hash made public. - \item \emph{Self-sovereign identity (SSI)}. If voters manage identities through SSI systems, the organizer can aggregate these identities and build - the tree accordingly. This enables participation without requiring centralized identity management. - \item \textit{Ethereum-based tokens}. Token balances (e.g., ERC-20 or NFTs) may also define eligibility. In this setting, the census can either be created via the optimistic approach, taking a snapshot of token balances and allowing a dispute period for fraud proofs, or through a ZK-SNARK that proves correctness directly from Ethereum storage proofs and ensures that both individual balances and the token’s total supply are consistent. -\end{itemize} -% -This flexibility allows the protocol to accommodate a wide range of use cases, from private associations to decentralized communities, while maintaining the same security and verifiability guarantees. - ------------------------------------------ - - -The census defines the set of eligible voters and their associated voting weights. Throughout the protocol, the census is represented by a lean incremental Merkle tree, as defined in Section~\ref{sec:cryptographic-primitives:merkle-trees}, and denoted by $\hlset{\censusTree}$. Voters are inserted sequentially into the tree: each new eligible voter occupies the next available leaf, and that leaf stores both their Ethereum address (or another unique identifier) and their voting weight. While the default weight is one, the protocol also supports weighted voting, where different participants may have different voting power. - - - - - ---------------------------------------- - -\subsection{ALTRETYPE} - -The census defines the set of eligible voters and their associated voting weights. -Throughout the protocol, the census is represented by a Merkle-tree commitment, denoted -by $$\hlset{\censusTree}$$, and its root $\censusroot$ is recorded in the election registry smart -contract. Each voter is mapped to a unique path in the tree---typically derived from -their Ethereum address or another unique identifier---and the corresponding leaf stores -the voter’s weight. While the default weight is one, the protocol naturally supports -weighted voting. - -During ballot submission, voters provide a Merkle membership proof showing that their -address and weight are included in the committed census. These proofs are verified inside -zero-knowledge circuits, ensuring that eligibility checks occur privately and without -requiring disclosure of the full census. The Merkle-tree commitment thus offers a compact, -scalable mechanism to attest voter eligibility. - -DAVINCI supports multiple census models depending on the deployment context, including -off-chain and on-chain trees, static or dynamically updatable registries, and -credential-based approaches. In all configurations, the election registry smart -contract stores two parameters: -(i) \texttt{censusRoot}, containing either a Merkle root or the address of a census -contract, and -(ii) \texttt{censusURI}, pointing to an off-chain location where sequencers can -retrieve the census data or related verification information. - -The supported census models are described below. - -\paragraph{Off-chain static census.} - -In this model, the organizer constructs a fixed census prior to the start of the election. -The census is represented as a (incremental) Merkle tree built off-chain, and its root is -submitted to the election registry contract during setup. The contract stores this -commitment in \texttt{censusRoot}, while \texttt{censusURI} provides a URL or -content-addressed reference (e.g., IPFS) where sequencers can download the full tree to -generate and verify Merkle proofs. The tree remains unchanged throughout the voting -period. - -\paragraph{Off-chain dynamic census.} - -In the off-chain dynamic model, the Merkle tree remains off-chain but can be \emph{extended} -during the voting period. The organizer may add new voters (but may never delete entries -or alter weights, as such operations would enable double voting). Each update produces a -new Merkle root, which the organizer must publish to the election registry contract via a -transaction that updates the \texttt{censusRoot} variable. Sequencers always verify -membership proofs against the most recently published root, ensuring consistency with the -on-chain commitment. - -\paragraph{On-chain static census.} - -Here, the census is deployed as a dedicated smart contract that stores the Merkle tree -on-chain. The tree is static and does not change during the voting period. During election -setup, the election registry contract reads the tree root from the census contract and -stores it in \texttt{censusRoot}, while \texttt{censusURI} indicates where sequencers may -retrieve the full tree representation (e.g., IPFS). Membership verification can therefore -be performed entirely on-chain. - -\paragraph{On-chain dynamic census.} - -In this configuration, the census lives in a dedicated on-chain contract that supports the -addition of new members during the voting period. The address of this contract is stored in -\texttt{censusRoot}, and \texttt{censusURI} points to an external representation of the tree -(e.g., dGraph, IPFS). The census contract maintains a list of all Merkle roots corresponding -to valid updates. Sequencers may produce membership proofs using earlier roots, since the -tree evolves over time. During state transitions, the election registry contract queries the -census contract to check whether the root used in a submitted proof is recognized as valid. -As in all dynamic models, only additions to the census are permitted. - -\paragraph{Credential service provider.} - -Credential service provider (CSP)\\ - -This model replaces the Merkle-tree-based census with an eligibility credential issued by a -trusted entity. Instead of providing a Merkle proof, voters obtain a digital signature from a -\emph{Credential Service Provider} (CSP) attesting to their eligibility. In this case, the -election registry smart contract stores the CSP’s public key in \texttt{censusRoot}, and -\texttt{censusURI} specifies where voters may request or obtain their credential. Sequencers -verify eligibility by checking the CSP signature directly, eliminating the need for a -census tree. This approach is suitable when eligibility is administered by an external -authority capable of issuing verifiable credentials. - -\paragraph{Constructing the census.} - -Any of the above models may be instantiated using different sources of eligibility -information. That is, the protocol does not mandate a specific method for constructing the census tree, different instantiations are possible depending on the application context: -% -\begin{itemize} - \item \emph{Private datasets}. Organizations maintaining internal voter registries (e.g., membership databases or CSV files) can directly convert them into the Merkle format. This approach keeps the registry confidential, with only the root hash made public. - \item \emph{Self-sovereign identity (SSI)}. If voters manage identities through SSI systems, the organizer can aggregate these identities and build - the tree accordingly. This enables participation without requiring centralized identity management. - \item \textit{Ethereum-based tokens}. Token balances (e.g., ERC-20 or NFTs) may also define eligibility. In this setting, the census can either be created via the optimistic approach, taking a snapshot of token balances and allowing a dispute period for fraud proofs, or through a \ac{ZK-SNARK} that proves correctness directly from Ethereum storage proofs and ensures that both individual balances and the token’s total supply are consistent. -\end{itemize} -% -This flexibility allows \davinci to accommodate a wide range of governance and participation use cases, from private associations to decentralized communities, while maintaining the same security and verifiability guarantees.
M v2/sections/cryptographic-primitives.tex → v2/sections/cryptographic-primitives.tex

@@ -191,7 +191,7 @@ %SMTs support efficient membership and non‑membership proofs, enabling a party to prove that a given key-value is (or is not) present in the tree without revealing the content.

In \davinci, SMTs are used to represent two core data structures: the census tree, which encodes the list of eligible voters along with their respective voting weights, and the state tree, which encodes the current status of submitted votes. Both trees have fixed depth 64. The census tree is instantiated with the MiMC hash function over the BLS12-377 scalar field, while the state tree uses Poseidon over the BN254 scalar field. Only the root hash of each tree is published on-chain, ensuring verifiability with minimal on-chain storage. % -To support state transitions and circuit verification, each tree $\tree$ has the following functions associated: +To support state transitions and circuit verification, each tree $\tree{}$ has the following functions associated: \begin{itemize} \item $\tree.\hlset{\MTRoot}()$: it returns the current Merkle root of the tree.

@@ -199,7 +199,7 @@ \item $\tree.\hlset{\MTInsert}(path, \leaf)$: it inserts a new leaf $\leaf$ at the position defined by the given path.

\item $\tree.\hlset{\MTUpdate}(\leaf_{old}, \leaf)$: it updates an existing leaf in the tree. \item $\tree.\hlset{\MTMembershipProof}(\leaf)$: it returns a Merkle proof of inclusion for the given leaf. \item $\tree.\hlset{\MTNonMembershipProof}(\leaf)$: it returns a proof that the given leaf is not included in the tree. - \item $\tree.\hlset{\MTVerify}(\leaf, proof, root)$: it verifies that the given proof corresponds to the claimed root and leaf. + \item $\tree.\hlset{\MTVerify}(\leaf, \MTProof, \root{})$: it verifies that the given proof corresponds to the claimed root and leaf. \end{itemize} These functions are used by sequencers to construct proofs that certify the validity of state transitions. In particular, they allow for off-chain state evolution that is independently verifiable on-chain and within ZK circuits. Additional details on the structure of the census and state trees, as well as the encoding of their leaves, are provided in Sections~\ref{sec:vocdoni-protocol:census} and~\ref{sec:vocdoni-protocol:state-tree}.
M v2/sections/state-tree.tex → v2/sections/state-tree.tex

@@ -10,9 +10,10 @@

\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}. +The state tree operates over keys in the range $[0, 2^D-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 = 2^{D-1}\), +which we use to split the address space into a lower region for configuration parameters and encrypted ballot storage, and an upper region strictly reserved for vote identifiers. This strict separation ensures that configuration entries, vote identifiers, and ballots never collide. The structure of the tree is depicted in Figure~\ref{fig:mt-state}. +%the 64-bit key space is partitioned into disjoint numeric namespaces by leveraging the most significant bit (MSB) of the address, effectively splitting the space exactly in half at the threshold N. + \begin{figure}[h] \centerline{\includegraphics[width=450pt,draft=false]{\figs/mt-state-mermaid}}

@@ -25,35 +26,40 @@

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}: 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. + \footnote{The index \texttt{0x1} is reserved for backward compatibility (historically used for alternative census structures).} \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). + \item \texttt{0x6}: the census origin (\censusorigin). %and \type, a field in case the organization was using a different structure for the census than a MT. \end{itemize} -Let $\configmax$ denote the largest index reserved for configuration parameters. +Let $\configmax$ denote the largest index reserved for configuration parameters (by default, $\configmax = 15$). + +\paragraph{Encrypted ballot namespace.} + +The region immediately following the configuration parameters, the interval $[\configmax + 1, N - 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} = \configmax + \idx \cdot 2^{16} + (\address \bmod 2^{16}). +\] +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. \paragraph{Vote identifier namespace.} -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: +The upper portion of the tree, $[N, 2^D - 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 by setting the most significant bit to 1: \[ -\voteid = \texttt{voteIDMin} + \bigl(\text{Hash}(\processid,\address,k) \bmod (N - \texttt{voteIDMin})\bigr), +\voteid = N + \bigl(\text{Hash}(\processid,\address,k) \bmod N\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. +The \hlget{\statetransitioncircuit} recomputes this derivation and enforces that $N \le \voteid < 2^D$, guaranteeing that vote identifiers cannot overlap with configuration entries or ballot storage. -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. +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. -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}$), +Note that the maximum number of vote identifiers that can be stored is bounded by the size of this namespace ($2^{D-1}$), 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{Encrypted ballot namespace.} - -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 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 and that collisions are exceptionally rare +\footnote{Based on the birthday paradox, the probability of at least one collision occurring is given by $P=1 - e^{-n^2/2d}$, where $n$ is the number of vote identifiers and $d = 2^{D-1}$. For a large-scale national election of $10^8$ votes emitted, this probability is vanishingly small ($\approx0.054\%$), and for an extreme workload of $10^9$ votes, the probability of a single collision is only $\approx5.4\%$, meaning that the need to resample $k$ remains highly improbable.}. 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

@@ -14,10 +14,6 @@ \subsection{Census}

\label{sec:vocdoni-protocol:census} \input{\secs/census.tex} -%\subsection{Census old} -%\label{sec:vocdoni-protocol:census-old} -%\input{\secs/census-old.tex} - \subsection{State tree} \label{sec:vocdoni-protocol:state-tree} \input{\secs/state-tree.tex}