add description to circuits + several wip changes
@@ -97,8 +97,4 @@ \bibliography{\bib/bibtex}
% ---- Temporary section: circuit details ---- -\newpage -\section*{Temporary appendix} -\input{\secs/tmp} - \end{document}
@@ -84,6 +84,8 @@ \newcommand{\costexponent}{\ballotstyle{costExponent}}
% Voting protocol \newcommand{\variablestyle}[1]{\texttt{#1}\xspace} +\newcommand{\voteproof}{\variablestyle{voteProof}} +\newcommand{\ballot}{\variablestyle{ballot}} \newcommand{\vote}{\variablestyle{vote}} \newcommand{\processid}{\variablestyle{processID}} \newcommand{\censuspf}{\variablestyle{censusProof}}
@@ -4,10 +4,10 @@ <mxGraphModel dx="1106" dy="661" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="850" math="1" shadow="0">
<root> <mxCell id="0" /> <mxCell id="1" parent="0" /> - <mxCell id="EW1sCxBa3IzSmhOEwzda-1" value="" style="rounded=0;whiteSpace=wrap;html=1;fontFamily=Courier New;" parent="1" vertex="1"> + <mxCell id="PMw66SxgLmh4I68YJgfF-1" value="" style="rounded=0;whiteSpace=wrap;html=1;fontFamily=Courier New;" vertex="1" parent="1"> <mxGeometry x="130" y="60" width="890" height="400" as="geometry" /> </mxCell> - <mxCell id="EW1sCxBa3IzSmhOEwzda-2" value="" style="rounded=0;whiteSpace=wrap;html=1;fontFamily=Courier New;" parent="1" vertex="1"> + <mxCell id="PMw66SxgLmh4I68YJgfF-2" value="" style="rounded=0;whiteSpace=wrap;html=1;fontFamily=Courier New;" vertex="1" parent="1"> <mxGeometry x="160" y="140" width="840" height="230" as="geometry" /> </mxCell> <mxCell id="EW1sCxBa3IzSmhOEwzda-3" value="$$\text{Hash}(\text{address} || \text{processID} || s)$$" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;fontFamily=Courier New;fillColor=#ffe6cc;strokeColor=#d79b00;" parent="1" vertex="1">@@ -49,29 +49,35 @@ </mxCell>
<mxCell id="EW1sCxBa3IzSmhOEwzda-11" value="$$C$$" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;fillColor=#d5e8d4;strokeColor=#82b366;fontFamily=Courier New;" parent="1" vertex="1"> <mxGeometry x="270" y="390" width="60" height="40" as="geometry" /> </mxCell> - <mxCell id="EW1sCxBa3IzSmhOEwzda-12" value="$$\text{protocolRulesCompliance}(\text{ballotMode}, \text{ballot})$$" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;fillColor=#dae8fc;strokeColor=#6c8ebf;fontFamily=Courier New;" parent="1" vertex="1"> + <mxCell id="EW1sCxBa3IzSmhOEwzda-12" value="<div>\(\text{protocolRulesCompliance}(\text{ballotMode},\) \(\text{weight}, \text{ballot})\)</div>" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;fillColor=#dae8fc;strokeColor=#6c8ebf;fontFamily=Courier New;" parent="1" vertex="1"> <mxGeometry x="520" y="190" width="240" height="40" as="geometry" /> </mxCell> - <mxCell id="EW1sCxBa3IzSmhOEwzda-13" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.25;entryY=0;entryDx=0;entryDy=0;fontSize=11;fontFamily=Courier New;" parent="1" source="EW1sCxBa3IzSmhOEwzda-14" target="EW1sCxBa3IzSmhOEwzda-12" edge="1"> - <mxGeometry relative="1" as="geometry" /> + <mxCell id="JmkZ6XpYD7EDUKb-CYlK-2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="EW1sCxBa3IzSmhOEwzda-14"> + <mxGeometry relative="1" as="geometry"> + <mxPoint x="560" y="190" as="targetPoint" /> + </mxGeometry> </mxCell> <mxCell id="EW1sCxBa3IzSmhOEwzda-14" value="$$\text{ballotMode}$$" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;fillColor=#d5e8d4;strokeColor=#82b366;fontFamily=Courier New;" parent="1" vertex="1"> - <mxGeometry x="550" y="80" width="60" height="40" as="geometry" /> + <mxGeometry x="530" y="80" width="60" height="40" as="geometry" /> </mxCell> <mxCell id="EW1sCxBa3IzSmhOEwzda-15" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.165;entryY=-0.015;entryDx=0;entryDy=0;entryPerimeter=0;startArrow=oval;startFill=1;fontSize=11;fontFamily=Courier New;" parent="1" target="EW1sCxBa3IzSmhOEwzda-22" edge="1"> <mxGeometry relative="1" as="geometry"> - <mxPoint x="700" y="160" as="sourcePoint" /> + <mxPoint x="720" y="160" as="sourcePoint" /> <Array as="points"> - <mxPoint x="700" y="160" /> <mxPoint x="810" y="160" /> </Array> </mxGeometry> </mxCell> - <mxCell id="EW1sCxBa3IzSmhOEwzda-16" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.75;entryY=0;entryDx=0;entryDy=0;fontSize=11;fontFamily=Courier New;" parent="1" source="EW1sCxBa3IzSmhOEwzda-17" target="EW1sCxBa3IzSmhOEwzda-12" edge="1"> - <mxGeometry relative="1" as="geometry" /> + <mxCell id="EW1sCxBa3IzSmhOEwzda-16" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;fontSize=11;fontFamily=Courier New;" parent="1" source="EW1sCxBa3IzSmhOEwzda-17" edge="1"> + <mxGeometry relative="1" as="geometry"> + <mxPoint x="720" y="190" as="targetPoint" /> + <Array as="points"> + <mxPoint x="720" y="190" /> + </Array> + </mxGeometry> </mxCell> <mxCell id="EW1sCxBa3IzSmhOEwzda-17" value="$$\text{ballot}$$" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;fillColor=#f8cecc;strokeColor=#b85450;fontFamily=Courier New;" parent="1" vertex="1"> - <mxGeometry x="670" y="80" width="60" height="40" as="geometry" /> + <mxGeometry x="690" y="80" width="60" height="40" as="geometry" /> </mxCell> <mxCell id="EW1sCxBa3IzSmhOEwzda-18" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.445;entryY=0.014;entryDx=0;entryDy=0;entryPerimeter=0;fontSize=11;fontFamily=Courier New;" parent="1" source="EW1sCxBa3IzSmhOEwzda-19" target="EW1sCxBa3IzSmhOEwzda-22" edge="1"> <mxGeometry relative="1" as="geometry" />@@ -153,6 +159,12 @@ <mxGeometry x="637.51" y="384.24" width="20" height="212.8" as="geometry" />
</mxCell> <mxCell id="EW1sCxBa3IzSmhOEwzda-37" value="" style="strokeWidth=1;html=1;shape=mxgraph.flowchart.annotation_2;align=left;labelPosition=right;pointerEvents=1;rotation=-90;" parent="1" vertex="1"> <mxGeometry x="867.66" y="381.59" width="20" height="218.11" as="geometry" /> + </mxCell> + <mxCell id="JmkZ6XpYD7EDUKb-CYlK-3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="JmkZ6XpYD7EDUKb-CYlK-1" target="EW1sCxBa3IzSmhOEwzda-12"> + <mxGeometry relative="1" as="geometry" /> + </mxCell> + <mxCell id="JmkZ6XpYD7EDUKb-CYlK-1" value="$$\text{weight}$$" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;fillColor=#d5e8d4;strokeColor=#82b366;fontFamily=Courier New;" vertex="1" parent="1"> + <mxGeometry x="610" y="80" width="60" height="40" as="geometry" /> </mxCell> </root> </mxGraphModel>@@ -464,7 +476,7 @@ </mxCell>
<mxCell id="gPXCQdP4MjgRAV3BPEsE-1" value="" style="strokeWidth=1;html=1;shape=mxgraph.flowchart.annotation_2;align=left;labelPosition=right;pointerEvents=1;rotation=-90;" parent="4ZG6TFl4bt9_09IySAMJ-1" vertex="1"> <mxGeometry x="409.19" y="160" width="20" height="440" as="geometry" /> </mxCell> - <mxCell id="iyqm4_-RWh7QM2yxefPn-0" value="$$\text{true}$$" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;fillColor=#d5e8d4;strokeColor=#82b366;fontFamily=Courier New;" parent="4ZG6TFl4bt9_09IySAMJ-1" vertex="1"> + <mxCell id="iyqm4_-RWh7QM2yxefPn-0" value="$$\text{boolean}$$" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;fillColor=#d5e8d4;strokeColor=#82b366;fontFamily=Courier New;" parent="4ZG6TFl4bt9_09IySAMJ-1" vertex="1"> <mxGeometry x="520" y="300" width="120" height="40" as="geometry" /> </mxCell> </root>
@@ -86,6 +86,14 @@ \label{sec:analysis:implementation}
\martai{Link to repos, etc. + details such as circuits have been implemented using \texttt{circom}, this and that.} +\paragraph{Circuits.} +\begin{itemize} + \item Circuit 1: circom/snarkJS, $\sim 53.000$ constraints. + \item Circuit 2: gnark, $\sim 3.1$ million constraints. + \item Circuit 3: gnark, 40.000 $\times$ (number of votes) constraints. + \item Circuit 4: gnark, $\sim 4$ million constraints. +\end{itemize} + \subsection{Performance evaluation} \label{sec:analysis:performance-evaluation}
@@ -4,6 +4,8 @@ \martai{It is not clear what is the advantage of defining a protocol like this. Is it easy because it is easy to implement as an arithmetic circuit? Make the advantage clear.}
\martai{Yes. The advantage is that we can define many types of voting systems (or recounting) with just these few variables. Moreover, we avoid if-else statements, which makes it very convenient to implement in-circuit. More info here: \url{https://docs.vocdoni.io/architecture/data-schemes/ballot-protocol.html\#vocdoni-results-interpretation} (no multiple question supported).} +\martai{How is the voter's $\weight$ encoded as part of the ballot?} + The \davinci ballot protocol is a simple and efficient mechanism for casting and tallying votes in any type of election or collective decision-making process. Each voting process consists of one or several fields and voters are required to provide a response for each of these fields in their ballot. The responses in the ballot are represented as a sequence of natural numbers, each corresponding to the voter’s choice for the respective field. Results are accumulated into a single array. Each position in the array corresponds to the sum of all votes cast for that field across all voters.
@@ -1,89 +0,0 @@
-% !TeX root = ../build/main.tex - -\subsection{Voter circuit} - -Figure~\ref{fig:circuit-voter}. - -\begin{figure}[H] - \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-voter}} - \caption{Voter circuit. All public values are framed in green.} - \label{fig:circuit-voter} -\end{figure} - -\textbf{Inputs}: - -\begin{itemize} - \setlength\itemsep{1em} - \item \public $\processid$: process identifier. - \item \public $\ballotmode$: ballot protocol configuration. - \item \public $EPK$: encryption public key. - \item \public voter's weight. - \item \public $C$: commitment. - \item \public $N$: nullifier. - \item \public $(C_1, C_2)$: encrypted ballot. -% - \item \private $\address$: voter's address. - \item \private $ballot$: plaintext voter's voting choice. - \item \private $s$: blinder factor (secret). - \item \private $k$: random scalar. -\end{itemize} - - -\newpage -\subsection{Authentication circuit} - -Figure~\ref{fig:circuit-authentication}. - -\begin{figure}[H] - \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-authentication}} - \caption{Authentication circuit. All public values are framed in green.} - \label{fig:circuit-authentication} -\end{figure} - -\textbf{Inputs}: - -\begin{itemize} - \setlength\itemsep{1em} - \item \public $\text{voteProof}$: voter's proof. - \item \public $\processid$: process identifier. - \item \public $\ballotmode$: ballot protocol configuration. - \item \public $EPK$: encryption public key. - \item \public $(C_1, C_2)$: encrypted ballot. - \item \public $C$: commitment. - \item \public $N$: nullifier. - \item \public Voter's weight. - \item \public $\text{censusProof}$: census membership proof. - \item \public $\text{censusRoot}$: census Merkle tree root. - \item \public $pk$: voter's address. - \item \public $\signature$: voter's signature. -\end{itemize} - -\newpage -\subsubsection{Aggregation circuit} - -Figure~\ref{fig:circuit-aggregate}. - -\begin{figure}[h] - \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-aggregate}} - \caption{Aggregation circuit. All public values are framed in green.} - \label{fig:circuit-aggregate} -\end{figure} - -\textbf{Inputs}: - -\begin{itemize} - \setlength\itemsep{1em} - \item \public $\text{authenticationProof}$: set of authentication proofs. - \item \public $C_i$: set of commitments. - \item \public $N_i$: set of nullifiers. - \item \public $\address_i$: list of voters' addresses. - \item \public $(C_1, C_2)$: list of voters' encrypted ballots. - \item \public $\weight_i$: Voters' weights. - \item \public $\processid$: process identifier. - \item \public $EPK$: encryption public key. - \item \public $\ballotmode$: ballot protocol configuration. - \item \public $\text{censusRoot}$: census Merkle tree root. -\end{itemize} - -\newpage -\subsubsection{State transition circuit}
@@ -7,7 +7,7 @@ \label{sec:vocdoni-protocol:parties}
A voting process involves three types of participants: the organizer, the sequencer, and the voters. -\paragraph{Organizer.} The organizer is the entity reposnible for defining and setting up the voting process. Its key responsibilities include defining the voting parameters and gathering the census data. The organizer ensures that the election is structured correctly but does not participate in vote collection or tallying. +\paragraph{Organizer.} The organizer is the entity responsible for defining and setting up the voting process. Its key responsibilities include defining the voting parameters and gathering the census data. The organizer ensures that the election is structured correctly but does not participate in vote collection or tallying. \paragraph{Sequencer.} Sequencers are a set of decentralized parties that facilitate the voting process. On the one hand, they collaboratively generate a public encryption key that voters use to encrypt their votes. Then, during the voting phase, they receive and verify encrypted votes from voters and reencrypt votes to prevent coercion.@@ -122,7 +122,6 @@ \item \signature: the signature authenticates the vote and ensure that was cast by a legitimate voter. The voter signs necessary components using their private key, depending on the census configuration (e.g., ECDSA, EdDSA, RSA).
\[ \signature = \text{Sign(xxx)}. \] \end{itemize} - \subsection{Circuits} \label{sec:vocdoni-protocol:circuits}@@ -137,133 +136,164 @@
\martai{It's convenient to name the proof associated to each circuit: a proof for this circuit is called [...].\\ Answer: 1. ballotProof, 2. voteVerifier, 3. aggregator, 4. stateTransition.} -\subsubsection{Voter circuit} +\newpage +\subsubsection{Voter circuit} -Figure~\ref{fig:circuit-voter}. - -\martai{The vote's weight is missing -- what to do with it?} - -\paragraph{Description.} Generated by the user when casting a vote, this circuit proves that the encrypted ballot is valid (i.e. follows the protocol rules) and that the nullifier and commitment are correctly generated. +Figure~\ref{fig:circuit-voter} -- BN254.\\ -\begin{itemize} - \item Constraints: Approximately 53.000 - \item Curve: BN254 - \item Framework: Circom/SnarkJS - \item Actor: User -\end{itemize} +\noi Generated by the user when casting a vote, this circuit proves that the encrypted ballot is valid (i.e. follows the protocol rules) and that the nullifier and commitment are correctly generated. -\paragraph{Assertions.} - -\begin{itemize} - \item \emph{Rules compliance}: The ballots meets the ballot mode provided following the protocol rules. - \item \emph{Vote encryption}: The ballots encryption is correct. - \item \emph{Vote commitment + nullification}: The nullifier and commitments are correctly computed. -\end{itemize} - -\begin{figure}[h] - \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-voter}} +\begin{figure}[H] + \centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-voter}} \caption{Voter circuit. All public values are framed in green.} \label{fig:circuit-voter} \end{figure} - The voter generates a ZKP to prove the correctness of the ballot and encryption process: - -\begin{enumerate} - \item \textbf{Correctness of Encryption}: Ensures the ciphertext $(C_1, C_2)$ is correctly computed from the plaintext message $M$ and random scalar $k$. - \item \textbf{Compliance with Ballot Protocol Rules}: The plaintext vote adheres to the ballot protocol constraints, such as valid choices and allowed number of selections. - \item \textbf{Correct Computation of Commitment and Nullifier}: - \begin{itemize} - \item \textbf{Commitment}: $C = \text{Hash} (\text{Address} || ProcessId || s).$ - \item \textbf{Nullifier}: $N = \text{Hash}(\text{C} || s)$. - \item The voter knows the secret linking the commitment and nullifier. - \end{itemize} -\end{enumerate} - -\textbf{Inputs to the ZKP Circuit}: - -\begin{itemize} - \item \textbf{Public Inputs}: - \begin{itemize} - \item Encrypted Ballot $(C_1, C_2)$. - \item Ballot Protocol Configuration. - \item Encryption Parameters. - \item Voter's Weight - \item Commitment $C$. - \item Nullifier $N$. - \end{itemize} - \item \textbf{Private Inputs}: - \begin{itemize} - \item Plaintext Vote $m$. - \item Secret $s$. - \item Random Scalar $k$. - \item Voter's Address (used internally in the computation of $C$). - \end{itemize} -\end{itemize} +\begin{mdframed} + \begin{minipage}[H]{1\textwidth} + \begin{spacing}{1.25} + \vspace{0.3cm} + \begin{center}{VOTER CIRCUIT}\end{center} + \textbf{Public inputs} + \begin{itemize} + \item $\public$ $\processid$: voting process identifier. + \item $\public$ $\ballotmode$: ballot protocol configuration. + \item $\public$ $\epk$ ($EPK$): encryption public key. + \item $\public$ $\weight$: voter's weight. + \item $\public$ $C$: commitment. + \item $\public$ $N$: nullifier. + \item $\public$ $(C_1, C_2)$: encrypted ballot. + \end{itemize} + \textbf{Private inputs} + \begin{itemize} + \item \private $\address$: voter's address. + \item \private $\ballot$: plaintext voter's voting choice. + \item \private $s$: blinder factor (secret). + \item \private $k$: random scalar. + \end{itemize} + \textbf{Constraints} \\ \vspace{-0.4cm} + + \emph{Vote encryption}. + \begin{itemize} + \item Correct encryption of the ballot: $(C_1, C_2) = \hlget{\Enc}_{\epk}(\ballot, k).$ + \end{itemize} + \emph{Rules compliance}. + \begin{itemize} + \item The ballot meets the protocol rules (number of valid choices, etc.): $... + \weight$. + \end{itemize} + \emph{Vote commitment + nullification}. + \begin{itemize} + \item The commitment is correctly computed: $C = \text{Hash} (\address \conc \processid \conc s)$. + \item The nullifier is correctly computed: $N = \text{Hash}(C \conc s)$. + \item The voter knows the shared secret $s$. + \end{itemize} + \vspace{-0.3cm} + \end{spacing} + \end{minipage} +\end{mdframed} +\newpage \subsubsection{Authentication circuit} -Figure~\ref{fig:circuit-authentication}. +Figure~\ref{fig:circuit-authentication} -- BLS12-377.\\ -\paragraph{Description.} Generated by the sequencer, this circuit transforms the vote proof to the BLS12-377 curve for native recursion and validates the user's eligibility in the census, as well as their signature. +\noi Generated by the sequencer, this circuit transforms the vote proof to the BLS12-377 curve for native recursion and validates the user's eligibility in the census, as well as their signature. -\begin{itemize} - \item Constraints: Approximately 3.1 million - \item Curve: BLS12-377 - \item Framework: Gnark - \item Actor: Sequencer -\end{itemize} - -\paragraph{Assertions.} - -\begin{itemize} - \item \emph{Voter's proof verification}: The vote zkProof is valid for the inputs provided. - \item \emph{Authentication + non-malleability}: The signature of the inputs provided is valid for the public key of the voter. - \item \emph{Census membership}: The address derived from the user public key is part of the census, and verifies the census proof with the user weight provided. -\end{itemize} - -\begin{figure}[h] - \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-authentication}} +\begin{figure}[H] + \centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-authentication}} \caption{Authentication circuit. All public values are framed in green.} \label{fig:circuit-authentication} \end{figure} +\begin{mdframed} + \begin{minipage}[H]{1\textwidth} + \begin{spacing}{1.25} + \vspace{0.3cm} + \begin{center}{AUTHENTICATION CIRCUIT}\end{center} + \textbf{Public inputs} + \begin{itemize} + \item \public $\voteproof$: voter's proof. + \item \public $\processid$: process identifier. + \item \public $\ballotmode$: ballot protocol configuration. + \item \public $\epk$ ($EPK$): encryption public key. + \item \public $(C_1, C_2)$: encrypted ballot. + \item \public $C$: commitment. + \item \public $N$: nullifier. + \item \public $\weight$: voter's weight. + \item \public $\censuspf$: census membership proof. + \item \public $\censusroot$: census Merkle tree root. + \item \public $pk$: voter's address. + \item \public $\signature$: voter's signature. + \end{itemize} + \textbf{Constraints} \\ \vspace{-0.4cm} + + \emph{Voter's proof verification.} + \begin{itemize} + \item The vote zkProof is valid for the inputs provided: $P.Verify().$ + \end{itemize} + \emph{Authentication + non-malleability.} + \begin{itemize} + \item The signature of the inputs provided is valid for the public key of the voter. + \end{itemize} + \emph{Census membership.} + \begin{itemize} + \item The address derived from the user public key is part of the census, and verifies the census proof with the user weight provided. + \end{itemize} + \vspace{-0.3cm} + \end{spacing} + \end{minipage} +\end{mdframed} + +\newpage \subsubsection{Aggregation circuit} -Figure~\ref{fig:circuit-aggregate}. +Figure~\ref{fig:circuit-aggregate} -- BW6-761.\\ -\paragraph{Description.} This circuit accumulates multiple authenticated votes into a single proof. It also verifies that all accumulated votes belong to the same voting process. - -\begin{itemize} - \item Constraints: 40.000 $\times$ (number of votes) - \item Curve: BW6-761 - \item Framework: Gnark - \item Actor: Sequencer -\end{itemize} - -\paragraph{Assertions.} - -\begin{itemize} - \item \emph{Votes aggregation}: The accumulated zkProofs are valid. - \item \emph{Shared public inputs}: The ProcessId, CensusRoot, BallotMode and EPK is the same for all of them. -\end{itemize} +\noi This circuit accumulates multiple authenticated votes into a single proof. It also verifies that all accumulated votes belong to the same voting process. \begin{figure}[h] - \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-aggregate}} + \centerline{\includegraphics[width=450pt,draft=false]{\figs/circuit-aggregate}} \caption{Aggregation circuit. All public values are framed in green.} \label{fig:circuit-aggregate} \end{figure} - -\subsubsection{State transition circuit} +\begin{mdframed} + \begin{minipage}[H]{1\textwidth} + \begin{spacing}{1.25} + \vspace{0.3cm} + \begin{center}{AGGREGATION CIRCUIT}\end{center} + \textbf{Public inputs} + \begin{itemize} + \item \public $\text{authenticationProof}$: set of authentication proofs. + \item \public $C_i$: set of commitments. + \item \public $N_i$: set of nullifiers. + \item \public $\address_i$: list of voters' addresses. + \item \public $(C_1, C_2)$: list of voters' encrypted ballots. + \item \public $\weight_i$: Voters' weights. + \item \public $\processid$: process identifier. + \item \public $EPK$: encryption public key. + \item \public $\ballotmode$: ballot protocol configuration. + \item \public $\text{censusRoot}$: census Merkle tree root. + \end{itemize} + \textbf{Constraints} \\ \vspace{-0.4cm} + + \emph{Votes aggregation.} + \begin{itemize} + \item The accumulated zkProofs are valid. + \end{itemize} + \emph{Shared public inputs.} + \begin{itemize} + \item The ProcessId, CensusRoot, BallotMode and EPK is the same for all of them. + \end{itemize} + \vspace{-0.3cm} + \end{spacing} + \end{minipage} +\end{mdframed} -\paragraph{Description.} Given the aggregated votes proof, this circuit verifies the correct inclusion of all new votes into the process's state Merkle tree. It generates the final state transition proof that will be validated by the Ethereum smart contract. +\newpage +\subsubsection{State transition circuit} -- BN254. \\ -\begin{itemize} - \item Constraints: Approximately 4 million - \item Curve: BN254 - \item Framework: Gnark - \item Actor: Sequencer -\end{itemize} +\noi Given the aggregated votes proof, this circuit verifies the correct inclusion of all new votes into the process's state Merkle tree. It generates the final state transition proof that will be validated by the Ethereum smart contract. \paragraph{Assertions.}@@ -289,10 +319,10 @@
The chain of integrity is maintained through a combination of smart contract enforcement and strict zkSNARK circuit constraints. This ensures that each state transition is valid and builds upon the last accepted state without requiring additional mechanisms. \begin{itemize} - \item \textbf{Sequential State Roots}: Each state transition updates the Merkle tree from a previous root (`Root1`) to a new root (`Root2`) after processing a batch of votes. - \item \textbf{Smart Contract Enforcement}: The smart contract verifies that the `Root1` provided in the zkSNARK proof matches the last committed state root stored on-chain. This guarantees that all transitions are sequential and based on the latest accepted state. - \item \textbf{Proof Validation}: The smart contract uses the zkSNARK verification key to validate the submitted proof. A valid proof confirms that the transition from `Root1` to `Root2` adheres to all protocol rules enforced by the circuit. - \item \textbf{State Update}: Upon successful verification, the smart contract updates the stored state root hash to`Root2`, ensuring an immutable and continuous chain of states. + \item \textbf{Sequential state roots}: Each state transition updates the Merkle tree from a previous root (`Root1`) to a new root (`Root2`) after processing a batch of votes. + \item \textbf{Smart contract enforcement}: The smart contract verifies that the `Root1` provided in the zkSNARK proof matches the last committed state root stored on-chain. This guarantees that all transitions are sequential and based on the latest accepted state. + \item \textbf{Proof validation}: The smart contract uses the zkSNARK verification key to validate the submitted proof. A valid proof confirms that the transition from `Root1` to `Root2` adheres to all protocol rules enforced by the circuit. + \item \textbf{State update}: Upon successful verification, the smart contract updates the stored state root hash to`Root2`, ensuring an immutable and continuous chain of states. \end{itemize} \paragraph{State Transition}@@ -305,43 +335,52 @@ \fbox{
\includegraphics[scale = 0.12, draft = false]{\figs/state-transition.png}} \end{figure} -The circuit have the following inputs (the public ones are required to verify the proof). - -\begin{itemize} - \item \textbf{Public Inputs:} - \begin{itemize} - \item Previous State Root (Root1): The Merkle tree root before the state transition. - \item New State Root (Root2): The Merkle tree root after the state transition. - \item Blob Data Commitment (blobCommitment): The commitment to the data blob containing the new votes. - \end{itemize} - \item \textbf{Private Inputs:} - \begin{itemize} - \item Votes: The list of new votes being processed, including census proofs and authentication data. - \item Merkle Proofs of nullifier inclusion: Proofs that each voter nullifier is included in the census. - \item Merkle Proofs of results update: Proofs that the process results have been correctly updated. - \item Merkle Tree Update Witnesses: Necessary data (e.g., Merkle paths) to update the Merkle tree from Root1 to Root2. - \item Process Parameters: Retrieved from Root1 within the circuit. - \end{itemize} -\end{itemize} - \begin{figure}[H] \centering \fbox{ \includegraphics[scale = 0.3, draft = false]{\figs/circuit-inputs.png}} \end{figure} -The following constraints must be enforced by the circuit. +\begin{figure}[H] + \centerline{\includegraphics[width=400pt,draft=false]{\figs/circuit-state-transition}} + \caption{State transition circuit. All public values are framed in green.} + \label{fig:circuit-state-transition} +\end{figure} -\begin{itemize} - \item \textbf{Immutable Process Parameters}: Ensure that critical process parameters (such as `censusRoot` or `processId`) retrieved from `Root1` remain consistent and are not altered in the transition. - \item \textbf{Vote Validity}: Validate that each vote proof is correct. - \item \textbf{Voter Eligibility}: Confirm that each voter is included in the census by verifying Merkle proofs of inclusion against the `censusRoot` retrieved from `Root1`. - \item \textbf{Nullifier Non-Existence}: Ensure that the nullifier for each vote does not exist in the current state (`Root1`), preventing double voting. - \item \textbf{Nullifier Addition}: Correctly add each new nullifier to the state, resulting in `Root2`, updating the Merkle tree accordingly. - \item \textbf{Results Update}: Ensure that the voting results are accurately updated by adding the new votes to the previous results retrieved from `Root1`, so that `results2 = results1 + votes`. - \item \textbf{Blob Data Integrity}: Confirm that the data used in the circuit (votes, nullifiers) corresponds to the `blobCommitment` provided as a public input, ensuring that the votes processed are exactly those published in the data blob. - \item \textbf{State Transition Validity}: Ensure that the new state root (`Root2`) is correctly computed from `Root1` by applying the validated votes and updates to the Merkle tree. -\end{itemize} +\begin{mdframed} + \begin{minipage}[H]{1\textwidth} + \begin{spacing}{1.25} + \vspace{0.3cm} + \begin{center}{STATE TRANSITION CIRCUIT}\end{center} + \textbf{Public inputs} + \begin{itemize} + \item \public $root_{old}$: Merkle tree root before the state transition. + \item \public $root_{new}$: Meklre tree root after the state transition. + \item \public $blobCommitment$: the commitment to the data blob containing the new votes. + \end{itemize} + \item \textbf{Private inputs} + \begin{itemize} + \item \private Votes: The list of new votes being processed, including census proofs and authentication data. + \item \private Merkle Proofs of nullifier inclusion: Proofs that each voter nullifier is included in the census. + \item \private Merkle Proofs of results update: Proofs that the process results have been correctly updated. + \item \private Merkle Tree Update Witnesses: Necessary data (e.g., Merkle paths) to update the Merkle tree from Root1 to Root2. + \item \private Process Parameters: Retrieved from Root1 within the circuit. + \end{itemize} + \textbf{Constraints} \\ \vspace{-0.4cm} + \begin{itemize} + \item \textbf{Immutable process parameters}: Ensure that critical process parameters (such as `censusRoot` or `processId`) retrieved from `Root1` remain consistent and are not altered in the transition. + \item \textbf{Vote validity}: Validate that each vote proof is correct. + \item \textbf{Voter eligibility}: Confirm that each voter is included in the census by verifying Merkle proofs of inclusion against the `censusRoot` retrieved from `Root1`. + \item \textbf{Nullifier non-existence}: Ensure that the nullifier for each vote does not exist in the current state (`Root1`), preventing double voting. + \item \textbf{Nullifier addition}: Correctly add each new nullifier to the state, resulting in `Root2`, updating the Merkle tree accordingly. + \item \textbf{Results update}: Ensure that the voting results are accurately updated by adding the new votes to the previous results retrieved from `Root1`, so that `results2 = results1 + votes`. + \item \textbf{Blob data integrity}: Confirm that the data used in the circuit (votes, nullifiers) corresponds to the `blobCommitment` provided as a public input, ensuring that the votes processed are exactly those published in the data blob. + \item \textbf{State transition validity}: Ensure that the new state root (`Root2`) is correctly computed from `Root1` by applying the validated votes and updates to the Merkle tree. + \end{itemize} + \vspace{-0.3cm} + \end{spacing} + \end{minipage} +\end{mdframed} \subsection{Protocol flow} \label{sec:vocdoni-protocol:flow}