arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
major changes to circuit 4
bellesmarta belles.mm@gmail.com
Thu, 21 Aug 2025 14:29:28 +0200
commit

2800c0628c4b3ac35c3329c3567d5cbdfe96fd75

parent

70cf437a70464622af8ae0152080e7426af3973b

M v2/build/preamble-macros.tex → v2/build/preamble-macros.tex

@@ -148,6 +148,7 @@ \newcommand{\zkproof}{\variablestyle{ZKproof}}

\newcommand{\signature}{\variablestyle{signature}} \newcommand{\address}{\variablestyle{address}} \newcommand{\stateproof}{\variablestyle{stateProof}} +\newcommand{\merkleproofs}{\variablestyle{merkleProofs}} % State Merkle tree \newcommand{\censusroot}{\variablestyle{censusRoot}}

@@ -162,6 +163,9 @@ \newcommand{\substractaccumulator}{\variablestyle{resultsSub}}

\newcommand{\addresses}{\variablestyle{addresses}} \newcommand{\nullifiers}{\variablestyle{nullifiers}} \newcommand{\weight}{\variablestyle{weight}} +\newcommand{\numoverwrites}{\variablestyle{numOverwrites}} +\newcommand{\numvotes}{\variablestyle{numVotes}} +\newcommand{\blobcomm}{\variablestyle{blobComm}} % Others \newcommand{\noi}{\noindent}
M v2/sections/circuits.tex → v2/sections/circuits.tex

@@ -133,130 +133,90 @@ \label{sec:vocdoni-protocol:circuits:state-transition}

The state transition circuit, illustrated in Figure~\ref{fig:circuit-state-transition-v2}, is generated by the sequencer to update the global state of the voting process. 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. 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 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<60$), of which $n$ are new submissions and $m = N-n$ are overwrites of previously cast ballots. In the following, we describe the inputs and constraints of the state transition circuit in detail. + + \begin{spacing}{1.25} \vspace{0.3cm} \noi \textbf{Public inputs} \begin{itemize} - \item \public $\stateroot^{old}$: most recent state tree root. - \item \public $\stateroot^{new}$: most recent state tree root. - \item \public $numOverwrites^{old}$: - \item \public $numOverwrites^{new}$: - \item \public $numVotes^{old}$: - \item \public $numVotes^{new}$: + \item \public $\stateroot^{old}$: current state tree root. + \item \public $\stateroot^{new}$: new tree root after all state transitions are applied. + \item \public $\numoverwrites^{old}$: current number of overwrites. + \item \public $\numoverwrites^{new}$: number of overwrites after all state transitions are applied. + \item \public $\numvotes^{old}$: current number of votes. + \item \public $\numvotes^{new}$: total number of votes after all state transitions are applied. + \item \public $\blobcomm$: commitment to the data blob. \end{itemize} \textbf{Private inputs} \begin{itemize} - \item \private $\{\aggregationproof_i\}$: set of aggregation proofs. + \item \private $\{\aggregationproof_i\}_{i= 1}^{N}$: set of aggregation proofs. \item \private $\censusroot$: census Merkle tree root. \item \private $\ballotmode$: ballot protocol configuration. \item \private $EPK$: encryption public key. \item \private $\processid$: process identifier. - \item \private $\{\voteid_i\}$: set of vote's identifiers. - \item \private $\{(C_1, C_2)_i\}$: set of vote's identifiers. - \item \private $\{\pk_i\}$: list of voters' public keys. - \item \private $\{MerkleProofs_i\}$: list of voters' public keys. - \item \private $\{resultsAdd^{old}\}$: list of voters' public keys. - \item \private $\{resultsSub^{old}\}$: list of voters' public keys. + \item \private $\{\voteid_i\}_{i= 1}^{N}$: set of vote's identifiers. + \item \private $\{(C_1, C_2)_i\}_{i= 1}^{N}$: set of voters' encrypted ballots. + \item \private $\{\pk_i\}_{i= 1}^{N}$: list of voters' public keys. + \item \private $\{\merkleproofs^{encBallots}_i\}_{i= 1}^{N}$: Merkle tree proofs of encrypted ballots. If it is a new vote, the proof will be a non-inclusion proof, if it is an overwrite, an inclusion proof. + \item \private $\{\merkleproofs^{\voteid}_i\}_{i= 1}^{N}$: non-membership proofs of vote identifiers. + \item \private $\addaccumulator^{old}$: current accumulator of votes (before the transitions). + \item \private $\substractaccumulator^{old}$: current accumulator of votes that have been overwritten (before the transition). \item \private $k$: random scalar. + \item \private {\color{blue}{ }Census Merkle tree (old): all leaves of the old tree (except the first six leaves).} \end{itemize} \textbf{Constraints} \\ \vspace{-0.4cm} \begin{itemize} - \item \emph{Aggregation verification.} The accumulated authentication proofs are valid (for the given inputs). For every $i$: + \item \emph{Aggregation verification.} The accumulated authentication proofs are valid. For every $i\in\{1,\dots,N\}$: $$\hlget{\PVerify}(\authenticationproof, PI = ((C_1, C_2)_i, \voteid_i, \pk_i, \processid, \ballotmode, EPK, \censusroot)).$$ - \item \emph{Transition verification.} The public inputs \processid, \ballotmode, \epk, and \censusroot are the same for all proofs. + \item \emph{Transition verification.} Verify initial state and state transitions are applied correctly. + \begin{itemize} + \renewcommand{\labelitemii}{$\circ$} + \item Verify that the inputs $\processid$, $\censusroot$, $\ballotmode$, $\epk$, $\addaccumulator$, and $\substractaccumulator$ correspond to the content of the census Merkle tree leaves $\texttt{0x0}$, $\texttt{0x1}$, $\texttt{0x2}$, $\texttt{0x3}$, $\texttt{0x4}$, $\texttt{0x5}$, respectively. {\color{blue} The root of the tree, with all data and those six leaves, results in \stateroot.} + \[\stateTree\text{(with these six leaves and the rest)}.\MTRoot() = \stateroot.\] + \item Verify that none of the $\voteid_i$ for all $i\in\{1,\dots,N\}$ are initially part of the tree: + \[\stateTree.NonInclusionVerify(\voteid_i, \merkleproofs^{\voteid}_i, \stateroot).\] + \item Ensure that new votes are not part of the tree yet. For $i = 1, \dots, n$: + \[\stateTree \text{-- the leaf following the $\address_i = \hlget{\Keccak}(\pk_i)$ path is empty}.\] + \item Ensure that overwrites do correspond to votes that were already on the tree. For $i = n+1, \dots, N$: + \[\stateTree \text{-- the leaf following the $\address_i = \hlget{\Keccak}(\pk_i)$ path stores an encrypted ballot}.\] + \item State transitions. + \begin{itemize} + \item For new votes (keep iterating for all of them): + \begin{enumerate} + \item Add encrypted ballot to the tree: $\stateTree.\hlget{\MTInsert}(\address = \hlget{\Keccak}(\pk), (C_1, C_2))$. + \item Add vote identifier: $\stateTree.\hlget{\MTInsert}(\voteid)$. + \item Increase votes counter: $\numvotes = \numvotes + 1$. + \item Aggregate the vote to the results accumulator: $\addaccumulator = \addaccumulator + (C_1, C_2)$. + \end{enumerate} + \item For overwritten votes (keep iterating for all of them): + \begin{enumerate} + \item Overwrite the encrypted ballot: $\stateTree.\hlget{\MTUpdate}(\address = \hlget{\Keccak}(\pk), (C_1, C_2))$. + \item Add vote identifier: $\stateTree.\hlget{\MTInsert}(\voteid)$. + \item Increase votes counter: $\numvotes = \numvotes + 1$. + \item Increase overwrites counter: $\numoverwrites = \numoverwrites + 1$. + \item Aggregate the vote to the results accumulator: $\addaccumulator = \addaccumulator + (C_1, C_2)$. + \item Aggregate the old vote to the accumulator: $\substractaccumulator = \substractaccumulator + (C_1, C_2)^{old}$. + \end{enumerate} + {\color{blue}The old ciphertexts $(C_1, C_2)^{old}$ should also be inputs or retrieved from the MT inclusion proofs.} + \end{itemize} + \item After all previous state transitions are done, recompute new tree root: + \[\stateroot^{new} = \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?}. + \[newLeafContent = \hlget{\ReEnc}_{\epk}((C_1, C_2)_i, k), \quad k = Hash(k).\] + \item Data blob commitment. + \end{itemize} \end{itemize} \vspace{-0.3cm} \end{spacing} --------------------------------------------------------- -\newpage +\subsubsection{Results circuit} +\label{sec:vocdoni-protocol:circuits:results} -\paragraph{Assertions.} +{\color{blue}{It needs to be done.}} -\begin{itemize} - \item \emph{Aggregation verification}: The agreggated zkProof is valid. - \item \emph{Transition verification}: The MerkleTree transition witness proves every change between Root1 and Root2. - \item \emph{Public inputs integrity}: ProcessID, BallotMode, CensusRoot, EncryptionKey remain unchanged. - \item \emph{Votes counting}: Ballots are correctly counted as new or overwrites, and added to results accumulators. -\end{itemize} - -When a new voting process begins, the Sequencer initializes a new State, represented by the root hash of a Merkle tree. This tree encapsulates all essential information about the voting process, including process parameters, voter registry (census), ballot configurations, and initial results. - -For each new batch of votes, the Sequencer updates the state by generating a zkSNARK proof that \textbf{validates the state transition from the current Root to a new Root}. This proof is submitted on-chain for settlement. By doing so, we maintain an immutable and verifiable record of the voting process on the blockchain. - -This approach allows anyone to access the latest verified state of the voting process from the Results Verification smart contract, along with the necessary data to process subsequent state updates. The system's design enables multiple Sequencers to participate in tallying votes. They can take the current State Root and its associated data to construct the next state, incorporating new votes into the tally. This decentralization of Sequencers helps prevent potential censorship and reinforces the robustness of the voting process. - -\paragraph{Maintaining the Chain.} - -The chain of integrity is maintained through a combination of smart contract enforcement and strict zkSNARK circuit constraints. This ensures that each state transition is valid and builds upon the last accepted state without requiring additional mechanisms. - -\begin{itemize} - \item \textbf{Sequential state roots}: Each state transition updates the Merkle tree from a previous root (`Root1`) to a new root (`Root2`) after processing a batch of votes. - \item \textbf{Smart contract enforcement}: The smart contract verifies that the `Root1` provided in the zkSNARK proof matches the last committed state root stored on-chain. This guarantees that all transitions are sequential and based on the latest accepted state. - \item \textbf{Proof validation}: The smart contract uses the zkSNARK verification key to validate the submitted proof. A valid proof confirms that the transition from `Root1` to `Root2` adheres to all protocol rules enforced by the circuit. - \item \textbf{State update}: Upon successful verification, the smart contract updates the stored state root hash to`Root2`, ensuring an immutable and continuous chain of states. -\end{itemize} - -\paragraph{State Transition} - -To validate and process state transitions, \textbf{we employ a zkSNARK circuit that enforces all protocol constraints}. This circuit proves that the transition from the previous state Root to the new state Root is valid based on the newly processed votes. - -\begin{figure}[H] - \centering - \fbox{ - \includegraphics[scale = 0.12, draft = false]{\figs/state-transition.png}} -\end{figure} - -%\begin{figure}[H] -% \centering -% \fbox{ - % \includegraphics[scale = 0.3, draft = false]{\figs/circuit-inputs.png}} -%\end{figure} -% -%\begin{figure}[H] -% \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-state-transition}} -% \caption{State transition circuit. All public values are framed in green.} -% \label{fig:circuit-state-transition} -%\end{figure} - -\begin{mdframed} - \begin{minipage}[H]{1\textwidth} - \begin{spacing}{1.25} - \vspace{0.3cm} - \begin{center}{STATE TRANSITION CIRCUIT}\end{center} - \textbf{Public inputs} - \begin{itemize} - \item \public $root_{old}$: Merkle tree root before the state transition. - \item \public $root_{new}$: Meklre tree root after the state transition. - \item \public $blobCommitment$: the commitment to the data blob containing the new votes. - \end{itemize} - \item \textbf{Private inputs} - \begin{itemize} - \item \private Votes: The list of new votes being processed, including census proofs and authentication data. - \item \private Merkle Proofs of nullifier inclusion: Proofs that each voter nullifier is included in the census. - \item \private Merkle Proofs of results update: Proofs that the process results have been correctly updated. - \item \private Merkle Tree Update Witnesses: Necessary data (e.g., Merkle paths) to update the Merkle tree from Root1 to Root2. - \item \private Process Parameters: Retrieved from Root1 within the circuit. - \end{itemize} - \textbf{Constraints} \\ \vspace{-0.4cm} - \begin{itemize} - \item \textbf{Immutable process parameters}: Ensure that critical process parameters (such as `censusRoot` or `processId`) retrieved from `Root1` remain consistent and are not altered in the transition. - \item \textbf{Vote validity}: Validate that each vote proof is correct. - \item \textbf{Voter eligibility}: Confirm that each voter is included in the census by verifying Merkle proofs of inclusion against the `censusRoot` retrieved from `Root1`. - \item \textbf{Nullifier non-existence}: Ensure that the nullifier for each vote does not exist in the current state (`Root1`), preventing double voting. - \item \textbf{Nullifier addition}: Correctly add each new nullifier to the state, resulting in `Root2`, updating the Merkle tree accordingly. - \item \textbf{Results update}: Ensure that the voting results are accurately updated by adding the new votes to the previous results retrieved from `Root1`, so that `results2 = results1 + votes`. - \item \textbf{Blob data integrity}: Confirm that the data used in the circuit (votes, nullifiers) corresponds to the `blobCommitment` provided as a public input, ensuring that the votes processed are exactly those published in the data blob. - \item \textbf{State transition validity}: Ensure that the new state root (`Root2`) is correctly computed from `Root1` by applying the validated votes and updates to the Merkle tree. - \end{itemize} - \vspace{-0.3cm} - \end{spacing} - \end{minipage} -\end{mdframed} - -\martai{STATE TRANSITION CIRCUIT: a potential problem is that a sequencer may know if one of their votes has been overwritten, for this reason, sequencers reencrypt a certain amount of ballots every time (already existing ballots I mean). So, the circuit should include the reencryptions: both for existing ballots and also for the new votes, which should be reencrypted (for receipt-freeness).} - +%%% STATE-TRANSITION CIRCUIT \begin{landscape} %\thispagestyle{empty} % removes the page number \begin{figure}[H]

@@ -265,8 +225,3 @@ \caption{State transition circuit. All public values are framed in green.}

\label{fig:circuit-state-transition-v2} \end{figure} \end{landscape} - -\subsubsection{Results circuit} -\label{sec:vocdoni-protocol:circuits:results} - -{\color{blue}{It needs to be done.}}
M v2/sections/cryptographic-primitives.tex → v2/sections/cryptographic-primitives.tex

@@ -158,7 +158,7 @@ \label{sec:cryptographic-primitives:hash}

\Davinci uses different hash functions. On the one side, we use Keccak256~\cite{bertoni11keccak} for Ethereum address derivation, and Poseidon~\cite{grassi21poseidon}, MiMC and MiMC-7~\cite{albrecht16mimc} for arithmetic circuits within zero-knowledge proofs. -\paragraph{Keccak256.} Keccak256 is the standard hash function used by Ethereum and is employed in \davinci to compress messages for signing and deriving Ethereum addresses from public keys over $\SEC{\G}$. Keccak256 takes arbitrary-length bitstrings and outputs 256-bit digests: $\hlset{\Keccak} : \{0,1\}^* \rightarrow \{0,1\}^{256}$. This function is not SNARK-friendly and it is used exclusively in the authentication circuit, where the verification of Ethereum-compatible signatures requires reproducing the original message hash computed by Ethereum clients (see Section~\ref{sec:vocdoni-protocol:circuits:authentication}). +\paragraph{Keccak256.} Keccak256 is the standard hash function used by Ethereum and is employed in \davinci to compress messages for signing and deriving Ethereum addresses from public keys over $\SEC{\G}$. Keccak256 takes arbitrary-length bitstrings and outputs 256-bit digests: $\hlset{\Keccak} : \{0,1\}^* \rightarrow \{0,1\}^{256}$. This function is not SNARK-friendly and it is used exclusively in the authentication circuit, where the verification of Ethereum-compatible signatures requires reproducing the original message hash computed by Ethereum clients (see Section~\ref{sec:vocdoni-protocol:circuits:verifier}). \paragraph{Poseidon.} Poseidon is a SNARK-optimized hash function designed for efficient implementation inside arithmetic circuits. It is used in \davinci for computing commitments, nullifiers, and the state Merkle tree roots. Poseidon is used as $\hlset{\Poseidon} : \mathfrak{F}_s \rightarrow \F_s$, where $\mathfrak{F}_s$ is the set of tuples of $\F_s$-elements of any length, and $\F_s$ is the field described in Section~\ref{sec:cryptographic-primitives:elliptic-curves}.
M v2/sections/introduction.tex → v2/sections/introduction.tex

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

% !TeX root = ../build/main.tex 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—including iVote, Helios, and the Estonian I‑voting system—have revealed deep-rooted usability flaws and security gaps, particularly when verifiability mechanisms are either poorly understood by users or reliant on centralized infrastructure. +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 across a range of devices, including smartphones. To support these goals, the team deployed a custom infrastructure emphasizing resilience, neutrality, and transparency.
M v2/sections/protocol-flow.tex → v2/sections/protocol-flow.tex

@@ -69,6 +69,7 @@

\noi \sequencers Upon receiving votes, a sequencer does the following: \begin{enumerate} + {\color{blue} \item Retrieve the current state root $\stateroot$ and census root $\censusroot$ from the process management smart contract and the associated data from the Ethereum data blobs. \item Verify each submission by generating a state transition proof (see Section~\ref{sec:vocdoni-protocol:circuits:state-transition}), ensuring: \begin{itemize}

@@ -79,6 +80,7 @@ \item absence of double voting (or correct handling of overwrites via nullifiers),

\item consistency between data blobs and the on-chain state. \end{itemize} \item Submit the updated state root to the smart contract, while the full data are stored in Ethereum blobs. + } \end{enumerate} Sequencers repeat this process until the voting deadline set by the organizer.