arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
wip protocol-flow
bellesmarta belles.mm@gmail.com
Sun, 09 Nov 2025 11:57:25 +0100
commit

44474c350c6245a2a357583d9c62b99d3f3a4b1c

parent

f53bfe64888516759d5c111bfd7f6628f2a7440a

M v2/build/main.tex → v2/build/main.tex

@@ -50,7 +50,7 @@

{\color{blue}\fbox{\parbox{0.93\textwidth}{ \vspace{0.2cm} - +a \noi Pieces of text marked in \textbf{blue} are heavily work in progress. In addition, there are these general tasks: \begin{itemize} \item Change $(C_1, C_2)$ to \texttt{ciphertext} in protocol flow and figures.
M v2/build/preamble-macros.tex → v2/build/preamble-macros.tex

@@ -106,6 +106,13 @@

% Circuits \newcommand{\public}{{\sf\color{teal}public}\xspace} \newcommand{\private}{{\sf\color{red}private}\xspace} +\newcommand{\circuitstyle}[1]{{\sf{#1}}\xspace} +\newcommand{\ballotcircuit}{\circuitstyle{BallotCircuit}} +\newcommand{\verifiercircuit}{\circuitstyle{VerifierCircuit}} +\newcommand{\aggregationcircuit}{\circuitstyle{AggregationCircuit}} +\newcommand{\statetransitioncircuit}{\circuitstyle{StateTransitionCircuit}} +\newcommand{\publicinputs}{\circuitstyle{PI}} +\newcommand{\witness}{\circuitstyle{witness}} % Roles \definecolor{voterbg}{RGB}{200, 230, 200} % soft, muted green

@@ -187,6 +194,13 @@ \newcommand{\dkgmanagement}{\smartcontractstyle{KeyManagement}}

\newcommand{\statetransitionverifier}{\smartcontractstyle{StateTransitionVerifier}} \newcommand{\resultsverifier}{\smartcontractstyle{ResultsVerifier}} +% Blobs +\newcommand{\blobstyle}[1]{{\sf{#1}}\xspace} +\newcommand{\blobdata}{\blobstyle{blobData}} +\newcommand{\blobcom}{\blobstyle{blobCommitment}} +\newcommand{\evalpoint}{\blobstyle{evalPoint}} +\newcommand{\openproof}{\blobstyle{openingProof}} + % Cryptographic primitives \newcommand{\methodstyle}[1]{{\sf{#1}}\xspace} \newcommand{\Keccak}{\methodstyle{Hash_1}}

@@ -199,6 +213,15 @@ \newcommand{\EncAdd}{\methodstyle{EncAdd}}

\newcommand{\ReEnc}{\methodstyle{ReEnc}} \newcommand{\SSign}{\methodstyle{S.Sign}} \newcommand{\SVer}{\methodstyle{S.Verify}} +\newcommand{\SPubKey}{\methodstyle{S.ExtractPublicKey}} +\newcommand{\CCommit}{\methodstyle{C.Commit}} +\newcommand{\CSetup}{\methodstyle{C.Setup}} +\newcommand{\COpen}{\methodstyle{C.Open}} +\newcommand{\CVerifyPoly}{\methodstyle{C.VerifyPoly}} +\newcommand{\CCreateWitness}{\methodstyle{C.CreateWitness}} +\newcommand{\CVerifyEval}{\methodstyle{C.VerifyEval}} +\newcommand{\CProve}{\methodstyle{C.Prove}} +\newcommand{\CVerify}{\methodstyle{C.Verify}} \newcommand{\PProve}{\methodstyle{P.Prove}} \newcommand{\PVerify}{\methodstyle{P.Verify}} \newcommand{\GenerateShares}{\methodstyle{GenerateShares}}
M v2/sections/ballot-protocol.tex → v2/sections/ballot-protocol.tex

@@ -32,7 +32,7 @@ \label{fig:ballot-variables}

\end{figure} \vspace{-1cm} -\paragraph{(Ballot mode) circuit constraints.} Given a ballot with $n$ fields and each field filled with a value $v_i$ for $i = 1, \dots, n$, we enforce the following constraints (captured in Figure~\ref{fig:ballot-variables}): +\paragraph{Definition of constraints.} Given a ballot with $n$ fields and each field filled with a value $v_i$ for $i = 1, \dots, n$, we enforce the following constraints (captured in Figure~\ref{fig:ballot-variables}): \begin{itemize} \item $\numfields = n$,
M v2/sections/circuits.tex → v2/sections/circuits.tex

@@ -16,7 +16,7 @@

\subsubsection{Ballot circuit} \label{sec:vocdoni-protocol:circuits:ballot} -The ballot circuit, illustrated in Figure~\ref{fig:circuit-ballot}, is generated locally by the voter at the time of casting a ballot. Its purpose is twofold: first, to prove that the encrypted ballot is valid and complies with the protocol rules defined by the organizer; and second, to prove that the vote identifier (\voteid) has been correctly derived. The correctness of this circuit is attested by a \ac{ZK} proof generated using the \ac{ZK-SNARK} protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BN254 curve. We call the resulting proof \textit{ballot proof} and denote it as $\hlset{\ballotproof}$. We detail below the inputs and constraints of the ballot circuit. +The ballot circuit (\hlset{\ballotcircuit}), illustrated in Figure~\ref{fig:circuit-ballot}, is generated locally by the voter at the time of casting a ballot. Its purpose is twofold: first, to prove that the encrypted ballot is valid and complies with the protocol rules defined by the organizer; and second, to prove that the vote identifier (\voteid) has been correctly derived. The correctness of this circuit is attested by a \ac{ZK} proof generated using the \ac{ZK-SNARK} protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BN254 curve. We call the resulting proof \textit{ballot proof} and denote it as $\hlset{\ballotproof}$. We detail below the inputs and constraints of the ballot circuit. \begin{spacing}{1.25} \vspace{0.3cm}

@@ -53,7 +53,7 @@

\subsubsection{Verifier circuit} \label{sec:vocdoni-protocol:circuits:verifier} -The verifier circuit, illustrated in Figure~\ref{fig:circuit-verifier}, is generated by the sequencer when processing a vote. This circuit verifies the ballot's proof generated by the voter and it also validates the voter’s eligibility in the census and the correctness of their digital signature. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BLS12-377 curve. We call the resulting proof the \textit{authentication proof} and denote it as $\hlset{\authenticationproof}$. We detail below the inputs and constraints of this circuit. {\color{blue}-- Authentication of verification proof?} +The verifier circuit (\hlset{\verifiercircuit}), illustrated in Figure~\ref{fig:circuit-verifier}, is generated by the sequencer when processing a vote. This circuit verifies the ballot's proof generated by the voter and it also validates the voter’s eligibility in the census and the correctness of their digital signature. The correctness of this circuit is attested by a ZK proof generated using the ZK-SNARK protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BLS12-377 curve. We call the resulting proof the \textit{authentication proof} and denote it as $\hlset{\authenticationproof}$. We detail below the inputs and constraints of this circuit. {\color{blue}-- Authentication of verification proof?} \begin{spacing}{1.25} \vspace{0.3cm}

@@ -95,7 +95,7 @@

\subsubsection{Aggregation circuit} \label{sec:vocdoni-protocol:circuits:aggregation} -The aggregation circuit, illustrated in Figure~\ref{fig:circuit-aggregate}, is generated by the sequencer to combine multiple authenticated votes into a single proof. Its purpose is to reduce verification overhead by recursively aggregating individual authentication proofs, while ensuring that all aggregated votes belong to the same election. The batch size, i.e., the maximum number of proofs aggregated in a single execution, is a fixed parameter (currently set to 60). If fewer proofs are available, the sequencer pads the batch with dummy proofs so that the circuit always operates on a fixed-size input. The correctness of this circuit is attested by a ZK proof generated using the \ac{ZK-SNARK} protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BW6-761 curve. We call the resulting proof the \textit{aggregation proof} and denote it as $\hlset{\aggregationproof}$. We detail below the inputs and constraints of the aggregation circuit. +The aggregation circuit (\hlset{\aggregationcircuit}), illustrated in Figure~\ref{fig:circuit-aggregate}, is generated by the sequencer to combine multiple authenticated votes into a single proof. Its purpose is to reduce verification overhead by recursively aggregating individual authentication proofs, while ensuring that all aggregated votes belong to the same election. The batch size, i.e., the maximum number of proofs aggregated in a single execution, is a fixed parameter (currently set to 60). If fewer proofs are available, the sequencer pads the batch with dummy proofs so that the circuit always operates on a fixed-size input. The correctness of this circuit is attested by a ZK proof generated using the \ac{ZK-SNARK} protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BW6-761 curve. We call the resulting proof the \textit{aggregation proof} and denote it as $\hlset{\aggregationproof}$. We detail below the inputs and constraints of the aggregation circuit. \begin{spacing}{1.25} \vspace{0.3cm}

@@ -131,7 +131,7 @@

\subsubsection{State transition circuit} \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 election. Its purpose is to verify that a batch of aggregated votes has been correctly incorporated into the state Merkle tree, that overwrites and vote identifiers are handled consistently, and that the accumulators of encrypted results are updated accordingly. The correctness of this circuit is attested by a \ac{ZK} proof generated using the \ac{ZK-SNARK} protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BN254 curve, which is supported by Ethereum’s native precompiles for proof verification. We call the resulting proof the \textit{state proof} and denote it as $\hlset{\stateproof}$. This proof is submitted on-chain and verified by the process management smart contract, ensuring that every accepted state transition complies with the protocol rules. +The state transition circuit (\hlset{\statetransitioncircuit}), illustrated in Figure~\ref{fig:circuit-state-transition-v2}, is generated by the sequencer to update the global state of the election. Its purpose is to verify that a batch of aggregated votes has been correctly incorporated into the state Merkle tree, that overwrites and vote identifiers are handled consistently, and that the accumulators of encrypted results are updated accordingly. The correctness of this circuit is attested by a \ac{ZK} proof generated using the \ac{ZK-SNARK} protocol described in Section~\ref{sec:cryptographic-primitives:zkp}, instantiated over the BN254 curve, which is supported by Ethereum’s native precompiles for proof verification. We call the resulting proof the \textit{state proof} and denote it as $\hlset{\stateproof}$. This proof is submitted on-chain and verified by the process management smart contract, ensuring that every accepted state transition complies with the protocol rules. To formalize the setting, let the sequencer collect a batch of $N$ votes ($N<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.

@@ -146,7 +146,7 @@ \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. + \item \public $\blobcomm$: {\color{blue}commitment to the data blob}. \end{itemize} \textbf{Private inputs} \begin{itemize}
M v2/sections/cryptographic-primitives.tex → v2/sections/cryptographic-primitives.tex

@@ -204,10 +204,18 @@ \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{Commitments} +\label{sec:cryptographic-primitives:commitments} + +{\color{blue} Description of KZG~\cite{kate2010constant} with SRS, $\hlset{\CCommit}()$, and $\hlset{\CVerify}()$.}\\ +Original methods: \hlset{\CSetup}, \hlset{\COpen}, \hlset{\CVerifyPoly}, \hlset{\CCreateWitness}, \hlset{\CVerifyEval}, \hlset{\CProve}, \hlset{\CVerify}. + \subsection{Digital signature schemes} \label{sec:cryptographic-primitives:signatures} -\Davinci uses the {elliptic curve digital signature algorithm} (ECDSA)~\cite{johnson2001ecdsa} over the SECP256K1 curve to ensure compatibility with standard Ethereum wallets. %, such as MetaMask~\ref{} or Ledger~\ref{}, +{\color{blue}{\textbf{TODO}: add algorithm \hlset{\SPubKey} that extracts $\pk$ from $\signature$.}}\\ + +\noi \Davinci uses the {elliptic curve digital signature algorithm} (ECDSA)~\cite{johnson2001ecdsa} 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. %
M v2/sections/protocol-flow.tex → v2/sections/protocol-flow.tex

@@ -9,12 +9,10 @@ In this phase, sequencers register and the organizer sets the election up.\\

\rogeri{I'd put this outside of the "voting process". I think adding a section "System setup and operation"-like before this one and rename this one as "voting process flow" (or simply "voting process") could ease the explanation.} -\martai{This section is outdated. Sequencers do not register, and we should remove the colours and boxes.} - -\noi \sequencers -Sequencers must first register in the sequencer registry smart contract, a process that remains open continuously. Registration involves publishing their identity, network endpoint (e.g., URI), and a collateral deposit to ensure honest participation. The collateral can later be slashed in case of misbehavior. \\ +%\noi \sequencers +%Sequencers must first register in the sequencer registry smart contract, a process that remains open continuously. Registration involves publishing their identity, network endpoint (e.g., URI), and a collateral deposit to ensure honest participation. The collateral can later be slashed in case of misbehavior. \\ -\noi \organizer For each new election, the organizer performs the following steps: +\noi For each new election, the organizer performs the following steps: \begin{enumerate} \item Prepare the census data \censusdata\ and generate the census Merkle tree $\censusTree$ with that data. \item Compute the census commitment $\censusroot = \censusTree.\hlget{\MTRoot}()$.

@@ -23,7 +21,7 @@ \item Define the election details, including duration, options, and the ballot rules $\ballotmode$ (see Section~\ref{sec:ballot-protocol}).

\item Compute a unique process identifier $\processid$, which is a 32-byte number derived from the organizer’s Ethereum address, nonce, and the chain ID. \item Set security parameters for the %forthcoming DKG ceremony (e.g., timeout, minimum number of sequencers). - \item Submit all this information in a transaction to the process management smart contract {\color{blue}(pay tx fees)}: + \item Submit all this information in a transaction to the \hlget{\electionregistry} smart contract {\color{blue}(pay tx fees)}: \[ tx_{org} = (\censusroot, ballotCommitment, \ballotmode, electionMetadata, \processid, dkgParameters).\] \end{enumerate}

@@ -58,8 +56,14 @@ \begin{equation}

\label{eq-voteid} \voteid = \hlget{\Multimimc}(\processid \conc \address \conc k). \end{equation} - \item Use the ballot circuit (Section~\ref{sec:vocdoni-protocol:circuits:ballot}) to generate a ZK-SNARK proof to prove that Eqs.~\labelcref{eq-ciphertext,eq-voteid} are correctly computed and that $\ballot$ satisfies ballot protocol rules according to $\ballotmode$: - \[ {\color{blue}\voteproof = \text{\hlget{Prove}(Circuit, PI = ())}.}\] + \item Use the \ballotcircuit from Section~\ref{sec:vocdoni-protocol:circuits:ballot} to generate a ZK-SNARK proof to prove that Eqs.~\labelcref{eq-ciphertext,eq-voteid} are correctly computed and that $\ballot$ satisfies ballot protocol rules according to $\ballotmode$: + \begin{align*} + \voteproof = & \hlget{\PProve}( + \hlget{\ballotcircuit}, + \witness = (\ballot, k), + \publicinputs = (\processid, \ballotmode,\\ + &\epk, \address, \weight, (C_1, C_2), \voteid)). + \end{align*} \item Sign the vote identifier with their Ethereum secret key to authenticate the vote and ensure that was cast by a legitimate voter: \[ \signature = \hlget{\SSign}_{\sk}(\voteid).\] \item Submits the package

@@ -75,22 +79,66 @@

\noi \textbf{(b) Vote batching.} 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} - \item the validity of the voter’s zkSNARK proof, - \item correct accumulation of encrypted votes via ElGamal’s homomorphic properties, - \item eligibility of voters (via census Merkle proofs), - \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 Retrieve election identifier $\processid$, current state root $\stateroot$, and census root $\censusroot$ from the \hlget{\electionregistry} smart contract and the associated data from the Ethereum data blobs. + \item Upon receiving a vote + \[\vote_i = [\processid, \voteid, \encryptedballot, \censusproof, \voteproof, \signature],\] + extract the voter's public key $\pk_i = \hlget{\SPubKey}(\signature)$. + \item For each $\vote_i$ received, use \verifiercircuit from Section~\ref{sec:vocdoni-protocol:circuits:verifier} to generate a proof + \begin{align*} + \authenticationproof_i = & \hlget{\PProve}(\hlget{\verifiercircuit}, + \witness = (\ballotproof, \weight, \censusproof, \signature),\\ + & \publicinputs = (\processid, \ballotmode, \epk, (C_1, C_2), \voteid, \censusroot, \pk)). + \end{align*} + This proof ensures that the voter’s \voteproof, the \signature, and the \censusproof are all valid. + \item Batch a set of $n$ proofs $\{\authenticationproof_i\}_{i = 1}^n$ and batch verify them together using \aggregationcircuit from Section~\ref{sec:vocdoni-protocol:circuits:aggregation}: + \begin{align*} + \aggregationproof = &\hlget{\PProve}(\hlget{\aggregationcircuit}, + \witness = (\{\authenticationproof_i\}_{i = 1}^n),\\ + &\publicinputs = (\encryptedballot, \{\voteid_i\}_{i = 1}^n), + \{\pk_i\}_{i = 1}^n, + \processid, + \ballotmode,\\ + & + \epk, + \censusroot + ). + \end{align*} + This proof ensures that the public inputs corresponding to the global process parameters ($\processid$, $\ballotmode$, $\epk$, $\censusroot$) are correct and that all $\authenticationproof_i$ are valid. + + \item Prepare the state transition data that will be stored in an Ethereum blob: pack votes/results into a 4096-cell blob \blobdata. + \begin{itemize} + \item Compute data commitment $\blobcom = \hlget{\CCommit}(\blobdata)$. + \item Derive evaluation point $\evalpoint = \hlget{\Poseidon}(\processid, oldRoot, batchNum, nonce).$ + \item Prepare polynomial $P$ from $\blobdata$. + \item Evaluate $y = P(\evalpoint)$. + \item Generate opening proof $\openproof$ from $...$. + \item The following step (circuit) will prove that $y = P(\evalpoint)$. + \end{itemize} + + \item {\color{blue}Before doing state transitions, we need to prepare the data that will be stored on chain as a blob. Hence, collect xxxx, create commitment. In circuit (next step), we will prove that... .} + + \item Finally, prove that all transitions are correct .... with circuit from Section~\ref{sec:vocdoni-protocol:circuits:state-transition}. + consistency between data blobs and the on-chain state: + + \begin{align*} + \stateproof = \hlget{\PProve}(\hlget{\statetransitioncircuit}, + \witness = (), \publicinputs = (). + \end{align*} + + \item Verify each $\vote$ submission received by generating a state transition proof (see Section~\ref{sec:vocdoni-protocol:circuits:state-transition}), ensuring: + \begin{itemize} + \item correct accumulation of encrypted votes via ElGamal’s homomorphic properties, + \item eligibility of voters (via census Merkle proofs), + \item absence of double voting (or correct handling of overwrites via nullifiers), + \end{itemize} + \item Compute blob commitment TAL. \item Submit the updated state root to the smart contract, while the full data are stored in Ethereum blobs. - } \martai{If \stateroot changed, repeat last circuit.} \end{enumerate} Sequencers repeat this process until the voting deadline set by the organizer. + +Upon receiving a valid transaction, the \electionregistry smart contract does the following checks: \subsubsection{Decryption key generation} \label{sec:vocdoni-protocol:deckey-gen}