arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
davinci-paper/v2/sections/appendix.tex
v2/sections/appendix.texRaw
  1% !TeX root = ../build/main.tex
  2%
  3% ============================================================================
  4% Appendix A (Cryptographic primitives).
  5% Standard schemes are cited rather than derived; only DAVINCI-specific detail
  6% is spelled out. Every \hlset anchor that the body \hlget's is preserved, so
  7% no hyperlink dangles.
  8% ============================================================================
  9
 10In this section, we present the cryptographic primitives used in the protocol described in Section~\ref{sec:vocdoni-protocol}. We first introduce elliptic curves as the underlying algebraic setting, and then describe the following building blocks, each tied to a specific role in the system: hash functions and Merkle trees for commitments to structured data; polynomial commitments for data availability; digital signatures for voter authentication; encryption schemes for ballot confidentiality; \ac{DKG} for decentralizing trust in the election keys; and zero-knowledge proofs (\acp{ZK-SNARK} and \acp{zkVM}) for verifiability of computations. Standard primitives are cited rather than re-derived; we spell out only the operations and instantiations specific to \davinci.
 11
 12\subsection{Elliptic curves}
 13\label{sec:cryptographic-primitives:elliptic-curves}
 14
 15\Davinci relies on multiple elliptic curves to ensure interoperability with Ethereum, compatibility with available cryptographic primitives, and efficient operations inside proofs. On the one hand, SECP256K1~\cite{brown2010sec} is used because Ethereum public keys are elements of this curve. As \Davinci assumes each voter holds a standard Ethereum address, cryptographic operations such as digital signatures and identity verification rely on SECP256K1 to match the Ethereum ecosystem. On the other hand, BN254~\cite{wood2014ethereum} is chosen because it is the curve supported by Ethereum's precompiled contracts for pairing-based proof verification, which makes it the optimal choice for verifying SNARK proofs on-chain with minimal gas cost; both the ballot proofs and the PlonK wrapper of the \ac{zkVM} proofs live on it. Then, BabyJubjub~\cite{belles2021twisted} is used as an inner curve for the encryption of ballots, since its base field is the scalar field of BN254 and its arithmetic is therefore native to the ballot circuit. Finally, BLS12-381 is the curve of the \ac{KZG} commitments that Ethereum uses for data blobs~\cite{eip4844}; \davinci only uses its scalar field, in which blob cells and evaluation points live. Below, we give the details of these curves.
 16
 17\paragraph{Parameters.}
 18
 19\begin{itemize}
 20	%
 21	\item[$\bullet$] $p = \tt{\hspace{0.04cm}0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f}$ (256-bit prime).
 22	\item[$\bullet$] $q = \tt{\hspace{0.01cm}0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141}$ (256-bit prime).
 23	%
 24	\item[$\bullet$] $r = \tt{0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47}$ (254-bit prime).
 25	\item[$\bullet$] $s = \tt{\hspace{0.03cm}0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001}$ (254-bit prime).
 26	\item[$\bullet$] $t = \tt{\hspace{0.07cm}0x60c89ce5c263405370a08b6d0302b0bab3eedb83920ee0a677297dc392126f1}$ (251-bit prime).
 27	%
 28	\item[$\bullet$] $u = \tt{0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f624}$
 29	\item[] \hspace{0.53cm} $\tt{1eabfffeb153ffffb9feffffffffaaab}$ (381-bit prime).
 30	\item[$\bullet$] $v = \tt{0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001}$ (255-bit prime).
 31	%
 32\end{itemize}
 33
 34\paragraph{Elliptic curve groups.}
 35\begin{itemize}
 36	%
 37	\item SECP256K1 curve: $\SEC{E}/\F_p$ defined by equation $\SEC{E}: y^2 = x^3 + 7$, with group $\SEC{\G}$ of prime order $q$.
 38	%
 39	\item BN254 curve: $\BN{E}/\F_r$ defined by equation \( \BN{E}: y^2 = x^3 + 3\), with subgroups $\BN{\G}_1, \BN{\G}_2$ of prime order $s$, and an efficiently computable pairing \(e:\BN{\G}_1\times\BN{\G}_2 \rightarrow \BN{\G}_T,\) where $\BN{\G}_T \subset \F_{r^{12}}$ and has order $s$.
 40	\item BabyJubjub curve: $\BJ{E}/\F_s$ defined by the twisted Edwards equation $\BJ{E}: 168700 x^2 + y^2 = 1 + 168696 x^2y^2$, of order $8t$, with subgroup $\BJ{\G}$ of prime order $t$. Its identity is the point $(0, 1)$, and the inverse of $(x, y)$ is $(-x, y)$.
 41	%
 42	\item BLS12-381 curve: $\BLS{E}/\F_u$ defined by equation \(\BLS{E}: y^2 = x^3 + 4,\) with subgroups $\BLS{\G}_1, \BLS{\G}_2$ of prime order $v$, and an efficiently computable pairing \({e}:\BLS{\G}_1\times\BLS{\G}_2 \rightarrow \BLS{\G}_T,\) where $\BLS{\G}_T \subset \F_{u^{12}}$ and has order~$v$. In the body of the paper, we write $q_{\mathsf{BLS}} = v$.
 43	%
 44\end{itemize}
 45
 46\paragraph{Finite fields.}
 47\begin{itemize}
 48	%
 49	\item $\F_p$: base field of the SECP256K1 curve.
 50	\item $\F_q$: scalar field of $\SEC{\G}$.
 51	%
 52	\item $\F_r$: base field of the BN254 curve.
 53	\item $\F_s$: scalar field of $\BN{\G}_1, \BN{\G}_2, \BN{\G}_T$ and base field of the BabyJubjub curve. Ballot coordinates, Poseidon inputs and outputs, and census leaves are elements of $\F_s$.
 54	\item $\F_t$: scalar field of $\BJ{\G}$, to which election secret keys belong.
 55	%
 56	\item $\F_u$: base field of the BLS12-381 curve.
 57	\item $\F_v$: scalar field of $\BLS{\G}_1, \BLS{\G}_2, \BLS{\G}_T$, to which blob cells and evaluation points belong.
 58	%
 59\end{itemize}
 60
 61\paragraph{Generators.}\mbox{}\\
 62
 63\noi We denote by $\hlget{\SEC{G}}$ the generator of $\SEC{\G}$ as defined in~\cite{brown2010sec}, $\hlget{\BN{G}}$ the generator of $\BN{\G}_1$ as defined in~\cite{wood2014ethereum}, $\hlget{\BJ{G}}$ the generator of $\BJ{\G}$ as defined in~\cite{erc2494} (the point usually called \emph{Base8}), and $\hlget{\BLS{G}}$ the standard generator of $\BLS{\G}_1$~\cite{eip4844}.
 64
 65\begin{itemize}
 66	\item
 67	$
 68	\hlset{\SEC{G}} =
 69	(\tt{0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798,0x483ada7726} \allowbreak
 70	\rule{1.37cm}{0pt}
 71	\tt{a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8}).
 72	$
 73	\item
 74	$
 75	\hlset{\BN{G}}\hspace{0.14cm} = \: (\tt{0x01}, \tt{0x02}).
 76	$
 77
 78	\item
 79	$
 80	\hlset{\BJ{G}}\hspace{0.18cm} =
 81	\hspace{0.09cm} (\tt{0x0bb77a6ad63e739b4eacb2e09d6277c12ab8d8010534e0b62893f3f6bb957051},
 82	\tt{0x25797} \\
 83	\rule{1.37cm}{0pt}
 84	\tt{203f7a0b24925572e1cd16bf9edfce0051fb9e133774b3c257a872d7d8b}).
 85	$
 86	\item
 87	$
 88	\hlset{\BLS{G}}\hspace{0.07cm} =
 89	\hspace{0.06cm}(\tt{0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac} \\
 90	\rule{1.37cm}{0pt}
 91	\tt{586c55e83ff97a1aeffb3af00adb22c6bb, 0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5} \\
 92	\rule{1.37cm}{0pt}
 93	\tt{e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1}).
 94	$
 95\end{itemize}
 96
 97\subsection{Hash functions}
 98\label{sec:cryptographic-primitives:hash}
 99
100\Davinci uses three hash functions: Keccak256~\cite{bertoni2011keccak} for Ethereum compatibility, SHA-256~\cite{fips180-4} for the state tree and every hash computed by the \ac{zkVM} programs and verified by smart contracts, and Poseidon~\cite{grassi2021poseidon} for every hash computed by the ballot circuit.
101
102\paragraph{Keccak256.} Keccak256 is the standard hash function used by Ethereum and is employed in \davinci to compress messages for signing, to derive Ethereum addresses from public keys over $\SEC{\G}$, and to hash Ethereum block headers when the registry verifies blob transactions in L1-blob mode. It maps arbitrary-length bitstrings to 256-bit digests, $\hlset{\Keccak} : \{0,1\}^* \rightarrow \{0,1\}^{256}$. Inside the \ac{zkVM}, it is used only by the authentication and \ac{CSP} checks of the batch program (see Section~\ref{sec:vocdoni-protocol:circuits:batch}), where verifying Ethereum-compatible signatures requires reproducing the message hash computed by Ethereum clients.
103
104\paragraph{SHA-256.} SHA-256 maps arbitrary-length bitstrings to 256-bit digests, $\hlset{\Sha} : \{0,1\}^* \rightarrow \{0,1\}^{256}$. It is a precompile of the \ac{EVM} and an accelerated operation of the ZisK \ac{zkVM}, which makes it the natural choice for every value that is computed in a \ac{zkVM} program and checked by a contract: the nodes and leaves of the state tree, the digests of ballots, accumulators, and verification keys stored in it, the derivation of ballot slots, the chain of re-encryption scalars, the evaluation points of the blobs and the digest of their openings, the transcript of the batched ballot proof verification, and the digest of the public values of a \ac{zkVM} proof. When a digest must be interpreted as a field element, it is read as a big-endian integer and reduced modulo the field order, unless stated otherwise.
105
106\paragraph{Poseidon.} Poseidon is a SNARK-optimized hash function designed for efficient evaluation inside arithmetic circuits. It is used in \davinci for computing vote identifiers, the commitment to the ballot circuit's inputs, the per-field encryption randomness of a ballot, the nodes of the census tree, and the challenges of decryption proofs. We write $\hlset{\Poseidon} : \mathfrak{F}_s \rightarrow \F_s$, where $\mathfrak{F}_s$ denotes tuples of $\F_s$-elements of any length and $\F_s$ is the field described in Section~\ref{sec:cryptographic-primitives:elliptic-curves}. A single Poseidon permutation accepts at most 16 inputs, so longer tuples are hashed in two levels: the tuple is split into consecutive chunks of at most 16 elements, each chunk is hashed, and the chunk digests are hashed together. For a ballot of 16 fields, the commitment \ballotinputshash covers $71$ elements (the process identifier, the packed ballot mode, the two coordinates of the key, the address, the vote identifier, the $64$ coordinates of the ciphertexts, and the weight), so it is computed as
107\begin{align*}
108\ballotinputshash = \hlget{\Poseidon}\bigl(&\Poseidon(x_{1..16}), \Poseidon(x_{17..32}), \Poseidon(x_{33..48}),\\ &\Poseidon(x_{49..64}), \Poseidon(x_{65..71})\bigr).
109\end{align*}
110
111\subsection{Merkle trees}
112\label{sec:cryptographic-primitives:merkle-trees}
113
114\davinci uses two Merkle-tree variants as hash-based accumulators: a \emph{sparse Merkle tree} (SMT) for the election state, and a \emph{lean incremental Merkle tree} (IMT) for the census. Only the root of each tree is published on-chain, so that large datasets can be committed and verified with minimal on-chain storage.
115
116\paragraph{Sparse Merkle tree (state tree).} Following~\cite{baylina2019sparse}, the state tree is a binary tree of maximum depth $64$ in which each leaf encodes a key--value pair and empty subtrees are represented by a constant, supporting both inclusion and non-inclusion proofs. The key determines a unique root-to-leaf path independent of insertion order, which makes membership and emptiness checks cheap to verify inside a proof. As in the circomlib construction, a leaf is placed at the shallowest level at which its path is unique, and a transition is proven by the processor of~\cite{baylina2019sparse}, which checks the old root and computes the new one from the same list of siblings, for insertions, updates, and deletions. \davinci instantiates the tree with SHA-256, with leaf hash $\Sha(\kappa_{\text{LE8}} \conc v_{\text{LE32}} \conc \texttt{0x01})$ and node hash $\Sha(L \conc R)$, as implemented by the arbo library~\cite{arbo}. Its key space is partitioned into disjoint regions for configuration parameters, encrypted ballots, and vote identifiers (see Section~\ref{sec:vocdoni-protocol:state-tree}).
117
118\paragraph{Lean incremental Merkle tree (census tree).} The census is maintained as a lean \ac{IMT}~\cite{leanimt}, a binary tree optimized for sequential insertion: voters are appended at consecutive leaf positions rather than at key-derived paths, so the tree grows only as needed and appending a voter recomputes hashes along a single path. A node without a right sibling is promoted to the next level without hashing, so a proof contains only the non-empty siblings of the path. Each leaf stores a voter's identifier and weight; concretely, the Ethereum address and weight packed into a single field element (see Section~\ref{sec:vocdoni-protocol:census}). Nodes are hashed with two-input Poseidon over $\F_s$, and only the root $\censusroot$ is published on-chain. The batch program accepts proofs of at most 61 siblings.
119
120\paragraph{Tree operations.} To support state transitions and in-circuit verification, the trees expose the following operations. For the state tree $\stateTree$, indexed by keys $\kappa$:
121\begin{itemize}
122	\item $\stateTree.\hlset{\MTRoot}()$: returns the current Merkle root of the tree.
123	\item $\stateTree.\hlset{\MTInsert}(\kappa, v)$: stores the value $v$ under the key $\kappa$, which must be empty. A transition proof of an insertion shows that $\kappa$ was empty under the old root.
124	\item $\stateTree.\hlset{\MTUpdate}(\kappa, v)$: replaces the value stored under the existing key $\kappa$ with $v$. A transition proof of an update shows the replaced value under the old root.
125	\item $\stateTree.\hlset{\MTVerify}(v, \kappa, \MTProof, \root{})$: returns $\true$ if and only if $\MTProof$ shows that $v$ is stored under $\kappa$ in the tree with root $\root{}$.
126\end{itemize}
127For the census tree $\censusTree$, whose leaves are indexed by their position:
128\begin{itemize}
129	\item $\censusTree.\MTVerify(\leaf, \idx, \MTProof, \root{})$: returns $\true$ if and only if $\MTProof$ shows that $\leaf$ is stored at position $\idx$ in the tree with root $\root{}$. The position is carried by the proof; as discussed in Section~\ref{sec:background:mt}, it is not authenticated.
130\end{itemize}
131These operations let sequencers evolve the state off-chain while keeping every update independently verifiable on-chain and within \ac{ZK} proofs. Additional details on the tree structures and their leaf encodings are given in Sections~\ref{sec:vocdoni-protocol:census} and~\ref{sec:vocdoni-protocol:state-tree}.
132
133\subsection{Commitment scheme}
134\label{sec:cryptographic-primitives:commitments}
135
136\davinci commits to the data published in each Ethereum blob using the KZG polynomial commitment scheme~\cite{kate2010constant} over BLS12-381, the same scheme that underlies EIP-4844; it therefore reuses Ethereum's structured reference string rather than requiring a dedicated ceremony. A blob of $\ell = 4096$ cells $d_0, \dots, d_{\ell-1} \in \F_v$ defines the unique polynomial $P$ of degree less than $\ell$ with $P(\omega_i) = d_i$, where $\omega_i$ are the $\ell$-th roots of unity of $\F_v$ in bit-reversed order. Its value at a point $z$ outside the domain is given by the barycentric formula
137\[
138P(z) = \frac{z^\ell - 1}{\ell} \sum_{i=0}^{\ell-1} \frac{d_i\, \omega_i}{z - \omega_i},
139\]
140which the batch program evaluates with $O(\ell)$ multiplications and one batched inversion, without any pairing. The sequencer commits to $P$ and proves a single evaluation at a point derived from the commitment itself, which lets the registry check, with one call to the point-evaluation precompile, that the blob published on-chain is the one whose contents the batch program derived (see Section~\ref{sec:vocdoni-protocol:circuits:batch}). We use two operations:
141\begin{itemize}
142	\item $\hlset{\CCommit}(P)$: outputs a succinct commitment $C \in \BLS{\G}_1$ to the polynomial $P$, encoded in 48 bytes. Its \emph{versioned hash}, $\texttt{0x01} \conc \Sha(C)_{[1..32]}$, is what a blob-carrying transaction exposes.
143	\item $\hlset{\CVerify}(C, z, y, \pi)$: returns $\true$ if and only if $\pi$ is a valid proof that $P(z) = y$ for the polynomial committed in $C$.
144\end{itemize}
145Because the evaluation point is a hash of the commitment, the process identifier, and the old state root, a sequencer cannot choose the commitment after the point, and a commitment prepared for another election or another state does not open to the value the batch program computed. By the Schwartz--Zippel lemma, two distinct blobs agree at a random point with probability at most $\ell / v \approx 2^{-243}$.
146
147\subsection{Digital signature scheme}
148\label{sec:cryptographic-primitives:signatures}
149
150\Davinci uses the elliptic curve digital signature algorithm (ECDSA)~\cite{johnson2001ecdsa} over the SECP256K1 curve, so that voters authenticate with standard Ethereum wallets without managing additional keys. We use ECDSA in its standard form and refer to~\cite{johnson2001ecdsa} for the full algorithms; here we only fix the notation used throughout the protocol:
151\begin{itemize}
152	\item $\hlset{\SSign}_{\sk}(\msg)$: produces a signature $\sigma$ on message $\msg$ under the secret key $\sk$; in Ethereum's 65-byte format, $\sigma$ carries the two ECDSA scalars and a recovery identifier.
153	\item $\hlset{\SVer}_{\pk}(\msg, \sigma)$: returns $\true$ if $\sigma$ is a valid signature on $\msg$ under the public key $\pk$.
154	\item $\hlset{\SPubKey}(\msg, \sigma)$: recovers the signer's public key $\pk$ from a message and its signature; this is the operation Ethereum exposes as \texttt{ecrecover}.
155\end{itemize}
156An Ethereum address is derived from a public key as the low-order 20 bytes of its Keccak digest, $\address = \mathsf{low\text{-}20}\bigl(\hlget{\Keccak}(\pk)\bigr)$. Messages are signed in the Ethereum personal-message format: the signed digest of a message $\msg$ of $L$ bytes is $\Keccak(\texttt{"\textbackslash x19Ethereum Signed Message:\textbackslash n"} \conc L \conc \msg)$, with $L$ written in decimal. A voter signs the 32-byte message formed by 24 zero bytes followed by the 8-byte big-endian vote identifier, and a \ac{CSP} signs the 92-byte message of Eq.~\eqref{eq:csp-message}. Inside the \ac{zkVM}, signatures are verified by recovering the public key with a SECP256K1 precompile and comparing its address.
157
158\subsection{Encryption scheme}
159\label{sec:cryptographic-primitives:encryption}
160
161To preserve ballot secrecy while enabling tallying, \davinci employs a threshold variant of the ElGamal cryptosystem instantiated over the BabyJubjub curve~\cite{sutikno1998implementation}. This scheme offers two properties crucial for the protocol: \emph{additive homomorphism}, which allows the aggregation of encrypted votes without decryption, and \emph{re-encryption}, which enables ciphertext randomization without altering the underlying plaintext. Together, these properties allow sequencers to tally votes while making it harder for voters to produce receipts that could be used for coercion or vote selling. The corresponding public key is generated collectively by the \keywardens\ via the distributed key generation protocol of Section~\ref{sec:cryptographic-primitives:dkg}, ensuring that no single entity can decrypt ballots unilaterally, or, in the sequencer key mode, by a single sequencer.
162
163\paragraph{Encryption and decryption.}
164Given a message $m$ and randomness $k$, the ElGamal encryption algorithm maps $m$ into a group element $M$ of $\BJ{\G}$ and outputs a ciphertext as follows. In \davinci, $k$ is an element of $\F_s$ used as a scalar, which the group arithmetic implicitly reduces modulo $t$.
165%
166\begin{mdframed}
167	\begin{minipage}[t]{0.54\textwidth}
168		\begin{itemize}
169			\item[$\bullet$] $\hlset{\Enc}_{\pk}(m; k)$:
170			\begin{enumerate}
171				\item Map $m$ to $\BJ{\G}$ via $M = m \cdot \hlget{\BJ{G}}$.
172				\item Compute $C_1 = k \cdot \hlget{\BJ{G}} \in \BJ{\G}$.
173				\item Compute $C_2 = k \cdot \pk + M \in \BJ{\G}$.
174				\item Output $\enc = (C_1, C_2) \in {(\BJ{\G})}^2$.
175			\end{enumerate}
176		\end{itemize}
177	\end{minipage}
178	\begin{minipage}[t]{0.44\textwidth}
179		\begin{itemize}
180			\item[$\bullet$] $\hlset{\Dec}_{\sk}(\enc)$:
181			\begin{enumerate}
182				\item Parse $\enc = (C_1, C_2)$.
183				\item Compute $K = \sk \cdot C_1 \in \BJ{\G}$.
184				\item Output $M = C_2 - K$.
185			\end{enumerate}
186		\end{itemize}
187	\end{minipage}
188\end{mdframed}
189
190Since the plaintext message space is small, recovering $m$ from $M$ is efficient: although the mapping $m \mapsto M$ is not generally invertible, it can be reversed by brute-force search or optimized techniques such as baby-step giant-step~\cite{blake1995elliptic}, in time proportional to the square root of the bound on $m$. The registry bounds every tally by $10^{12} < 2^{40}$, so each field is recovered with about $2^{20}$ group operations.
191
192\paragraph{Homomorphic addition and re-encryption.} ElGamal encryption is additively homomorphic. Given two ciphertexts $(C_1, C_2)$ and $(C_1', C_2')$, their component-wise sum $(C_1 + C_1',\, C_2 + C_2')$ is a valid ciphertext that decrypts to the sum of the two underlying messages, which allows sequencers to aggregate encrypted ballots directly; adding the inverse of a ciphertext subtracts its message, which the batch program uses to remove overwritten ballots from the accumulator. Re-encryption exploits the same property by adding an encryption of zero to a ciphertext, yielding a fresh ciphertext of the same message under new randomness and making it computationally infeasible to link the re-encrypted ballot with the original submission.
193
194\begin{mdframed}
195	\begin{minipage}[t]{0.50\textwidth}
196		\begin{itemize}
197			\item[$\bullet$] $\hlset{\EncAdd}_{\pk}(\enc \in {(\BJ{\G})}^2, \enc' \in {(\BJ{\G})}^2)$:
198			\begin{enumerate}
199				\item Parse $\enc = (C_1, C_2) \in {(\BJ{\G})}^2$.
200				\item Parse $\enc' = (C_1', C_2') \in {(\BJ{\G})}^2$.
201				\item Output $(C_1 + C_1', C_2 + C_2') \in {(\BJ{\G})}^2$.
202			\end{enumerate}
203		\end{itemize}
204	\end{minipage}
205	\begin{minipage}[t]{0.48\textwidth}
206		\begin{itemize}
207			\item[$\bullet$] $\hlset{\ReEnc}_{\pk}(\enc \in {(\BJ{\G})}^2; k)$: \vspace{0.1cm}
208			\begin{enumerate}
209				\item Parse $\enc = (C_1, C_2) \in {(\BJ{\G})}^2$.
210				\item Compute $\enc' = \hlget{\Enc}_{\pk}(0; k)$.
211				\item Output $\hlget{\EncAdd}_{\pk}(\enc, \enc')$.
212			\end{enumerate}
213		\end{itemize}
214	\end{minipage}
215\end{mdframed}
216
217In the protocol, re-encryption is applied not only to newly submitted ballots but also to ballots already stored in the state tree. By refreshing the randomness of both new and existing ciphertexts, sequencers make it hard for an outside observer to tell whether a ballot has been overwritten or merely re-randomized, which is the basis of silent revoting; Section~\ref{sec:analysis:security} discusses the conditions and limits of this protection. In the batch program, the randomness of each re-encryption is a scalar of the chain of Section~\ref{sec:vocdoni-protocol:circuits:batch}, a SHA-256 output reduced modulo $s$.
218
219\paragraph{Proof of correct decryption.} To publish a decryption without revealing the secret key, the key holder proves that the decrypted point is consistent with the public key using a Chaum--Pedersen proof of equality of discrete logarithms~\cite{chaum1992wallet}, made non-interactive with the Fiat--Shamir transform~\cite{fiat1986prove}. For a ciphertext $(C_1, C_2)$ and a claimed message $m$, let $D = C_2 - m \cdot \BJ{G}$; the statement is that $\log_{\BJ{G}} \pk = \log_{C_1} D$, which holds exactly when $m$ is the decryption of the ciphertext under $\sk$.
220\begin{mdframed}
221	\begin{minipage}[t]{0.52\textwidth}
222		\begin{itemize}
223			\item[$\bullet$] $\hlset{\CPProve}_{\sk}(\enc, m)$:
224			\begin{enumerate}
225				\item Sample $w \sample \F_t$.
226				\item Compute $A_1 = w \cdot \BJ{G}$, $A_2 = w \cdot C_1$.
227				\item Compute $e = \Poseidon(\hat{\pk}, \hat{\pk}, \hat{C_1}, \hat{D}, \hat{A_1}, \hat{A_2})$.
228				\item Output $\pi = (A_1, A_2, z = w + e \cdot \sk \bmod t)$.
229			\end{enumerate}
230		\end{itemize}
231	\end{minipage}
232	\begin{minipage}[t]{0.46\textwidth}
233		\begin{itemize}
234			\item[$\bullet$] $\hlset{\CPVerify}_{\pk}(\enc, m, \pi)$:
235			\begin{enumerate}
236				\item Recompute $D$ and $e$.
237				\item Check $z \cdot \BJ{G} = A_1 + e \cdot \pk$.
238				\item Check $z \cdot C_1 = A_2 + e \cdot D$.
239			\end{enumerate}
240		\end{itemize}
241	\end{minipage}
242\end{mdframed}
243The challenge is a single 12-input Poseidon permutation over the coordinates of the points, each hashed in the \emph{reduced} twisted Edwards form used by gnark, $\hat{P} = (-f \cdot x \bmod s,\ y)$ for $P = (x, y)$, with $f = 6360561867910373094066688120553762416144456282423235903351243436111059670888$; the public key appears twice, as in the reference implementation. The results program additionally requires all points to be on the curve and all coordinates and scalars to be canonical, so that each statement has a single encoding.
244
245\subsection{Distributed key generation scheme}
246\label{sec:cryptographic-primitives:dkg}
247
248To ensure that no single entity controls the decryption key, \davinci employs a \ac{DKG} protocol to jointly derive the threshold ElGamal encryption key pair used for ballot encryption. Participants who contribute to the ceremony are called \emph{\keywardens}. The outcome is a collective public key ($\epk$) that is published on-chain and used by voters to encrypt their ballots, while the corresponding private key is secret-shared among the \keywardens\ so that only a threshold $\theta$ out of $\nu$ of them can later collaborate to decrypt the tally. Our construction publishes encrypted dealings together with publicly verifiable \ac{ZK-SNARK} proofs of their correctness, so that the key-management smart contracts can verify each contribution without learning any of the underlying shares. We use the non-interactive distributed key generation protocol of~\cite{kampa2026dkg}, in which each dealer publishes a Feldman verifiable secret sharing~\cite{feldman1987practical} of its contribution, with every share encrypted to its recipient and a Groth16 proof that the dealing is consistent, and we refer the reader to that work for the full construction and its security analysis. The permissionless \ac{DKG} network deals sixteen independent keys per run, so that one run serves sixteen elections, and the invite-only council deals a single key per ceremony; both decrypt by collecting $\theta$ partial decryptions $D_i = \mathsf{sh}_i \cdot C_1$, each with a proof of consistency with the committed share $\mathsf{sh}_i$, and combining them by Lagrange interpolation in the exponent.
249
250\subsection{Zero-knowledge proof systems}
251\label{sec:cryptographic-primitives:zkp}
252
253Zero-knowledge proofs are the backbone of \davinci's integrity guarantees: voters prove that their encrypted ballots are well-formed and rule-compliant without revealing their choices, and sequencers prove that ballot verification, vote aggregation, and state transitions were carried out correctly.
254
255\paragraph{\acp{ZK-SNARK}.} For a circuit $\mathcal{C}$ with public inputs $\publicinputs$ and witness $\witness$, we write:
256\begin{itemize}
257	\item $\hlset{\PProve}(\mathcal{C}, \witness, \publicinputs)$: outputs a proof $\pi$ that the prover knows a witness satisfying $\mathcal{C}$ for the given public inputs, using the circuit's proving key.
258	\item $\hlset{\PVerify}(\pi, \publicinputs)$: returns $\true$ if and only if $\pi$ is valid for $\publicinputs$, using the circuit's verification key.
259\end{itemize}
260The ballot circuit uses the Groth16 proof system~\cite{groth2016size} over BN254, chosen for its constant-size proofs and cheap verification. A Groth16 proof $(A, B, C) \in \BN{\G}_1 \times \BN{\G}_2 \times \BN{\G}_1$ for public inputs $x$ is valid if $e(A, B) = e(\alpha, \beta) \cdot e(L_x, \gamma) \cdot e(C, \delta)$, where $\alpha, \beta, \gamma, \delta$ belong to the verification key and $L_x$ is a linear combination of its elements with coefficients $x$. The batch program verifies $n$ such proofs at once by checking a single random linear combination of their equations~\cite{bellare1998batch}, with 128-bit coefficients derived by hashing all the proofs and public inputs; for a fixed transcript, an invalid proof passes with probability at most $2^{-127}$.
261
262\paragraph{Zero-knowledge virtual machines.} For a guest program $\Prog$, compiled to RISC-V, and a private input $\witness$, we write:
263\begin{itemize}
264	\item $\hlset{\VMProve}(\Prog, \witness)$: executes $\Prog$ on $\witness$ and outputs the public values $\publicvalues$ it commits and a proof $\pi$ of the execution.
265	\item $\hlset{\VMVerify}(\programvk, \publicvalues, \pi)$: returns $\true$ if and only if $\pi$ proves that the program identified by \programvk, executed on some input, committed $\publicvalues$.
266\end{itemize}
267\Davinci uses the ZisK \ac{zkVM}~\cite{zisk}. The execution is proven with FRI-based \acp{STARK} over the Goldilocks field, aggregated recursively into a single VADCOP-final \ac{STARK}, and wrapped in a PlonK proof over BN254~\cite{gabizon2019plonk}, whose single public input is $\Sha(\programvk \conc \publicvalues \conc \rootc) \bmod s$. The program key \programvk is the root of a commitment to the compiled program, and \rootc identifies the setup of the VADCOP-final circuit. The \ac{STARK} part is a transparent, hash-based argument made non-interactive with the Fiat--Shamir transform, whose soundness is argued in the random oracle model, while the PlonK wrapper relies on a universal structured reference string and on the hardness of discrete logarithms in the BN254 groups. Further details on the programs are provided in Section~\ref{sec:vocdoni-protocol:circuits} and a summary of the instantiations can be found in Fig.~\ref{fig:circuits-flow}.