changes to census + circuits
@@ -170,6 +170,7 @@ \newcommand{\censuspf}{\variablestyle{censusProof}}
\newcommand{\commitment}{\variablestyle{identityCommitment}} \newcommand{\nullifier}{\variablestyle{nullifier}} \newcommand{\encryptedballot}{\variablestyle{encryptedBallot}} +\newcommand{\reencryptedballot}{\variablestyle{reEncryptedBallot}} \newcommand{\zkproof}{\variablestyle{ZKproof}} \newcommand{\signature}{\variablestyle{signature}} \newcommand{\address}{\variablestyle{address}}
@@ -21,7 +21,7 @@ \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{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. -\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, GraphQL provides the endpoint from which sequencers download the current version of the tree. Sequencers verify membership proofs against the most recently published root. +\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 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.
@@ -1,10 +1,10 @@
% !TeX root = ../build/main.tex -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 census membership; 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 Figure~\ref{fig:circuits-flow}. +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 Figure~\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.} + Overview of the circuit flow in \davinci. {\color{blue}\textit{Results circuit} is missing.}} \label{fig:circuits-flow} \end{figure}@@ -34,6 +34,7 @@ \begin{itemize}
\item \private $\ballot$: voter's voting choice. \item \private $k$: random scalar. \end{itemize} + \pagebreak \textbf{Constraints} \begin{itemize} \item \emph{Vote encryption}. Correct encryption of the ballot: \[\encryptedballot = \hlget{\Enc}_{\epk}(\ballot; k).\]@@ -54,7 +55,7 @@
\subsubsection{Verifier circuit} \label{sec:vocdoni-protocol:circuits:verifier} -The verifier circuit (\hlset{\verifiercircuit}), illustrated in Figure~\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 it also validates the voter’s eligibility in the census 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. {\color{blue}-- Authentication of verification proof?} +The verifier circuit (\hlset{\verifiercircuit}), illustrated in Figure~\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. {\color{blue}-- Authentication of verification proof?} \begin{spacing}{1.25} \vspace{0.3cm}@@ -68,6 +69,7 @@ \item \public $\voteid$: vote's unique identifier.
\item \public $\address$: voter's address. \item \public $\weight$: voter's weight. \end{itemize} + \pagebreak \textbf{Private inputs} \begin{itemize} \item \private $\pk$: voter's public key.@@ -152,9 +154,9 @@ \vspace{-0.5cm}
\subsubsection{State transition circuit} \label{sec:vocdoni-protocol:circuits:state-transition} -The state transition circuit (\hlset{\statetransitioncircuit}), illustrated in Figure~\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, and that the accumulators of encrypted results are updated accordingly {\color{blue}[+census membership +blobs]}. The correctness of this circuit is attested by a \ac{ZK} proof generated using the \ac{ZK-SNARK} protocol described in Section~\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}$. This proof is submitted on-chain and verified by the process management smart contract, ensuring that every accepted state transition complies with the protocol rules. +The state transition circuit (\hlset{\statetransitioncircuit}), illustrated in Figure~\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 Section~\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}$. This proof 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 {\color{blue}[Notation is easier if this is in the reverse order]}. In the following, we describe the inputs and constraints of the state transition circuit in detail. +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} \vspace{0.3cm}@@ -183,7 +185,7 @@ \item \private $\{\censuspf_i\}_{i = 1}^N$: census membership proofs.
% \item \private $\{\voteid_i\}_{i = 1}^{N}$: set of vote's identifiers. \item \private $\{\encryptedballot_i\}_{i = 1}^{N}$: set of voters' encrypted ballots. - \item \private $\{\encryptedballot_i^\old\}_{i = 1}^{m}$: set of all old encrypted ballots that will be overwritten. + \item \private $\{\encryptedballot_i^\old\}_{i = n+1}^{N}$: set of all old encrypted ballots that will be overwritten. \item \private $\{\address_i\}_{i = 1}^{N}$: list of voters' addresses. \item \private $\{\weight_i\}_{i = 1}^{N}$: list of voters' weights. \\ %@@ -193,7 +195,7 @@ \item \private $\merkleInclusionPf^{\ballotmode}$: proof that $\ballotmode$ is stored in leaf $\texttt{0x2}$ of the state tree.
\item \private $\merkleInclusionPf^{\addaccumulator}$: proof that $\addaccumulator^\old$ is stored in leaf $\texttt{0x3}$ of the state tree. \item \private $\merkleInclusionPf^{\substractaccumulator}$: proof that $\substractaccumulator^\old$ is stored in leaf $\texttt{0x4}$ of the state tree.\\ % - \item \private $\{\merkleNInclusionPf^{\encryptedballot}_i\}_{i = 1}^{n}$: proof that the leaf corresponding to a voter's $\address$ that submits a new vote is empty. + \item \private $\{\merkleNInclusionPf^{\encryptedballot}_i\}_{i = 1}^{n}$: proof that the leaf corresponding to a voter's $\address_i$ that submits a new vote is empty. \item \private $\{\merkleInclusionPf^{\encryptedballot}_i\}_{i = n+1}^{N}$: proof that the vote $\encryptedballot_i^\old$ is stored in the leaf corresponding to a voter's $\address$ that submits the vote overwrite $\encryptedballot_i$. \item \private $\{\merkleNInclusionPf^{\voteid}_i\}_{i= 1}^{N}$: non-membership proofs of vote identifiers.\\ %@@ -212,8 +214,21 @@ \end{align*}
\item Verify proof: $$\hlget{\PVerify}(\aggregationproof_i, \publicinputs) = \true.$$ \end{itemize} - \item \emph{Census membership.} The voter's address and weight are part of the census. For every $i\in\{1,\dots,N\}$: - $$ \hlget{\censusTree}.\hlget{\MTVerify}\left((\weight_i, \address_i), {\color{blue}{path??}}, \censuspf_i, \censusroot\right) = \true. $$ + \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, + \] + 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\}$: + \[ + \hlget{\censusTree}.\hlget{\MTVerify}\big((\address_i, \weight_i), \censuspf_i, \censusroot\big) = \true. + \] + \end{itemize} + + %%%%% \item \emph{Transition verification.} Verify that the initial state and the state transition updates are applied correctly. \begin{itemize} \renewcommand{\labelitemii}{$\circ$}@@ -229,20 +244,25 @@ \end{align*}
\item Verify that none of the $\voteid_i$ for all $i\in\{1,\dots,N\}$ are initially part of the tree: \[\hlget{\stateTree}.\hlget{\MTVerify}(\voteid_i, \merkleNInclusionPf^{\voteid}_i, \stateroot^\old).\] \item Ensure that new votes are not part of the tree yet. For $i = 1, \dots, n$: - \[\hlget{\stateTree}.\hlget{\MTVerify}(\textsc{\color{blue}EMPTY}, \address_i, \merkleNInclusionPf^{\encryptedballot}_i, \stateroot^\old).\] + \[\hlget{\stateTree}.\hlget{\MTVerify}(\address_i, \merkleNInclusionPf^{\encryptedballot}_i, \stateroot^\old).\] \item Ensure that overwrites do correspond to votes that were already on the tree. For $i = 1, \dots, m$: \[\hlget{\stateTree}.\hlget{\MTVerify}(\encryptedballot_i^\old, \address_i, \merkleInclusionPf^{\encryptedballot}_i, \stateroot^\old).\] \item State transitions. \begin{itemize} \item For every new vote $i = 1, \dots, n$: \begin{enumerate} - \item Add encrypted ballot to the tree: $\hlget{\stateTree}.\hlget{\MTInsert}(\encryptedballot_i, \address_i)$. - \item Add vote identifier: $\hlget{\stateTree}.\hlget{\MTInsert}(\voteid)$. + \item Reencrypt the ballot: + $\encryptedballot_i = \hlget{\ReEnc}_{\epk}(\encryptedballot_i, k).$ + \item Refresh reencryption randomness: $k = \hlget{\Mimc}(k).$ + \item Add reencrypted ballot to the tree: $\hlget{\stateTree}.\hlget{\MTInsert}(\encryptedballot_i, \address_i)$. + \item Add vote identifier to the tree: $\hlget{\stateTree}.\hlget{\MTInsert}(\voteid_i)$. \item Increase votes counter: $\numvotes = \numvotes + 1$. \item Aggregate the vote to the results accumulator: $\addaccumulator = \addaccumulator + \encryptedballot_i$. \end{enumerate} \item For every overwritten vote $i = n+1, \dots, N$: - \begin{enumerate} + \begin{enumerate} \item Refresh reencryption randomness: $k = \hlget{\Mimc}(k).$ + \item Reencrypt the ballot: + $\encryptedballot_i = \hlget{\ReEnc}_{\epk}(\encryptedballot_i, k).$ \item Overwrite the encrypted ballot: $\hlget{\stateTree}.\hlget{\MTUpdate}(\encryptedballot, \address_i)$. \item Add vote identifier: $\hlget{\stateTree}.\hlget{\MTInsert}(\voteid)$. \item Increase votes counter: $\numvotes = \numvotes + 1$.@@ -253,12 +273,12 @@ \end{enumerate}
\end{itemize} \item After all previous state transitions are done, recompute new tree root: \[\stateroot^\new = \hlget{\stateTree}.\hlget{\MTRoot}().\] - \item Reencrypt all leafs of the tree (both old and new ones). {\color{blue}New are ok, but for those that are old, also verify MTProofs of membership? -- YES}. - \[newLeafContent = \hlget{\ReEnc}_{\epk}(\encryptedballot_i, k), \quad k = Hash(k).\] + \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.} \end{itemize} \item \emph{Data blob}. \begin{itemize} - \item Construct blob $B$ (as described in Section~X). + \item From all leaves that changed after the state transitions in the $\hlget{\stateTree}$ tree, construct blob $B$. + %(as described in Section~{\color{blue}X}) \item Derive polynomial $p(x)$ from $B$. \item Compute evaluation point \( z = \hlget{\Poseidon}(\processid, C, \openproof) \).@@ -270,9 +290,9 @@ \end{itemize}
\vspace{-0.3cm} \end{spacing} -{\color{blue}Mention that an advantage of splitting the circuits of the sequencers in 3 is that if the stateRoot changes in the meantime, the sequencer only needs to rerun the last circuit and not all three of them.}\\ - -\martai{\numvotes and \numoverwrites are part of the smart contract state.} +\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. +\end{remark} \begin{landscape} \centering