davinci-paper/v2/sections/cryptographic-primitives.tex
v2/sections/cryptographic-primitives.texRaw
1% !TeX root = ../build/main.tex
2
3In this section, we detail the cryptographic primitives used in Section~\ref{sec:vocdoni-protocol}. We briefly introduce Merkle trees, the commitment and encryption schemes, proof systems, elliptic curves and hash functions used. We also specify at each step the concrete parameters with which each of the primitives is instantiated.\\
4
5\martai{This section is a mix of theoretical description and implementation details.}
6\martai{Hmm not really, it's more details. Maybe it should go under the protocol section?}
7\martai{Rethink the structure (e.g., hash functions should go before Merkle trees).}
8
9\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\}^*$.
10%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$.
11%$\F_p$ denotes de finite field of order $p$, and $\F_p^* = \F_p/\{0\}$.
12
13\subsection{Merkle trees}
14\label{sec:cryptographic-primitives:merkle-trees}
15
16\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.}
17\martai{Sparse MTs (binary) with depth $64$. Instantiated with Poseidon hash function.}
18
19\subsection{Zero-knowledge proof systems}
20\label{sec:cryptographic-primitives:zkp}
21
22\textit{Old text: zero-knowledge succinct non-interactive arguments of knowledge are a crucial component in ensuring the validity of the voting results. Voters generate zkSNARK proofs to prove that their encrypted votes comply with the rules and requirements of the voting process, without revealing any information about their choices. Sequencers also generate zkSNARK proofs to prove the correct aggregation of votes into the shared state that maintains the status of the voting process.}
23
24\subsection{Elliptic curves}
25\label{sec:cryptographic-primitives:elliptic-curves}
26
27\davinci uses BW6-761 \cite{elhousni20optimized}, BLS12-377 \cite{bowe20zexe}, and BN254 \cite{jancar20bn256} curves. Below, we give the details of these curves.
28
29\paragraph{Parameters.}
30
31\begin{itemize}
32 \item[$\bullet$] $p = \tt{0x122e824fb83ce0ad187c94004faff3eb926186a81d14688528275ef8087be41707ba638e584e9190}$
33 \item[] \hspace{0.53cm} $\tt{3cebaff25b423048689c8ed12f9fd9071dcd3dc73ebff2e98a116c25667a8f8160cf8aeeaf0a437e69}$
34 \item[] \hspace{0.53cm} $\tt{13e6870000082f49d00000000008b}$ (761-bit prime).
35 \item[$\bullet$] $q = \tt{0x01ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d4430000000}$
36 \item[] \hspace{0.52cm} $\tt{8508c00000000001}$ (377-bit prime).
37 \item[$\bullet$] $r = \tt{0x12ab655e9a2ca55660b44d1e5c37b00159aa76fed00000010a11800000000001}$ (253-bit prime).
38 \item[$\bullet$] $s = \tt{0x2523648240000001ba344d80000000086121000000000013a700000000000013}$ (254-bit prime).
39 \item[$\bullet$] $t = \tt{\hspace{0.04cm}0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d}$ (254-bit prime).
40\end{itemize}
41
42\paragraph{Elliptic curve groups.}
43\begin{itemize}
44 \item BW6-761 curve: $\BW{E}/\F_p$ defined by equation $\BW{E}: y^2 = x^3 - 1$, with subgroups $\BW{\G}_1, \BW{\G}_2$ of prime order $q$, and an efficiently computable pairing \({e}:\BW{\G}_1\times\BW{\G}_2 \rightarrow \BW{\G}_T,\) where $\BW{\G}_T \subset \F_{q^{6}}$ and has order $q$ as well.
45 \item BLS12-377 curve: $\BLS{E}/\F_q$ defined by equation \(\BLS{E}: y^2 = x^3 + 1,\) with subgroups $\BLS{\G}_1, \BLS{\G}_2$ of prime order $r$, and an efficiently computable pairing \({e}:\BLS{\G}_1\times\BLS{\G}_2 \rightarrow \BLS{\G}_T,\) where $\BLS{\G}_T \subset \F_{r^{12}}$ and has order $r$.
46 \item BN254 curve: $\BN{E}/\F_s$ defined by equation \( \BN{E}: y^2 = x^3 + 3\), with subgroups $\BN{\G}_1, \BN{\G}_2$ of prime order $t$, and an efficiently computable pairing \(e:\BN{\G}_1\times\BN{\G}_2 \rightarrow \BN{\G}_T,\) where $\BN{\G}_T \subset \F_{t^{12}}$ and has order $t$.
47 \item Baby Jubjub.
48 \item Secp256k1.
49\end{itemize}
50
51\paragraph{Finite fields.}
52\begin{itemize}
53 \item $\F_p$: base field of the BW6-761 curve.
54 \item $\F_q$: scalar field of $\BW{\G}_1, \BW{\G}_2, \BW{\G}_T$ and base field of the BLS12-377 curve.
55 \item $\F_r$: scalar field of $\BLS{\G}_1, \BLS{\G}_2, \BLS{\G}_T$.
56 \item $\F_s$: base field of the BN254 curve.
57 \item $\F_t$: scalar field of $\BN{\G}_1, \BN{\G}_2, \BN{\G}_T$.
58\end{itemize}
59
60%The primes and groups defined here will be used through the rest of the document.
61
62\subsection{Hash functions}
63\label{sec:cryptographic-primitives:hash}
64
65\martai{Poseidon? Specify parameters? And $p$ may actually not be $p$, and probably it will be instantiated with different curves, depending on the circuit.}
66
67\martai{Yes, Poseidon. But also MiMC-7 for hashing the public inputs and passing them between circuits (for efficiency).}
68
69We use the Poseidon~\cite{grassi21poseidon} hash function $ \hlset{\Hash} : \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}. In particular, we make use of the \textsc{Poseidon-128} permutation \[\pi: \F_p^t\rightarrow \F_p^t,\] where $t=r+c$, with the following parameters:
70\begin{table}[H]
71 \begin{center}
72 \begin{tabular}{| c | c | c | c | c | }
73 \hline
74 Rate & Capacity & Full rounds & Partial rounds & S-box \\
75 \hline
76 $r=4$ & $c=1$ & $R_F=8$ & $R_P=59$ & $S(x)=x^5$ \\
77 \hline
78 \end{tabular}
79 \end{center}
80\end{table}
81
82% \begin{itemize}
83 % \item Rate $r=4$.
84 % \item Capacity $c=1$.
85 % \item Full rounds $R_F = 8$.
86 % \item Partial rounds $R_P = 59$.
87 % \item S-box: $S(x) = x^5$.
88 % \end{itemize}
89
90For the sake of clarity, in our notation we admit anything as an input of $\Hash$, although it might not be parsed as a sequence of $\F_p$-elements. Any bitstring can be converted to a tuple of $\F_p$-elements, so this does not change the actual working of the hash computation. In this document, is implied that the proper conversion happens before feeding the input into the actual hash function.
91
92\subsection{Encryption schemes}
93\label{sec:cryptographic-primitives:encryption}
94
95\textit{Old text: Threshold homomorphic encryption, specifically the ElGamal scheme, is used to allow the summation of encrypted votes without decrypting them. This enables the system to compute the final vote tally while maintaining the privacy of individual votes. By ensuring that no vote is exposed during the aggregation phase, this scheme preserves voter confidentiality and provides anti-coercion protection, as voters cannot prove their choice to a third party once an encrypted vote is added.}\\
96
97ElGamal [CITE].
98
99\medskip
100
101\begin{mdframed}
102 \begin{minipage}[t]{0.54\textwidth}
103 \begin{itemize}
104 \item[$\bullet$] $\hlset{\Enc}_{\pk}(\msg \in \{0,1\}^\star)$: \vspace{0.1cm}
105 \begin{enumerate}
106 \item Map $\msg$ to $\J$ via $M = mG$. (link G).
107 \item Select a random scalar $k \sample $.
108 \item Compute $C_1 = k \cdot G \in \J$.
109 \item Compute $C_2 = k \cdot \pk + M \in \J$.
110 \item Output $\enc = (C_1, C_2) \in \J^2$.
111 \end{enumerate}
112 \end{itemize}
113 \end{minipage}
114 \begin{minipage}[t]{0.44\textwidth}
115 \begin{itemize}
116 \item[$\bullet$] $\hlset{\Dec}_{\sk}(\enc \in \J)$: \vspace{0.1cm}
117 \begin{enumerate}
118
119 %From a ciphertext (C,D) calculate C′=xC, and retrieve the point Pm with Pm=D−C′=(k(xP)+Pm)−(x(kP)). Then calculate the message m with f−1(Pm).
120
121 \item Parse $\enc = (C_1, C_2) \in \J^2$.
122 \item Compute $K = \sk \cdot C_1 \in \J$.
123 \item Output $\msg = C_2 - K$.
124 \end{enumerate}
125 \end{itemize}
126 \end{minipage}
127\end{mdframed}
128
129\martai{The group $\J$ is not the right group. This should be changed after writing the elliptic curves section. Actually, I am unsure we should specify where do all elements live.}
130
131\martai{It remains to explain how to recover $m$ from $M$. I propose to define a function $P_m$ that maps $m$ to $\J$, and then say that although it is generally not invertible, in this case the message space is small, and therefore, it can be done via brute-force search or using the baby-step giant-step algorithm [CITE].}
132
133Note that this scheme is additively homomorphic. That is, given two ciphertexts $(C_1, C_2)$ and $(C_1', C_2')$, their component-wise addition yields: $(C_1^{sum}, C_2^{sum}) = (C_1 + C_1', C_2, C_2)$. The aggregated ciphertext decrypts to the sum of the messages $M^{sum} = M_1 + M_2$.
134
135\martai{The $pk$ used to encrypt is generated by multiple parties as defined in Section~\ref{sec:cryptographic-primitives:dkg}.}
136
137\subsection{Commitment schemes}
138\label{sec:cryptographic-primitives:commitments}
139
140%Pedersen commitment scheme~\cite{pedersen1991non}.
141
142\subsection{Digital signature schemes}
143\label{sec:cryptographic-primitives:signatures}
144
145ECDSA.
146
147\subsection{Key generation schemes}
148\label{sec:cryptographic-primitives:dkg}
149
150\textit{Old text: The DKG protocol is used to generate the encryption public key (EPK) in a decentralized manner. Sequencers collaboratively participate in the DKG process to create the EPK, ensuring that no single party has full control over the key. This approach guarantees that the encryption key remains secure and that decryption of results is only possible when a threshold number of sequencers publish their shares.}\\
151
152We use the distributed key generation (DKG) protocol that allows a group of participants to jointly generate a pair of public/private keys for the ElGamal cryptosystem [CITE]. Each participant holds a share of the private key, and only a threshold number of participants can collaborate to decrypt messages.
153
154\martai{We use a variation of DKG because of the encryption of shares. Below I described the original functions but they should be changed!}
155\martai{Mention that in the SC participants are listed, that is, they have an associated number $i$.}
156
157Let $t$ be the threshold parameter (minimum number of participants required to decrypt messages) and $n$ the total number of participants participating in the DKG protocol ($t \leq n$). Let $G$ be generator point of order $q$. (This will already be defined in the EC section).
158
159\begin{mdframed}
160Each participant $P_i$ will use $\hlget{\GenerateShares}$ to generate their share. Then, they will make the set $\{C_i\}_{i=1}^{t-1}$ publicly available and send each $s_j$ privately to each participant $s_j$. Every participant $P_i$ can verify the share $s_{j,i}$ received from $P_j$ (from of the others) using the algorithm $\hlget{\VerifyShare}$.\\
161
162\noindent
163\begin{minipage}[t]{0.5\textwidth}
164 \begin{itemize}
165 \item[$\bullet$] $\hlset{\GenerateShares}(\text{participant $i$})$: \vspace{0.1cm}
166 \begin{enumerate}
167 \item Select random scalars $a_{i,0} \sample \Z_q$.
168 \item Define the polynomial $f_i(x) = \sum_{j = 0}^{t-1} a_{i,j} x^{j}$.
169 \item For every $j\in\{0,\dots,t-1\}$, compute
170 $$C_{i, j} = a_{i,j}\cdot G.$$
171 \item For every $j\in\{1,\dots,n\}$, compute shares
172 $$s_{i, j} = f_i(j).$$
173 \item Output $\{C_{i,j}\}_{i=0}^{t-1}$ and $\{s_{i,j}\}_{j=1}^{n}$.
174 \end{enumerate}
175 \end{itemize}
176 \martai{This is not true - according to the specs, shares are encrypted using a simplified version of the EC integrated encryption scheme (ECIES). Each participant generates a zkSNARK proof to prove the correctness of the encrypted shares and compliance of the DKG protocol. This allows the Ethereum SC to verify the validity without revealing the secrets.}
177 \martai{Change the name of algorithm to $\texttt{GenerateEncryptedShares}$.}
178\end{minipage}
179\begin{minipage}[t]{0.5\textwidth}
180 \begin{itemize}
181 \item[$\bullet$] $\hlset{\VerifyShare}(i, j, s_{i,j}, C_i)$: \vspace{0.1cm}
182 \begin{enumerate}
183 \item Compute $V = \sum_{i = 0}^{t-1} C_i$.
184 \item Verify that $V = s_{i,j} \cdot G$.
185 \martai{This is done by the smart contract - the shares are not in the clear but encrypted.}
186 \end{enumerate}
187 \end{itemize}
188 \martai{Describe slashing mechanism in SC section if one of the shares fails the verification?}
189\end{minipage}
190\end{mdframed}
191%%%%
192%
193%%%%
194\begin{mdframed}
195Participant $P_j$ uses the algorithm $\hlget{\DeriveSecretShare}$ to compute their portion of the collective private key. The algorithm $\hlget{\DerivePublicKey}$ generates the public key from the committed data from the participants. \\
196
197\noindent
198\begin{minipage}[t]{0.5\textwidth}
199 \begin{itemize}
200 \item[$\bullet$] $\hlset{\DeriveSecretShare}(\text{participant $j$})$: \vspace{0.1cm}
201 \begin{enumerate}
202 \item Compute $s_j = \sum_{i = 1}^{n} s_{i, j} \mod q$.
203 \item Output $s_j$.
204 \end{enumerate}
205 \end{itemize}
206\end{minipage}
207%
208\begin{minipage}[t]{0.5\textwidth}
209 \begin{itemize}
210 \item[$\bullet$] $\hlset{\DerivePublicKey}(\{C_{i,0}\}_{i=1}^n)$: \vspace{0.1cm}
211 \begin{enumerate}
212 \item Let $pk = \sum_{i=1}^n C_{i,0}$.
213 \item Output $pk$.
214 \end{enumerate}
215 \end{itemize}
216 Note that since $C_{i,0} = a_{i,0} \cdot G$, the public key is effectively $sG$ where $s = \sum_{i = 1}^n a_{i,0} \mod q$ is the collective private key (unknown to any single participant).
217 \martai{As before, this should be changed to the encrypted version. It should be explained how the public key is generated from the encrypted shares.}
218\end{minipage}
219%
220\end{mdframed}