% !TeX root = ../build/main.tex In this section, we detail the cryptographic primitives used in Section~\ref{sec:vocdoni-protocol}. We briefly introduce elliptic curves, hash functions, Merkle trees, encryption schemes, and proof systems used in the protocol. We also specify at each step the concrete parameters with which each of the primitives is instantiated. %\paragraph{Notation.} Throughout the document, we use the following conventions. Given a set $S$, we denote sampling an element $x$ uniformly at random from $S$ by $x \sample S$. We denote all bitstrings of arbitrary length by $\{0,1\}^*$. %Any group $\G$ used is of a large prime order, and we assume that the discrete logarithm problem is hard in $\G$. If two elements are denoted by the same letter in upper and lower case, e.g. $a, A$, this often means that $A$ is a public key corresponding to the secret key $a$. %$\F_p$ denotes de finite field of order $p$, and $\F_p^* = \F_p/\{0\}$. \subsection{Elliptic curves} \label{sec:cryptographic-primitives:elliptic-curves} \Davinci relies on multiple elliptic curves to ensure interoperability with Ethereum, compatibility with available cryptographic primitives, and efficient in-circuit operations. On the one hand, SECP256K1~\cite{brown10sec} 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{jancar20bn256} is chosen because it is the curve supported by Ethereum's precompiled contracts for ZK proof verification, which makes it ideal for verifying SNARK proofs on-chain with minimal gas cost. Then, BabyJubjub~\cite{belles21twisted} is used as an inner curve for elliptic curve operations within arithmetic circuits. Finally, BLS12-377~\cite{bowe20zexe} and BW6-761~\cite{elhousni20optimized} are used to enable recursive proof composition. More specifically, BLS12-377 acts as the inner curve for constructing proofs, while BW6-761 serves as the outer curve that verifies those proofs within larger ZK-SNARK circuits. This pairing enables succinct verification and composability of ZK-SNARKs within other ZK-SNARKs, which we use for \davinci’s aggregation and state transition logic. Below, we give the details of these curves. \paragraph{Parameters.} \begin{itemize} % \item[$\bullet$] $p = \tt{\hspace{0.04cm}0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f}$ (256-bit prime). \item[$\bullet$] $q = \tt{\hspace{0.01cm}0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141}$ (256-bit prime). % \item[$\bullet$] $r = \tt{0x2523648240000001ba344d80000000086121000000000013a700000000000013}$ (254-bit prime). \item[$\bullet$] $s = \tt{\hspace{0.04cm}0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d}$ (254-bit prime). \item[$\bullet$] $t = \tt{\hspace{0.01cm}0x60c89ce5c263405370a08b6d0302b0bab3eedb83920ee0a677297dc392126f1}$ (251-bit prime). % \item[$\bullet$] $u = \tt{0x122e824fb83ce0ad187c94004faff3eb926186a81d14688528275ef8087be41707ba638e584e9190}$ \item[] \hspace{0.53cm} $\tt{3cebaff25b423048689c8ed12f9fd9071dcd3dc73ebff2e98a116c25667a8f8160cf8aeeaf0a437e69}$ \item[] \hspace{0.53cm} $\tt{13e6870000082f49d00000000008b}$ (761-bit prime). \item[$\bullet$] $v = \tt{0x01ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d4430000000}$ \item[] \hspace{0.52cm} $\tt{8508c00000000001}$ (377-bit prime). \item[$\bullet$] $w = \tt{0x12ab655e9a2ca55660b44d1e5c37b00159aa76fed00000010a11800000000001}$ (253-bit prime). % \end{itemize} \paragraph{Elliptic curve groups.} \begin{itemize} % \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$. % \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_{s^{12}}$ and has order $s$. \item BabyJubjub curve: $\BJ{E}/\F_s$ defined by equation $\BJ{E}: 168700 x^2 + y^2 = 1 + 168696 x^2y^2$, with subgroup $\BJ{\G}$ of prime order $t$. % \item BW6-761 curve: $\BW{E}/\F_u$ defined by equation $\BW{E}: y^2 = x^3 - 1$, with subgroups $\BW{\G}_1, \BW{\G}_2$ of prime order $v$, and an efficiently computable pairing \({e}:\BW{\G}_1\times\BW{\G}_2 \rightarrow \BW{\G}_T,\) where $\BW{\G}_T \subset \F_{v^{6}}$ and has order $v$ as well. \item BLS12-377 curve: $\BLS{E}/\F_v$ defined by equation \(\BLS{E}: y^2 = x^3 + 1,\) with subgroups $\BLS{\G}_1, \BLS{\G}_2$ of prime order $w$, and an efficiently computable pairing \({e}:\BLS{\G}_1\times\BLS{\G}_2 \rightarrow \BLS{\G}_T,\) where $\BLS{\G}_T \subset \F_{w^{12}}$ and has order~$w$. % \end{itemize} \paragraph{Finite fields.} \begin{itemize} % \item $\F_p$: base field of the SECP256K1 curve. \item $\F_q$: scalar field of $\SEC{\G}$. % \item $\F_r$: base field of the BN254 curve. \item $\F_s$: scalar field of $\BN{\G}_1, \BN{\G}_2, \BN{\G}_T$ and base field of the BabyJubjub curve. \item $\F_t$: scalar field of $\BJ{\G}$. % \item $\F_u$: base field of the BW6-761 curve. \item $\F_v$: scalar field of $\BW{\G}_1, \BW{\G}_2, \BW{\G}_T$ and base field of the BLS12-377 curve. \item $\F_w$: scalar field of $\BLS{\G}_1, \BLS{\G}_2, \BLS{\G}_T$. % \end{itemize} \paragraph{Generators.}\mbox{}\\ \noi We denote by $\hlget{\SEC{G}}$ the generator of $\SEC{\G}$ as defined in~\cite{brown10sec}, $\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}, $\hlget{\BW{G}}$ the generator of $\BW{\G}_1$ as defined in~\cite{eip3026}, and $\hlget{\BLS{G}}$ the generator of $\BLS{\G}_1$ as defined in~\cite{eip2539}. \begin{itemize} \item $ \hlset{\SEC{G}} = (\tt{0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798,0x483ada7726} \allowbreak \rule{1.37cm}{0pt} \tt{a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8}). $ \item $ \hlset{\BN{G}}\hspace{0.14cm} = \: (\tt{0x01}, \tt{0x02}). $ \item $ \hlset{\BJ{G}}\hspace{0.18cm} = \hspace{0.09cm} (\tt{0x0b9feffffffffaaabfffffffffffffffeffffffffffffffffffffffffffffff}, \tt{0x17fffffffff} \\ \rule{1.37cm}{0pt} \tt{ffffffffffffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141}). $ \item $ \hlset{\BW{G}}\hspace{0.085cm} = \hspace{0.09cm} (\tt{0x1075b020ea190c8b277ce98a477beaee6a0cfb7551b27f0ee05c54b85f56fc779017ffac15520}\\ \rule{1.37cm}{0pt} \tt{ac11dbfcd294c2e746a17a54ce47729b905bd71fa0c9ea097103758f9a280ca27f6750dd0356133}\\ \rule{1.37cm}{0pt} \tt{e82055928aca6af603f4088f3af66e5b43d, 0x58b84e0a6fc574e6fd637b45cc2a420f952589884} \\ \rule{1.37cm}{0pt} \tt{c9ec61a7348d2a2e573a3265909f1af7e0dbac5b8fa1771b5b806cc685d31717a4c55be3fb90b6f} \\ \rule{1.37cm}{0pt} \tt{c2cdd49f9df141b3053253b2b08119cad0fb93ad1cb2be0b20d2a1bafc8f2db4e95363)}. $ \item $ \hlset{\BLS{G}}\hspace{0.07cm} = \hspace{0.06cm}(\tt{0x008848defe740a67c8fc6225bf87ff5485951e2caa9d41bb188282c8bd37cb5cd5481512ffcd3} \\ \rule{1.37cm}{0pt} \tt{94eeab9b16eb21be9ef,0x01914a69c5102eff1f674f5d30afeec4bd7fb348ca3e52d96d182ad44} \\ \rule{1.37cm}{0pt} \tt{fb82305c2fe3d3634a9591afd82de55559c8ea6}). $ \end{itemize} %\begin{itemize} % \item Generator of $\SEC{\G}$ as defined in~\cite{}: % \begin{align*} % \hlset{\SEC{G}} = % (&\tt{0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798},\\ % &\tt{0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8}). % \end{align*} % % % \item Generator of $\BN{\G}_1$ as defined in~\cite{}: % %https://ethereum.github.io/yellowpaper/paper.pdf % \begin{align*} % \hlset{\BN{G}} = % (\tt{0x01}, \tt{0x02}). % \end{align*} % % (-1, 1) o bé (1, 2)? % % % \item Generator of $\BJ{\G}$ as defined in~\cite{}: % %https://eips.ethereum.org/EIPS/eip-2494 % \begin{align*} % \hlset{\BJ{G}} = % (&\tt{0x0b9feffffffffaaabfffffffffffffffeffffffffffffffffffffffffffffff},\\ % &\tt{0x17fffffffffffffffffffffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141}). % \end{align*} % % % \item Generator of $\BW{\G}_1$ as defined in~\cite{}: % %https://eips.ethereum.org/EIPS/eip-3026 % \begin{align*} % \hlset{\BW{G}} = % (&\tt{0x1075b020ea190c8b277ce98a477beaee6a0cfb7551b27f0ee05c54b85f56fc779017ffac15520ac11dbfcd294c2e746a17a54ce47729b905bd71fa0c9ea097103758f9a280ca27f6750dd0356133e82055928aca6af603f4088f3af66e5b43d},\\ % &\tt{0x58b84e0a6fc574e6fd637b45cc2a420f952589884c9ec61a7348d2a2e573a3265909f1af7e0dbac5b8fa1771b5b806cc685d31717a4c55be3fb90b6fc2cdd49f9df141b3053253b2b08119cad0fb93ad1cb2be0b20d2a1bafc8f2db4e95363}). % \end{align*} % % % \item Generator of $\BLS{\G}_1$ as defined in~\cite{}: % %https://eips.ethereum.org/EIPS/eip-2539 % \begin{align*} % \hlset{\BLS{G}} = % (&\tt{0x008848defe740a67c8fc6225bf87ff5485951e2caa9d41bb188282c8bd37cb5cd5481512ffcd394eeab9b16eb21be9ef},\\ % &\tt{0x01914a69c5102eff1f674f5d30afeec4bd7fb348ca3e52d96d182ad44fb82305c2fe3d3634a9591afd82de55559c8ea6}). % \end{align*} % % %\end{itemize} \pagebreak \subsection{Hash functions} \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{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}. {\color{blue} \paragraph{MiMC-7.} Finally, we use functions from the MiMC family. On the one side, MiMC-7 hash function $\hlset{\Mimc} : \F_p \rightarrow \F_p$, where $\F_p$ is the set of tuples of $\F_p$-elements of any length, and $\F_p$ is the field described in Section~\ref{sec:cryptographic-primitives:elliptic-curves}. This hash is used to hash the public inputs of the different circuits and verify the associated proofs more efficiently (see Section~\ref{sec:vocdoni-protocol:circuits} for further details). On the other side, $\hlset{\Multimimc}$. Different curves.} %MiMC-7~\cite{mimc} is another hash function optimized for zero-knowledge circuits, with extremely low multiplicative complexity. It is used in \davinci for hashing public inputs inside zkSNARKs, especially when generating a unique identifier for a vote (see Section~\ref{sec:vocdoni-protocol:circuits}). %We use the cubic S-box S(x)=x7S(x)=x7, and instantiate MiMC-7 over the same field FpFp​ as the SNARK circuit: %MiMC7:Fpt→Fp %MiMC7:Fpt​→Fp​ %This function is denoted Hash3Hash3 in our implementation. {\color{blue} For the sake of clarity, in our notation we admit anything as an input of the above hash functions, although it might not be parsed as a sequence of field elements. Any bitstring can be converted to a tuple of field elements, so this does not change the actual working of the hash computation. In this document, it is implied that the proper conversion happens before feeding the input into the actual hash function.} %\subsection{Commitment schemes} %\label{sec:cryptographic-primitives:commitments} %Pedersen commitment scheme~\cite{pedersen1991non}. \subsection{Encryption schemes} \label{sec:cryptographic-primitives:encryption} To preserve ballot secrecy while enabling tallying, \davinci employs a threshold variant of the ElGamal cryptosystem instantiated over the BabyJubjub curve~\cite{sutikno98implementation}. 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 preventing voters from producing receipts that could be used for coercion or vote selling. The corresponding public key is generated collectively by the sequencers via the distributed key generation protocol described in Section~\ref{sec:cryptographic-primitives:dkg}, ensuring that no single entity can decrypt ballots unilaterally. \paragraph{Encryption and decryption.} Given a message $m$, the ElGamal encryption algorithm maps it into a group element $M$ of $\BJ{\G}$ and outputs a ciphertext as follows: % \begin{mdframed} \begin{minipage}[t]{0.54\textwidth} \begin{itemize} \item[$\bullet$] $\hlset{\Enc}_{\pk}(m; k \in \F_t)$: \begin{enumerate} \item Map $m$ to $\BJ{\G}$ via $M = m \cdot \hlget{\BJ{G}}$. \item Compute $C_1 = k \cdot \hlget{\BJ{G}} \in \BJ{\G}$. \item Compute $C_2 = k \cdot \pk + M \in \BJ{\G}$. \item Output $\enc = (C_1, C_2) \in {(\BJ{\G})}^2$. \end{enumerate} \end{itemize} \end{minipage} \begin{minipage}[t]{0.44\textwidth} \begin{itemize} \item[$\bullet$] $\hlset{\Dec}_{\sk}(\enc)$: \begin{enumerate} \item Parse $\enc = (C_1, C_2)$. \item Compute $K = \sk \cdot C_1 \in \BJ{\G}$. \item Output $M = C_2 - K$. \end{enumerate} \end{itemize} \end{minipage} \end{mdframed} Since the plaintext message space is typically 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{blake95elliptic}.%Blake: section V.4. \paragraph{Homomorphic addition and reencryption.} ElGamal encryption is additively homomorphic. Given two ciphertexts $(C_1, C_2)$ and $(C_1', C_2')$, their component-wise addition yields another valid ciphertext $(C_1 + C_1',\, C_2 + C_2')$. The resulting ciphertext decrypts to the sum of the two underlying messages. This property allows sequencers to aggregate encrypted ballots directly. Moreover, to prevent linkability and ensure receipt-freeness, sequencers also re-randomize ciphertexts. Re-encryption exploits this property by adding to a ciphertext an encryption of zero. This operation yields a fresh ciphertext of the same message under new randomness, making it computationally infeasible to link the re-encrypted ballot with the original submission. \begin{mdframed} \begin{minipage}[t]{0.53\textwidth} \begin{itemize} \item[$\bullet$] $\hlset{\EncAdd}_{\pk}(\enc \in {(\BJ{\G})}^2, \enc' \in {(\BJ{\G})}^2)$: \begin{enumerate} \item Parse $\enc = (C_1, C_2) \in {(\BJ{\G})}^2$. \item Parse $\enc' = (C_1', C_2') \in {(\BJ{\G})}^2$. \item Output $(C_1 + C_1', C_2 + C_2') \in {(\BJ{\G})}^2$. \end{enumerate} \end{itemize} \end{minipage} \begin{minipage}[t]{0.45\textwidth} \begin{itemize} \item[$\bullet$] $\hlset{\ReEnc}_{\pk}(\enc \in {(\BJ{\G})}^2; k\in\F_t)$: \vspace{0.1cm} \begin{enumerate} \item Parse $\enc = (C_1, C_2) \in {(\BJ{\G})}^2$. \item Compute $\enc' = \hlget{\Enc}_{\pk}(0; k)$. \item Output $\hlget{\EncAdd}_{\pk}(\enc, \enc')$. % \item Compute $C_1' = k \cdot G + C_1 \in \J$. % \item Compute $C_2' = k \cdot \pk + C_2 \in \J$. % \item Output $\enc' = (C_1', C_2') \in \J^2$. \end{enumerate} \end{itemize} \end{minipage} \end{mdframed} In 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 ensure that it is indistinguishable whether a ballot has been overwritten or merely re-randomized. This mechanism is essential for guaranteeing receipt-freeness: voters cannot produce a verifiable receipt of their choice, and adversaries cannot detect or prove whether a particular vote has been replaced (see Section~\ref{sec:analysis}). \subsection{Digital signature schemes} \label{sec:cryptographic-primitives:signatures} \Davinci uses the {elliptic curve digital signature algorithm} (ECDSA)~\cite{johnson01ecdsa} over the SECP256K1 curve to ensure compatibility with standard Ethereum wallets. %, such as MetaMask~\ref{} or Ledger~\ref{}, % %\Davinci uses the elliptic curve digital signature algorithm (ECDSA)~\cite{johnson01ecdsa} over the SECP256K1 curve for user authentication and vote authorization. This decision is taken to ensure that \davinci is compatible with standard Ethereum wallets, such as MetaMask~\ref{} or Ledger~\ref{}, without requiring users to generate or manage additional cryptographic keys. % Verification of ECDSA signatures is performed inside zero-knowledge proofs using a specialized circuit that emulates SECP256K1 arithmetic. This approach is necessary because SECP256K1 is defined over a 256-bit prime field that differs from the native field used in the ZK-SNARK circuit (see Section\ref{sec:vocdoni-protocol:circuits} for more details). Below, we describe the algorithms, which follow the standard ECDSA protocol. % {\color{blue} (The output of the hash does not match -- check where variables live.)} \begin{mdframed} \begin{minipage}[t]{0.46\textwidth} \begin{itemize} \item[$\bullet$] $\hlset{\SSign}_{\sk}(\msg \in \{0,1\}^\star)$: \vspace{0.1cm} \begin{enumerate} \item Compute $h = \hlget{\Keccak}(\msg) \bmod q$. \item\label{item:ssign-step} Select a random scalar $k \sample \Z_q^{*}$. \item Compute $R = k \cdot \hlget{\SEC{G}} = (x_R, y_R) \in \SEC{\G}$. \item Set $r = x_R \bmod q$. \begin{itemize} \item If $r = 0$, go back to step~\ref{item:ssign-step}. \item Else, continue. \end{itemize} \item Compute $s = k^{-1} \cdot (h + r \cdot \sk) \bmod q.$ \begin{itemize} \item If $s = 0$, go back to step~\ref{item:ssign-step}. \item Else, continue. \end{itemize} \item Output $\sigma = (r, s)$. \end{enumerate} \end{itemize} \end{minipage} \begin{minipage}[t]{0.54\textwidth} \begin{itemize} \item[$\bullet$] $\hlset{\SVer}_{\pk}(\msg \in \{0,1\}^\star, \sigma = (r, s)\in(\Z_q^*)^2)$: %\vspace{0.1cm} \begin{enumerate} \item Check that $\pk \in \SEC{\G}$. \item Compute $h = \hlget{\Keccak}(\msg) \bmod q$. \item Compute $w = s^{-1} \bmod q$. \item Compute $u_1 = h \cdot w \bmod q$. \item Compute $u_2 = r \cdot w \bmod q$. \item Compute $$X = u_1 \cdot \hlget{\SEC{G}} + u_2 \cdot \pk = (x_X, y_X) \in \SEC{\G}.$$ \item Accept if $r = x_X \bmod q$; otherwise, reject. \end{enumerate} \end{itemize} \end{minipage} \end{mdframed} \subsection{Key generation schemes} \label{sec:cryptographic-primitives:dkg} To ensure that no single entity controls the decryption key, DAVINCI employs a distributed key generation (DKG) protocol to jointly derive the ElGamal encryption key pair used for ballots encryption~\cite{}. Sequencers who participate in the DKG ceremony are each identified by a unique index $i$. 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 sequencers. Only a threshold number $t$ out of $n$ sequencers can later collaborate to decrypt the tally. Unlike classical DKG protocols where shares are exchanged in the clear, our construction uses encrypted shares and ZK-SNARK proofs of correctness. This allows the Ethereum smart contract to verify compliance without learning any of the underlying secrets, ensuring both security and verifiability in a fully decentralized setting. {\color{blue} Let $t$ be the threshold parameter and $n$ the number of sequencers, with $t\leq n$. Let $G$ be a generator of the elliptic curve group of order $q$. Each participant $P_i$ runs the following procedure. \begin{mdframed} \begin{itemize} {\color{blue} \item[$\bullet$] $\hlset{\GenerateEncryptedShares}(i)$: \begin{enumerate} \item Select random scalars $a_{i,0},\dots,a_{i,t-1} \sample \Z_q$. \item Define the polynomial $f_i(x) = \sum_{j=0}^{t-1} a_{i,j} x^j$. \item For each $j \in \{0,\dots,t-1\}$, compute public commitments $C_{i,j} = a_{i,j}\cdot G$. \item For each sequencer $P_\ell$ with index $\ell \in \{1,\dots,n\}$, compute the secret share $s_{i,\ell} = f_i(\ell)$. \item Encrypt each $s_{i,\ell}$ under $P_\ell$'s public key using a simplified version of the EC integrated encryption scheme (ECIES), obtaining $EncECIES(s_{i,\ell})$. \item Output $\{C_{i,j}\}_{j=0}^{t-1}$ and $\{EncECIES(s_{i,\ell})\}_{\ell=1}^n$, together with a ZK-SNARK proof attesting that the encrypted values are consistent with the commitments. \end{enumerate} } \end{itemize} \end{mdframed} The smart contract verifies the encrypted shares. \begin{mdframed} \begin{itemize} {\color{blue} \item[$\bullet$] $\hlset{\VerifyEncryptedShare}(i, \ell, EncECIES(s_{i,\ell}), \{C_{i,j}\})$: \begin{enumerate} \item Verify that the ZK-SNARK proof attached to $EncECIES(s_{i,\ell})$ is correct. \item If the proof is valid, the share is accepted; otherwise, the participant $P_i$ may be slashed. \end{enumerate} } \end{itemize} \end{mdframed} After collecting valid encrypted shares, each sequencer $P_j$ can recover their secret share $s_j$ by decrypting all contributions addressed to them:} \begin{mdframed} \begin{itemize} {\color{blue} \item[$\bullet$] $\hlset{\DeriveSecretShare}(j)$: \begin{enumerate} \item Decrypt all $EncECIES(s_{i,j})$ values received from other participants. \item Compute $s_j = \sum_{i=1}^n s_{i,j} \mod q$. \item Output $s_j$. \end{enumerate} } \end{itemize} \end{mdframed} \begin{mdframed} \begin{itemize} {\color{blue} \item[$\bullet$] $\hlset{\DerivePublicKey}(\{C_{i,0}\}_{i=1}^n)$: \begin{enumerate} \item Compute $pk = \sum_{i=1}^n C_{i,0}$. \item Output $pk$. \end{enumerate} Note that $C_{i,0} = a_{i,0}\cdot G$, so the collective public key corresponds to $pk = s \cdot G$, where $s = \sum_{i=1}^n a_{i,0} \bmod q$ is the collective private key, unknown to any single participant. } \end{itemize} \end{mdframed} This approach ensures that the encryption public key is securely generated in a decentralized way, that each sequencer learns only their own secret share, and that the correctness of the entire DKG procedure is verifiable on-chain. Misbehavior, such as submitting invalid shares, can be detected and penalized through the slashing mechanism enforced by the smart contract (see Section~\ref{sec:token}). \subsection{Merkle trees} \label{sec:cryptographic-primitives:merkle-trees} The \davinci protocol uses sparse Merkle Trees (SMTs) as its primary data structure for maintaining off-chain state. Following the construction in~\cite{baylina19sparse}, these are full binary trees of fixed depth in which each leaf encodes a key-value pair and empty leaves are explicitly represented, allowing for both inclusion and non-inclusion proofs. A key property of SMTs is that the hash of each key determines a unique traversal path from the root to the leaf, regardless of insertion order. When inserting a new key, the tree descends until it encounters either an empty node or a leaf. In case of a path collision, the algorithm splits at the first differing bit, creating intermediate nodes accordingly. %SMTs support efficient membership and non‑membership proofs, enabling a party to prove that a given key-value is (or is not) present in the tree without revealing the content. In \davinci, SMTs are used to represent two core data structures: the census tree, which encodes the list of eligible voters along with their respective voting weights, and the state tree, which encodes the current status of submitted votes. Both trees have fixed depth 64. The census tree is instantiated with the MiMC hash function over the BLS12-377 scalar field, while the state tree uses Poseidon over the BN254 scalar field. Only the root hash of each tree is published on-chain, ensuring verifiability with minimal on-chain storage. % To support state transitions and circuit verification, each tree $\tree$ has the following functions associated: \begin{itemize} \item $\tree.\hlset{\MTRoot}()$: it returns the current Merkle root of the tree. \item $\tree.\hlset{\MTInsert}(path, \leaf)$: it inserts a new leaf $\leaf$ at the position defined by the given path. \item $\tree.\hlset{\MTUpdate}(\leaf_{old}, \leaf)$: it updates an existing leaf in the tree. \item $\tree.\hlset{\MTMembershipProof}(\leaf)$: it returns a Merkle proof of inclusion for the given leaf. \item $\tree.\hlset{\MTNonMembershipProof}(\leaf)$: it returns a proof that the given leaf is not included in the tree. \item $\tree.\hlset{\MTVerify}(\leaf, proof, root)$: it verifies that the given proof corresponds to the claimed root and leaf. \end{itemize} These functions are used by sequencers to construct proofs that certify the validity of state transitions. In particular, they allow for off-chain state evolution that is independently verifiable on-chain and within ZK circuits. Additional details on the structure of the census and state trees, as well as the encoding of their leaves, are provided in Section~\ref{sec:vocdoni-protocol:merkle-trees}. \subsection{Zero-knowledge proof systems} \label{sec:cryptographic-primitives:zkp} {Zero-knowledge succinct non-interactive arguments of knowledge (ZK-SNARKs)} are a crucial component in ensuring the integrity of the voting process. Voters generate ZK-SNARK proofs to demonstrate that their encrypted ballots comply with the rules and constraints defined by the election parameters, without revealing any information about their choices. Similarly, sequencers produce proofs to certify the correctness of vote aggregation and state transitions throughout the protocol. {\color{blue}\hlset{\PProve}(), \hlset{\PVerify}(proof, PI) -- pkey, vkey.} All ZK circuits in \davinci are compiled using the Groth16 proof system~\cite{groth2016size}, a widely adopted ZK-SNARK construction known for its succinctness, efficient verification, and minimal proof size. Although all circuits rely on the same proving system, they are instantiated with different elliptic curves depending on the cryptographic requirements of each phase. Specifically, the vote validity circuit is compiled over the BN254 curve, the census-related circuit uses BLS12-377, and the aggregation circuit is instantiated over BW6-761. Finally, the last circuit used by the sequencer—responsible for generating the final proof of correct tallying and result—is compiled over BN254 as well, since this is the proof that is verified on-chain by the smart contract using Ethereum’s native precompiles. Further details on the circuits are provided in Section~\ref{sec:vocdoni-protocol:circuits} and a summary of the instantiations can be found in Figure~\ref{fig:circuits-flow}.