Debian Codegraph @

texmf-dist/source/latex/cryptocode/cryptocode.dtx

raw
1 %\iffalse
2 %<*package>
3 \NeedsTeXFormat{LaTeX2e}
4 \DeclareRelease{v0.30}{2018-11-11}{cryptocode-2018-11-11.sty}
5 \DeclareRelease{v0.32}{2020-04-24}{cryptocode-2020-04-24.sty}
6 \DeclareCurrentRelease{v0.44}{2021-08-15}
7 \ProvidesPackage{cryptocode}
8 [2021/08/15 v0.44 Cryptocode LaTeX package for typesetting pseudocode, algorithms and protocols as well as cryptographic proofs.]
9 %</package>
10 %\fi
11 % \iffalse
12 % Doc-Source file to use with LaTeX2e
13 % Copyright (C) 2021 Arno Mittelbach, all rights reserved.
14 % \fi
15 % \iffalse
16 %<*driver>
17 \documentclass{ltxdoc}
18 \usepackage[T1]{fontenc}
19 \usepackage{lmodern}
20 \usepackage[usenames]{xcolor}
21 \usepackage{hypdoc}
22 \usepackage[
23 n,
24 operators,
25 advantage,
26 sets,
27 adversary,
28 landau,
29 probability,
30 notions,
31 logic,
32 ff,
33 mm,
34 primitives,
35 events,
36 complexity,
37 oracles,
38 asymptotics,
39 keys]{cryptocode}
40
41 \createpseudocodeblock{pcb}{center,boxed}{}{}{}
42 \createprocedureblock{procb}{center,boxed}{}{}{}
43 \usepackage{csquotes}
44 \usepackage{fullpage}
45 \usepackage{dashbox}
46 \usepackage{textcomp}
47 \usepackage{url}
48 \usepackage{xspace}
49
50 \usetikzlibrary{shapes.callouts}
51
52 \usepackage{listings}
53
54 \usepackage{trace}
55
56 \usepackage{makeidx}
57 \usepackage{mdframed}
58
59 \definecolor{mygreen}{rgb}{0,0.6,0}
60 \definecolor{mygray}{rgb}{0.1,0.1,0.1}
61 \definecolor{verylightgray}{rgb}{0.9,0.9,0.9}
62 \definecolor{mymauve}{rgb}{0.58,0,0.82}
63
64 \let\amipagebreak\pagebreak
65
66 \setlength{\textwidth}{386pt}
67 \addtolength\marginparwidth{50pt}
68 \addtolength\oddsidemargin{40pt}
69 \addtolength\evensidemargin{40pt}
70
71 \lstset{language=[LaTeX]TeX,
72 backgroundcolor=\color{verylightgray}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
73 rulecolor=\color{lightgray},
74 basicstyle=\scriptsize, % the size of the fonts that are used for the code
75 breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
76 breaklines=true, % sets automatic line breaking
77 captionpos=b, % sets the caption-position to bottom
78 commentstyle=\color{mygreen}, % comment style
79 escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
80 extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
81 frame=single, % adds a frame around the code
82 keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
83 keywordstyle=\color{blue}, % keyword style
84 numbers=left, % where to put the line-numbers; possible values are (none, left, right)
85 numbersep=5pt, % how far the line-numbers are from the code
86 numberstyle=\scriptsize\color{mygray}, % the style that is used for the line-numbers
87 rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
88 showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
89 showstringspaces=false, % underline spaces within strings only
90 showtabs=false, % show tabs within strings adding particular underscores
91 stepnumber=1, % the step between two line-numbers. If it's 1, each line will be numbered
92 stringstyle=\color{mymauve}, % string literal style
93 frameround=ftff,
94 belowskip=-0.8 \baselineskip,
95 aboveskip=1em,
96 tabsize=2, % sets default tabsize to 2 spaces
97 title=\lstname }
98
99 \EnableCrossrefs
100 \CodelineIndex
101 \RecordChanges
102 \begin{document}
103 \DocInput{cryptocode.dtx}
104 \end{document}
105 %</driver>
106 %\fi
107 %
108 % \changes{v0.10}{2015/03/30}{Initial version}
109 % \changes{v0.11}{2016/11/30}{changed command pckeystyle to ensure that subscripts on $\sk$ and $\pk$ are aligned the same
110 % before, $(\sk_R, \pk_R)$ had slightly misaligned subscripts due to Tex treating
111 % subscripts on composite objects with descenders differently than without.}
112 % ^^A see \url{https://groups.google.com/forum/#!msg/comp.text.tex/IaXu_xBG06Q/CibRPH5GCAAJ}
113 %
114 % \changes{v0.11}{2016/11/30}{Added \textbackslash{}NAND command.}
115 % \changes{v0.11}{2016/11/30}{Added \emph{pcmbox} environment for matrices in pseudocode.}
116 %
117 % \changes{v0.20}{2016/12/02}{Changed \emph{minheight} for bbrbox environment to actually reflect a minimum height in tikz.
118 % The old minheight which added space at the bottom was preserved as \emph{addheight}.}
119 % \changes{v0.20}{2016/12/02}{Added namepos middle for bbrbox.}
120 % \changes{v0.20}{2016/12/02}{Added \textbackslash{}pcfail.}
121 % \changes{v0.20}{2016/12/02}{Added valign to pseudocode to allow minipage vertical alignment.}
122 % \changes{v0.20}{2016/12/02}{Ensure line numbers are right aligned to allow for two digit linenumbers having the same width.}
123 %
124 % \changes{v0.04}{2017/08/26}{added \textbackslash{}pcabort.}
125 % \changes{v0.04}{2017/08/26}{better control whitespace for \textbackslash{}pcif, \textbackslash{}pcelse, \textbackslash{}pcelseif.}
126 %
127 % \changes{v0.05}{2017/10/02}{side and oside support to \textbackslash{}bbroracleqryto and \textbackslash{}bbroracleqryfrom}
128 % \changes{v0.05}{2017/10/02}{add bottom to namepos in bbrbox}
129 % \changes{v0.05}{2017/10/02}{names for brrinput and bbroutput}
130 % \changes{v0.05}{2017/10/02}{angle for bbrloop}
131 % \changes{v0.05}{2017/10/02}{fix length for bbrinput}
132 % \changes{v0.05}{2017/10/02}{introduce hoffset for bbrinput}
133 %
134 % \changes{v0.06}{2017/12/21}{added \textbackslash{}pcunless}
135 %
136 % \changes{v0.30}{2018/11/11}{replace obsolete l3regex}
137 %
138 % \changes{v0.31}{2018/11/26}{added \textbackslash{}tprob (variants for prob and co for in-text)}
139 % \changes{v0.31}{2018/11/26}{added \textbackslash{}prp}
140 %
141 % \changes{v0.32}{2020/01/11}{allow to control spacing with \textbackslash{}pcfor}
142 % \changes{v0.32}{2020/01/11}{allow overwriting rule command in pseudocode via headlinecmd (defaults to \textbackslash{}hrule)}
143 %
144 % \changes{v0.40}{2020/07/10}{Bigger refactoring. Not completely backwards compatible. In particular, optimized spacing of pseudocode blocks and black box reductions.}
145 % \changes{v0.40}{2020/07/10}{Switched to mathtools \emph{DeclarePairedDelimiter} for paired operators.
146 % Each paired operator comes in two forms, e.g, \emph{abs} and \emph{tabs} the latter to be used in flowtext
147 % which does not scale the outer delimiters.}
148 % \changes{v0.40}{2020/07/10}{Adjusted spacing via \textbackslash{}pcaboveskip and \textbackslash{}pcbelowskip which are
149 % added to \textbackslash{}pseudocode blocks and \emph{pchstack} environments}
150 % \changes{v0.40}{2020/07/10}{Added block forms for pseudocode and procedure commands (\textbackslash{}pseudocodeblock and \textbackslash{}procedureblock).}
151 % \changes{v0.40}{2020/07/10}{Added minlineheight option to \textbackslash{}pseudocode.}
152 % \changes{v0.40}{2020/07/10}{Added headheight option to \textbackslash{}pseudocode.}
153 % \changes{v0.40}{2020/07/10}{Added \textbackslash{}argmax and \textbackslash{}argmin to operators.}
154 % \changes{v0.40}{2020/07/10}{Added \textbackslash{}pindist, \textbackslash{}sindist, and \textbackslash{}cindist to operators.}
155 % \changes{v0.40}{2020/07/10}{Added aboveskip and belowskip option to \textbackslash{}pchstack and \textbackslash{}pcvstack.}
156 % \changes{v0.40}{2020/07/10}{Added boxed, inline, noindent options to \textbackslash{}pchstack and \textbackslash{}pcvstack.}
157 % \changes{v0.40}{2020/07/10}{Added space option to \textbackslash{}pchstack and \textbackslash{}pcvstack.}
158 % \changes{v0.40}{2020/07/10}{Renamed horizontal spacing commands \textbackslash{}beforepcskip and \textbackslash{}afterpcskip to \textbackslash{}pcbeforeskip and \textbackslash{}pcafterskip.}
159 % \changes{v0.40}{2020/07/10}{Added command \textbackslash{}pcsetargs to define default arguments for pseudocode blocks.}
160 % \changes{v0.40}{2020/07/10}{Added command \textbackslash{}pcsethstackargs and \textbackslash{}pcsetvstackargs to define default arguments for hstack and vstack environments.}
161 % \changes{v0.40}{2020/07/10}{Adapted bbrenv environment to take key value option list. Old format is still supported but deprecated.}
162 % \changes{v0.40}{2020/07/10}{Added additional polynomials.}
163 % \changes{v0.40}{2020/07/10}{Added additional adversaries.}
164 % \changes{v0.40}{2020/07/10}{Added additional complexity classes.}
165 % \changes{v0.40}{2020/07/10}{Added oracles package option.}
166 % \changes{v0.40}{2020/07/10}{Fixed spacing issues with black box reduction messages.}
167 % \changes{v0.40}{2020/07/10}{Added clockwise, leftstyle, centerstyle, rightstyle for bbrloop. Adjusted placing of center.}
168 % \changes{v0.40}{2020/07/10}{Added fixedoffset, fixedboffset, islast for reduction messages.}
169 %
170 % \changes{v0.41}{2020/07/13}{Fixed horizontal spacing in bbrenv environment.}
171 %
172 % \changes{v0.42}{2020/10/15}{Added command \textbackslash{}pcassert.}
173 % \changes{v0.42}{2020/10/15}{More robust \textbackslash{}sample command that also works in subscripts.}
174 %
175 % \changes{v0.43}{2021/01/17}{Added support for cleveref via \textbackslash{}pcfixcleveref command.}
176 %
177 % \changes{v0.44}{2021/08/15}{Removed dependency on deprecated etex package.}
178 %
179 % \def\cryptocodeversion{v0.44}
180 %
181 %
182 %
183 % \author{Arno Mittelbach\\
184 % \texttt{[email protected]}\\
185 % \url{https://github.com/arnomi/cryptocode}\thanks{If you use cryptocode in your work, consider starring the repository on GitHub and/or rating it on CTAN.}}
186 % \title{\Huge Cryptocode \\ \large\textsc{Typesetting Cryptography} \\ \small{Version \cryptocodeversion}}
187 %
188 %
189 % \maketitle
190 %
191 %
192 %
193 %
194 % \begin{abstract}
195 % \thispagestyle{empty}
196 % The cryptocode package provides a set of macros to ease the typesetting of
197 % pseudocode, algorithms and protocols (such as the one below). In addition it comes with a wide range of tools to typeset cryptographic papers (hence the name).
198 % This includes simple predefined commands for typesetting probabilities and \enquote{commonly encountered math}
199 % as well as for concepts such as
200 % a security parameter $\secparam$ or advantage terms $\advantage{prf}{\adv,\prf} = \negl$. Furthermore, it includes
201 % environments to layout game-based proofs or black-box reductions.
202 %
203 % \vspace{2em}
204 % \begin{center}
205 % \fbox{
206 % \pseudocode{%
207 % \textbf{ Alice} \< \< \textbf{ Bob} \\[0.1\baselineskip][\hline]
208 % \<\< \\[-0.5\baselineskip]
209 % x \sample \ZZ_q \< \< \\
210 % X \gets g^x \<\< \\[-4ex]
211 % \< \sendmessageright*{\GG,q,g,X} \< \\[-2ex]
212 % \<\< y \sample \ZZ_q \\
213 % \<\< Y \gets g^y \\[-4ex]
214 % \< \sendmessageleft*{Y} \< \\
215 % \key_A \gets Y^x \<\< \key_B \gets X^y }
216 % }
217 % \end{center}
218 %
219 %
220 % \end{abstract}
221 % \newpage
222 %
223 % \pagenumbering{roman}
224 %
225 % \tableofcontents
226 % \thispagestyle{empty}
227 % \newpage
228 %
229 % \pagenumbering{arabic}
230 %
231 %
232 % \section{Cryptocode by Example}
233 %
234 % The cryptocode package provides a set of commands to ease the typesetting of
235 % pseudocode, protocols, game-based proofs and black-box reductions. In addition it comes
236 % with a large number of predefined commands. In this section we present the various features of
237 % cryptocode by giving small examples. But first, let's load the package
238 %
239 % \iffalse
240 %<*example>
241 % \fi
242 \begin{lstlisting}
243 \usepackage[
244 n, % or lambda
245 advantage,
246 operators,
247 sets,
248 adversary,
249 landau,
250 probability,
251 notions,
252 logic,
253 ff,
254 mm,
255 primitives,
256 events,
257 complexity,
258 oracles,
259 asymptotics,
260 keys
261 ]{cryptocode}\end{lstlisting}
262 % \iffalse
263 %</example>
264 % \fi
265 %
266 % Note that all the options refer to a set of commands. That is, without any options cryptocode will provide the mechanisms
267 % for writing pseudocode, protocols, game-based proofs and black-box reductions but not define additional commands,
268 % such as |\pk| or |\sk| (for typesetting public and private/secret keys) which are part of the keys option.
269 % We discuss the various options and associated commands in Section~\ref{chap:commands}.
270 %
271 %
272 % \subsection{Pseudocode}
273 % The cryptocode package tries to make writing pseudocode easy and enjoyable. The
274 % |\pseudocode| command takes a single parameter where you can start writing
275 % code in mathmode using \lstinline{\\} as line breaks. Following is an $\indcpa$ game
276 % definition using various commands from cryptocode to ease writing keys (\lstinline{\pk,\sk}),
277 % sampling (\lstinline{\sample}), and more:
278 %
279 % \medskip
280 % \pseudocode[linenumbering]{
281 % b \sample \bin \\
282 % (\pk,\sk) \sample \kgen (\secparam) \\
283 % (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \\
284 % c \sample \enc(\pk,m_b) \\
285 % b' \sample \adv(\secparam, \pk, c, \state) \\
286 % \pcreturn b = b' }
287 %
288 % \iffalse
289 %<*example>
290 % \fi
291 \begin{lstlisting}
292 \pseudocode[linenumbering]{
293 b \sample \bin \\
294 (\pk,\sk) \sample \kgen (\secparam) \\
295 (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \\
296 c \sample \enc(\pk,m_b) \\
297 b' \sample \adv(\secparam, \pk, c, \state) \\
298 \pcreturn b = b' }
299 \end{lstlisting}
300 % \iffalse
301 %</example>
302 % \fi
303 % \amipagebreak
304 %
305 % In many cases, we want to set pseudocode blocks in-between paragraphs with spacing
306 % similar to how we would offset equations. For this, and for laying out multiple code
307 % blocks, cryptocode offers \enquote{stacking} environments |\pchstack| and |\pcvstack|.
308 % For typesetting a code block nicely centered and boxed
309 % \begin{pchstack}[center,boxed]
310 % \pseudocode[linenumbering]{
311 % b \sample \bin \\
312 % (\pk,\sk) \sample \kgen (\secparam) \\
313 % (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \\
314 % c \sample \enc(\pk,m_b) \\
315 % b' \sample \adv(\secparam, \pk, c, \state) \\
316 % \pcreturn b = b' }
317 % \end{pchstack}
318 % you could thus use:
319 %
320 % \iffalse
321 %<*example>
322 % \fi
323 \begin{lstlisting}
324 \begin{pchstack}[center,boxed]
325 \pseudocode[linenumbering]{
326 b \sample \bin \\
327 (\pk,\sk) \sample \kgen (\secparam) \\
328 (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \\
329 c \sample \enc(\pk,m_b) \\
330 b' \sample \adv(\secparam, \pk, c, \state) \\
331 \pcreturn b = b' }
332 \end{pchstack}\end{lstlisting}
333 % \iffalse
334 %</example>
335 % \fi
336 %
337 % As this is a common task, cryptocode offers the |\pseudocodeblock| command which
338 % is a shorthand for the above (without the frame). In case you want to provide different
339 % options or a shorter command (say |\pcb|) you can easily define the command via
340 %
341 % \iffalse
342 %<*example>
343 % \fi
344 \begin{lstlisting}
345 \createpseudocodeblock{pcb}{center,boxed}{}{}{}
346 \end{lstlisting}
347 % \iffalse
348 %</example>
349 % \fi
350 % The above could now be written, more succinctly as
351 % \iffalse
352 %<*example>
353 % \fi
354 \begin{lstlisting}
355 \pcb[linenumbering]{
356 b \sample \bin \\
357 (\pk,\sk) \sample \kgen (\secparam) \\
358 (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \\
359 c \sample \enc(\pk,m_b) \\
360 b' \sample \adv(\secparam, \pk, c, \state) \\
361 \pcreturn b = b'
362 }\end{lstlisting}
363 % \iffalse
364 %</example>
365 % \fi
366 %
367 %
368 % The pseudocode command (and its block variant) takes a single mandatory argument (the code) plus an optional argument
369 % which allows you to specify options in a key=value fashion. In the above example we used the linenumbering
370 % option.
371 %
372 % \medskip
373 %
374 % It is easy to define a heading for your code. Either specify the header using the option \enquote{head} or use
375 % the |\procedure| command (or its block variant |\procedureblock|) which takes an additional argument to specify the headline.
376 %
377 % \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secpar)$}{
378 % b \sample \bin \\
379 % (\pk,\sk) \sample \kgen (\secparam) \\
380 % (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \\
381 % c \sample \enc(\pk,m_b) \\
382 % b' \sample \adv(\secparam, \pk, c, \state) \\
383 % \pcreturn b = b' }
384 %
385 % \iffalse
386 %<*example>
387 % \fi
388 \begin{lstlisting}
389 \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secpar)$}{
390 b \sample \bin \\
391 (\pk,\sk) \sample \kgen (\secparam) \\
392 (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \\
393 c \sample \enc(\pk,m_b) \\
394 b' \sample \adv(\secparam, \pk, c, \state) \\
395 \pcreturn b = b' }
396 \end{lstlisting}
397 % \iffalse
398 %</example>
399 % \fi
400 %
401 % Similarly to before, we can define a shorthand and boxed variant as
402 % \iffalse
403 %<*example>
404 % \fi
405 \begin{lstlisting}
406 \createprocedureblock{procb}{center,boxed}{}{}{}
407 \end{lstlisting}
408 % \iffalse
409 %</example>
410 % \fi
411 %
412 %
413 % There is a lot more that we will discuss in detail in Section~\ref{chap:pseudocode}. Here, for example,
414 % is the same code with an overlay explanation and a division of the pseudocode.
415 %
416 % \begin{pcimage}
417 % \procb[linenumbering]{$\indcpa_\enc^\adv(\secpar)$}{
418 % b \sample \bin \\
419 % (\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen} \pclb
420 % \pcintertext[dotted]{Setup Completed}
421 % (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
422 % c \sample \enc(\pk,m_b) \\
423 % b' \sample \adv(\secparam, \pk, c, \state) \\
424 % \pcreturn b = b' }
425 %
426 % \pcdraw{
427 % \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
428 % at ([shift={(+3,-1)}]kgen) {
429 % \begin{varwidth}{3cm}
430 % $\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
431 % \end{varwidth}
432 % };
433 % }
434 % \end{pcimage}
435 %
436 %
437 % \iffalse
438 %<*example>
439 % \fi
440 \begin{lstlisting}
441 \begin{pcimage}
442 \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secpar)$}{%
443 b \sample \bin \\
444 (\pk,\sk) \sample \kgen(\secparam)\pcnode{kgen} \pclb
445 \pcintertext[dotted]{Setup Completed}
446 (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
447 c \sample \enc(\pk,m_b) \\
448 b' \sample \adv(\secparam, \pk, c, \state) \\
449 \pcreturn b = b' }
450
451 \pcdraw{
452 \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
453 at ([shift={(+3,-1)}]kgen) {
454 \begin{varwidth}{3cm}
455 $\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
456 \end{varwidth}
457 };
458 }
459 \end{pcimage}
460 \end{lstlisting}
461 % \iffalse
462 %</example>
463 % \fi
464 %
465 % \subsection{Stacking}
466 %
467 % To arrange multiple procedures, cryptocode offers horizontal and vertical stacking
468 % environments |\pchstack| and |\pcvstack|. In the example below we arrange four
469 % code blocks in three columns equispaced with 1cm distance and stack two procedures
470 % in the center column.
471 %
472 % \begin{pchstack}[center,space=1cm]
473 % \procedure{A}{
474 % a \sample A \\
475 % \pcreturn a
476 % }
477 %
478 % \begin{pcvstack}[boxed,space=0.5cm]
479 % \procedure{B.1}{
480 % b \sample B \\
481 % \pcreturn b
482 % }
483 % \procedure{B.1}{
484 % b \sample B \\
485 % \pcreturn b
486 % }
487 % \end{pcvstack}
488 %
489 % \procedure{C}{
490 % c \sample C \\
491 % \pcreturn c
492 % }
493 % \end{pchstack}
494 %
495 % \iffalse
496 %<*example>
497 % \fi
498 \begin{lstlisting}
499 \begin{pchstack}[center,space=1cm]
500 \procedure{A}{
501 a \sample A \\
502 \pcreturn a
503 }
504
505 \begin{pcvstack}[boxed,space=0.5cm]
506 \procedure{B.1}{
507 b \sample B \\
508 \pcreturn b
509 }
510 \procedure{B.1}{
511 b \sample B \\
512 \pcreturn b
513 }
514 \end{pcvstack}
515
516 \procedure{C}{
517 c \sample C \\
518 \pcreturn c
519 }
520 \end{pchstack}
521 \end{lstlisting}
522 % \iffalse
523 %</example>
524 % \fi
525 %
526 % \subsection{Columns}
527 % The |\pseudocode| and |\procedure| commands allow the usage of multiple columns.
528 % You switch to a new column by inserting a |\>|. This is similar to using an |align|
529 % environment and placing a tabbing \& character.\footnote{In fact, the \emph{pseudocode} command
530 % is based on amsmath's flalign environment.}
531 % \pcb{
532 % \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
533 % b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
534 % \iffalse
535 %<*example>
536 % \fi
537 \begin{lstlisting}
538 \pseudocodeblock{%
539 \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
540 b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
541 \end{lstlisting}
542 % \iffalse
543 %</example>
544 % \fi
545 % As you can see the first column is left aligned the second right, the third left and so forth.
546 % In order to get only left aligned columns you could thus always skip a column by
547 % using |\>\>| or you can alternatively use |\<| as a shorthand for |\>\>|.
548 % \pcb{
549 % \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
550 % b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
551 %
552 % \subsection{Protocols}
553 % Using columns makes it easy to write even complex protocols. Following is a simple
554 % three-party protocol.
555 % \pcb{
556 % \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\[][\hline]
557 % \text{work} \< \< \< \< \\
558 % \< \sendmessageright{top=Work result,topstyle=red} \< \< \< \\
559 % \< \< \text{work} \< \< \\
560 % \< \< \< \sendmessageright{top=Work result,bottom=Bottom message} \< \\
561 % \< \< \< \< \text{work} \\
562 % \< \sendmessageleftx{8}{\text{A long message for Alice}} \< \\
563 % \text{finalize} \< \< \< \< }
564 % \iffalse
565 %<*example>
566 % \fi
567 \begin{lstlisting}
568 \pseudocodeblock{
569 \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\[][\hline]
570 \text{work} \< \< \< \< \\
571 \< \sendmessageright{top=Work result,topstyle=red} \< \< \< \\
572 \< \< \text{work} \< \< \\
573 \< \< \< \sendmessageright{top=Work result,bottom=Bottom message} \< \\
574 \< \< \< \< \text{work} \\
575 \< \sendmessageleftx{8}{\text{A long message for Alice}} \< \\
576 \text{finalize} \< \< \< \< }
577 \end{lstlisting}
578 % \iffalse
579 %</example>
580 % \fi
581 % The commands |\sendmessageright| and |\sendmessageleft| are very flexible and
582 % allow to style the sending of messages in various ways. Also note the |\\[][\hline]| at the end of the
583 % first line. Here the first optional argument allows us to specify the lineheight (similarly to the behavior in an
584 % align environment) while the second optional argument allows us to, for example, draw a horizontal line.
585 %
586 % \medskip
587 % In multi-player protocols such as the one
588 % above the commands |\sendmessagerightx| and |\sendmessageleftx| (note the x at the end)
589 % allow to send messages over multiple columns. In the example, as we were using |\<| the
590 % final message thus spans 8 columns.
591 %
592 % \medskip
593 % For basic protocols you might also utilize the |\sendmessageright*| and |\sendmessageleft*|
594 % commands which simply take a message which is displayed (in math mode) on top.
595 % \pcb{
596 % \textbf{ Alice} \< \< \textbf{ Bob} \\[0.1\baselineskip][\hline]
597 % \<\< \\[-0.5\baselineskip]
598 % x \sample \ZZ_q \< \< \\
599 % X \gets g^x \<\< \\
600 % \< \sendmessageright*{\GG,q,g,X} \< \\
601 % \<\< y \sample \ZZ_q \\
602 % \<\< Y \gets g^y \\
603 % \< \sendmessageleft*{Y} \< \\
604 % \key_A \gets Y^x \<\< \key_B \gets X^y
605 % }
606 % \iffalse
607 %<*example>
608 % \fi
609 \begin{lstlisting}
610 \pseudocodeblock{
611 \textbf{ Alice} \< \< \textbf{ Bob} \\[0.1\baselineskip][\hline]
612 \<\< \\[-0.5\baselineskip]
613 x \sample \ZZ_q \< \< \\
614 X \gets g^x \<\< \\
615 \< \sendmessageright*{\GG,q,g,X} \< \\
616 \<\< y \sample \ZZ_q \\
617 \<\< Y \gets g^y \\
618 \< \sendmessageleft*{Y} \< \\
619 \key_A \gets Y^x \<\< \key_B \gets X^y }
620 \end{lstlisting}
621 % \iffalse
622 %</example>
623 % \fi
624 % We will discuss protocols in greater detail in Section~\ref{chap:protocols}.
625 %
626 % \subsection{Game-Based Proofs}
627 % Cryptocode supports authors in visualizing game-based proofs. It defines an environment
628 % |gameproof| which allows to wrap a number of game procedures displaying helpful
629 % information as to what changes from game to game and to what each step is reduced.
630 %
631 %\begin{gameproof}
632 % \begin{pchstack}[center,space=1em]
633 % \gameprocedure[linenumbering,minlineheight=1.5em]{%
634 % \text{Step 1} \\
635 % \\
636 % \text{Step 2}
637 % }
638 %
639 % \tbxgameprocedure[minlineheight=1.5em]{%
640 % \text{Step 1} \\
641 % \pcbox{\text{From game 3 on}} \\
642 % \gamechange{\text{Step 3 is different}}
643 % }
644 %
645 % \gameprocedure[minlineheight=1.5em]{%
646 % \text{Step 1} \\
647 % \text{From game 3 on}\\
648 % \text{\gamechange{Step 3 adapted again}}
649 % }
650 %
651 % \end{pchstack}
652 %\end{gameproof}
653 % \iffalse
654 %<*example>
655 % \fi
656 \begin{lstlisting}
657 \begin{gameproof}
658 \begin{pchstack}[center,space=1em]
659 \gameprocedure[linenumbering,minlineheight=1.5em]{%
660 \text{Step 1} \\
661 \\
662 \text{Step 3}
663 }
664
665 \tbxgameprocedure[minlineheight=1.5em]{%
666 \text{Step 1} \\
667 \pcbox{\text{From game 3 on}} \\
668 \gamechange{\text{Step 3 is different}}
669 }
670
671 \gameprocedure[minlineheight=1.5em]{%
672 \text{Step 1} \\
673 \text{From game 3 on}\\
674 \text{\gamechange{Step 3 adapted again}}
675 }
676
677 \end{pchstack}
678 \end{gameproof}
679 \end{lstlisting}
680 % \iffalse
681 %</example>
682 % \fi
683 % Note that we made use of the option \enquote{mode=text} in the above example which tells the underlying pseudocode
684 % command to not work in math mode but in plain text mode. We will discuss how to visualize game-based proofs in Section~\ref{chap:gbproofs}.
685 %
686 % \subsection{Black-Box Reductions}
687 % Cryptocode provides a strucured syntax to visualize black-box reductions. Basically cryptocode
688 % provides an environment to draw boxes that may have oracles and/or challengers and that can be communicated with.
689 % Cryptocode makes heavy use of TIKZ (\url{https://www.ctan.org/pkg/pgf}) for this, which gives you
690 % quite some control over how things should look like. Additionally, as you can specify node names
691 % (for example the outer box in the next example is called \enquote{A}) you can easily extend the pictures
692 % by using plain TIKZ commands. Following is an example reduction. We discuss the details in Section~\ref{chap:bbr}.
693 %
694 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
695 % \begin{bbrbox}[name=Reduction]
696 % \pseudocode{
697 % \text{Do something} \\
698 % \text{Step 2}
699 % }
700 %
701 % \begin{bbrenv}{B}
702 % \begin{bbrbox}[name=Adversary,minheight=2.25cm]
703 % \end{bbrbox}
704 %
705 % \bbrmsgto{top=$m$}
706 % \bbrmsgfrom{top=$\sigma$}
707 % \bbrmsgtxt{\pseudocode{%
708 % \text{more work}
709 % }}
710 % \bbrmsgto{top=$m$}
711 % \bbrmsgfrom{top=$\sigma$}
712 %
713 % \bbrqryto{side=$m$}
714 % \bbrqryfrom{side=$b$}
715 % \end{bbrenv}
716 %
717 % \pseudocode{
718 % \text{finalize}
719 % }
720 %
721 % \end{bbrbox}
722 % \bbrinput{input}
723 % \bbroutput{output}
724 %
725 % \begin{bbroracle}{OraA}
726 % \begin{bbrbox}[name=Oracle 1,minheight=1cm]
727 % \end{bbrbox}
728 % \end{bbroracle}
729 % \bbroracleqryto{top=$m$}
730 % \bbroracleqryfrom{top=$b$}
731 %
732 % \begin{bbroracle}{OraB}
733 % \begin{bbrbox}[name=Oracle 2,minheight=1cm]
734 % \end{bbrbox}
735 % \end{bbroracle}
736 % \bbroracleqryto{top=$m$}
737 % \bbroracleqryfrom{top=$b$}
738 % \end{bbrenv}
739 % \iffalse
740 %<*example>
741 % \fi
742 \begin{lstlisting}
743 \begin{bbrenv}{A}
744 \begin{bbrbox}[name=Reduction]
745 \pseudocode{
746 \text{Do something} \\
747 \text{Step 2}
748 }
749
750 \begin{bbrenv}{B}
751 \begin{bbrbox}[name=Adversary,minheight=2.25cm]
752 \end{bbrbox}
753
754 \bbrmsgto{top=$m$}
755 \bbrmsgfrom{top=$\sigma$}
756 \bbrmsgtxt{\pseudocode{%
757 \text{more work}
758 }}
759 \bbrmsgto{top=$m$}
760 \bbrmsgfrom{top=$\sigma$}
761
762 \bbrqryto{side=$m$}
763 \bbrqryfrom{side=$b$}
764 \end{bbrenv}
765
766 \pseudocode{
767 \text{finalize}
768 }
769
770 \end{bbrbox}
771 \bbrinput{input}
772 \bbroutput{output}
773
774 \begin{bbroracle}{OraA}
775 \begin{bbrbox}[name=Oracle 1,minheight=1cm]
776 \end{bbrbox}
777 \end{bbroracle}
778 \bbroracleqryto{top=$m$}
779 \bbroracleqryfrom{top=$b$}
780
781 \begin{bbroracle}{OraB}
782 \begin{bbrbox}[name=Oracle 2,minheight=1cm]
783 \end{bbrbox}
784 \end{bbroracle}
785 \bbroracleqryto{top=$m$}
786 \bbroracleqryfrom{top=$b$}
787 \end{bbrenv}
788 \end{lstlisting}
789 % \iffalse
790 %</example>
791 % \fi
792 %
793 % \amipagebreak
794 % \section{Notation Macros}
795 % \label{chap:commands}
796 % \index{package options}
797 % In this section we'll discuss the various commands for notation that can be
798 % loaded via package options.
799 % \iffalse
800 %<*example>
801 % \fi
802 \begin{lstlisting}
803 \usepackage[
804 n, % or lambda
805 advantage,
806 operators,
807 sets,
808 adversary,
809 landau,
810 probability,
811 notions,
812 logic,
813 ff,
814 mm,
815 primitives,
816 events,
817 complexity,
818 oracles,
819 asymptotics,
820 keys
821 ]{cryptocode}
822 \end{lstlisting}
823 % \iffalse
824 %</example>
825 % \fi
826 %
827 % \textbf{Remark. }
828 % Note that the available command sets are far from complete and
829 % reflect my own work (especially once you get to cryptographic notions and primitives).
830 % In case you feel that something should be added feel free to drop me an email,
831 % or better yet, open an issue and pull request on github (\url{https://github.com/arnomi/cryptocode}).
832 %
833 % \subsection{Security Parameter}
834 % \index{security parameter|see {package options}}
835 % \index{package options!security parameter}
836 % In cryptography we make use of a security parameter which is usually denoted by $1^n$ or $1^\lambda$. The cryptocode
837 % package, when loading either option \enquote{n} or option \enquote{lambda} will define the commands
838 % \iffalse
839 %<*example>
840 % \fi
841 \begin{lstlisting}
842 \secpar
843 \secparam
844 \SECPAR
845 \end{lstlisting}
846 % \iffalse
847 %</example>
848 % \fi
849 % The first command provides the \enquote{letter}, i.e., either $n$ or $\lambda$, whereas |\secparam| prints
850 % |\1^\secpar| (i.e., $\secparam$ for option \enquote{n}). Finally, |\SECPAR| yields $N_0$ (resp.~$\Lambda$)
851 % and is meant to be used in sentences such as, \enquote{there exists $\SECPAR\in\NN$ such that for all $\secpar \geq \SECPAR$, ...}
852 %
853 % \subsection{Advantage Terms}
854 % Load the package option ``advantage'' in order to define the command |\advantage| used to specify advantage terms such as:
855 % \[
856 % \advantage{prf}{\adv,\prf}
857 % \]
858 % \iffalse
859 %<*example>
860 % \fi
861 \begin{lstlisting}
862 \advantage{prf}{\adv,\prf}
863 \end{lstlisting}
864 % \iffalse
865 %</example>
866 % \fi
867 % Specify an optional third parameter to replace the $(\secpar)$.
868 % \iffalse
869 %<*example>
870 % \fi
871 \begin{lstlisting}
872 \advantage{prf}{\adv,\prf}[(arg)]
873 \end{lstlisting}
874 % \iffalse
875 %</example>
876 % \fi
877 % In order to redefine the styles in which superscript and subscript are set, or in case
878 % you want to replace the term $\pcadvantagename$, redefine:
879 % \iffalse
880 %<*example>
881 % \fi
882 \begin{lstlisting}
883 \renewcommand{\pcadvantagename}{\mathsf{Adv}}
884 \renewcommand{\pcadvantagesuperstyle}[1]{\mathrm{\MakeLowercase{#1}}}
885 \renewcommand{\pcadvantagesubstyle}[1]{#1}
886 \end{lstlisting}
887 % \iffalse
888 %</example>
889 % \fi
890 %
891 % \subsection{Math Operators}
892 % \index{operators|see {package options}}
893 % \index{package options!operators}
894 % \index{math operators|see {package options}}
895 % \index{\textbackslash{} sample}
896 % \index{\textbackslash{} floor}
897 % \index{\textbackslash{} tfloor}
898 % \index{\textbackslash{} ceil}
899 % \index{\textbackslash{} tceil}
900 % \index{\textbackslash{} Angle}
901 % \index{\textbackslash{} tAngle}
902 % \index{\textbackslash{} abs}
903 % \index{\textbackslash{} tabs}
904 % \index{\textbackslash{} norm}
905 % \index{\textbackslash{} tnorm}
906 % \index{\textbackslash{} concat}
907 % \index{\textbackslash{} emptystring}
908 % \index{\textbackslash{} argmax}
909 % \index{\textbackslash{} argmin}
910 % \index{\textbackslash{} pindist}
911 % \index{\textbackslash{} cindist}
912 % \index{\textbackslash{} sindist}
913 % The \enquote{operators} option provides the following list of commands:
914 %
915 % \begin{center}
916 % \begin{tabular}{l p{5cm} l l}
917 % \textbf{Command} & \textbf{Description} & \textbf{Result} & \textbf{Example} \\\hline
918 % |\sample| & Sampling from a distribution, or running a randomized procedure & $\sample$ & $b \sample \bin$ \\
919 % |\floor{42.5}| & Rounding down & $\floor{42.5}$ & \\
920 % |\ceil{41.5}| & Rounding up & $\ceil{41.5}$ & \\
921 % |\Angle{x,y}| & Vector product & $\Angle{x,y}$ & \\
922 % |\abs{\frac{a}{b}}| & Absolute number & $\abs{\frac{a}{b}}$ & \\
923 % |\norm{x}| & Norm & $\norm{x}$ & \\
924 % |\concat| & Verbose concatenation (I usually prefer simply \verb$\|$) & $\concat$ & $x \gets a\concat b$ \\
925 % |\emptystring| & The empty string & $\emptystring$ & $x \gets \emptystring$ \\
926 % |\argmax| & arg max & $\argmax$ & $\argmax_{x \in S} f(x)$ \\
927 % |\argmin| & arg min & $\argmin$ & $\argmin_{x \in S} f(x)$ \\
928 % |\pindist| & Perfect indistinguishability & $\pindist$ & $X \pindist Y$ \\
929 % |\sindist| & Statistical indistinguishability & $\sindist$ & $X \sindist Y$ \\
930 % |\cindist| & Computational indistinguishability & $\cindist$ & $X \cindist Y$
931 % \end{tabular}
932 % \end{center}
933 %
934 % The paired operators |\floor|, |\ceil|, |\Angle|, |\norm|, and |\abs| also
935 % come in a form for flow text which does not scale the outer delimter. These
936 % are |\tfloor|, |\tceil|, |\tAngle|, |\tnorm|, and |\tabs|.
937 %
938 % Note that $\argmax$ and $\argmin$ in block formulas will set their subscripts as limits, i.e.,:
939 %
940 % \[ \argmax_{x \in S} f(x) \]
941 %
942 % \subsection{Adversaries}
943 % \index{adversary|see {package options}}
944 % \index{package options!adversary}
945 % The \enquote{adversary} option provides the following list of commands:
946 %
947 % \begin{center}
948 % \begin{tabular}{l l l}
949 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
950 % |\adv| & Adversary & $\adv$ \\
951 % |\bdv| & Adversary & $\bdv$ \\
952 % |\cdv| & Adversary & $\cdv$ \\
953 % |\ddv| & Adversary & $\ddv$ \\
954 % |\edv| & Adversary & $\edv$ \\
955 % |\mdv| & Adversary & $\mdv$ \\
956 % |\pdv| & Adversary & $\pdv$ \\
957 % |\rdv| & Adversary & $\rdv$ \\
958 % |\sdv| & Adversary & $\sdv$
959 % \end{tabular}
960 % \end{center}
961 %
962 % \noindent The style in which an adversary is rendered is controlled via
963 % \iffalse
964 %<*example>
965 % \fi
966 \begin{lstlisting}
967 \renewcommand{\pcadvstyle}[1]{\ensuremath{\mathcal{#1}}}
968 \end{lstlisting}
969 % \iffalse
970 %</example>
971 % \fi
972 %
973 %
974 % \subsection{Landau}
975 % \index{Landau|see {package options}}
976 % \index{package options!Landau}
977 % The \enquote{landau} option provides the following list of commands:
978 %
979 % \begin{center}
980 % \begin{tabular}{l l l}
981 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
982 % |\bigO{n^2}| & Big O(micron) notation & $\bigO{n^2}$ \\
983 % |\smallO{n^2}| & small o(micron) notation & $\smallO{n^2}$ \\
984 % |\bigOmega{n^2}| & Big Omega notation & $\bigOmega{n^2}$ \\
985 % |\bigTheta{n^2}| & Big Theta & $\bigTheta{n^2}$ \\
986 % |\orderOf| & On the order of & $f(n) \orderOf g(n)$
987 % \end{tabular}
988 % \end{center}
989 %
990 %
991 % \subsection{Probabilities}
992 % \index{probability|see {package options}}
993 % \index{package options!probabilities}
994 % The \enquote{probability} option provides commands for writing probabilities. Use
995 % \iffalse
996 %<*example>
997 % \fi
998 \begin{lstlisting}
999 \prob{X=x}
1000 \probsub{x\sample{\bin^n}}{x=5}
1001 \condprob{X=x}{A=b}
1002 \condprobsub{x\sample{\bin^n}}{x=5}{A=b}
1003 \end{lstlisting}
1004 % \iffalse
1005 %</example>
1006 % \fi
1007 % to write basic probabilities, probabilities with explicit probability spaces and conditional probabilities.
1008 % \begin{align*}
1009 % & \prob{X=x} \\
1010 % & \probsub{x\sample{\bin^n}}{X=x} \\
1011 % & \condprob{X=x}{A=b} \\
1012 % & \condprobsub{x\sample{\bin^n}}{x=5}{A=b}
1013 % \end{align*}
1014 % You can control the probability symbol (Pr) by redefining
1015 % \iffalse
1016 %<*example>
1017 % \fi
1018 \begin{lstlisting}
1019 \renewcommand{\probname}{Pr}
1020 \end{lstlisting}
1021 % \iffalse
1022 %</example>
1023 % \fi
1024 % The probability commands have a flowtext version |\tprob{X=X}| or |\tcondprob{X=x}{Y=y}|
1025 % which does not scale the delimiters.
1026 % In case the probability space is more complex, you can use
1027 % \iffalse
1028 %<*example>
1029 % \fi
1030 \begin{lstlisting}
1031 \probsublong{x,y\sample\set{1,2,3,4,5,6}, z = x + y}{z = 7}
1032 \end{lstlisting}
1033 % \iffalse
1034 %</example>
1035 % \fi
1036 % which yields
1037 % \[ \probsublong{x,y\sample\set{1,2,3,4,5,6}, z = x + y}{z = 7}.\]
1038 %
1039 %
1040 % For specifying expectations the following commands are defined
1041 % \iffalse
1042 %<*example>
1043 % \fi
1044 \begin{lstlisting}
1045 \expect{X}
1046 \expsub{x,y\sample\set{1,\ldots,6}}{x+y}
1047 \condexp{X+Y}{Y>3}
1048 \condexpsub{x,y\sample\set{1,\ldots,6}}{x+y}{y>3}
1049 \end{lstlisting}
1050 % \iffalse
1051 %</example>
1052 % \fi
1053 % yielding
1054 % \begin{align*}
1055 % & \expect{X} \\
1056 % & \expsub{x,y\sample\set{1,\ldots,6}}{x+y} \\
1057 % & \condexp{X+Y}{Y>3} \\
1058 % & \condexpsub{x,y\sample\set{1,\ldots,6}}{x+y}{y>3}
1059 % \end{align*}
1060 % Again flowtext versions such as |\texpect{X}| are available.
1061 % To control the expactation symbol ($\mathbb{E}$), redefine
1062 % \iffalse
1063 %<*example>
1064 % \fi
1065 \begin{lstlisting}
1066 \renewcommand{\expectationname}{\ensuremath{\mathbb{E}}}
1067 \end{lstlisting}
1068 % \iffalse
1069 %</example>
1070 % \fi
1071 %
1072 % The support $\supp{X}$ of a random variable $X$ can be written as
1073 % \iffalse
1074 %<*example>
1075 % \fi
1076 \begin{lstlisting}
1077 \supp{X}
1078 \end{lstlisting}
1079 % \iffalse
1080 %</example>
1081 % \fi
1082 % where again the name can be controlled via
1083 % \iffalse
1084 %<*example>
1085 % \fi
1086 \begin{lstlisting}
1087 \renewcommand{\supportname}{Supp}
1088 \end{lstlisting}
1089 % \iffalse
1090 %</example>
1091 % \fi
1092 %
1093 % For denoting entropy and min-entropy use
1094 % \iffalse
1095 %<*example>
1096 % \fi
1097 \begin{lstlisting}
1098 \entropy{X}
1099 \minentropy{X}
1100 \condentropy{X}{Y=5}
1101 \condminentropy{X}{Y=5}
1102 \condavgminentropy(X}{Y=5}
1103 \end{lstlisting}
1104 % \iffalse
1105 %</example>
1106 % \fi
1107 % This yields
1108 % \begin{align*}
1109 % & \entropy{X} \\
1110 % & \minentropy{X} \\
1111 % & \condentropy{X}{Y=5} \\
1112 % & \condminentropy{X}{Y=5} \\
1113 % & \condavgminentropy{X}{Y=5}
1114 % \end{align*}
1115 %
1116 % \subsection{Sets}
1117 % \index{sets|see {package options}}
1118 % \index{package options!sets}
1119 % The \enquote{sets} option provides commands for basic mathematical sets.
1120 % You can write sets and sequences as
1121 % \iffalse
1122 %<*example>
1123 % \fi
1124 \begin{lstlisting}
1125 \set{1, \ldots, 10}
1126 \sequence{1, \ldots, 10}
1127 \end{lstlisting}
1128 % \iffalse
1129 %</example>
1130 % \fi
1131 % which are typeset as
1132 % \begin{align*}
1133 % & \set{1, \ldots, 10} \\
1134 % & \sequence{1, \ldots, 10}
1135 % \end{align*}
1136 % In addition, the following commands are provided
1137 % \begin{center}
1138 % \begin{tabular}{l l l}
1139 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1140 % |\bin| & The set containing 0 and 1 & $\bin$ \\
1141 % |\NN| & Natural numbers & $\NN$ \\
1142 % |\ZZ| & Integers & $\ZZ$ \\
1143 % |\QQ| & Rational numbers & $\QQ$ \\
1144 % |\CC| & Complex numbers & $\CC$ \\
1145 % |\RR| & Reals & $\RR$ \\
1146 % |\PP| & & $\PP$ \\
1147 % |\FF| & & $\FF$ \\
1148 % |\GG| & & $\GG$ \\
1149 % \end{tabular}
1150 % \end{center}
1151 %
1152 % The style in which sets are being set can be adapted by redefining
1153 % \iffalse
1154 %<*example>
1155 % \fi
1156 \begin{lstlisting}
1157 \renewcommand{\pcsetstyle}[1]{\ensuremath{\mathbb{#1}}}
1158 \end{lstlisting}
1159 % \iffalse
1160 %</example>
1161 % \fi
1162 %
1163 % \subsection{Cryptographic Notions}
1164 % \index{notions|see {package options}}
1165 % \index{package options!notions}
1166 % \index{Crypto notions|see {package options}}
1167 % The \enquote{notions} option defines the following list of commands:
1168 %
1169 % \begin{center}
1170 % \begin{tabular}{l p{8cm} l}
1171 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1172 % |\indcpa| & IND-CPA security for encryption schemes & $\indcpa$ \\
1173 % |\indcca| & IND-CCA security for encryption schemes & $\indcca$ \\
1174 % |\indccai| & IND-CCA1 security for encryption schemes & $\indccai$ \\
1175 % |\indccaii| & IND-CCA2 security for encryption schemes & $\indccaii$ \\
1176 % |\ind| & IND security & $\ind$ \\
1177 % |\priv| & PRIV security for deterministic public-key encryption schemes & $\priv$ \\
1178 % |\prvcda| & PRV-CDA security (for deterministic public-key encryption schemes)& $\prvcda$ \\
1179 % |\prvrcda| & PRV\$-CDA security (for deterministic public-key encryption schemes) & $\prvrcda$ \\
1180 % |\kiae| & Key independent authenticated encryption & $\kiae$ \\
1181 % |\kdae| & Key dependent authenticated encryption & $\kdae$ \\
1182 % |\mle| & Message locked encryption & $\mle$ \\
1183 % |\uce| & Universal computational extractors & $\uce$ \\
1184 % |\eufcma| & Existential unforgeability under chosen message attack & $\eufcma$ \\
1185 % |\eufnacma| & Non-adaptive existential unforgeability under chosen message attack & $\eufnacma$ \\
1186 % |\seufcma| & Strong existential unforgeability under chosen message attack & $\seufcma$ \\
1187 % |\eufko| & Existential unforgeability under key only attack & $\eufko$
1188 % \end{tabular}
1189 % \end{center}
1190 %
1191 % The style in which notions are displayed can be controlled via redefining
1192 % \iffalse
1193 %<*example>
1194 % \fi
1195 \begin{lstlisting}
1196 \renewcommand{\pcnotionstyle}[1]{\ensuremath{\mathrm{#1}}}
1197 \end{lstlisting}
1198 % \iffalse
1199 %</example>
1200 % \fi
1201 %
1202 % \subsection{Logic}
1203 % \index{logic|see {package options}}
1204 % \index{package options!logic}
1205 % The \enquote{logic} option provides the following list of commands:
1206 %
1207 % \begin{center}
1208 % \begin{tabular}{l l l}
1209 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1210 % |\AND| & Logical AND & $\AND$ \\
1211 % |\NAND| & Logical NAND & $\NAND$ \\
1212 % |\OR| & Logical OR & $\OR$ \\
1213 % |\NOR| & Logical NOR & $\NOR$ \\
1214 % |\XOR| & Logical XOR & $\XOR$ \\
1215 % |\XNOR| & Logical XNOR & $\XNOR$ \\
1216 % |\notimplies| & Negated implication & $\notimplies$ \\
1217 % |\NOT| & not & $\NOT$ \\
1218 % |\xor| & exclusive or & $\xor$ \\
1219 % |\false| & false & $\false$ \\
1220 % |\true| & true & $\true$
1221 % \end{tabular}
1222 % \end{center}
1223 %
1224 %
1225 % \subsection{Function Families}
1226 % \index{ff|see {package options}}
1227 % \index{package options!ff}
1228 % \index{function families|see {package options}}
1229 % The \enquote{ff} option provides the following list of commands:
1230 %
1231 % \begin{center}
1232 % \begin{tabular}{l l l}
1233 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1234 % |\kgen| & Key generation & $\kgen$ \\
1235 % |\pgen| & Parameter generation & $\pgen$ \\
1236 % |\eval| & Evaluation & $\eval$ \\
1237 % |\invert| & Inversion & $\invert$ \\
1238 % |\il| & Input length & $\il$ \\
1239 % |\ol| & Output length & $\ol$ \\
1240 % |\kl| & Key length & $\kl$ \\
1241 % |\nl| & Nonce length & $\nl$ \\
1242 % |\rl| & Randomness length & $\rl$
1243 % \end{tabular}
1244 % \end{center}
1245 %
1246 % The style in which these are displayed can be controlled via redefining
1247 % \iffalse
1248 %<*example>
1249 % \fi
1250 \begin{lstlisting}
1251 \renewcommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
1252 \end{lstlisting}
1253 % \iffalse
1254 %</example>
1255 % \fi
1256 %
1257 %
1258 % \subsection{Machine Model}
1259 % \index{machine model|see {package options}}
1260 % \index{package options!mm}
1261 % \index{mm|see {package options}}
1262 % The \enquote{mm} option provides the following list of commands:
1263 %
1264 % \begin{center}
1265 % \begin{tabular}{l l l}
1266 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1267 % |\CRKT| & A circuit & $\CRKT$ \\
1268 % |\TM| & A Turing machine & $\TM$ \\
1269 % |\PROG| & A program & $\PROG$ \\
1270 % |\uTM| & A universal Turing machine & $\uTM$ \\
1271 % |\uC| & A universal Circuit & $\uC$ \\
1272 % |\uP| & A universal Program & $\uP$ \\
1273 % |\tmtime| & Time (of a TM) & $\tmtime$ \\
1274 % |\ppt| & Probabilistic polynomial time & $\ppt$
1275 % \end{tabular}
1276 % \end{center}
1277 %
1278 % The style in which these are displayed can be controlled via redefining
1279 % \iffalse
1280 %<*example>
1281 % \fi
1282 \begin{lstlisting}
1283 \renewcommand{\pcmachinemodelstyle}[1]{\ensuremath{\mathsf{#1}}}
1284 \end{lstlisting}
1285 % \iffalse
1286 %</example>
1287 % \fi
1288 %
1289 % \amipagebreak
1290 % \subsection{Crypto Primitives}
1291 % \index{primitives|see {package options}}
1292 % \index{package options!primitives}
1293 % \index{Crypto primitives|see {package options}}
1294 % The \enquote{primitives} option provides the following list of commands:
1295 %
1296 %
1297 % \begin{center}
1298 % \begin{tabular}{l l l}
1299 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1300 % |\prover| & Proover & $\prover$ \\
1301 % |\verifier| & Verifier & $\verifier$ \\
1302 % |\nizk| & Non interactive zero knowledge & $\nizk$ \\
1303 % |\hash| & A hash function & $\hash$ \\
1304 % |\gash| & A hash function& $\gash$ \\
1305 % |\fash| & A hash function & $\fash$ \\
1306 % |\pad| & A padding function & $\pad$ \\
1307 % |\enc| & Encryption & $\enc$ \\
1308 % |\dec| & Decryption & $\dec$ \\
1309 % |\sig| & Signing & $\sig$ \\
1310 % |\sign| & Signing & $\sign$ \\
1311 % |\verify| & Verifying & $\verify$ \\
1312 % |\owf| & One-way function & $\owf$ \\
1313 % |\prf| & Pseudorandom function & $\prf$ \\
1314 % |\prp| & Pseudorandom permutation & $\prp$ \\
1315 % |\prg| & Pseudorandom generator & $\prg$ \\
1316 % |\obf| & Obfuscation & $\obf$ \\
1317 % |\iO| & Indistinguishability obfuscation & $\iO$ \\
1318 % |\diO| & Differing inputs obfuscation & $\diO$ \\
1319 % |\mac| & Message authentication & $\mac$ \\
1320 % |\puncture| & Puncturing & $\puncture$ \\
1321 % |\source| & A source & $\source$ \\
1322 % |\predictor| & A predictor & $\predictor$ \\
1323 % |\sam| & A sampler & $\sam$ \\
1324 % |\distinguisher| & A distinguisher & $\distinguisher$ \\
1325 % |\dist| & A distinguisher& $\dist$ \\
1326 % |\simulator| & A simulator & $\simulator$ \\
1327 % |\extractor| & An extractor & $\extractor$ \\
1328 % |\ext| & Shorthand for |\extractor| & $\ext$
1329 % \end{tabular}
1330 % \end{center}
1331 %
1332 % The style in which these are displayed can be controlled via redefining
1333 % \iffalse
1334 %<*example>
1335 % \fi
1336 \begin{lstlisting}
1337 \renewcommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
1338 \end{lstlisting}
1339 % \iffalse
1340 %</example>
1341 % \fi
1342 %
1343 % \subsection{Oracles}
1344 % \index{oracles|see {package options}}
1345 % \index{package options!oracles}
1346 % The \enquote{oracles} option provides the following list of commands:
1347 %
1348 %
1349 % \begin{center}
1350 % \begin{tabular}{l l l}
1351 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1352 % |\oracle| & Generic oracle & $\oracle$ \\
1353 % |\oracle[LoR]| & Custom oracle & $\oracle[LoR]$ \\
1354 % |\ro| & Random oracle & $\ro$ \\
1355 % |\Oracle{\sign}| & Oracle version of procedure & $\Oracle{\sign}$
1356 % \end{tabular}
1357 % \end{center}
1358 %
1359 % The style in which these are displayed can be controlled via redefining
1360 % \iffalse
1361 %<*example>
1362 % \fi
1363 \begin{lstlisting}
1364 \renewcommand{\pcoraclestyle}[1]{\ensuremath{\mathsf{#1}}}
1365 \end{lstlisting}
1366 % \iffalse
1367 %</example>
1368 % \fi
1369 %
1370 % \subsection{Events}
1371 % \index{events|see {package options}}
1372 % \index{package options!events}
1373 % The \enquote{events} option provides the following list of commands.
1374 %
1375 % \begin{center}
1376 % \begin{tabular}{l l l}
1377 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1378 % |\event{E}| & Event \event{E} & $\event{E}$ \\
1379 % |\nevent{E}| & Negated event \event{E} & $\nevent{E}$ \\
1380 % |\bad| & Bad event & $\bad$ \\
1381 % |\nbad| & Bad event & $\nbad$
1382 % \end{tabular}
1383 % \end{center}
1384 %
1385 % \subsection{Complexity}
1386 % \index{complexity|see {package options}}
1387 % \index{package options!complexity}
1388 % The \enquote{complexity} option provides the following list of commands:
1389 %
1390 % \begin{center}
1391 % \begin{tabular}{l l l}
1392 % \textbf{Command} & \textbf{Result} \\\hline
1393 % |\complclass{myClass}| & $\complclass{myClass}$ \\
1394 % |\cocomplclass{myClass}| & $\cocomplclass{myClass}$ \\
1395 % |\npol| & $\npol$ \\
1396 % |\conpol| & $\conpol$ \\
1397 % |\pol| & $\pol$ \\
1398 % |\bpp| & $\bpp$ \\
1399 % |\ppoly| & $\ppoly$ \\
1400 % |\NC{1}| & $\NC1$ \\
1401 % |\AC{1}| & $\AC1$ \\
1402 % |\TC{1}| & $\TC1$ \\
1403 % |\AM| & $\AM$ \\
1404 % |\coAM| & $\coAM$ \\
1405 % |\PH| & $\PH$ \\
1406 % |\csigma{1}| & $\csigma{1}$ \\
1407 % |\cpi{1}| & $\cpi{1}$ \\
1408 % |\cosigma{1}| & $\cosigma{1}$ \\
1409 % |\copi{1}| & $\copi{1}$
1410 % \end{tabular}
1411 % \end{center}
1412 %
1413 % The style in which these are displayed can be controlled via redefining
1414 % \iffalse
1415 %<*example>
1416 % \fi
1417 \begin{lstlisting}
1418 \renewcommand{\pccomplexitystyle}[1]{\ensuremath{\mathsf{#1}}}
1419 \end{lstlisting}
1420 % \iffalse
1421 %</example>
1422 % \fi
1423 %
1424 % \amipagebreak
1425 % \subsection{Asymptotics}
1426 % \index{asymptotics|see {package options}}
1427 % \index{package options!asymptotics}
1428 % The \enquote{asymptotics} option provides the following list of commands:
1429 %
1430 % \begin{center}
1431 % \begin{tabular}{l l p{7.5cm}}
1432 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1433 % |\negl| & A negligible function & $\negl$ (\secpar\ is |\secpar|) \\
1434 % |\negl[x]| & A negligible function & $\negl[x]$ \\
1435 % |\negl[]| & A negligible function & $\negl[]$ \\
1436 % |\poly| & A polynomial & $\poly$ (\secpar\ is |\secpar|) \\
1437 % |\poly[x]| & A polynomial & $\poly[x]$ \\
1438 % |\poly[]| & A polynomial & $\poly[]$ \\
1439 % |\pp| & some polynomial $\pp$ & $\pp$ \\
1440 % |\pp[t]| & some custom polynomial $\pp[t]$ & $\pp[t]$ \\
1441 % |\cc| & some polynomial $\cc$ & $\cc$ \\
1442 % |\ee| & some polynomial $\ee$ & $\ee$ \\
1443 % |\kk| & some polynomial $\kk$ & $\kk$ \\
1444 % |\mm| & some polynomial $\mm$ & $\mm$ \\
1445 % |\nn| & some polynomial $\nn$ & $\nn$ \\
1446 % |\qq| & some polynomial $\qq$ & $\qq$ \\
1447 % |\rr| & some polynomial $\rr$ & $\rr$
1448 % \end{tabular}
1449 % \end{center}
1450 %
1451 % The style in which these are displayed can be controlled via redefining
1452 % \iffalse
1453 %<*example>
1454 % \fi
1455 \begin{lstlisting}
1456 \renewcommand{\pcpolynomialstyle}[1]{\ensuremath{\mathrm{#1}}}
1457 \end{lstlisting}
1458 % \iffalse
1459 %</example>
1460 % \fi
1461 %
1462 % \subsection{Keys}
1463 % \index{keys|see {package options}}
1464 % \index{package options!keys}
1465 % The \enquote{keys} option provides the following list of commands:
1466 %
1467 %
1468 % \begin{center}
1469 % \begin{tabular}{l l l}
1470 % \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
1471 % |pk| &public key & $\pk$ \\
1472 % |vk| & verification key& $\vk$ \\
1473 % |sk| & secret key& $\sk$ \\
1474 % |key| & a plain key& $\key$ \\
1475 % |key[xk]| & custom key & $\key[xk]$ \\
1476 % |hk| & hash key& $\hk$ \\
1477 % |gk| &gash key & $\gk$ \\
1478 % |fk| & function key & $\fk$ \\
1479 % |st| & state & $\st$ \\
1480 % |state| & state & $\state$ \\
1481 % |state{myState}| & custom state & $\state{myState}$
1482 % \end{tabular}
1483 % \end{center}
1484 %
1485 % The style in which these are displayed can be controlled via redefining
1486 % \iffalse
1487 %<*example>
1488 % \fi
1489 \begin{lstlisting}
1490 \renewcommand{\pckeystyle}[1]{\ensuremath{\mathsf{#1}}}
1491 \end{lstlisting}
1492 % \iffalse
1493 %</example>
1494 % \fi
1495 %
1496 %
1497 % \amipagebreak
1498 % \section{Pseudocode}
1499 % \label{chap:pseudocode}
1500 %
1501 % \subsection{Basics}
1502 % \index{\textbackslash pseudocode}
1503 %
1504 % The cryptocode package provides the command |\pseudocode| for typesetting algorithms.
1505 % Consider the following definition of an IND-CPA game
1506 %
1507 % \begin{pchstack}[center]
1508 % \pseudocode{%
1509 % b \sample \bin \\
1510 % (\pk,\sk) \sample \kgen (\secparam) \\
1511 % (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
1512 % c \sample \enc(\pk,m_b) \\
1513 % b' \sample \adv(\secparam, \pk, c) \\
1514 % \pcreturn b = b' }
1515 % \end{pchstack}
1516 % which is generated by
1517 % \iffalse
1518 %<*example>
1519 % \fi
1520 \begin{lstlisting}
1521 \begin{pchstack}[center]
1522 \pseudocode{
1523 b \sample \bin \\
1524 (\pk,\sk) \sample \kgen (\secparam) \\
1525 (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
1526 c \sample \enc(\pk,m_b) \\
1527 b' \sample \adv(\secparam, \pk, c) \\
1528 \pcreturn b = b' }
1529 \end{pchstack}
1530 \end{lstlisting}
1531 % \iffalse
1532 %</example>
1533 % \fi
1534 %
1535 % First note that |\pseudocode| on its own does not space itself. For laying out
1536 % one (or multiple) code blocks cryptocode
1537 % defines stacking environemnts such as |\pchstack| and |\pcvstack| that we discuss
1538 % in Section~\ref{chap:stacking}. Wrapping a single pseudocode in a |\pchstack|
1539 % as in the above example generates a nicely offset code block.
1540 %
1541 % \medskip
1542 % As code blocks are most often not used in flow text, cryptocode offers the shorthand
1543 % |\pseudocodeblock| which centers and offsets a pseudocode block as above. We thus
1544 % get the very same by writing
1545 % \iffalse
1546 %<*example>
1547 % \fi
1548 \begin{lstlisting}
1549 \pseudocodeblock{
1550 b \sample \bin \\
1551 (\pk,\sk) \sample \kgen (\secparam) \\
1552 (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
1553 c \sample \enc(\pk,m_b) \\
1554 b' \sample \adv(\secparam, \pk, c) \\
1555 \pcreturn b = b' }
1556 \end{lstlisting}
1557 % \iffalse
1558 %</example>
1559 % \fi
1560 %
1561 % We can also define custom block commands, for example, the following defines
1562 % a command |\pcb| that offsets and centers code and draws a tight fitting box around the code block:
1563 % \iffalse
1564 %<*example>
1565 % \fi
1566 \begin{lstlisting}
1567 \createpseudocodeblock{pcb}{center,boxed}{}{}{}
1568 \end{lstlisting}
1569 % \iffalse
1570 %</example>
1571 % \fi
1572 % (We discuss creating custom pseudocode commands in detail in Section~\ref{sec:custom:pc:command}).
1573 % If we now use |\pcb| as just defined in the above example, we obtain the following
1574 % nicely spaced and boxed result.
1575 % \pcb{
1576 % b \sample \bin \\
1577 % (\pk,\sk) \sample \kgen (\secparam) \\
1578 % (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
1579 % c \sample \enc(\pk,m_b) \\
1580 % b' \sample \adv(\secparam, \pk, c) \\
1581 % \pcreturn b = b' }
1582 % which is generated as
1583 % \iffalse
1584 %<*example>
1585 % \fi
1586 \begin{lstlisting}
1587 \pcb{
1588 b \sample \bin \\
1589 (\pk,\sk) \sample \kgen (\secparam) \\
1590 (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
1591 c \sample \enc(\pk,m_b) \\
1592 b' \sample \adv(\secparam, \pk, c) \\
1593 \pcreturn b = b' }
1594 \end{lstlisting}
1595 % \iffalse
1596 %</example>
1597 % \fi
1598 %
1599 % \textbf{Remark. } In the following we will use this boxed representation for the examples, but
1600 % use |\pseudocodeblock| in the corresponding code listings.
1601 %
1602 % \medskip
1603 % As you can see, the pseudocode command provides a math based environment where you can simply start typing your pseudocode
1604 % separating lines by |\\|.
1605 %
1606 %
1607 %
1608 % \subsubsection{Customizing Pseudocode}
1609 % \index{lnstart}
1610 % \index{head}
1611 % \index{lnstartright}
1612 % \index{linenumbering}
1613 % \index{syntaxhighlight}
1614 % \index{keywords}
1615 % \index{keywordsindent}
1616 % \index{codesize}
1617 % \index{keywordsunindent}
1618 % \index{keywordsuninindent}
1619 % \index{addkeywords}
1620 % \index{altkeywords}
1621 % \index{mode}
1622 % \index{space}
1623 % \index{xshift}
1624 % \index{colsep}
1625 % \index{addtolength}
1626 % \index{nodraft}
1627 % \index{yshift}
1628 % \index{bodylinesep}
1629 % \index{headlinesep}
1630 % \index{jot}
1631 % \index{beginline}
1632 % \index{endline}
1633 % \index{minlineheight}
1634 % \index{\textbackslash{}pcminlineheight}
1635 %
1636 % Besides the mandatory argument the |\pseudocode| command can take an optional argument which consists of a list of key=value pairs
1637 % separated by commas.
1638 % \iffalse
1639 %<*example>
1640 % \fi
1641 \begin{lstlisting}
1642 \pseudocode[options]{body}
1643 \end{lstlisting}
1644 % \iffalse
1645 %</example>
1646 % \fi
1647 % The following parameters are available:
1648 % \begin{description}
1649 % \item[head]
1650 % A header for the code
1651 % \item[width]
1652 % An exact width. If no width is specified, cryptocode tries to automatically compute the correct width.
1653 % \item[lnstart]
1654 % The starting line number when using line numbering.
1655 % \item[lnstartright]
1656 % The starting line number for right aligned line numberswhen using line numbering.
1657 % \item[linenumbering]
1658 % Enables line numbering.
1659 %
1660 % \item[skipfirstln]
1661 % Starts line numbering on the second line.
1662 %
1663 % \item[minlineheight]
1664 % Specify a minimum height for each line. Can be globally set by redefining |\pcminlineheight|.
1665 %
1666 % \item[syntaxhighlight]
1667 % When set to \enquote{auto} cryptocode will attempt to automatically hightlight keywords such as \enquote{for}, \enquote{foreach}
1668 % and \enquote{return}. Note that this feature should be regarded as experimental. In particular, it is rather slow.
1669 % \item[keywords]
1670 % Provide a comma separated list of keywords for automatic syntax highlighting. To customize the behavior of automatic spacing
1671 % you can provide keywords as
1672 % \begin{description}
1673 % \item[keywordsindent]
1674 % After seeing this keyword all following lines will be indented one extra level.
1675 % \item[keywordsunindent]
1676 % After seeing this keyword the current and all following lines will be unindented one extra level.
1677 % \item[keywordsuninindent]
1678 % After seeing this keyword the current line will be unindented one level.
1679 % \end{description}
1680 % \item[addkeywords]
1681 % Provide additional keywords for automatic syntax highlighting.
1682 % \item[altkeywords]
1683 % Provide a second list of keywords for automatic syntax highlighting that are highlighted differently.
1684 % \item[mode]
1685 % When set to text pseudocode will not start in math mode but in text mode.
1686 % \item[space]
1687 % Allows you to enable automatic spacing mode. If set to \enquote{keep} the spaces in the input are preserved.
1688 % If set to \enquote{auto} it will try to detect spacing according to keywords such as \enquote{if} and \enquote{fi}.
1689 % \item[codesize]
1690 % Allows to specify the fontsize for the pseudocode. Set to |\scriptsize| for a smaller size.
1691 %
1692 % \item[colspace]
1693 % Allows to insert spacing between columns. In particular this allows to also overlap columns by inserting negative space.
1694 %
1695 % \item[jot]
1696 % Allows to specify extra space between each line. Use |jot=1mm|.
1697 %
1698 % \item[beginline]
1699 % Allows to specify a macro that is placed at the beginning of each line.
1700 %
1701 % \item[endline]
1702 % Allows to specify a macro that is placed at the end of each line.
1703 %
1704 % \item[xshift]
1705 % Allows horizontal shifting
1706 % \item[yshift]
1707 % Allows horizontal shifting
1708 %
1709 % \item[headlinesep]
1710 % Specifies the distance between header and the line. By default set to 0pt which can be globally overwritten by setting length |\pcheadlinesep|.
1711 % \item[bodylinesep]
1712 % Specifies the distance between body and the line. By default set to |0.3\baselineskip| which can be globally overwritten by setting length |\pcbodylinesep|.
1713 % \item[colsep]
1714 % Defines the space between columns.
1715 %
1716 % \item[headheight]
1717 % Specifies the height of the header. By default set to 3.25ex which can be globally overwritten by setting length |\pcheadheight|.
1718 %
1719 % \item[headlinecmd]
1720 % Allows to overwrite which command is used to draw the bar below the headline. Defaults to |\hrule|.
1721 %
1722 % \item[addtolength]
1723 % Is added to the automatically computed width of the pseudocode (which does not take colsep into account).
1724 %
1725 % \item[valign]
1726 % Controls the vertical alignment of the pseudocode. Pseudocode is wrapped in a minipage environment and valign value is passed as orientation for the minipage. By default valign is set to \enquote{t}.
1727 %
1728 % \item[nodraft]
1729 % Forces syntax highlighting also in draft mode.
1730 % \end{description}
1731 % The following code
1732 % \iffalse
1733 %<*example>
1734 % \fi
1735 \begin{lstlisting}
1736 \pseudocodeblock[linenumbering,syntaxhighlight=auto,head=Header]{ return null }
1737 \end{lstlisting}
1738 % \iffalse
1739 %</example>
1740 % \fi
1741 % creates
1742 % \begin{center}
1743 % \pcb[linenumbering,syntaxhighlight=auto,head=Header]{ return null }
1744 % \end{center}
1745 %
1746 % \subsubsection{Customized Pseudocode Commands}\label{sec:custom:pc:command}
1747 % \index{\textbackslash procedure}
1748 % \index{\textbackslash createpseudocodecommand}
1749 % \index{\textbackslash createprocedurecommand}
1750 %
1751 % Besides the |\pseudocode| and |\pseudocodeblock| command the command |\procedure|
1752 % (and its block variant |\procedureblock| provides easy access to generate code with a header.
1753 % They take the following form
1754 % \iffalse
1755 %<*example>
1756 % \fi
1757 \begin{lstlisting}
1758 \procedure[options]{Header}{Body}
1759 \procedureblock[options]{Header}{Body}
1760 \end{lstlisting}
1761 % \iffalse
1762 %</example>
1763 % \fi
1764 %
1765 % \subsubsection*{Examples}
1766 % \procb{$\indcpa_\enc^\adv(\secpar)$}{
1767 % b \sample \bin \\
1768 % (\pk,\sk) \sample \kgen(\secparam) \\
1769 % (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
1770 % c \sample \enc(\pk,m_b) \\
1771 % b' \sample \adv(\secparam, \pk, c) \\
1772 % \pcreturn b = b' }
1773 % which is generated as
1774 % \iffalse
1775 %<*example>
1776 % \fi
1777 \begin{lstlisting}
1778 \procedureblock{$\indcpa_\enc^\adv(\secpar)$}{
1779 b \sample \bin \\
1780 (\pk,\sk) \sample \kgen(\secparam) \\
1781 (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
1782 c \sample \enc(\pk,m_b) \\
1783 b' \sample \adv(\secparam, \pk, c) \\
1784 \pcreturn b = b' }
1785 \end{lstlisting}
1786 % \iffalse
1787 %</example>
1788 % \fi
1789 %
1790 %
1791 % \medskip
1792 % You can define customized pseudocode commands which either take one optional argument and two mandatory arguments (as the procedure command)
1793 % or one optional and one mandatory argument (as the pseudocode command). The following
1794 % \iffalse
1795 %<*example>
1796 % \fi
1797 \begin{lstlisting}
1798 \createpseudocodecommand{mypseudocode}{}{}{linenumbering}
1799 \createprocedurecommand{myprocedure}{}{}{linenumbering}
1800 \createpseudocodeblock{pcb}{center,boxed}{}{}{linenumbering}
1801 \createprocedureblock{procb}{center,boxed}{}{}{linenumbering}
1802 \end{lstlisting}
1803 % \iffalse
1804 %</example>
1805 % \fi
1806 % creates the commands |\mypseudocode| and |\myprocedure| with line numbering always enabled as well
1807 % as the block commands |\pcb| and |\procb| also with line numbering enabled. The created commands
1808 % have an identical interface as the |\pseudocode| (resp.~|\procedure|) command.
1809 % The two arguments that we kept empty when generating the commands allows us to specify commands that are executed at the
1810 % very beginning when the command is called (first empty argument) and a prefix for the header.
1811 % For example, the command created as
1812 % \iffalse
1813 %<*example>
1814 % \fi
1815 \begin{lstlisting}
1816 \createprocedureblock{expproc}{center,boxed}{}{$\mathrm{Experiment}$\xspace}{linenumbering}
1817 \end{lstlisting}
1818 % \iffalse
1819 %</example>
1820 % \fi
1821 % could be used as
1822 % \iffalse
1823 %<*example>
1824 % \fi
1825 \begin{lstlisting}
1826 \expproc{$\indcpa_\enc^\adv(\secpar)$}{
1827 b \sample \bin \\
1828 (\pk,\sk) \sample \kgen(\secparam) \\
1829 (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
1830 c \sample \enc(\pk,m_b) \\
1831 b' \sample \adv(\secparam, \pk, c) \\
1832 \pcreturn b = b' }
1833 \end{lstlisting}
1834 % \iffalse
1835 %</example>
1836 % \fi
1837 % This results in
1838 % \createprocedureblock{expproc}{center,boxed}{}{$\mathrm{Experiment}$\xspace}{linenumbering}
1839 % \expproc{$\indcpa_\enc^\adv(\secpar)$}{%
1840 % b \sample \bin \\
1841 %(\pk,\sk) \sample \kgen(\secparam) \\
1842 %(m_0,m_1) \sample \adv(\secparam, \pk, c) \\
1843 %c \sample \enc(\pk,m_b) \\
1844 %b' \sample \adv(\secparam, \pk, c) \\
1845 % \pcreturn b = b' }
1846 %
1847 %
1848 % \subsection{Indentation}
1849 % \index{indentation}
1850 % \index{\textbackslash pcind}
1851 % \index{\textbackslash t}
1852 %
1853 % In order to indent code use |\pcind| or short |\t|. You can also use customized spacing such as |\quad| or |\hspace|
1854 % when using the pseudocode command in math mode.
1855 % \pcb{
1856 % \pcfor i = 1..10 \pcdo \\
1857 % \pcind T[i] \sample \bin^n \\
1858 % \pcfor i = 1..10 \pcdo \\
1859 % \t T[i] \sample \bin^n }
1860 % which is generated as
1861 % \iffalse
1862 %<*example>
1863 % \fi
1864 \begin{lstlisting}
1865 \pseudocodeblock{
1866 \pcfor i = 1..10 \pcdo \\
1867 \pcind T[i] \sample \bin^n \\
1868 \pcfor i = 1..10 \pcdo \\
1869 \t T[i] \sample \bin^n }
1870 \end{lstlisting}
1871 % \iffalse
1872 %</example>
1873 % \fi
1874 % You can specify multiple levels via the optional first argument
1875 % \iffalse
1876 %<*example>
1877 % \fi
1878 \begin{lstlisting}
1879 \t[level] % \pcind[level]
1880 \end{lstlisting}
1881 % \iffalse
1882 %</example>
1883 % \fi
1884 % \pcb{
1885 % \pcfor i = 1..10 \pcdo \\
1886 % \t T[i] \sample \bin^n \\
1887 % \t\t T[i] \sample \bin^n \\
1888 % \t[3] T[i] \sample \bin^n \\
1889 % \t[4] T[i] \sample \bin^n \\
1890 % \t[5] T[i] \sample \bin^n }
1891 % \iffalse
1892 %<*example>
1893 % \fi
1894 \begin{lstlisting}
1895 \pseudocodeblock{
1896 \pcfor i = 1..10 \pcdo \\
1897 \t T[i] \sample \bin^n \\
1898 \t\t T[i] \sample \bin^n \\
1899 \t[3] T[i] \sample \bin^n \\
1900 \t[4] T[i] \sample \bin^n \\
1901 \t[5] T[i] \sample \bin^n }
1902 \end{lstlisting}
1903 % \iffalse
1904 %</example>
1905 % \fi
1906 %
1907 % \index{\textbackslash pcindentname}
1908 % You can customize the indentation shortcut by redefining
1909 % \iffalse
1910 %<*example>
1911 % \fi
1912 \begin{lstlisting}
1913 \renewcommand{\pcindentname}{t}
1914 \end{lstlisting}
1915 % \iffalse
1916 %</example>
1917 % \fi
1918 %
1919 % \subsubsection*{Automatic Indentation}
1920 % The pseudocode command comes with an option \enquote{space=auto} which tries to detect the correct indentation from the use of
1921 % keywords. When it sees one of the following keywords
1922 % \iffalse
1923 %<*example>
1924 % \fi
1925 \begin{lstlisting}
1926 \pcif, \pcfor, \pcwhile, \pcrepeat, \pcforeach
1927 \end{lstlisting}
1928 % \iffalse
1929 %</example>
1930 % \fi
1931 % it will increase the indentation starting from the next line. It will again remove the indentation on seeing
1932 % \iffalse
1933 %<*example>
1934 % \fi
1935 \begin{lstlisting}
1936 \pcfi, \pcendif, \pcendfor, \pcendwhile, \pcuntil, \pcendforeach
1937 \end{lstlisting}
1938 % \iffalse
1939 %</example>
1940 % \fi
1941 % Additionally, on seeing
1942 % \iffalse
1943 %<*example>
1944 % \fi
1945 \begin{lstlisting}
1946 \pcelse, \pcelseif
1947 \end{lstlisting}
1948 % \iffalse
1949 %</example>
1950 % \fi
1951 % it will remove the indentation for that particular line. Thus the following
1952 % \pcb[space=auto]{%
1953 % \pcfor a \in [10] \pcdo \\
1954 % \pcfor a \in [10] \pcdo \\
1955 % \pcfor a \in [10] \pcdo \\
1956 % \pcif a = b \pcthen \\
1957 % \text{some operation} \\
1958 % \pcelseif a = c \pcthen \\
1959 % \text{some operation} \\
1960 % \pcelse \\
1961 % \text{some default operation} \\
1962 % \pcfi \\
1963 % \pcendfor \\
1964 % \pcendfor \\
1965 % \pcendfor \\
1966 % \pcreturn a}
1967 % can be obtained by:
1968 % \iffalse
1969 %<*example>
1970 % \fi
1971 \begin{lstlisting}
1972 \pseudocodeblock[space=auto]{%
1973 \pcfor a \in [10] \pcdo \\
1974 \pcfor a \in [10] \pcdo \\
1975 \pcfor a \in [10] \pcdo \\
1976 \pcif a = b \pcthen \\
1977 \text{some operation} \\
1978 \pcelseif a = c \pcthen \\
1979 \text{some operation} \\
1980 \pcelse \\
1981 \text{some default operation} \\
1982 \pcfi \\
1983 \pcendfor \\
1984 \pcendfor \\
1985 \pcendfor \\
1986 \pcreturn a}
1987 \end{lstlisting}
1988 % \iffalse
1989 %</example>
1990 % \fi
1991 % Note that the manual indentation in the above example is not necessary for the outcome. Further note that the same
1992 % works when using automatic syntax highlighting (see Section~\ref{sec:syntaxhighlight}).
1993 %
1994 % \subsubsection*{Keep Input Indentation (experimental)}
1995 % \label{sec:keepindent}
1996 % The pseudocode package comes with an \emph{experimental} feature that preserves the spacing in the input. This can be enabled with
1997 % the option \enquote{space=keep}.
1998 % \iffalse
1999 %<*example>
2000 % \fi
2001 \begin{lstlisting}
2002 \begin{center}
2003 \pseudocode[space=keep]{%
2004 \pcfor i = 1..10 \pcdo \\
2005 T[i] \sample \bin^n \\
2006 T[i] \sample \bin^n \\
2007 T[i] \sample \bin^n \\
2008 T[i] \sample \bin^n \\
2009 T[i] \sample \bin^n }
2010 \end{center}
2011 \end{lstlisting}
2012 % \iffalse
2013 %</example>
2014 % \fi
2015 % This yields the following result
2016 % \begin{center}
2017 % \pseudocode[space=keep]{%
2018 % \pcfor i = 1..10 \pcdo \\
2019 % T[i] \sample \bin^n \\
2020 % T[i] \sample \bin^n \\
2021 % T[i] \sample \bin^n \\
2022 % T[i] \sample \bin^n \\
2023 % T[i] \sample \bin^n }
2024 % \end{center}
2025 %
2026 % Note that automatic spacing only works when the |\pseudocode| command is not wrapped within another command.
2027 % Thus in order to get a frame box |\fbox{\pseudocode[space=keep]{code}}| will not work but you would need to use
2028 % an environment such as one offered by the \emph{mdframed} package ((\url{https://www.ctan.org/pkg/mdframed}). Also see
2029 % Section~\ref{sec:keepindent-problem}.
2030 %
2031 % \subsection{Textmode}
2032 % \index{text mode}
2033 %
2034 % By default pseudocode enables \LaTeX' math mode. You can change this behavior and tell the pseudocode command to interpret the content
2035 % in text mode by setting the option \enquote{mode=text}.
2036 % \begin{center}
2037 % \fbox{\pseudocode[mode=text]{%
2038 % This is \\
2039 % \t simply text}}
2040 % \end{center}
2041 % \iffalse
2042 %<*example>
2043 % \fi
2044 \begin{lstlisting}
2045 \pseudocodeblock[mode=text]{%
2046 This is \\
2047 \t simply text}
2048 \end{lstlisting}
2049 % \iffalse
2050 %</example>
2051 % \fi
2052 %
2053 % \subsection{Syntax Highlighting}
2054 % \label{sec:syntaxhighlight}
2055 %
2056 % \index{\textbackslash pcabort}
2057 % \index{\textbackslash pcassert}
2058 % \index{\textbackslash pcfail}
2059 % \index{\textbackslash pccontinue}
2060 % \index{\textbackslash pccomment}
2061 % \index{\textbackslash pcdo}
2062 % \index{\textbackslash pcdone}
2063 % \index{\textbackslash pcelse}
2064 % \index{\textbackslash pcelseif}
2065 % \index{\textbackslash pcfi}
2066 % \index{\textbackslash pcendif}
2067 % \index{\textbackslash pcforeach}
2068 % \index{\textbackslash pcendforeach}
2069 % \index{\textbackslash pcglobvar}
2070 % \index{\textbackslash pcif}
2071 % \index{\textbackslash pcin}
2072 % \index{\textbackslash pcnew}
2073 % \index{\textbackslash pcnull}
2074 % \index{\textbackslash pcparse}
2075 % \index{\textbackslash pcrepeat}
2076 % \index{\textbackslash pcuntil}
2077 % \index{\textbackslash pcreturn}
2078 % \index{\textbackslash pcthen}
2079 % \index{\textbackslash pctrue}
2080 % \index{\textbackslash pcwhile}
2081 % \index{\textbackslash pcendwhile}
2082 %
2083 %
2084 % In the above examples we have used commands |\pcreturn| and |\pcfor| to highlight certain keywords.
2085 % Besides the \emph{pcreturn}, \emph{pcfor} and \emph{pcdo} (where the pc stands for pseudocode) that were used in the above
2086 % examples the package defines the following set of constants:
2087 %
2088 % \begin{center}
2089 % \begin{tabular}{lll}
2090 % \textbf{command} & \textbf{outcome} \\
2091 % |\pcabort| & \pcabort\\
2092 % |\pcassert| & \pcassert\\
2093 % |\pccontinue| & \pccontinue \\
2094 % |\pccomment{comment}| & \pccomment{comment} \\
2095 % |\pccomment[2em]{comment}| & \pccomment[2em]{comment} \\
2096 % |\pclinecomment{comment}| & \pclinecomment{comment} \\
2097 % |\pcdo| & \pcdo \\
2098 % |\pcdone| & \pcdone \\
2099 % |\pcfail| & \pcfail \\
2100 % |\pcfalse| & \pcfalse \\
2101 % |\pcif| & \pcif \\
2102 % |\pcfi| & \pcfi \\
2103 % |\pcendif| & \pcendif \\
2104 % |\pcelse| & \pcelse \\
2105 % |\pcelseif| & \pcelseif \\
2106 % |\pcfor| & \pcfor \\
2107 % |\pcendfor| & \pcendfor \\
2108 % |\pcforeach| & \pcforeach \\
2109 % |\pcendforeach| & \pcendforeach \\
2110 % |\pcglobvar| & \pcglobvar \\
2111 % |\pcin| & \pcin \\
2112 % |\pcnew| & \pcnew \\
2113 % |\pcnull| & \pcnull \\
2114 % |\pcparse| & \pcparse \\
2115 % |\pcrepeat{10}| & \pcrepeat{10} \\
2116 % |\pcreturn| & \pcreturn \\
2117 % |\pcuntil| & \pcuntil \\
2118 % |\pcthen| & \pcthen \\
2119 % |\pctrue| & \pctrue \\
2120 % |\pcwhile| & \pcwhile \\
2121 % |\pcendwhile| & \pcendwhile \\
2122 % \end{tabular}
2123 % \end{center}
2124 % Note that |\pcdo|, |\pcin| and |\pcthen| have a leading space. This is due to their usual usage scenarios
2125 % such as
2126 % \pseudocodeblock{\pcfor i \pcin \{1,\ldots,10\}}
2127 % Furthermore all constants have a trailing space. This can be removed by adding the optional parameter [] such as
2128 % \pseudocodeblock{\pcfor i \pcin[] \{1,\ldots,10\}}
2129 % \iffalse
2130 %<*example>
2131 % \fi
2132 \begin{lstlisting}
2133 \pseudocodeblock{\pcfor i \pcin[] \{1,\ldots,10\}}
2134 \end{lstlisting}
2135 % \iffalse
2136 %</example>
2137 % \fi
2138 %
2139 % \index{highlight keywords}
2140 % \index{emphasize|see highlight keywords}
2141 % \index{\textbackslash highlightkeyword}
2142 % In order to change the font you can overwrite the command \lstinline{\highlightkeyword} which is defined as
2143 % \iffalse
2144 %<*example>
2145 % \fi
2146 \begin{lstlisting}
2147 \newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
2148 \end{lstlisting}
2149 % \iffalse
2150 %</example>
2151 % \fi
2152 %
2153 % \subsubsection{Automatic Syntax Highlighting (Experimental)}
2154 % The pseudocode command comes with an experimental (and rather slow) feature to automatically highlight keywords.
2155 % This can be activated via
2156 % the option \enquote{syntaxhighlight=auto}. The preset list of keywords it looks for are
2157 % \iffalse
2158 %<*example>
2159 % \fi
2160 \begin{lstlisting}
2161 for,foreach,{return },return,{ do },{ in },new,if, null, true,{until },{ to }, false,{ then},repeat,else if,elseif,while,else,done
2162 \end{lstlisting}
2163 % \iffalse
2164 %</example>
2165 % \fi
2166 % Note that the keywords are matched with spaces and note the grouping for trailing spaces. That is, the \enquote{ do } keyword won't match within the string \enquote{don't}.
2167 % Via the option \enquote{keywords} you can provide a custom list of keywords.
2168 % Thus the following bubblesort variant (taken from \url{http://en.wikipedia.org/wiki/Bubble_sort})
2169 % \procb[syntaxhighlight=auto]{Bubblesort(A : list of items)}{
2170 % n \gets \mathsf{length}(A) \\
2171 % repeat \\
2172 % \t s \gets false \\
2173 % \t for i = 1 to n-1 do \\
2174 % \t\t \pclinecomment{if this pair is out of order} \\
2175 % \t\t if A[i-1] > A[i] then \\
2176 % \t\t\t \pclinecomment{swap them and remember something changed} \\
2177 % \t\t\t \mathsf{swap}( A[i-1], A[i] ) \\
2178 % \t\t\t s \gets true \\
2179 % until \neg s }
2180 % \noindent can be typeset as
2181 % \iffalse
2182 %<*example>
2183 % \fi
2184 \begin{lstlisting}
2185 \procedureblock[syntaxhighlight=auto]{Bubblesort(A : list of items)}{
2186 n \gets \mathsf{length}(A) \\
2187 repeat \\
2188 \t s \gets false \\
2189 \t for i = 1 to n-1 do \\
2190 \t\t \pclinecomment{if this pair is out of order} \\
2191 \t\t if A[i-1] > A[i] then \\
2192 \t\t\t \pclinecomment{swap them and remember something changed} \\
2193 \t\t\t \mathsf{swap}( A[i-1], A[i] ) \\
2194 \t\t\t s \gets true \\
2195 until \neg s }
2196 \end{lstlisting}
2197 % \iffalse
2198 %</example>
2199 % \fi
2200 %
2201 % \index{addkeywords}
2202 % You can also define additional keywords using the \enquote{addkeywords} option.
2203 % This would allow us to specify \enquote{length} and \enquote{swap} in the above example.
2204 % \procb[syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
2205 % n \gets \mathsf{length}(A) \\
2206 % repeat \\
2207 % \t s \gets false \\
2208 % \t for i = 1 to n-1 do \\
2209 % \t\t \pclinecomment{if this pair is out of order} \\
2210 % \t\t if A[i-1] > A[i] then \\
2211 % \t\t\t \pclinecomment{swap them and remember something changed} \\
2212 % \t\t\t \mathsf{swap}( A[i-1], A[i] ) \\
2213 % \t\t\t s \gets true \\
2214 % until \neg s }
2215 % can be typeset as
2216 % \iffalse
2217 %<*example>
2218 % \fi
2219 \begin{lstlisting}
2220 \procedureblock[syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
2221 n \gets \mathsf{length}(A) \\
2222 repeat \\
2223 \t s \gets false \\
2224 \t for i = 1 to n-1 do \\
2225 \t\t \pclinecomment{if this pair is out of order} \\
2226 \t\t if A[i-1] > A[i] then \\
2227 \t\t\t \pclinecomment{swap them and remember something changed} \\
2228 \t\t\t \mathsf{swap}( A[i-1], A[i] ) \\
2229 \t\t\t s \gets true \\
2230 until \neg s }
2231 \end{lstlisting}
2232 % \iffalse
2233 %</example>
2234 % \fi
2235 % We can also combine automatic syntax highlighting with automatic spacing in which case we need
2236 % to insert \enquote{group end} keywords:
2237 % \procb[space=auto,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
2238 % n \gets length(A) \\
2239 % repeat \\
2240 % s \gets false \\
2241 % for i=1 to n-1 do \\
2242 % \pclinecomment{assuming this pair is out of order} \\
2243 % if A[i-1]>A[i] then \\
2244 % \pclinecomment{swap them and remember something changed} \\
2245 % swap(A[i-1], A[i]) \\
2246 % s \gets true \\
2247 % endif \\
2248 % endfor \\
2249 % until \neg s }
2250 %
2251 % \iffalse
2252 %<*example>
2253 % \fi
2254 \begin{lstlisting}
2255 \procedureblock[space=auto,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
2256 n \gets length(A) \\
2257 repeat \\
2258 s \gets false \\
2259 for i=1 to n-1 do \\
2260 \pclinecomment{assuming this pair is out of order} \\
2261 if A[i-1]>A[i] then \\
2262 \pclinecomment{swap them and remember something changed} \\
2263 swap(A[i-1], A[i]) \\
2264 s \gets true \\
2265 endif \\
2266 endfor \\
2267 until \neg s }
2268 \end{lstlisting}
2269 % \iffalse
2270 %</example>
2271 % \fi
2272 %
2273 % \subsubsection*{Alternative Keywords}
2274 % \index{altkeywords}
2275 % There is a second keyword list that you can add keywords to which are highlighted not via |\highlightkeyword| but via |\highlightaltkeyword|
2276 % where alt stands for alternate. This allows you to have two different keyword styles which are by default defined as
2277 % \iffalse
2278 %<*example>
2279 % \fi
2280 \begin{lstlisting}
2281 \newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
2282 \newcommand{\highlightaltkeyword}[1]{\ensuremath{\mathsf{#1}}}
2283 \end{lstlisting}
2284 % \iffalse
2285 %</example>
2286 % \fi
2287 % This allows you to rewrite the above example and emphasize the different nature of swap and length.
2288 % \procb[space=auto,syntaxhighlight=auto,altkeywords={swap,length}]{Bubblesort(A : list of items)}{
2289 % n \gets length(A) \\
2290 % repeat \\
2291 % s \gets false \\
2292 % for i=1 to n-1 do \\
2293 % \pclinecomment{assuming this pair is out of order} \\
2294 % if A[i-1]>A[i] then \\
2295 % \pclinecomment{swap them and remember something changed} \\
2296 % swap(A[i-1], A[i]) \\
2297 % s \gets true \\
2298 % endif \\
2299 % endfor \\
2300 % until \neg s }
2301 % \iffalse
2302 %<*example>
2303 % \fi
2304 \begin{lstlisting}
2305 \procedureblock[space=auto,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
2306 n \gets length(A) \\
2307 repeat \\
2308 s \gets false \\
2309 for i=1 to n-1 do \\
2310 \pclinecomment{assuming this pair is out of order} \\
2311 if A[i-1]>A[i] then \\
2312 \pclinecomment{swap them and remember something changed} \\
2313 swap(A[i-1], A[i]) \\
2314 s \gets true \\
2315 endif \\
2316 endfor \\
2317 until \neg s }
2318 \end{lstlisting}
2319 % \iffalse
2320 %</example>
2321 % \fi
2322 %
2323 % \subsubsection*{Draft Mode}
2324 % \index{nodraft}
2325 % \index{performance}
2326 % \index{draft mode}
2327 % Automatic syntax highlighting is a somewhat expensive operation as it requires several rounds of regular expression matching.
2328 % In order to speed up compilation the pseudocode command will not attempt automatic highlighting when the document is in draft mode.
2329 % When in draft mode and you want to force a specific instance of |\pseudocode| to render the code with automatic syntax
2330 % highlighting you can use the option |nodraft|.
2331 %
2332 %
2333 % \subsection{Line Numbering}
2334 % \index{line numbering}
2335 % \index{\textbackslash pcln}
2336 % \index{\textbackslash pclnr}
2337 % \index{\textbackslash pcrln}
2338 % The pseudocode command allows to insert line numbers into pseudocode.
2339 % You can either manually control line numbering or simply turn on the option
2340 % |linenumbering|.
2341 % \procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2342 % b \sample \bin \\
2343 % (\pk,\sk) \sample \kgen(\secparam) \\
2344 % \label{my:line:label} (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
2345 % c \sample \enc(\pk,m_b) \\
2346 % b' \sample \adv(\secparam, \pk, c) \\
2347 % \pcreturn b = b' }
2348 % is generated by
2349 % \iffalse
2350 %<*example>
2351 % \fi
2352 \begin{lstlisting}
2353 \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2354 b \sample \bin \\
2355 (\pk,\sk) \sample \kgen(\secparam) \\
2356 \label{my:line:label} (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
2357 c \sample \enc(\pk,m_b) \\
2358 b' \sample \adv(\secparam, \pk, c) \\
2359 \pcreturn b = b' }
2360 \end{lstlisting}
2361 % \iffalse
2362 %</example>
2363 % \fi
2364 % Note that you can use labels. In the above example |\label{my:line:label}| points to~\ref{my:line:label}.
2365 %
2366 % \subsubsection{Skipping Line Numbers}
2367 % \index{skipfirstln}
2368 % \index{\textbackslash pcskipln}
2369 %
2370 % When using automatic line numbering, you can skip line numbers by inserting a |\pcskipln| command.
2371 % This causes the line number on the \emph{next line} to be supressed. In order to suppress the first
2372 % line number use the option |skipfirstln|. Thus the following
2373 % \pcb[linenumbering,skipfirstln,mode=text]{
2374 % \pclinecomment{Some comment on first line} \\
2375 % Some code \pcskipln\\
2376 % \pclinecomment{Some other comment } \\
2377 % Some code }
2378 % is generated by
2379 % \iffalse
2380 %<*example>
2381 % \fi
2382 \begin{lstlisting}
2383 \pseudocodeblock[linenumbering,skipfirstln,mode=text]{
2384 \pclinecomment{Some comment on first line} \\
2385 Some code \pcskipln\\
2386 \pclinecomment{Some other comment } \\
2387 Some code }
2388 \end{lstlisting}
2389 % \iffalse
2390 %</example>
2391 % \fi
2392 %
2393 %
2394 % \subsubsection{Manually Inserting Line Numbers}
2395 % In order to manually insert line numbers use the command |\pcln|.
2396 % \procb{$\indcpa_\enc^\adv(\secparam)$}{%
2397 % \pcln b \sample \bin \\
2398 % \pcln (\pk,\sk) \sample \kgen(\secparam) \\
2399 % \pcln\label{my:line:label2} (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
2400 % \pcln c \sample \enc(\pk,m_b) \\
2401 % \pcln b' \sample \adv(\secparam, \pk, c) \\
2402 % \pcln \pcreturn b = b' }
2403 % is generated by
2404 % \iffalse
2405 %<*example>
2406 % \fi
2407 \begin{lstlisting}
2408 \procedure{$\indcpa_\enc^\adv(\secparam)$}{
2409 \pcln b \sample \bin \\
2410 \pcln (\pk,\sk) \sample \kgen(\secparam) \\
2411 \pcln\label{my:line:label2} (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
2412 \pcln c \sample \enc(\pk,m_b) \\
2413 \pcln b' \sample \adv(\secparam, \pk, c) \\
2414 \pcln \pcreturn b = b' }
2415 \end{lstlisting}
2416 % \iffalse
2417 %</example>
2418 % \fi
2419 % Note that labels also work when manually placing line numbers. In the above example
2420 % label \emph{my:line:label2} points to line number~\ref{my:line:label2}.
2421 %
2422 %
2423 %
2424 % \subsubsection{Start Values}
2425 % You can specify the start value (minus one) of the counter by setting the option |lnstart|.
2426 % \iffalse
2427 %<*example>
2428 % \fi
2429 \begin{lstlisting}
2430 \procedure[lnstart=10,linenumbering]{Header}{Body}
2431 \end{lstlisting}
2432 % \iffalse
2433 %</example>
2434 % \fi
2435 % \procb[lnstart=10,linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2436 % b \sample \bin \\
2437 % (\pk,\sk) \sample \kgen(\secparam) \\
2438 % (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
2439 % c \sample \enc(\pk,m_b) \\
2440 % b' \sample \adv(\secparam, \pk, c) \\
2441 % \pcreturn b = b' }
2442 %
2443 % \subsubsection{Separators}
2444 % \index{\textbackslash pclnseparator}
2445 % The command |\pclnseparator| defines the separator between code and line number. By
2446 % default the left separator is set to (:) colon. Also see Section~\ref{sec:protocol:separator}.
2447 %
2448 % \subsubsection{Style}
2449 % \index{\textbackslash pclnstyle}
2450 % The style in which line numbers are set can be controlled by redefining |\pclnstyle|.
2451 %
2452 % \iffalse
2453 %<*example>
2454 % \fi
2455 \begin{lstlisting}
2456 \renewcommand\pclnstyle[1]{\text{\scriptsize#1}}
2457 \end{lstlisting}
2458 % \iffalse
2459 %</example>
2460 % \fi
2461 % For example, to set line numbers in normal font and dot separated use
2462 %
2463 % \iffalse
2464 %<*example>
2465 % \fi
2466 \begin{lstlisting}
2467 \renewcommand{\pclnstyle}[1]{\text{#1}}
2468 \renewcommand{\pclnseparator}{.}
2469 \end{lstlisting}
2470 % \iffalse
2471 %</example>
2472 % \fi
2473 %
2474 % {
2475 % \renewcommand{\pclnstyle}[1]{\text{#1}}
2476 % \renewcommand{\pclnseparator}{.}
2477 % \procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2478 % b \sample \bin \\
2479 % (\pk,\sk) \sample \kgen(\secparam) \\
2480 % (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
2481 % c \sample \enc(\pk,m_b) \\
2482 % b' \sample \adv(\secparam, \pk, c) \\
2483 % \pcreturn b = b' }}
2484 %
2485 %
2486 % \subsection{Subprocedures}
2487 % \index{subprocedure}
2488 % The pseudocode package allows the typesetting of subprocedures such as
2489 %
2490 % \procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2491 % b \sample \bin \\
2492 % (\pk,\sk) \sample \kgen(\secparam) \\
2493 % (m_0,m_1) \sample \begin{subprocedure}%
2494 % \dbox{\procedure{$\adv(\secparam, \pk, c)$}{%
2495 % \text{Step 1} \\
2496 % \text{Step 2} \\
2497 % \pcreturn m_0, m_1 }}
2498 % \end{subprocedure} \\
2499 % c \sample \enc(\pk,m_b) \\
2500 % b' \sample \adv(\secparam, \pk, c) \\
2501 % \pcreturn b = b' }
2502 %
2503 % To create a subprocedure use the |subprocedure| environment. The above example is generated via
2504 % \iffalse
2505 %<*example>
2506 % \fi
2507 \begin{lstlisting}
2508 \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2509 b \sample \bin \\
2510 (\pk,\sk) \sample \kgen(\secparam) \\
2511 (m_0,m_1) \sample \begin{subprocedure}%
2512 \dbox{\procedure{$\adv(\secparam, \pk, c)$}{%
2513 \text{Step 1} \\
2514 \text{Step 2} \\
2515 \pcreturn m_0, m_1 }}
2516 \end{subprocedure} \\
2517 c \sample \enc(\pk,m_b) \\
2518 b' \sample \adv(\secparam, \pk, c) \\
2519 \pcreturn b = b' }
2520 \end{lstlisting}
2521 % \iffalse
2522 %</example>
2523 % \fi
2524 % Here the dbox command (from the dashbox package) is used to generate a dashed box around the sub procedure.
2525 %
2526 % \subsubsection{Numbering in Subprocedures}
2527 % As subprocedures are simply normal pseudocode blocks, you can use easily add line numbers.
2528 % By default the line numbering starts with 1 in a subprocedure while
2529 % ensuring that the outer numbering remains intact. Also note that the linenumbering on the outer procedure in the above example is inherited
2530 % by the subprocedure. For more control, either use manual numbering or set the
2531 % option \enquote{linenumbering=off} on the |\pseudocode| command within the subprocedure.
2532 %
2533 %
2534 %
2535 % \subsection{Stacking Procedures}\label{chap:stacking}
2536 % You can stack procedures horizontally or vertically using the environments \enquote{pchstack} and \enquote{pcvstack}.
2537 % \iffalse
2538 %<*example>
2539 % \fi
2540 \begin{lstlisting}
2541 \begin{pchstack}[options] body \end{pchstack}
2542 \begin{pcvstack}[options] body \end{pcvstack}
2543 \end{lstlisting}
2544 % \iffalse
2545 %</example>
2546 % \fi
2547 %
2548 % The following example displays two procedures next to one another. To space two horizontally outlined procedures
2549 % use the |space| option or manually insert spaces via |\pchspace| which takes an optional length as a parameter.
2550 %
2551 % \begin{pchstack}[boxed,center,space=1em]
2552 % \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{
2553 % b \sample \bin \\
2554 % (\pk,\sk) \sample \kgen(\secparam) \\
2555 % (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2556 % c \sample \enc(\pk,m_b) \\
2557 % b' \sample \adv(\secparam, \pk, c) \\
2558 % \pcreturn b = b' }
2559 %
2560 % \procedure[linenumbering,mode=text]{Oracle $O$}{
2561 % Some code \\
2562 % Some more code
2563 % }
2564 % \end{pchstack}
2565 %
2566 % \iffalse
2567 %<*example>
2568 % \fi
2569 \begin{lstlisting}
2570 \begin{pchstack}[boxed,center,space=1em]
2571 \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2572 b \sample \bin \\
2573 (\pk,\sk) \sample \kgen(\secparam) \\
2574 (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2575 c \sample \enc(\pk,m_b) \\
2576 b' \sample \adv(\secparam, \pk, c) \\
2577 \pcreturn b = b' }
2578
2579 % alternatively use \pchspace for spacing
2580
2581 \procedure[linenumbering,mode=text]{Oracle $O$}{%
2582 Some code \\
2583 Some more code
2584 }
2585 \end{pchstack}
2586 \end{lstlisting}
2587 % \iffalse
2588 %</example>
2589 % \fi
2590 %
2591 % Similarly you can stack two procedures vertically using the \enquote{pcvstack} environment. As a spacing
2592 % between two vertically stacked procedures again use either the |space| option or
2593 % insert space manually via |\pcvspace| which takes an optional length as a parameter.
2594 %
2595 % \begin{pcvstack}[boxed,center,space=0.5em]
2596 % \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2597 % b \sample \bin \\
2598 % (\pk,\sk) \sample \kgen(\secparam) \\
2599 % (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2600 % c \sample \enc(\pk,m_b) \\
2601 % b' \sample \adv(\secparam, \pk, c) \\
2602 % \pcreturn b = b' }
2603 %
2604 % \procedure[linenumbering,mode=text]{Oracle $O$}{
2605 % Some code \\
2606 % Some more code
2607 % }
2608 % \end{pcvstack}
2609 %
2610 %
2611 % \iffalse
2612 %<*example>
2613 % \fi
2614 \begin{lstlisting}
2615 \begin{pcvstack}[boxed,center,space=0.5em]]
2616 \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2617 b \sample \bin \\
2618 (\pk,\sk) \sample \kgen(\secparam) \\
2619 (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2620 c \sample \enc(\pk,m_b) \\
2621 b' \sample \adv(\secparam, \pk, c) \\
2622 \pcreturn b = b' }
2623
2624 % alternatively use \pcvspace for spacing
2625
2626 \procedure[linenumbering,mode=text]{Oracle $O$}{%
2627 Some code \\
2628 Some more code
2629 }
2630 \end{pcvstack}
2631 \end{lstlisting}
2632 % \iffalse
2633 %</example>
2634 % \fi
2635 %
2636 % Horizontal and vertical stacking can be combined
2637 % \begin{pcvstack}[boxed,center,space=1em]
2638 %
2639 % \begin{pchstack}[space=2em,center]
2640 % \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2641 % b \sample \bin \\
2642 % (\pk,\sk) \sample \kgen(\secparam) \\
2643 % (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2644 % c \sample \enc(\pk,m_b) \\
2645 % b' \sample \adv(\secparam, \pk, c) \\
2646 % \pcreturn b = b' }
2647 %
2648 % \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2649 % b \sample \bin \\
2650 % (\pk,\sk) \sample \kgen(\secparam) \\
2651 % (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2652 % c \sample \enc(\pk,m_b) \\
2653 % b' \sample \adv(\secparam, \pk, c) \\
2654 % \pcreturn b = b' }
2655 % \end{pchstack}
2656 %
2657 % \begin{pchstack}[space=0.25em]
2658 % \procedure[linenumbering,mode=text]{Oracle $O$}{
2659 % Some code \\
2660 % Some more code
2661 % }
2662 %
2663 % \procedure[linenumbering,mode=text]{Oracle $H_1$}{
2664 % Some code \\
2665 % Some more code
2666 % }
2667 %
2668 % \procedure[linenumbering,mode=text]{Oracle $H_2$}{
2669 % Some code \\
2670 % Some more code
2671 % }
2672 % \end{pchstack}
2673 % \end{pcvstack}
2674 %
2675 % \iffalse
2676 %<*example>
2677 % \fi
2678 \begin{lstlisting}
2679 \begin{pcvstack}[boxed,center,space=1em]
2680 \begin{pchstack}[center,space=2em]
2681
2682 \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{
2683 b \sample \bin \\
2684 (\pk,\sk) \sample \kgen(\secparam) \\
2685 (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2686 c \sample \enc(\pk,m_b) \\
2687 b' \sample \adv(\secparam, \pk, c) \\
2688 \pcreturn b = b' }
2689
2690 % alternatively use \pchspace for spacing
2691
2692 \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2693 b \sample \bin \\
2694 (\pk,\sk) \sample \kgen(\secparam) \\
2695 (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2696 c \sample \enc(\pk,m_b) \\
2697 b' \sample \adv(\secparam, \pk, c) \\
2698 \pcreturn b = b' }
2699
2700 \end{pchstack}
2701
2702 % alternatively use \pcvspace for spacing
2703
2704 \begin{pchstack}[space=0.25em]
2705 \procedure[linenumbering,mode=text]{Oracle $O$}{
2706 Some code \\
2707 Some more code
2708 }
2709
2710 \procedure[linenumbering,mode=text]{Oracle $H_1$}{
2711 Some code \\
2712 Some more code
2713 }
2714
2715 \procedure[linenumbering,mode=text]{Oracle $H_2$}{
2716 Some code \\
2717 Some more code
2718 }
2719 \end{pchstack}
2720 \end{pcvstack}
2721 \end{lstlisting}
2722 % \iffalse
2723 %</example>
2724 % \fi
2725 %
2726 % \subsubsection{Stacking Options}
2727 % \index{center}
2728 % \index{boxed}
2729 % \index{space}
2730 % \index{noindent}
2731 % \index{aboveskip}
2732 % \index{belowskip}
2733 %
2734 % The following keys are available on both |pchstack| and |pcvstack| environments
2735 % \begin{description}
2736 % \item[center]
2737 % Centers the stack.
2738 %
2739 % \item[boxed]
2740 % Draws a box around the stack.
2741 %
2742 % \item[space]
2743 % Controls the space between two pseudocode blocks within a stack. The default is 0pt
2744 % which can be adapted globally by redefining |\pchstackspace| or |\pcvstackspace|.
2745 %
2746 % \item[noindent]
2747 % Does not indent the stack. Only applies if option |center| is not used.
2748 %
2749 % \item[inline]
2750 % Ensures that no paragraph is added by |pchstack|. This cannot be used together with either |center| or |noindent|.
2751 %
2752 % \item[aboveskip]
2753 % By default the outer most stack adds vertical space above. The default space added
2754 % is |\abovedisplayskip| and can be adapted by redefining |\pcaboveskip|.
2755 %
2756 % \item[belowskip]
2757 % By default the outer most stack adds vertical space below. The default space added
2758 % is |\belowdisplayskip| and can be adapted by redefining |\pcbelowskip|. Note that
2759 % the defualt space below will not be added when used in a floating environment such as a figure.
2760 % However, when manually setting belowskip it will always be added.
2761 % \end{description}
2762 %
2763 % \subsection{Default Arguments}
2764 % \index{\textbackslash pcsetargs}
2765 % \index{\textbackslash pcsethstackargs}
2766 % \index{\textbackslash pcsetvstackargs}
2767 %
2768 % You can set the default arguments to be used with pseudocode blocks via |\pcsetargs|.
2769 % This is especially handy in stacking environments to add arguments to all enclosed
2770 % code blocks.
2771 % \begin{pchstack}[space=1em,center,boxed]
2772 % \renewcommand\pclnstyle[1]{#1}
2773 % \pcsetargs{linenumbering,mode=text,minlineheight=1cm,codesize=\Large{}}
2774 % \procedure{Some Procedue A}{%
2775 % Step 1\\
2776 % Step 2 }
2777 %
2778 %\procedure{Some Procedue B}{%
2779 %\text{Step 1}\\
2780 %\scriptsize$\begin{pcmbox}\begin{pmatrix} A \\ B + C \end{pmatrix}\end{pcmbox}$\\
2781 %\text{Step 3}}
2782 %
2783 %
2784 %\procedure{Some Procedue C}{
2785 % Step 1\\
2786 % Step 2 }
2787 %
2788 % \end{pchstack}
2789 % \iffalse
2790 %<*example>
2791 % \fi
2792 \begin{lstlisting}
2793 \begin{pchstack}[space=1em,center,boxed]
2794 % Do not change size to scriptsize for line numbers
2795 \renewcommand\pclnstyle[1]{#1}
2796
2797 % set default arguments for all pseudocode blocks in this hstack
2798 \pcsetargs{linenumbering,mode=text,minlineheight=1cm,codesize=\Large{}}
2799
2800 \procedure{Some Procedue A}{
2801 Step 1\\
2802 Step 2 }
2803
2804 \procedure{Some Procedue B}{
2805 \text{Step 1}\\
2806 \scriptsize$\begin{pcmbox}\begin{pmatrix}A \\ B + C \end{pmatrix}\end{pcmbox}$\\
2807 \text{Step 3}}
2808
2809 \procedure{Some Procedue C}{
2810 Step 1\\
2811 Step 2 }
2812 \end{pchstack}
2813 \end{lstlisting}
2814 % \iffalse
2815 %</example>
2816 % \fi
2817 %
2818 % \subsubsection*{Default Arguments for Stacking}
2819 % Similarly to |\pcsetargs| you can define default arguments for |hstack| and |vstack|
2820 % environments via |\pcsethstackargs| and |\pcsetvstackargs|.
2821 %
2822 % \subsection{Divisions and Linebreaks}
2823 % \index{linebreaks}
2824 % \index{\textbackslash hline}
2825 % Within the pseudocode command you generate linebreaks as |\\|. In order to specify the linewidth you can add an optional argument
2826 % \iffalse
2827 %<*example>
2828 % \fi
2829 % \begin{lstlisting}
2830 \\[height]
2831 \end{lstlisting}
2832 % \iffalse
2833 %</example>
2834 % \fi
2835 % Furthermore, you can add horizontal lines by using the second optional argument and write
2836 % \iffalse
2837 %<*example>
2838 % \fi
2839 \begin{lstlisting}
2840 \\[][\hline]
2841 \end{lstlisting}
2842 % \iffalse
2843 %</example>
2844 % \fi
2845 %
2846 % \procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{
2847 % b \sample \bin \\[2\baselineskip][\hline\hline]
2848 % (\pk,\sk) \sample \kgen(\secparam) \\
2849 % (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2850 % c \sample \enc(\pk,m_b) \\
2851 % b' \sample \adv(\secparam, \pk, c) \\
2852 % \pcreturn b = b' }
2853 %
2854 % \iffalse
2855 %<*example>
2856 % \fi
2857 \begin{lstlisting}
2858 \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
2859 b \sample \bin \\[2\baselineskip][\hline\hline]
2860 (\pk,\sk) \sample \kgen(\secparam) \\
2861 (m_0,m_1) \sample \adv^O(\secparam, \pk) \\
2862 c \sample \enc(\pk,m_b) \\
2863 b' \sample \adv(\secparam, \pk, c) \\
2864 \pcreturn b = b' }
2865 \end{lstlisting}
2866 % \iffalse
2867 %</example>
2868 % \fi
2869 %
2870 % \subsubsection{Optimizing Layout}
2871 %
2872 % In case you are laying out multiple procedures horizontally, procedures may be slightly
2873 % misaligned if the procedure headings are not of the same height. As an example, Consider
2874 % the following setup
2875 %
2876 %\begin{pchstack}[center,space=1ex]
2877 %\procedure[linenumbering]{Procedure $A$}{
2878 %\text{do}\\
2879 %\text{some} \\
2880 %\text{work}
2881 %}
2882 %
2883 %\procedure[linenumbering]{Procedure $B^{F^{h^*}}_{G_1}$}{
2884 %\text{do}\\
2885 %\text{some} \\
2886 %\text{work}
2887 %}
2888 %\end{pchstack}
2889 %
2890 % Here the sub and double superscripts in Procedure $B$ make the header slightly larger than
2891 % the maximum alotted space provided for headers which causes procedure $B$ to be slightly
2892 % shifted to the bottom. The best way to remedy such a situation is to use a combination
2893 % of the |headheight| and |headlinesep| properties to increase the header space in both procedures
2894 % and shift back the headline for a more compact visualization. As we here want to set some
2895 % arguments for all procedure blocks within the stacking environment we can use |\pcsetargs|.
2896 %
2897 %\begin{pchstack}[center,space=1ex]
2898 %\pcsetargs{headheight=5ex,headlinesep=-1ex}
2899 %
2900 %\procedure[linenumbering]{Procedure $A$}{
2901 %\text{do}\\
2902 %\text{some} \\
2903 %\text{work}
2904 %}
2905 %
2906 %\procedure[linenumbering]{Procedure $B^{F^{h^*}}_{G_1}$}{
2907 %\text{do}\\
2908 %\text{some} \\
2909 %\text{work}
2910 %}
2911 %\end{pchstack}
2912 %
2913 % \iffalse
2914 %<*example>
2915 % \fi
2916 \begin{lstlisting}
2917 \begin{pchstack}[center,space=1ex]
2918 \pcsetargs{headheight=5ex,headlinesep=-1ex}
2919
2920 \procedure[linenumbering]{Procedure $A$}{
2921 \text{do}\\
2922 \text{some} \\
2923 \text{work}
2924 }
2925
2926 \procedure[linenumbering]{Procedure $B^{F^{h^*}}_{G_1}$}{
2927 \text{do}\\
2928 \text{some} \\
2929 \text{work}
2930 }
2931 \end{pchstack}
2932 \end{lstlisting}
2933 % \iffalse
2934 %</example>
2935 % \fi
2936 %
2937 % \subsection{Matrices and Math Environments within Pseudocode}
2938 %
2939 % In order to work its magic, cryptocode (in particular within the \lstinline{\pseudocode} command) mingles with a few low level commands such as
2940 % \lstinline{\\} or \lstinline{\halign}. The effect of this is, that when you use certain math environments, for example, to create matrices, within pseudocode
2941 % the result may be unexpected. Consider the following example
2942 %
2943 % \iffalse
2944 %<*example>
2945 % \fi
2946 \begin{lstlisting}
2947 \pseudocodeblock{
2948 \text{compute } P = \begin{pmatrix}
2949 A \\ B + C
2950 \end{pmatrix}
2951 }
2952 \end{lstlisting}
2953 % \iffalse
2954 %</example>
2955 % \fi
2956 % which, somewhat unexpectedly, yields
2957 % \pcb{
2958 % \text{compute } P = \begin{pmatrix}
2959 % A \\ B + C
2960 % \end{pmatrix}
2961 % }
2962 %
2963 % Here, the alignment is somewhat off. In order, to allow for the \emph{pmatrix} environment
2964 % to properly work without interference from |\pseudocode|
2965 % you can wrap it into a |pcmbox| environment (where pcmbox is short for pseudocode math box).
2966 % This ensures that the low-level changes introduced by |\pseudocode| are not active.
2967 %
2968 % \iffalse
2969 %<*example>
2970 % \fi
2971 \begin{lstlisting}
2972 \pseudocodeblock{
2973 \text{compute } P = \begin{pcmbox}\begin{pmatrix}
2974 A \\ B + C
2975 \end{pmatrix}\end{pcmbox}
2976 }
2977 \end{lstlisting}
2978 % \iffalse
2979 %</example>
2980 % \fi
2981 %
2982 % \begin{center}
2983 % \fbox{
2984 % \pseudocode{
2985 % \text{compute } P = \begin{pcmbox}\begin{pmatrix}
2986 % A \\ B + C
2987 % \end{pmatrix}\end{pcmbox}
2988 % }
2989 % }
2990 % \end{center}
2991 %
2992 % \subsection{Fancy Code with Overlays}
2993 %
2994 % Consider the \indcpa\ game. Here we have a single adversary $\adv$ that is called twice, first to output two messages and
2995 % which is then given the ciphertext of one of the messages in order to \enquote{guess} which one was encrypted.
2996 % Often this is not visualized.
2997 % Sometimes an additional state $\state$ is passed as we have in the following example on the left. On the right,
2998 % we visualize the same idea in a slightly more fancy way.
2999 %
3000 % \begin{pchstack}[center,space=1cm]
3001 %
3002 % \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
3003 % b \sample \bin \\
3004 % (\pk,\sk) \sample \kgen (\secparam) \\
3005 % (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start} \\
3006 % c \sample \enc(\pk,m_b) \\
3007 % b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end} \\
3008 % \pcreturn b = b' }
3009 %
3010 % \begin{pcimage}
3011 % \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
3012 % b \sample \bin \\
3013 % (\pk,\sk) \sample \kgen (\secparam) \\
3014 % (m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start} \\
3015 % c \sample \enc(\pk,m_b) \\
3016 % b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end} \\
3017 % \pcreturn b = b' }
3018 %
3019 % \pcdraw{
3020 % \path[->] (start) edge[bend left=50] node[right]{$\state$} (start|-end);
3021 % }
3022 % \end{pcimage}
3023 % \end{pchstack}
3024 %
3025 % The image on the right is generated by:
3026 % \iffalse
3027 %<*example>
3028 % \fi
3029 \begin{lstlisting}
3030 \begin{pcimage}
3031 \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
3032 b \sample \bin \\
3033 (\pk,\sk) \sample \kgen (\secparam) \\
3034 (m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start} \\
3035 c \sample \enc(\pk,m_b) \\
3036 b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end} \\
3037 \pcreturn b = b' }
3038
3039 \pcdraw{
3040 \path[->] (start) edge[bend left=50] node[right]{$\state$} (start|-end);
3041 }
3042 \end{pcimage}
3043 \end{lstlisting}
3044 % \iffalse
3045 %</example>
3046 % \fi
3047 %
3048 % In order to achieve the above effect cryptocode utilizes TIKZ underneath. The
3049 % |\pcnode| command generates TIKZ nodes and additionally we wrapped the
3050 % pseudocode (or procedure) command in an |\begin{pcimage}\end{pcimage}| environment
3051 % which allows us to utilize these nodes later, for example using the |\pcdraw|
3052 % command. We can achieve a similar effect without an additional pcimage environment by
3053 % using the optional argument of |\pcnode| for the TIKZ code.
3054 %
3055 % \iffalse
3056 %<*example>
3057 % \fi
3058 \begin{lstlisting}
3059 \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
3060 b \sample \bin \\
3061 (\pk,\sk) \sample \kgen (\secparam) \\
3062 (m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start} \\
3063 c \sample \enc(\pk,m_b) \\
3064 b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end}[draw={
3065 \path[->] (start) edge[bend left=50] node[right]{$\state$} (start|-end);
3066 }] \\
3067 \pcreturn b = b' }
3068 \end{lstlisting}
3069 % \iffalse
3070 %</example>
3071 % \fi
3072 %
3073 % \subsubsection*{Example: Explain your Code}
3074 % As an exmaple of what you can do with this, let us put an explanation to a line of the code.
3075 %
3076 % \begin{pcimage}
3077 % \procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
3078 % b \sample \bin \\
3079 % (\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen} \\
3080 % (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
3081 % c \sample \enc(\pk,m_b) \\
3082 % b' \sample \adv(\secparam, \pk, c, \state) \\
3083 % \pcreturn b = b' }
3084 %
3085 % \pcdraw{
3086 % \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
3087 % at ([shift={(+3,+1)}]kgen) {
3088 % \begin{varwidth}{3cm}
3089 % $\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
3090 % \end{varwidth}
3091 % };
3092 % }
3093 % \end{pcimage}
3094 %
3095 % \iffalse
3096 %<*example>
3097 % \fi
3098 \begin{lstlisting}
3099 \begin{pcimage}
3100 \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
3101 b \sample \bin \\
3102 (\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen} \\
3103 (m_0,m_1) \sample \adv(\secparam, \pk, c) \\
3104 c \sample \enc(\pk,m_b) \\
3105 b' \sample \adv(\secparam, \pk, c, \state) \\
3106 \pcreturn b = b' }
3107
3108 \pcdraw{
3109 \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
3110 at ([shift={(+3,+1)}]kgen) {
3111 \begin{varwidth}{3cm}
3112 $\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
3113 \end{varwidth}
3114 };
3115 }
3116 \end{pcimage}
3117 \end{lstlisting}
3118 % \iffalse
3119 %</example>
3120 % \fi
3121 %
3122 % \amipagebreak
3123 % \section{Tabbing Mode}
3124 % \label{chap:tabbing}
3125 % \index{\&}
3126 % \index{Tabbing Mode}
3127 % \index{\textbackslash\textlangle{}}
3128 % \index{\textbackslash\textrangle{}}
3129 % In the following section we discuss how to create multiple columns within a |\pseudocode| command.
3130 % Within a |\pseudocode| command you can switch to a new column by inserting a |\>|.
3131 % This is similar to using an |align| environment and placing a tabbing character (\&). Also,
3132 % similarly to using |align| you should ensure that the number of |\>| are identical
3133 % on each line.
3134 % \pcb{%
3135 % \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
3136 % b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
3137 % \iffalse
3138 %<*example>
3139 % \fi
3140 \begin{lstlisting}
3141 \pseudocodeblock{
3142 \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
3143 b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
3144 \end{lstlisting}
3145 % \iffalse
3146 %</example>
3147 % \fi
3148 % As you can see the first column is left aligned the second right, the third left and so forth.
3149 % In order to get only left aligned columns you could thus simply always skip a column by
3150 % using |\>\>|. You can also use |\<| a shorthand for |\>\>|.
3151 % \pcb{%
3152 % \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
3153 % b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
3154 % \iffalse
3155 %<*example>
3156 % \fi
3157 \begin{lstlisting}
3158 \pseudocodeblock{
3159 \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
3160 b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
3161 \end{lstlisting}
3162 % \iffalse
3163 %</example>
3164 % \fi
3165 %
3166 % \paragraph{Column Spacing}
3167 % \index{colsep}
3168 % \index{addtolength}
3169 % You can control the space between columns using the option \enquote{colsep=2em}. Note that when doing so you should
3170 % additionally use \enquote{addtolength=5em} (where 5em depends on the number of columns) in order to avoid having
3171 % overfull hboxes.
3172 % \pcb[colsep=1em,addtolength=10em]{%
3173 % \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
3174 % b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
3175 % \iffalse
3176 %<*example>
3177 % \fi
3178 \begin{lstlisting}
3179 \pseudocodeblock[colsep=1em,addtolength=10em]{%
3180 \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
3181 b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
3182 \end{lstlisting}
3183 % \iffalse
3184 %</example>
3185 % \fi
3186 %
3187 % This is basically all you need to know in order to go on to writing protocols with the
3188 % cryptocode package. So unless you want to know a bit more about tabbing (switching columns)
3189 % and learn some of the internals, feel free to proceed to Section~\ref{chap:protocols}.
3190 %
3191 % \subsection{Tabbing in Detail}
3192 % \index{mintabmode}
3193 % At the heart of the pseudocode package is an align (or rather a flalign*) environment which allows you to use basic math notation.
3194 % Usually an align (or flalign) environment uses \& as tabbing characters.
3195 % The pseudocode comes in two modes the first of which changes the default align behavior.
3196 % That is, it automatically adds a tabbing character to the beginning and end of each line
3197 % and changes the tabbing character to |\>|. This mode is called \emph{mintabmode} and is active by default.
3198 %
3199 % In mintabmode in order to make use of extra columns in the align environment
3200 % (which we will use shortly in order to write protocols) you can use |\>| as you would use \& normally.
3201 % But, don't forget that there is an alignment tab already placed at the beginning and end of each line. So the following example
3202 % \pcb{%
3203 % \textbf{Alice} \> \> \textbf{Bob} \\
3204 % b \sample \bin \> \> \\
3205 % \> \xrightarrow{\text{send over } b} \> \\
3206 % \> \> \text{do something}}
3207 % is generated by
3208 % \iffalse
3209 %<*example>
3210 % \fi
3211 \begin{lstlisting}
3212 \pseudocodeblock{
3213 \textbf{Alice} \> \> \textbf{Bob} \\
3214 b \sample \bin \> \> \\
3215 \> \xrightarrow{\text{send over } b} \> \\
3216 \> \> \text{do something}}
3217 \end{lstlisting}
3218 % \iffalse
3219 %</example>
3220 % \fi
3221 %
3222 % \subsubsection{Overriding The Tabbing Character}
3223 % \index{\textbackslash pctabname}
3224 % If you don't like |\>| as the tabbing character you can choose a custom command by overwriting |\pctabname|.
3225 % For example
3226 % \iffalse
3227 %<*example>
3228 % \fi
3229 \begin{lstlisting}
3230 \renewcommand{\pctabname}{\myTab}
3231
3232 \pseudocode{
3233 \textbf{Alice} \myTab \myTab \textbf{Bob} \\
3234 b \sample \bin \myTab \myTab \\
3235 \myTab \xrightarrow{\text{send over } b} \myTab \\
3236 \myTab \myTab \text{do something}}
3237 \end{lstlisting}
3238 % \iffalse
3239 %</example>
3240 % \fi
3241 % Similarly you can redefine the double tabbing character |\<| by overwriting |\pcdbltabname| (also see Section~\ref{chap:protocols}).
3242 %
3243 % \subsubsection{Custom Line Spacing and Horizontal Rules}
3244 % \index{\textbackslash pclb}
3245 % As explained, underlying the pseudocode command is an flalign environment. This would allow the use
3246 % of |\\[spacing]| to specifiy the spacing between two lines or of |[\\\hline]|
3247 % to insert a horizontal rule. In order to achieve the same effect within the pseudocode command you
3248 % can use |\\[spacing][\hline]|. You can also use |\pclb| to get a line break which
3249 % does not insert the additional alignment characters.
3250 %
3251 % \amipagebreak
3252 % \section{Protocols}
3253 % \label{chap:protocols}
3254 %
3255 % Using tabbing, we can use |\pseudocode| to also layout protocols such as
3256 % \procb{My Protocol}{
3257 % \textbf{Alice} \> \> \textbf{Bob} \\
3258 % b \sample \bin \> \> \\
3259 % \> \xrightarrow{\text{send over } b} \> \\
3260 % \> \> \text{do something} \\
3261 % \> \xleftarrow{\text{send over sth. else}} \> \\
3262 % \text{finalize} \> \>}
3263 % which is generated as
3264 % \iffalse
3265 %<*example>
3266 % \fi
3267 \begin{lstlisting}
3268 \procedureblock{My Protocol}{
3269 \textbf{Alice} \> \> \textbf{Bob} \\
3270 b \sample \bin \> \> \\
3271 \> \xrightarrow{\text{send over } b} \> \\
3272 \> \> \text{do something} \\
3273 \> \xleftarrow{\text{send over sth. else}} \> \\
3274 \text{finalize} \> \>}
3275 \end{lstlisting}
3276 % \iffalse
3277 %</example>
3278 % \fi
3279 % \index{\textbackslash sendmessage}%
3280 % \index{\textbackslash sendmessage*}%
3281 % \index{\textbackslash sendmessageright*}
3282 % \index{\textbackslash sendmessageright}
3283 % \index{\textbackslash sendmessageleft*}
3284 % \index{\textbackslash sendmessageleft}
3285 % In order to get nicer message arrows use the commands |\sendmessageright*{message}|, |\sendmessageleft*{message}|, and
3286 % |\sendmessagerightleft*{message}|.
3287 % All three take an additional optional argument specifying the length of the arrow and all
3288 % wrap their mandatory argument in an |aligned| environment.
3289 % \iffalse
3290 %<*example>
3291 % \fi
3292 \begin{lstlisting}
3293 \sendmessageright*[3.5cm]{message}
3294 \sendmessageleft*[3.5cm]{message}
3295 \end{lstlisting}
3296 % \iffalse
3297 %</example>
3298 % \fi
3299 %
3300 % \procb{My Protocol}{
3301 % \textbf{Alice} \> \> \textbf{Bob} \\
3302 % b \sample \bin \> \> \\
3303 % \> \sendmessageright*{\text{send over } b} \> \\
3304 % \> \> \text{do something} \\
3305 % \> \sendmessageleft*{\text{send over sth. else}} \> \\
3306 % \text{finalize} \> \> }
3307 % \iffalse
3308 %<*example>
3309 % \fi
3310 \begin{lstlisting}
3311 \procedureblock{My Protocol}{%
3312 \textbf{Alice} \> \> \textbf{Bob} \\
3313 b \sample \bin \> \> \\
3314 \> \sendmessageright*{\text{send over } b} \> \\
3315 \> \> \text{do something} \\
3316 \> \sendmessageleft*{\text{send over sth. else}} \> \\
3317 \text{finalize} \> \> }
3318 \end{lstlisting}
3319 % \iffalse
3320 %</example>
3321 % \fi
3322 %
3323 % To obtain granular control over how messages are set use the |\sendmessage| and
3324 % |\sendmessage*| commands. These take two parameters, the first being the message style
3325 % for the underlying TIKZ path (e.g., |->| for messages to the right) and the second
3326 % a key value list of arguments. The difference between the starred version and the
3327 % unstarred version is that the starred version wraps its labels in an |aligned|
3328 % environment. Following is an example, that showcases various message options.
3329 % \procedureblock{My Protocol}{
3330 % \textbf{Alice} \> \> \textbf{Bob} \\
3331 % b \sample \bin \> \> \\
3332 % \> \sendmessage{->}{centercol=3,top=send over $b$,bottom=Text below,topstyle={draw,solid,yshift=0.25cm},style={dashed}} \> \\
3333 % \> \> \text{do something} \\
3334 % \> \sendmessage{<-}{length=8cm,top=send over sth. else} \> \\
3335 % \> \sendmessage*{<->}{length=8cm,top={{a,b, c\\c,d, e}},bottom={foo}} \> \\
3336 % \> \sendmessage{<->}{length=8cm,top=\pseudocode[linenumbering]{\text{you can also}\\\text{use pseudocode}},bottom={foo}} \> \\
3337 % \text{finalize} \> \> }
3338 % \iffalse
3339 %<*example>
3340 % \fi
3341 \begin{lstlisting}
3342 \procedureblock{My Protocol}{
3343 \textbf{Alice} \> \> \textbf{Bob} \\
3344 b \sample \bin \> \> \\
3345 \> \sendmessage{->}{centercol=3,top=send over $b$,bottom=Text below,topstyle={draw,solid,yshift=0.25cm},style={dashed}} \> \\
3346 \> \> \text{do something} \\
3347 \> \sendmessage{<-}{length=8cm,top=send over sth. else} \> \\
3348 \> \sendmessage*{<->}{length=8cm,top={{a,b, c\\c,d, e}},bottom={foo}} \> \\
3349 \> \sendmessage{<->}{length=8cm,top=\pseudocode[linenumbering]{\text{you can also}\\\text{use pseudocode}},bottom={foo}} \> \\
3350 \text{finalize} \> \> }
3351 \end{lstlisting}
3352 % \iffalse
3353 %</example>
3354 % \fi
3355 % |sendmessage| and |sendmessage*| support the following options:
3356 % \begin{description}
3357 % \item[top]
3358 % The content to display on top of the arrow.
3359 % \item[bottom]
3360 % The content to display below the arrow.
3361 % \item[left]
3362 % The content to display on the left of the arrow.
3363 % \item[right]
3364 % The content to display on the right of the arrow.
3365 % \item[topstyle]
3366 % The TIKZ style to be used for the top node.
3367 % \item[bottomstyle]
3368 % The TIKZ style to be used for the bottom node.
3369 % \item[rightstyle]
3370 % The TIKZ style to be used for the right node.
3371 % \item[leftstyle]
3372 % The TIKZ style to be used for the left node.
3373 % \item[length]
3374 % The length of the arrow.
3375 % \item[style]
3376 % The style of the arrow.
3377 % \item[width]
3378 % The width of the column
3379 % \item[centercol]
3380 % Can be used to ensure that the message is displayed in the center. This should be set to the
3381 % column index. In the above example, the message column is the third column (note that there is
3382 % a column left of alice that is automatically inserted).
3383 % \end{description}
3384 %
3385 % \subsection{Tabbing}
3386 % When typesetting protocols you might find that using two tabs instead of a single tab usually provides
3387 % a better result as this ensures that all columns are left aligned.
3388 % For this you can use |\<| instead of |\>| (see Section~\ref{chap:tabbing}).
3389 %
3390 % \medskip
3391 % Following is once more the example from before but now with double tapping.
3392 % \procb{My Protocol}{
3393 % \textbf{Alice} \< \< \textbf{Bob} \\
3394 % b \sample \bin \< \< \\
3395 % \< \sendmessageright*{\text{send over } b} \< \\
3396 % \< \< \text{do something} \\
3397 % \< \sendmessageleft*{\text{send over sth. else}} \< \\
3398 % \text{finalize} \< \< }
3399 %
3400 % \subsection{Multiline Messages}
3401 % Using the starred send message commands you can easily generate multiline messages as the command
3402 % wraps an \emph{aligned} environment around the message.
3403 % \procb{My Protocol}{%
3404 % \textbf{Alice} \< \< \textbf{Bob} \\
3405 % b \sample \bin \< \< \\
3406 % \< \sendmessageright*{\text{send over } b\\ \text{second line}} \< \\
3407 % \< \< \text{do something} \\
3408 % \< \sendmessage*{<-}{top={\>\text{left aligned}\\ \> \text{multiline message}}} \< \\
3409 % \text{finalize} \< \<}
3410 % \iffalse
3411 %<*example>
3412 % \fi
3413 \begin{lstlisting}
3414 \procedureblock{My Protocol}{%
3415 \textbf{Alice} \< \< \textbf{Bob} \\
3416 b \sample \bin \< \< \\
3417 \< \sendmessageright*{\text{send over } b\\ \text{second line}} \< \\
3418 \< \< \text{do something} \\
3419 \< \sendmessage*{<-}{top={\>\text{left aligned}\\ \> \text{multiline message}}} \< \\
3420 \text{finalize} \< \<}
3421 \end{lstlisting}
3422 % \iffalse
3423 %</example>
3424 % \fi
3425 %
3426 % \textbf{Remark. } When using |\sendmessage*| the tabbing character |&| cannot be used.
3427 % Instead use the |\>| command as defined within |\pseudocode|.
3428 %
3429 % \subsubsection{Multiplayer Protocols}
3430 %
3431 % You are not limited to two players. In order to send messages skipping players
3432 % use |\sendmessagerightx| and |\sendmessageleftx|.
3433 % \iffalse
3434 %<*example>
3435 % \fi
3436 \begin{lstlisting}
3437 \sendmessagerightx[width]{columnspan}{Text}
3438 \sendmessageleftx[width]{columnspan}{Text}
3439 \end{lstlisting}
3440 % \iffalse
3441 %</example>
3442 % \fi
3443 %
3444 % \procb{Multiparty Protocol}{
3445 % \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\
3446 % \text{work} \< \< \< \< \\
3447 % \< \sendmessageright{top=Work result} \< \< \< \\
3448 % \< \< \text{work} \< \< \\
3449 % \< \< \< \sendmessageright{top=Work result,bottom=Bottom message} \< \\
3450 % \< \< \< \< \text{work} \\
3451 % \< \sendmessageleftx[7cm]{8}{\text{A long message for Alice}} \< \\
3452 % \text{finalize} \< \< \< \< }
3453 %
3454 % \iffalse
3455 %<*example>
3456 % \fi
3457 \begin{lstlisting}
3458 \procedureblock{Multiparty Protocol}{%
3459 \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\
3460 \text{work} \< \< \< \< \\
3461 \< \sendmessageright{top=Work result} \< \< \< \\
3462 \< \< \text{work} \< \< \\
3463 \< \< \< \sendmessageright{top=Work result,bottom=Bottom message} \< \\
3464 \< \< \< \< \text{work} \\
3465 \< \sendmessageleftx[7cm]{8}{\text{A long message for Alice}} \< \\
3466 \text{finalize} \< \< \< \< }
3467 \end{lstlisting}
3468 % \iffalse
3469 %</example>
3470 % \fi
3471 % Note that for the last message from Charlie to Alice we needed to specify the number of passed
3472 % over colums (|\sendmessageleftx[7cm]{8}{message}|). As we were passing
3473 % 4 |\<| where each creates 2 columns, the total was 8 columns.
3474 %
3475 % \subsubsection{Divisions}
3476 % You can use |\pcintertext| in order to divide protocols (or other pseudocode for that matter).
3477 % \iffalse
3478 %<*example>
3479 % \fi
3480 \begin{lstlisting}
3481 \pcintertext[dotted|center]{Division Text}
3482 \end{lstlisting}
3483 % \iffalse
3484 %</example>
3485 % \fi
3486 % Note that in order to use the |\pcintertext| you need to use |\pclb| as the line break for the line
3487 % before. Also see Section~\ref{chap:tabbing}.
3488 %
3489 % \procb{My Protocol}{
3490 % \textbf{Alice} \< \< \textbf{Bob} \\
3491 % b \sample \bin \< \< \pclb
3492 % \pcintertext[dotted]{Some Division} \\
3493 % \< \sendmessageright*{\text{send over } b} \< \\
3494 % \< \< \text{do something} \pclb
3495 % \pcintertext[dotted]{Another Division} \\
3496 % \< \sendmessageleft*{\text{message}} \< \\
3497 % \text{finalize} \< \< }
3498 %
3499 % \iffalse
3500 %<*example>
3501 % \fi
3502 \begin{lstlisting}
3503 \procedureblock{My Protocol}{%
3504 \textbf{Alice} \< \< \textbf{Bob} \\
3505 b \sample \bin \< \< \pclb
3506 \pcintertext[dotted]{Some Division} \\
3507 \< \sendmessageright*{\text{send over } b} \< \\
3508 \< \< \text{do something} \pclb
3509 \pcintertext[dotted]{Another Division} \\
3510 \< \sendmessageleft*{\text{message}} \< \\
3511 \text{finalize} \< \< }
3512 \end{lstlisting}
3513 % \iffalse
3514 %</example>
3515 % \fi
3516 %
3517 % \subsection{Line Numbering in Protocols}
3518 % Protocols can be numbered similarly to plain pseudocode. Additionally to the
3519 % |\pcln| there are the commands |\pclnr| and |\pcrln|. The first
3520 % allows you to right align line numbers but uses the same counter as
3521 % |\pcln|. The second uses a different counter.
3522 %
3523 % \procb{My Protocol}{%
3524 % \pcln \textbf{Alice} \< \< \textbf{Bob} \< \\
3525 % \pcln b \sample \bin \< \< \< \\
3526 % \< \sendmessageright*{\text{send over } b} \< \< \pclnr\\
3527 % \< \< \text{do something} \< \pclnr \\
3528 % \< \sendmessageleft*{\text{send over sth. else}} \<\< \pclnr \\
3529 % \pcln \text{finalize} \< \< \<}
3530 % Which is generated as
3531 % \iffalse
3532 %<*example>
3533 % \fi
3534 \begin{lstlisting}
3535 \procedureblock{My Protocol}{
3536 \pcln \textbf{Alice} \< \< \textbf{Bob} \< \\
3537 \pcln b \sample \bin \< \< \< \\
3538 \< \sendmessageright*{\text{send over } b} \< \< \pclnr\\
3539 \< \< \text{do something} \< \pclnr \\
3540 \< \sendmessageleft*{\text{send over sth. else}} \<\< \pclnr \\
3541 \pcln \text{finalize} \< \< \<}
3542 \end{lstlisting}
3543 % \iffalse
3544 %</example>
3545 % \fi
3546 %
3547 % And using |\pcrln| we obtain:
3548 % \procb{My Protocol}{%
3549 % \pcln \textbf{Alice} \< \< \textbf{Bob} \< \\
3550 % \pcln b \sample \bin \< \< \< \\
3551 % \< \sendmessageright*{\text{send over } b} \<\< \pcrln\\
3552 % \< \< \text{do something} \< \pcrln \\
3553 % \< \sendmessageleft*{\text{send over sth. else}} \< \< \pcrln \\
3554 % \pcln \text{finalize} \< \< \< }
3555 % This is generated as
3556 % \iffalse
3557 %<*example>
3558 % \fi
3559 \begin{lstlisting}
3560 \procedureblock{My Protocol}{%
3561 \pcln \textbf{Alice} \< \< \textbf{Bob} \\
3562 \pcln b \sample \bin \< \< \\
3563 \< \sendmessageright*{\text{send over } b} \< \pcrln\\
3564 \< \< \text{do something} \pcrln \\
3565 \< \sendmessageleft*{\text{send over sth. else}} \< \pcrln \\
3566 \pcln \text{finalize} \< \< }
3567 \end{lstlisting}
3568 % \iffalse
3569 %</example>
3570 % \fi
3571 %
3572 % \subsubsection{Separators}
3573 % \label{sec:protocol:separator}
3574 % The commands |\pclnseparator| and |\pcrlnseparator| define the separators between code and line number.
3575 % By default the left separator is set to (:) colon and the right separator is set to an empty string.
3576 %
3577 % \subsubsection{Spacing}
3578 % Spacings after the left separator and in front of the right separator can be controlled by
3579 % |\pclnspace| and |\pclnrspace| which are set to 1em and 0.5em, respectively.
3580 %
3581 % \amipagebreak
3582 %
3583 % \subsection{Sub Protocols}
3584 %
3585 % Use the |subprocedure| environemnt to also create sub protocols.
3586 %
3587 % \procb{My Protocol}{
3588 % \textbf{Alice} \< \< \textbf{Bob} \\
3589 % b \sample \bin \< \< \\
3590 % \< \sendmessageright*{\text{send over } b} \< \\
3591 % \< \< \text{do something} \\
3592 % \<\< \dbox{\begin{subprocedure}\procedure{Subprotocol}{
3593 % \< \< \textbf{Charlie} \\
3594 % \text{something more} \< \< \\
3595 % \< \sendmessageright*[1.5cm]{\text{message}} \< \\
3596 % \< \< \text{some processing} \\
3597 % \< \< \text{more processing} \\
3598 % \< \sendmessageleft*[1.5cm]{\text{message}} \< \\
3599 % \< \sendmessageright*[1.5cm]{\text{message}} \< \\
3600 % \< \sendmessageleft*[1.5cm]{\text{message}} \< \\
3601 % }\end{subprocedure}} \\
3602 % \< \sendmessageleft*{\text{send over sth. else}} \< \\
3603 % \text{finalize} \< \< }
3604 %
3605 % \iffalse
3606 %<*example>
3607 % \fi
3608 \begin{lstlisting}
3609 \procedureblock{My Protocol}{
3610 \textbf{Alice} \< \< \textbf{Bob} \\
3611 b \sample \bin \< \< \\
3612 \< \sendmessageright*{\text{send over } b} \< \\
3613 \< \< \text{do something} \\
3614 \<\< \dbox{\begin{subprocedure}\procedure{Subprotocol}{
3615 \< \< \textbf{Charlie} \\
3616 \text{something more} \< \< \\
3617 \< \sendmessageright*[1.5cm]{\text{message}} \< \\
3618 \< \< \text{some processing} \\
3619 \< \< \text{more processing} \\
3620 \< \sendmessageleft*[1.5cm]{\text{message}} \< \\
3621 \< \sendmessageright*[1.5cm]{\text{message}} \< \\
3622 \< \sendmessageleft*[1.5cm]{\text{message}} \< \\
3623 }\end{subprocedure}} \\
3624 \< \sendmessageleft*{\text{send over sth. else}} \< \\
3625 \text{finalize} \< \< }
3626 \end{lstlisting}
3627 % \iffalse
3628 %</example>
3629 % \fi
3630 %
3631 % \subsection{Compact Presentation of Protocols}
3632 %
3633 % In order to present protocols more compactly you can use the |colspace| option
3634 % which adds space inbetween two columns. When set to a negative space, this has
3635 % the effect that columns overlap. The following example is once more our above
3636 % example using a sub protocol but this time with |colspace=-1cm|. Note that
3637 % the sub protocol inherits the option which is why both the outer and the inner
3638 % protocol now have overlapping columns.
3639 %
3640 % \procb[colspace=-1cm]{My Protocol}{
3641 % \textbf{Alice} \< \< \textbf{Bob} \\
3642 % b \sample \bin \< \< \\
3643 % \< \sendmessageright*{\text{send over } b} \< \\
3644 % \< \< \text{do something} \\
3645 % \<\< \dbox{\begin{subprocedure}\procedure{Subprotocol}{
3646 % \< \< \textbf{Charlie} \\
3647 % \text{something more} \< \< \\
3648 % \< \sendmessageright*[1.5cm]{\text{message}} \< \\
3649 % \< \< \text{some processing} \\
3650 % \< \< \text{more processing} \\
3651 % \< \sendmessageleft*[1.5cm]{\text{message}} \< \\
3652 % \< \sendmessageright*[1.5cm]{\text{message}} \< \\
3653 % \< \sendmessageleft*[1.5cm]{\text{message}} \< \\
3654 % }\end{subprocedure}} \\
3655 % \< \sendmessageleft*{\text{send over sth. else}} \< \\
3656 % \text{finalize} \< \< }
3657 %
3658 % \iffalse
3659 %<*example>
3660 % \fi
3661 \begin{lstlisting}
3662 \procedureblock[colspace=-1cm]{My Protocol}{
3663 \textbf{Alice} \< \< \textbf{Bob} \\
3664 b \sample \bin \< \< \\
3665 \< \sendmessageright*{\text{send over } b} \< \\
3666 \< \< \text{do something} \\
3667 \<\< \dbox{\begin{subprocedure}\procedure{Subprotocol}{
3668 \< \< \textbf{Charlie} \\
3669 \text{something more} \< \< \\
3670 \< \sendmessageright*[1.5cm]{\text{message}} \< \\
3671 \< \< \text{some processing} \\
3672 \< \< \text{more processing} \\
3673 \< \sendmessageleft*[1.5cm]{\text{message}} \< \\
3674 \< \sendmessageright*[1.5cm]{\text{message}} \< \\
3675 \< \sendmessageleft*[1.5cm]{\text{message}} \< \\
3676 }\end{subprocedure}} \\
3677 \< \sendmessageleft*{\text{send over sth. else}} \< \\
3678 \text{finalize} \< \< }
3679 \end{lstlisting}
3680 % \iffalse
3681 %</example>
3682 % \fi
3683 %
3684 % \amipagebreak
3685 % \section{Game-Based Proofs}
3686 % \label{chap:gbproofs}
3687 %
3688 % \subsection{Basics}
3689 % \index{gameproof}
3690 % \index{\textbackslash \pcgame}
3691 % \index{gameprocedure}
3692 %
3693 % Besides displaying pseudocode the package also comes with commands to help presetn game-based proofs.
3694 % The |gameproof| environment wraps the pseudocode block of a game-based proof.
3695 % \iffalse
3696 %<*example>
3697 % \fi
3698 \begin{lstlisting}
3699 \begin{gameproof}
3700 proof goes here
3701 \end{gameproof}
3702 \end{lstlisting}
3703 % \iffalse
3704 %</example>
3705 % \fi
3706 % Within a |gameproof| environment use the command |\gameprocedure| which works similarly to the pseudocode
3707 % command and produces a heading of the form $\pcgame[\text{counter}](\secpar)$ where counter is a consecutive counter.
3708 % Thus, we can create the following setup
3709 % \begin{gameproof}
3710 % \begin{pchstack}[space=1em,center,boxed]
3711 % \gameprocedure[linenumbering,mode=text]{%
3712 % Step 1 \\
3713 % Step 2
3714 % }
3715 % \gameprocedure[mode=text]{%
3716 % Step 1 \\
3717 % Step 2
3718 % }
3719 % \end{pchstack}
3720 % \end{gameproof}
3721 % by using
3722 % \iffalse
3723 %<*example>
3724 % \fi
3725 \begin{lstlisting}
3726 \begin{gameproof}
3727 \begin{pchstack}[space=1em,center,boxed]
3728 \gameprocedure[linenumbering,mode=text]{%
3729 Step 1 \\
3730 Step 2
3731 }
3732 \gameprocedure[mode=text]{%
3733 Step 1 \\
3734 Step 2
3735 }
3736 \end{pchstack}
3737 \end{gameproof}
3738 \end{lstlisting}
3739 % \iffalse
3740 %</example>
3741 % \fi
3742 %
3743 % For discussing individual games, cryptocode provides the |\pcgame| command which
3744 % without argument prints \pcgame\ and with (optional) argument |\pcgame[n]| prints \pcgame[n].
3745 %
3746 % \subsubsection{Highlight Changes}
3747 % \index{highlight game change}
3748 % \index{\textbackslash gamechange}
3749 % In order to highlight changes from one game to the next use |\gamechange|.
3750 % \begin{gameproof}
3751 % \begin{pchstack}[space=1em,center,boxed]
3752 % \gameprocedure[linenumbering,mode=text]{%
3753 % Step 1 \\
3754 % Step 2
3755 % }
3756 % \gameprocedure[mode=text]{%
3757 % Step 1 \\
3758 % \gamechange{Step 2}
3759 % }
3760 % \end{pchstack}
3761 % \end{gameproof}
3762 % \iffalse
3763 %<*example>
3764 % \fi
3765 \begin{lstlisting}
3766 \begin{gameproof}
3767 \begin{pchstack}[space=1em,center,boxed]
3768 \gameprocedure[linenumbering,mode=text]{%
3769 Step 1 \\
3770 Step 2
3771 }
3772 \gameprocedure[mode=text]{%
3773 Step 1 \\
3774 \gamechange{Step 2}
3775 }
3776 \end{pchstack}
3777 \end{gameproof}
3778 \end{lstlisting}
3779 % \iffalse
3780 %</example>
3781 % \fi
3782 % The background color can be controlled by redefining |\gamechangecolor| which by default
3783 % is defined as
3784 % \iffalse
3785 %<*example>
3786 % \fi
3787 \begin{lstlisting}
3788 \definecolor{gamechangecolor}{gray}{0.90}
3789 \end{lstlisting}
3790 % \iffalse
3791 %</example>
3792 % \fi
3793 %
3794 % \textbf{Remark. } Note that |\gamechange| is always in text mode.
3795 %
3796 % \subsubsection{Boxed Games}
3797 % \index{\textbackslash tbxgameprocedure}
3798 % \index{\textbackslash pcbox}
3799 % Use |\tbxgameprocedure| in order to create two consecutive games where the second game is \emph{boxed}. Use
3800 % |\pcbox| to create boxed statements.
3801 %\begin{gameproof}
3802 %\begin{pchstack}[space=1em,boxed,center]
3803 % \gameprocedure[linenumbering]{
3804 % \text{Step 1} \\
3805 % \text{Step 2}
3806 % }
3807 % \tbxgameprocedure{
3808 % \text{Step 1}; \pcbox{\text{Alternative step 1}} \\
3809 % \gamechange{\text{Step 2 is different}}
3810 % }
3811 % \gameprocedure{
3812 % \text{Step 1} \\
3813 % \text{\gamechange{Step 2}}
3814 % }
3815 %\end{pchstack}
3816 %\end{gameproof}
3817 %
3818 % \iffalse
3819 %<*example>
3820 % \fi
3821 \begin{lstlisting}
3822 \begin{gameproof}
3823 \begin{pchstack}[space=1em,boxed,center]
3824 \gameprocedure[linenumbering]{
3825 \text{Step 1} \\
3826 \text{Step 2}
3827 }
3828 \tbxgameprocedure{
3829 \text{Step 1}; \pcbox{\text{Alternative step 1}} \\
3830 \gamechange{\text{Step 2 is different}}
3831 }
3832 \gameprocedure{
3833 \text{Step 1} \\
3834 \text{\gamechange{Step 2}}
3835 }
3836 \end{pchstack}
3837 \end{gameproof}
3838 \end{lstlisting}
3839 % \iffalse
3840 %</example>
3841 % \fi
3842 %
3843 % \subsubsection{Reduction Hints}
3844 % \index{\textbackslash addgamehop}
3845 % In a game based proof, in order to go from one game to the next we usually give a reduction, for example, we show that
3846 % the difference between two games is bound by the security of some pseudorandom generator $\mathsf{PRG}$. To give a hint
3847 % within the pseudocode that the difference between two games is down to ``something'' you can use the |\addgamehop|
3848 % command.
3849 % \iffalse
3850 %<*example>
3851 % \fi
3852 \begin{lstlisting}
3853 \addgamehop{startgame}{endgame}{options}
3854 \end{lstlisting}
3855 % \iffalse
3856 %</example>
3857 % \fi
3858 % Here options allows you to specify the hint as well as the style. The following options are available
3859 % \begin{description}
3860 % \item[hint]
3861 % The hint text
3862 % \item[nodestyle]
3863 % A TIKZ style to be used for the node.
3864 % \item[pathstyle]
3865 % A TIKZ style to be used for the path.
3866 % \item[edgestyle]
3867 % A TIKZ style to be used for the edge. This defaults to \enquote{bend left}.
3868 % \end{description}
3869 %
3870 %\begin{gameproof}
3871 %\begin{pchstack}[center,space=2em,aboveskip=1.5em]
3872 % \gameprocedure[linenumbering]{
3873 % \text{Step 1} \\
3874 % \text{Step 2}
3875 % }
3876 % \tbxgameprocedure{
3877 % \text{Step 1} \\
3878 % \gamechange{\text{Step 2 is different}}
3879 % }
3880 %\end{pchstack}
3881 %
3882 %\addgamehop{1}{2}{hint=\footnotesize some hint,nodestyle=red}
3883 %\addgamehop{2}{3}{hint=\footnotesize some other hint,nodestyle=red}
3884 %\end{gameproof}
3885 % \iffalse
3886 %<*example>
3887 % \fi
3888 \begin{lstlisting}
3889 \begin{gameproof}
3890 \begin{pchstack}[center,space=2em]
3891 \gameprocedure[linenumbering]{
3892 \text{Step 1} \\
3893 \text{Step 2}
3894 }
3895 \tbxgameprocedure{
3896 \text{Step 1} \\
3897 \gamechange{\text{Step 2 is different}}
3898 }
3899 \end{pchstack}
3900
3901 \addgamehop{1}{2}{hint=\footnotesize some hint,nodestyle=red}
3902 \addgamehop{2}{3}{hint=\footnotesize some other hint}
3903 \end{gameproof}
3904 \end{lstlisting}
3905 % \iffalse
3906 %</example>
3907 % \fi
3908 % The edgestyle allows you to specify how the hint is displayed. If you, for example want a straight line, rather than the curved arrow simply
3909 % use
3910 % \iffalse
3911 %<*example>
3912 % \fi
3913 \begin{lstlisting}
3914 \addgamehop{1}{2}{hint=\footnotesize some hint,edgestyle=}
3915 \end{lstlisting}
3916 % \iffalse
3917 %</example>
3918 % \fi
3919 %
3920 % If game proofs do not fit into a single picture you can specify start and end hints using the commands
3921 % \iffalse
3922 %<*example>
3923 % \fi
3924 \begin{lstlisting}
3925 \addstartgamehop[first game]{options}
3926 \addendgamehop[last game]{options}
3927 \end{lstlisting}
3928 % \iffalse
3929 %</example>
3930 % \fi
3931 %
3932 %\begin{gameproof}
3933 %\begin{pchstack}[center,space=2em,aboveskip=1em]
3934 % \gameprocedure[linenumbering]{
3935 % \text{Step 1} \\
3936 % \text{Step 2}
3937 % }
3938 % \gameprocedure{%
3939 % \text{Step 1} \\
3940 % \gamechange{\text{Step 2 is different}}
3941 % }
3942 %\addstartgamehop{hint=\footnotesize some hint,edgestyle=}
3943 %\addgamehop{1}{2}{hint=\footnotesize some hint}
3944 %\addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
3945 %\end{pchstack}
3946 %\end{gameproof}
3947 %
3948 % \iffalse
3949 %<*example>
3950 % \fi
3951 \begin{lstlisting}
3952 \begin{gameproof}
3953 \begin{pchstack}[center,space=2em]
3954 \gameprocedure[linenumbering]{
3955 \text{Step 1} \\
3956 \text{Step 2}
3957 }
3958 \gameprocedure{
3959 \text{Step 1} \\
3960 \gamechange{\text{Step 2 is different}}
3961 }
3962 \end{pchstack}
3963
3964 \addstartgamehop{hint=\footnotesize some hint,edgestyle=}
3965 \addgamehop{1}{2}{hint=\footnotesize some hint}
3966 \addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
3967 \end{gameproof}
3968 \end{lstlisting}
3969 % \iffalse
3970 %</example>
3971 % \fi
3972 %
3973 % \subsubsection{Numbering and Names}
3974 % By default the |gameproof| environment starts to count from 1 onwards. Its optional parameters allow you to specify a custom
3975 % name for the game as well as defining the starting number.
3976 % \iffalse
3977 %<*example>
3978 % \fi
3979 % \begin{lstlisting}
3980 \begin{gameproof}[options]
3981 \end{lstlisting}
3982 % \iffalse
3983 %</example>
3984 % \fi
3985 %
3986 % The following parameters are available which, as usual, are provided in a key=value based form.
3987 % \begin{description}
3988 % \item[nr]
3989 % The starting number minus 1. Thus, when setting nr=5, the first game will be \pcgame[6].
3990 % \item[name]
3991 % The name for the game
3992 % \item[arg]
3993 % The argument to be used for the game.
3994 % \end{description}
3995 %
3996 %\begin{gameproof}[nr=5,name=\mathsf{MyGame},arg=(1^n)]
3997 %\begin{pchstack}[center,space=2em,aboveskip=2.5em]
3998 % \gameprocedure[linenumbering]{
3999 % \text{Step 1} \\
4000 % \text{Step 2} }
4001 % \gameprocedure{
4002 % \text{Step 1} \\
4003 % \gamechange{\text{Step 2 is different}} }
4004 %\end{pchstack}
4005 %
4006 %\addstartgamehop{hint=\footnotesize some ingoing hint,edgestyle=}
4007 %\addgamehop{6}{7}{hint=\footnotesize some hint}
4008 %\addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
4009 %\end{gameproof}
4010 %
4011 % \iffalse
4012 %<*example>
4013 % \fi
4014 % \begin{lstlisting}
4015 \begin{gameproof}[nr=5,name=\mathsf{MyGame},arg=(1^n)]
4016 \begin{pchstack}[center,space=2em]
4017 \gameprocedure[linenumbering]{
4018 \text{Step 1} \\
4019 \text{Step 2} }
4020 \gameprocedure{
4021 \text{Step 1} \\
4022 \gamechange{\text{Step 2 is different}} }
4023 \end{pchstack}
4024
4025 \addstartgamehop{hint=\footnotesize some ingoing hint,edgestyle=}
4026 \addgamehop{6}{7}{hint=\footnotesize some hint}
4027 \addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
4028 \end{gameproof}
4029 \end{lstlisting}
4030 % \iffalse
4031 %</example>
4032 % \fi
4033 %
4034 % \subsubsection{Default Name and Argument}
4035 % The default name and argument are controlled via the commands |\pcgamename| and |\gameprocedurearg|.
4036 %
4037 % \begin{center}
4038 % \begin{tabular}{ll}
4039 % \textbf{Command} & \textbf{Default} \\
4040 % |\pcgamename| & |\mathsf{Game}| \\
4041 % |\gameprocedurearg| & |\secpar|
4042 % \end{tabular}
4043 % \end{center}
4044 %
4045 % \subsubsection{Bi-Directional Games}
4046 % \index{\textbackslash bxgameprocedure}
4047 % \index{\textbackslash addloopgamehop}
4048 % You can use the |\bxgameprocedure| to generate games for going in two directions. Use the |\addloopgamehop|
4049 % to add the gamehop in the middle.
4050 %
4051 % \vspace{1cm}
4052 % \begin{center}
4053 % \begin{gameproof}
4054 % \bxgameprocedure{4}{%
4055 % \pcln \text{Step 1}; \pcbox{Alternative} \\
4056 % \pcln \text{Step 2}
4057 % }
4058 % \bxgameprocedure{3}{%
4059 % \text{Step 1}; \pcbox{Alternative} \\
4060 % \gamechange{\text{Step 2 is different}}
4061 % }
4062 % \addstartgamehop{hint=\footnotesize some hint,edgestyle=}
4063 % \addgamehop{1}{2}{hint=\footnotesize some hint,edgestyle=}
4064 % \addloopgamehop{hint=\footnotesize some loop hint}
4065 % \addgamehop{2}{1}{hint=\footnotesize some hint}
4066 % \end{gameproof}
4067 % \end{center}
4068 %
4069 % \iffalse
4070 %<*example>
4071 % \fi
4072 \begin{lstlisting}
4073 \begin{gameproof}
4074 \bxgameprocedure{4}{%
4075 \pcln \text{Step 1}; \pcbox{Alternative} \\
4076 \pcln \text{Step 2}
4077 }
4078 \bxgameprocedure{3}{%
4079 \text{Step 1}; \pcbox{Alternative} \\
4080 \gamechange{\text{Step 2 is different}}
4081 }
4082 \addstartgamehop{hint=\footnotesize some hint,edgestyle=}
4083 \addgamehop{1}{2}{hint=\footnotesize some hint,edgestyle=}
4084 \addloopgamehop{hint=\footnotesize some loop hint}
4085 \addgamehop{2}{1}{hint=\footnotesize some hint}
4086 \end{gameproof}
4087 \end{lstlisting}
4088 % \iffalse
4089 %</example>
4090 % \fi
4091 %
4092 % \subsubsection{Styling Game Procedures}
4093 % It may come in handy to define default style arguments for the underlying pseudocode
4094 % command used by |\gameprocedure|. For this you can
4095 % define the default arguments by calling \lstinline{\setgameproceduredefaultstyle} to
4096 % for example:
4097 %
4098 % \iffalse
4099 %<*example>
4100 % \fi
4101 \begin{lstlisting}
4102 \setgameproceduredefaultstyle{beginline=\vphantom{\bin^\prg_\prg}
4103 \end{lstlisting}
4104 % \iffalse
4105 %</example>
4106 % \fi
4107 % The default is to not set any options.
4108 %
4109 % \subsection{Game Descriptions}
4110 % Cryptocode also comes with an environment to provide textual descriptions of games such as
4111 %
4112 % \begin{gamedescription}[name=MyGame,nr=2]
4113 % \describegame
4114 % This is the third game. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis condimentum velit et orci volutpat, sed ultrices lorem lobortis. Nam vehicula, justo eu varius interdum, felis mi consectetur dolor, ac posuere nulla lacus varius diam. Etiam dapibus blandit leo, et porttitor augue lacinia auctor.
4115 %
4116 % \describegame[inhint=reduction target]
4117 % This is the fourt game. The arrow at the side indicates the reduction target.
4118 % \end{gamedescription}
4119 %
4120 % The above example is generated as
4121 %
4122 % \iffalse
4123 %<*example>
4124 % \fi
4125 \begin{lstlisting}
4126 \begin{gamedescription}[name=MyGame,nr=2]
4127 \describegame
4128 This is the third game. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis condimentum velit et orci volutpat, sed ultrices lorem lobortis. Nam vehicula, justo eu varius interdum, felis mi consectetur dolor, ac posuere nulla lacus varius diam. Etiam dapibus blandit leo, et porttitor augue lacinia auctor.
4129
4130 \describegame[inhint=reduction target]
4131 This is the second game. The arrow at the side indicates the reduction target.
4132 \end{gamedescription}
4133 \end{lstlisting}
4134 % \iffalse
4135 %</example>
4136 % \fi
4137 %
4138 % The |gamedescription| environment takes an optional argument to specify name and counter (defaults to Game and 0). The command
4139 % |\describegame| starts a new game description and can allows you to provide a reduction hint using the option parameter |inhint|.
4140 %
4141 % \begin{description}
4142 % \item[inhint] Displays an ingoing arrow to denote the reduction target for this game hop.
4143 % \item[length] Allows to control the length of the arrow. \\
4144 % \item[nodestyle] Allows to control the style of the node. \\
4145 % \item[hint] Instead of having an ingoing arrow, this adds an outgoing arrow. \\
4146 % \end{description}
4147 %
4148 % \amipagebreak
4149 % \section{Black-Box Reductions}
4150 % \label{chap:bbr}
4151 % \index{bbrenv}
4152 % \index{bbrbox}
4153 % \index{\textbackslash bbrinput}
4154 % \index{\textbackslash bbroutput}
4155 %
4156 % The cryptocode package comes with support for drawing basic black box reductions. A reduction
4157 % always takes the following form.
4158 %
4159 % \iffalse
4160 %<*example>
4161 % \fi
4162 \begin{lstlisting}
4163 \begin{bbrenv}{A}
4164 \begin{bbrbox}[name=Box Name]
4165 % The Box's content
4166 \end{bbrbox}
4167 % Commands to display communication, input output etc
4168 \end{bbrenv}
4169 \end{lstlisting}
4170 % \iffalse
4171 %</example>
4172 % \fi
4173 % That is, a |bbrenv| environment (where bbr is short for black-box reduction) which takes a single
4174 % |bbrbox| environment plus some additional commands.
4175 %
4176 % \medskip
4177 % Following is a simple example with a single (black)box and some code plus inputs outputs:
4178 %
4179 % \begin{bbrenv}[aboveskip=0.75cm,belowskip=0.75cm]{A}
4180 % \begin{bbrbox}[name=Box Name]
4181 % \pseudocode{
4182 % \text{step 1} \\
4183 % \text{step 2} \\
4184 % \pcfor \text{some condition} \pcdo \\
4185 % \t\text{step 3}
4186 % }
4187 % \end{bbrbox}
4188 % \bbrinput{input}
4189 % \bbroutput{output}
4190 % \end{bbrenv}
4191 %
4192 % \noindent This box is generated as
4193 % \iffalse
4194 %<*example>
4195 % \fi
4196 \begin{lstlisting}
4197 \begin{bbrenv}[aboveskip=1cm,belowskip=1cm]{A}
4198 \begin{bbrbox}[name=Box Name]
4199 \pseudocode{
4200 \text{step 1} \\
4201 \text{step 2} \\
4202 \pcfor \text{some condition} \pcdo \\
4203 \t\text{step 3}
4204 }
4205 \end{bbrbox}
4206 \bbrinput{input}
4207 \bbroutput{output}
4208 \end{bbrenv}
4209 \end{lstlisting}
4210 % \iffalse
4211 %</example>
4212 % \fi
4213 %
4214 % The commands |bbrinput| and |bbroutput| allow to specify input and output for the latest
4215 % |bbrenv| environment. The optional parameter for the |bbrenv| environment allows to specify leading and trailing space (this
4216 % may become necessary when using inputs and outputs). For this provide |aboveskip| and |belowskip| keys.
4217 % (Note that in an earlier version of cryptocode you could write |\begin{bbrenv}[1cm]{A}[1cm]|. While this format
4218 % is still supported it should be regarded deprecated.)
4219 %
4220 % \medskip
4221 % The |bbrenv| environment takes the following options as optional first parameter:
4222 % \begin{description}
4223 % \item[aboveskip]
4224 % Space above.
4225 % \item[belowskip]
4226 % Space below.
4227 % \item[tikzargs]
4228 % Underneath |bbrenv| is a |tikzpicture| and via |tikzargs| you can pass in arguments.
4229 % \end{description}
4230 %
4231 % \medskip
4232 % The single mandatory argument to the bbrenv environment needs to specify a unique identifier
4233 % (unique for the current reduction). This id is used as an internal TIKZ node name (\url{https://www.ctan.org/pkg/pgf}).
4234 % \iffalse
4235 %<*example>
4236 % \fi
4237 \begin{lstlisting}
4238 \begin{bbrenv}[options]{UNIQUE IDENTIFIER}
4239 % deprecated version
4240 \begin{bbrenv}[vspace before]{UNIQUE IDENTIFIER}[vspace after]
4241 \end{lstlisting}
4242 % \iffalse
4243 %</example>
4244 % \fi
4245 % As we are drawing a TIKZ image, note that we can easily later customize the image using the labels that we
4246 % have specified on the way.
4247 %
4248 % \begin{bbrenv}[aboveskip=1cm,belowskip=1cm]{A}
4249 % \begin{bbrbox}[name=Box Name]
4250 % \pseudocode{
4251 % \text{step 1} \\
4252 % \text{step 2} \\
4253 % \pcfor \text{some condition} \pcdo \\
4254 % \pcind\text{step 3}
4255 % }
4256 % \end{bbrbox}
4257 % \bbrinput{input}
4258 % \bbroutput{output}
4259 %
4260 % \filldraw[fill=blue] (A.north) circle (4pt);
4261 % \filldraw[fill=blue] (A.west) circle (4pt);
4262 % \filldraw[fill=blue] (A.east) circle (4pt);
4263 % \filldraw[fill=blue] (A.south) circle (4pt);
4264 % \end{bbrenv}
4265 % \iffalse
4266 %<*example>
4267 % \fi
4268 \begin{lstlisting}
4269 \begin{bbrenv}{A}
4270 \begin{bbrbox}[name=Box Name]
4271 \pseudocode{
4272 \text{step 1} \\
4273 \text{step 2} \\
4274 \pcfor \text{some condition} \pcdo \\
4275 \pcind\text{step 3}
4276 }
4277 \end{bbrbox}
4278 \bbrinput{input}
4279 \bbroutput{output}
4280
4281 \filldraw[fill=blue] (A.north) circle (4pt);
4282 \filldraw[fill=blue] (A.west) circle (4pt);
4283 \filldraw[fill=blue] (A.east) circle (4pt);
4284 \filldraw[fill=blue] (A.south) circle (4pt);
4285 \end{bbrenv}
4286 \end{lstlisting}
4287 % \iffalse
4288 %</example>
4289 % \fi
4290 %
4291 % The |bbrbox| takes as single argument a comma separated list of key value pairs. In the example we used
4292 % \iffalse
4293 %<*example>
4294 % \fi
4295 \begin{lstlisting}
4296 name=Box Name
4297 \end{lstlisting}
4298 % \iffalse
4299 %</example>
4300 % \fi
4301 % to specify the label. The following options are available
4302 %
4303 % \index{namepos}
4304 % \index{namestyle}
4305 % \index{abovesep}
4306 % \index{minheight}
4307 % \index{xshift}
4308 % \index{yshift}
4309 % \begin{center}
4310 % \begin{tabular}{ll}
4311 % \textbf{Option} & \textbf{Description} \\ \hline
4312 % name & Specifies the box's label \\
4313 % namepos & Specifies the position (left, center, right, top left, top center, top right, middle) \\
4314 % namestyle & Specifies the style of the name \\
4315 % abovesep & Space above box (defaults to |\baselineskip|) \\
4316 % minheight & The minimal height \\
4317 % addheight & Additional height at the end of the box \\
4318 % xshift & Allows horizontal positioning \\
4319 % yshift & Allows horizontal positioning \\
4320 % style & allows to customize the node
4321 % \end{tabular}
4322 % \end{center}
4323 %
4324 % \subsection{Nesting of Boxes}
4325 % Boxes can be nested. For this simply insert a |bbrenv| (together with a single bbrbox) environment into an
4326 % existing bbrbox.
4327 %
4328 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
4329 % \begin{bbrbox}[name=Box Name]
4330 % \pseudocode{
4331 % \text{step 1} \\
4332 % \text{step 2} \\
4333 % \pcfor \text{some condition} \pcdo \\
4334 % \pcind\text{step 3}
4335 % }
4336 %
4337 % \begin{bbrenv}{B}
4338 % \begin{bbrbox}[name=Inner Box]
4339 % \pseudocode{
4340 % \text{inner step 1} \\
4341 % \text{inner step 2}
4342 % }
4343 % \end{bbrbox}
4344 % \end{bbrenv}
4345 %
4346 % \pseudocode{
4347 % \text{step 4} \\
4348 % \text{step 5}
4349 % }
4350 % \end{bbrbox}
4351 % \bbrinput{input}
4352 % \bbroutput{output}
4353 % \end{bbrenv}
4354 %
4355 % \iffalse
4356 %<*example>
4357 % \fi
4358 \begin{lstlisting}
4359 \begin{bbrenv}{A}
4360 \begin{bbrbox}[name=Box Name]
4361 \pseudocode{
4362 \text{step 1} \\
4363 \text{step 2} \\
4364 \pcfor \text{some condition} \pcdo \\
4365 \pcind\text{step 3}
4366 }
4367
4368 \begin{bbrenv}{B}
4369 \begin{bbrbox}[name=Inner Box]
4370 \pseudocode{
4371 \text{inner step 1} \\
4372 \text{inner step 2}
4373 }
4374 \end{bbrbox}
4375 \end{bbrenv}
4376
4377 \pseudocode{
4378 \text{step 4} \\
4379 \text{step 5}
4380 }
4381 \end{bbrbox}
4382 \bbrinput{input}
4383 \bbroutput{output}
4384 \end{bbrenv}
4385 \end{lstlisting}
4386 % \iffalse
4387 %</example>
4388 % \fi
4389 %
4390 % \subsection{Messages and Queries}
4391 % \index{\textbackslash bbrmsgto}
4392 % \index{\textbackslash bbrmsgfrom}
4393 % \index{\textbackslash bbrmsgtofrom}
4394 % \index{\textbackslash bbrmsgfromto}
4395 % \index{\textbackslash bbrqryto}
4396 % \index{\textbackslash bbrqryfrom}
4397 % \index{\textbackslash bbrqrytofrom}
4398 % \index{\textbackslash bbrqryfromto}
4399 %
4400 % You can send messages and queries to boxes. For this use the commands
4401 % \iffalse
4402 %<*example>
4403 % \fi
4404 \begin{lstlisting}
4405 \bbrmsgto{options}
4406 \bbrmsgfrom{options}
4407 \bbrmsgtofrom{options}{options}
4408 \bbrmsgfromto{options}{options}
4409 \bbrqryto{options}
4410 \bbrqryfrom{options}
4411 \bbrqrytofrom{options}{options}
4412 \bbrqryfromto{options}{options}
4413 \end{lstlisting}
4414 % \iffalse
4415 %</example>
4416 % \fi
4417 % By convention messages are on the left of boxes and queries on the right. Commands ending on |to|
4418 % make an arrow to the right while commands ending on |from| make an arrow to the left. The |options|
4419 % define how the message is drawn and consists of a key-value list. The |tofrom| and |fromto| variants
4420 % draw two messages (back and forth) that are more compactly set together. Here usually, the fist message
4421 % should be drawn on top (|top=Label|) while the second message should be drawn on the bottom (|bottom=Label|).
4422 %
4423 % \medskip
4424 % For example, to draw a message with a label on top and on the side use
4425 % \iffalse
4426 %<*example>
4427 % \fi
4428 \begin{lstlisting}
4429 \bbrmsgto{top=Top Label, side=Side Label}
4430 \end{lstlisting}
4431 % \iffalse
4432 %</example>
4433 % \fi
4434 % If your label contains a \enquote{,} (comma), then group the label in $\{\}$ (curly brackets).
4435 % \iffalse
4436 %<*example>
4437 % \fi
4438 \begin{lstlisting}
4439 \bbrmsgto{top=Top Label, side={Side, Label}}
4440 \end{lstlisting}
4441 % \iffalse
4442 %</example>
4443 % \fi
4444 %
4445 % Following is a complete example. Notice that cryptocode takes care of the vertical positioning.
4446 %
4447 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
4448 % \begin{bbrbox}[name=Box Name]
4449 % \pseudocode{
4450 % \text{step 1} \\
4451 % \text{step 2} \\
4452 % \pcfor \text{some condition} \pcdo \\
4453 % \pcind\text{step 3}
4454 % }
4455 %
4456 % \begin{bbrenv}{B}
4457 % \begin{bbrbox}[name=Inner Box]
4458 % \pseudocode{
4459 % \text{inner step 1} \\
4460 % \text{inner step 2}
4461 % }
4462 % \end{bbrbox}
4463 %
4464 % \bbrmsgto{top={$m_0,m_1$}}
4465 % \bbrmsgfrom{top=$q$}
4466 %
4467 % \bbrqrytofrom{top={$m_0,m_1$}}{bottom=$q$}
4468 %
4469 % \end{bbrenv}
4470 %
4471 % \pseudocode{
4472 % \text{step 4} \\
4473 % \text{step 5}
4474 % }
4475 % \end{bbrbox}
4476 % \bbrinput{input}
4477 % \bbroutput{output}
4478 % \end{bbrenv}
4479 %
4480 % \iffalse
4481 %<*example>
4482 % \fi
4483 \begin{lstlisting}
4484 \begin{bbrenv}{A}
4485 \begin{bbrbox}[name=Box Name]
4486 \pseudocode{
4487 \text{step 1} \\
4488 \text{step 2} \\
4489 \pcfor \text{some condition} \pcdo \\
4490 \pcind\text{step 3}
4491 }
4492
4493 \begin{bbrenv}{B}
4494 \begin{bbrbox}[name=Inner Box]
4495 \pseudocode{
4496 \text{inner step 1} \\
4497 \text{inner step 2}
4498 }
4499 \end{bbrbox}
4500
4501 \bbrmsgto{top={$m_0,m_1$}}
4502 \bbrmsgfrom{top=$q$}
4503
4504 \bbrqrytofrom{top={$m_0,m_1$}}{bottom=$q$}
4505
4506 \end{bbrenv}
4507
4508 \pseudocode{
4509 \text{step 4} \\
4510 \text{step 5}
4511 }
4512 \end{bbrbox}
4513 \bbrinput{input}
4514 \bbroutput{output}
4515 \end{bbrenv}
4516 \end{lstlisting}
4517 % \iffalse
4518 %</example>
4519 % \fi
4520 %
4521 % \subsubsection{Options}
4522 % Following is a list of all available options. Remember that underneath the reduction
4523 % commands is a TIKZ image (\url{https://www.ctan.org/pkg/pgf/}) and for each label
4524 % position (top, side, bottom) a node is generated which can be further customized
4525 % via low-level TIKZ.
4526 %
4527 % \begin{description}
4528 % \item[top] Label on top
4529 % \item[bottom] Label on the bottom
4530 % \item[side] Label on the far side of the box. For challengers and oracles, on the side of the box.
4531 % \item[oside] Label on the \enquote{other} side.
4532 % \item[topstyle] Style for label on top
4533 % \item[bottomstyle] Style for label on bottom
4534 % \item[sidestyle] Style for label on side
4535 % \item[osidestyle] Style for label on other side
4536 % \item[edgestyle] Style for edge
4537 % \item[length] Length of arrow
4538 % \item[topname] Name for node on top
4539 % \item[bottomname] Name for node on bottom
4540 % \item[sidename] Name for node on side
4541 % \item[osidename] Name for node on other side
4542 % \item[aboveskip] Space before message
4543 % \item[belowskip] Space after message
4544 % \item[fixedoffset] Ignores automatic spacing and sets the message at the provided offset from the top.
4545 % \item[fixedboffset] Ignores automatic spacing and sets the message at the provided offset from the bottom.
4546 % \item[islast] Places the message at the bottom.
4547 % \end{description}
4548 %
4549 %
4550 %
4551 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
4552 % \begin{bbrbox}[name=Box Name]
4553 % \pseudocode{
4554 % \text{step 1} \\
4555 % \text{step 2} \\
4556 % \pcfor \text{some condition} \pcdo \\
4557 % \pcind\text{step 3}
4558 % }
4559 %
4560 % \begin{bbrenv}{B}
4561 % \begin{bbrbox}[name=Inner Box]
4562 % \pseudocode{
4563 % \text{inner step 1} \\
4564 % \text{inner step 2} \\
4565 % }
4566 % \end{bbrbox}
4567 %
4568 % \bbrmsgto{top={$m_0,m_1$},side=Side Label, bottom=$b$, length=2cm,
4569 % topstyle={draw, solid}, sidestyle={red}, bottomstyle={draw, dashed}}
4570 %
4571 % \end{bbrenv}
4572 %
4573 % \pseudocode{
4574 % \text{step 4} \\
4575 % \text{step 5} \\
4576 % }
4577 % \end{bbrbox}
4578 % \bbrinput{input}
4579 % \bbroutput{output}
4580 % \end{bbrenv}
4581 %
4582 % \iffalse
4583 %<*example>
4584 % \fi
4585 \begin{lstlisting}
4586 \begin{bbrenv}{A}
4587 \begin{bbrbox}[name=Box Name]
4588 \pseudocode{
4589 \text{step 1} \\
4590 \text{step 2} \\
4591 \pcfor \text{some condition} \pcdo \\
4592 \pcind\text{step 3}
4593 }
4594
4595 \begin{bbrenv}{B}
4596 \begin{bbrbox}[name=Inner Box]
4597 \pseudocode{
4598 \text{inner step 1} \\
4599 \text{inner step 2} \\
4600 }
4601 \end{bbrbox}
4602
4603 \bbrmsgto{top={$m_0,m_1$},side=Side Label, bottom=$b$, length=2cm,
4604 topstyle={draw, solid}, sidestyle={red}, bottomstyle={draw, dashed}}
4605
4606 \end{bbrenv}
4607
4608 \pseudocode{
4609 \text{step 4} \\
4610 \text{step 5} \\
4611 }
4612 \end{bbrbox}
4613 \bbrinput{input}
4614 \bbroutput{output}
4615 \end{bbrenv}
4616 \end{lstlisting}
4617 % \iffalse
4618 %</example>
4619 % \fi
4620 %
4621 %
4622 % \subsubsection*{First Message}
4623 % \index{\textbackslash bbrfirstmessageoffset}
4624 % The first message is offset by |\bbrfirstmessageoffset| which defaults to 1ex.
4625 %
4626 % \subsubsection{Vdots}
4627 % \index{\textbackslash bbrmsgvdots}
4628 % \index{\textbackslash bbrqryvdots}
4629 %
4630 % You can use |\bbrmsgvdots| and |\bbrqryvdots| to add |\vdots| in between messages or queries.
4631 %
4632 % \begin{bbrenv}{A}
4633 % \begin{bbrbox}[name=A,minheight=14mm]
4634 % \pseudocode{a}
4635 % \end{bbrbox}
4636 % \bbrmsgfrom{top={$a$}}
4637 % \bbrmsgvdots
4638 % \bbrmsgfrom{islast=true,bottom={$a$}}
4639 % \bbrqryto{top=a}
4640 % \bbrqryvdots
4641 % \bbrqryto{bottom=a,islast=true}
4642 % \end{bbrenv}
4643 %
4644 %
4645 % \iffalse
4646 %<*example>
4647 % \fi
4648 \begin{lstlisting}
4649 \begin{bbrenv}{A}
4650 \begin{bbrbox}[name=A,minheight=14mm]
4651 \pseudocode{a}
4652 \end{bbrbox}
4653 \bbrmsgfrom{top={$a$}}
4654 \bbrmsgvdots
4655 \bbrmsgfrom{islast=true,bottom={$a$}}
4656 \bbrqryto{top=a}
4657 \bbrqryvdots%
4658 \bbrqryto{bottom=a,islast=true}
4659 \end{bbrenv}
4660 \end{lstlisting}
4661 % \iffalse
4662 %</example>
4663 % \fi
4664 %
4665 % \subsubsection{Add Space}
4666 % \index{\textbackslash bbrmsgspace}
4667 % \index{\textbackslash bbrqryspace}
4668 % If the spacing between messages is not sufficient you can use the |bbrmsgspace| and
4669 % |bbrqryspace| commands to add additional space. Alternatively, you can use the options
4670 % |aboveskip| and |belowskip| on the individual message or query commands.
4671 %
4672 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
4673 % \begin{bbrbox}[name=Reduction]
4674 % \pseudocode{
4675 % \text{Do something}
4676 % }
4677 %
4678 % \begin{bbrenv}{B}
4679 %
4680 % \begin{bbrbox}[name=Adversary,minheight=15ex,xshift=4cm]
4681 %
4682 % \end{bbrbox}
4683 %
4684 % \bbrmsgto{top=$m$}
4685 % \bbrmsgspace{1.5cm}
4686 % \bbrmsgfrom{top=$\sigma$}
4687 %
4688 % \bbrqryto{top=$m$}
4689 % \bbrqryspace{1cm}
4690 % \bbrqryfrom{top=$\sigma$}
4691 %
4692 % \end{bbrenv}
4693 %
4694 % \end{bbrbox}
4695 % \bbrinput{input}
4696 % \bbroutput{output}
4697 % \end{bbrenv}
4698 %
4699 % \iffalse
4700 %<*example>
4701 % \fi
4702 \begin{lstlisting}
4703 \begin{bbrenv}{A}
4704 \begin{bbrbox}[name=Reduction]
4705 \pseudocode{
4706 \text{Do something}
4707 }
4708
4709 \begin{bbrenv}{B}
4710
4711 \begin{bbrbox}[name=Adversary,minheight=15ex,xshift=4cm]
4712
4713 \end{bbrbox}
4714
4715 \bbrmsgto{top=$m$}
4716 \bbrmsgspace{1.5cm}
4717 \bbrmsgfrom{top=$\sigma$}
4718
4719 \bbrqryto{top=$m$}
4720 \bbrqryspace{1cm}
4721 \bbrqryfrom{top=$\sigma$}
4722
4723 \end{bbrenv}
4724
4725 \end{bbrbox}
4726 \bbrinput{input}
4727 \bbroutput{output}
4728 \end{bbrenv}
4729 \end{lstlisting}
4730 % \iffalse
4731 %</example>
4732 % \fi
4733 %
4734 % Note that for placing a message at the bottom, |islast| or fixed offsets often allow
4735 % obtain more accurate results.
4736 %
4737 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
4738 % \begin{bbrbox}[name=Reduction]
4739 % \pseudocode{
4740 % \text{Do something}
4741 % }
4742 %
4743 % \begin{bbrenv}{B}
4744 %
4745 % \begin{bbrbox}[name=Adversary,minheight=15ex,xshift=4cm]
4746 %
4747 % \end{bbrbox}
4748 %
4749 % \bbrmsgto{top=$m$}
4750 % \bbrmsgfrom{top=$\sigma$,islast}
4751 %
4752 % \bbrqryto{top=$m$,fixedoffset=4ex}
4753 % \bbrqryfrom{top=$\sigma$,fixedboffset=4ex}
4754 %
4755 % \end{bbrenv}
4756 %
4757 % \end{bbrbox}
4758 % \bbrinput{input}
4759 % \bbroutput{output}
4760 % \end{bbrenv}
4761 % \iffalse
4762 %<*example>
4763 % \fi
4764 \begin{lstlisting}
4765 \begin{bbrenv}{A}
4766 \begin{bbrbox}[name=Reduction]
4767 \pseudocode{
4768 \text{Do something}
4769 }
4770
4771 \begin{bbrenv}{B}
4772
4773 \begin{bbrbox}[name=Adversary,minheight=15ex,xshift=4cm]
4774
4775 \end{bbrbox}
4776
4777 \bbrmsgto{top=$m$}
4778 \bbrmsgfrom{top=$\sigma$,islast}
4779
4780 \bbrqryto{top=$m$,fixedoffset=4ex}
4781 \bbrqryfrom{top=$\sigma$,fixedboffset=4ex}
4782
4783 \end{bbrenv}
4784
4785 \end{bbrbox}
4786 \bbrinput{input}
4787 \bbroutput{output}
4788 \end{bbrenv}
4789 \end{lstlisting}
4790 % \iffalse
4791 %</example>
4792 % \fi
4793 %
4794 % \subsubsection{Loops}
4795 % \index{\textbackslash bbrloop}
4796 % Often an adversary may send poly many queries to an oracle, or a reduction sends many queries to an adversary.
4797 % Consider the following setting
4798 %
4799 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
4800 % \begin{bbrbox}[name=Reduction]
4801 % \pseudocode{
4802 % \text{Do something}
4803 % }
4804 %
4805 % \begin{bbrenv}{B}
4806 %
4807 % \begin{bbrbox}[name=Adversary,minheight=10ex,xshift=4cm]
4808 %
4809 % \end{bbrbox}
4810 %
4811 % \bbrmsgto{top=$m$,sidename=BeginLoop}
4812 % \bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
4813 %
4814 % \end{bbrenv}
4815 %
4816 % \end{bbrbox}
4817 % \bbrinput{input}
4818 % \bbroutput{output}
4819 % \end{bbrenv}
4820 %
4821 % \iffalse
4822 %<*example>
4823 % \fi
4824 \begin{lstlisting}
4825 \begin{bbrenv}{A}
4826 \begin{bbrbox}[name=Reduction]
4827 \pseudocode{
4828 \text{Do something}
4829 }
4830
4831 \begin{bbrenv}{B}
4832
4833 \begin{bbrbox}[name=Adversary,minheight=10ex,xshift=4cm]
4834
4835 \end{bbrbox}
4836
4837 \bbrmsgto{top=$m$}
4838 \bbrmsgfrom{top=$\sigma$}
4839
4840 \end{bbrenv}
4841
4842 \end{bbrbox}
4843 \bbrinput{input}
4844 \bbroutput{output}
4845 \end{bbrenv}
4846 \end{lstlisting}
4847 % \iffalse
4848 %</example>
4849 % \fi
4850 %
4851 % First note that by specifying the minheight and xshift option we shifted the adversary box a bit to the right
4852 % and enlarged its box. Further we specified custom names for the node on the side of the two messages. We
4853 % can now use the |bbrloop| command to visualize that these two messages are exchanged $q$ many times
4854 % \iffalse
4855 %<*example>
4856 % \fi
4857 \begin{lstlisting}
4858 \bbrloop{BeginLoop}{EndLoop}{center=$q$}
4859 \end{lstlisting}
4860 % \iffalse
4861 %</example>
4862 % \fi
4863 % The |bbrloop| command takes two node names and a config which allows you to specify if the label is
4864 % to be shown on the left, center or right. Here is the result.
4865 %
4866 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
4867 % \begin{bbrbox}[name=Reduction]
4868 % \pseudocode{
4869 % \text{Do something}
4870 % }
4871 %
4872 % \begin{bbrenv}{B}
4873 %
4874 % \begin{bbrbox}[name=Adversary,minheight=10ex,xshift=4cm]
4875 %
4876 % \end{bbrbox}
4877 %
4878 % \bbrmsgto{top=$m$,sidename=BeginLoop}
4879 % \bbrmsgspace{0.5cm}
4880 % \bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
4881 % \bbrloop{BeginLoop}{EndLoop}{center=$q$}
4882 %
4883 % \end{bbrenv}
4884 %
4885 % \end{bbrbox}
4886 % \bbrinput{input}
4887 % \bbroutput{output}
4888 % \end{bbrenv}
4889 %
4890 % \iffalse
4891 %<*example>
4892 % \fi
4893 \begin{lstlisting}
4894 \begin{bbrenv}{A}
4895 \begin{bbrbox}[name=Reduction]
4896 \pseudocode{
4897 \text{Do something}
4898 }
4899
4900 \begin{bbrenv}{B}
4901
4902 \begin{bbrbox}[name=Adversary,minheight=10ex,xshift=4cm]
4903
4904 \end{bbrbox}
4905
4906 \bbrmsgto{top=$m$,sidename=BeginLoop}
4907 \bbrmsgspace{0.5cm}
4908 \bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
4909 \bbrloop{BeginLoop}{EndLoop}{center=$q$}
4910
4911 \end{bbrenv}
4912
4913 \end{bbrbox}
4914 \bbrinput{input}
4915 \bbroutput{output}
4916 \end{bbrenv}
4917 \end{lstlisting}
4918 % \iffalse
4919 %</example>
4920 % \fi
4921 %
4922 % The |\bbrloop| command supports the following parameters:
4923 % \begin{description}
4924 % \item[center]
4925 % Label displayed within the loop
4926 % \item[left]
4927 % Label displayed left of the loop
4928 % \item[right]
4929 % Label displayed right of the loop
4930 % \item[centerstyle]
4931 % Style for center label
4932 % \item[leftstyle]
4933 % Style for left label
4934 % \item[rightstyle]
4935 % Style for right label
4936 % \item[clockwise]
4937 % Loop going in clockwise direction
4938 % \item[angle]
4939 % Angle of the arrows
4940 % \end{description}
4941 %
4942 % \subsubsection{Intertext}
4943 % \index{\textbackslash bbrmsgtxt}
4944 % \index{\textbackslash bbrqrytxt}
4945 %
4946 % If your reduction needs to do some extra work between queries use the |\bbrmsgtxt|
4947 % and |\bbrqrytxt| commands.
4948 % \iffalse
4949 %<*example>
4950 % \fi
4951 \begin{lstlisting}
4952 \bbrmsgtxt[options]{Text}
4953 \bbrqrytxt[options]{Text}
4954 \end{lstlisting}
4955 % \iffalse
4956 %</example>
4957 % \fi
4958 %
4959 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
4960 % \begin{bbrbox}[name=Reduction]
4961 % \pseudocode{
4962 % \text{Do something}
4963 % }
4964 %
4965 % \begin{bbrenv}{B}
4966 %
4967 % \begin{bbrbox}[name=Adversary,minheight=12ex,xshift=4cm]
4968 %
4969 % \end{bbrbox}
4970 %
4971 % \bbrmsgto{top=$m$}
4972 % \bbrmsgtxt{\pseudocode{
4973 % do \\
4974 % some \\
4975 % work
4976 % }}
4977 % \bbrmsgfrom{top=$\sigma$}
4978 %
4979 % \bbrqryto{top=$m$}
4980 % \bbrqrytxt[nodestyle={draw,dashed},xshift=2cm]{\pseudocode{
4981 % do \\
4982 % some \\
4983 % work
4984 % }}
4985 % \bbrqryfrom{top=$\sigma$}
4986 %
4987 % \end{bbrenv}
4988 %
4989 % \end{bbrbox}
4990 % \bbrinput{input}
4991 % \bbroutput{output}
4992 % \end{bbrenv}
4993 %
4994 % \iffalse
4995 %<*example>
4996 % \fi
4997 \begin{lstlisting}
4998 \begin{bbrenv}{A}
4999 \begin{bbrbox}[name=Reduction]
5000 \pseudocode{
5001 \text{Do something}
5002 }
5003
5004 \begin{bbrenv}{B}
5005
5006 \begin{bbrbox}[name=Adversary,minheight=12ex,xshift=4cm]
5007
5008 \end{bbrbox}
5009
5010 \bbrmsgto{top=$m$}
5011 \bbrmsgtxt{\pseudocode{
5012 do \\
5013 some \\
5014 work
5015 }}
5016 \bbrmsgfrom{top=$\sigma$}
5017
5018 \bbrqryto{top=$m$}
5019 \bbrqrytxt[nodestyle={draw,dashed},xshift=2cm]{\pseudocode{
5020 do \\
5021 some \\
5022 work
5023 }}
5024 \bbrqryfrom{top=$\sigma$}
5025
5026 \end{bbrenv}
5027
5028 \end{bbrbox}
5029 \bbrinput{input}
5030 \bbroutput{output}
5031 \end{bbrenv}
5032 \end{lstlisting}
5033 % \iffalse
5034 %</example>
5035 % \fi
5036 %
5037 % \subsection{Oracles}
5038 % \index{bbroracle}
5039 % \index{hdistance}
5040 % \index{vdistance}
5041 % Each box can have one or more oracles which are drawn on the right hand side of the box. An oracle
5042 % is created similarly to a |bbrenv| environment using the |bbroracle| environment. Oracles
5043 % go behind the single |bbrbox| environment within an |bbrenv| enviornment.
5044 %
5045 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
5046 % \begin{bbrbox}[name=Reduction]
5047 % \pseudocode{
5048 % \text{Do something}
5049 % }
5050 %
5051 % \begin{bbrenv}{B}
5052 % \begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
5053 % \end{bbrbox}
5054 %
5055 % \end{bbrenv}
5056 %
5057 % \end{bbrbox}
5058 % \bbrinput{input}
5059 % \bbroutput{output}
5060 %
5061 % \begin{bbroracle}{OraA}
5062 % \begin{bbrbox}[name=Oracle 1]
5063 % \end{bbrbox}
5064 % \end{bbroracle}
5065 %
5066 % \begin{bbroracle}{OraB}[vdistance=2cm,hdistance=3cm]
5067 % \begin{bbrbox}[name=Oracle 2]
5068 % \end{bbrbox}
5069 % \end{bbroracle}
5070 % \end{bbrenv}
5071 %
5072 % \iffalse
5073 %<*example>
5074 % \fi
5075 \begin{lstlisting}
5076 \begin{bbrenv}{A}
5077 \begin{bbrbox}[name=Reduction]
5078 \pseudocode{
5079 \text{Do something}
5080 }
5081
5082 \begin{bbrenv}{B}
5083 \begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
5084 \end{bbrbox}
5085
5086 \end{bbrenv}
5087
5088 \end{bbrbox}
5089 \bbrinput{input}
5090 \bbroutput{output}
5091
5092 \begin{bbroracle}{OraA}
5093 \begin{bbrbox}[name=Oracle 1]
5094 \end{bbrbox}
5095 \end{bbroracle}
5096
5097 \begin{bbroracle}{OraB}[vdistance=2cm,hdistance=3cm]
5098 \begin{bbrbox}[name=Oracle 2]
5099 \end{bbrbox}
5100 \end{bbroracle}
5101 \end{bbrenv}
5102 \end{lstlisting}
5103 % \iffalse
5104 %</example>
5105 % \fi
5106 % Via the option \enquote{hdistance=length} and \enquote{vdistance=length} you can control the horizontal and vertical position of the oracle. By default this value is set to 1.5cm and |\baselineskip|.
5107 %
5108 % \subsubsection{Communicating with Oracles}
5109 % \index{\textbackslash bbroracleqryfrom}
5110 % \index{\textbackslash bbroracleqryto}
5111 % \index{\textbackslash bbroracleqrytofrom}
5112 % \index{\textbackslash bbroracleqryfromto}
5113 % As oracles use the \emph{bbrbox} environment we can directly use the established ways to send messages and
5114 % queries to oracles. In addition you can use the |\bbroracleqryfrom| and |\bbroracleqryto|.
5115 % \iffalse
5116 %<*example>
5117 % \fi
5118 \begin{lstlisting}
5119 \bbroracleqryfrom{options}
5120 \bbroracleqryto{options}
5121 \bbroracleqrytofrom{options}{options}
5122 \bbroracleqryfromto{options}{options}
5123 \end{lstlisting}
5124 % \iffalse
5125 %</example>
5126 % \fi
5127 % Here options allow you to specify where the label goes (top, bottom). In addition you can use
5128 % |\bbroracleqryspace| to generate extra space between oracle messages. Note
5129 % that oracle messages need to be added after the closing |\end{bbroracle}| command.
5130 %
5131 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
5132 % \begin{bbrbox}[name=Reduction]
5133 % \pseudocode{
5134 % \text{Do something}
5135 % }
5136 %
5137 % \begin{bbrenv}{B}
5138 % \begin{bbrbox}[name=Adversary,minheight=3cm,xshift=3cm]
5139 % \end{bbrbox}
5140 %
5141 % \end{bbrenv}
5142 %
5143 % \end{bbrbox}
5144 % \bbrinput{input}
5145 % \bbroutput{output}
5146 %
5147 % \begin{bbroracle}{OraA}
5148 % \begin{bbrbox}[name=Oracle 1,minheight=1cm]
5149 % \end{bbrbox}
5150 % \end{bbroracle}
5151 % \bbroracleqryto{top=$m$}
5152 % \bbroracleqryfrom{top=$b$}
5153 %
5154 % \begin{bbroracle}{OraB}
5155 % \begin{bbrbox}[name=Oracle 2,minheight=1cm]
5156 % \end{bbrbox}
5157 % \end{bbroracle}
5158 % \bbroracleqrytofrom{top=$m$}{bottom=$b$}
5159 % \end{bbrenv}
5160 %
5161 % \iffalse
5162 %<*example>
5163 % \fi
5164 \begin{lstlisting}
5165 \begin{bbrenv}{A}
5166 \begin{bbrbox}[name=Reduction]
5167 \pseudocode{
5168 \text{Do something}
5169 }
5170
5171 \begin{bbrenv}{B}
5172 \begin{bbrbox}[name=Adversary,minheight=3cm,xshift=3cm]
5173 \end{bbrbox}
5174
5175 \end{bbrenv}
5176
5177 \end{bbrbox}
5178 \bbrinput{input}
5179 \bbroutput{output}
5180
5181 \begin{bbroracle}{OraA}
5182 \begin{bbrbox}[name=Oracle 1,minheight=1cm]
5183 \end{bbrbox}
5184 \end{bbroracle}
5185 \bbroracleqrytotop=$m$}
5186 \bbroracleqryfrom{top=$b$}
5187
5188 \begin{bbroracle}{OraB}
5189 \begin{bbrbox}[name=Oracle 2,minheight=1cm]
5190 \end{bbrbox}
5191 \end{bbroracle}
5192 \bbroracleqrytofrom{top=$m$}{bottom=$b$}
5193 \end{bbrenv}
5194 \end{lstlisting}
5195 % \iffalse
5196 %</example>
5197 % \fi
5198 %
5199 % \subsection{Challengers}
5200 % \index{bbrchallenger}
5201 % \index{hdistance}
5202 % \index{vdistance}
5203 % Each box can have one or more challengers which are drawn on the left hand side of the box. Challengers
5204 % behave identically to oracles with the exception that they are to the left of the box. A challenger
5205 % is created similarly to a \emph{bbrenv} environment using the \emph{bbrchallenger} environment. Challengers
5206 % go behind the single \emph{bbrbox} environment within an \emph{bbrenv} enviornment.
5207 %
5208 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
5209 % \begin{bbrbox}[name=Adversary,minheight=2cm]
5210 % \pseudocode{
5211 % \text{Do something}
5212 % }
5213 %
5214 % \end{bbrbox}
5215 % \bbrinput{input}
5216 % \bbroutput{output}
5217 %
5218 % \begin{bbrchallenger}{ChaA}
5219 % \begin{bbrbox}[name=Challenger,minheight=2cm]
5220 %
5221 % \end{bbrbox}
5222 % \end{bbrchallenger}
5223 % \end{bbrenv}
5224 %
5225 % \iffalse
5226 %<*example>
5227 % \fi
5228 \begin{lstlisting}
5229 \begin{bbrenv}{A}
5230 \begin{bbrbox}[name=Adversary,minheight=2cm]
5231 \pseudocode{
5232 \text{Do something}
5233 }
5234
5235 \end{bbrbox}
5236 \bbrinput{input}
5237 \bbroutput{output}
5238
5239 \begin{bbrchallenger}{ChaA}
5240 \begin{bbrbox}[name=Challenger,minheight=2cm]
5241
5242 \end{bbrbox}
5243 \end{bbrchallenger}
5244 \end{bbrenv}
5245 \end{lstlisting}
5246 % \iffalse
5247 %</example>
5248 % \fi
5249 % Via the option \enquote{hdistance=length} and \enquote{vdistance=length} you can control the horizontal and vertical position of the challenger. By default this value is set to 1.5cm and |\baselineskip|.
5250 %
5251 % \subsubsection{Communicating with Challengers}
5252 % \index{\textbackslash bbrchallengerqryfrom}
5253 % \index{\textbackslash bbrchallengerqryto}
5254 % \index{\textbackslash bbrchallengerqrytofrom}
5255 % \index{\textbackslash bbrchallengerqryfromto}
5256 % As challengers use the \emph{bbrbox} environment we can directly use the established ways to send messages and
5257 % queries to oracles. In addition you can use the |\bbrchallengerqryfrom| and |\bbrchallengerqryto|.
5258 % \iffalse
5259 %<*example>
5260 % \fi
5261 \begin{lstlisting}
5262 \bbrchallengerqryfrom{options}
5263 \bbrchallengerqryto{options}
5264 \bbrchallengerqrytofrom{options}{options}
5265 \bbrchallengerqryfromto{options}{options}
5266 \end{lstlisting}
5267 % \iffalse
5268 %</example>
5269 % \fi
5270 % Here options allow you to specify where the label goes (top, bottom). In addition you can use
5271 % |\bbrchallengerqryspace| to generate extra space between oracle messages. Note
5272 % that challenger messages need to be added after the closing |\end{bbrchallenger}| command.
5273 %
5274 % \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
5275 % \begin{bbrbox}[name=Adversary,minheight=2cm]
5276 % \pseudocode{
5277 % \text{Do something}
5278 % }
5279 %
5280 % \end{bbrbox}
5281 % \bbrinput{input}
5282 % \bbroutput{output}
5283 %
5284 % \begin{bbrchallenger}{ChaA}
5285 % \begin{bbrbox}[name=Challenger,minheight=2cm]
5286 %
5287 % \end{bbrbox}
5288 % \end{bbrchallenger}
5289 %
5290 % \bbrchallengerqrytofrom{top=$m$}{bottom=$b$}
5291 % \end{bbrenv}
5292 %
5293 % \iffalse
5294 %<*example>
5295 % \fi
5296 \begin{lstlisting}
5297 \begin{bbrenv}{A}
5298 \begin{bbrbox}[name=Adversary,minheight=2cm]
5299 \pseudocode{
5300 \text{Do something}
5301 }
5302
5303 \end{bbrbox}
5304 \bbrinput{input}
5305 \bbroutput{output}
5306
5307 \begin{bbrchallenger}{ChaA}
5308 \begin{bbrbox}[name=Challenger,minheight=2cm]
5309
5310 \end{bbrbox}
5311 \end{bbrchallenger}
5312
5313 \bbrchallengerqryfromto{top=$m$}{bottom=$b$}
5314 \end{bbrenv}
5315 \end{lstlisting}
5316 % \iffalse
5317 %</example>
5318 % \fi
5319 %
5320 %
5321 % \subsection{Horizontal Stacking}
5322 %
5323 % |bbrenv| environments can be stacked horizontally.
5324 %
5325 %\begin{figure}[h]
5326 % \centering
5327 % \begin{bbrenv}{A}
5328 % \begin{bbrbox}[name=A,minheight=15mm]
5329 % \pseudocode{a}
5330 % \end{bbrbox}
5331 % \bbrmsgfrom{islast=true,top={$a$}}
5332 % \bbrqryto{aboveskip=6mm,top={$2a$}}
5333 % \end{bbrenv}\begin{bbrenv}{B}
5334 % \begin{bbrbox}[name=B,minheight=15mm]%
5335 % \end{bbrbox}%
5336 % \bbrqryto{edgestyle={<->}}%
5337 % \bbrqryvdots[aboveskip=1mm]%
5338 % \bbrqryto{islast=true,edgestyle={<->}}%
5339 % \end{bbrenv}\begin{bbrenv}{C}
5340 % \begin{bbrbox}[name=C,minheight=15mm]%
5341 % \end{bbrbox}%
5342 % \bbrqryto{top={$3a$}}%
5343 % \end{bbrenv}%
5344 %\end{figure}
5345 %
5346 % Note that in order to not have horizontal space inbetween the boxes, that you
5347 % need to not leave any space. In the following code this is handled via comments.
5348 %
5349 % \iffalse
5350 %<*example>
5351 % \fi
5352 \begin{lstlisting}
5353 \begin{figure}[h]
5354 \centering
5355 \begin{bbrenv}{A}
5356 \begin{bbrbox}[name=A,minheight=15mm]
5357 \pseudocode{a}
5358 \end{bbrbox}
5359 \bbrmsgfrom{islast=true,top={$a$}}
5360 \bbrqryto{aboveskip=6mm,top={$2a$}}
5361 \end{bbrenv}%
5362 \begin{bbrenv}{B}
5363 \begin{bbrbox}[name=B,minheight=15mm]
5364 \end{bbrbox}
5365 \bbrqryto{edgestyle={<->}}
5366 \bbrqryvdots[aboveskip=1mm]
5367 \bbrqryto{islast=true,edgestyle={<->}}
5368 \end{bbrenv}%
5369 \begin{bbrenv}{C}
5370 \begin{bbrbox}[name=C,minheight=15mm]
5371 \end{bbrbox}
5372 \bbrqryto{top={$3a$}}
5373 \end{bbrenv}%
5374 \end{figure}
5375 \end{lstlisting}
5376 % \iffalse
5377 %</example>
5378 % \fi
5379
5380 %
5381 %
5382 % \subsection{Examples}
5383 % A reduction sketch for full domain hash.
5384 %
5385 %\begin{bbrenv}{Red}
5386 %
5387 % \begin{bbrbox}[name=\textsc{Reduction }$\bdv$]
5388 %
5389 % \pseudocode{
5390 % j \sample [q]
5391 % }
5392 %
5393 % \vspace{2ex}
5394 % \emph{/* begin simulation */}
5395 %
5396 % \begin{bbrenv}[aboveskip=2em]{Adv}
5397 % \begin{bbrbox}[name=$\adv$,minheight=8.5cm,style={fill=black},namestyle={color=white},xshift=3cm]
5398 % \end{bbrbox}
5399 %
5400 % \bbrinput{$\fk$}
5401 % \bbroutput{$\sigma$}
5402 %
5403 % \bbrmsgfrom{top=$m_1$,afterskip=-0.5\baselineskip}
5404 % \bbrmsgto{bottom=$\$$,afterskip=0.5\baselineskip}
5405 %
5406 % \bbrmsgvdots
5407 %
5408 % \bbrmsgfrom{top=$m_{j-1}$,beforeskip=0.5\baselineskip,afterskip=-0.5\baselineskip}
5409 % \bbrmsgto{bottom=$\$$,afterskip=1.5\baselineskip}
5410 %
5411 % \bbrmsgfrom{top=$m_j$,afterskip=-0.5\baselineskip}
5412 % \bbrmsgto{bottom=$y$,afterskip=1.5\baselineskip}
5413 %
5414 % \bbrmsgfrom{top=$m_{j+1}$,afterskip=-0.5\baselineskip}
5415 % \bbrmsgto{bottom=$\$$,afterskip=0.5\baselineskip}
5416 %
5417 % \bbrmsgvdots
5418 %
5419 % \bbrmsgfrom{top=$m_q$,beforeskip=0.5\baselineskip,afterskip=-0.5\baselineskip}
5420 % \bbrmsgto{bottom=$\$$}
5421 %
5422 % \begin{bbroracle}{Sign}
5423 % \begin{bbrbox}[name=Sign,namepos=center,style={draw},minheight=1cm]
5424 % \end{bbrbox}
5425 % \end{bbroracle}
5426 %
5427 % \bbroracleqryto{top=$m$}
5428 % \bbroracleqryfrom{top=$\sigma$}
5429 %
5430 % \end{bbrenv}
5431 %
5432 % \pcdraw{
5433 % \node[left=2cm of Adv.north west] (startsim) {};
5434 % \node[left=2cm of Adv.south west] (endsim) {};
5435 % \draw[->,thick] (startsim) -- (endsim);
5436 % \node[rotate=90, left=2.75cm of Adv.west,anchor=center] () {\textsc{Simulation of Random Oracle}};
5437 % }
5438 %
5439 % \emph{/* end simulation */}
5440 %
5441 % \pseudocode{
5442 % y \gets \sigma
5443 % }
5444 %
5445 % \end{bbrbox}
5446 % \bbrqryfrom{beforeskip=0.25cm,top={$(\fk, y)$},side={\dbox{\pseudocode{
5447 % \fk \sample \fash.\kgen(\secparam) \\ x \sample \bin^{\fash.\il(\secpar)} \\ y \gets \fash.\eval(\fk, x)}
5448 % }}}
5449 % \bbrqryto{beforeskip=11.75cm,side=\pseudocode{y \in \fash^{-1}(\fk, x)}}
5450 % \end{bbrenv}
5451 %
5452 %
5453 % \iffalse
5454 %<*example>
5455 % \fi
5456 \begin{lstlisting}
5457 \begin{bbrenv}{Red}
5458
5459 \begin{bbrbox}[name=\textsc{Reduction }$\bdv$]
5460
5461 \pseudocode{
5462 j \sample [q]
5463 }
5464
5465 \vspace{2ex}
5466 \emph{/* begin simulation */}
5467
5468 \begin{bbrenv}[aboveskip=2em]{Adv}
5469 \begin{bbrbox}[name=$\adv$,minheight=8.5cm,style={fill=black},namestyle={color=white},xshift=3cm]
5470 \end{bbrbox}
5471
5472 \bbrinput{$\fk$}
5473 \bbroutput{$\sigma$}
5474
5475 \bbrmsgfrom{top=$m_1$,afterskip=-0.5\baselineskip}
5476 \bbrmsgto{bottom=$\$$,afterskip=0.5\baselineskip}
5477
5478 \bbrmsgvdots
5479
5480 \bbrmsgfrom{top=$m_{j-1}$,beforeskip=0.5\baselineskip,afterskip=-0.5\baselineskip}
5481 \bbrmsgto{bottom=$\$$,afterskip=1.5\baselineskip}
5482
5483 \bbrmsgfrom{top=$m_j$,afterskip=-0.5\baselineskip}
5484 \bbrmsgto{bottom=$y$,afterskip=1.5\baselineskip}
5485
5486 \bbrmsgfrom{top=$m_{j+1}$,afterskip=-0.5\baselineskip}
5487 \bbrmsgto{bottom=$\$$,afterskip=0.5\baselineskip}
5488
5489 \bbrmsgvdots
5490
5491 \bbrmsgfrom{top=$m_q$,beforeskip=0.5\baselineskip,afterskip=-0.5\baselineskip}
5492 \bbrmsgto{bottom=$\$$}
5493
5494 \begin{bbroracle}{Sign}
5495 \begin{bbrbox}[name=Sign,namepos=center,style={draw},minheight=1cm]
5496 \end{bbrbox}
5497 \end{bbroracle}
5498
5499 \bbroracleqryto{top=$m$}
5500 \bbroracleqryfrom{top=$\sigma$}
5501
5502 \end{bbrenv}
5503
5504 \pcdraw{
5505 \node[left=2cm of Adv.north west] (startsim) {};
5506 \node[left=2cm of Adv.south west] (endsim) {};
5507 \draw[->,thick] (startsim) -- (endsim);
5508 \node[rotate=90, left=2.75cm of Adv.west,anchor=center] () {\textsc{Simulation of Random Oracle}};
5509 }
5510
5511 \emph{/* end simulation */}
5512
5513 \pseudocode{
5514 y \gets \sigma
5515 }
5516
5517 \end{bbrbox}
5518 \bbrqryfrom{beforeskip=0.25cm,top={$(\fk, y)$},side={\dbox{\pseudocode{
5519 \fk \sample \fash.\kgen(\secparam) \\ x \sample \bin^{\fash.\il(\secpar)} \\ y \gets \fash.\eval(\fk, x)}
5520 }}}
5521 \bbrqryto{beforeskip=11.75cm,side=\pseudocode{y \in \fash^{-1}(\fk, x)}}
5522 \end{bbrenv}
5523
5524 \end{lstlisting}
5525 % \iffalse
5526 %</example>
5527 % \fi
5528 %
5529 % \amipagebreak
5530 % \section{Known Issues}
5531 %
5532 % \subsection{Pseudocode KeepSpacing within Commands}
5533 % \label{sec:keepindent-problem}
5534 % \index{\textbackslash fbox}
5535 % \index{framebox}
5536 % The (experimental) \enquote{space=keep} option of pseudocode which should output spacing identical to that of the input
5537 % will fail, if the pseudocode command is called from within another command. An example is to
5538 % wrap the |\pseudocode| command in an |\fbox| or in a stacking environment such as |\pchstack|.
5539 % As a workaround for generating frame boxes you should hence
5540 % use a package such as \emph{mdframed} (\url{https://www.ctan.org/pkg/mdframed}) which provides a frame environment.
5541 %
5542 % \begin{mdframed}
5543 % \pseudocode[space=keep,mode=text]{ Pseudocode with - spaces -}
5544 % \end{mdframed}
5545 % \iffalse
5546 %<*example>
5547 % \fi
5548 \begin{lstlisting}
5549 \pseudocode[space=keep,mode=text]{ Pseudocode with - spaces -}
5550 \end{lstlisting}
5551 % \iffalse
5552 %</example>
5553 % \fi
5554 %
5555 % As an alternative you could use a \emph{savebox} (in combination with the |lrbox| environment):
5556 %
5557 % \newsavebox{\mypcbox}
5558 % \begin{lrbox}{\mypcbox}%
5559 % \pseudocode[space=keep,mode=text]{ Pseudocode with - spaces -}%
5560 % \end{lrbox}
5561 % \fbox{\usebox{\mypcbox}}
5562 %
5563 % \iffalse
5564 %<*example>
5565 % \fi
5566 \begin{lstlisting}
5567 \newsavebox{\mypcbox}
5568 \begin{lrbox}{\mypcbox}%
5569 \pseudocode[space=keep,mode=text]{ Pseudocode with - spaces -}%
5570 \end{lrbox}
5571 \fbox{\usebox{\mypcbox}}
5572 \end{lstlisting}
5573 % \iffalse
5574 %</example>
5575 % \fi
5576 %
5577 % \subsection{AMSFonts}
5578 % \index{amsfonts}
5579 % \index{noamsfonts|see {package options}}
5580 % \index{package options!noamsfonts}
5581 % Some packages are not happy with the \enquote{amsfonts} package. Cryptocode will attempt to load amsfonts if it is loaded
5582 % with either the \enquote{sets} or the \enquote{probability} option. In order to not load amsfonts you can additionally add the
5583 % \enquote{noamsfonts} at the very end. Note that in this case you should ensure that the command |\mathbb| is defined
5584 % as this is used by most of the commands in \enquote{sets} and some of the commands in \enquote{probability}.
5585 %
5586 % \subsection{Hyperref}
5587 % \index{hyperref}
5588 % The hyperref package (\url{https://www.ctan.org/pkg/hyperref}) should be loaded before cryptocode. If this is not possible
5589 % call the |\pcfixhyperref| after |\begin{document}|.
5590 %
5591 % \subsection{Cleveref}
5592 % \index{cleveref}
5593 % In order to support the cleveref package (\url{https://ctan.org/pkg/cleveref}) load cleveref after cryptocode and subsequently
5594 % (but still in the preamble) call |\pcfixcleveref|.
5595 %
5596 % \subsection{Babel - Spanish}
5597 % The spanish version of the babel package uses < and > as shorthands which are used by cryptocode as tabbing characters.
5598 % The easisest workaround is to tell cryptocode to use different tabbing characters, for example:
5599 % \iffalse
5600 %<*example>
5601 % \fi
5602 \begin{lstlisting}
5603 \renewcommand{\pctabname}{ctab}
5604 \renewcommand{\pcdbltabname}{cdtab}
5605 \end{lstlisting}
5606 % \iffalse
5607 %</example>
5608 % \fi
5609 %
5610 %\StopEventually{%
5611 % \PrintChanges
5612 % \PrintIndex
5613 %}
5614 %
5615 %
5616 % \amipagebreak
5617 %\section{Implementation}
5618 %
5619 % Following is the implementation of cryptocode. The source code documentation is
5620 % a work in progress.
5621 %
5622 % \begin{macrocode}
5623 %<*cryptocode.sty>
5624 % \end{macrocode}
5625 %
5626 % Note that most macros are prefixed with \emph{pc}
5627 % short for pseudocode. This is a general design choice to not conflict
5628 % with macros defined by other packages. One exception are the macros
5629 % defined via the various package options.
5630 %
5631 %
5632 % Load amsmath and mathtools early on, before defining various macros.
5633 % \begin{macrocode}
5634 \RequirePackage{amsmath}
5635 \RequirePackage{mathtools}
5636 % \end{macrocode}
5637 %
5638 %
5639 % \subsection{Package Options}
5640 %
5641 %\begin{macro}{\@pc@opt@amsfonts}
5642 % Definitions of boolean flags used to determin whether or not to load amsfonts.
5643 % \begin{macrocode}
5644 \newif\if@pc@opt@amsfonts
5645 % \end{macrocode}
5646 %\end{macro}
5647 %
5648 %
5649 %\begin{macro}{\@pc@opt@advantage}
5650 % Whether or not to define commands for the given option.
5651 % \begin{macrocode}
5652 \newif\if@pc@opt@advantage
5653 % \end{macrocode}
5654 %\end{macro}
5655 %
5656 %
5657 %\begin{macro}{\@pc@opt@centernot}
5658 % Whether or not to load centernot
5659 % \begin{macrocode}
5660 \newif\if@pc@opt@centernot
5661 % \end{macrocode}
5662 %\end{macro}
5663 %
5664 %
5665 % \subsubsection{operators}
5666 %
5667 %\begin{macro}{\sample}
5668 %\begin{macro}{\floor}
5669 %\begin{macro}{\tfloor}
5670 %\begin{macro}{\ceil}
5671 %\begin{macro}{\tceil}
5672 %\begin{macro}{\Angle}
5673 %\begin{macro}{\tAngle}
5674 %\begin{macro}{\abs}
5675 %\begin{macro}{\tabs}
5676 %\begin{macro}{\norm}
5677 %\begin{macro}{\tnorm}
5678 %\begin{macro}{\concat}
5679 %\begin{macro}{\emptystring}
5680 %\begin{macro}{\argmax}
5681 %\begin{macro}{\argmin}
5682 %\begin{macro}{\pindist}
5683 %\begin{macro}{\cindist}
5684 %\begin{macro}{\sindist}
5685 % Definitions of macros for the \emph{operators} pacakge option.
5686 %
5687 % \begin{macrocode}
5688 \DeclareOption{operators}{
5689 % \end{macrocode}
5690 %
5691 % Robust sample operator that also works in subscripts. Is based on
5692 % egreg's solution given in \url{https://tex.stackexchange.com/questions/418740/how-to-write-left-arrow-with-a-dollar-sign}.
5693 % \begin{macrocode}
5694 \providecommand\sample{\leftarrow\mathrel{\mkern-2.0mu}\pc@smalldollar}
5695 \newcommand{\pc@smalldollar}{\mathrel{\mathpalette\pc@small@dollar\relax}}
5696 \newcommand{\pc@small@dollar}[2]{%
5697 \vcenter{\hbox{%
5698 $#1\textnormal{\fontsize{0.7\dimexpr\f@size pt}{0}\selectfont\$\hskip-0.05em plus 0.5em}$%
5699 }}%
5700 }
5701
5702 \DeclarePairedDelimiter\pc@floor{\lfloor}{\rfloor}
5703 \providecommand{\floor}[1]{\pc@floor*{#1}}
5704 \providecommand{\tfloor}[1]{\pc@floor{#1}}
5705
5706 \DeclarePairedDelimiter\pc@ceil{\lceil}{\rceil}
5707 \providecommand{\ceil}[1]{\pc@ceil*{#1}}
5708 \providecommand{\tceil}[1]{\pc@ceil{#1}}
5709
5710 \DeclarePairedDelimiter\pc@Angle{\langle}{\rangle}
5711 \providecommand{\Angle}[1]{\pc@Angle*{#1}}
5712 \providecommand{\tAngle}[1]{\pc@Angle{#1}}
5713
5714 \DeclarePairedDelimiter\pc@abs{\lvert}{\rvert}
5715 \providecommand{\abs}[1]{\pc@abs*{#1}}
5716 \providecommand{\tabs}[1]{\pc@abs{#1}}
5717
5718 \DeclarePairedDelimiter\pc@norm{\lVert}{\rVert}
5719 \providecommand{\norm}[1]{\pc@norm*{#1}}
5720 \providecommand{\tnorm}[1]{\pc@tnorm{#1}}
5721
5722 \providecommand{\concat}{\ensuremath{\|}}
5723 \providecommand{\emptystring}{\ensuremath{\varepsilon}}
5724
5725 \DeclareMathOperator*{\argmax}{arg\,max}
5726 \DeclareMathOperator*{\argmin}{arg\,min}
5727
5728 %indistinguishability
5729 \newcommand{\@pc@oset}[3][0ex]{%
5730 \mathrel{\mathop{#3}\limits^{
5731 \vbox to#1{\kern-2\ex@
5732 \hbox{$\scriptstyle#2$}\vss}}}}
5733
5734 \newcommand{\pindist}{\@pc@oset{\text{p}}{\lower.2ex\hbox{$=$}}}
5735 \newcommand{\sindist}{\@pc@oset{\text{s}}{\lower.1ex\hbox{$\approx$}}}
5736 \newcommand{\cindist}{\@pc@oset{\text{c}}{\lower.1ex\hbox{$\approx$}}}
5737 }
5738 % \end{macrocode}
5739 %\end{macro}
5740 %\end{macro}
5741 %\end{macro}
5742 %\end{macro}
5743 %\end{macro}
5744 %\end{macro}
5745 %\end{macro}
5746 %\end{macro}
5747 %\end{macro}
5748 %\end{macro}
5749 %\end{macro}
5750 %\end{macro}
5751 %\end{macro}
5752 %\end{macro}
5753 %\end{macro}
5754 %\end{macro}
5755 %\end{macro}
5756 %\end{macro}
5757 %
5758 %
5759 % \subsubsection{adversary}
5760 %
5761 %\begin{macro}{\adversary}
5762 %\begin{macro}{\adv}
5763 %\begin{macro}{\bdv}
5764 %\begin{macro}{\cdv}
5765 %\begin{macro}{\ddv}
5766 %\begin{macro}{\edv}
5767 %\begin{macro}{\mdv}
5768 %\begin{macro}{\pdv}
5769 %\begin{macro}{\rdv}
5770 %\begin{macro}{\sdv}
5771 % Definitions of adversaries $\adv$ (|\adv|), $\bdv$ (|\bdv|), etc.~together with a style |\pcadvstyle|.
5772 % \begin{macrocode}
5773 \DeclareOption{adversary}{
5774 \providecommand{\adversary}[1]{\pcadvstyle{#1}}
5775
5776 \providecommand{\adv}{\pcadvstyle{A}}
5777 \providecommand{\bdv}{\pcadvstyle{B}}
5778 \providecommand{\cdv}{\pcadvstyle{C}}
5779 \providecommand{\ddv}{\pcadvstyle{D}}
5780 \providecommand{\edv}{\pcadvstyle{E}}
5781 \providecommand{\mdv}{\pcadvstyle{M}}
5782 \providecommand{\pdv}{\pcadvstyle{P}}
5783 \providecommand{\rdv}{\pcadvstyle{R}}
5784 \providecommand{\sdv}{\pcadvstyle{S}}
5785 }
5786 % \end{macrocode}
5787 %\end{macro}
5788 %\end{macro}
5789 %\end{macro}
5790 %\end{macro}
5791 %\end{macro}
5792 %\end{macro}
5793 %\end{macro}
5794 %\end{macro}
5795 %\end{macro}
5796 %\end{macro}
5797 %
5798 %
5799 % \subsubsection{landau}
5800 %
5801 %\begin{macro}{\bigO}
5802 %\begin{macro}{\smallO}
5803 %\begin{macro}{\bigOmega}
5804 %\begin{macro}{\smallOmega}
5805 %\begin{macro}{\bigsmallO}
5806 %\begin{macro}{\bigTheta}
5807 %\begin{macro}{\orderOf}
5808 % Defines several \emph{Landau symbols}.
5809 % \begin{macrocode}
5810 \DeclareOption{landau}{
5811 \providecommand{\bigO}[1]{\ensuremath{\mathcal{O}\pc@olrk*{#1}}}
5812 \providecommand{\smallO}[1]{\ensuremath{\text{o}\pc@olrk*{#1}}}
5813 \providecommand{\bigOmega}[1]{\ensuremath{\Omega\pc@olrk*{#1}}}
5814 \providecommand{\smallOmega}[1]{\ensuremath{\omega\pc@olrk*{#1}}}
5815 \providecommand{\bigsmallO}[1]{%
5816 \PackageWarning{cryptocode}{bigsmallO is deprecated. Use bigTheta instead.}%
5817 \ensuremath{\Theta\pc@olrk*{#1}}}
5818 \providecommand{\bigTheta}[1]{\ensuremath{\Theta\pc@olrk*{#1}}}
5819 \providecommand{\orderOf}{\ensuremath{\sim}}
5820 }
5821 % \end{macrocode}
5822 %\end{macro}
5823 %\end{macro}
5824 %\end{macro}
5825 %\end{macro}
5826 %\end{macro}
5827 %\end{macro}
5828 %\end{macro}
5829 %
5830 %
5831 % \subsubsection{probability}
5832 %
5833 %\begin{macro}{\probname}
5834 %\begin{macro}{\expectationname}
5835 %\begin{macro}{\supportname}
5836 %\begin{macro}{\tprob}
5837 %\begin{macro}{\prob}
5838 %\begin{macro}{\tprobsub}
5839 %\begin{macro}{\probsub}
5840 %\begin{macro}{\probsublong}
5841 %\begin{macro}{\tcondprob}
5842 %\begin{macro}{\condprob}
5843 %\begin{macro}{\tcondprobsub}
5844 %\begin{macro}{\condprobsub}
5845 %\begin{macro}{\texpect}
5846 %\begin{macro}{\expect}
5847 %\begin{macro}{\texpsub}
5848 %\begin{macro}{\expsub}
5849 %\begin{macro}{\tcondexp}
5850 %\begin{macro}{\condexp}
5851 %\begin{macro}{\tcondexpsub}
5852 %\begin{macro}{\condexpsub}
5853 %\begin{macro}{\supp}
5854 %\begin{macro}{\entropy}
5855 %\begin{macro}{\condentropy}
5856 %\begin{macro}{\minentropy}
5857 %\begin{macro}{\condminentropy}
5858 %\begin{macro}{\condavgminentropy}
5859 % The \emph{probability} package option defines various macros for typesetting
5860 % probabilities.
5861 %
5862 % Sets flags |\@pc@opt@amsfontstrue|.
5863 % \begin{macrocode}
5864 \DeclareOption{probability}{
5865 \@pc@opt@amsfontstrue
5866
5867 \providecommand{\probname}{Pr}
5868 \providecommand{\expectationname}{\ensuremath{\mathbb{E}}}
5869 \providecommand{\supportname}{Supp}
5870
5871 \providecommand{\tprob}[1]{\ensuremath{\operatorname{\probname}\pc@elrk{#1}}}
5872 \providecommand{\prob}[1]{\ensuremath{\operatorname{\probname}\pc@elrk*{#1}}}
5873
5874 \providecommand{\tprobsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\pc@elrk{#2}}}
5875 \providecommand{\probsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\pc@elrk*{#2}}}
5876 \providecommand{\probsublong}[2]{\ensuremath{\prob{#2\,:\,#1}}}
5877
5878 \providecommand{\tcondprob}[2]{\ensuremath{\tprob{#1\,\left|\,#2\vphantom{#1}\right.}}}
5879 \providecommand{\condprob}[2]{\ensuremath{\prob{#1\,\left|\,#2\vphantom{#1}\right.}}}
5880
5881 \providecommand{\tcondprobsub}[3]{\ensuremath{\tprobsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
5882 \providecommand{\condprobsub}[3]{\ensuremath{\probsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
5883
5884 \providecommand{\texpect}[1]{\ensuremath{\operatorname{\expectationname}\pc@elrk{#1}}}
5885 \providecommand{\expect}[1]{\ensuremath{\operatorname{\expectationname}\pc@elrk*{#1}}}
5886
5887 \providecommand{\texpsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\pc@elrk{#2}}}
5888 \providecommand{\expsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\pc@elrk*{#2}}}
5889
5890 \providecommand{\tcondexp}[2]{\ensuremath{\texpect{#1\,\left|\,#2\vphantom{#1}\right.}}}
5891 \providecommand{\condexp}[2]{\ensuremath{\expect{#1\,\left|\,#2\vphantom{#1}\right.}}}
5892
5893 \providecommand{\tcondexpsub}[3]{\ensuremath{\texpsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
5894 \providecommand{\condexpsub}[3]{\ensuremath{\expsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
5895
5896 \providecommand{\supp}[1]{\ensuremath{\operatorname{Supp}\pc@olrk*{#1}}}
5897
5898 \providecommand{\entropy}[1]{\ensuremath{\operatorname{H}\pc@olrk*{#1}}}
5899 \providecommand{\condentropy}[2]{%
5900 \ensuremath{\operatorname{H}\pc@olrk*{#1\,\left|\,#2\vphantom{#1}\right.}}}
5901
5902 \providecommand{\minentropy}[1]{\ensuremath{\operatorname{H_\infty}\pc@olrk*{#1}}}
5903 \providecommand{\tminentropy}[1]{\ensuremath{\operatorname{H_\infty}\pc@olrk{#1}}}
5904 \providecommand{\condminentropy}[2]{%
5905 \ensuremath{\operatorname{H_\infty}\pc@olrk*{#1\,\left|\,#2\vphantom{#1}\right.}}}
5906 \providecommand{\tcondminentropy}[2]{%
5907 \ensuremath{\operatorname{H_\infty}\pc@olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}
5908 \providecommand{\condavgminentropy}[2]{%
5909 \ensuremath{\operatorname{\tilde{H}_\infty}\pc@olrk*{#1\,\left|\,#2\vphantom{#1}\right.}}}
5910 \providecommand{\tcondavgminentropy}[2]{%
5911 \ensuremath{\operatorname{\tilde{H}_\infty}\pc@olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}
5912 }
5913 % \end{macrocode}
5914 %\end{macro}
5915 %\end{macro}
5916 %\end{macro}
5917 %\end{macro}
5918 %\end{macro}
5919 %\end{macro}
5920 %\end{macro}
5921 %\end{macro}
5922 %\end{macro}
5923 %\end{macro}
5924 %\end{macro}
5925 %\end{macro}
5926 %\end{macro}
5927 %\end{macro}
5928 %\end{macro}
5929 %\end{macro}
5930 %\end{macro}
5931 %\end{macro}
5932 %\end{macro}
5933 %\end{macro}
5934 %\end{macro}
5935 %\end{macro}
5936 %\end{macro}
5937 %\end{macro}
5938 %\end{macro}
5939 %\end{macro}
5940 %
5941 %
5942 % \subsubsection{sets}
5943 %
5944 %\begin{macro}{\NN}
5945 %\begin{macro}{\ZZ}
5946 %\begin{macro}{\CC}
5947 %\begin{macro}{\QQ}
5948 %\begin{macro}{\RR}
5949 %\begin{macro}{\PP}
5950 %\begin{macro}{\FF}
5951 %\begin{macro}{\GG}
5952 %\begin{macro}{\set}
5953 %\begin{macro}{\sequence}
5954 %\begin{macro}{\bin}
5955 % The \emph{sets} option defines various macros for standard sets such as
5956 % natural numbers |\NN| (\NN). The style can be configured via |\pcsetstyle|.
5957 %
5958 % As we usually work with bit strings, the macro |\bin| defines the set \bin.
5959 % Sets the flags |\@pc@opt@amsfontstrue|.
5960 % \begin{macrocode}
5961 \DeclareOption{sets}{
5962 \@pc@opt@amsfontstrue
5963
5964 \providecommand\NN{\pcsetstyle{N}}
5965 \providecommand\ZZ{\pcsetstyle{Z}}
5966 \providecommand\CC{\pcsetstyle{C}}
5967 \providecommand\QQ{\pcsetstyle{Q}}
5968 \providecommand\RR{\pcsetstyle{R}}
5969 \providecommand\PP{\pcsetstyle{P}}
5970 \providecommand\FF{\pcsetstyle{F}}
5971 \providecommand\GG{\pcsetstyle{G}}
5972
5973 \providecommand{\set}[1]{\ensuremath{\pc@clrk*{#1}}}
5974 \providecommand{\sequence}[1]{\ensuremath{\pc@olrk*{#1}}}
5975 \providecommand{\bin}{\ensuremath{\{0,1\}}}
5976 }
5977 % \end{macrocode}
5978 %\end{macro}
5979 %\end{macro}
5980 %\end{macro}
5981 %\end{macro}
5982 %\end{macro}
5983 %\end{macro}
5984 %\end{macro}
5985 %\end{macro}
5986 %\end{macro}
5987 %\end{macro}
5988 %\end{macro}
5989 %
5990 %
5991 %
5992 % \subsubsection{noamsfonts}
5993 %
5994 %\begin{macro}{\@pc@opt@amsfontsfalse}
5995 % Package option \emph{noamsfonts} ensures that ams fonts are not loaded.
5996 % For this flag |\@pc@opt@amsfontsfalse| is set to false.
5997 % \begin{macrocode}
5998 \DeclareOption{noamsfonts}{
5999 \@pc@opt@amsfontsfalse
6000 }
6001 % \end{macrocode}
6002 %\end{macro}
6003 %
6004 %
6005 % \subsubsection{notions}
6006 %
6007 %\begin{macro}{\indcpa}
6008 %\begin{macro}{\indcca}
6009 %\begin{macro}{\indccai}
6010 %\begin{macro}{\indccaii}
6011 %\begin{macro}{\priv}
6012 %\begin{macro}{\ind}
6013 %\begin{macro}{\indcda}
6014 %\begin{macro}{\prvcda}
6015 %\begin{macro}{\prvrcda}
6016 %\begin{macro}{\kiae}
6017 %\begin{macro}{\kdae}
6018 %\begin{macro}{\mle}
6019 %\begin{macro}{\uce}
6020 %\begin{macro}{\eufcma}
6021 %\begin{macro}{\eufko}
6022 %\begin{macro}{\eufnacma}
6023 %\begin{macro}{\seufcma}
6024 % The \emph{notion} package option defines various cryptographic security
6025 % notions.
6026 % The style to be can be defined via |\pcnotionstyle|.
6027 % \begin{macrocode}
6028 \DeclareOption{notions}{
6029 \providecommand{\indcpa}{\pcnotionstyle{IND\pcmathhyphen{}CPA}}
6030 \providecommand{\indcca}{\pcnotionstyle{IND\pcmathhyphen{}CCA}}
6031 \providecommand{\indccai}{\pcnotionstyle{IND\pcmathhyphen{}CCA1}}
6032 \providecommand{\indccaii}{\pcnotionstyle{IND\pcmathhyphen{}CCA2}}
6033 \providecommand{\priv}{\pcnotionstyle{PRIV}}
6034 \providecommand{\ind}{\pcnotionstyle{IND}}
6035 \providecommand{\indcda}{\pcnotionstyle{IND\pcmathhyphen{}CDA}}
6036 \providecommand{\prvcda}{\pcnotionstyle{PRV\pcmathhyphen{}CDA}}
6037 \providecommand{\prvrcda}{\pcnotionstyle{PRV\$\pcmathhyphen{}CDA}}
6038 \providecommand{\kiae}{\pcnotionstyle{KIAE}}
6039 \providecommand{\kdae}{\pcnotionstyle{KDAE}}
6040 \providecommand{\mle}{\pcnotionstyle{MLE}}
6041 \providecommand{\uce}{\pcnotionstyle{UCE}}
6042
6043 \providecommand{\eufcma}{\pcnotionstyle{EUF\pcmathhyphen{}CMA}}
6044 \providecommand{\eufnacma}{\pcnotionstyle{EUF\pcmathhyphen{}naCMA}}
6045 \providecommand{\seufcma}{\pcnotionstyle{SUF\pcmathhyphen{}CMA}}
6046
6047 \providecommand{\eufko}{\pcnotionstyle{EUF\pcmathhyphen{}KO}}
6048 }
6049 % \end{macrocode}
6050 %\end{macro}
6051 %\end{macro}
6052 %\end{macro}
6053 %\end{macro}
6054 %\end{macro}
6055 %\end{macro}
6056 %\end{macro}
6057 %\end{macro}
6058 %\end{macro}
6059 %\end{macro}
6060 %\end{macro}
6061 %\end{macro}
6062 %\end{macro}
6063 %\end{macro}
6064 %\end{macro}
6065 %\end{macro}
6066 %\end{macro}
6067 %
6068 %
6069 %
6070 % \subsubsection{logic}
6071 %
6072 %\begin{macro}{\AND}
6073 %\begin{macro}{\OR}
6074 %\begin{macro}{\NOR}
6075 %\begin{macro}{\NOT}
6076 %\begin{macro}{\NAND}
6077 %\begin{macro}{\XOR}
6078 %\begin{macro}{\XNOR}
6079 %\begin{macro}{\xor}
6080 %\begin{macro}{\false}
6081 %\begin{macro}{\true}
6082 %\begin{macro}{\notimplies}
6083 % \begin{macrocode}
6084 \DeclareOption{logic}{
6085 % load centernot needed for notimplies
6086 \@pc@opt@centernottrue
6087
6088 \providecommand{\AND}{\ensuremath{\mathrm{AND}}}
6089 \providecommand{\OR}{\ensuremath{\mathrm{OR}}}
6090 \providecommand{\NOR}{\ensuremath{\mathrm{NOR}}}
6091 \providecommand{\NOT}{\ensuremath{\mathrm{NOT}}}
6092 \providecommand{\NAND}{\ensuremath{\mathrm{NAND}}}
6093 \providecommand{\XOR}{\ensuremath{\mathrm{XOR}}}
6094 \providecommand{\XNOR}{\ensuremath{\mathrm{XNOR}}}
6095 \providecommand{\xor}{\ensuremath{\oplus}}
6096 \providecommand{\false}{\mathsf{false}}
6097 \providecommand{\true}{\mathsf{true}}
6098 \providecommand{\notimplies}{\centernot\implies}
6099 }
6100 % \end{macrocode}
6101 %\end{macro}
6102 %\end{macro}
6103 %\end{macro}
6104 %\end{macro}
6105 %\end{macro}
6106 %\end{macro}
6107 %\end{macro}
6108 %\end{macro}
6109 %\end{macro}
6110 %\end{macro}
6111 %\end{macro}
6112 %
6113 %
6114 % \subsubsection{ff (function families)}
6115 %
6116 %
6117 %\begin{macro}{\kgen}
6118 %\begin{macro}{\pgen}
6119 %\begin{macro}{\eval}
6120 %\begin{macro}{\invert}
6121 %\begin{macro}{\il}
6122 %\begin{macro}{\ol}
6123 %\begin{macro}{\kl}
6124 %\begin{macro}{\nl}
6125 %\begin{macro}{\rl}
6126 % The \emph{ff} option defines macros for function families.
6127 % Algorithms are typeset via |\pcalgostyle|.
6128 % \begin{macrocode}
6129 \DeclareOption{ff}{
6130 \providecommand{\kgen}{\pcalgostyle{KGen}}
6131 \providecommand{\pgen}{\pcalgostyle{Pgen}}
6132 \providecommand{\eval}{\pcalgostyle{Eval}}
6133 \providecommand{\invert}{\pcalgostyle{Inv}}
6134
6135 \providecommand{\il}{\pcalgostyle{il}}
6136 \providecommand{\ol}{\pcalgostyle{ol}}
6137 \providecommand{\kl}{\pcalgostyle{kl}}
6138 \providecommand{\nl}{\pcalgostyle{nl}}
6139 \providecommand{\rl}{\pcalgostyle{rl}}
6140 }
6141 % \end{macrocode}
6142 %\end{macro}
6143 %\end{macro}
6144 %\end{macro}
6145 %\end{macro}
6146 %\end{macro}
6147 %\end{macro}
6148 %\end{macro}
6149 %\end{macro}
6150 %\end{macro}
6151 %
6152 %
6153 % \subsubsection{mm (machine models)}
6154 %
6155 %
6156 %\begin{macro}{\pcmachinemodelstyle}
6157 %\begin{macro}{\CRKT}
6158 %\begin{macro}{\TM}
6159 %\begin{macro}{\PROG}
6160 %\begin{macro}{\uTM}
6161 %\begin{macro}{\uC}
6162 %\begin{macro}{\uP}
6163 %\begin{macro}{\csize}
6164 %\begin{macro}{\tmtime}
6165 %\begin{macro}{\ppt}
6166 % The \emph{mm} option defines macros for machine models.
6167 % \begin{macrocode}
6168 \DeclareOption{mm}{
6169 \providecommand{\CRKT}{\pcmachinemodelstyle{C}}
6170 \providecommand{\TM}{\pcmachinemodelstyle{M}}
6171 \providecommand{\PROG}{\pcmachinemodelstyle{P}}
6172
6173 \providecommand{\uTM}{\pcmachinemodelstyle{UM}}
6174 \providecommand{\uC}{\pcmachinemodelstyle{UC}}
6175 \providecommand{\uP}{\pcmachinemodelstyle{UEval}}
6176
6177 \providecommand{\csize}{\pcmachinemodelstyle{size}}
6178 \providecommand{\tmtime}{\pcmachinemodelstyle{time}}
6179 \providecommand{\ppt}{\pcalgostyle{PPT}}
6180 }
6181 % \end{macrocode}
6182 %\end{macro}
6183 %\end{macro}
6184 %\end{macro}
6185 %\end{macro}
6186 %\end{macro}
6187 %\end{macro}
6188 %\end{macro}
6189 %\end{macro}
6190 %\end{macro}
6191 %\end{macro}
6192 %
6193 %
6194 %
6195 % \subsubsection{advantage}
6196 %
6197 % The \emph{advantage} option defines an |\advantage| command for typesetting
6198 % advantage declarations of adversaries.
6199 % \begin{macrocode}
6200 \DeclareOption{advantage}{
6201 \@pc@opt@advantagetrue
6202 }
6203 % \end{macrocode}
6204 %
6205 %
6206 % \subsubsection{primitives}
6207 %
6208 %\begin{macro}{\prover}
6209 %\begin{macro}{\verifier}
6210 %\begin{macro}{\nizk}
6211 %\begin{macro}{\hash}
6212 %\begin{macro}{\gash}
6213 %\begin{macro}{\fash}
6214 %\begin{macro}{\enc}
6215 %\begin{macro}{\dec}
6216 %\begin{macro}{\sig}
6217 %\begin{macro}{\sign}
6218 %\begin{macro}{\verify}
6219 %\begin{macro}{\obf}
6220 %\begin{macro}{\iO}
6221 %\begin{macro}{\diO}
6222 %\begin{macro}{\owf}
6223 %\begin{macro}{\prf}
6224 %\begin{macro}{\prp}
6225 %\begin{macro}{\prg}
6226 %\begin{macro}{\mac}
6227 %\begin{macro}{\puncture}
6228 %\begin{macro}{\source}
6229 %\begin{macro}{\predictor}
6230 %\begin{macro}{\sam}
6231 %\begin{macro}{\dist}
6232 %\begin{macro}{\distinguisher}
6233 %\begin{macro}{\simulator}
6234 %\begin{macro}{\ext}
6235 %\begin{macro}{\extractor}
6236 % The \emph{primitives} package option defines various cryptographic primitives.
6237 % \begin{macrocode}
6238 \DeclareOption{primitives}{
6239 % \end{macrocode}
6240 % Zero knowledge
6241 % \begin{macrocode}
6242 \providecommand{\prover}{\pcalgostyle{P}}
6243 \providecommand{\verifier}{\pcalgostyle{V}}
6244 \providecommand{\nizk}{\pcalgostyle{NIZK}}
6245 % \end{macrocode}
6246 % Hash
6247 % \begin{macrocode}
6248 \providecommand{\hash}{\pcalgostyle{H}}
6249 \providecommand{\gash}{\pcalgostyle{G}}
6250 \providecommand{\fash}{\pcalgostyle{F}}
6251 \providecommand{\pad}{\pcalgostyle{pad}}
6252 % \end{macrocode}
6253 % Encryption
6254 % \begin{macrocode}
6255 \providecommand{\enc}{\pcalgostyle{Enc}}
6256 \providecommand{\dec}{\pcalgostyle{Dec}}
6257 % \end{macrocode}
6258 % Signatures
6259 % \begin{macrocode}
6260 \providecommand{\sig}{\pcalgostyle{Sig}}
6261 \providecommand{\sign}{\pcalgostyle{Sign}}
6262 \providecommand{\verify}{\pcalgostyle{Vf}}
6263 % \end{macrocode}
6264 % Obfuscation
6265 % \begin{macrocode}
6266 \providecommand{\obf}{\pcalgostyle{O}}
6267 \providecommand{\iO}{\pcalgostyle{iO}}
6268 \providecommand{\diO}{\pcalgostyle{diO}}
6269 % \end{macrocode}
6270 % One-wayness
6271 % \begin{macrocode}
6272 \providecommand{\owf}{\pcalgostyle{OWF}}
6273 \providecommand{\owp}{\pcalgostyle{OWP}}
6274 \providecommand{\tdf}{\pcalgostyle{TF}}
6275 \providecommand{\inv}{\pcalgostyle{Inv}}
6276 \providecommand{\hcf}{\pcalgostyle{HC}}
6277 % \end{macrocode}
6278 % Pseudorandomness
6279 % \begin{macrocode}
6280 \providecommand{\prf}{\pcalgostyle{PRF}}
6281 \providecommand{\prp}{\pcalgostyle{PRP}}
6282 \providecommand{\prg}{\pcalgostyle{PRG}}
6283 % \end{macrocode}
6284 % Message authentication code
6285 % \begin{macrocode}
6286 \providecommand{\mac}{\pcalgostyle{MAC}}
6287 % \end{macrocode}
6288 % Puncture
6289 % \begin{macrocode}
6290 \providecommand{\puncture}{\pcalgostyle{Puncture}}
6291 % \end{macrocode}
6292 % Misc
6293 % \begin{macrocode}
6294 \providecommand{\source}{\pcalgostyle{S}}
6295 \providecommand{\predictor}{\pcalgostyle{P}}
6296 \providecommand{\sam}{\pcalgostyle{Sam}}
6297 \providecommand{\dist}{\pcalgostyle{D}}
6298 \providecommand{\distinguisher}{\pcalgostyle{Dist}}
6299 \providecommand{\simulator}{\pcalgostyle{Sim}}
6300 \providecommand{\ext}{\pcalgostyle{Ext}}
6301 \providecommand{\extractor}{\ext}
6302 }
6303 % \end{macrocode}
6304 %\end{macro}
6305 %\end{macro}
6306 %\end{macro}
6307 %\end{macro}
6308 %\end{macro}
6309 %\end{macro}
6310 %\end{macro}
6311 %\end{macro}
6312 %\end{macro}
6313 %\end{macro}
6314 %\end{macro}
6315 %\end{macro}
6316 %\end{macro}
6317 %\end{macro}
6318 %\end{macro}
6319 %\end{macro}
6320 %\end{macro}
6321 %\end{macro}
6322 %\end{macro}
6323 %\end{macro}
6324 %\end{macro}
6325 %\end{macro}
6326 %\end{macro}
6327 %\end{macro}
6328 %\end{macro}
6329 %\end{macro}
6330 %\end{macro}
6331 %\end{macro}
6332 %
6333 %
6334 % \subsubsection{oracles}
6335 %
6336 %\begin{macro}{\Oracle}
6337 %\begin{macro}{\oracle}
6338 %\begin{macro}{\ro}
6339 % The \emph{oracles} package option defines macros for typesetting oracles.
6340 % \begin{macrocode}
6341 \DeclareOption{oracles}{
6342 \providecommand{\Oracle}[1]{\pcalgostyle{O{#1}}}
6343
6344 \def\oracle{\bgroup\oracle@}
6345 \newcommand{\oracle@}[1][]{\ifthenelse{\equal{#1}{}}{\oracle@@{O}}{\oracle@@{#1}}}
6346 \def\oracle@@#1{\pcoraclestyle{#1}\egroup}
6347
6348 \providecommand{\ro}{\pcoraclestyle{RO}}
6349 }
6350 % \end{macrocode}
6351 %\end{macro}
6352 %\end{macro}
6353 %\end{macro}
6354 %
6355 %
6356 %
6357 % \subsubsection{events}
6358 %
6359 %\begin{macro}{\event}
6360 %\begin{macro}{\nevent}
6361 %\begin{macro}{\bad}
6362 %\begin{macro}{\nbad}
6363 % The \emph{events} package option defines macros for typesetting
6364 % events (probabilistic).
6365 % Also defines |\bad| as a \emph{bad event} often used in game based proofs.
6366 % \begin{macrocode}
6367 \DeclareOption{events}{
6368 \providecommand{\event}[1]{\ensuremath{\mathsf{#1}}}
6369 \providecommand{\nevent}[1]{\ensuremath{\overline{\event{#1}}}}
6370
6371 \providecommand{\bad}{\ensuremath{\event{bad}}}
6372 \providecommand{\nbad}{\ensuremath{\nevent{bad}}}
6373 }
6374 % \end{macrocode}
6375 %\end{macro}
6376 %\end{macro}
6377 %\end{macro}
6378 %\end{macro}
6379 %
6380 %
6381 %
6382 % \subsubsection{complexity}
6383 %
6384 %\begin{macro}{\complclass}
6385 %\begin{macro}{\cocomplclass}
6386 %\begin{macro}{\npol}
6387 %\begin{macro}{\conpol}
6388 %\begin{macro}{\pol}
6389 %\begin{macro}{\bpp}
6390 %\begin{macro}{\ppoly}
6391 %\begin{macro}{\AM}
6392 %\begin{macro}{\coAM}
6393 %\begin{macro}{\AC}
6394 %\begin{macro}{\NC}
6395 %\begin{macro}{\TC}
6396 %\begin{macro}{\PH}
6397 %\begin{macro}{\csigma}
6398 %\begin{macro}{\cpi}
6399 %\begin{macro}{\cosigma}
6400 %\begin{macro}{\copi}
6401 % The \emph{complexity} package option defines various complexity classes.
6402 % The style can be adjusted via |\pccomplexitystyle|
6403 % \begin{macrocode}
6404 \DeclareOption{complexity}{
6405 \providecommand{\complclass}[1]{\pccomplexitystyle{#1}}
6406 \providecommand{\cocomplclass}[1]{\pccomplexitystyle{co}\pcmathhyphen{}\pccomplexitystyle{#1}}
6407
6408 \providecommand{\npol}{\pccomplexitystyle{NP}}
6409 \providecommand{\conpol}{\cocomplclass{NP}}
6410 \providecommand{\pol}{\pccomplexitystyle{P}}
6411 \providecommand{\bpp}{\pccomplexitystyle{BPP}}
6412 \providecommand{\ppoly}{\ensuremath{\pol/\mathrm{poly}}}
6413
6414 \providecommand{\AM}{\pccomplexitystyle{AM}}
6415 \providecommand{\coAM}{\cocomplclass{AM}}
6416
6417 \providecommand{\AC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{AC}}{\pccomplexitystyle{AC}^{#1}}}}
6418 \providecommand{\NC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{NC}}{\pccomplexitystyle{NC}^{#1}}}}
6419 \providecommand{\TC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{TC}}{\pccomplexitystyle{TC}^{#1}}}}
6420
6421 \providecommand{\PH}{\pccomplexitystyle{PH}}
6422 \providecommand{\csigma}[1]{\pccomplexitystyle{\Sigma}^p_{#1}}
6423 \providecommand{\cpi}[1]{\pccomplexitystyle{\Pi}^p_{#1}}
6424 \providecommand{\cosigma}[1]{\cocomplclass{\Sigma}^p_{#1}}
6425 \providecommand{\copi}[1]{\cocomplclass{\Pi}^p_{#1}}
6426 }
6427 % \end{macrocode}
6428 %\end{macro}
6429 %\end{macro}
6430 %\end{macro}
6431 %\end{macro}
6432 %\end{macro}
6433 %\end{macro}
6434 %\end{macro}
6435 %\end{macro}
6436 %\end{macro}
6437 %\end{macro}
6438 %\end{macro}
6439 %\end{macro}
6440 %\end{macro}
6441 %\end{macro}
6442 %\end{macro}
6443 %\end{macro}
6444 %\end{macro}
6445 %
6446 %
6447 %
6448 % \subsubsection{asymptotics}
6449 %
6450 %\begin{macro}{\negl}
6451 %\begin{macro}{\poly}
6452 %\begin{macro}{\cc}
6453 %\begin{macro}{\ee}
6454 %\begin{macro}{\kk}
6455 %\begin{macro}{\mm}
6456 %\begin{macro}{\nn}
6457 %\begin{macro}{\pp}
6458 %\begin{macro}{\qq}
6459 %\begin{macro}{\rr}
6460 % The \emph{asymptotics} package option defines \enquote{polynomials} \cc\ (|\cc|),
6461 % \ee\ (|\ee|), \kk\, (|\kk|), \mm\ (|\mm|), \nn\ (|\nn|), \pp\ (|\pp|), and \qq\ (|\qq|) as well as macros |\negl| and |\poly|.
6462 % \begin{macrocode}
6463 \DeclareOption{asymptotics}{
6464 \providecommand{\negl}[1][\secpar]{%
6465 \pcpolynomialstyle{negl}\ifthenelse{\equal{#1}{}}{}{\pc@olrk*{#1}}}
6466
6467 \providecommand{\poly}[1][\secpar]{%
6468 \pcpolynomialstyle{poly}\ifthenelse{\equal{#1}{}}{}{\pc@olrk*{#1}}}
6469
6470 \def\pp{\bgroup\pp@}
6471 \newcommand{\pp@}[1][]{\ifthenelse{\equal{#1}{}}{\pp@@{p}}{\pp@@{#1}}}
6472 \def\pp@@#1{\pcpolynomialstyle{#1}\egroup}
6473
6474
6475 \providecommand{\cc}{\pcpolynomialstyle{c}}
6476 \providecommand{\ee}{\pcpolynomialstyle{e}}
6477 \providecommand{\kk}{\pcpolynomialstyle{k}}
6478 \providecommand{\mm}{\pcpolynomialstyle{m}}
6479 \providecommand{\nn}{\pcpolynomialstyle{n}}
6480 \providecommand{\qq}{\pcpolynomialstyle{q}}
6481 \providecommand{\rr}{\pcpolynomialstyle{r}}
6482 }
6483 % \end{macrocode}
6484 %\end{macro}
6485 %\end{macro}
6486 %\end{macro}
6487 %\end{macro}
6488 %\end{macro}
6489 %\end{macro}
6490 %\end{macro}
6491 %\end{macro}
6492 %\end{macro}
6493 %\end{macro}
6494 %
6495 %
6496 % \subsubsection{keys}
6497 %
6498 %\begin{macro}{\pk}
6499 %\begin{macro}{\vk}
6500 %\begin{macro}{\sk}
6501 %\begin{macro}{\key}
6502 %\begin{macro}{\hk}
6503 %\begin{macro}{\gk}
6504 %\begin{macro}{\fk}
6505 %\begin{macro}{\st}
6506 %\begin{macro}{\state}
6507 % The \emph{keys} package option defines various \enquote{keys} such as
6508 % a symmetric and general purpose \key\ (|\key|) or an asymmetric key pair
6509 % \pk, \sk\ (|\pk| and |\sk|)
6510 % \begin{macrocode}
6511 \DeclareOption{keys}{
6512 \providecommand{\pk}{\pckeystyle{pk}}
6513 \providecommand{\vk}{\pckeystyle{vk}}
6514 \providecommand{\sk}{\pckeystyle{sk}}
6515
6516 \def\key{\bgroup\key@}
6517 \newcommand{\key@}[1][]{\ifthenelse{\equal{#1}{}}{\key@@{k}}{\key@@{#1}}}
6518 \def\key@@#1{\pckeystyle{#1}\egroup}
6519
6520 \providecommand{\hk}{\pckeystyle{hk}}
6521 \providecommand{\gk}{\pckeystyle{gk}}
6522 \providecommand{\fk}{\pckeystyle{fk}}
6523
6524 \providecommand{\st}{\pckeystyle{st}}
6525
6526 \def\state{\bgroup\state@}
6527 \newcommand{\state@}[1][]{\ifthenelse{\equal{#1}{}}{\state@@{state}}{\state@@{#1}}}
6528 \def\state@@#1{\pckeystyle{#1}\egroup}
6529 }
6530 % \end{macrocode}
6531 %\end{macro}
6532 %\end{macro}
6533 %\end{macro}
6534 %\end{macro}
6535 %\end{macro}
6536 %\end{macro}
6537 %\end{macro}
6538 %\end{macro}
6539 %\end{macro}
6540 %
6541 % \subsubsection{Security parameter}
6542 %
6543 %
6544 %\begin{macro}{\SECPAR}
6545 %\begin{macro}{\secpar}
6546 %\begin{macro}{\secparam}
6547 % The \emph{n} option defines security parameter macros |\secpar| and |\secparam|
6548 % using $n$.
6549 % See also \enquote{lambda} package option.
6550 % \begin{macrocode}
6551 \DeclareOption{n}{
6552 \providecommand{\SECPAR}{\ensuremath{{N_0}}}
6553 \providecommand{\secpar}{\ensuremath{n}}
6554 \providecommand{\secparam}{\ensuremath{1^\secpar}}
6555 }
6556 % \end{macrocode}
6557 % \end{macro}
6558 % \end{macro}
6559 % \end{macro}
6560 %
6561 %
6562 %
6563 %\begin{macro}{\SECPAR}
6564 %\begin{macro}{\secpar}
6565 %\begin{macro}{\secparam}
6566 % The \emph{n} option defines security parameter macros |\secpar| and |\secparam|
6567 % using $\lambda$.
6568 % See also \enquote{n} package option.
6569 % \begin{macrocode}
6570 \DeclareOption{lambda}{
6571 \renewcommand{\SECPAR}{\ensuremath{\Lambda}}
6572 \renewcommand{\secpar}{\ensuremath{\lambda}}
6573 \renewcommand{\secparam}{\ensuremath{1^\secpar}}
6574 }
6575 % \end{macrocode}
6576 % \end{macro}
6577 % \end{macro}
6578 % \end{macro}
6579 %
6580 %
6581 % \subsection{Preamble and Option Parsing}
6582 %
6583 % Print a warning in case an undefined package option is provided.
6584 % \begin{macrocode}
6585 \DeclareOption*{%
6586 \PackageError{cryptocode}{Unknown option ‘\CurrentOption’}%
6587 }
6588 % \end{macrocode}
6589 %
6590 % By default, only the \emph{n} option (security parameter as $n$ and $1^n$) is loaded
6591 % \begin{macrocode}
6592 \ExecuteOptions{n}
6593 % \end{macrocode}
6594 %
6595 % We are now ready to process all package options
6596 % \begin{macrocode}
6597 \ProcessOptions\relax
6598 % \end{macrocode}
6599 %
6600 % The cryptocode package depends on various external packages which are
6601 % loaded next. Note that the \emph{amsfonts} package is optional and can be
6602 % disabled via the \emph{noamsfonts} package option.
6603 %
6604 % Note that amsmath and mathtools have been loaded already earlier.
6605 % \begin{macrocode}
6606
6607 \if@pc@opt@amsfonts
6608 \RequirePackage{amsfonts}
6609 \fi
6610 \if@pc@opt@centernot
6611 \RequirePackage{centernot}
6612 \fi
6613 \RequirePackage{xcolor}
6614 \RequirePackage{calc}
6615 \RequirePackage{tikz}
6616 \usetikzlibrary{positioning,calc}
6617 \RequirePackage{ifthen}
6618 \RequirePackage{xargs}
6619 \RequirePackage{pgf}
6620 \RequirePackage{forloop}
6621 \RequirePackage{array}
6622 \RequirePackage{xparse}
6623 \RequirePackage{expl3}
6624 \RequirePackage{pbox}
6625 \RequirePackage{varwidth}
6626 \RequirePackage{suffix}
6627 \RequirePackage{etoolbox}
6628 \RequirePackage{environ}
6629 \RequirePackage{xkeyval}
6630 % \end{macrocode}
6631 %
6632 %
6633 %
6634 %\begin{macro}{\pcadvantagesuperstyle}
6635 %\begin{macro}{\pcadvantagename}
6636 %\begin{macro}{\pcadvantagesubstyle}
6637 %\begin{macro}{\advantage}
6638 % The \emph{advantage} option defines an |\advantage| command for typesetting
6639 % advantage declarations of adversaries.
6640 % \begin{macrocode}
6641 \if@pc@opt@advantage
6642 \providecommand{\pcadvantagesuperstyle}[1]{\mathrm{\MakeLowercase{#1}}}
6643 \providecommand{\pcadvantagesubstyle}[1]{#1}
6644 \providecommand{\pcadvantagename}{\mathsf{Adv}}
6645
6646 \newcommandx*{\advantage}[3][3=(\secpar)]{\ensuremath{\pcadvantagename^{\pcadvantagesuperstyle{#1}}_{\pcadvantagesubstyle{#2}}#3}}
6647 \fi
6648 % \end{macrocode}
6649 %\end{macro}
6650 %\end{macro}
6651 %\end{macro}
6652 %\end{macro}
6653 %
6654 % \subsection{Global Macros}
6655 %
6656 %
6657 %
6658 %
6659 % \subsubsection{Styles}
6660 %
6661 %
6662 %
6663 %\begin{macro}{\pcalgostyle}
6664 %\begin{macro}{\pcsetstyle}
6665 %\begin{macro}{\pccomplexitystyle}
6666 %\begin{macro}{\pcpolynomialstyle}
6667 %\begin{macro}{\pcadvstyle}
6668 %\begin{macro}{\pcnotionstyle}
6669 %\begin{macro}{\pckeystyle}
6670 %\begin{macro}{\pcmachinemodelstyle}
6671 %\begin{macro}{\pcoraclestyle}
6672 % Definition of styles for algorithms, sets, complexity classes, polynomials,
6673 % adversaries, notions, keys, and machine models.
6674 % \begin{macrocode}
6675 \providecommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
6676 \providecommand{\pcsetstyle}[1]{\ensuremath{\mathbb{#1}}}
6677 \providecommand{\pccomplexitystyle}[1]{\ensuremath{\mathsf{#1}}}
6678 \providecommand{\pcpolynomialstyle}[1]{\ensuremath{\mathsf{#1}}}
6679 \providecommand{\pcadvstyle}[1]{\ensuremath{\mathcal{#1}}}
6680 \providecommand{\pcnotionstyle}[1]{\ensuremath{\mathrm{#1}}}
6681 \providecommand{\pckeystyle}[1]{\ensuremath{\mathsf{\protect\vphantom{p}#1}}}
6682 \providecommand{\pcmachinemodelstyle}[1]{\ensuremath{\mathsf{#1}}}
6683 \providecommand{\pcoraclestyle}[1]{\ensuremath{\mathsf{#1}}}
6684 % \end{macrocode}
6685 %\end{macro}
6686 %\end{macro}
6687 %\end{macro}
6688 %\end{macro}
6689 %\end{macro}
6690 %\end{macro}
6691 %\end{macro}
6692 %\end{macro}
6693 %\end{macro}
6694 %
6695 %
6696 % \subsubsection{Order of Growth}
6697 %
6698 %\begin{macro}{\pc@olrk}
6699 %\begin{macro}{\pc@olrk*}
6700 %\begin{macro}{\pc@elrk}
6701 %\begin{macro}{\pc@elrk*}
6702 %\begin{macro}{\pc@clrk}
6703 %\begin{macro}{\pc@clrk*}
6704 % Define order of growth helper macros. These are optionally defined depending
6705 % on the loaded package options.
6706 % \begin{macrocode}
6707 \DeclarePairedDelimiter\pc@olrk{(}{)}
6708 \DeclarePairedDelimiter\pc@elrk{[}{]}
6709 \DeclarePairedDelimiter\pc@clrk{\{}{\}}
6710 % \end{macrocode}
6711 %\end{macro}
6712 %\end{macro}
6713 %\end{macro}
6714 %\end{macro}
6715 %\end{macro}
6716 %\end{macro}
6717 %
6718 %
6719 % \subsubsection{Spacing}
6720 %
6721 %\begin{macro}{\pcaboveskip}
6722 %\begin{macro}{\pcbelowskip}
6723 %\begin{macro}{\pcbeforeskip}
6724 %\begin{macro}{\pcafterskip}
6725 % Control the spacing before (resp.~after) pseudocode and stacking blocks both
6726 % vertically and horizontally.
6727 % \begin{macrocode}
6728 \newlength\pcaboveskip
6729 \setlength\pcaboveskip{\abovedisplayskip}
6730
6731 \newlength\pcbelowskip
6732 \setlength\pcbelowskip{\belowdisplayskip}
6733
6734 \newlength\pcbeforeskip
6735 \newlength\pcafterskip
6736 % \end{macrocode}
6737 %\end{macro}
6738 %\end{macro}
6739 %\end{macro}
6740 %\end{macro}
6741 %
6742 %
6743 %
6744 % \subsubsection{Keywords and Highlighting}
6745 %
6746 %
6747 %\begin{macro}{\highlightkeyword}
6748 %\begin{macro}{\highlightaltkeyword}
6749 % Commands for highlighting primary and secondary keywords.
6750 % Both commands take an optional first parameter to control spacing
6751 % \begin{macrocode}
6752 \newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
6753 \newcommand{\highlightaltkeyword}[2][\ ]{\ensuremath{\mathsf{#2}}#1}
6754 % \end{macrocode}
6755 %\end{macro}
6756 %\end{macro}
6757 %
6758 %
6759 %
6760 %\begin{macro}{\pcglobvar}
6761 %\begin{macro}{\pcnew}
6762 %\begin{macro}{\pcwhile}
6763 %\begin{macro}{\pcendwhile}
6764 %\begin{macro}{\pcdo}
6765 %\begin{macro}{\pcif}
6766 %\begin{macro}{\pcunless}
6767 %\begin{macro}{\pcelse}
6768 %\begin{macro}{\pcelseif}
6769 %\begin{macro}{\pcfi}
6770 %\begin{macro}{\pcendif}
6771 %\begin{macro}{\pcendfor}
6772 %\begin{macro}{\pcthen}
6773 %\begin{macro}{\pcreturn}
6774 %\begin{macro}{\pcin}
6775 %\begin{macro}{\pcfor}
6776 %\begin{macro}{\pcrepeat}
6777 %\begin{macro}{\pcrepeatuntil}
6778 %\begin{macro}{\pcforeach}
6779 %\begin{macro}{\pcendforeach}
6780 %\begin{macro}{\pcuntil}
6781 %\begin{macro}{\pccontinue}
6782 %\begin{macro}{\pcfalse}
6783 %\begin{macro}{\pctrue}
6784 %\begin{macro}{\pcnull}
6785 %\begin{macro}{\pcdone}
6786 %\begin{macro}{\pcparse}
6787 %\begin{macro}{\pcfail}
6788 %\begin{macro}{\pcabort}
6789 %\begin{macro}{\pcassert}
6790 % All predefined (highlightable) keywords.
6791 % \begin{macrocode}
6792 \newcommand{\pcglobvar}{\highlightkeyword{gbl}}
6793 \newcommand{\pcnew}{\highlightkeyword{new}}
6794 \newcommand{\pcwhile}{\@pc@increaseindent\highlightkeyword{while}}
6795 \newcommand{\pcendwhile}{\@pc@decreaseindent\highlightkeyword{endwhile}}
6796 \newcommandx*{\pcdo}[2][1=\ ,2=]{#1\highlightkeyword[#2]{do}}
6797 \newcommandx*{\pcif}[1][1=\ ]{\@pc@increaseindent\highlightkeyword[#1]{if}}
6798 \newcommandx*{\pcunless}[1][1=\ ]{\@pc@increaseindent\highlightkeyword[#1]{unless}}
6799 \newcommandx*{\pcelse}[1][1=\ ]{\@pc@tmpdecreaseindent\highlightkeyword[#1]{else}}
6800 \newcommandx*{\pcelseif}[1][1=\ ]{\@pc@tmpdecreaseindent\highlightkeyword[#1]{else if}}
6801 \newcommand{\pcfi}{\@pc@decreaseindent\highlightkeyword{fi}}
6802 \newcommand{\pcendif}{\@pc@decreaseindent\highlightkeyword{endif}}
6803 \newcommand{\pcendfor}{\@pc@decreaseindent\highlightkeyword{endfor}}
6804 \newcommandx*{\pcthen}[2][1=\ ,2=\ ]{#1\highlightkeyword[#2]{then}}
6805 \newcommand{\pcreturn}{\highlightkeyword{return}}
6806 \newcommandx*{\pcin}[2][1=\ ,2=]{#1\highlightkeyword[#2]{in}}
6807 \newcommandx*{\pcfor}[1][1=\ ]{\@pc@increaseindent\highlightkeyword[#1]{for}}
6808 \newcommand{\pcrepeat}[1]{%
6809 \@pc@increaseindent\ensuremath{%
6810 \highlightkeyword{repeat} #1\ \highlightkeyword{times}%
6811 }}
6812 \newcommand{\pcrepeatuntil}[2]{%
6813 \ensuremath{\highlightkeyword{repeat}\ #1\ \highlightkeyword{until}\ #2}}
6814 \newcommand{\pcforeach}{\@pc@increaseindent\highlightkeyword{foreach}}
6815 \newcommand{\pcendforeach}{\@pc@decreaseindent\highlightkeyword{endforeach}}
6816 \newcommand{\pcuntil}{\@pc@decreaseindent\highlightkeyword{until}}
6817 \newcommand{\pccontinue}{\highlightkeyword{continue}}
6818 \newcommandx*{\pcfalse}[2][1=\ ,2=]{\highlightkeyword[#2]{false}}
6819 \newcommandx*{\pctrue}[2][1=\ ,2=]{\highlightkeyword[#2]{true}}
6820 \newcommandx*{\pcnull}[2][1=\ ,2=]{\highlightkeyword[#2]{null}}
6821 \newcommand{\pcdone}{\highlightkeyword{done}}
6822 \newcommand{\pcparse}{\highlightkeyword{parse}}
6823 \newcommand{\pcfail}{\highlightkeyword{fail}}
6824 \newcommand{\pcabort}{\highlightkeyword{abort}}
6825 \newcommand{\pcassert}{\highlightkeyword{assert}}
6826 % \end{macrocode}
6827 %\end{macro}
6828 %\end{macro}
6829 %\end{macro}
6830 %\end{macro}
6831 %\end{macro}
6832 %\end{macro}
6833 %\end{macro}
6834 %\end{macro}
6835 %\end{macro}
6836 %\end{macro}
6837 %\end{macro}
6838 %\end{macro}
6839 %\end{macro}
6840 %\end{macro}
6841 %\end{macro}
6842 %\end{macro}
6843 %\end{macro}
6844 %\end{macro}
6845 %\end{macro}
6846 %\end{macro}
6847 %\end{macro}
6848 %\end{macro}
6849 %\end{macro}
6850 %\end{macro}
6851 %\end{macro}
6852 %\end{macro}
6853 %\end{macro}
6854 %\end{macro}
6855 %\end{macro}
6856 %\end{macro}
6857 %
6858 % \subsubsection{Misc}
6859 %
6860 %
6861 %\begin{macro}{\pcmathhyphen}
6862 % Definition of a hyphen to be used within math formulas.
6863 % \begin{macrocode}
6864 \mathchardef\pcmathhyphen ="2D
6865 % \end{macrocode}
6866 %\end{macro}
6867 %
6868 %
6869 %\begin{macro}{\pccomment}
6870 %\begin{macro}{\pclinecomment}
6871 % Programming style line comment prefixing the comment with a double slash.
6872 % An optional first parameter allows to control the spacing before the comment
6873 % (defaults to 1em).
6874 % \begin{macrocode}
6875 \newcommand{\pccomment}[2][1em]{\hspace{#1}{\mbox{/\!\!/ } \text{\scriptsize#2}}}
6876 \newcommand{\pclinecomment}[2][0em]{\hspace{#1}{\mbox{/\!\!/ } \text{\scriptsize#2}}}
6877 % \end{macrocode}
6878 %\end{macro}
6879 %\end{macro}
6880 %
6881 %
6882 % \subsection{Internal Helper Functions}
6883 %
6884 %
6885 %\begin{macro}{\@expandedsetkeys}
6886 %^^A https://tex.stackexchange.com/questions/27172/how-can-i-detect-if-im-inside-or-outside-of-a-float-environment
6887 % \begin{macrocode}
6888 \newcommand\@pc@ifinfloat[2]{\ifnum\@floatpenalty<0\relax#1\else#2\fi}
6889 % \end{macrocode}
6890 %\end{macro}
6891 %
6892 %\begin{macro}{\@expandedsetkeys}
6893 % Calls |\setkeys| from the xkeyval package but before exapands argument number 4.
6894 % Arguments \marg{families} \marg{na} \marg{first set of keys} \marg{keys to be expanded} \marg{final set of keys}
6895 % \begin{macrocode}
6896 \newcommand*\@expandedsetkeys[5]{\expandafter\@expandedsetkeys@\expandafter{#4}{#1}{#2}{#3}{#5}}
6897 \def\@expandedsetkeys@#1#2#3#4#5{\setkeys{#2}[#3]{#4,#1,#5}}
6898 % \end{macrocode}
6899 %\end{macro}
6900 %
6901 % \begin{macrocode}
6902 \newenvironment{@pc@withspaces}
6903 {\obeyspaces\begingroup\lccode`~=` \lowercase{\endgroup\let~}\ }
6904 {}
6905 % \end{macrocode}
6906 %
6907 %\begin{macro}{\@pc@settowidthofalign}
6908 %\begin{macro}{\@pc@settowidthofaligned}
6909 % Commands to measure width of an align (resp. aligned) environment. Takes two arguments
6910 % a length in which to store the resulting width and the content.
6911 % \begin{macrocode}
6912 \newcommand{\@pc@settowidthofalign}[2]{%
6913 \setbox\z@=\vbox{\@pseudocodecodesize
6914 \begin{flalign*}
6915 #2
6916 \ifmeasuring@\else\global\let\got@maxcolwd\maxcolumn@widths\fi
6917 \end{flalign*}
6918 }%
6919 \begingroup
6920 \def\or{+}\edef\x{\endgroup#1=\dimexpr\got@maxcolwd\relax}\x}
6921
6922 \newcommand{\@pc@settowidthofaligned}[2]{%
6923 \settowidth{#1}{\@pseudocodesubcodesize$\begin{aligned}#2\end{aligned}$}}
6924 % \end{macrocode}
6925 %\end{macro}
6926 %\end{macro}
6927 %
6928 %
6929 %
6930 %\begin{macro}{\@pc@ifdraft}
6931 % Check for draft mode.
6932 % \begin{macrocode}
6933 \def\@pc@ifdraft{\ifdim\overfullrule>\z@
6934 \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
6935 % \end{macrocode}
6936 %\end{macro}
6937 %
6938 %
6939 %\begin{macro}{\@pc@executeblindly}
6940 % Run stuff in an empty box
6941 % \begin{macrocode}
6942 \newcommand{\@pc@executeblindly}[1]{%
6943 \setbox\z@=\vbox{#1 }}
6944 % \end{macrocode}
6945 %\end{macro}
6946 %
6947 %
6948 % We need to fiddle with the label command to use it in |\pseudocode|. To
6949 % access the original, we store it in
6950 % \begin{macrocode}
6951 \AtBeginDocument{
6952 \let\@pc@original@label\ltx@label
6953 }
6954 % \end{macrocode}
6955 %
6956 %
6957 %\begin{macro}{\@pc@globaladdtolength}
6958 %\begin{macro}{\@pc@globalsetlength}
6959 % A helper command to set (resp.~add to) the length to a given value globally
6960 % even when being within a scoped grouping.
6961 % \begin{macrocode}
6962 \newcommand*{\@pc@globaladdtolength}[2]{%
6963 \addtolength{#1}{#2}%
6964 \global#1=#1\relax}
6965
6966 \newcommand*{\@pc@globalsetlength}[2]{%
6967 \setlength{#1}{#2}%
6968 \global#1=#1\relax}
6969 % \end{macrocode}
6970 %\end{macro}
6971 %\end{macro}
6972 %
6973 %
6974 %
6975 %
6976 %
6977 %\begin{macro}{@pc@global@pc@cnt}
6978 %\begin{macro}{@pc@global@pc@nestcnt}
6979 % A global counter storing the number of times the pseudocode command was triggered.
6980 % \begin{macrocode}
6981 \newcounter{@pc@global@pc@cnt}
6982 \newcounter{@pc@global@pc@nestcnt}
6983 % \end{macrocode}
6984 %\end{macro}
6985 %\end{macro}
6986 %
6987 %
6988 %
6989 %
6990 %
6991 % Fix hyperref package.. gnarl http://tex.stackexchange.com/questions/130319/incompatibility-between-etoolbox-and-hyperref
6992 % \begin{macrocode}
6993 \providecommand{\pcfixhyperref}{
6994 \global\let\textlabel\label
6995 \global\let\@pc@original@label\textlabel
6996 %\global\let\@pc@original@label\relax
6997 %\global\let\label\relax
6998 }
6999 % \end{macrocode}
7000 %
7001 %
7002 % Allow to support cleveref package. It wants to be loaded after amsmath which is why it needs to be loaded after cryptocode.
7003 % To do the necessary label fixes, we need to run these after its label fixes at begin document.
7004 % \begin{macrocode}
7005 \providecommand{\pcfixcleveref}{
7006 \AtBeginDocument{%
7007 \pcfixhyperref%
7008 \makeatletter%
7009 \crefformat{@pclinenumber}{line~##2##1##3}%
7010 \crefrangeformat{@pclinenumber}{lines~##3##1##4 to~##5##2##6}%
7011 \makeatother%
7012 }}
7013 % \end{macrocode}
7014 %
7015 %
7016 %
7017 % \subsection{Stacking}
7018 %
7019 % In the following we define two stacking environments |pchstack| and |pcvstack|
7020 % to layout multiple pseudocode blocks.
7021 %
7022 %
7023 %
7024 % \subsubsection{Manual Spacing}
7025 %
7026 % \begin{macrocode}
7027 %
7028 \newcommand{\pchspace}[1][1em]{\hspace{#1}}
7029 \newcommand{\pcvspace}[1][\baselineskip]{\par\vspace{#1}}
7030 %
7031 % \end{macrocode}
7032 %
7033 %
7034 % \subsubsection{Misc}
7035 %
7036 %\begin{macro}{@pc@stackdepth}
7037 %\begin{macro}{\@pc@incstackdepth}
7038 %\begin{macro}{\@pc@decstackdepth}
7039 % Counter to keep track of nesting level of stacks.
7040 % \begin{macrocode}
7041 \newcounter{@pc@stackdepth}
7042 \newcommand{\@pc@incstackdepth}{\addtocounter{@pc@stackdepth}{1}}
7043 \newcommand{\@pc@decstackdepth}{\addtocounter{@pc@stackdepth}{-1}}
7044 % \end{macrocode}
7045 %\end{macro}
7046 %\end{macro}
7047 %\end{macro}
7048 %
7049 % \subsubsection{Stacking Options}
7050 %
7051 %\begin{macro}{center}
7052 %\begin{macro}{\@pc@centerstack}
7053 % Allows to center the stack.
7054 % \begin{macrocode}
7055 \newcommand{\@pc@centerstack}{false}
7056 \define@key{pcstack}{center}[true]{\ifthenelse{\equal{#1}{true}}
7057 {\renewcommand{\@pc@centerstack}{true}}
7058 {\renewcommand{\@pc@centerstack}{false}}}%
7059 % \end{macrocode}
7060 %\end{macro}
7061 %\end{macro}
7062 %
7063 %
7064 %\begin{macro}{boxed}
7065 %\begin{macro}{\@pc@boxedstack}
7066 % Allows to draw a box around the stack.
7067 % \begin{macrocode}
7068 \newcommand{\@pc@boxedstack}{false}
7069 \define@key{pcstack}{boxed}[true]{\ifthenelse{\equal{#1}{true}}
7070 {\renewcommand{\@pc@boxedstack}{true}}
7071 {\renewcommand{\@pc@boxedstack}{false}}}%
7072 % \end{macrocode}
7073 %\end{macro}
7074 %\end{macro}
7075 %
7076 %
7077 %\begin{macro}{noindent}
7078 %\begin{macro}{\@pc@noindentstack}
7079 % Allows to draw a box around the stack.
7080 % \begin{macrocode}
7081 \newcommand{\@pc@noindentstack}{false}
7082 \define@key{pcstack}{noindent}[true]{\ifthenelse{\equal{#1}{true}}
7083 {\renewcommand{\@pc@noindentstack}{true}}
7084 {\renewcommand{\@pc@noindentstack}{false}}}%
7085 % \end{macrocode}
7086 %\end{macro}
7087 %\end{macro}
7088 %
7089 %
7090 %\begin{macro}{inline}
7091 %\begin{macro}{\@pc@inlinestack}
7092 % Allows to keep the pchstack inline and not creating a paragraph.
7093 % \begin{macrocode}
7094 \newcommand{\@pc@inlinestack}{false}
7095 \define@key{pcstack}{inline}[true]{\ifthenelse{\equal{#1}{true}}
7096 {\renewcommand{\@pc@inlinestack}{true}}
7097 {\renewcommand{\@pc@inlinestack}{false}}}%
7098 % \end{macrocode}
7099 %\end{macro}
7100 %\end{macro}
7101 %
7102 %
7103 %
7104 %\begin{macro}{space}
7105 %\begin{macro}{\pchstackspace}
7106 %\begin{macro}{\pcvstackspace}
7107 %\begin{macro}{\@pc@centerstack}
7108 % Introduces horizontal (resp.~vertical) space in-between pseudocode blocks
7109 % in stacking environments .
7110 % \begin{macrocode}
7111 \providecommand{\pchstackspace}{0pt}
7112 \providecommand{\pcvstackspace}{0pt}
7113 \newcommand{\@pc@stackspace@forpseudocode}{}
7114 \newlength{\@pc@stackspace@len}
7115 \newcommand*{\@pc@stackspace}{0pt}
7116 \newcommand*{\@pc@reset@stackspace}{\setlength{\@pc@stackspace@len}{\@pc@stackspace}}
7117 \define@key{pcstack}{space}[0pt]{\renewcommand*{\@pc@stackspace}{#1}}%
7118 % \end{macrocode}
7119 %\end{macro}
7120 %\end{macro}
7121 %\end{macro}
7122 %\end{macro}
7123 %
7124 %
7125 %\begin{macro}{aboveskip}
7126 %\begin{macro}{\@pc@applyaboveskipinstack}
7127 %\begin{macro}{\@pc@addabovespaceunlessstacking}
7128 % By default |\pcaboveskip| is applied on the outer most stacking environment.
7129 % Can be overriden using |aboveskip|.
7130 % \begin{macrocode}
7131 \newcommand{\@pc@addabovespaceunlessstacking}{%
7132 \ifthenelse{\value{@pc@stackdepth}=0}{\par\addvspace{\pcaboveskip}}{}}
7133
7134 \newcommand{\@pc@applyaboveskipinstack}{\@pc@addabovespaceunlessstacking}
7135 \let\org@pc@applyaboveskipinstack\@pc@applyaboveskipinstack
7136
7137 \define@key{pcstack}{aboveskip}[default]{\ifthenelse{\equal{#1}{default}}
7138 {\renewcommand{\@pc@applyaboveskipinstack}{\org@pc@applyaboveskipinstack}}
7139 {\renewcommand{\@pc@applyaboveskipinstack}{\vspace{#1}}}}%
7140 % \end{macrocode}
7141 %\end{macro}
7142 %\end{macro}
7143 %\end{macro}
7144 %
7145 %
7146 %\begin{macro}{belowskip}
7147 %\begin{macro}{\@pc@applybelowskipinstack}
7148 %\begin{macro}{\@pc@addbelowspaceunlessstacking}
7149 % By default |\pcbelowskip| is applied on the outer most stacking environment.
7150 % Can be overriden using |belowskip|.
7151 % \begin{macrocode}
7152 \newcommand{\@pc@addbelowspaceunlessstacking}{%
7153 \ifthenelse{\value{@pc@stackdepth}=0}
7154 {\@pc@ifinfloat{}{\par\addvspace{\pcbelowskip}}}
7155 {}}
7156
7157 \newcommand{\@pc@applybelowskipinstack}{\@pc@addbelowspaceunlessstacking}
7158 \let\org@pc@applybelowskipinstack\@pc@addbelowspaceunlessstacking
7159
7160 \define@key{pcstack}{belowskip}[default]{\ifthenelse{\equal{#1}{default}}
7161 {\renewcommand{\@pc@applybelowskipinstack}{\org@pc@applybelowskipinstack}}
7162 {\renewcommand{\@pc@applybelowskipinstack}{\par\addvspace{#1}}}}%
7163 % \end{macrocode}
7164 %\end{macro}
7165 %\end{macro}
7166 %\end{macro}
7167 %
7168 %
7169 %\begin{macro}{\pcbeforehstackskip}
7170 %\begin{macro}{\pcafterhstackskip}
7171 %Allows adding global skips before and after |\pchstack| blocks.
7172 % \begin{macrocode}
7173 \newlength{\pcbeforehstackskip}
7174 \newlength{\pcafterhstackskip}
7175 % \end{macrocode}
7176 %\end{macro}
7177 %\end{macro}
7178 %
7179 %
7180 %
7181 %\begin{macro}{\@pc@boxedstack}
7182 % For |\pchstack| and |\pcvstack| we use a box to store temporary results.
7183 % \begin{macrocode}
7184 \newsavebox{\@pc@stackcontentbox}%
7185 % \end{macrocode}
7186 %\end{macro}
7187 %
7188 %
7189 %\begin{macro}{\pcsethstackargs}
7190 %\begin{macro}{\pcsetvstackargs}
7191 % \begin{macrocode}
7192 \newcommand*\@pc@hstack@defaultargs{}
7193 \newcommand*\pcsethstackargs[1]{\renewcommand*\@pc@hstack@defaultargs{#1}}
7194 \newcommand*\@pc@vstack@defaultargs{}
7195 \newcommand*\pcsetvstackargs[1]{\renewcommand*\@pc@vstack@defaultargs{#1}}
7196 % \end{macrocode}
7197 %\end{macro}
7198 %\end{macro}
7199 %
7200 % \subsubsection{The Stacking Environments}
7201 %
7202 %\begin{macro}{pccenter}
7203 % \begin{macrocode}
7204 \newenvironment{pccenter}{%
7205 \setlength\topsep{0pt}\setlength\parskip{0pt}%
7206 \begin{center}}{\end{center}}
7207 % \end{macrocode}
7208 %\end{macro}
7209 %
7210 %
7211 %\begin{environment}{pchstack}
7212 % A stacking environment for horizontally stacked pseudocode blocks.
7213 % \begin{macrocode}
7214 \NewEnviron{pchstack}[1][]{%
7215 %Ensure that the parameters are defaulted
7216 \begingroup%
7217 % parse args this is the same as
7218 % \setkeys{pcstack}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pchstackspace,#1}%
7219 % expect that we expand the default args
7220 \@expandedsetkeys{pcstack}{}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pchstackspace}{\@pc@hstack@defaultargs}{#1}%
7221 \@pc@reset@stackspace%
7222 %add above skip except when in inline mode
7223 \ifthenelse{\equal{\@pc@inlinestack}{true}}{}{\@pc@applyaboveskipinstack}%
7224 \@pc@incstackdepth%
7225 \renewcommand{\@pc@stackspace@forpseudocode}{\hspace{\@pc@stackspace}}%
7226 %Store main content in a box
7227 \ifthenelse{\equal{\@pc@boxedstack}{true}}%
7228 {\sbox{\@pc@stackcontentbox}
7229 {\fbox{\mbox{\hspace{\pcbeforehstackskip}\BODY\hspace{\pcafterhstackskip}\hspace{-\@pc@stackspace}}}}}%
7230 {\sbox{\@pc@stackcontentbox}
7231 {\mbox{\hspace{\pcbeforehstackskip}\BODY\hspace{\pcafterhstackskip}\hspace{-\@pc@stackspace}}}}%
7232 % handle noindent
7233 \ifthenelse{\equal{\@pc@noindentstack}{true}}{\par\noindent\ignorespaces}{}%
7234 %set content either centered or directly
7235 \ifthenelse{\equal{\@pc@centerstack}{true}}%
7236 {\begin{pccenter}\usebox{\@pc@stackcontentbox}\end{pccenter}}
7237 {\usebox{\@pc@stackcontentbox}}%
7238 % cleanup
7239 \@pc@decstackdepth%
7240 \ifthenelse{\equal{\@pc@inlinestack}{true}}{}{\@pc@applybelowskipinstack}%
7241 \endgroup%reset space outside group
7242 \@pc@reset@stackspace%
7243 \@pc@stackspace@forpseudocode%
7244 %ignore any spaces after, to allow staying within paragraph
7245 \ignorespacesafterend\noindent%
7246 }
7247 % \end{macrocode}
7248 %\end{environment}
7249 %
7250 %
7251 %\begin{environment}{pchstack}
7252 % A stacking environment for vertically stacked pseudocode blocks.
7253 % \begin{macrocode}
7254 \NewEnviron{pcvstack}[1][]{%
7255 %Ensure that the parameters are defaulted
7256 \begingroup%
7257 % parse args this is the same as
7258 % \setkeys{pcstack}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pcvstackspace,#1}
7259 % expect that we expand the default args
7260 \@expandedsetkeys{pcstack}{}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pcvstackspace}{\@pc@vstack@defaultargs}{#1}%
7261 \@pc@reset@stackspace%
7262 \@pc@applyaboveskipinstack%
7263 \@pc@incstackdepth%
7264 \renewcommand{\@pc@stackspace@forpseudocode}{\par\vspace{\@pc@stackspace}}%
7265 %Store main content in a box
7266 \sbox{\@pc@stackcontentbox}{%
7267 \ifthenelse{\equal{\@pc@boxedstack}{true}}%
7268 {\fbox{\raisebox{\dimexpr\ht\strutbox-\height}{\begin{varwidth}[t]{2\linewidth}\BODY\end{varwidth}}}}%
7269 {\raisebox{\dimexpr\ht\strutbox-\height}{\begin{varwidth}[t]{2\linewidth}\BODY\end{varwidth}}}%
7270 \vspace{-\@pc@stackspace}}%
7271 % handle noindent
7272 \ifthenelse{\equal{\@pc@noindentstack}{true}}{\par\noindent\ignorespaces}{}%
7273 % display content
7274 \ifthenelse{\equal{\@pc@centerstack}{true}}%
7275 {\begin{pccenter}\usebox{\@pc@stackcontentbox}\end{pccenter}}%
7276 {\usebox{\@pc@stackcontentbox}}%
7277 % cleanup
7278 \@pc@decstackdepth%
7279 \@pc@applybelowskipinstack%
7280 \endgroup%reset space outside group
7281 \@pc@reset@stackspace%
7282 \@pc@stackspace@forpseudocode%
7283 %ignore any spaces after, to allow staying within paragraph
7284 \ignorespacesafterend\noindent%
7285 }
7286 % \end{macrocode}
7287 %\end{environment}
7288 %
7289 %
7290 %
7291 % \subsection{The pseudocode command}
7292 %
7293 %
7294 %
7295 % Define internal lengths used for measurements within pseudocode.
7296 % \begin{macrocode}
7297 \newlength{\@pc@minipage@length}
7298 \newlength{\@pc@alt@minipage@length}
7299 \newlength{\@pc@length@tmp@width@vstack}
7300 % \end{macrocode}
7301 %
7302 %
7303 % Define flags used in game based proofs.
7304 % \begin{macrocode}
7305 \newcommand{\@withingame}{false}
7306 \newcommand{\@withinbxgame}{false}
7307 \newcommand{\@withingamedescription}{false}
7308 % \end{macrocode}
7309 %
7310 %
7311 %\begin{macro}{\@bxgameheader}
7312 % Define a placeholder command which will take the current game header.
7313 % \begin{macrocode}
7314 \newcommand{\@bxgameheader}{}
7315 % \end{macrocode}
7316 %\end{macro}
7317 %
7318 %
7319 %\begin{macro}{\@pc@beginnewline}
7320 % An internal helper that is called at the beginning of each new line.
7321 % \begin{macrocode}
7322 \newlength\@pseudocodecodeminlineheight@len
7323 \newcommand{\@pc@beginnewline}{%
7324 \@pseudocodecodeatbeginline\@pseudocodelinenumber\@pc@and\@pcln@stephiddenlncnt%
7325 \setlength{\@pseudocodecodeminlineheight@len}{\@pseudocodecodeminlineheight}%
7326 \vphantom{\rule[0.5ex-0.5\@pseudocodecodeminlineheight@len]{0pt}{\@pseudocodecodeminlineheight@len}}%
7327 %checkspace
7328 \ifthenelse{\equal{\@pseudocodespace}{auto}}%
7329 {\expandafter\pcind\expandafter[\value{@pc@indentationlevel}]}%
7330 {}%
7331 %reset column counter
7332 \setcounter{pccolumncounter}{2}%
7333 %beginmode
7334 \@pc@modebegin}
7335 % \end{macrocode}
7336 %\end{macro}
7337 %
7338 %
7339 %
7340 %\begin{macro}{\@pc@and@wrap@end}
7341 %\begin{macro}{\@pc@and@wrap@start}
7342 % Every pseudocode line is wrapped in between |\@pc@and@wrap@start| and
7343 % |\@pc@and@wrap@end|.
7344 % \begin{macrocode}
7345 \newcommand{\@pc@and@wrap@start}{\@pc@beginnewline}
7346 \newcommand{\@pc@and@wrap@end}{\@pc@modeend&\@pseudocodecodeatendline}
7347 % \end{macrocode}
7348 %\end{macro}
7349 %\end{macro}
7350 %
7351 %
7352 %\begin{macro}{\@pc@and}
7353 % An internal helper to store the ampersand. As this is a special character
7354 % this is the easiest in order to place custom alignment tags.
7355 % \begin{macrocode}
7356 \newcommand{\@pc@and}{&}
7357 % \end{macrocode}
7358 %\end{macro}
7359 %
7360 %
7361 %
7362 %\begin{macro}{\pcind}
7363 % An indentation macro to be used within pseudocode.
7364 % As writing |\pcind| is a bit cumbersome, there is a shorthand that can
7365 % be defined via |\pcindentname| (defaults to t). See below.
7366 % \begin{macrocode}
7367 \newlength{\@pcindentwidth}
7368 \providecommand{\pcind}[1][1]{%
7369 \setlength{\@pcindentwidth}{\widthof{\ensuremath{\quad}}*#1}%
7370 \ensuremath{\mathmakebox[\@pcindentwidth]{}}}
7371 % \end{macrocode}
7372 %\end{macro}
7373 %
7374 %
7375 %
7376 %\begin{macro}{\pctabname}
7377 %\begin{macro}{\pcdbltabname}
7378 %\begin{macro}{\pcindentname}
7379 % Shorthands for alignment tabs and indentation. These are defined only within
7380 % the pseudocode scope.
7381 % \begin{macrocode}
7382 \newcommand{\pctabname}{>}
7383 \newcommand{\pcdbltabname}{<}
7384 \newcommand{\pcindentname}{t}
7385 % \end{macrocode}
7386 %\end{macro}
7387 %\end{macro}
7388 %\end{macro}
7389 %
7390 %
7391 %
7392
7393 %
7394 % The following commands handle line numbering within the pseudocode command. The
7395 % pseudocode command itself does need to do some counter magic. We start
7396 % with a definition of various helper counters.
7397 % The H version of counters is needed to make hyperref happy
7398 % \begin{macrocode}
7399 \newcounter{pclinenumber}
7400 \newcounter{Hpclinenumber}
7401 \newcounter{@pclinenumber}
7402 \newcounter{H@pclinenumber}
7403 \newcounter{@pclinenumbertmp}
7404 \newcounter{pcgamecounter}
7405 \newcounter{Hpcgamecounter}
7406 \newcounter{pcrlinenumber}
7407 \newcounter{Hpcrlinenumber}
7408 \newcounter{@pcrlinenumbertmp}
7409 % \end{macrocode}
7410 %
7411 % The following implements some counter magic. When using automatic linenumbering
7412 % line numbers are nicely aligned before the first alignment tag. This, however
7413 % confuses hyperref and we thus have a second counter that is updated after the
7414 % first tag. This is done with the |\@pcln@stephiddenlncnt|
7415 % \begin{macrocode}
7416 \renewcommand{\the@pclinenumber}{\thepclinenumber}
7417 \providecommand{\@pcln@stephiddenlncnt}{%
7418 \refstepcounter{@pclinenumber}%
7419 \stepcounter{H@pclinenumber}%
7420 }
7421 % \end{macrocode}
7422 %
7423 %
7424 %\begin{macro}{\pclnseparator}
7425 %\begin{macro}{\pcrlnseparator}
7426 % Define separators between line numbers and code (left and right).
7427 % Note that line numbers can be displayed either to the left or to the right
7428 % of code.
7429 % \begin{macrocode}
7430 \providecommand{\pclnseparator}{:}
7431 \providecommand{\pcrlnseparator}{}
7432 % \end{macrocode}
7433 %\end{macro}
7434 %\end{macro}
7435 %
7436 %
7437 %\begin{macro}{\pclnspace}
7438 %\begin{macro}{\pclnrspace}
7439 % Define spacing between line numbers and code (left and right).
7440 % \begin{macrocode}
7441 \providecommand{\pclnspace}{1em}
7442 \providecommand{\pclnrspace}{0.5em}
7443 % \end{macrocode}
7444 %\end{macro}
7445 %\end{macro}
7446 %
7447 %
7448 %\begin{macro}{\pclnstyle}
7449 % \begin{macrocode}
7450 \providecommand\pclnstyle[1]{\text{\scriptsize#1}}
7451 % \end{macrocode}
7452 %\end{macro}
7453 %
7454 %\begin{macro}{pcln}
7455 % Manually place (left aligned) line numbers.
7456 % This command is also used by the automatic placement of line numbers.
7457 % \begin{macrocode}
7458 \providecommand{\pcln}{%
7459 \ifthenelse{\equal{\@pc@skiplnmarker}{1}}{\ifmeasuring@\else\@pc@resetskipln{}\fi}{%
7460 \refstepcounter{pclinenumber}%
7461 \stepcounter{Hpclinenumber}%
7462 \ifthenelse{\value{pclinenumber}<10}{\hspace{1ex}}{}%
7463 \pclnstyle{\arabic{pclinenumber}}\pclnseparator\hspace{\pclnspace}%
7464 }}%
7465 % \end{macrocode}
7466 %\end{macro}
7467 %
7468 %
7469 %\begin{macro}{\pcskipln}
7470 %\begin{macro}{\@pc@skiplnmarker}
7471 %\begin{macro}{skipfirstln}
7472 % allow to skip numbering single lines if linenumbering=on
7473 % \begin{macrocode}
7474 \def\@pc@skiplnmarker{}
7475 \providecommand{\pcskipln}{\ifmeasuring@\else\global\def\@pc@skiplnmarker{1}\fi}
7476 \newcommand{\@pc@resetskipln}{\global\def\@pc@skiplnmarker{}}
7477 \define@key{pseudocode}{skipfirstln}[1]{\global\def\@pc@skiplnmarker{1}}
7478 % \end{macrocode}
7479 %\end{macro}
7480 %\end{macro}
7481 %\end{macro}
7482 %
7483 %
7484 %\begin{macro}{\pclnr}
7485 %\begin{macro}{\pcrln}
7486 % Manual placement of right aligned line numbers using the same counter
7487 % (|\pclnr|) or a separate counter (|\pcrln|).
7488 % \begin{macrocode}
7489 \providecommand{\pclnr}{%
7490 \refstepcounter{pclinenumber}%
7491 \stepcounter{Hpclinenumber}%
7492 \hspace{\pclnrspace}\pcrlnseparator\pclnstyle{\arabic{pclinenumber}}}
7493
7494 \providecommand{\pcrln}{
7495 \refstepcounter{pcrlinenumber}%
7496 \stepcounter{Hpcrlinenumber}%
7497 \hspace{\pclnrspace}\pcrlnseparator\pclnstyle{\arabic{pcrlinenumber}}}
7498 % \end{macrocode}
7499 %\end{macro}
7500 %\end{macro}
7501 %
7502 %
7503 % \subsubsection{Options}
7504 %
7505 %
7506 % The following commands define a bunch of placeholders (plus their default values)
7507 % that are defined via the various options of the pseudocode command.
7508 % \begin{macrocode}
7509 \newcommand*\@pseudocodehead{}
7510 \newcommand*\@pseudocodewidth{}
7511 \newcommand*\@pseudocodexshift{0pt}
7512 \newcommand*\@pseudocodeyshift{0pt}
7513 \newcommand*\@pseudocodelinenumber{}
7514 \newcommand*\@pseudocodebeforeskip{0ex}
7515 \newcommand*\@pseudocodeafterskip{0ex}
7516 \newcommand*\@pseudocodelnstart{0}
7517 \newcommand*\@pseudocodelnstartright{0}
7518 \newcommand*\@pseudocodesyntaxhighlighting{}
7519 \newcommand*\@pseudocodenodraft{false}
7520 \newcommand*\@pseudocodecolspace{} % empty per default, use length,
7521
7522 \newcommand*\@pseudocodeheadlinecmd{\hrule}
7523
7524 % \end{macrocode}
7525
7526 %\begin{macro}{headlinesep}
7527 %\begin{macro}{\pcheadlinesep}
7528 %\begin{macro}{\@pseudocodeheadlinesep}
7529 % Distance between header and line.
7530 % \begin{macrocode}
7531 \newlength\pcheadlinesep
7532 \setlength\pcheadlinesep{0pt}
7533 \newcommand*\@pseudocodeheadlinesep{0em}
7534 \define@key{pseudocode}{headlinesep}[0em]{\renewcommand*\@pseudocodeheadlinesep{#1}}
7535 % \end{macrocode}
7536 %\end{macro}
7537 %\end{macro}
7538 %\end{macro}
7539 %
7540 %
7541 %\begin{macro}{bodylinesep}
7542 %\begin{macro}{\pcbodylinesep}
7543 %\begin{macro}{\@pseudocodebodylinesep}
7544 % \begin{macrocode}
7545 \newlength\pcbodylinesep
7546 \setlength\pcbodylinesep{0.3\baselineskip}
7547 \newcommand*\@pseudocodebodylinesep{0em}
7548 \define@key{pseudocode}{bodylinesep}[0em]{\renewcommand*\@pseudocodebodylinesep{#1}}
7549 % \end{macrocode}
7550 %\end{macro}
7551 %\end{macro}
7552 %\end{macro}
7553 %
7554 %\begin{macro}{headheight}
7555 %\begin{macro}{\pcheadheight}
7556 %\begin{macro}{\@pc@headheightskip}
7557 %\begin{macro}{\@pseudocodeheadheight}
7558 % \begin{macrocode}
7559 \newlength\@pseudocodeheadheight@len
7560 \newcommand{\@pc@headheightskip}{%
7561 \setlength{\@pseudocodeheadheight@len}{\@pseudocodeheadheight}%
7562 \vphantom{\rule[0.5ex-0.5\@pseudocodeheadheight@len]{0pt}{\@pseudocodeheadheight@len}}%
7563 }
7564 \newlength\pcheadheight
7565 \setlength{\pcheadheight}{3.25ex}
7566 \newcommand*\@pseudocodeheadheight{\pcheadheight}
7567 \define@key{pseudocode}{headheight}[0em]{\renewcommand*\@pseudocodeheadheight{#1}}
7568 % \end{macrocode}
7569 %\end{macro}
7570 %\end{macro}
7571 %\end{macro}
7572 %\end{macro}
7573 %
7574
7575
7576 %
7577 % \begin{macrocode}
7578
7579 \newcommand*\@pseudocodecolsep{0em}
7580 \newcommand*\@pseudocodeaddtolength{2pt}
7581
7582 \newcommand*\@pseudocodecodeatbeginline{}
7583 \newcommand*\@pseudocodecodeatendline{}
7584 \newcommand*\@pseudocodecodejot{0em}
7585 \newcommand*\@pseudocodecodesize{\small}
7586 \newcommand*\@pseudocodesubcodesize{\footnotesize}
7587
7588 \newcommand*\@pseudocodeminipagealign{t}
7589
7590 %
7591 % Define keywords for the automatic syntax highlighting
7592 % the accompanying add provides additional keywords.
7593 % The space version for automatic spacing
7594 \newcommand*\@pseudocodekeywordsindent{for ,foreach ,if ,repeat ,while }
7595 \newcommand*\@pseudocodekeywordsunindent{endfor,endforeach,fi,endif,until,endwhile}
7596 \newcommand*\@pseudocodekeywordsuninindent{else if ,elseif ,else }
7597 \newcommand*\@pseudocodekeywords{for,foreach,{return },return,{ do },{ in },new,if, null, true,{until },{ to }, false,{ then},repeat,else if,elseif,while,else,done}
7598 \newcommand*\@pseudocodeaddkeywords{}
7599 \newcommand*\@pseudocodealtkeywords{}
7600 \begin{@pc@withspaces}
7601 \global\def\@pseudocodekeywordsspace{for,endfor,foreach,endforeach,return,do,in,new,if,null,true,until,to,false,then,repeat,else if,elseif,while,endwhile,else,done,fi,endif}
7602 \end{@pc@withspaces}
7603 % \end{macrocode}
7604 %
7605 %
7606 % Specification of the various options of the |\pseudocode| command.
7607 % \begin{macrocode}
7608 \define@key{pseudocode}{beginline}[]{\renewcommand*\@pseudocodecodeatbeginline{#1}}
7609 \define@key{pseudocode}{endline}[]{\renewcommand*\@pseudocodecodeatendline{#1}}
7610 \define@key{pseudocode}{jot}[0em]{\renewcommand*\@pseudocodecodejot{#1}}
7611 \define@key{pseudocode}{codesize}[\small]{\renewcommand*\@pseudocodecodesize{#1}}
7612 \define@key{pseudocode}{subcodesize}[\small]{\renewcommand*\@pseudocodesubcodesize{#1}}
7613 \define@key{pseudocode}{head}[]{\renewcommand*\@pseudocodehead{#1}}
7614 \define@key{pseudocode}{width}[]{\renewcommand*\@pseudocodewidth{#1}}
7615 \define@key{pseudocode}{valign}[t]{\renewcommand*\@pseudocodeminipagealign{#1}}
7616 \define@key{pseudocode}{xshift}[]{\renewcommand*\@pseudocodexshift{#1}}
7617 \define@key{pseudocode}{yshift}[]{\renewcommand*\@pseudocodeyshift{#1}}
7618 \define@key{pseudocode}{colspace}[]{\renewcommand*\@pseudocodecolspace{#1}}
7619 \define@key{pseudocode}{linenumbering}[on]{\ifthenelse{\equal{#1}{on}}{\renewcommand*\@pseudocodelinenumber{\pcln}}{\renewcommand*\@pseudocodelinenumber{}}}
7620 \define@key{pseudocode}{beforeskip}[]{\renewcommand*\@pseudocodebeforeskip{#1}}
7621 \define@key{pseudocode}{afterskip}[]{\renewcommand*\@pseudocodeafterskip{#1}}
7622 \define@key{pseudocode}{lnstart}[0]{\renewcommand*\@pseudocodelnstart{#1}}
7623 \define@key{pseudocode}{lnstartright}[0]{\renewcommand*\@pseudocodelnstartright{#1}}
7624 \define@key{pseudocode}{colsep}[0em]{\renewcommand*\@pseudocodecolsep{#1}}
7625 \define@key{pseudocode}{headlinecmd}[\hrule]{\renewcommand*\@pseudocodeheadlinecmd{#1}}
7626 \define@key{pseudocode}{addtolength}[2pt]{\renewcommand*\@pseudocodeaddtolength{#1}}
7627 \define@key{pseudocode}{nodraft}[true]{\renewcommand*\@pseudocodenodraft{#1}}
7628 \define@key{pseudocode}{keywords}[]{\renewcommand*\@pseudocodekeywords{#1}}
7629 \define@key{pseudocode}{keywordsindent}[]{\renewcommand*\@pseudocodekeywordsindent{#1}}
7630 \define@key{pseudocode}{keywordsunindent}[]{\renewcommand*\@pseudocodekeywordsunindent{#1}}
7631 \define@key{pseudocode}{keywordsuninindent}[]{\renewcommand*\@pseudocodekeywordsuninindent{#1}}
7632 \define@key{pseudocode}{addkeywords}[]{\renewcommand*\@pseudocodeaddkeywords{#1}}
7633 \define@key{pseudocode}{altkeywords}[]{\renewcommand*\@pseudocodealtkeywords{#1}}
7634 \define@key{pseudocode}{syntaxhighlight}[]{\renewcommand*\@pseudocodesyntaxhighlighting{#1}}
7635 % \end{macrocode}
7636 %
7637 %
7638 %
7639 %\begin{macro}{mode}
7640 % The \oarg{mode} key (with values \meta{text} or \meta{math} (default)) specifies
7641 % whether within a pseudocode block input is by default typeset in text mode or in
7642 % math mode.
7643 % The |\@pc...| variables are variables that help typesetting each line in a pseudocode block.
7644 % \begin{macrocode}
7645 \newcommand{\@pc@modebegin}{}
7646 \newcommand{\@pc@modeend}{}
7647 \define@key{pseudocode}{mode}[math]{%
7648 \ifthenelse{\equal{#1}{text}}{%
7649 \renewcommand*\@pc@modebegin{\begin{varwidth}{\textwidth}%
7650 %introduce line magic for text mode
7651 \let\@pc@lb\\%
7652 \renewcommandx*{\\}[2][1=,2=]{\@pc@modeend\@pc@and \@pseudocodecodeatendline\ifthenelse{\equal{####1}{}}{\@pc@lb}{\@pc@lb[####1]}####2 \@pc@beginnewline}%
7653 \def\pclb{\let\\\@pc@lb\relax\@pc@modeend\\}%
7654 \def\pcolb{\let\\\@pc@lb\relax\@pc@modeend\\}%
7655 }%
7656 \renewcommand*\@pc@modeend{\end{varwidth}}%
7657 }{\renewcommand{\@pc@modebegin}{}\renewcommand{\@pc@modeend}{}}}
7658 % \end{macrocode}
7659 %\end{macro}
7660 %
7661 %
7662 %\begin{macro}{minlineheight}
7663 %\begin{macro}{\pcminlineheight}
7664 %\begin{macro}{\@pseudocodecodeminlineheight}
7665 % Control the minimal line height of pseudocode blocks.
7666 % \begin{macrocode}
7667 \providecommand{\pcminlineheight}{0pt}
7668 \newcommand*\@pseudocodecodeminlineheight{\pcminlineheight}
7669 \define@key{pseudocode}{minlineheight}[0pt]{\renewcommand*\@pseudocodecodeminlineheight{#1}}
7670 % \end{macrocode}
7671 %\end{macro}
7672 %\end{macro}
7673 %\end{macro}
7674 %
7675 %
7676 %
7677 %
7678 % \subsubsection{Automatic Syntax Highlighting and Spacing (Experimental)}
7679 %
7680 %
7681 %
7682 %
7683 % Experimental LaTex3 string substitution helpers for automatic keyword
7684 % highlighting. The regex parsing is (regrettably) super slow.
7685 % \begin{macrocode}
7686 \ExplSyntaxOn
7687 \tl_new:N \l_pc_strsub_input_tl
7688 \tl_new:N \l_pc_strsub_search_tl
7689 \tl_new:N \l_pc_strsub_replace_tl
7690
7691 \NewDocumentCommand{\@pc@stringsubstitution}{mmm}
7692 {
7693 \tl_set:Nn \l_pc_strsub_input_tl { #1 }
7694 \tl_set:Nn \l_pc_strsub_search_tl { #2 }
7695 \tl_set:Nn \l_pc_strsub_replace_tl { #3 }
7696 % \tl_show_analysis:N \l_pc_strsub_input_tl % uncomment for debugging
7697 % \tl_show_analysis:N \l_pc_strsub_search_tl % uncomment for debugging
7698 % \tl_show_analysis:N \l_pc_strsub_replace_tl % uncomment for debugging
7699 \regex_replace_all:nnN
7700 { \u{l_pc_strsub_search_tl} } %only match if keyword does not have a word character preceding
7701 { \u{l_pc_strsub_replace_tl} }
7702 \l_pc_strsub_input_tl
7703 % \tl_show_analysis:N \l_tmpa_tl % uncomment for debugging
7704 \tl_use:N \l_pc_strsub_input_tl
7705 }
7706 \ExplSyntaxOff
7707 % \end{macrocode}
7708 %
7709 %
7710 %
7711 %\begin{macro}{\@pc@syntaxhighlight}
7712 %\begin{macro}{\@pc@highlight}
7713 %\begin{macro}{\@pc@highlightindent}
7714 %\begin{macro}{\@pc@highlightunindent}
7715 %\begin{macro}{\@pc@highlightuninindent}
7716 %\begin{macro}{\@pc@althighlight}
7717 % This is the core of the (experimental) automatic syntax highlighting and
7718 % automatic spacing. The code is ugly, and very slow.
7719 % It is not really recommended to be used in larger projects.
7720 % \begin{macrocode}
7721 \newcommand{\@pc@syntaxhighlight}[1]{%
7722 %don't highlight during measuring runs for performance improvements.
7723 \ifmeasuring@#1\else%
7724 \ifthenelse{\equal{\@pseudocodesyntaxhighlighting}{auto}}{%
7725 \def\@shtmp{#1}% first step
7726 % Depending on space mode, we might later run the indent/unindent/... lists
7727 % if not, we add them now to tmp lists in order to have a complete list.
7728 \ifthenelse{\equal{\@pseudocodespace}{keep}}
7729 {\edef\@tmpkeywords{\@pseudocodekeywordsspace,\@pseudocodeaddkeywords}}
7730 {\ifthenelse{\equal{\@pseudocodespace}{auto}}
7731 {\edef\@tmpkeywords{\@pseudocodekeywords,\@pseudocodeaddkeywords}}
7732 {\edef\@tmpkeywords{\@pseudocodekeywords,\@pseudocodekeywordsindent,\@pseudocodekeywordsunindent,\@pseudocodekeywordsuninindent,\@pseudocodeaddkeywords}}}
7733 \foreach \@pckw in \@tmpkeywords{%
7734 \ifthenelse{\equal{\@pckw}{}}{}{%
7735 % we are doing a simple strsub and storing the result (globally) in @shtmp
7736 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7737 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7738 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7739 {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7740 \@pc@stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7741 {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
7742 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc@highlight\expandafter{\@pckw}}}%
7743 }}% alt keywords
7744 \foreach \@pckw in \@pseudocodealtkeywords{%
7745 \ifthenelse{\equal{\@pckw}{}}{}{%
7746 % we are doing a simple strsub and storing the result (globally) in @shtmp
7747 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7748 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7749 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7750 {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7751 \@pc@stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7752 {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
7753 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc@althighlight\expandafter{\@pckw}}}%
7754 }}%
7755 % if automatic spacing
7756 \ifthenelse{\equal{\@pseudocodespace}{auto}}
7757 {%
7758 \foreach \@pckw in \@pseudocodekeywordsindent{% indentation keywords
7759 \ifthenelse{\equal{\@pckw}{}}{}{%
7760 % we are doing a simple strsub and storing the result (globally) in @shtmp
7761 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7762 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7763 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7764 {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7765 \@pc@stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7766 {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
7767 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc@highlightindent\expandafter{\@pckw}}}%
7768 }}%
7769 \foreach \@pckw in \@pseudocodekeywordsunindent{% unindentation keywords
7770 \ifthenelse{\equal{\@pckw}{}}{}{%
7771 % we are doing a simple strsub and storing the result (globally) in @shtmp
7772 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7773 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7774 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7775 {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7776 \@pc@stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7777 {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
7778 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc@highlightunindent\expandafter{\@pckw}}}%
7779 }}%
7780 \foreach \@pckw in \@pseudocodekeywordsuninindent{% uninindentation keywords
7781 \ifthenelse{\equal{\@pckw}{}}{}{%
7782 % we are doing a simple strsub and storing the result (globally) in @shtmp
7783 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7784 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7785 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7786 {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7787 \@pc@stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
7788 {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
7789 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc@highlightuninindent\expandafter{\@pckw}}}%
7790 }}%
7791 }{}%
7792 % return result
7793 \@shtmp%
7794 }{#1}% nothing to highlight
7795 \fi}
7796
7797 \newcommand{\@pc@highlight}[1]{%
7798 \ifthenelse{\equal{\@pseudocodespace}{keep}}
7799 {\highlightkeyword[]{#1}}%
7800 {\highlightkeyword[]{\@pc@stringsubstitution{#1}{ }{~}}}%
7801 }
7802
7803 \newcommand{\@pc@highlightindent}[1]{%
7804 \@pc@increaseindent\@pc@highlight{#1}%
7805 }
7806
7807 \newcommand{\@pc@highlightunindent}[1]{%
7808 \@pc@decreaseindent\@pc@highlight{#1}%
7809 }
7810
7811 \newcommand{\@pc@highlightuninindent}[1]{%
7812 \@pc@tmpdecreaseindent\@pc@highlight{#1}%
7813 }
7814
7815 \newcommand{\@pc@althighlight}[1]{%
7816 \ifthenelse{\equal{\@pseudocodespace}{keep}}
7817 {\highlightaltkeyword{#1}}%
7818 {\highlightaltkeyword{\@pc@stringsubstitution{#1}{ }{~}}}%
7819 }
7820 % \end{macrocode}
7821 %\end{macro}
7822 %\end{macro}
7823 %\end{macro}
7824 %\end{macro}
7825 %\end{macro}
7826 %\end{macro}
7827 %
7828 %
7829 % \subsubsection{Helper Variables}
7830 %
7831 %\begin{macro}{\@pc@thecontent}
7832 %\begin{macro}{\@pc@colspace}
7833 % Helper variables used within pseudocode
7834 % \begin{macrocode}
7835 \newcommand{\@pc@thecontent}{}
7836 \newcommand{\@pc@colspace}{}
7837 % \end{macrocode}
7838 %\end{macro}
7839 %\end{macro}
7840 %
7841 %
7842 %
7843 %
7844 %\begin{macro}{\@withinspaces}
7845 %\begin{macro}{\@keepspaces}
7846 % Helper variables for controlling automatic spacing
7847 % \begin{macrocode}
7848 \newcommand{\@withinspaces}{false}%
7849 \newcommand{\@keepspaces}{%
7850 \renewcommand{\@withinspaces}{true}\@pc@withspaces%
7851 }
7852 % \end{macrocode}
7853 %\end{macro}
7854 %\end{macro}
7855 %
7856 %
7857 % \begin{macrocode}
7858 \newcommand*\@pseudocodespace{}
7859 \define@key{pcspace}{space}[]{\ifthenelse{\equal{#1}{keep}}{\@keepspaces}{}\renewcommand*\@pseudocodespace{#1}}
7860
7861
7862 \newcommand*\@pc@defaultargs{}
7863 \newcommand*\pcsetargs[1]{\renewcommand*\@pc@defaultargs{#1}}
7864
7865 % automatic indentation
7866 \newcounter{@pc@indentationlevel}
7867 \newcommand{\@pc@increaseindent}{\addtocounter{@pc@indentationlevel}{1}}
7868 \newcommand{\@pc@decreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}\addtocounter{@pc@indentationlevel}{-1}}
7869 \newcommand{\@pc@tmpdecreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}}
7870
7871 \newcounter{pccolumncounter}
7872 \setcounter{pccolumncounter}{2}
7873
7874 % store original halign
7875 \let\@pc@halign\halign%
7876 % \end{macrocode}
7877 %
7878 % \subsubsection{The Actual Pseudocode Command}
7879 %
7880 % \begin{macrocode}
7881 % Check if the pseudocode command is called with an optional argument
7882 \providecommand{\pseudocode}{%
7883 \begingroup%
7884 \renewcommand{\@withinspaces}{false}%
7885 \@ifnextchar[%]
7886 {\@pseudocodeA}%
7887 {\@pseudocode[]}%
7888 }
7889
7890 \def\@pseudocodeA[#1]{%
7891 \setkeys*{pcspace}{#1}%test if there is a space assignment within the keys .. make the necessary arrangements and call the actual method
7892 \@pseudocode[#1]%
7893 }
7894
7895 \def\@pseudocode[#1]#2{%
7896 \begingroup%
7897 % reset skip marker before parsing options, as this might set it
7898 \@pc@resetskipln%
7899 % parse options
7900 % this is the same as %\setkeys{pseudocode}[space]{\@pc@defaultargs,#1}%ignore the space key.
7901 % expect that we expand the default args
7902 \@expandedsetkeys{pseudocode}{space}{head=}{\@pc@defaultargs}{#1}%
7903 % check draft mode and disable syntax highlighting
7904 \@pc@ifdraft{\ifthenelse{\equal{\@pseudocodenodraft}{true}}{}{\renewcommand\@pseudocodesyntaxhighlighting{}}}{}%
7905 %
7906 %
7907 \addtocounter{@pc@global@pc@nestcnt}{1}%
7908 % allow for tikz usage
7909 \@pc@ensureremember%
7910 %
7911 % create tabbing command
7912 \ifcsname \pctabname\endcsname%
7913 \expandafter\renewcommand\csname \pctabname\endcsname{\@pc@modeend&\@pc@colspace\@pc@modebegin}%
7914 \else%
7915 \expandafter\newcommand\csname \pctabname\endcsname{\@pc@modeend&\@pc@colspace\@pc@modebegin}%
7916 \fi%
7917 \ifcsname \pcdbltabname\endcsname%
7918 \expandafter\renewcommand\csname \pcdbltabname\endcsname{\@pc@modeend&&\@pc@colspace\@pc@modebegin}%
7919 \else%
7920 \expandafter\newcommand\csname \pcdbltabname\endcsname{\@pc@modeend&&\@pc@colspace\@pc@modebegin}%
7921 \fi%
7922 % create colspace command if necessary (must be empty for multicolumns
7923 \ifthenelse{\equal{\@pseudocodecolspace}{}}
7924 {}
7925 {\renewcommand{\@pc@colspace}{\hspace{\@pseudocodecolspace}}}%
7926 %
7927 %adjust row width
7928 \addtolength{\jot}{\@pseudocodecodejot}%
7929 % create indent command
7930 \expandafter\let\csname \pcindentname\endcsname\pcind%
7931 %
7932 %store and wrap (do syntax highlighting) argument
7933 \renewcommand{\@pc@thecontent}{\@pc@and@wrap@start\@pc@syntaxhighlight{#2}\@pc@and@wrap@end}%
7934 %
7935 %take care of counters
7936 \stepcounter{@pc@global@pc@cnt}%
7937 \setcounter{pclinenumber}{\@pseudocodelnstart}%
7938 \setcounter{pcrlinenumber}{\@pseudocodelnstartright}%
7939 \setlength{\@pc@minipage@length}{0pt}%
7940 \setlength{\@pc@alt@minipage@length}{0pt}%
7941 \setcounter{@pclinenumbertmp}{\value{pclinenumber}}%
7942 \setcounter{@pcrlinenumbertmp}{\value{pcrlinenumber}}%
7943 %reset column counter
7944 \setcounter{pccolumncounter}{2}%
7945 %
7946 % vertical space
7947 \vspace{\@pseudocodeyshift}%
7948 %
7949 %
7950 %
7951 % line magic
7952 \ifthenelse{\value{@pc@global@pc@nestcnt}=1}{%
7953 \let\@pc@halign\halign%
7954 \newenvironment{pcmbox}{\let\halign\@pc@halign}{}%
7955 \def\halign{%
7956 \renewcommand{\label}[1]{\ifmeasuring@\else\@pc@original@label{####1}\fi}%
7957 \let\@pc@lb\\%
7958 \renewcommandx*{\\}[2][1=,2=]{\@pc@modeend\@pc@and\@pseudocodecodeatendline \ifthenelse{\equal{####1}{}}{\@pc@lb}{\@pc@lb[####1]}####2 \@pc@beginnewline}%
7959 \def\pclb{\let\\\@pc@lb\relax\@pc@modeend\\}%
7960 \@pc@halign}%
7961 }{}%
7962 %
7963 %align column separation
7964 \renewcommand*{\minalignsep}{\@pseudocodecolsep}%
7965 %
7966 %as the following block will execute the pseudocode we need to store the skip command
7967 \edef\@pc@org@skiplnmarker{\@pc@skiplnmarker}%
7968 % if no width is set compute width and store in circuitlength
7969 \ifthenelse{\equal{\@pseudocodewidth}{}}{%
7970 % compute length of pseudocode
7971 \ifthenelse{\value{@pcsubprogstep}=0}{%
7972 \@pc@settowidthofalign{\@pc@minipage@length}{\@pc@thecontent}%
7973 }{%
7974 \@pc@settowidthofaligned{\@pc@minipage@length}{\@pc@thecontent}%
7975 }%
7976 %compute length of header
7977 \ifthenelse{\equal{\@withingame}{true}}%
7978 {\ifthenelse{\equal{\@pc@secondheader}{true}}%
7979 {\addtolength{\@pc@alt@minipage@length}{\widthof{x\ensuremath{\@pc@gametitle[1]\@pc@gametitle[1]}}}}
7980 {\addtolength{\@pc@alt@minipage@length}{\widthof{\ensuremath{\@pc@gametitle[1]}}}}}%
7981 {\addtolength{\@pc@alt@minipage@length}{\widthof{\@pseudocodehead}}}%
7982 % use header length if longer and add some points for good measure
7983 \ifdim\@pc@alt@minipage@length>\@pc@minipage@length%
7984 \setlength{\@pc@minipage@length}{\@pc@alt@minipage@length}%
7985 \fi%
7986 \addtolength{\@pc@minipage@length}{\@pseudocodeaddtolength}%
7987 }{\addtolength{\@pc@minipage@length}{\@pseudocodewidth}}%
7988 % reset counter and skip command
7989 \setcounter{pclinenumber}{\value{@pclinenumbertmp}}%
7990 \setcounter{pcrlinenumber}{\value{@pcrlinenumbertmp}}%
7991 \setcounter{@pc@indentationlevel}{0}%
7992 \edef\@pc@skiplnmarker{\@pc@org@skiplnmarker}%
7993 % begin actual output
7994 %
7995 %
7996 %do the actual mini page
7997 \hspace{\pcbeforeskip}\hspace{\@pseudocodexshift}%
7998 \ifthenelse{\equal{\@pseudocodeminipagealign}{t}}{%
7999 \raisebox{\dimexpr\ht\strutbox-\height}{\@pc@pseudocodeminipage{t}}%
8000 }{%
8001 \@pc@pseudocodeminipage{\@pseudocodeminipagealign}%
8002 }%
8003 \hspace{\pcafterskip}%
8004 % tikz usage
8005 \@pc@releaseremember%
8006 \addtocounter{@pc@global@pc@nestcnt}{-1}%
8007 \endgroup%
8008 % close spacing and potentially a single group generated by the space tester
8009 \ifthenelse{\equal{\@withinspaces}{true}}{\end@pc@withspaces}{}%
8010 \endgroup%
8011 %insert space from stacking
8012 \@pc@stackspace@forpseudocode%
8013 }
8014
8015 \newcommand{\@pc@pseudocodeminipage}[1]{%
8016 \begin{minipage}[#1]{\@pc@minipage@length}%
8017 \ifthenelse{\value{@pcsubprogstep}=0}{%
8018 \pc@display@pseudocode{\@pseudocodehead}{\@pc@thecontent}%
8019 }{% if sub procedure
8020 \pc@display@subcode{\@pseudocodehead}{\@pc@thecontent}%
8021 }%
8022 \end{minipage}%
8023 }
8024
8025
8026 \newcommand{\@pc@display@gameheader}[1]{%
8027 \tikz{\gdef\i{\thepcgamecounter}%
8028 \node[anchor=base,text depth=0pt, inner sep=0.05em,outer sep=0pt] (gamenode\i) {#1};
8029 \ifthenelse{\equal{\@withinbxgame}{true}}
8030 {\node[draw,anchor=base, above=2ex of gamenode\i] (bgamenode\i) {\@bxgameheader};}
8031 {}%
8032 }%
8033 }
8034
8035 \let\pclb\relax
8036 %
8037 \newcommand{\pc@display@pseudocode}[2]{%
8038 \ifthenelse{\equal{#1}{}}{\vspace{-\baselineskip}\@pseudocodecodesize{}}{%
8039 \ifthenelse{\equal{\@withingame}{true}}
8040 {\ifthenelse{\equal{\@pc@secondheader}{true}}
8041 {\@pc@display@gameheader{#1}\addtocounter{pcgamecounter}{1}\fboxsep=1pt\fbox{\vphantom{#1}\@pc@display@gameheader{#1}}}
8042 {\@pc@display@gameheader{#1}}}
8043 {#1}%
8044 \@pc@headheightskip\vspace{\pcheadlinesep}\vspace{\@pseudocodeheadlinesep}\@pseudocodeheadlinecmd%
8045 \vspace{-\baselineskip}\vspace{\pcbodylinesep}\vspace{\@pseudocodebodylinesep}\@pseudocodecodesize}%
8046 \begin{flalign*}#2\end{flalign*}%
8047 }
8048
8049
8050 \newcommand{\pc@display@subcode}[2]{%
8051 \begingroup%
8052 \ifthenelse{\equal{#1}{}}{}{#1\@pc@headheightskip%
8053 \vspace{\pcheadlinesep}\vspace{\@pseudocodeheadlinesep}\@pseudocodeheadlinecmd{}%
8054 \vspace{\pcbodylinesep}\vspace{\@pseudocodebodylinesep}}%
8055 \@pseudocodesubcodesize%
8056 $\begin{aligned}#2\end{aligned}$%
8057 \endgroup%
8058 }
8059
8060
8061 \newcommand{\@pc@gettikzwidth}[2]{ % #1 = width, #2 = height
8062 \pgfextractx{\@tempdima}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
8063 {\pgfpointanchor{current bounding box}{north east}}}
8064 \global#1=\@tempdima
8065 \pgfextracty{\@tempdima}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
8066 {\pgfpointanchor{current bounding box}{north east}}}
8067 \global#2=\@tempdima
8068 }
8069
8070
8071 % \end{macrocode}
8072 %
8073 % \subsection{Create Pseudocode/Procedure Commands}
8074 %
8075 % \begin{macrocode}
8076 %
8077 % parameter reordering
8078 \def\@pseudocodeB#1#2[#3]#4{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1#4},#2,#3]}
8079 \def\@pseudocodeC#1#2#3{\setkeys*{pcspace}{#2}\@pseudocode[head={#1#3},#2]}
8080 %for no headers
8081 \def\@pseudocodeE#1#2[#3]{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1},#2,#3]}
8082 \def\@pseudocodeF#1#2{\setkeys*{pcspace}{#2}\@pseudocode[head={#1},#2]}
8083 %
8084 % \end{macrocode}
8085 %
8086 %\begin{macro}{\createprocedurecommand}
8087 % Define pseudocode command with parameters:
8088 % \begin{enumerate}
8089 % \item name
8090 % \item code to execute after begingroup
8091 % \item head prefix
8092 % \item other config
8093 % \end{enumerate}
8094 % \begin{macrocode}
8095 \newcommand*{\@pc@createproc@headmode}{text}
8096 \newcommand{\createprocedurecommand}[4]{
8097 \expandafter\gdef\csname #1\endcsname{%
8098 \begingroup%
8099 \renewcommand{\@withinspaces}{false}%
8100 #2%
8101 \@ifnextchar[%]
8102 {\@pseudocodeB{#3}{#4}}
8103 {\@pseudocodeC{#3}{#4}}%
8104 }%
8105 }
8106 % \end{macrocode}
8107 %\end{macro}
8108 %
8109 %
8110 %
8111 %\begin{macro}{\createpseudocodecommand}
8112 % \begin{macrocode}
8113 \newcommand{\createpseudocodecommand}[4]{
8114 \expandafter\gdef\csname #1\endcsname{%
8115 \begingroup%
8116 \renewcommand{\@withinspaces}{false}%
8117 #2%
8118 \@ifnextchar[%]
8119 {\@pseudocodeE{#3}{#4}}
8120 {\@pseudocodeF{#3}{#4}}%
8121 }%
8122 }
8123 % \end{macrocode}
8124 %\end{macro}
8125 %
8126 %
8127 %
8128 %
8129 %
8130 %\begin{macro}{\createpseudocodeblock}
8131 % Creates a command that has pseudocode wrapped in an |\pchstack|.
8132 % \item name
8133 % \item options for |\pchstack|
8134 % \item code to execute after begingroup
8135 % \item head prefix
8136 % \item other config
8137 % \begin{macrocode}
8138 \newcommand{\createpseudocodeblock}[5]{
8139 \createpseudocodecommand{#1@pc}{#3}{#4}{#5}
8140 \expandafter\gdef\csname #1\endcsname{%
8141 \@ifnextchar[%]
8142 {\csname #1@@\endcsname}
8143 {\csname #1@\endcsname}
8144 }%
8145 \expandafter\gdef\csname #1@\endcsname##1{%
8146 \begin{pchstack}[#2]
8147 \csname #1@pc\endcsname{##1}
8148 \end{pchstack}
8149 }
8150 \expandafter\gdef\csname #1@@\endcsname[##1]##2{%
8151 \begin{pchstack}[#2]
8152 \csname #1@pc\endcsname[##1]{##2}
8153 \end{pchstack}
8154 }
8155 }
8156 % \end{macrocode}
8157 %\end{macro}
8158 %
8159 %
8160 %
8161 %\begin{macro}{\createprocedureblock}
8162 % Creates a command that has procedure wrapped in an |\pchstack|.
8163 % \item name
8164 % \item options for |\pchstack|
8165 % \item code to execute after begingroup
8166 % \item head prefix
8167 % \item other config
8168 % \begin{macrocode}
8169 \newcommand{\createprocedureblock}[5]{
8170 \createprocedurecommand{#1@pc}{#3}{#4}{#5}
8171 \expandafter\gdef\csname #1\endcsname{%
8172 \@ifnextchar[%]
8173 {\csname #1@@\endcsname}
8174 {\csname #1@\endcsname}
8175 }%
8176 \expandafter\gdef\csname #1@\endcsname##1##2{%
8177 \begin{pchstack}[#2]
8178 \csname #1@pc\endcsname{##1}{##2}
8179 \end{pchstack}
8180 }
8181 \expandafter\gdef\csname #1@@\endcsname[##1]##2##3{%
8182 \begin{pchstack}[#2]
8183 \csname #1@pc\endcsname[##1]{##2}{##3}
8184 \end{pchstack}
8185 }
8186 }
8187 % \end{macrocode}
8188 %\end{macro}
8189 %
8190 %
8191 %
8192 %\begin{macro}{\procedure}
8193 %\begin{macro}{\pseudocodeblock}
8194 %\begin{macro}{\procedureblock}
8195 % Create |\procedure| command.
8196 % \begin{macrocode}
8197 \createprocedurecommand{procedure}{}{}{}
8198 \createpseudocodeblock{pseudocodeblock}{center}{}{}{}
8199 \createprocedureblock{procedureblock}{center}{}{}{}
8200 % \end{macrocode}
8201 %\end{macro}
8202 %\end{macro}
8203 %\end{macro}
8204 %
8205 %
8206 %
8207 % \subsection{Subprocedures}
8208 %
8209 % \begin{macrocode}
8210
8211 %
8212 % subprocedures
8213 \newcounter{@pcsubprogcnt1}
8214 \newcounter{@pcrsubprogcnt1}
8215 \newcounter{@pcsubprogcnt2}
8216 \newcounter{@pcrsubprogcnt2}
8217 \newcounter{@pcsubprogcnt3}
8218 \newcounter{@pcrsubprogcnt3}
8219 \newcounter{@pcsubprogcnt4}
8220 \newcounter{@pcrsubprogcnt4}
8221 \newcounter{@pcsubprogcnt5}
8222 \newcounter{@pcrsubprogcnt5}
8223 \newcounter{@pcsubprogcnt6}
8224 \newcounter{@pcrsubprogcnt6}
8225 \newcounter{@pcsubprogcnt7}
8226 \newcounter{@pcrsubprogcnt7}
8227 \newcounter{@pcsubprogcnt8}
8228 \newcounter{@pcrsubprogcnt8}
8229 \newcounter{@pcsubprogcnt9}
8230 \newcounter{@pcrsubprogcnt9}
8231 \newcounter{@pcsubprogstep}
8232
8233 \newenvironment{subprocedure}{%
8234 \addtocounter{@pcsubprogstep}{1}%
8235 % store old counter values
8236 \setcounter{@pcsubprogcnt\the@pcsubprogstep}{\value{pclinenumber}}%
8237 \setcounter{@pcrsubprogcnt\the@pcsubprogstep}{\value{pcrlinenumber}}%
8238 }{%
8239 \setcounter{pclinenumber}{\value{@pcsubprogcnt\the@pcsubprogstep}}%
8240 \setcounter{pcrlinenumber}{\value{@pcrsubprogcnt\the@pcsubprogstep}}%
8241 \addtocounter{@pcsubprogstep}{-1}}
8242
8243
8244 % \end{macrocode}
8245 %
8246 % \subsection{Protocols}
8247 %
8248 % \begin{macrocode}
8249
8250 %
8251 % send message
8252 \newcommand{\pcshortmessageoffset}{0.5cm}
8253 \newcommand{\pcdefaultmessagelength}{3.5cm}
8254 \newcommand{\pcdefaultlongmessagelength}{6cm}
8255 \newcommand{\pcbeforemessageskip}{0pt}
8256 \newcommand{\pcaftermessageskip}{10pt}
8257 \newlength{\pcmessagearrow}
8258
8259 \newcommand*\@pcsendmessagelength{\pcdefaultmessagelength}
8260 \newcommand*\@pcsendmessagecol{}
8261 \newcommand*\@pcsendmessagewidth{}
8262 \newcommand*\@pcsendmessagestyle{}
8263 \newcommand*\@pcsendmessagetop{}
8264 \newcommand*\@pcsendmessagebottom{}
8265 \newcommand*\@pcsendmessageright{}
8266 \newcommand*\@pcsendmessageleft{}
8267 \newcommand*\@pcsendmessagetopname{t}
8268 \newcommand*\@pcsendmessagebottomname{b}
8269 \newcommand*\@pcsendmessagerightname{r}
8270 \newcommand*\@pcsendmessageleftname{l}
8271 \newcommand*\@pcsendmessagetopstyle{}
8272 \newcommand*\@pcsendmessagebottomstyle{}
8273 \newcommand*\@pcsendmessagerightstyle{}
8274 \newcommand*\@pcsendmessageleftstyle{}
8275 \newcommand*\@pcsendmessagebeforeskip{\pcbeforemessageskip}
8276 \newcommand*\@pcsendmessageafterskip{\pcaftermessageskip}
8277
8278 \define@key{pcsendmessage}{centercol}[]{\renewcommand*\@pcsendmessagecol{#1}}
8279 \define@key{pcsendmessage}{width}[]{\renewcommand*\@pcsendmessagewidth{#1}}
8280 \define@key{pcsendmessage}{style}[]{\renewcommand*\@pcsendmessagestyle{#1}}
8281 \define@key{pcsendmessage}{length}[]{\renewcommand*\@pcsendmessagelength{#1}}
8282 \define@key{pcsendmessage}{top}[]{\renewcommand*\@pcsendmessagetop{#1}}
8283 \define@key{pcsendmessage}{bottom}[]{\renewcommand*\@pcsendmessagebottom{#1}}
8284 \define@key{pcsendmessage}{right}[]{\renewcommand*\@pcsendmessageright{#1}}
8285 \define@key{pcsendmessage}{left}[]{\renewcommand*\@pcsendmessageleft{#1}}
8286 \define@key{pcsendmessage}{topname}[]{\renewcommand*\@pcsendmessagetopname{#1}}
8287 \define@key{pcsendmessage}{bottomname}[]{\renewcommand*\@pcsendmessagebottomname{#1}}
8288 \define@key{pcsendmessage}{rightname}[]{\renewcommand*\@pcsendmessagerightname{#1}}
8289 \define@key{pcsendmessage}{leftname}[]{\renewcommand*\@pcsendmessageleftname{#1}}
8290 \define@key{pcsendmessage}{topstyle}[]{\renewcommand*\@pcsendmessagetopstyle{#1}}
8291 \define@key{pcsendmessage}{bottomstyle}[]{\renewcommand*\@pcsendmessagebottomstyle{#1}}
8292 \define@key{pcsendmessage}{rightstyle}[]{\renewcommand*\@pcsendmessagerightstyle{#1}}
8293 \define@key{pcsendmessage}{leftstyle}[]{\renewcommand*\@pcsendmessageleftstyle{#1}}
8294 \define@key{pcsendmessage}{beforeskip}[]{\renewcommand*\@pcsendmessagebeforeskip{#1}}
8295 \define@key{pcsendmessage}{afterskip}[]{\renewcommand*\@pcsendmessageafterskip{#1}}
8296
8297 \newcommand*\@pcsendmessagealignedtop{false}
8298 \define@key{pcsendmessage}{topaligned}[true]{\renewcommand*\@pcsendmessagealignedtop{#1}}
8299 \newcommand*\@pcsendmessagealignedbottom{false}
8300 \define@key{pcsendmessage}{bottomaligned}[true]{\renewcommand*\@pcsendmessagealignedbottom{#1}}
8301 \newcommand*\@pcsendmessagealignedleft{false}
8302 \define@key{pcsendmessage}{leftaligned}[true]{\renewcommand*\@pcsendmessagealignedleft{#1}}
8303 \newcommand*\@pcsendmessagealignedright{false}
8304 \define@key{pcsendmessage}{rightaligned}[true]{\renewcommand*\@pcsendmessagealignedright{#1}}
8305
8306
8307 \newcommand{\@pc@centerincol}[2]{%
8308 \ifmeasuring@%
8309 #2%
8310 \else%
8311 \makebox[\ifcase\expandafter #1\maxcolumn@widths\fi]{$\displaystyle#2$}%
8312 \fi%
8313 }
8314
8315 \newcommand{\centerincol}[1]{\@pc@centerincol{\thepccolumncounter}{#1}}
8316
8317 \newcommand{\@do@sendmessage}[1]{%
8318 \ifthenelse{\equal{\@pcsendmessagecol}{}}{%
8319 \ifthenelse{\equal{\@pcsendmessagewidth}{}}{#1}{% we have some width
8320 \makebox[\@pcsendmessagewidth]{$\displaystyle#1$}%
8321 }}{%we know the column to center on
8322 \@pc@centerincol{\@pcsendmessagecol}{#1}%
8323 }%
8324 }
8325
8326 \newcommand*{\sendmessage}[2]{%
8327 \begingroup\setkeys{pcsendmessage}{#2}%
8328 \tikzset{PCSENDMSG-PATH-STYLE/.style/.expand once=\@pcsendmessagestyle}%
8329 \tikzset{PCSENDMSG-TOP-STYLE/.style/.expand once=\@pcsendmessagetopstyle}%
8330 \tikzset{PCSENDMSG-BOTTOM-STYLE/.style/.expand once=\@pcsendmessagebottomstyle}%
8331 \tikzset{PCSENDMSG-LEFT-STYLE/.style/.expand once=\@pcsendmessageleftstyle}%
8332 \tikzset{PCSENDMSG-RIGHT-STYLE/.style/.expand once=\@pcsendmessagerightstyle}%
8333 %
8334 %
8335 \ifthenelse{\equal{\@pcsendmessagealignedtop}{true}}
8336 {\ifthenelse{\equal{\@pcsendmessagetop}{}}
8337 {\let\@pc@fin@sendmessagetop\@pcsendmessagetop}%
8338 {\newcommand{\@pc@fin@sendmessagetop}{\let\halign\@pc@halign$\begin{aligned}\@pcsendmessagetop\end{aligned}$}}}
8339 {\let\@pc@fin@sendmessagetop\@pcsendmessagetop}%
8340 %
8341 \ifthenelse{\equal{\@pcsendmessagealignedbottom}{true}}
8342 {\ifthenelse{\equal{\@pcsendmessagebottom}{}}
8343 {\let\@pc@fin@sendmessagebottom\@pcsendmessagebottom}%
8344 {\newcommand{\@pc@fin@sendmessagebottom}{\let\halign\@pc@halign$\begin{aligned}\@pcsendmessagebottom\end{aligned}$}}}
8345 {\let\@pc@fin@sendmessagebottom\@pcsendmessagebottom}%
8346 %
8347 \ifthenelse{\equal{\@pcsendmessagealignedright}{true}}
8348 {\ifthenelse{\equal{\@pcsendmessageright}{}}
8349 {\let\@pc@fin@sendmessageright\@pcsendmessageright}
8350 {\newcommand{\@pc@finsendmessageright}{\let\halign\@pc@halign$\begin{aligned}\@pcsendmessageright\end{aligned}$}}}
8351 {\let\@pc@fin@sendmessageright\@pcsendmessageright}%
8352 %
8353 \ifthenelse{\equal{\@pcsendmessagealignedleft}{true}}
8354 {\ifthenelse{\equal{\@pcsendmessageleft}{}}
8355 {\let\@pc@fin@sendmessageleft\@pcsendmessageleft}
8356 {\newcommand{\@pc@fin@sendmessageleft}{\let\halign\@pc@halign$\begin{aligned}\@pcsendmessageleft\end{aligned}$}}}
8357 {\let\@pc@fin@sendmessageleft\@pcsendmessageleft}%
8358 %restore halign
8359 %
8360 \addtocounter{@pcsubprogstep}{1}%
8361 \hspace{\@pcsendmessagebeforeskip}%
8362 \begin{varwidth}{\linewidth}
8363 \@do@sendmessage{
8364 \begin{tikzpicture}%
8365 \node[PCSENDMSG-LEFT-STYLE] (\@pcsendmessageleftname) {\@pc@fin@sendmessageleft};
8366 \node[right=\@pcsendmessagelength of \@pcsendmessageleftname,PCSENDMSG-RIGHT-STYLE] (\@pcsendmessagerightname) {\@pc@fin@sendmessageright};
8367 \path[#1,PCSENDMSG-PATH-STYLE] (\@pcsendmessageleftname) edge[] node[above,PCSENDMSG-TOP-STYLE] (\@pcsendmessagetopname) {\@pc@fin@sendmessagetop} node[below,PCSENDMSG-BOTTOM-STYLE] (\@pcsendmessagebottomname) {\@pc@fin@sendmessagebottom} (\@pcsendmessagerightname);
8368 \end{tikzpicture}%
8369 }%
8370 \end{varwidth}
8371 \addtocounter{@pcsubprogstep}{-1}%
8372 \hspace{\@pcsendmessageafterskip}%
8373 \endgroup%
8374 }
8375
8376 \WithSuffix\newcommand\sendmessage*[2]{%
8377 \sendmessage{#1}{topaligned,leftaligned,bottomaligned,rightaligned,#2}%
8378 }
8379
8380 \newcommandx*{\sendmessageright}[2][1=->]{%
8381 \sendmessage{#1}{#2}%
8382 }
8383
8384 \newcommandx*{\sendmessageleft}[2][1=<-]{%
8385 \sendmessage{#1}{#2}%
8386 }
8387
8388 \WithSuffix\newcommand\sendmessageleft*[2][\pcdefaultmessagelength]{%
8389 \begingroup%
8390 \renewcommand{\@pcsendmessagetop}{\let\halign\@pc@halign$\begin{aligned}#2\end{aligned}$}%
8391 \sendmessage{<-}{length=#1}%
8392 \endgroup%
8393 }
8394
8395
8396 \WithSuffix\newcommand\sendmessageright*[2][\pcdefaultmessagelength]{%
8397 \begingroup%
8398 \renewcommand{\@pcsendmessagetop}{\let\halign\@pc@halign$\begin{aligned}#2\end{aligned}$}%
8399 \sendmessage{->}{length=#1}%
8400 \endgroup%
8401 }
8402
8403 \WithSuffix\newcommand\sendmessagerightleft*[2][\pcdefaultmessagelength]{%
8404 \begingroup%
8405 \renewcommand{\@pcsendmessagetop}{\let\halign\@pc@halign$\begin{aligned}#2\end{aligned}$}%
8406 \sendmessage{<->}{length=#1}%
8407 \endgroup%
8408 }
8409
8410 \DeclareExpandableDocumentCommand{\sendmessagerightx}{O{\pcdefaultlongmessagelength}mO{}m}{%
8411 \multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xrightarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
8412 }
8413
8414 \DeclareExpandableDocumentCommand{\sendmessageleftx}{O{\pcdefaultlongmessagelength}mO{}m}{%
8415 \multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xleftarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
8416 }
8417
8418 %
8419 % Division
8420 \DeclareExpandableDocumentCommand{\pcintertext}{O{}m}{\intertext{%
8421 \ifthenelse{\equal{#1}{center}}{\makebox[\linewidth][c]{#2}}{}%
8422 \ifthenelse{\equal{#1}{dotted}}{\dotfill#2\dotfill}{}%
8423 \ifthenelse{\equal{#1}{}}{#2}{}%
8424 }\@pc@beginnewline}
8425
8426
8427
8428 % \end{macrocode}
8429 %
8430 % \subsection{Tikz within Pseudocode}
8431 %
8432 % \begin{macrocode}
8433
8434 %
8435 % remember pictues
8436 \newcounter{@pc@remember}
8437
8438 \newcommand{\@pc@ensureremember}{%
8439 \ifthenelse{\value{@pc@remember}=0}{\tikzstyle{every picture}+=[remember picture]}{}%
8440 \addtocounter{@pc@remember}{1}}
8441
8442 \newcommand{\@pc@releaseremember}{%
8443 \addtocounter{@pc@remember}{-1}%
8444 \ifthenelse{\value{@pc@remember}=0}{\tikzstyle{every picture}-=[remember picture]}{}%
8445 }
8446
8447
8448 %
8449 % pcimage
8450 \newenvironment{pcimage}{%
8451 \begingroup\@pc@ensureremember%
8452 }{%
8453 \@pc@releaseremember\endgroup%
8454 }
8455
8456 \newcommand*\@pcnodecontent{}
8457 \newcommand*\@pcnodestyle{}
8458 \newcommand*\@pcnodedraw{}
8459 \define@key{pcnode}{content}[]{\renewcommand*\@pcnodecontent{#1}}
8460 \define@key{pcnode}{style}[]{\renewcommand*\@pcnodestyle{#1}}
8461 \define@key{pcnode}{draw}[]{\renewcommand*\@pcnodedraw{#1}}
8462
8463 \newcommandx*{\pcnode}[2][2=]{%
8464 \begingroup\setkeys{pcnode}{#2}%
8465 \tikzset{PCNODE-STYLE/.style/.expand once=\@pcnodestyle}%
8466 \begin{tikzpicture}[inner sep=0ex,baseline=0pt]%
8467 \node[PCNODE-STYLE] (#1) {\@pcnodecontent}; %
8468 \end{tikzpicture}%
8469 \ifdefempty{\@pcnodedraw}{}{%
8470 \begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt]\@pcnodedraw\end{tikzpicture}
8471 }%
8472 \endgroup}
8473
8474 \newcommandx*{\pcdraw}[2][2=]{%
8475 \begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#2]
8476 #1
8477 \end{tikzpicture}}
8478
8479 % \end{macrocode}
8480 %
8481 % \subsection{Black Box Reductions}
8482 %
8483 % \begin{macrocode}
8484
8485 %
8486 % Reductions
8487 \newcommand{\@bb@lastbox}{}
8488 \newcommand{\@bb@lastoracle}{}
8489 \newcommand{\@bb@lastchallenger}{}
8490
8491 \newlength{\@bb@message@voffset}
8492 \newlength{\@bb@query@voffset}
8493 \newlength{\@bb@oraclequery@voffset}
8494 \newlength{\@bb@challengerquery@voffset}
8495
8496 \newcounter{@bb@oracle@cnt}
8497 \newcounter{@bb@oracle@nestcnt}
8498 \newcounter{@bb@challenger@cnt}
8499 \newcounter{@bb@challenger@nestcnt}
8500
8501 \newcounter{@bb@env@nestcnt}
8502
8503 \newcommand{\bbroraclenodenameprefix}{ora-}
8504 \newcommand{\bbrchallengernodenameprefix}{challenger-}
8505 \newcommand{\bbrenvnodenameprefix}{env-}
8506 % \end{macrocode}
8507
8508
8509
8510 %\begin{macro}{aboveskip}
8511 %\begin{macro}{\@pc@bbrenvaboveskip}
8512 % \begin{macrocode}
8513 \newcommand*\@pc@bbrenvaboveskip{0pt}
8514 \define@key{pcbbrenv}{aboveskip}[0pt]{\renewcommand*\@pc@bbrenvaboveskip{#1}}
8515 % \end{macrocode}
8516 %\end{macro}
8517 %\end{macro}
8518 %
8519 %
8520 %\begin{macro}{belowskip}
8521 %\begin{macro}{\@pc@bbrenvbelowskip}
8522 % \begin{macrocode}
8523 \newcommand*\@pc@bbrenvbelowskip{0pt}
8524 \define@key{pcbbrenv}{belowskip}[0pt]{\renewcommand*\@pc@bbrenvbelowskip{#1}}
8525 % \end{macrocode}
8526 %\end{macro}
8527 %\end{macro}
8528
8529 %\begin{macro}{\@pc@bbrenv@legacyargcheck}
8530 %\begin{macro}{\@pc@bbrenv@argstring}
8531 % ensures that first command can still be 5cm which is rewritten as aboveskip=5cm
8532 % \begin{macrocode}
8533 \newcommand*\@pc@bbrenv@argstring{}
8534 \def\@pc@bbrenv@remfinalequals#1=#2=\relax{\renewcommand*\@pc@bbrenv@argstring{#1=#2}}
8535 \def\@pc@bbrenv@legacyargcheck#1=#2\relax{%
8536 \ifthenelse{\equal{#2}{}}
8537 {\PackageWarning{cryptocode}{Deprecated option for bbrenv. Please use key value list as first parameter with keys aboveskip and/or belowskip.}%
8538 \renewcommand*\@pc@bbrenv@argstring{aboveskip=#1}}
8539 {\@pc@bbrenv@remfinalequals#1=#2\relax}%
8540 }
8541 % \end{macrocode}
8542 %\end{macro}
8543 %\end{macro}
8544 %
8545 %\begin{macro}{\bbrfirstmessageoffset}
8546 % offset of the first message from top
8547 % \begin{macrocode}
8548 \providecommand{\bbrfirstmessageoffset}{1ex}
8549 % \end{macrocode}
8550 %\end{macro}
8551 %
8552 %
8553 %\begin{macro}{tikzargs}
8554 %\begin{macro}{\bbrtikzargs}
8555 % Allow passing in arguments to |tikzpicture|.
8556 % \begin{macrocode}
8557 \newcommand*\bbrtikzargs{}
8558 \define@key{pcbbrenv}{tikzargs}[]{\renewcommand*\bbrtikzargs{#1}}
8559 % \end{macrocode}
8560 %\end{macro}
8561 %\end{macro}
8562 %
8563 %
8564 %\begin{environment}{bbrenv}
8565 % \changes{v0.41}{2020/07/13}{Fixed horizontal spacing behind bbrenv blocks.}
8566 % \changes{v0.41}{2020/07/13}{Added tikzargs key to pass in arguments to surrounding tikzpicture.}
8567 % Black Box Reduction Environment
8568 % \begin{macrocode}
8569 \newenvironmentx{bbrenv}[3][1={aboveskip=0pt,belowskip=0pt},3=0pt]{%
8570 \addtocounter{@bb@env@nestcnt}{1}%
8571 \renewcommand{\@bb@lastbox}{#2}%
8572 % parse args and allow old style #1=0pt
8573 \@pc@bbrenv@legacyargcheck#1=\relax%
8574 \@expandedsetkeys{pcbbrenv}{}{belowskip=#3}{\@pc@bbrenv@argstring}{}%
8575 %
8576 % reset lengths
8577 \@pc@globalsetlength{\@bb@message@voffset}{\bbrfirstmessageoffset}%
8578 \@pc@globalsetlength{\@bb@query@voffset}{\bbrfirstmessageoffset}%
8579 \@pc@globalsetlength{\@bb@oraclequery@voffset}{\bbrfirstmessageoffset}%
8580 \@pc@globalsetlength{\@bb@challengerquery@voffset}{\bbrfirstmessageoffset}%
8581 %
8582 %reset oracle counter and oracle query offset
8583 \ifthenelse{\value{@bb@oracle@nestcnt}=0}
8584 {\setcounter{@bb@oracle@cnt}{0}}{}%
8585 \ifthenelse{\value{@bb@challenger@nestcnt}=0}
8586 {\setcounter{@bb@challenger@cnt}{0}}{}%
8587 %
8588 \vspace{\@pc@bbrenvaboveskip}%
8589 \ifthenelse{\value{@bb@env@nestcnt}=1}
8590 {\@pc@ensureremember%
8591 \begin{tikzpicture}[baseline=0pt,\bbrtikzargs]
8592 }{\tikz\bgroup}
8593 }{%
8594 \ifthenelse{\value{@bb@env@nestcnt}=1}
8595 {\end{tikzpicture}%
8596 \@pc@releaseremember%
8597 }{\egroup}%
8598 \vspace{\@pc@bbrenvbelowskip}%
8599 \addtocounter{@bb@env@nestcnt}{-1}%
8600 % reset lengths
8601 \@pc@globalsetlength{\@bb@message@voffset}{\bbrfirstmessageoffset}%
8602 \@pc@globalsetlength{\@bb@query@voffset}{\bbrfirstmessageoffset}%
8603 \@pc@globalsetlength{\@bb@oraclequery@voffset}{\bbrfirstmessageoffset}%
8604 \@pc@globalsetlength{\@bb@challengerquery@voffset}{\bbrfirstmessageoffset}%
8605 }
8606 % \end{macrocode}
8607 %\end{environment}
8608
8609 %
8610 %
8611
8612 %
8613 % black box reduction box
8614 % option keys
8615 % \begin{macrocode}
8616 \newcommand*\bbrboxname{}
8617 \newcommand*\bbrboxnamepos{right}
8618 \newcommand*\bbrboxnamestyle{}
8619 \newcommand*\@bbrboxnamepos{below right=0.5ex and -0.5ex of \@[email protected] east,anchor=north east}
8620 \newcommand*\bbrboxabovesep{\baselineskip}
8621 \newcommand*\@bbrboxnameposoffset{below left=\bbrboxabovesep of phantomname.south west}
8622 \newcommand*\bbrboxstyle{draw}
8623 \newcommand*\bbrboxafterskip{}
8624 \newcommand*\bbrboxminheight{0pt}
8625 \newcommand*\bbrboxminwidth{2cm}
8626 \newcommand*\bbrboxxshift{0pt}
8627 \newcommand*\bbrboxyshift{0pt}
8628 \define@key{bbrbox}{abovesep}[]{\renewcommand*\bbrboxabovesep{#1}}
8629 \define@key{bbrbox}{name}[]{\renewcommand*\bbrboxname{#1}}
8630 \define@key{bbrbox}{namestyle}[]{\renewcommand*\bbrboxnamestyle{#1}}
8631 \define@key{bbrbox}{namepos}[]{\renewcommand*\bbrboxnamepos{#1}}
8632 \define@key{bbrbox}{style}[draw]{\renewcommand*\bbrboxstyle{#1}}
8633 \define@key{bbrbox}{minwidth}[]{\renewcommand*\bbrboxminwidth{#1}}
8634 \define@key{bbrbox}{addheight}[]{\renewcommand*\bbrboxafterskip{#1}}
8635 \define@key{bbrbox}{minheight}[]{\renewcommand*\bbrboxminheight{#1}}
8636 \define@key{bbrbox}{xshift}[]{\renewcommand*\bbrboxxshift{#1}}
8637 \define@key{bbrbox}{yshift}[]{\renewcommand*\bbrboxyshift{#1}}
8638
8639
8640 \NewEnviron{bbrbox}[1][]{%
8641 \setkeys{bbrbox}{#1}%
8642
8643 \ifthenelse{\equal{\bbrboxnamepos}{center}}
8644 {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@[email protected],anchor=north}}{}
8645 \ifthenelse{\equal{\bbrboxnamepos}{left}}
8646 {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@[email protected] west,anchor=north west}}{}
8647 \ifthenelse{\equal{\bbrboxnamepos}{top right}}
8648 {\renewcommand{\@bbrboxnamepos}{above=0cm of \@[email protected] east,anchor=south east}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{}
8649 \ifthenelse{\equal{\bbrboxnamepos}{top center}}
8650 {\renewcommand{\@bbrboxnamepos}{above=0cm of \@[email protected],anchor=south}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{}
8651 \ifthenelse{\equal{\bbrboxnamepos}{top left}}
8652 {\renewcommand{\@bbrboxnamepos}{above=0cm of \@[email protected] west,anchor=south west}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{}
8653 \ifthenelse{\equal{\bbrboxnamepos}{middle}}
8654 {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@[email protected],anchor=south}}{}
8655 \ifthenelse{\equal{\bbrboxnamepos}{bottom}}
8656 {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@[email protected],anchor=north}}{}
8657
8658
8659 \tikzset{BBRBOXSTYLE/.style/.expand once=\bbrboxstyle}%
8660 \tikzset{BBRBOXNAMEPOS/.style/.expand once=\@bbrboxnamepos}%
8661 \tikzset{BBRBOXNAMESTYLE/.style/.expand once=\bbrboxnamestyle}%
8662 \tikzset{BBRBOXNAMEPOSOFFSET/.style/.expand once=\@bbrboxnameposoffset}%
8663
8664 \ifthenelse{\equal{\bbrboxxshift}{} \OR \equal{\bbrboxxshift}{0pt}}{
8665 \coordinate[inner sep=0pt,outer sep=0pt] (\@bb@lastbox-tmpouter) {};
8666 }{
8667 \node[inner sep=0pt, outer sep=0pt] (\@bb@lastbox-tmpouter) {}; %this empty node seems needed to get the xyshift right.
8668 }
8669
8670 \node[inner sep=.3333em,anchor=north,BBRBOXSTYLE,minimum height=\bbrboxminheight,below right=\bbrboxyshift and \bbrboxxshift of \@bb@lastbox-tmpouter] (\@bb@lastbox) \bgroup
8671 \tikz{
8672 \node[inner sep=0pt,outer sep=0pt,minimum height=0cm] (phantomname) {}; %minimum width
8673 \node[BBRBOXNAMEPOSOFFSET,minimum height=0cm] (\@bb@lastbox-inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}};
8674 \ifthenelse{\equal{\bbrboxafterskip}{}}{}{
8675 \node[below=0cm of \@bb@lastbox-inner,minimum height=\bbrboxafterskip] {};
8676 }
8677 \node[inner sep=0pt,outer sep=0pt,at=(\@[email protected] west),minimum height=0cm] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width
8678 }
8679 \egroup;
8680 \ifthenelse{\equal{\bbrboxnamepos}{none}}
8681 {}{\node[BBRBOXNAMEPOS,BBRBOXNAMESTYLE, inner sep=0.2ex, outer sep=0pt, overlay] () {\bbrboxname};}
8682 }
8683
8684
8685 \newcommand*\bbroraclevdistance{\baselineskip}
8686 \newcommand*\bbroraclehdistance{1.5cm}
8687 \define@key{bbroracle}{distance}[]{\renewcommand*\bbroraclehdistance{#1}}
8688 \define@key{bbroracle}{hdistance}[]{\renewcommand*\bbroraclehdistance{#1}}
8689 \define@key{bbroracle}{vdistance}[]{\renewcommand*\bbroraclevdistance{#1}}
8690
8691
8692 % ORACLES
8693 \newenvironmentx{bbroracle}[2][2=]{%
8694 \begingroup
8695 \setkeys{bbroracle}{#2}
8696 %reset query boolean. This is a bit crude and does not allow nesting oracles
8697 %in oracles but should be good enough
8698 \gdef\@bbr@first@oraclequery{true}
8699 %add to nesting cout
8700 \addtocounter{@bb@oracle@nestcnt}{1}
8701 %if first oracle, then put it to the right, else stack them vertically
8702 \addtocounter{@bb@oracle@cnt}{1}
8703 \ifthenelse{\value{@bb@oracle@cnt}=1}{
8704 \setlength{\@bb@tmplength@b}{\bbroraclevdistance-\baselineskip}
8705 \node[inner sep=0pt,below right=\@bb@tmplength@b and \bbroraclehdistance of \@[email protected] east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
8706 }{
8707 % compute distance of top of last box to bottom of last oracle
8708 \coordinate (@bbtmpcoord) at (\@[email protected] east);
8709 \path (@bbtmpcoord);
8710 \pgfgetlastxy{\XCoord}{\YCoordA}
8711 \coordinate (@bbtmpcoord) at (\bbroraclenodenameprefix \@[email protected] west);
8712 \path (@bbtmpcoord);
8713 \pgfgetlastxy{\XCoord}{\YCoordB}
8714 \setlength{\@bb@tmplength@b}{\YCoordA-\YCoordB+\bbroraclevdistance}
8715 \node[inner sep=0pt,below right=\@bb@tmplength@b and \bbroraclehdistance of \@[email protected] east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
8716 }
8717 \global\def\@bb@lastoracle{#1}
8718 \begin{bbrenv}{#1}
8719 }{
8720 \end{bbrenv}
8721 \egroup;
8722
8723 \addtocounter{@bb@oracle@nestcnt}{-1}
8724 \endgroup
8725 }
8726
8727
8728 \newcommand*\bbrchallengerhdistance{1.5cm}
8729 \newcommand*\bbrchallengervdistance{\baselineskip}
8730 \define@key{bbrchallenger}{distance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
8731 \define@key{bbrchallenger}{hdistance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
8732 \define@key{bbrchallenger}{vdistance}[]{\renewcommand*\bbrchallengervdistance{#1}}
8733
8734
8735 % Challenger
8736 \newenvironmentx{bbrchallenger}[2][2=]{%
8737 \begingroup%
8738 \setkeys{bbrchallenger}{#2}%
8739 %reset query boolean. This is a bit crude and does not allow nesting oracles
8740 %in oracles but should be good enough
8741 \gdef\@bbr@first@challengerquery{true}%
8742 %add to nesting cout
8743 \addtocounter{@bb@challenger@nestcnt}{1}%
8744 %if first oracle, then put it to the right, else stack them vertically
8745 \addtocounter{@bb@challenger@cnt}{1}%
8746 \ifthenelse{\value{@bb@challenger@cnt}=1}{%
8747 \setlength{\@bb@tmplength@b}{\bbrchallengervdistance-\baselineskip}%
8748 \node[inner sep=0pt,outer sep=0pt,below left=\@bb@tmplength@b and \bbrchallengerhdistance of \@[email protected] west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
8749 }{%
8750 \coordinate (@bbtmpcoord) at (\@[email protected] west);%
8751 \path (@bbtmpcoord);%
8752 \pgfgetlastxy{\XCoord}{\YCoordA}%
8753 \coordinate (@bbtmpcoord) at (\bbrchallengernodenameprefix \@[email protected] east);%
8754 \path (@bbtmpcoord);%
8755 \pgfgetlastxy{\XCoord}{\YCoordB}%
8756 \setlength{\@bb@tmplength@b}{\YCoordA-\YCoordB+\bbrchallengervdistance}%
8757 \node[inner sep=0pt,below left=\@bb@tmplength@b and \bbrchallengerhdistance of \@[email protected] west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
8758 }%
8759 \global\def\@bb@lastchallenger{#1}
8760 \begin{bbrenv}{#1}%
8761 }{
8762 \end{bbrenv}%
8763 \egroup;%
8764 \addtocounter{@bb@challenger@nestcnt}{-1}%
8765 \endgroup%
8766 \let\msgfrom\bbrchallengerqueryto%
8767 }
8768
8769
8770 \newcommand*\bbrinputlength{0.5cm}
8771 \newcommand*\bbrinputhoffset{0.5cm}
8772 \newcommand*\bbrinputbottom{}
8773 \newcommand*\bbrinputtop{}
8774 \newcommand*\bbrinputedgestyle{}
8775 \newcommand*\bbrinputtopstyle{}
8776 \newcommand*\bbrinputbottomstyle{}
8777 \newcommand*\bbrinputnodestyle{}
8778 \newcommand*\bbrinputnodename{}
8779 \define@key{bbrinput}{length}[]{\renewcommand*\bbrinputlength{#1}}
8780 \define@key{bbrinput}{hoffset}[]{\renewcommand*\bbrinputhoffset{#1}}
8781 \define@key{bbrinput}{name}[]{\renewcommand*\bbrinputnodename{#1}}
8782 \define@key{bbrinput}{top}[]{\renewcommand*\bbrinputtop{#1}}
8783 \define@key{bbrinput}{bottom}[]{\renewcommand*\bbrinputbottom{#1}}
8784
8785
8786 \newcommand{\@bb@inputsetup}[1]{
8787 %load keys
8788 \begingroup % for local keys
8789
8790 \setkeys{bbrinput}{#1}%
8791
8792 \tikzset{BBRINPUT-NODESTYLE/.style/.expand once=\bbrinputedgestyle}%
8793 \tikzset{BBRINPUT-TOPSTYLE/.style/.expand once=\bbrinputtopstyle}%
8794 \tikzset{BBRINPUT-BOTTOMSTYLE/.style/.expand once=\bbrinputbottomstyle}%
8795 \tikzset{BBRINPUT-EDGESTYLE/.style/.expand once=\bbrinputedgestyle}%
8796
8797 }
8798
8799 \newcommand{\@bb@inputfinalize}{
8800 \endgroup
8801 }
8802
8803 \newcommandx*{\bbrinput}[2][2=]{%
8804 \@bb@inputsetup{#2}
8805 \ifthenelse{\equal{\bbrinputnodename}{}}
8806 {\renewcommand{\bbrinputnodename}{\@bb@lastbox-input}}{}
8807
8808 \node[overlay,above right={\bbrinputlength} and {\bbrinputhoffset} of \@[email protected] west, anchor=south,BBRINPUT-NODESTYLE] (\bbrinputnodename) {#1};
8809 \path[->] (\bbrinputnodename.south) edge[BBRINPUT-EDGESTYLE] node[above,anchor=east,BBRINPUT-TOPSTYLE] () {\bbrinputtop} node[below,anchor=west,BBRINPUT-BOTTOMSTYLE] () {\bbrinputbottom} (\bbrinputnodename.south|-\@[email protected]);
8810 \@bb@inputfinalize
8811 }
8812
8813 \newcommandx*{\bbroutput}[2][2=]{%
8814 \@bb@inputsetup{#2}
8815 \ifthenelse{\equal{\bbrinputnodename}{}}
8816 {\renewcommand{\bbrinputnodename}{\@bb@lastbox-output}}{}
8817
8818 \node[overlay,below right={\bbrinputlength} and {\bbrinputhoffset} of \@[email protected] west, anchor=north] (\bbrinputnodename) {#1};
8819 \draw[->] (\bbrinputnodename.north|-\@[email protected]) -- (\bbrinputnodename.north|-\bbrinputnodename.north);
8820 \@bb@inputfinalize
8821 }
8822
8823 \newenvironment{bbrpic}[1][]{%
8824 \begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#1]%
8825 }{%
8826 \end{tikzpicture}}
8827
8828 %
8829 % communication
8830 %temporary lengths
8831 \newlength{\@bb@com@tmpoffset}
8832 \newlength{\@bb@tmplength@b}
8833
8834 %keys
8835 \newcommand*\@bbrcomsidestyle{}
8836 \newcommand*\@bbrcomosidestyle{}
8837 \newcommand*\@bbrcomtopstyle{}
8838 \newcommand*\@bbrcombottomstyle{}
8839 \newcommand*\@bbrcomside{}
8840 \newcommand*\@bbrcomoside{}
8841 \newcommand*\@bbrcomtop{}
8842 \newcommand*\@bbrcombottom{}
8843 \newcommand*\@bbrcomedgestyle{}
8844 \newcommand*\@bbrcomlength{1.25cm}
8845 \newcommand*\@bbrcomtopname{bbrcomtop}
8846 \newcommand*\@bbrcombottomname{bbrcombottom}
8847 \newcommand*\@bbrcomsidename{bbrcomside}
8848 \newcommand*\@bbrcomosidename{bbrcomoside}
8849 \newcommand*\@bbrcombeforeskip{0pt}
8850 \newcommand*\@bbrcomafterskip{0ex}
8851 \define@key{bbrcom}{sidestyle}[]{\renewcommand*\@bbrcomsidestyle{#1}}
8852 \define@key{bbrcom}{osidestyle}[]{\renewcommand*\@bbrcomosidestyle{#1}}
8853 \define@key{bbrcom}{topstyle}[]{\renewcommand*\@bbrcomtopstyle{#1}}
8854 \define@key{bbrcom}{bottomstyle}[]{\renewcommand*\@bbrcombottomstyle{#1}}
8855 \define@key{bbrcom}{side}[]{\renewcommand*\@bbrcomside{#1}}
8856 \define@key{bbrcom}{oside}[]{\renewcommand*\@bbrcomoside{#1}}
8857 \define@key{bbrcom}{top}[]{\renewcommand*\@bbrcomtop{#1}}
8858 \define@key{bbrcom}{bottom}[]{\renewcommand*\@bbrcombottom{#1}}
8859 \define@key{bbrcom}{edgestyle}[]{\renewcommand*\@bbrcomedgestyle{#1}}
8860 \define@key{bbrcom}{length}[]{\renewcommand*\@bbrcomlength{#1}}
8861 \define@key{bbrcom}{topname}[]{\renewcommand*\@bbrcomtopname{#1}}
8862 \define@key{bbrcom}{bottomname}[]{\renewcommand*\@bbrcombottomname{#1}}
8863 \define@key{bbrcom}{sidename}[]{\renewcommand*\@bbrcomsidename{#1}}
8864 \define@key{bbrcom}{osidename}[]{\renewcommand*\@bbrcomosidename{#1}}
8865 \define@key{bbrcom}{beforeskip}[]{\renewcommand*\@bbrcombeforeskip{#1}}
8866 \define@key{bbrcom}{aboveskip}[]{\renewcommand*\@bbrcombeforeskip{#1}}
8867 \define@key{bbrcom}{afterskip}[]{\renewcommand*\@bbrcomafterskip{#1}}
8868 \define@key{bbrcom}{belowskip}[]{\renewcommand*\@bbrcomafterskip{#1}}
8869 % \end{macrocode}
8870
8871
8872 %\begin{macro}{\@bbrcomfixedoffset}
8873 %\begin{macro}{\@bbrcomfixedboffset}
8874 %\begin{macro}{fixedoffset}
8875 %\begin{macro}{fixedboffset}
8876 % Provide means for fixed message offset from top or bottom
8877 % \begin{macrocode}
8878 \newcommand*\@bbrcomfixedoffset{}
8879 \newcommand*\@bbrcomfixedboffset{false}
8880 \define@key{bbrcom}{fixedoffset}[]{\renewcommand*\@bbrcomfixedoffset{#1}}
8881 \define@key{bbrcom}{fixedboffset}[]{\renewcommand*\@bbrcomfixedoffset{#1}\renewcommand*\@bbrcomfixedboffset{true}}
8882 % \end{macrocode}
8883 %\end{macro}
8884 %\end{macro}
8885 %\end{macro}
8886 %\end{macro}
8887 %
8888 %
8889 % \begin{macrocode}
8890 %
8891 %
8892 \newcommand*\@bbrbasenodestyle{}
8893 \newcommand*\@bbrbasenodename{bbrtmpname}
8894 \define@key{bbrabase}{nodestyle}[]{\renewcommand*\@bbrbasenodestyle{#1}}
8895 \define@key{bbrabase}{nodename}[]{\renewcommand*\@bbrbasenodename{#1}}
8896
8897 \newcommand*\@bbr@first@msg{true}
8898 \newcommand*\@bbr@first@query{true}
8899 \newcommand*\@bbr@first@oraclequery{true}
8900 \newcommand*\@bbr@first@challengerquery{true}
8901
8902 % \end{macrocode}
8903 %
8904 %
8905 %\begin{macro}{\@bbr@intermessage@skip}
8906 %\begin{macro}{\@bbr@intermessage@medskip}
8907 %\begin{macro}{\@bbr@intermessage@shortskip}
8908 %\begin{macro}{\@bbr@intermessage@veryshortskip}
8909 % Skip between two messages.
8910 % \begin{macrocode}
8911 \newcommand*\@bbr@intermessage@skip{4ex}
8912 \newcommand*\@bbr@intermessage@veryshortskip{1ex}
8913 \newcommand*\@bbr@intermessage@shortskip{1.5ex}
8914 \newcommand*\@bbr@intermessage@medskip{2.5ex}
8915 % \end{macrocode}
8916 %\end{macro}
8917 %\end{macro}
8918 %\end{macro}
8919 %\end{macro}
8920 %
8921 %
8922 %\begin{macro}{islast}
8923 %\begin{macro}{\@bbrcomislast}
8924 % Sets the message from the bottom of the box with the same distance as the first message.
8925 % \begin{macrocode}
8926 \newcommand*\@bbrcomislast{false}
8927 \define@key{bbrcom}{islast}[true]{\renewcommand*\@bbrcomislast{#1}}
8928
8929 \newcommand*\@bbrcom@check@islast{%
8930 \ifthenelse{\equal{\@bbrcomislast}{true}}
8931 {\renewcommand*\@bbrcomfixedoffset{\bbrfirstmessageoffset}\renewcommand*\@bbrcomfixedboffset{true}}
8932 {}
8933 }
8934 % \end{macrocode}
8935 %\end{macro}
8936 %\end{macro}
8937 %
8938 %
8939 %
8940 %\begin{macro}{\@bbr@lastskip}
8941 % marker to set whether next skip is a short or a long one
8942 % \begin{macrocode}
8943 \def\@bbr@lastskip{0pt}
8944 % \end{macrocode}
8945 %\end{macro}
8946 %
8947 %\begin{macro}{\@bb@comsetup}
8948 % Sets up communication parameters for message/query commands. Parameters are
8949 % \marg{key value list}, \marg{length}, \marg{command for adding space}
8950 % \marg{true if first message}
8951 % \begin{macrocode}
8952 \newcommand{\@bb@comsetup}[4]{
8953 % check if is first message and mark as false
8954 \edef\@tmp@bbr@isfirst{#4}
8955 \renewcommand#4{false}
8956
8957 %load keys
8958 \begingroup % for local keys
8959
8960 \setkeys{bbrcom}{#1}%
8961
8962 %set styles
8963 \tikzset{BBRCOM-SIDESTYLE/.style/.expand once=\@bbrcomsidestyle}%
8964 \tikzset{BBRCOM-OSIDESTYLE/.style/.expand once=\@bbrcomosidestyle}%
8965 \tikzset{BBRCOM-TOPSTYLE/.style/.expand once=\@bbrcomtopstyle}%
8966 \tikzset{BBRCOM-BOTTOMSTYLE/.style/.expand once=\@bbrcombottomstyle}%
8967 \tikzset{BBRCOM-EDGESTYLE/.style/.expand once=\@bbrcomedgestyle}%
8968
8969 \@bbrcom@check@islast{}
8970
8971 % increase space
8972 #3{\@bbrcombeforeskip}
8973 \ifthenelse{\equal{\@bbrcomfixedoffset}{}}
8974 {
8975 \ifthenelse{\equal{\@tmp@bbr@isfirst}{true}}
8976 {}{#3{\@bbr@lastskip}}
8977
8978 \setlength{\@bb@com@tmpoffset}{#2}%
8979 }
8980 {
8981 \setlength{\@bb@com@tmpoffset}{\@bbrcomfixedoffset}%
8982 }
8983 }
8984 % \end{macrocode}
8985 %\end{macro}
8986 %
8987 %
8988 %\begin{macro}{\@bb@comfinalize}
8989 % \begin{macrocode}
8990 \newcommand{\@bb@comfinalize}[1]{
8991 #1{\@bbrcomafterskip}
8992 \endgroup
8993 \def\@bbr@lastskip{\@bbr@intermessage@skip}
8994 }
8995 % \end{macrocode}
8996 %\end{macro}
8997 %
8998 %
8999 %
9000 %\begin{macro}{\@bbrmsg}
9001 % 9 -> true if first message
9002 % 10 -> anchor from bottom
9003 % \begin{macrocode}
9004 \newcommand{\@bbrmsg}[9]{
9005 \@bb@comsetup{#1}{#7}{#8}{#9}
9006 %
9007 \ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
9008 {
9009 % from bottom
9010 \ifthenelse{\equal{#4}{north east}}{\def\@bbr@tmp@bottomanchor{south east}}{}
9011 \ifthenelse{\equal{#4}{north west}}{\def\@bbr@tmp@bottomanchor{south west}}{}
9012
9013 \ifdefempty{\@bbrcomside}{
9014 \coordinate[#3=-\@bb@com@tmpoffset and \@bbrcomlength of \@bb@lastbox.\@bbr@tmp@bottomanchor] (\@bbrcomsidename);
9015 }{
9016 \node[#3=-\@bb@com@tmpoffset and \@bbrcomlength of \@bb@lastbox.\@bbr@tmp@bottomanchor,anchor=#6,BBRCOM-SIDESTYLE] (\@bbrcomsidename) {\@bbrcomside};
9017 }
9018 }
9019 {
9020 % from top
9021 \ifdefempty{\@bbrcomside}{
9022 \coordinate[#3=\@bb@com@tmpoffset and \@bbrcomlength of \@bb@lastbox.#4] (\@bbrcomsidename);
9023 }{
9024 \node[#3=\@bb@com@tmpoffset and \@bbrcomlength of \@bb@lastbox.#4,anchor=#6,BBRCOM-SIDESTYLE] (\@bbrcomsidename) {\@bbrcomside};
9025 }
9026 }
9027 \path[#2] (\@bbrcomsidename.#6) edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\@bbrcomtopname) {\@bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\@bbrcombottomname) {\@bbrcombottom} (\@bb@lastbox.#5|-\@bbrcomsidename) -- (\@bb@lastbox.#5|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {};
9028 %
9029 \@bb@comfinalize{#8}
9030 }
9031 % \end{macrocode}
9032 %\end{macro}
9033 %
9034 %
9035 %\begin{macro}{\bbrmsgto}
9036 %\begin{macro}{\bbrmsgfrom}
9037 %\begin{macro}{\bbrmsgtofrom}
9038 %\begin{macro}{\bbrmsgfromto}
9039 % \begin{macrocode}
9040 \newcommandx{\bbrmsgto}[1]{%
9041 \@bbrmsg{#1}{->}{below left}{north west}{west}{east}{\@bb@message@voffset}{\bbrmsgspace}{\@bbr@first@msg}
9042 }
9043 \newcommandx{\bbrmsgfrom}[1]{%
9044 \@bbrmsg{#1}{<-}{below left}{north west}{west}{east}{\@bb@message@voffset}{\bbrmsgspace}{\@bbr@first@msg}
9045 }
9046
9047 \newcommandx{\bbrmsgtofrom}[2]{%
9048 \bbrmsgto{#1}
9049 \bbrmsgspace{-\@bbr@intermessage@skip}
9050 \bbrmsgspace{\@bbr@intermessage@shortskip}
9051 \bbrmsgfrom{#2}
9052 \bbrmsgspace{\@bbr@intermessage@medskip}
9053 }
9054
9055 \newcommandx{\bbrmsgfromto}[2]{%
9056 \bbrmsgfrom{#1}
9057 \bbrmsgspace{-\@bbr@intermessage@skip}
9058 \bbrmsgspace{\@bbr@intermessage@shortskip}
9059 \bbrmsgto{#2}
9060 \bbrmsgspace{\@bbr@intermessage@medskip}
9061 }
9062 % \end{macrocode}
9063 %\end{macro}
9064 %\end{macro}
9065 %\end{macro}
9066 %\end{macro}
9067 %
9068 %
9069 %\begin{macro}{\bbrmsgvdots}
9070 % \begin{macrocode}
9071 \newcommand{\bbrmsgvdots}[1][]{%
9072 \bbrmsgtxt[xshift=\@bbrcomlength/2,afterskip=\@bbr@intermessage@shortskip,#1]{$\vdots$}
9073 }
9074 % \end{macrocode}
9075 %\end{macro}
9076 %
9077 %
9078 %
9079 %
9080 %\begin{macro}{\bbrqryto}
9081 %\begin{macro}{\bbrqryfrom}
9082 %\begin{macro}{\bbrqrytofrom}
9083 %\begin{macro}{\bbrqryfromto}
9084 % \begin{macrocode}
9085 \newcommandx{\bbrqryto}[1]{%
9086 \@bbrmsg{#1}{<-}{below right}{north east}{east}{west}{\@bb@query@voffset}{\bbrqryspace}{\@bbr@first@query}
9087 }
9088 \newcommandx{\bbrqryfrom}[1]{%
9089 \@bbrmsg{#1}{->}{below right}{north east}{east}{west}{\@bb@query@voffset}{\bbrqryspace}{\@bbr@first@query}
9090 }
9091
9092 \newcommand*{\bbrqrytofrom}[2]{%
9093 \bbrqryto{#1}
9094 \bbrqryspace{-\@bbr@intermessage@skip}
9095 \bbrqryspace{\@bbr@intermessage@shortskip}
9096 \bbrqryfrom{#2}
9097 \bbrqryspace{\@bbr@intermessage@medskip}
9098 }
9099
9100 \newcommand*{\bbrqryfromto}[2]{%
9101 \bbrqryfrom{#1}
9102 \bbrqryspace{-\@bbr@intermessage@skip}
9103 \bbrqryspace{\@bbr@intermessage@shortskip}
9104 \bbrqryto{#2}
9105 \bbrqryspace{\@bbr@intermessage@medskip}
9106 }
9107 % \end{macrocode}
9108 %\end{macro}
9109 %\end{macro}
9110 %\end{macro}
9111 %\end{macro}
9112 %
9113 %
9114 %\begin{macro}{\bbrqryvdots}
9115 % \changes{v0.41}{2020/07/13}{Added bbrqryvdots.}
9116 % \begin{macrocode}
9117 \newcommand{\bbrqryvdots}[1][]{%
9118 \bbrqrytxt[xshift=\@bbrcomlength/2,afterskip=\@bbr@intermessage@skip,#1]{$\vdots$}
9119 }
9120 % \end{macrocode}
9121 %\end{macro}
9122 %
9123 %\begin{macro}{\@bbroracleqry}
9124 % \begin{macrocode}
9125 \newcommand{\@bbroracleqry}[4]{
9126 \@bb@comsetup{#1}{#3}{#4}{\@bbr@first@oraclequery}
9127 %
9128 \ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
9129 {
9130 % from bottom
9131 \path[#2] (\@[email protected] west) -- ++ (0,\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt,anchor=west,BBRCOM-SIDESTYLE] (\@bbrcomsidename){\@bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\@bbrcomtopname) {\@bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\@bbrcombottomname) {\@bbrcombottom} (\@[email protected]|-\@bbrcomsidename) -- (\@[email protected]|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=east,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
9132 }
9133 {
9134 \path[#2] (\@[email protected] west) -- ++ (0,-\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt,anchor=west,BBRCOM-SIDESTYLE] (\@bbrcomsidename){\@bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\@bbrcomtopname) {\@bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\@bbrcombottomname) {\@bbrcombottom} (\@[email protected]|-\@bbrcomsidename) -- (\@[email protected]|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=east,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
9135 }
9136 %
9137 \@bb@comfinalize{#4}
9138 }
9139 % \end{macrocode}
9140 %\end{macro}
9141 %
9142 %
9143 %\begin{macro}{\bbroracleqryto}
9144 %\begin{macro}{\bbroracleqryfrom}
9145 %\begin{macro}{\bbroracleqrytofrom}
9146 %\begin{macro}{\bbroracleqryfromto}
9147 % \begin{macrocode}
9148 \newcommand{\bbroracleqryfrom}[1]{
9149 \@bbroracleqry{#1}{->}{\@bb@oraclequery@voffset}{\bbroracleqryspace}
9150 }
9151
9152 \newcommand{\bbroracleqryto}[1]{
9153 \@bbroracleqry{#1}{<-}{\@bb@oraclequery@voffset}{\bbroracleqryspace}
9154 }
9155
9156 \newcommand*{\bbroracleqrytofrom}[2]{%
9157 \bbroracleqryto{#1}
9158 \bbroracleqryspace{-\@bbr@intermessage@skip}
9159 \bbroracleqryspace{\@bbr@intermessage@shortskip}
9160 \bbroracleqryfrom{#2}
9161 \bbroracleqryspace{\@bbr@intermessage@medskip}
9162 }
9163
9164 \newcommand*{\bbroracleqryfromto}[2]{%
9165 \bbroracleqryfrom{#1}
9166 \bbroracleqryspace{-\@bbr@intermessage@skip}
9167 \bbroracleqryspace{\@bbr@intermessage@shortskip}
9168 \bbroracleqryto{#2}
9169 \bbroracleqryspace{\@bbr@intermessage@medskip}
9170 }
9171 % \end{macrocode}
9172 %\end{macro}
9173 %\end{macro}
9174 %\end{macro}
9175 %\end{macro}
9176 %
9177 %
9178 %\begin{macro}{\@bbrchallengerqry}
9179 % \begin{macrocode}
9180 \newcommand{\@bbrchallengerqry}[4]{
9181 \@bb@comsetup{#1}{#3}{#4}{\@bbr@first@challengerquery}
9182 %
9183 \ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
9184 {
9185 \path[#2] (\@[email protected] east) -- ++ (0,\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt,anchor=east,BBRCOM-SIDESTYLE] (\@bbrcomsidename){\@bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\@bbrcomtopname) {\@bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\@bbrcombottomname) {\@bbrcombottom} (\@[email protected]|-\@bbrcomsidename) -- (\@[email protected]|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=west,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
9186 }
9187 {
9188 \path[#2] (\@[email protected] east) -- ++ (0,-\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt,anchor=east,BBRCOM-SIDESTYLE] (\@bbrcomsidename){\@bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\@bbrcomtopname) {\@bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\@bbrcombottomname) {\@bbrcombottom} (\@[email protected]|-\@bbrcomsidename) -- (\@[email protected]|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=west,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
9189 }
9190 %
9191 \@bb@comfinalize{#4}
9192 }
9193 % \end{macrocode}
9194 %\end{macro}
9195 %
9196 %
9197 %
9198 %\begin{macro}{\bbroracleqryto}
9199 %\begin{macro}{\bbroracleqryfrom}
9200 %\begin{macro}{\bbroracleqrytofrom}
9201 %\begin{macro}{\bbroracleqryfromto}
9202 % \begin{macrocode}
9203 \newcommand{\bbrchallengerqryfrom}[1]{
9204 \@bbrchallengerqry{#1}{<-}{\@bb@challengerquery@voffset}{\bbrchallengerqryspace}
9205 }
9206
9207 \newcommand{\bbrchallengerqryto}[1]{
9208 \@bbrchallengerqry{#1}{->}{\@bb@challengerquery@voffset}{\bbrchallengerqryspace}
9209 }
9210
9211 \newcommand*{\bbrchallengerqrytofrom}[2]{%
9212 \bbrchallengerqryto{#1}
9213 \bbrchallengerqryspace{-\@bbr@intermessage@skip}
9214 \bbrchallengerqryspace{\@bbr@intermessage@shortskip}
9215 \bbrchallengerqryfrom{#2}
9216 \bbrchallengerqryspace{\@bbr@intermessage@medskip}
9217 }
9218
9219 \newcommand*{\bbrchallengerqryfromto}[2]{%
9220 \bbrchallengerqryfrom{#1}
9221 \bbrchallengerqryspace{-\@bbr@intermessage@skip}
9222 \bbrchallengerqryspace{\@bbr@intermessage@shortskip}
9223 \bbrchallengerqryto{#2}
9224 \bbrchallengerqryspace{\@bbr@intermessage@medskip}
9225 }
9226 % \end{macrocode}
9227 %\end{macro}
9228 %\end{macro}
9229 %\end{macro}
9230 %\end{macro}
9231 %
9232 %
9233 % \begin{macrocode}
9234
9235
9236 \newcommand*\bbrcomloopleft{}
9237 \newcommand*\bbrcomloopleftstyle{}
9238 \newcommand*\bbrcomloopright{}
9239 \newcommand*\bbrcomlooprightstyle{}
9240 \newcommand*\bbrcomloopcenter{}
9241 \newcommand*\bbrcomloopcenterstyle{}
9242 \newcommand*\bbrcomloopclockwise{false}
9243 \newcommand*\bbrcomloopangle{50}
9244 \define@key{bbrcomloop}{left}[]{\renewcommand*\bbrcomloopleft{#1}}
9245 \define@key{bbrcomloop}{leftstyle}[]{\renewcommand*\bbrcomloopleftstyle{#1}}
9246 \define@key{bbrcomloop}{right}[]{\renewcommand*\bbrcomloopright{#1}}
9247 \define@key{bbrcomloop}{rightstyle}[]{\renewcommand*\bbrcomlooprightstyle{#1}}
9248 \define@key{bbrcomloop}{center}[]{\renewcommand*\bbrcomloopcenter{#1}}
9249 \define@key{bbrcomloop}{centerstyle}[]{\renewcommand*\bbrcomloopcenterstyle{#1}}
9250 \define@key{bbrcomloop}{angle}[]{\renewcommand*\bbrcomloopangle{#1}}
9251 \define@key{bbrcomloop}{clockwise}[true]{\renewcommand*\bbrcomloopclockwise{#1}}
9252
9253 \newcommand{\bbrloop}[3]{
9254 \begingroup % for local keys
9255 \setkeys{bbrcomloop}{#3}%
9256
9257 \tikzset{BBRLOOP-LEFTSTYLE/.style/.expand once=\bbrcomloopleftstyle}%
9258 \tikzset{BBRLOOP-RIGHTSTYLE/.style/.expand once=\bbrcomlooprightstyle}%
9259 \tikzset{BBRLOOP-CENTERSTYLE/.style/.expand once=\bbrcomloopcenterstyle}%
9260
9261
9262 \ifthenelse{\equal{\bbrcomloopclockwise}{true}}
9263 {
9264 \path[->] (#1) edge[bend left=\bbrcomloopangle] node[midway,left,inner sep=0,outer sep=0,BBRLOOP-LEFTSTYLE] (bbrleft) {\bbrcomloopleft} (#2);
9265 \path[->] (#2) edge[bend left=\bbrcomloopangle] node[midway,right,inner sep=0,outer sep=0,BBRLOOP-RIGHTSTYLE] (bbrright) {\bbrcomloopright} (#1);
9266 }
9267 {
9268 \path[->] (#1) edge[bend right=\bbrcomloopangle] node[midway,left,inner sep=0,outer sep=0,] (bbrleft) {\bbrcomloopleft} (#2);
9269 \path[->] (#2) edge[bend right=\bbrcomloopangle] node[midway,right,inner sep=0,outer sep=0,] (bbrright) {\bbrcomloopright} (#1);
9270 }
9271 \node[at=($(bbrleft.west)!0.5!(bbrright.east)$),anchor=center,BBRLOOP-CENTERSTYLE]() {\bbrcomloopcenter};
9272
9273 \endgroup
9274 }
9275
9276 \newcommand*\bbrintertexthoffset{1.5cm}
9277 \define@key{bbrintertext}{xshift}[]{\renewcommand*\bbrintertexthoffset{#1}}
9278
9279 \newcommand{\@bb@intertextsetup}[1]{
9280 %load keys
9281 \begingroup % for local keys
9282
9283 % fix align environment (e.g. for use of pseudocode)
9284 % ^^A https://tex.stackexchange.com/questions/36954/spurious-space-above-align-environment-at-top-of-page-minipage
9285 %\pretocmd\start@align{%
9286 %\if@minipage\kern-0.5\abovedisplayskip\fi
9287 %}{}{}
9288
9289 \setkeys{bbrcom,bbrabase,bbrintertext}{#1}%
9290 \@bbrcom@check@islast{}
9291
9292 \tikzset{BBRBASE-NODESTYLE/.style/.expand once=\@bbrbasenodestyle}%
9293 }
9294
9295 \newcommand{\@bb@intertextfinalize}[1]{
9296 #1{\@bbrcomafterskip}
9297 \endgroup
9298 \def\@bbr@lastskip{\@bbr@intermessage@veryshortskip}
9299 }
9300 % \end{macrocode}
9301
9302 %\begin{macro}{\@bbrintertext}
9303 % 7 -> whether or not this is the first msg/query
9304 % \begin{macrocode}
9305 \newcommand{\@bbrintertext}[7]{
9306 \edef\@tmp@bbr@isfirst{#7}
9307 \renewcommand#7{false}
9308
9309 \@bb@intertextsetup{#1}
9310
9311 % increase space
9312 #5{\@bbrcombeforeskip}
9313 \ifthenelse{\equal{\@bbrcomfixedoffset}{}}
9314 {
9315 \ifthenelse{\equal{\@tmp@bbr@isfirst}{true}}
9316 {}{#5{\@bbr@intermessage@veryshortskip}}
9317
9318 \setlength{\@bb@com@tmpoffset}{#4}%
9319 }
9320 {
9321 \setlength{\@bb@com@tmpoffset}{\@bbrcomfixedoffset}%
9322 }
9323
9324 %
9325 \ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
9326 {
9327 % from bottom
9328 \ifthenelse{\equal{#3}{north east}}{\def\@bbr@tmp@bottomanchor{south east}}{}
9329 \ifthenelse{\equal{#3}{north west}}{\def\@bbr@tmp@bottomanchor{south west}}{}
9330
9331 \node[#2=-\@bb@com@tmpoffset and \bbrintertexthoffset of \@bb@lastbox.\@bbr@tmp@bottomanchor, inner sep=0, outer sep=0, BBRBASE-NODESTYLE] (\@bbrbasenodename) {#6};
9332 }
9333 {
9334 \node[#2=\@bb@com@tmpoffset and \bbrintertexthoffset of \@bb@lastbox.#3, inner sep=0, outer sep=0, BBRBASE-NODESTYLE] (\@bbrbasenodename) {#6};
9335 }
9336 %
9337 % compute height of node
9338 \coordinate (@bbtmpcoord) at (\@bbrbasenodename.north);
9339 \path (@bbtmpcoord);
9340 \pgfgetlastxy{\XCoord}{\YCoordA}
9341 \coordinate (@bbtmpcoord) at (\@bbrbasenodename.south);
9342 \path (@bbtmpcoord);
9343 \pgfgetlastxy{\XCoord}{\YCoordB}
9344
9345 % update voffset
9346 \setlength{\@bb@tmplength@b}{\YCoordA-\YCoordB}
9347 #5{\the\@bb@tmplength@b}
9348
9349 \@bb@intertextfinalize{#5}
9350 }
9351 % \end{macrocode}
9352 %\end{macro}
9353
9354 % \begin{macrocode}
9355 \newcommand{\bbrmsgtxt}[2][]{
9356 \@bbrintertext{#1}{below left}{north west}{\@bb@message@voffset}{\bbrmsgspace}{#2}{\@bbr@first@msg}
9357 }
9358
9359 \newcommand{\bbrqrytxt}[2][]{
9360 \@bbrintertext{#1}{below right}{north east}{\@bb@query@voffset}{\bbrqryspace}{#2}{\@bbr@first@query}
9361 }
9362
9363 \newcommand{\bbrchallengertxt}[2][]{
9364 \begingroup
9365 \setlength{\@bb@tmplength@b}{\bbrchallengerhdistance/2}%
9366 \renewcommand{\bbrintertexthoffset}{\the\@bb@tmplength@b}%
9367 \@bbrintertext{#1}{below left}{north west}{\@bb@challengerquery@voffset}{\bbrchallengerqryspace}{#2}{\@bbr@first@challengerquery}
9368 \endgroup
9369 }
9370
9371 \newcommand{\bbroracletxt}[2][]{
9372 \begingroup
9373 \setlength{\@bb@tmplength@b}{\bbroraclehdistance/2}%
9374 \renewcommand{\bbrintertexthoffset}{\the\@bb@tmplength@b}%
9375 \@bbrintertext{#1}{below left}{north west}{\@bb@oraclequery@voffset}{\bbroracleqryspace}{#2}{\@bbr@first@oraclequery}
9376 \endgroup
9377 }
9378
9379 \newcommand{\bbrmsgspace}[1]{
9380 \@pc@globaladdtolength{\@bb@message@voffset}{#1}
9381 }
9382
9383 \newcommand{\bbrqryspace}[1]{
9384 \@pc@globaladdtolength{\@bb@query@voffset}{#1}
9385 }
9386
9387 \newcommand{\bbroracleqryspace}[1]{
9388 \@pc@globaladdtolength{\@bb@oraclequery@voffset}{#1}
9389 }
9390
9391 \newcommand{\bbrchallengerqryspace}[1]{
9392 \@pc@globaladdtolength{\@bb@challengerquery@voffset}{#1}
9393 }
9394
9395
9396 % \end{macrocode}
9397 %
9398 % \subsection{Game-Based Proofs}
9399 %
9400 % \begin{macrocode}
9401
9402 \newcounter{pcstartgamecounter}
9403 %
9404 %
9405 % \end{macrocode}
9406 %
9407 %
9408 %\begin{macro}{gamechange}
9409 % Highlighting of changes between games. Highlight color can be set via
9410 % |\gamechangecolor|
9411 % \begin{macrocode}
9412 \definecolor{gamechangecolor}{gray}{0.90}
9413 \newcommand{\gamechange}[2][gamechangecolor]{%
9414 {\setlength{\fboxsep}{0pt}\colorbox{#1}{\ifmmode$\displaystyle#2$\else#2\fi}}%
9415 }
9416 % \end{macrocode}
9417 %\end{macro}
9418 %
9419 %\begin{macro}{\pcbox}
9420 % A simple box for conditional (ie., boxed) lines.
9421 % \begin{macrocode}
9422 \newcommand{\pcbox}[1]{%
9423 {\setlength{\fboxsep}{3pt}\fbox{$\displaystyle#1$}}
9424 }
9425 % \end{macrocode}
9426 %\end{macro}
9427 %
9428 %
9429 %
9430 %
9431 %\begin{macro}{\pcgame}
9432 %\begin{macro}{\pcgamename}
9433 %\begin{macro}{\pcgameprocedurestyle}
9434 % \begin{macrocode}
9435 \newcommand*{\pcgamename}{Game}
9436 \newcommand*{\pcgameprocedurestyle}[1]{\ensuremath{\mathsf{#1}}}
9437
9438 \def\pcgame{\bgroup\pcgame@}
9439 \newcommand{\pcgame@}[1][]{\ifthenelse{\equal{#1}{}}{\pcgame@@}{\pcgame@@@{#1}}}
9440 \def\pcgame@@{\pcgameprocedurestyle{\pcgamename}\egroup}
9441 \def\pcgame@@@#1{\ensuremath{\pcgameprocedurestyle{\pcgamename_{\normalfont{#1}}}}\egroup}
9442
9443 % \end{macrocode}
9444 %\end{macro}
9445 %\end{macro}
9446 %\end{macro}
9447 %
9448 %
9449 %\begin{macro}{\@pc@gametitle}
9450 % Creates the header/title of a game
9451 % \begin{macrocode}
9452 \newcommand\@pc@gametitle[1][]{\ifthenelse{\equal{#1}{}}
9453 {\ensuremath{\pcgame[\thepcgamecounter]\gameprocedurearg}}
9454 {\ensuremath{\pcgame[#1]\gameprocedurearg}}}
9455 % \end{macrocode}
9456 %\end{macro}
9457 %
9458 %\begin{macro}{\gameprocedurearg}
9459 % \begin{macrocode}
9460 \newcommand*{\gameprocedurearg}{\ensuremath{(\secpar)}}
9461 % \end{macrocode}
9462 %\end{macro}
9463 %
9464 %
9465 %\begin{environment}{gameproof}
9466 % \begin{macrocode}
9467 \newcommand*\@pcgameproofgamenr{0}
9468 \define@key{pcgameproof}{nr}[]{\renewcommand*\@pcgameproofgamenr{#1}}
9469 \define@key{pcgameproof}{name}[]{\renewcommand*\pcgamename{\ensuremath{#1}}}
9470 \define@key{pcgameproof}{arg}[]{\renewcommand*\gameprocedurearg{\ensuremath{#1}}}
9471
9472 \newenvironment{gameproof}[1][]{%
9473 \begingroup%
9474 \setkeys{pcgameproof}{#1}%
9475 \@pc@ensureremember%
9476 \setcounter{pcgamecounter}{\@pcgameproofgamenr}%
9477 \setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}%
9478 }{\@pc@releaseremember\endgroup}
9479 % \end{macrocode}
9480 %\end{environment}
9481 %
9482 %
9483 %
9484 % \begin{macrocode}
9485 \newcommand{\setgameproceduredefaultstyle}[1]{%
9486 \PackageWarning{cryptocode}{Deprecated command setgameproceduredefaultstyle. Use pcsetargs instead.}%
9487 \pcsetargs{#1}}
9488
9489 \createpseudocodecommand{gameprocedure}
9490 {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}}
9491 {\@pc@gametitle}
9492 {}
9493
9494 \def\@bxgame@pseudocodeA[#1]#2#3{\setkeys*{pcspace}{#1}\renewcommand{\@bxgameheader}{\@pc@gametitle[#2]}%
9495 \@pseudocode[head=\@pc@gametitle,#1]{#3}}
9496 \def\@bxgame@pseudocodeB#1#2{\renewcommand{\@bxgameheader}{\@pc@gametitle[#1]}%
9497 \@pseudocode[head=\@pc@gametitle]{#2}}
9498
9499 \newcommand{\bxgameprocedure}{
9500 \begingroup%
9501 \renewcommand{\@withinspaces}{false}%
9502 \renewcommand{\@withingame}{true}%
9503 \renewcommand{\@withinbxgame}{true}%
9504 \stepcounter{pcgamecounter}%
9505 \@ifnextchar[%]
9506 {\@bxgame@pseudocodeA}
9507 {\@bxgame@pseudocodeB}%
9508 }
9509
9510 \newcommand{\@pc@secondheader}{}
9511
9512 %tbx top boxed
9513 \createpseudocodecommand{tbxgameprocedure}
9514 {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}%
9515 \renewcommand{\@pc@secondheader}{true}}
9516 {\@pc@gametitle}
9517 {}
9518
9519
9520 \newcommand*\@pcgamehopnodestyle{}
9521 \newcommand*\@pcgamehopedgestyle{bend left}
9522 \newcommand*\@pcgamehoppathestyle{}
9523 \newcommand*\@pcgamehophint{}
9524 \newcommand*\@pcgamehophintbelow{}
9525 \newcommand*\@pcgamehopinhint{}
9526 \newcommand*\@pcgamehoplength{1.5cm}
9527 \define@key{pcgamehop}{nodestyle}[]{\renewcommand*\@pcgamehopnodestyle{#1}}
9528 \define@key{pcgamehop}{edgestyle}[]{\renewcommand*\@pcgamehopedgestyle{#1}}
9529 \define@key{pcgamehop}{pathstyle}[]{\renewcommand*\@pcgamehoppathestyle{#1}}
9530 \define@key{pcgamehop}{hint}[]{\renewcommand*\@pcgamehophint{#1}}
9531 \define@key{pcgamehop}{belowhint}[]{\renewcommand*\@pcgamehophintbelow{#1}}
9532 \define@key{pcgamehop}{inhint}[]{\renewcommand*\@pcgamehopinhint{#1}}
9533 \define@key{pcgamehop}{length}[]{\renewcommand*\@pcgamehoplength{#1}}
9534
9535
9536 \newcommand{\@pc@setupgamehop}[1]{
9537 \begingroup\setkeys{pcgamehop}{#1}%
9538 \tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
9539 \tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
9540 \tikzset{GAMEHOP-EDGE-STYLE/.style/.expand once=\@pcgamehopedgestyle}%
9541 }
9542
9543 \newcommand{\@pc@finalizegamehop}{
9544 \endgroup
9545 }
9546
9547 \newcommandx*{\addgamehop}[3]{%
9548 \begingroup%
9549 \ifthenelse{#1<#2}%
9550 {\ifthenelse{\equal{\@withingamedescription}{true}}%
9551 {\renewcommand*\@pcgamehopedgestyle{bend right=20}\renewcommand*\@pcgamehopnodestyle{rotate=90}}{}%
9552 }%
9553 {\renewcommand*\@pcgamehopedgestyle{bend right}}%
9554 \@pc@setupgamehop{#3}%
9555 \begin{tikzpicture}[overlay]%
9556 \ifthenelse{#1<#2}{%
9557 \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
9558 node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#2);
9559 }{%
9560 \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
9561 node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
9562 }%
9563 \end{tikzpicture}%
9564 \@pc@finalizegamehop%
9565 \endgroup%
9566 }
9567 \newcommandx*{\addstartgamehop}[2][1=\thepcstartgamecounter]{%
9568 \@pc@setupgamehop{#2}
9569 \begin{tikzpicture}[overlay]
9570 \node[left=\@pcgamehoplength of gamenode#1] (tmpgamenode0) {};
9571 \path[->,GAMEHOP-PATH-STYLE] (tmpgamenode0) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
9572 node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#1);
9573 \end{tikzpicture}
9574 \@pc@finalizegamehop
9575 }
9576 \newcommandx*{\addendgamehop}[2][1=\thepcgamecounter]{%
9577 \@pc@setupgamehop{#2}
9578 \begin{tikzpicture}[overlay]
9579 \node[right=\@pcgamehoplength of gamenode#1] (tmpgamenode#1) {};
9580 \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
9581 node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (tmpgamenode#1);
9582 \end{tikzpicture}
9583 \@pc@finalizegamehop
9584 }
9585 \newcommandx*{\addbxgamehop}[3]{%
9586 \@pc@setupgamehop{#3}
9587 \begin{tikzpicture}[overlay]
9588 \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE]] {\@pcgamehophint}
9589 node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
9590 \end{tikzpicture}
9591 \@pc@finalizegamehop
9592 }
9593 \newcommandx*{\addloopgamehop}[2][1=\thepcgamecounter]{%
9594 \@pc@setupgamehop{#2}
9595 \begin{tikzpicture}[overlay]
9596 \node (looptemp1) [right=0.5cm of gamenode#1] {};
9597 \draw[->,GAMEHOP-PATH-STYLE] (gamenode#1) -- (looptemp1|-gamenode#1) -- node[right,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
9598 node[left,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (looptemp1|-bgamenode#1)-- (bgamenode#1);
9599 \end{tikzpicture}
9600 \@pc@finalizegamehop
9601 }
9602
9603
9604 % \end{macrocode}
9605 %
9606 % \subsubsection{Game Descriptions}
9607 %
9608 % \begin{macrocode}
9609
9610 \newenvironment{gamedescription}[1][]{%
9611 \begingroup%
9612 \setkeys{pcgameproof}{#1}
9613 \renewcommand{\@withingamedescription}{true}%
9614 \@pc@ensureremember%
9615 \setcounter{pcgamecounter}{\@pcgameproofgamenr}%
9616 \setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}%
9617 \begin{description}%
9618 }{\end{description}\@pc@releaseremember\endgroup}
9619
9620 \newcommandx*{\describegame}[1][1=]{%
9621 \addtocounter{pcgamecounter}{1}%
9622 \item[%
9623 \pcdraw{
9624 \gdef\i{\thepcgamecounter}%
9625 \node[inner sep=0.0em,outer sep=0, xshift=-1ex, yshift=0.5ex] (gamenode\i) {};
9626 }%
9627 \@pc@gametitle:]%
9628 \begingroup\setkeys{pcgamehop}{#1}%
9629 \ifthenelse{\equal{}{\@pcgamehophint}}
9630 {}
9631 {\hspace{-0.7ex}\pcdraw{%the -0.7ex is a horrible hack to fix a whitespace issue with tikz (see http://tex.stackexchange.com/questions/22873/tikzpicture-with-overlay-takes-up-space
9632 \tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
9633 \tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
9634 \draw[->,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,-\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE] {\@pcgamehophint};
9635 }}%
9636 \ifthenelse{\equal{}{\@pcgamehopinhint}}
9637 {}
9638 {\hspace{-0.7ex}\pcdraw{%the -0.7ex is a horrible hack to fix a whitespace issue with tikz (see http://tex.stackexchange.com/questions/22873/tikzpicture-with-overlay-takes-up-space
9639 \tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
9640 \tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
9641 \draw[<-,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE] {\@pcgamehopinhint};
9642 }%
9643 }%
9644 \endgroup%
9645 }
9646 %
9647 % \end{macrocode}
9648 %
9649 %
9650 % \iffalse
9651 % \begin{macrocode}
9652 % \fi
9653 %</cryptocode.sty>
9654 % \end{macrocode}
9655 %\Finale