% !TeX root = ../build/main.tex The \davinci protocol builds on several decentralized technologies and advanced cryptographic tools. In this section, we give a high-level overview of these components and their role in the system. We first introduce content-addressed off-chain storage, which serves to distribute large datasets such as censuses and election metadata. We then describe Ethereum, the settlement layer where commitments are published, rules are enforced through smart contracts, and state data is published using data blobs, together with the OP Stack rollups on which \davinci can also settle. We continue with the Merkle trees that commit to the census and to the election state. Finally, we present the \ac{ZK} proof systems that underpin the protocol's integrity and security: \acp{ZK-SNARK} and arithmetic circuits, which voters use to prove that their ballots comply with the election rules, and \acp{zkVM}, which sequencers use to prove that they processed the ballots correctly. \subsection{Off-chain storage} \label{sec:background:ipfs} Large datasets, such as the full census (eligible voters and their weights) and the election metadata (which may include questions, options, images, etc.), do not need to be stored directly on a blockchain. Instead, \davinci stores them off-chain and publishes on-chain a short commitment to their content: the root of the census Merkle tree (see Section~\ref{sec:background:mt}) for the census, and the SHA-256 digest of the exact bytes of the metadata document. Anyone who fetches a dataset can recompute the commitment and confirm its integrity, so the transport does not need to be trusted and can be chosen freely, from a conventional web server to a peer-to-peer network. The \acf{IPFS} is a natural choice for such a transport. \ac{IPFS} is a peer-to-peer distributed storage network that retrieves data based on its content rather than on its location. 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, versioning, and distributed availability (data can be fetched from any node that stores it), which allows it to function as a decentralized content delivery network. In the context of \davinci, the census and metadata \acp{URI} registered on-chain may point to \ac{IPFS} content (typically through a gateway) or to any other location; in all cases, the on-chain commitment, not the location, is authoritative. \subsection{Ethereum} \label{sec:background:ethereum} Ethereum is a decentralized blockchain platform that supports programmable transactions through its built-in execution environment, the \acf{EVM}. All interactions with the Ethereum network take the form of transactions, which must be broadcast to the network, validated by consensus, and permanently recorded on-chain. Every transaction requires the payment of a fee (measured in units of gas), denominated in ETH, to compensate validators for computation and storage. This fee model ensures that resources are used efficiently and prevents denial-of-service attacks by making large or complex operations costly. Each block header commits to the block's transactions through the root of a \ac{MPT}~\cite{wood2014ethereum}, and to its parent block through the parent's hash, so a chain of headers anchored at a trusted block hash proves that a given transaction belongs to the canonical chain. In the context of \davinci, Ethereum serves as the settlement layer where critical commitments are published, ensuring transparency and immutability. \paragraph{Smart contracts.} Smart contracts are programs deployed on the Ethereum blockchain that execute deterministically in response to transactions. Once deployed, they cannot be altered, and their execution is guaranteed by the consensus of the network. In \davinci, smart contracts orchestrate the election by managing state transitions and storing critical data such as the current state root and the encryption public key. They enforce the protocol rules in a trustless environment, ensuring that no single participant can manipulate the election. By anchoring these rules in Ethereum smart contracts, \davinci guarantees that the election logic is applied consistently and verifiably across all participants. \paragraph{Data blobs.} Data availability is a key requirement for decentralized protocols. EIP-4844~\cite{eip4844} introduces data blobs as a mechanism for publishing large volumes of data alongside transactions at a lower cost than calldata or contract storage. A blob is a vector of $4096$ elements of the scalar field of the BLS12-381 curve (128~KiB), interpreted as the evaluations of a polynomial over a multiplicative subgroup of that field. A blob-carrying transaction does not expose the blob contents to the \ac{EVM}; it exposes only a \emph{versioned hash} of a \ac{KZG} commitment to the blob polynomial (see Appendix~\ref{sec:cryptographic-primitives:commitments}). A contract can nevertheless check a claim about the blob contents with the point-evaluation precompile, which verifies that the committed polynomial evaluates to a given value at a given point. Blobs are kept by the consensus layer for 4096 epochs, approximately 18 days, after which they are pruned; for longer election periods, nodes or third-party archivers must retain them. Since the activation of EIP-7594~\cite{eip7594}, a transaction carries at most six blobs. In \davinci, sequencers use data blobs to publish the data of each state transition, so that any participant can reconstruct and verify the evolution of the election without overloading Ethereum's permanent storage. \paragraph{Rollups and the OP Stack.} A rollup is a blockchain that executes transactions off the Ethereum mainnet (the \emph{layer 1}) and posts its own transaction data to it, inheriting its data availability and, through fraud or validity proofs, its security. The OP Stack~\cite{opstack} is a widely deployed framework for optimistic rollups (\emph{layer 2} chains), among which is OP Mainnet. Execution on such chains is substantially cheaper than on Ethereum, which makes them attractive for settling frequent state transitions. Two properties of the OP Stack matter for \davinci. First, each layer-2 block is derived from a recent layer-1 block, its \emph{L1 origin}, and a system contract (\lblock) exposes the number and the hash of that block to the layer-2 \ac{EVM}. Second, layer-2 contracts have no access to the versioned hashes of layer-1 blob transactions. \Davinci therefore supports an \emph{L1-blob mode}, in which the election data is published in Ethereum blobs and the registry contract on the rollup verifies, from a chain of Ethereum block headers anchored at the L1 origin, that the corresponding blob transactions are part of the Ethereum chain (see Section~\ref{sec:vocdoni-protocol:flow:settlement}). \subsection{Merkle trees} \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. 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 determined by the bits of the key, independently of the insertion order, and empty subtrees are represented by a constant. The proof of a leaf's membership or non-membership therefore has a bounded length and can be verified by a fixed procedure, which makes the structure well suited to \ac{ZK} proofs. In \davinci, the state tree is an \ac{SMT} of depth 64 indexed by 64-bit keys. Configuration parameters occupy reserved keys, each voter's encrypted ballot is stored at a key derived from the voter's identity, and each one-time vote identifier is recorded at its own key. 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 \ac{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 is arbo~\cite{arbo}, whose structure and proof format follow the circomlib sparse Merkle tree specification~\cite{baylina2019sparse}, instantiated with the SHA-256 hash function. SHA-256 is cheap both on the \ac{EVM}, where it is a precompile, and in the \ac{zkVM}, where it is an accelerated operation, so the same tree can be updated inside a proof and checked by a smart contract. \paragraph{Incremental Merkle trees.} The census (voter registry) is maintained with an \ac{IMT}, a binary Merkle tree designed for efficient sequential updates. 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 a lean \ac{IMT}~\cite{leanimt} hashed with Poseidon: each eligible voter's address 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 $M$ voters has height $\lceil \log_2{M} \rceil$, instead of a fixed large height). Consequently, proving one's inclusion in the voter list is more efficient than it would be with an \ac{SMT}: the Merkle proof is shorter and involves no unnecessary default nodes. A lean \ac{IMT} root does not commit to the number of leaves, and a node with a single child is promoted to the next level instead of being hashed with an empty sibling, so a membership proof does not pin the position of its leaf. For this reason, the slot where a voter's ballot is stored is derived from the voter's address, never from the voter's position in the census (see Section~\ref{sec:vocdoni-protocol:state-tree}). \subsection{Zero-knowledge proofs} \label{sec:background:zkp} Zero-knowledge (ZK) proofs are cryptographic protocols that allow one party (the prover) to convince another (the verifier) that a certain statement is true, without revealing any information beyond the validity of the statement itself. In the context of voting, this enables participants to prove that their encrypted ballot is well-formed and complies with the election rules, without disclosing their actual choice. \paragraph{\Acp{ZK-SNARK}.} We focus on a specific type of proof system called zero-knowledge succinct non-interactive arguments of knowledge (\acsp{ZK-SNARK}). Informally, while a \ac{ZK} proof convinces the verifier that a valid witness exists, an argument of knowledge additionally ensures that the prover actually knows such a witness, except with negligible probability. \acsp{ZK-SNARK} extend this notion with two crucial properties: they are non-interactive, requiring only a single message from prover to verifier, and succinct, meaning that proof size and verification cost remain small regardless of the size of the underlying statement. For instance, Groth16 proofs~\cite{groth2016size}, which rely on pairing-based cryptography over elliptic curves, are only about 200 bytes long and can be verified in a few milliseconds, and PlonK proofs~\cite{gabizon2019plonk} are less than a kilobyte long and are verified on the \ac{EVM} for a few hundred thousand gas. These properties make \acsp{ZK-SNARK} particularly well-suited for blockchain applications, where verification cost and data size are critical. In \davinci, voters generate Groth16 proofs to show that their encrypted ballots are correct, and the proofs of the sequencers reach the smart contracts as PlonK proofs (see the paragraph on \acp{zkVM} below). In essence, \acsp{ZK-SNARK} enable both voters and sequencers to produce compact proofs that can be checked on-chain, ensuring that all protocol rules are followed without requiring trust in any party. \paragraph{Trusted setup.} A limitation of some \ac{ZK-SNARK} protocols is their reliance on a \ac{CRS} generated during a so-called trusted setup. The \ac{CRS} is built from random values that must not be known to either the prover or the verifier. To achieve this, the \ac{CRS} can be created by a trusted third party or, more robustly, via a secure \ac{MPC} protocol \cite{canetti2001universally}. In an MPC setup, it suffices that at least one participant discards their secret contribution to ensure the integrity of the whole ceremony. Groth16 requires a setup specific to each circuit, preceded by a universal \emph{powers of tau} phase, whereas PlonK requires only a universal setup that serves every circuit up to a given size. \acp{STARK} require no trusted setup at all. In \davinci, only the ballot circuit and the final PlonK wrapper of the \ac{zkVM} depend on a structured reference string (see Section~\ref{sec:analysis:implementation} and Appendix~\ref{sec:cryptographic-primitives:zkp}). \paragraph{Arithmetic circuits.} In general, \acsp{ZK-SNARK} operate by proving the satisfiability of an arithmetic circuit. An arithmetic circuit (from now on also called circuit or \ac{ZK} circuit) is a directed acyclic graph where nodes represent addition or multiplication gates over a finite field. The inputs and outputs of the circuit correspond to the public inputs and private witnesses of the computation, while the intermediate wires carry intermediate values. Any deterministic computation, from verifying an encryption to checking Merkle proofs, can be compiled into an arithmetic circuit \cite{gennaro2013quadratic}. In practice, proving with \acsp{ZK-SNARK} means showing knowledge of a secret witness (e.g., a plaintext ballot or encryption randomness) that satisfies all the equations encoded in the circuit. For example, the ballot circuit in \davinci encodes the constraints that a ciphertext is well-formed, that the vote identifier is correctly derived, and that the ballot complies with the rules of the voting mode. The prover generates a proof of satisfiability, while the verifier only checks the proof against the public inputs, without learning the secret witness. Circuits are compact for algebraic statements over their native field, such as elliptic curve operations on an embedded curve, but they become large and difficult to audit for statements with heavy control flow, variable-length data, or arithmetic over foreign fields, which is precisely the nature of the work of a sequencer. \paragraph{Zero-knowledge virtual machines.} A \ac{zkVM} proves the correct execution of a program rather than the satisfiability of a hand-written circuit. The program, called the \emph{guest}, is written in a conventional language (Rust, in \davinci), compiled to a standard instruction set such as RISC-V~\cite{riscv2019}, and executed on an input supplied by the \emph{host}. The \ac{zkVM} proves that the guest ran to completion on some input and committed a given vector of \emph{public values}; the input itself remains private. Formally, for a program $\Prog$ we write $\VMProve(\Prog, \witness) \rightarrow (\publicvalues, \pi)$ and $\VMVerify(\programvk, \publicvalues, \pi) \rightarrow \{\true, \texttt{false}\}$, where \programvk is a verification key that identifies $\Prog$ (a commitment to its compiled code). A verifier that pins \programvk therefore pins the exact program whose execution is being proven, and any change to the program changes its key. \Davinci uses the ZisK \ac{zkVM}~\cite{zisk}, which proves RISC-V executions with FRI-based \acp{STARK}~\cite{bensasson2018stark,bensasson2018fri} over the Goldilocks field and accelerates hashing (SHA-256, Keccak), modular arithmetic, and elliptic curve operations (SECP256K1, BN254, BabyJubjub) with precompiles. ZisK splits an execution into segments proven by specialized state machines, aggregates the resulting proofs recursively into a single \emph{VADCOP-final} \ac{STARK}, and, for on-chain verification, wraps that proof in a PlonK proof over BN254. The PlonK verifier takes a single public input, the SHA-256 digest of the program key, the public values, and the root of the VADCOP-final setup, \rootc, so one deployed verifier contract serves every program. \acp{STARK} are transparent and rely only on collision-resistant hashing; the PlonK wrapper is the only part of the sequencer's proof that depends on a structured reference string and on pairings over BN254.