Skip to content

Commit f96bd24

Browse files
authored
Merge pull request #12 from AAU-Dat/implementation
Implementation
2 parents fdadd81 + f06eb47 commit f96bd24

File tree

1 file changed

+135
-18
lines changed

1 file changed

+135
-18
lines changed

report/src/sections/04-Approach.tex

Lines changed: 135 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ \subsection{Springproofs}\label{sec:approach-springproofs}
7474
First of all, we have the prover computation, where the proof is constructed.
7575
The construction can be seen in~\autoref{fig:ipa-prover}.
7676

77-
\begin{figure}[ht]
77+
\begin{figure}[h]
7878
\begin{framed}
7979
\begin{lstlisting}[language=Python,mathescape=true,label={lst:ipa-prover}]
8080
$\textbf{Step 1:}$
@@ -149,7 +149,7 @@ \subsection{Springproofs}\label{sec:approach-springproofs}
149149
Having the proof on the blockchain allows for each validator to asynchronously verify whether it is a valid proof.
150150
Again, the originally proposed verifying protocol has been modified according to Springproofs, which is seen in~\autoref{fig:ipa-verifier}.
151151

152-
\begin{figure}[ht]
152+
\begin{figure}[h]
153153
\begin{framed}
154154
\begin{lstlisting}[language=Python,mathescape=true,label={lst:ipa-verifier}]
155155
$\textbf{Step 1:}$
@@ -205,10 +205,10 @@ \subsection{Springproofs}\label{sec:approach-springproofs}
205205
If so, the verifier accepts the proof.
206206

207207

208-
\subsection{Shuffle security}\label{sec:approach-shuffle-security}
209-
The shuffle method proposed by Larsen et al.~\cite{cryptoeprint:2022/560} that was used in curdleproofs is based on the idea of shuffling a list of proposers over a set of slots.
210-
The shuffle itself however is not too complex.
211-
A formal definition of the shuffle is given in~\autoref{fig:shuffle}.
208+
\subsection{Shuffle security}\label{subsec:approach-shuffle-security}
209+
The shuffle method proposed by Larsen et al.~\cite{cryptoeprint:2022/560} that was used in Curdleproofs is based on the idea of shuffling a list of proposers over a set of slots.
210+
The shuffle itself, however, is not too complex.
211+
A formal definition of the shuffle is given in~\autoref{fig:shuffle}~\cite{cryptoeprint:2022/560}.
212212

213213
\begin{figure}[ht]
214214
\begin{framed}
@@ -230,29 +230,146 @@ \subsection{Shuffle security}\label{sec:approach-shuffle-security}
230230
\end{figure}
231231

232232
Here the set $(c_1, \ldots, c_n)$ is a set of ciphertexts that are shuffled over $T$ slots.
233-
In each slot $t$, a subset of the ciphertexts ${i_1, \ldots, i_k}$ is chosen randomly and shuffled and added back to the list of ciphertexts.
234-
It is then encrypts the ciphertexts again and publishes them.
233+
In each slot $t$, a subset of the ciphertexts ${i_1, \ldots, i_k}$ is chosen randomly, shuffled, and added back to the list of ciphertexts.
234+
The shuffler then re-encrypts the ciphertexts and publishes them.
235235
This process is repeated for $T$ slots and the shuffle is complete.
236-
During the $T$ shuffles some of the shufflers may be adversarial.
237-
This means that whenever the shuffling process is taking place a part of the shuffles may be adversarial which can be seen as not being shuffled.
238-
Therefore the amount of honest shuffles that happen during the shuffle process is $T_H = T - \alpha$.
239-
Where $\alpha$ is the amount of adversarial shufflers.
236+
During the $T$ shuffles, some shufflers may be adversarial.
237+
This means that whenever the shuffling process is taking place, a part of the shuffles may be adversarial, which can be seen as not being shuffled.
238+
Therefore, the number of honest shuffles that happen during the shuffle process is $T_H = T - \alpha$, where $\alpha$ is the number of adversarial tracked ciphertexts.
240239

241-
The Shuffle is secure if none of these two events occur.
240+
The shuffle is secure if none of the following two events occur.
242241
The first event is a short backtracking, where an adversary can find the original ciphertexts from the shuffled ciphertexts.
243-
Since the subsets of ciphertexts are chosen randomly in each shuffle, if is enough adversarial shufflers in a row to end the process, then a shot backtrack is possible.
242+
Since the subsets of ciphertexts are chosen randomly in each shuffle, if there are enough adversarial shufflers in a row to end the process, then a short backtracking is possible.
244243

245-
The second event that can occur is that since every shuffle distributes the possibility of a certain ciphertext to be in a certain slot.
246-
Then if a shuffle contains a lot of ciphertext with a larger than average chance of containing a certain ciphertext, then that would imply that there is a higher chance of that ciphertext being in that slot.
244+
The second event that can occur is related to the fact that every shuffle distributes the possibility of a certain ciphertext to be in a certain slot.
245+
So, if a shuffle contains a lot of ciphertexts with a larger than average chance of containing a certain ciphertext, then that would imply that there is a higher chance of that ciphertext being in that slot.
247246

248-
It is theoretically possible to find a shuffle size and a number of shuffles given an amount of adversarial shufflers to guarantee that the shuffle is secure.
247+
It is theoretically possible to find a number of shuffles, given the shuffle size, and a number of adversarial shufflers, to guarantee that the shuffle is secure.
249248
For any $0 < \delta < 1/3$, if $T \geq 20 n / k \ln(n/\delta) + \beta $ and $ k \geq 256 \ln^2(n/\delta)(1 - \alpha/n)^{-2}$.
250249
If $T$ and $k$ are chosen such that the above two conditions are met, then the protocol is an $(\epsilon , \delta)$-secure $(T,n,k)$-shuffle in the presence of a $(\alpha, \beta)$-adversary where $\epsilon = 2/(n-\alpha)$.
251250

252251
This formula is the lowest theoretically proven bound for $T$ and $k$.
253-
It is however possible to find lower secure values for $T$ and $k$ but this has to be done experimentally.
252+
Plotting numbers relevant to Whisk will show that this theoretical bound is too large to use for argumentation of security.
253+
It is, however, possible to find lower secure values for $T$ and $k$, but this has to be done experimentally.
254254

255255

256256
\subsection{Implementation}\label{subsec:approach-implementation}
257+
Implementing the above-explained CAAUrdleproofs protocol introduced some optimizations required to have the code run as fast as possible.
258+
These are explained in the following with a focus on how CAAUrdleproofs differentiates itself from Curdleproofs.
259+
Both our implementation of CAAUrdleproofs and the experiment involving the security of the shuffle are publicly available on GitHub~\footnote{\href{https://github.com/AAU-Dat/curdleproofsplus/tree/SIPA}{https://github.com/AAU-Dat/curdleproofsplus/tree/SIPA}}.
260+
The implementation of CAAUrdleproofs is a fork of and builds directly on the already existing Curdleproofs code.
261+
\subsubsection{CAAUdleproofs}
262+
The protocol in Curdleproofs~\cite{Curdleproofs} introduces a lot of multiscalar multiplications.
263+
As such, CAAUrdleproofs also introduces these multiplications.
264+
This allows for checking calculations of the form:
265+
\begin{align}
266+
C\stackrel{?}{=}\mathbf{x}\times(\mathbf{g}\|\mathbf{h}\|G_T\|G_U\|H\|\mathbf{R}\|\mathbf{S}\|\mathbf{T}\|\mathbf{U})
267+
\end{align}
268+
As explained by Curdleproofs, the verifier computation can be significantly optimized by checking the multiscalar multiplications as a single check at the end of the protocol instead.
269+
270+
CAAUrdleproofs introduced a slight difference on this topic in regard to the~\glspl{ipa}, \texttt{sameperm} and \texttt{same multiscalar}.
271+
In each recursive round, both the folded vectors and the commitments are being multiplied by verification scalars, $\gamma_j$.
272+
To keep track of which elements of the vectors are multiplied by each $\gamma_j$, a function called \texttt{get\_verification\_scalars\_bitstring} is used.
273+
The output of this function is a list of length $\ell$, each element with a list corresponding to the rounds in which $\gamma_j$ was multiplied to the element.
274+
Curdleproofs' implementation is simpler than CAAUrdleproofs' in this case.
275+
As Curdleproofs works on powers of two, it is always the right half of the vectors in each round that are multiplied by the challenge.
276+
277+
The multiplication of challenges are not as easily trackable in the CAAUrdleproofs protocol.
278+
Here, it is necessary to simulate a run though the recursive protocol.
279+
Though, this should not have a big impact on performance, as it is run over vectors of small integers, and never actually has to do any multiplications.
280+
It is simply used as a measuring tool.
281+
282+
\begin{figure}[ht]
283+
\begin{framed}
284+
\begin{lstlisting}[language=Python,mathescape=true,label={lst:ipa-verifier-optimized}]
285+
$\textbf{Step 1:}$
286+
$(\textbf{G},H)\gets$parse$(crs_{dl_{inner}})$
287+
$(C,D,z,\mathbf{u})\gets$parse$(\phi_{dl_{inner}})$
288+
$(B_C,B_D,\mathbf{\pi},c,d)\gets$parse$(\pi_{dl_{inner}})$
289+
$\alpha,\beta\gets$Hash$(C,D,z,B_C,B_D)$
290+
291+
$\textbf{Step 2:}$
292+
$m\gets \lceil\log n\rceil$
293+
for $1\leq j\leq m$
294+
$T,S\gets \textbf{\textit{f(}}n\textbf{\textit{)}}$
295+
$n\gets \frac{|T|}{2}$
296+
$(L_{C,j},L_{D,j},R_{C,j},R_{D,j})\gets$parse$(\pi_j)$
297+
$\gamma_j\gets$Hash$(\pi_j)$
298+
$n\gets n+\text{len}(S)$
299+
300+
$\textbf{Step 3:}$
301+
$\mathbf{CP}\text{: }\mathbf{\gamma}\gets(\gamma_m,...,\gamma_1)$
302+
$\mathbf{CAAUP}\text{: }\mathbf{\gamma}\gets(\gamma_1,...,\gamma_m)$
303+
$\textit{Compute }\mathbf{s}\textit{: see below for difference}$
304+
305+
AccumulateCheck$(\mathbf{\gamma}\times\mathbf{L}_C+(B_C+\alpha C+(\alpha^2z)H)$
306+
$+\mathbf{\gamma}^{-1}\times\mathbf{R}_C\stackrel{?}{=}(c\mathbf{s}\| cd\beta)\times(\mathbf{G}\| H))$
307+
AccumulateCheck$(\mathbf{\gamma}\times\mathbf{L}_D+(B_D+\alpha D)$
308+
$+\mathbf{\gamma}^{-1}\times\mathbf{R}_D\stackrel{?}{=}d(\mathbf{s'}\circ\mathbf{u})\times\mathbf{G})$
309+
$\text{return 1}$
310+
311+
$\textbf{s-step Curdleproofs:}$
312+
for $1\leq j\leq n$:
313+
$s_i=\sum_{j=1}^m\delta_j^{b_{i,j}}\text{, }b_{i,j}\in\{0,1\}\text{ s.t. }i=\sum_{j=1}^mb_{i,j}2^j$
314+
$s'_i=\sum_{j=1}^m\delta_j^{-b_{i,j}}$
315+
$\textbf{s-step CAAUrdleproofs:}$
316+
$ActivePos\gets[(i,i)\text{, }i=1,\dots,n]$
317+
for $1\leq j\leq m:$
318+
$h\gets\frac{2^{\lceil\log n\rceil}}{2}$
319+
$f\gets n-h$
320+
$nf\gets h-f$
321+
$fs\gets \frac{nf}{2}$
322+
for $(i,k)$ in $ActivePos$:
323+
if $k\geq h:$
324+
$b_{i,j}\gets1$
325+
$newPos=k-h-fs$
326+
else:
327+
$b_{i,j}\gets0$
328+
$newPos=k$
329+
$nextActivePos.push((i,newPos))$
330+
$ActivePos\gets nextActivePos$
331+
$n\gets h$
332+
for $1\leq j\leq n$:
333+
$s_i=\sum_{j=1}^m\delta_j^{b_{i,j}}$
334+
$s'_i=\sum_{j=1}^m\delta_j^{-b_{i,j}}$
335+
\end{lstlisting}
336+
\end{framed}
337+
\caption{Optimized verifier computation for CAAU-IPA in CAAUrdleproofs}
338+
\label{fig:ipa-verifier-optimized}
339+
\end{figure}
340+
341+
The protocol used in the implementation can be seen in~\autoref{fig:ipa-verifier-optimized}.
342+
A list, \texttt{ActivePos}, keeps track of the original index placement and its position after each fold.
343+
Doing this, we can run the recursion and find the correct challenges for each index, while still knowing what the original index was.
344+
A bit matrix,~$b_{i,j}$, is constructed as in Curdleproofs, such that the vector, $\mathbf{s}$, is made in the same way for both protocols.
345+
346+
The vector, $\mathbf{u}$, is used for optimization in the grand product argument rather than $\mathbf{G'}$, and the \texttt{AccumulateCheck} function is used for the multiscalar multiplication optimization.
347+
For a thorough explanation of these, we refer to Curdleproofs~\cite{Curdleproofs}.
348+
349+
In Curdleproofs, both the \texttt{SamePerm} and \texttt{SameMultiscalar} proof are recursive~\glspl{ipa}.
350+
So, the modifications and optimization used on the \texttt{SamePerm} argument are also used on the \texttt{SameMultiscalar} argument.
351+
This includes the split into set $T$ and $S$ before recursion, and the construction of the bit matrix, $b_{i,j}$, to keep track of multiplications on individual elements.
352+
353+
354+
\subsubsection{Shuffle Security}
355+
As mentioned in~\autoref{subsec:approach-shuffle-security}, the theoretically proven bound, on the necessary number of shuffles to ensure security is too high.
356+
Hence, as also done in~\cite{cryptoeprint:2022/560}, we implement an experiment to find the bounds, where the shuffle is secure.
357+
The goal of the experimental code is to find the number of honest shuffles required for security.
358+
359+
We inherit the authors of the shuffle's terminology, and interpret each ciphertext as a cup that can contain water.
360+
Each cup contains an amount of water between 0 and 1.
361+
362+
An experiment run starts with the first cup being full and the rest being empty.
363+
As mentioned, $\alpha$ cups are tracked by an adversary, the first $n-\alpha$ cups are called active cups, while the last $\alpha$ cups are tracked.
364+
So, at each shuffle, the shuffler randomly picks $k$ ciphertexts and shuffles them, also randomly.
365+
Meanwhile, an average of the water between the active indices of the $k$-shuffle is found.
366+
All active indices are given this amount of water.
367+
368+
Now, after each shuffle, if any cup has more than $\frac{2}{n-\alpha}$ water, its position can be predicted by the adversary, hence the shuffle is insecure~\cite{cryptoeprint:2022/560}.
369+
If a position can be predicted, another round of shuffling is performed.
370+
This method is used until no cup exceeds the threshold, after which the shuffle is deemed secure.
371+
372+
The experiment denotes how many rounds it took before the shuffle was secure.
257373

374+
By repeating this experiment for several runs, one can experimentally say, when a shuffle with given parameters is secure.
258375

0 commit comments

Comments
 (0)