arnaucube
arnaucube/davinci-paperPublic Self-hosted repository
wip protocol desc
bellesmarta belles.mm@gmail.com
Sat, 12 Jul 2025 23:58:41 +0200
commit

bd255b7d04a2f91aa9d9de8d531a7f5f0d6708fc

parent

4be5521a9c6af9bf1f9ef47d45c593acb538d6c0

M v2/bibliography/bibtex.bib → v2/bibliography/bibtex.bib

@@ -453,16 +453,6 @@ url = {https://eips.ethereum.org/EIPS/eip-2494},

year = {January 2020} } -@article{wood2014ethereum, - title={Ethereum: A secure decentralised generalised transaction ledger}, - author={Wood, Gavin and others}, - journal={Ethereum project yellow paper}, - volume={151}, - number={2014}, - pages={1--32}, - year={2014} -} - @misc{eip3026, author = {Youssef El Housni and Michael Connor and Aurore Guillevic}, title = {{EIP-3026}: {BW6-761} curve operations [{DRAFT}], {E}thereum {I}mprovement {P}roposals, no. 3026, [Online serial]},

@@ -475,4 +465,11 @@ author = {Alex Vlasov and hujw77},

title = {{EIP-2539}: {BLS12-377} curve operations [{DRAFT}], {E}thereum {I}mprovement {P}roposals, no. 2539, [Online serial]}, url = {https://eips.ethereum.org/EIPS/eip-2539}, year = {February 2020} -}+} + +@misc{baylina19sparse, + author = {Jordi Baylina and Marta Bellés}, + title = {Sparse {M}erkle Trees}, + url = {https://docs.iden3.io/publications/pdfs/Merkle-Tree.pdf}, + year = {2019} +}
M v2/build/main.tex → v2/build/main.tex

@@ -29,7 +29,7 @@

% \freefootnote{\scriptsize{Authors are listed in alphabetical order (\url{https://www.ams.org/profession/leaders/CultureStatement04.pdf}).}} \end{abstract} -\martai{Separate the roles of the sequencers from key generators?} +\martai{Consider separating the roles of the sequencers from key generators.} \setcounter{tocdepth}{2} \makeatletter
M v2/build/preamble-macros.tex → v2/build/preamble-macros.tex

@@ -42,6 +42,14 @@ \hskip -\leftskip

\bfseries #1\hfil \hbox to\@pnumwidth{\hss #2}}\par} \makeatother +% Adds vertical space before and after \subsubsection headings and ensures body text starts on a new line +\makeatletter +\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% + {-18\p@ \@plus -4\p@ \@minus -4\p@}% % Before skip + {4\p@ \@plus 2\p@ \@minus 2\p@}% % After skip + {\normalfont\normalsize\bfseries}} % Font style +\makeatother + % Colours \definecolor{cred}{rgb}{1, 0.5, 0.5} \definecolor{cgreen}{rgb}{0.5, 1, 0.5}

@@ -70,9 +78,32 @@ \newcommand{\BN}[1]{\ensuremath{{#1}^{\text{\tiny \sf BN}}}\xspace}

\newcommand{\BJ}[1]{\ensuremath{{#1}^{\text{\tiny \sf BJ}}}\xspace} \newcommand{\SEC}[1]{\ensuremath{{#1}^{\text{\tiny \sf SEC}}}\xspace} +% Trees +\newcommand{\tree}[1][]{\sf{MT}^{\sf{#1}}} +\renewcommand{\root}[1][]{\sf{root}^{\sf{#1}}} +\newcommand{\recentroots}{\sf{recentRoots}} +\newcommand{\leaf}{\sf{leaf}} +\newcommand{\leaves}{\sf{leaves}} +\newcommand{\MTRoot}{\sf{Root}} +\newcommand{\MTInsert}{\sf{Insert}} +\newcommand{\MTRemove}{\sf{Remove}} +\newcommand{\MTOpen}{\sf{Open}} +\newcommand{\MTVerify}{\sf{Verify}} + % Circuits \newcommand{\public}{{\sf\color{teal}public}\xspace} \newcommand{\private}{{\sf\color{red}private}\xspace} + +% Roles +\definecolor{voterbg}{RGB}{200, 230, 200} % soft, muted green +\definecolor{organizerbg}{RGB}{245, 222, 135} % classic mustard tone +\definecolor{sequencerbg}{RGB}{235, 225, 250} % soft lavender-like purple +\definecolor{darkgrayborder}{RGB}{100, 100, 100} % dark neutral gray + +\newcommand{\voter}{\fcolorbox{darkgrayborder}{voterbg}{ \textsf{voter} }\xspace} +\newcommand{\organizer}{\fcolorbox{darkgrayborder}{organizerbg}{ \textsf{organizer} }\xspace} +\newcommand{\sequencer}{\fcolorbox{darkgrayborder}{sequencerbg}{ \textsf{sequencer} }\xspace} +\newcommand{\sequencers}{\fcolorbox{darkgrayborder}{sequencerbg}{ \textsf{sequencers} }\xspace} % Ballot protocol \newcommand{\ballotstyle}[1]{\texttt{#1}\xspace}
M v2/build/preamble-packages.tex → v2/build/preamble-packages.tex

@@ -20,6 +20,7 @@

\usepackage{amsmath, amssymb, mathtools} \usepackage{listings} \usepackage{graphicx, color, xcolor} +\usepackage{soul} \usepackage{xspace} %list of punctuation marks \usepackage{enumitem} \usepackage{multirow}
M v2/sections/cryptographic-primitives.tex → v2/sections/cryptographic-primitives.tex

@@ -158,9 +158,7 @@ \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 for computing 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}). - -\martai{And also compress messages for signing!} +\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}.

@@ -369,9 +367,32 @@

\subsection{Merkle trees} \label{sec:cryptographic-primitives:merkle-trees} -\martai{I am not sure a Merkle trees section is needed, but I thought we could use it to specify the hash function used in the trees, the depth, and the -arity. We could also include some functions like \texttt{MT.Root()}, etc.} -\martai{Sparse MTs (binary) with depth $64$. Structure of sparse MT from iden3.} +The \davinci protocol uses sparse Merkle trees (SMTs) as defined in ~\cite{baylina19sparse}. Essentially, in this kind of trees each leaf corresponds to a key-value pair, with empty leaves explicitly represented to enable both inclusion and non-inclusion proofs. The key feature of these trees is that the hash of each entry defines a unique traversal path in the tree from root to leaf, regardless of insertion order. When inserting, the algorithm descends until it encounters an empty node or a leaf; if there is a hash prefix collision, the tree is split at the first differing bit, creating new intermediate nodes appropriately. 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, both the census (voter registry with weights) and the vote state are maintained using SMTs. The root hashes are committed on-chain, while full tree contents remain off-chain. Sequencers generate and submit Merkle proofs to the verification circuits, which reconstruct and validate the root transitions. This design allows compact, verifiable state updates and enables independent verification without relying on trusted data sources. + +\noi To each Merkle tree $\tree$, we associate the following functions: + +\begin{itemize} + \item ${\tree.\hlset{\MTRoot}}()$: it returns the root of the tree. + \item ${\tree.\hlset{\MTInsert}}()$: it inserts a new leaf in the tree. If the position is passed as an input, the element is inserted in that position. Otherwise, the new element is inserted in the first empty position. The root is updated. + \item ${\tree.\hlset{\MTRemove}}()$: it removes a leaf from the tree. The root is updated. + \item ${\tree.\hlset{\MTOpen}}()$: it returns the Merkle tree inclusion proof of the given leaf. + % \item ${\MT.\Prove}_{\pp}((\leaf_i)_{i=1}^q, \pos)$. + %This algorithm is run by the committer to output the value $m$ at position $i$ in $\vec{m}$, and the corresponding proof $\proof_i$. + % \item ${\MT.\Verify}_{\pp}(\leaf, \pos, \root, \proof)$. + %The verification algorithm accepts only if $\proof$ is a valid proof that $m_i$ is at the $i$th position of the vector commited in $\com$. + % \item ${\MT.\UpdateRoot}_{\pp}({\leaf, \pos, \root})$: it updates the root - I am not sure this function is needed! + \item ${\tree.\hlset{\MTVerify}} + ()$: it takes a Merkle proof and a root as an input and verifies the proof against the given root. The output is accept/reject. + %This algorithm is run by the committer who produced $\com$ and wants to update it by changing the $i$-th message to $m'$. The algorithm outputs a new commitment $\com'$. + % \item ${\MT.\UpdateProof}_{\pp}({\leaf, \pos, \proof})$. + %This algorithm produces an updated proof $\proof'$ that $m'$ (instead of $m$) is in the $i$-th position of the vector. +\end{itemize} + \martai{\textbf{(1) State MT:} Poseidon with BN254 scalar field. \textbf{(2) Census MT:} MiMC with BLS12-377 scalar field.} + +\martai{Sparse MTs (binary) with depth $64$. Structure of sparse MT from iden3.} \subsection{Zero-knowledge proof systems} \label{sec:cryptographic-primitives:zkp}
M v2/sections/vocdoni-protocol.tex → v2/sections/vocdoni-protocol.tex

@@ -381,7 +381,7 @@ % \item Deployment of the 3 smart contracts.

% \item Sequencers registry starts (it doesn't end). %\end{enumerate} -Sequencers (nodes validadors) -- this process is always open: +\sequencers -- this process is always open: \begin{enumerate} \item Register this and that way. \item Public keys?

@@ -394,7 +394,7 @@

\subsubsection{Start of the voting process} \label{sec:vocdoni-protocol:start} -The organizer: +\organizer \begin{enumerate} \item Prepares the census data \texttt{census\_data}. \item Generates the census commitment \texttt{MT\_census.root = Com(census\_data)}.

@@ -410,7 +410,7 @@

\subsubsection{Encryption key generation process} %Voting key generation \label{sec:vocdoni-protocol:dkg} -The sequencer: +\sequencers \begin{enumerate} \item Download all required data from the PM smart contract which includes the census MT root to handle the new vote. \item Make contributions to DKG ceremony.

@@ -426,28 +426,31 @@ \martai{I understand EPK becomes available in the SR smart contract, and that key is sent to the PM contract?}

\martai{The idea here is that some sequencer makes EPK available (a.k.a. sends a transaction). Alternatively, generate a SNARK proving the EPK has been generated correctly and the SC verifies it.} \end{itemize} +\newpage \subsubsection{Voting process} \label{sec:vocdoni-protocol:voting} - -Voter: +\voter \begin{itemize} - \item Choose any of the available sequencers (from?? -- from the SR SC). - \item Fetch their census \textbf{Merkle proof} to prove eligibility (from the census registry). - \item Collect the process data $\epk$, $\ballotmode$, $\processid$ from the process management smart contract. - \item Sample a fresh random $k\in\F$ and use the $\epk$ to encrypt the voting choice $\ballot$: - \begin{equation} + \item Choose any of the available sequencers from the sequencer registry smart contract. + \item Fetch from the census registry their membership proof $\censusproof$ to prove eligibility. + \item Collect %the process data + the $\epk$, $\ballotmode$, $\processid$ from the process management smart contract. + \item Select their voting choice $\ballot$ according to the election rules specified by the $\ballotmode$ parameter. \item Sample a fresh random $k \in \F$ and encrypt the selected choice using the public key $\epk$: + \begin{equation} \label{eq-ciphertext} - (C_1, C_2) = \hlget{\Enc}_{\epk}(\ballot; k). - \end{equation} + (C_1, C_2) = \hlget{\Enc}_{\epk}(\ballot; k). + \end{equation} \martai{Actually, I would not write $(C_1, C_2)$ but rather \texttt{ciphertext}.} \item Use the user's own Ethereum address $\address$ and the previous $k$ to compute the $\voteid$: \begin{equation} \label{eq-voteid} \voteid = Hash(\processid \conc \address \conc k). \end{equation} - \martai{The hash used in votID is MultiMiMC7.} - \item Generate ZK-SNARK of satisfiability of circuit from Fig.~\ref{fig:circuit-voter} with the proof system from Section~\ref{sec:cryptographic-primitives:zkp} to prove that Eqs.~\labelcref{eq-ciphertext,eq-voteid} are correctly computed, and that $\ballot$ satisfies ballot protocol rules according to $\ballotmode$. We call this proof \textbf{vote proof}. + \martai{The hash used in voteID is MultiMiMC7.} + \item Generate ZK-SNARK of satisfiability of circuit from Fig.~\ref{fig:circuit-voter} with the proof system from Section~\ref{sec:cryptographic-primitives:zkp} to prove that Eqs.~\labelcref{eq-ciphertext,eq-voteid} are correctly computed, and that $\ballot$ satisfies ballot protocol rules according to $\ballotmode$. We call this proof \textbf{vote proof}. \item \zkproof: the voter generates a ZK proof to prove the correctness of the ballot and encryption process: + \[ \zkproof = \text{Prove(), Circuit()}. \] + This proof proves the correct computation of the vote encryption, the nullifier, the commitment, and the compliance with the ballot protocol rules. \item Sign $\voteid$ using the user's secret key $\sk$ to authenticates the vote and ensure that was cast by a legitimate voter: \[ \signature = \hlget{\SSign}_{\sk}(\voteid).\] \item Send the encrypted vote, Merkle proof, validity proof, and identity proof to the sequencer:

@@ -460,15 +463,7 @@ \martai{Actually, the address could be recomputed by the sequencer (add it as a footnote).}

\martai{In the code, they call it vote, verifierVote. Alternative: envelope.} -\begin{itemize} - \item \censuspf: the census proof serves as the voter's identity verification mechanism, ensuring that only eligible voters can participate. Depending on the process configuration, the voter provides either a Merkle tree-based proof showing inclusion in the census true, or a credential issued by a trusted third party (e.g. from a credential service provider). - % - \item \zkproof: the voter generates a ZK proof to prove the correctness of the ballot and encryption process: - \[ \zkproof = \text{Prove(), Circuit()}. \] - This proof proves the correct computation of the vote encryption, the nullifier, the commitment, and the compliance with the ballot protocol rules. -\end{itemize} - -Sequencer: +\noi \sequencers \begin{itemize} \item Fetch current state: retrieve the current valid process state root from the Etherem smart contract and the associated data from Ethereum blobs.

@@ -502,7 +497,7 @@ \label{sec:vocdoni-protocol:validation}

Once the voting is completed (I understand the timeout set by the organizer expires), the following things happen. -Sequencer: +\noi \sequencers \begin{itemize} \item $t$ out of $n$ sequencers publish their shares corresponding to the EPK to the Ethereum smart contract.