arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
davinci-paper/v2/sections/census.tex
v2/sections/census.texRaw
 1% !TeX root = ../build/main.tex
 2
 3The 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:
 4\begin{itemize}
 5	\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).
 6	\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. 
 7	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}).
 8	
 9	
10\end{itemize}
11%
12To support different census models, the \hlget{\electionregistry} smart contract stores the following three parameters:
13\begin{itemize}
14	\item \censusorigin: the deployment model (off-chain static, off-chain dynamic, on-chain dynamic, or \ac{CSP}).
15	\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.
16	\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 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).	
17\end{itemize}
18%
19Organizers 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. 
20%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.
21%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.
22This flexibility supports a broad range of use cases and governance scenarios. 
23%
24The supported census models are summarized in Table~\ref{tab:census-models} and described in detail below.
25
26\begin{table}[H]
27	\centering
28	\renewcommand{\arraystretch}{1.25}
29	\begin{tabular}{|P{1.6cm}|P{2.1cm}|P{3.3cm}|P{4.1cm}|P{4.8cm}|}
30		
31		\hline
32		\multicolumn{2}{|c|}{\censusorigin} &
33		\censusroot &
34		\censusuri &
35		Membership proof \\
36		\hline
37		
38		\multicolumn{2}{|P{3.5cm}|}{Credential service provider (\ac{CSP})}
39		& Hash of the {\ac{CSP}'s public key}
40		& Endpoint to obtain an eligibility credential
41		& \multirow{2}{*}{Digital signature verification}\\
42		\hline
43		
44		\multirow{4}{*}{Off-chain}			
45		& \multirow{2}{*}{\centering Static}
46		& \multirow{2}{*}{Fixed Merkle root}
47		& Endpoint to obtain the census tree
48		& Merkle proof verified against the fixed Merkle root \\
49		\cline{2-5}
50		
51		& \centering Dynamic (add-only)
52		& \multirow{2}{*}{Latest Merkle root}
53		& Endpoint to obtain the latest version of the tree
54		& Merkle proof verified against the latest Merkle root\\
55		\hline
56		
57		\multirow{2}{*}{On-chain}
58		& \centering Dynamic (add-only)
59		& \censusmanagement contract address
60		& Endpoint to obtain the latest version of the tree
61		& Merkle proof verified against most recent Merkle roots \\
62		\hline
63		
64	\end{tabular}
65	\vspace{0.5cm}
66	\caption{Summary of census configurations supported by the \davinci protocol.}
67	\label{tab:census-models}
68\end{table}
69
70\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.
71
72\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.
73
74\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.
75
76\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.
77
78%CENSUS ORIGIN
79%MerkleTreeOffchainStaticV1
80%MerkleTreeOffchainDynamicV1
81%MerkleTreeOnchainDynamicV1
82%CSPEdDSABabyJubJubV1