texlive[55800] Master/texmf-dist: cryptocode (10jul20)

commits+karl at tug.org commits+karl at tug.org
Fri Jul 10 23:20:22 CEST 2020


Revision: 55800
          http://tug.org/svn/texlive?view=revision&revision=55800
Author:   karl
Date:     2020-07-10 23:20:21 +0200 (Fri, 10 Jul 2020)
Log Message:
-----------
cryptocode (10jul20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/cryptocode/cryptocode.pdf
    trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/cryptocode/README.md
    trunk/Master/texmf-dist/source/latex/cryptocode/
    trunk/Master/texmf-dist/source/latex/cryptocode/cryptocode.dtx
    trunk/Master/texmf-dist/source/latex/cryptocode/cryptocode.ins
    trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2018-11-11.sty
    trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2020-04-24.sty

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/latex/cryptocode/README
    trunk/Master/texmf-dist/doc/latex/cryptocode/cryptocode.tex

Deleted: trunk/Master/texmf-dist/doc/latex/cryptocode/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/cryptocode/README	2020-07-10 21:19:52 UTC (rev 55799)
+++ trunk/Master/texmf-dist/doc/latex/cryptocode/README	2020-07-10 21:20:21 UTC (rev 55800)
@@ -1,10 +0,0 @@
-The cryptocode package provides a set of macros to ease the typesetting of 
-pseudocode, algorithms and protocols. In addition it comes with a wide range 
-of tools to typeset cryptographic papers (hence the name).
-This includes simple predefined commands for concepts such as 
-a security parameter or advantage terms but also flexible and powerful
-environments to layout game-based proofs or black-box reductions.
-
-The cryptocode bundle is licensed under the LaTeX Project Public License
-
- -- Arno Mittelbach <mail at arno-mittelbach.de>  11 Nov 2018
\ No newline at end of file

Added: trunk/Master/texmf-dist/doc/latex/cryptocode/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/cryptocode/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/cryptocode/README.md	2020-07-10 21:20:21 UTC (rev 55800)
@@ -0,0 +1,45 @@
+# Cryptocode
+The cryptocode package provides a set of macros to ease the typesetting of pseudocode, algorithms and protocols. In addition it comes with a wide range of tools to typeset cryptographic papers. This includes simple predefined commands for concepts such as a security parameter or advantage terms but also flexible and powerful environments to layout game-based proofs or black-box reductions.
+
+# Installation
+
+Extract the *cryptocode.sty* file via
+
+    pdflatex cryptocode.ins
+
+# Documentation
+
+Create the documentation via
+
+    pdflatex cryptocode.dtx
+    pdflatex cryptocode.dtx
+    makeindex -s gind.ist -o cryptocode.idx cryptocode
+    makeindex -s gglo.ist -o cryptocode.gls cryptocode.glo
+    pdflatex cryptocode.dtx
+
+A prebuilt version of the documentation is available in the repository.
+
+# Versioning
+
+Cryptocode supports LaTeX' rollback mechanism. To load a particular version of cryptocode use
+
+    \usepackage[options]{cryptocode}[=2018-11-11]
+
+Besides the current version 0.40, the following deprecated versions are available via
+the rollback mechanism.
+
+- v0.32 (2020-04-01)
+- v0.30 (2018-11-11)
+
+# Contribution
+
+Contributions to *cryptocode* are very welcome. 
+
+# Attribution
+
+If you use cryptocode in your work, consider starring the repository on GitHub and/or rating it on CTAN.
+
+# License
+
+[LaTeX Project Public License](http://www.latex-project.org/lppl.txt)
+


Property changes on: trunk/Master/texmf-dist/doc/latex/cryptocode/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/cryptocode/cryptocode.pdf
===================================================================
(Binary files differ)

Deleted: trunk/Master/texmf-dist/doc/latex/cryptocode/cryptocode.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/cryptocode/cryptocode.tex	2020-07-10 21:19:52 UTC (rev 55799)
+++ trunk/Master/texmf-dist/doc/latex/cryptocode/cryptocode.tex	2020-07-10 21:20:21 UTC (rev 55800)
@@ -1,3981 +0,0 @@
-%% Copyright 2018 Arno Mittelbach
-  %
-  % This work may be distributed and/or modified under the
-  % conditions of the LaTeX Project Public License, either version 1.3
-  % of this license or (at your option) any later version.
-  % The latest version of this license is in
-  %   http://www.latex-project.org/lppl.txt
-  % and version 1.3 or later is part of all distributions of LaTeX
-  % version 2005/12/01 or later.
-  %
-  % This work has the LPPL maintenance status `maintained'.
-  % 
-  % The Current Maintainer of this work is Arno Mittelbach.
-  %
-  % This work consists of the files cryptocode.tex and cryptocode.sty
-
-\documentclass[a4paper]{report}
-
-% more than one optional parameter
-\usepackage[usenames]{xcolor}
-\usepackage{hyperref}
-\usepackage[
-	n,
-	operators,
-	advantage,
-	sets,
-	adversary,
-	landau,
-	probability,
-	notions,	
-	logic,
-	ff,
-	mm,
-	primitives,
-	events,
-	complexity,
-	asymptotics,
-	keys]{cryptocode}
-
-
-\usepackage{csquotes}
-\usepackage{fullpage}
-\usepackage{dashbox}
-\usepackage{todonotes}
-
-\usepackage{url}
-
-\usetikzlibrary{shapes.callouts}
-
-\usepackage{listings}
-
-\usepackage{trace}
-
-\usepackage{makeidx}
-\usepackage{mdframed}
-
-\makeindex
-
-
-
-
-
-
-\author{Arno Mittelbach\\
-\texttt{mail at arno-mittelbach.de}}
-\title{\Huge Cryptocode \\ \large\textsc{Typesetting Cryptography}}
-
-\definecolor{mygreen}{rgb}{0,0.6,0}
-\definecolor{mygray}{rgb}{0.1,0.1,0.1}
-\definecolor{mymauve}{rgb}{0.58,0,0.82}
-
-\lstset{language=[LaTeX]TeX,
- backgroundcolor=\color{lightgray},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
- rulecolor=\color{lightgray},
-  basicstyle=\scriptsize,        % the size of the fonts that are used for the code
-  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
-  breaklines=true,                 % sets automatic line breaking
-  captionpos=b,                    % sets the caption-position to bottom
-  commentstyle=\color{mygreen},    % comment style
-  escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
-  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
-  frame=single,                    % adds a frame around the code
-  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
-  keywordstyle=\color{blue},       % keyword style
-  numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)
-  numbersep=5pt,                   % how far the line-numbers are from the code
-  numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
-  rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
-  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
-  showstringspaces=false,          % underline spaces within strings only
-  showtabs=false,                  % show tabs within strings adding particular underscores
-  stepnumber=1,                    % the step between two line-numbers. If it's 1, each line will be numbered
-  stringstyle=\color{mymauve},     % string literal style
-  frameround=ftff,
-  belowskip=0em,
-  aboveskip=1em,
-  tabsize=2,                       % sets default tabsize to 2 spaces
-  title=\lstname        }  
-
-\begin{document}
-
-\maketitle
-
-
-
-
-\begin{abstract}
-\thispagestyle{empty}
-The cryptocode package provides a set of macros to ease the typesetting of 
-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).
-This includes simple predefined commands for concepts such as 
-a security parameter $\secparam$ or advantage terms $\advantage{prf}{\adv,\prf} = \negl$ but also flexible and powerful
-environments to layout game-based proofs or black-box reductions.
-
-\vspace{2em}
-\begin{center}
-\fbox{
-\pseudocode{%
-\textbf{ Alice} \< \< \textbf{ Bob}  \\[0.1\baselineskip][\hline]
- \<\< \\[-0.5\baselineskip]
-x \sample \ZZ_q \< \< \\
- X \gets g^x \<\< \\
- \< \sendmessageright*{\GG,q,g,X} \< \\
- \<\< y \sample \ZZ_q \\
- \<\< Y \gets g^y \\
- \< \sendmessageleft*{Y} \< \\
- \key_A \gets Y^x \<\< \key_B \gets X^y }
-}
-\end{center}
-
-
-\end{abstract}
-\newpage
-
-\pagenumbering{roman}
-
-\tableofcontents
-\thispagestyle{empty}
-\newpage
-
-\pagenumbering{arabic}
-
-
-\chapter{Cryptocode by Example}
-
-The cryptocode package provides a set of commands to ease the typesetting of 
-pseudocode, protocols, game-based proofs and black-box reductions. In addition it comes
-with a large number of predefined commands. In this chapter we present the various features of 
-cryptocode by giving small examples. But first, let's load the package
-
-\begin{lstlisting}
-\usepackage[
-	n,
-	advantage,
-	operators,
-	sets,
-	adversary,
-	landau,
-	probability,
-	notions,
-	logic,
-	ff,
-	mm,
-	primitives,
-	events,
-	complexity,
-	asymptotics,
-	keys
-	]{cryptocode}
-\end{lstlisting}
-
-Note that all the options refer to a set of commands. That is, without any options cryptocode will provide the mechanisms
-for writing pseudocode, protocols, game-based proofs and black-box reductions but not define additional commands,
-such as \lstinline$\pk$ or \lstinline$\sk$ (for typesetting public and private/secret keys) which are part of the keys option.
-We discuss the various options and associated commands in Chapter~\ref{chap:commands}.
-
-
-\section{Pseudocode}
-The cryptocode package tries to make writing pseudocode easy and enjoyable. The
-\lstinline$\pseudocode$ command takes a single parameter where you can start writing
-code in mathmode using \lstinline{\\} as line breaks. Following is an $\indcpa$ game
-definition using various commands from cryptocode to ease writing keys (\lstinline{\pk,\sk}),
-sampling (\lstinline{\sample}), and more:
-\begin{center}
-\fbox{\pseudocode[linenumbering,syntaxhighlight=auto]{%
-  b \sample \bin  \\
-  (\pk,\sk) \sample \kgen (\secparam)  \\
-  (\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
-  c \sample \enc(\pk,m_b)  \\
-  b' \sample \adv(\secparam, \pk, c, \state)  \\
-  return b = b' }}
-\end{center}
-
-
-The above code is generated by (the code is actually wrapped in an \lstinline$fbox$).
-\begin{lstlisting}
-\pseudocode[linenumbering,syntaxhighlight=auto]{%
-  b \sample \bin  \\
-  (\pk,\sk) \sample \kgen (\secparam)  \\
-  (\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
-  c \sample \enc(\pk,m_b)  \\
-  b' \sample \adv(\secparam, \pk, c, \state)  \\
-  return b = b' }
-\end{lstlisting}
-The pseudocode command thus takes a single mandatory argument (the code) plus an optional argument
-which allows you to specify options in a key=value fashion. In the above example we used the linenumbering
-option (which not surprisingly adds line numbers to the code) as well as the syntaxhighlighting option which
-highlights certain keywords (in the example it is responsible for setting \enquote{return} as \highlightkeyword[]{return}).
-
-It is easy to define a heading for your code. Either specify the header using the option \enquote{head} or use 
-the \lstinline$\procedure$ command which takes an additional argument to specify the headline.
-\begin{center}
-\fbox{\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
-  b \sample \bin  \\
-  (\pk,\sk) \sample \kgen (\secparam)  \\
-  (\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
-  c \sample \enc(\pk,m_b)  \\
-  b' \sample \adv(\secparam, \pk, c, \state) \\
-  \pcreturn b = b' }}
-\end{center}
-
-\begin{lstlisting}
-\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
-  b \sample \bin  \\
-  (\pk,\sk) \sample \kgen (\secparam)  \\
-  (\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
-  c \sample \enc(\pk,m_b)  \\
-  b' \sample \adv(\secparam, \pk, c, \state) \\
-  \pcreturn b = b' }
-\end{lstlisting}
-Here in the example we have not turned on the automatic syntax highlighting but used the command \lstinline$\pcreturn$
-to highlight the return statement. Besides \lstinline$\pcreturn$ there are a variant of predefined \enquote{keywords}
-such as \lstinline$\pcfor$, \lstinline$\pcif$, etc. (all prefixed with pc)
-
-There is a lot more that we will discuss in detail in Chapter~\ref{chap:pseudocode}. Here, for example
-is the same code with an overlay explanation and a division of the pseudocode.
-\begin{center}
-\fbox{
-\begin{pcimage}
-\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
-	 b \sample \bin  \\
-	 (\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen}  \pclb
-	\pcintertext[dotted]{Setup Completed} 
-	 (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-	  c \sample \enc(\pk,m_b)  \\
-	  b' \sample \adv(\secparam, \pk, c, \state) \\
-	  \pcreturn b = b' }
-
-\pcdraw{
-  \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
-      at ([shift={(+3,-1)}]kgen) {
-		\begin{varwidth}{3cm}
-			$\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
-		\end{varwidth}
-  };
-}
-\end{pcimage}
-}
-\end{center}
-
-\begin{lstlisting}
-\begin{pcimage}
-\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
-	 b \sample \bin  \\
-	 (\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen}  \pclb
-	\pcintertext[dotted]{Setup Completed} 
-	 (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-	  c \sample \enc(\pk,m_b)  \\
-	  b' \sample \adv(\secparam, \pk, c, \state) \\
-	  \pcreturn b = b' }
-
-\pcdraw{
-  \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
-      at ([shift={(+3,-1)}]kgen) {
-		\begin{varwidth}{3cm}
-			$\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
-		\end{varwidth}
-  };
-}
-\end{pcimage}
-\end{lstlisting}
-
-
-
-\section{Columns}
-The \lstinline$\pseudocode$ and \lstinline$\procedure$ commands allow the usage of multiple columns.
-You switch to a new column by inserting a \lstinline$\>$. This is similar to using an \lstinline$align$
-environment and placing a tabbing \& character.\footnote{In fact, the \emph{pseudocode} command
-is based on amsmath's flalign environment.}
-\begin{center}
-\fbox{%
-\pseudocode{%
- \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
-  b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
-}
-\end{center}
-\begin{lstlisting}
-\pseudocode{%
- \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
-  b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
-\end{lstlisting}
-As you can see the first column is left aligned the second right, the third left and so forth.
-In order to get only left aligned columns you could thus simply always skip a column by
-using \lstinline$\>\>$. You can also use \lstinline$\<$ a shorthand for \lstinline$\>\>$.
-\begin{center}
-\fbox{%
-\pseudocode{%
- \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
-  b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
-}
-\end{center}
-
-\section{Protocols}
-Using columns makes it easy to write even complex protocols. Following is a simple
-three party protocol
-\begin{center}
-\fbox{%
-\pseudocode{%
- \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\[][\hline]
- \text{work} \< \< \< \< \\
- \< \sendmessageright{top=Work result,topstyle=red} \< \< \< \\
- \< \< \text{work} \< \< \\
- \< \< \<  \sendmessageright{top=Work result,bottom=Bottom message} \< \\
- \< \<  \< \< \text{work} \\
- \< \sendmessageleftx{8}{\text{A long message for Alice}} \< \\
- \text{finalize} \< \< \< \< }
-}
-\end{center}
-\begin{lstlisting}
-\pseudocode{%
- \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\[][\hline]
- \text{work} \< \< \< \< \\
- \< \sendmessageright{top=Work result,topstyle=red} \< \< \< \\
- \< \< \text{work} \< \< \\
- \< \< \<  \sendmessageright{top=Work result,bottom=Bottom message} \< \\
- \< \<  \< \< \text{work} \\
- \< \sendmessageleftx{8}{\text{A long message for Alice}} \< \\
- \text{finalize} \< \< \< \< }
-\end{lstlisting}
-The commands \lstinline$\sendmessageright$ and \lstinline$\sendmessageleft$ are very flexible and
-allow to style the sending of messages in various ways. Also note the \lstinline$\\[][\hline]$ at the end of the
-first line. Here the first optional argument allows us to specify the lineheight (similarly to the behavior in an
-align environment). The second optional argument allows us to, for example, draw a horizontal line.
-
-In multi player protocols such as the one
-above the commands  \lstinline$\sendmessagerightx$ and \lstinline$\sendmessageleftx$ (note the x at the end)
-allow to send messages over multiple columns. In the example, as we were using \lstinline$\<$ the
-final message thus spans 8 columns. 
-
-For basic protocols you might also utilize the \lstinline$\sendmessageright*$ and \lstinline$\sendmessageleft*$
-commands which simply take a message which is displayed.
-\begin{center}
-\fbox{%
-\pseudocode{%
-\textbf{ Alice} \< \< \textbf{ Bob}  \\[0.1\baselineskip][\hline]
- \<\< \\[-0.5\baselineskip]
-x \sample \ZZ_q \< \< \\
- X \gets g^x \<\< \\
- \< \sendmessageright*{\GG,q,g,X} \< \\
- \<\< y \sample \ZZ_q \\
- \<\< Y \gets g^y \\
- \< \sendmessageleft*{Y} \< \\
- \key_A \gets Y^x \<\< \key_B \gets X^y 
-}
-}
-\end{center}
-\begin{lstlisting}
-\pseudocode{%
-\textbf{ Alice} \< \< \textbf{ Bob}  \\[0.1\baselineskip][\hline]
- \<\< \\[-0.5\baselineskip]
-x \sample \ZZ_q \< \< \\
- X \gets g^x \<\< \\
- \< \sendmessageright*{\GG,q,g,X} \< \\
- \<\< y \sample \ZZ_q \\
- \<\< Y \gets g^y \\
- \< \sendmessageleft*{Y} \< \\
- \key_A \gets Y^x \<\< \key_B \gets X^y }
-\end{lstlisting}
-We will discuss protocols in greater detail in Chapter~\ref{chap:protocols}.
-
-\section{Game-based Proofs}
-Cryptocode supports authors in visualizing game-based proofs. It defines an environment
-\lstinline$gameproof$ which allows to wrap a number of game procedures displaying helpful
-information as to what changes from game to game, and to what each step is reduced.
-
-\vspace{2\baselineskip}
-\begin{center}
-\begin{gameproof}
-\gameprocedure[linenumbering,mode=text]{%
- Step 1 \\
- Step 2 \\
- Step 3  
- }
-\gameprocedure[mode=text]{%
-   Step 1  \\
-   \gamechange{Step 2 is different} \\
-   Step 3
- }
-\addgamehop{1}{2}{hint={\footnotesize some hint}}
-\end{gameproof}
-\end{center}
-\begin{lstlisting}
-\begin{gameproof}
-\gameprocedure[linenumbering,mode=text]{%
- Step 1 \\
- Step 2 \\
- Step 3  
- }
-\gameprocedure[mode=text]{%
-   Step 1  \\
-   \gamechange{Step 2 is different} \\
-   Step 3
- }
-\addgamehop{1}{2}{hint={\footnotesize some hint}}
-\end{gameproof}
-\end{lstlisting}
-Note that we made use of the option \enquote{mode=text} in the above example which tells the underlying pseudocode 
-command to not work in math mode but in plain text mode. We'll discuss how to visualize game-based proofs in Chapter~\ref{chap:gbproofs}.
-
-\section{Black-box Reductions}
-Cryptocode provides a strucured syntax to visualize black-box reductions. Basically cryptocode
-provides an environment to draw boxes that may have oracles and that can be communicated with.
-Cryptocode makes heavy use of TIKZ (\url{https://www.ctan.org/pkg/pgf}) for this, which gives you 
-quite some control over how things should look like. Additionally, as you can specify node names
-(for example the outer box in the next example is called \enquote{A}) you can easily extend the pictures
-by using plain TIKZ commands.
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} \\
-		\text{Step 2} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Adversary,minheight=4cm]
-		\end{bbrbox}
-
-		\bbrmsgto{top=$m$}
-		\bbrmsgfrom{top=$\sigma$}
-		\bbrmsgtxt{\pseudocode{%
-			\text{more work} 
-		}}
-		\bbrmsgto{top=$m$}
-		\bbrmsgfrom{top=$\sigma$}
-
-		\bbrqryto{side=$m$}
-		\bbrqryfrom{side=$b$}
-	\end{bbrenv}
-
-	\pseudocode{
-		\text{finalize} 
-	}	
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbroracle}{OraA}
-		\begin{bbrbox}[name=Oracle 1,minheight=1cm]
-		\end{bbrbox}
-	\end{bbroracle}
-	\bbroracleqryto{top=$m$}
-	\bbroracleqryfrom{top=$b$}
-
-	\begin{bbroracle}{OraB}
-		\begin{bbrbox}[name=Oracle 2,minheight=1cm]
-		\end{bbrbox}
-	\end{bbroracle}
-	\bbroracleqryto{top=$m$}
-	\bbroracleqryfrom{top=$b$}
-\end{bbrenv}
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} \\
-		\text{Step 2} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Adversary,minheight=4cm]
-		\end{bbrbox}
-
-		\bbrmsgto{top=$m$}
-		\bbrmsgfrom{top=$\sigma$}
-		\bbrmsgtxt{\pseudocode{%
-			\text{more work} 
-		}}
-		\bbrmsgto{top=$m$}
-		\bbrmsgfrom{top=$\sigma$}
-
-		\bbrqryto{side=$m$}
-		\bbrqryfrom{side=$b$}
-	\end{bbrenv}
-
-	\pseudocode{
-		\text{finalize} 
-	}	
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbroracle}{OraA}
-		\begin{bbrbox}[name=Oracle 1,minheight=1cm]
-		\end{bbrbox}
-	\end{bbroracle}
-	\bbroracleqryto{top=$m$}
-	\bbroracleqryfrom{top=$b$}
-
-	\begin{bbroracle}{OraB}
-		\begin{bbrbox}[name=Oracle 2,minheight=1cm]
-		\end{bbrbox}
-	\end{bbroracle}
-	\bbroracleqryto{top=$m$}
-	\bbroracleqryfrom{top=$b$}
-\end{bbrenv}
-\end{lstlisting}
-We'll discuss the details in Chapter~\ref{chap:bbr}.
-
-\chapter{Cryptographic Notation}
-\label{chap:commands}
-\index{package options}
-In this section we'll discuss the various commands for notation that can be loaded via package options.
-\begin{lstlisting}
-\usepackage[
-	n,
-	advantage,
-	operators,
-	sets,
-	adversary,
-	landau,
-	probability,
-	notions,
-	logic,
-	ff,
-	mm,
-	primitives,
-	events,
-	complexity,
-	asymptotics,
-	keys
-	]{cryptocode}
-\end{lstlisting}
-
-\textbf{Remark. } The commands defined so far are far from complete and are currently mostly targeted at what I needed in my
-papers (especially once you get to cryptographic notions and primitives). So please if you feel that something should be added
-drop me an email.
-
-\section{Security Parameter}
-\index{security parameter|see {package options}}
-\index{package options!security parameter}
-In cryptography we make use of a security parameter which is usually written as $1^n$ or $1^\lambda$. The cryptocode
-package, when loading either option \enquote{n} or option \enquote{lambda} will define the commands
-\begin{lstlisting}
-	\secpar
-	\secparam
-\end{lstlisting}
-The first command provides the \enquote{letter}, i.e., either $n$ or $\lambda$, whereas \lstinline$\secparam$ points
-to $1^\secpar$.
-
-\section{Advantage Terms}
-Load the package option ``advantage'' in order to define the command \lstinline$\advantage$ used to specify advantage terms such as:
-\[
-\advantage{prf}{\adv,\prf} = \negl
-\]
-\begin{lstlisting}
-	\advantage{prf}{\adv,\prf} = \negl
-\end{lstlisting}
-Specify an optional third parameter to replace the $(\secpar)$. 
-\begin{lstlisting}
-	\advantage{prf}{\adv,\prf}[(arg)]
-\end{lstlisting}
-In order to redefine the styles in which superscript and subscript are set redefine
-\begin{lstlisting}
-	\renewcommand{\pcadvantagesuperstyle}[1]{\mathrm{\MakeLowercase{#1}}}
-	\renewcommand{\pcadvantagesubstyle}[1]{#1}
-\end{lstlisting}
-
-\section{Math Operators}
-\index{operators|see {package options}}
-\index{package options!operators}
-\index{math operators|see {package options}}
-The \enquote{operators} option provides the following list of commands:
-
-\begin{center}
-\begin{tabular}{l p{6cm} l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} & \textbf{Example}  \\\hline
-\lstinline$\sample$ & Sampling from a distribution, or running a randomized procedure & $\sample$ & $b \sample \bin$ \\
-\lstinline$\floor{42.5}$ & Rounding down & $\floor{42.5}$ &  \\
-\lstinline$\ceil{41.5}$ & Rounding up & $\ceil{41.5}$ &  \\
-\lstinline$\Angle{x,y}$ & Vector product & $\Angle{x,y}$ &  \\
-\lstinline$\abs{42.9}$ & Absolute number & $\abs{42.9}$ &  \\
-\lstinline$\norm{x}$ & Norm & $\norm{x}$ & \\
-\lstinline$\concat$ & Verbose concatenation (I usually prefer simply \lstinline$\|$) & $\concat$ & $x \gets a\concat b$ \\
-\lstinline$\emptystring$ & The empty string & $\emptystring$ & $x \gets \emptystring$ 
-\end{tabular}
-\end{center}
-
-\section{Adversaries}
-\index{adversary|see {package options}}
-\index{package options!adversary}
-The \enquote{adversary} option provides the following list of commands:
-
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\adv$ & Adversary & $\adv$  \\
-\lstinline$\bdv$ & Adversary & $\bdv$  \\
-\lstinline$\cdv$ & Adversary & $\cdv$  \\
-\lstinline$\ddv$ & Adversary & $\ddv$  \\
-\lstinline$\mdv$ & Adversary & $\mdv$  \\
-\lstinline$\pdv$ & Adversary & $\pdv$  \\
-\lstinline$\sdv$ & Adversary & $\sdv$  
-\end{tabular}
-\end{center}
-
-The style in which an adversary is rendered is controlled via 
-\begin{lstlisting}
-\renewcommand{\pcadvstyle}[1]{\mathcal{#1}}
-\end{lstlisting}
-
-
-\section{Landau}
-\index{Landau|see {package options}}
-\index{package options!Landau}
-The \enquote{landau} option provides the following list of commands:
-
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\bigO{n^2}$ & Big O notation & $\bigO{n^2}$  \\
-\lstinline$\smallO{n^2}$ & small o notation & $\smallO{n^2}$  \\
-\lstinline$\bigOmega{n^2}$ & Big Omega notation & $\bigOmega{n^2}$  \\
-\lstinline$\bigsmallO{n^2}$ & Big and small O notation & $\bigsmallO{n^2}$  
-\end{tabular}
-\end{center}
-
-
-\section{Probabilities}
-\index{probability|see {package options}}
-\index{package options!probabilities}
-The \enquote{probability} option provides commands for writing probabilities. Use
-\begin{lstlisting}
-\prob{X=x}
-\probsub{x\sample{\bin^n}}{x=5}
-\condprob{X=x}{A=b}
-\condprobsub{x\sample{\bin^n}}{x=5}{A=b}
-\end{lstlisting}
-to write basic probabilities, probabilities with explicit probability spaces and conditional probabilities.
-\begin{align*}
-& \prob{X=x} \\
-& \probsub{x\sample{\bin^n}}{X=x} \\
-& \condprob{X=x}{A=b} \\
-& \condprobsub{x\sample{\bin^n}}{x=5}{A=b}
-\end{align*}
-You can control the probability symbol (Pr) by redefining
-\begin{lstlisting}
-\renewcommand{\probname}{Pr}
-\end{lstlisting}
-
-For expectations you can use
-\begin{lstlisting}
-\expect{X}
-\expsub{x,y\sample\set{1,\ldots,6}}{x+y}
-\condexp{X+Y}{Y>3}
-\condexpsub{x,y\sample\set{1,\ldots,6}}{x+y}{y>3}
-\end{lstlisting}
-yielding
-\begin{align*}
-& \expect{X} \\
-& \expsub{x,y\sample\set{1,\ldots,6}}{x+y} \\
-& \condexp{X+Y}{Y>3} \\
-& \condexpsub{x,y\sample\set{1,\ldots,6}}{x+y}{y>3} 
-\end{align*}
-You can control the expactation symbol ($\mathbb{E}$) by redefining
-\begin{lstlisting}
-\renewcommand{\expectationname}{\ensuremath{\mathbb{E}}}
-\end{lstlisting}
-
-The support $\supp{X}$ of a random variable $X$ can be written as
-\begin{lstlisting}
-\supp{X}
-\end{lstlisting}
-where again the name can be controlled via
-\begin{lstlisting}
-\renewcommand{\supportname}{Supp}
-\end{lstlisting}
-
-For denoting entropy and min-entropy use
-\begin{lstlisting}
-\entropy{X}
-\minentropy{X}
-\condentropy{X}{Y=5}
-\condminentropy{X}{Y=5}
-\condavgminentropy(X}{Y=5}
-\end{lstlisting}
-This yields 
-\begin{align*}
-& \entropy{X} \\
-& \minentropy{X} \\
-& \condentropy{X}{Y=5} \\
-& \condminentropy{X}{Y=5} \\
-& \condavgminentropy{X}{Y=5}
-\end{align*}
-
-\section{Sets}
-\index{sets|see {package options}}
-\index{package options!sets}
-The \enquote{sets} option provides commands for basic mathematical sets.
-You can write sets and sequences as
-\begin{lstlisting}
-\set{1, \ldots, 10}
-\sequence{1, \ldots, 10}
-\end{lstlisting}
-which is typeset as
-\begin{align*}
-& \set{1, \ldots, 10} \\
-& \sequence{1, \ldots, 10}
-\end{align*}
-
-In addation the following commands are provided
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\bin$ & The set containing 0 and 1 & $\bin$  \\
-\lstinline$\NN$ & Natural numbers & $\NN$  \\
-\lstinline$\ZZ$ & Integers & $\ZZ$  \\
-\lstinline$\QQ$ & Rational numbers & $\QQ$  \\
-\lstinline$\CC$ & Complex numbers & $\CC$  \\
-\lstinline$\RR$ & Reals & $\RR$  \\
-\lstinline$\PP$ & & $\PP$  \\
-\lstinline$\FF$ & & $\FF$  \\
-\end{tabular}
-\end{center}
-
-\section{Crypto Notions}
-\index{notions|see {package options}}
-\index{package options!notions}
-\index{Crypto notions|see {package options}}
-The \enquote{notions} option provides the following list of commands:
-
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\indcpa$ & IND-CPA security for encryption schemes & $\indcpa$  \\
-\lstinline$\indcca$ & IND-CCA security for encryption schemes & $\indcca$  \\
-\lstinline$\indccai$ & IND-CCA1 security for encryption schemes & $\indccai$  \\
-\lstinline$\indccaii$ &  IND-CCA2 security for encryption schemes & $\indccaii$  \\
-\lstinline$\priv$ & PRIV security for deterministic public-key encryption schemes & $\priv$  \\
-\lstinline$\ind$ & IND security (for deterministic public-key encryption schemes) & $\ind$  \\
-\lstinline$\prvcda$ & PRV-CDA security (for deterministic public-key encryption schemes)& $\prvcda$  \\
-\lstinline$\prvrcda$ & PRV\$-CDA security (for deterministic public-key encryption schemes) & $\prvrcda$  \\
-\lstinline$\kiae$ & Key independent authenticated encryption & $\kiae$  \\
-\lstinline$\kdae$ & Key dependent authenticated encryption & $\kdae$  \\
-\lstinline$\mle$ & Message locked encryption & $\mle$  \\
-\lstinline$\uce$ & Universal computational extractors & $\uce$  \\
-\end{tabular}
-\end{center}
-
-The style in which notions are displayed can be controlled via redefining
-\begin{lstlisting}
-\renewcommand{\pcnotionstyle}[1]{\ensuremath{\mathrm{#1}}}
-\end{lstlisting}
-
-\section{Logic}
-\index{logic|see {package options}}
-\index{package options!logic}
-The \enquote{logic} option provides the following list of commands:
-
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\AND$ & Logical AND & $\AND$  \\
-\lstinline$\NAND$ & Logical NAND & $\NAND$  \\
-\lstinline$\OR$ & Logical OR & $\OR$  \\
-\lstinline$\NOR$ & Logical NOR & $\NOR$  \\
-\lstinline$\XOR$ & Logical XOR & $\XOR$  \\
-\lstinline$\XNOR$ & Logical XNOR & $\XNOR$  \\
-\lstinline$\NOT$ & not & $\NOT$  \\
-\lstinline$\xor$ & exclusive or & $\xor$  \\
-\lstinline$\false$ & false & $\false$  \\
-\lstinline$\true$ & true & $\true$  
-\end{tabular}
-\end{center}
-
-
-% Function Families
-\section{Function Families}
-\index{ff|see {package options}}
-\index{package options!ff}
-\index{function families|see {package options}}
-The \enquote{ff} option provides the following list of commands:
-
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\kgen$ & Key generation & $\kgen$  \\
-\lstinline$\pgen$ & Parameter generation & $\pgen$  \\
-\lstinline$\eval$ & Evaluation & $\eval$  \\
-\lstinline$\invert$ & Inversion & $\invert$  \\
-\lstinline$\il$ & Input length & $\il$  \\
-\lstinline$\ol$ & Output length & $\ol$  \\
-\lstinline$\kl$ & Key length & $\kl$  \\
-\lstinline$\nl$ & Nonce length & $\nl$  \\
-\lstinline$\rl$ & Randomness length & $\rl$  
-\end{tabular}
-\end{center}
-
-The style in which these are displayed can be controlled via redefining
-\begin{lstlisting}
-\renewcommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
-\end{lstlisting}
-
-
-% Machine Model
-\section{Machine Model}
-\index{machine model|see {package options}}
-\index{package options!mm}
-\index{mm|see {package options}}
-The \enquote{mm} option provides the following list of commands:
-
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\CRKT$ & A circuit & $\CRKT$  \\
-\lstinline$\TM$ & A Turing machine & $\TM$  \\
-\lstinline$\PROG$ & A program & $\PROG$  \\
-\lstinline$\uTM$ & A universal Turing machine & $\uTM$  \\
-\lstinline$\uC$ & A universal Circuit & $\uC$  \\
-\lstinline$\uP$ & A universal Program & $\uP$  \\
-\lstinline$\tmtime$ & Time (of a TM) & $\tmtime$  \\
-\lstinline$\ppt$ & Probabilistic polynomial time & $\ppt$  
-\end{tabular}
-\end{center}
-
-The style in which these are displayed can be controlled via redefining
-\begin{lstlisting}
-\renewcommand{\pcmachinemodelstyle}[1]{\ensuremath{\mathsf{#1}}}
-\end{lstlisting}
-
-\section{Crypto Primitives}
-\index{primitives|see {package options}}
-\index{package options!primitives}
-\index{Crypto primitives|see {package options}}
-The \enquote{primitives} option provides the following list of commands:
-
-
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\prover$ & Proover & $\prover$  \\
-\lstinline$\verifier$ & Verifier & $\verifier$  \\
-\lstinline$\nizk$ & Non interactie zero knowledge & $\nizk$  \\
-\lstinline$\hash$ & A hash function & $\hash$  \\
-\lstinline$\gash$ & A hash function& $\gash$  \\
-\lstinline$\fash$ & A hash function & $\fash$  \\
-\lstinline$\enc$ & Encryption  & $\enc$  \\
-\lstinline$\dec$ & Decryption & $\dec$  \\
-\lstinline$\sig$ & Signing & $\sig$  \\
-\lstinline$\verify$ & Verifying & $\verify$  \\
-\lstinline$\obf$ & Obfuscation & $\obf$  \\
-\lstinline$\iO$ & Indistinguishability obfuscation & $\iO$  \\
-\lstinline$\diO$ & Differing inputs obfuscation & $\diO$  \\
-\lstinline$\mac$ & Message authentication & $\mac$  \\
-\lstinline$\puncture$ & Puncturing & $\puncture$  \\
-\lstinline$\source$ & A source & $\source$  \\
-\lstinline$\predictor$ & A predictor & $\predictor$  \\
-\lstinline$\sam$ & A sampler & $\sam$  \\
-\lstinline$\distinguisher$ & A distinguisher & $\distinguisher$  \\
-\lstinline$\dist$ & A distinguisher& $\dist$  \\
-\lstinline$\simulator$ & A simulator & $\simulator$  \\
-\lstinline$\ext$ & An extractor & $\ext$  
-\end{tabular}
-\end{center}
-
-The style in which these are displayed can be controlled via redefining
-\begin{lstlisting}
-\renewcommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
-\end{lstlisting}
-
-\section{Events}
-\index{events|see {package options}}
-\index{package options!events}
-The \enquote{events} option provides the following list of commands. 
-
-To classify an event use
-\begin{lstlisting}
-\event{Event}
-\nevent{Event}
-\end{lstlisting}
-where the second is meant as the negation. These are typset as
-\begin{align*}
-&\event{Event}\\
-&\nevent{Event}
-\end{align*}
-
-For bad events, use \lstinline$\bad$ ($\bad$).
-
-\section{Complexity}
-\index{complexity|see {package options}}
-\index{package options!complexity}
-The \enquote{complexity} option provides the following list of commands:
-
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Result} \\\hline
-\lstinline$\npol$ &  $\npol$  \\
-\lstinline$\conpol$ &  $\conpol$  \\
-\lstinline$\pol$ &  $\pol$  \\
-\lstinline$\bpp$ & $\bpp$  \\
-\lstinline$\ppoly$ & $\ppoly$  \\
-\lstinline$\NC{1}$ &  $\NC1$  \\
-\lstinline$\AC{1}$ & $\AC1$  \\
-\lstinline$\TC{1}$ & $\TC1$ \\
-\lstinline$\AM$ &  $\AM$  \\
-\lstinline$\coAM$ &  $\coAM$  
-\end{tabular}
-\end{center}
-
-The style in which these are displayed can be controlled via redefining
-\begin{lstlisting}
-\renewcommand{\pccomplexitystyle}[1]{\ensuremath{\mathsf{#1}}}
-\end{lstlisting}
-
-\section{Asymptotics}
-\index{asymptotics|see {package options}}
-\index{package options!asymptotics}
-The \enquote{asymptotics} option provides the following list of commands:
-
-\begin{center}
-\begin{tabular}{l l p{7.5cm}}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\negl$ & A negligible function & $\negl$ (takes an optional argument \lstinline$\negl[a]$ ($\negl[a]$). Write \lstinline$\negl[]$ for $\negl[]$.)  \\
-\lstinline$\poly$ &  A polynomial & $\poly$ (takes an optional argument \lstinline$\poly[a]$ ($\poly[a]$). Write \lstinline$\poly[]$ for $\poly[]$.) \\
-\lstinline$\pp$ & some polynomial $\pp$ & $\pp$  \\
-\lstinline$\qq$ & some polynomial $\qq$ &  $\qq$  \\
-\end{tabular}
-\end{center}
-
-The style in which these are displayed can be controlled via redefining
-\begin{lstlisting}
-\renewcommand{\pcpolynomialstyle}[1]{\ensuremath{\mathrm{#1}}}
-\end{lstlisting}
-
-\section{Keys}
-\index{keys|see {package options}}
-\index{package options!keys}
-The \enquote{keys} option provides the following list of commands:
-
-
-\begin{center}
-\begin{tabular}{l l l}
-\textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
-\lstinline$\pk$ &public key & $\pk$  \\
-\lstinline$\vk$ &  verification key& $\vk$  \\
-\lstinline$\sk$ & secret key&  $\sk$  \\
-\lstinline$\key$ & a plain key& $\key$  \\
-\lstinline$\hk$ & hash key&  $\hk$  \\
-\lstinline$\gk$ &gash key & $\gk$  \\
-\lstinline$\fk$ & function key & $\fk$  
-\end{tabular}
-\end{center}
-
-The style in which these are displayed can be controlled via redefining
-\begin{lstlisting}
-\renewcommand{\pckeystyle}[1]{\ensuremath{\mathsf{#1}}}
-\end{lstlisting}
-
-
-\chapter{Pseudocode}
-\label{chap:pseudocode}
-
-In this chapter we discuss how to write pseudocode with the cryptocode library.
-
-\section{Basics}
-\index{\textbackslash pseudocode}
-
-The cryptocode package provides the command \emph{pseudocode} for typesetting algorithms.
-Consider the following definition of an IND-CPA game
-\begin{center}
-\fbox{%
-\pseudocode{%
-   b \sample \bin  \\
-   (\pk,\sk) \sample \kgen (\secparam)  \\
-   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-   c \sample \enc(\pk,m_b)  \\
-   b' \sample \adv(\secparam, \pk, c)  \\
-   \pcreturn b = b' }
-}
-\end{center}
-which is generated as
-\begin{lstlisting}
-\pseudocode{%
-   b \sample \bin  \\
-   (\pk,\sk) \sample \kgen (\secparam)  \\
-   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-   c \sample \enc(\pk,m_b)  \\
-   b' \sample \adv(\secparam, \pk, c)  \\
-   \pcreturn b = b' }
-\end{lstlisting}
-As you can see the pseudocode command provides a math based environment where you can simply start typing your pseudocode
-separating lines by \lstinline$\\$.
-
-
-\paragraph{Boxed appearance}
-Although most examples here appear centered and boxed this is not directly part of the pseudocode package but due to the examples being 
-typeset as
-\begin{lstlisting}
-\begin{center}
-\fbox{%
-Code
-}
-\end{center}
-\end{lstlisting}
-
-
-\subsection{Customizing Pseudocode}
-\index{lnstart}
-\index{head}
-\index{lnstartright}
-\index{linenumbering}
-\index{syntaxhighlight}
-\index{keywords}
-\index{keywordsindent}
-\index{codesize}
-\index{keywordsunindent}
-\index{keywordsuninindent}
-\index{addkeywords}
-\index{altkeywords}
-\index{mode}
-\index{space}
-\index{xshift}
-\index{colsep}
-\index{addtolength}
-\index{nodraft}
-\index{yshift}
-\index{bodylinesep}
-\index{headlinesep}
-\index{jot}
-\index{beginline}
-\index{endline}
-
-Besides the mandatory argument the \lstinline{\pseudocode} command can take an optional argument which consists of a list of key=value pairs
-separated by commas (,).
-\begin{lstlisting}
-\pseudocode[options]{body}
-\end{lstlisting}
-The following keys are available:
-\begin{description}
-\item[head]
-A header for the code
-\item[width]
-An exact width. If no width is specified, cryptocode tries to automatically compute the correct width.
-\item[lnstart]
-The starting line number when using line numbering.
-\item[lnstartright]
-The starting line number for right aligned line numberswhen using line numbering.
-\item[linenumbering]
-Enables line numbering.
-\item[syntaxhighlight]
-When set to \enquote{auto} cryptocode will attempt to automatically hightlight keywords such as \enquote{for}, \enquote{foreach}
-and \enquote{return}
-\item[keywords]
-Provide a comma separated list of keywords for automatic syntax highlighting. To customize the behavior of automatic spacing 
-you can provide keywords as
-\begin{description}
-\item[keywordsindent]
-After seeing this keyword all following lines will be indented one extra level.
-\item[keywordsunindent]
-After seeing this keyword the current and all following lines will be unindented one extra level.
-\item[keywordsuninindent]
-After seeing this keyword the current line will be unindented one level.
-\end{description}
-\item[addkeywords]
-Provide additional keywords for automatic syntax highlighting.
-\item[altkeywords]
-Provide a second list of keywords for automatic syntax highlighting that are highlighted differently.
-\item[mode]
-When set to text pseudocode will not start in math mode but in text mode.
-\item[space]
-Allows you to enable automatic spacing mode. If set to \enquote{keep} the spaces in the input are preserved.
-If set to \enquote{auto} it will try to detect spacing according to keywords such as \enquote{if} and \enquote{fi}.
-\item[codesize]
-Allows to specify the fontsize for the pseudocode. Set to \lstinline$\scriptsize$ for a smaller size.
-
-\item[colspace]
-Allows to insert spacing between columns. In particular this allows to also overlap columns by inserting negative space.
-
-\item[jot]
-Allows to specify extra space between each line. Use \lstinline$jot=1mm$.
-
-\item[beginline]
-Allows to specify a macro that is placed at the beginning of each line.
-
-\item[endline]
-Allows to specify a macro that is placed at the end of each line.
-
-\item[xshift]
-Allows horizontal shifting
-\item[yshift]
-Allows horizontal shifting
-
-\item[headlinesep]
-Specifies the distance between header and the line.
-\item[bodylinesep]
-Specifies the distance between body and the line.
-\item[colsep]
-Defines the space between columns.
-\item[addtolength]
-Is added to the automatically computed width of the pseudocode (which does not take colsep into account). 
-
-\item[valign]
-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}.
-
-\item[nodraft]
-Forces syntax highlighting also in draft mode.
-\end{description}
-The following code 
-\begin{lstlisting}
-\pseudocode[linenumbering,syntaxhighlight=auto,head=Header]{ return null }
-\end{lstlisting}
-creates 
-\begin{center}
-\fbox{\pseudocode[linenumbering,syntaxhighlight=auto,head=Header]{ return null }}
-\end{center}
-
-\subsection{Customized Pseudocode Commands}
-\index{\textbackslash procedure}
-\index{\textbackslash createpseudocodecommand}
-\index{\textbackslash createprocedurecommand}
-
-Besides the  \lstinline{\pseudocode}  command the command  \lstinline{\procedure}
-provides easy access to generate code with a header. It takes the following form
-\begin{lstlisting}
-\procedure[options]{Header}{Body}
-\end{lstlisting}
-
-\subsubsection{Examples}
-\begin{center}
-\fbox{%
-\procedure{$\indcpa_\enc^\adv$}{%
-   b \sample \bin  \\
-   (\pk,\sk) \sample \kgen(\secparam)  \\
-   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-   c \sample \enc(\pk,m_b)  \\
-   b' \sample \adv(\secparam, \pk, c)  \\
-   \pcreturn b = b' }
-}
-\end{center}
-which is generated as
-\begin{lstlisting}
-\procedure{$\indcpa_\enc^\adv$}{%
-   b \sample \bin  \\
-   (\pk,\sk) \sample \kgen(\secparam)  \\
-   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-   c \sample \enc(\pk,m_b)  \\
-   b' \sample \adv(\secparam, \pk, c)  \\
-   \pcreturn b = b' }
-\end{lstlisting}
-
-You can define customized pseudocode commands which either take one optional argument and two mandatory arguments (as the procedure command)
-or one optional and one mandatory argument (as the pseudocode command). The following
-\begin{lstlisting}
-\createprocedurecommand{mypseudocode}{}{}{linenumbering}
-\createpseudocodecommand{myheadlesscmd}{}{}{linenumbering}
-\end{lstlisting}
-creates the commands \lstinline$\mypseudocode$ and \lstinline$\myheadlesscmd$ with line numbering always enabled. The first command
-has an identical interface as the \lstinline$\pseudocode$ command, the second has an interface as the \lstinline$\procedure$ command.
-The second and third argument that we kept empty when generating the commands allows us to specify commands that are executed at the
-very beginning when the command is called (argument 2) and a prefix for the header.
-
-
-\section{Indentation}
-\index{indentation}
-\index{\textbackslash pcind}
-\index{\textbackslash t}
-
-In order to indent code use \lstinline$\pcind$ or short \lstinline$\t$. You can also usecustomized spacing such as \lstinline$\quad$ or \lstinline$\hspace$
-when using the pseudocode command in math mode.
-\begin{center}
-\fbox{%
-\pseudocode{%
-   \pcfor i = 1..10 \pcdo  \\
-   \pcind T[i] \sample \bin^n \\
-   \pcfor i = 1..10 \pcdo  \\
-   \t T[i] \sample \bin^n }
-}
-\end{center}
-which is generated as
-\begin{lstlisting}
-\pseudocode{%
-   \pcfor i = 1..10 \pcdo  \\
-   \pcind T[i] \sample \bin^n  \\
-   \pcfor i = 1..10 \pcdo  \\
-   \t T[i] \sample \bin^n }
-\end{lstlisting}
-You can specify multiple levels via the optional first argument
-\begin{lstlisting}
-\pcind[level]
-\end{lstlisting}
-\begin{center}
-\fbox{%
-\pseudocode{%
-   \pcfor i = 1..10 \pcdo  \\
-   \pcind T[i] \sample \bin^n  \\
-   \pcind\pcind T[i] \sample \bin^n \\
-   \pcind[3] T[i] \sample \bin^n \\
-   \pcind[4] T[i] \sample \bin^n \\
-   \pcind[5] T[i] \sample \bin^n }
-}
-\end{center}
-\begin{lstlisting}
-\pseudocode{%
-   \pcfor i = 1..10 \pcdo  \\
-   \pcind T[i] \sample \bin^n  \\
-   \pcind\pcind T[i] \sample \bin^n \\
-   \pcind[3] T[i] \sample \bin^n \\
-   \pcind[4] T[i] \sample \bin^n \\
-   \pcind[5] T[i] \sample \bin^n }
-\end{lstlisting}
-
-\index{\textbackslash pcindentname}
-You can customize the indentation shortcut by redefining
-\begin{lstlisting}
-\renewcommand{\pcindentname}{t}
-\end{lstlisting}
-
-\subsubsection{Automatic Indentation}
-The pseudocode command comes with an option \enquote{space=auto} which tries to detect the correct indentation from the use of
-keywords. When it sees one of the following keywords
-\begin{lstlisting}
-\pcif, \pcfor, \pcwhile, \pcrepeat, \pcforeach
-\end{lstlisting}
-it will increase the indentation starting from the next line. It will again remove the indentation on seeing 
-\begin{lstlisting}
-\pcfi, \pcendif, \pcendfor, \pcendwhile, \pcuntil, \pcendforeach
-\end{lstlisting}
-Additionally, on seeing
-\begin{lstlisting}
-\pcelse, \pcelseif
-\end{lstlisting}
-it will remove the indentation for that particular line. Thus the following 
-\begin{center}
-\fbox{\pseudocode[space=auto]{%
-\pcfor a \in [10] \pcdo \\
-	\pcfor a \in [10] \pcdo \\
-		\pcfor a \in [10] \pcdo \\
-			\pcif a = b \pcthen \\
-				\text{some operation} \\
-			\pcelseif a = c \pcthen \\
-				\text{some operation} \\
-			\pcelse \\
-				\text{some default operation} \\
-			\pcfi \\
-		\pcendfor \\
-	\pcendfor \\
-\pcendfor \\
-\pcreturn a}}
-\end{center}
-can be obtained by:
-\begin{lstlisting}
-\pseudocode[space=auto]{%
-\pcfor a \in [10] \pcdo \\
-	\pcfor a \in [10] \pcdo \\
-		\pcfor a \in [10] \pcdo \\
-			\pcif a = b \pcthen \\
-				\text{some operation} \\
-			\pcelseif a = c \pcthen \\
-				\text{some operation} \\
-			\pcelse \\
-				\text{some default operation} \\
-			\pcfi \\
-		\pcendfor \\
-	\pcendfor \\
-\pcendfor \\
-\pcreturn a}
-\end{lstlisting}
-Note that the manual indentation in the above example is not necessary for the outcome. Further note that the same
-works when using automatic syntax highlighting (see Section~\ref{sec:syntaxhighlight}).
-
-\subsubsection{Keep Input Indentation}
-\label{sec:keepindent}
-The pseudocode package comes with an experimental feature that preserves the spacing in the input. This can be enabled with
-the option \enquote{space=keep}. Thus the above can also be written as
-\begin{center}
-\pseudocode[space=keep]{%
-\pcfor i = 1..10 \pcdo  \\
-    T[i] \sample \bin^n  \\
-        T[i] \sample \bin^n \\
-            T[i] \sample \bin^n \\
-                T[i] \sample \bin^n \\
-                    T[i] \sample \bin^n }
-\end{center}
-\begin{lstlisting}
-\pseudocode[space=keep]{%
-\pcfor i = 1..10 \pcdo  \\
-    T[i] \sample \bin^n  \\
-        T[i] \sample \bin^n \\
-            T[i] \sample \bin^n \\
-                T[i] \sample \bin^n \\
-                    T[i] \sample \bin^n }
-\end{lstlisting}
-Note that automatic spacing only works when the \lstinline$\pseudocode$ command is not wrapped within another command.
-Thus in order to get a frame box \lstinline$\fbox{\pseudocode[space=keep]{code}}$ will not work but you would need to use
-an environment such as one offered by the \emph{mdframed} package ((\url{https://www.ctan.org/pkg/mdframed}). Also see
-Section~\ref{sec:keepindent-problem}.
-
- 
-\section{Textmode}
-\index{text mode}
-
-By default pseudocode enables \LaTeX' math mode. You can change this behavior and tell the pseudocode command to interpret the content
-in text mode by setting the option \enquote{mode=text}.
-\begin{center}
-\fbox{\pseudocode[mode=text]{%
-This is \\
-\t simply text}}
-\end{center}
-\begin{lstlisting}
-\pseudocode[mode=text]{%
-This is \\
-\t simply text}
-\end{lstlisting}
-
-\section{Syntax Highlighting}
-\label{sec:syntaxhighlight}
-
-\index{\textbackslash pcabort}
-\index{\textbackslash pcfail}
-\index{\textbackslash pccontinue}
-\index{\textbackslash pccomment}
-\index{\textbackslash pcdo}
-\index{\textbackslash pcdone}
-\index{\textbackslash pcelse}
-\index{\textbackslash pcelseif}
-\index{\textbackslash pcfi}
-\index{\textbackslash pcendif}
-\index{\textbackslash pcforeach}
-\index{\textbackslash pcendforeach}
-\index{\textbackslash pcglobvar}
-\index{\textbackslash pcif}
-\index{\textbackslash pcin}
-\index{\textbackslash pcnew}
-\index{\textbackslash pcnull}
-\index{\textbackslash pcparse}
-\index{\textbackslash pcrepeat}
-\index{\textbackslash pcuntil}
-\index{\textbackslash pcreturn}
-\index{\textbackslash pcthen}
-\index{\textbackslash pctrue}
-\index{\textbackslash pcwhile}
-\index{\textbackslash pcendwhile}
-
-
-In the above examples we have used commands \lstinline$\pcreturn$ and \lstinline$\pcfor$ to highlight certain keywords.
-Besides the \emph{pcreturn}, \emph{pcfor} and \emph{pcdo} (where the pc stands for pseudocode) that were used in the above 
-examples the package defines the following set of constants:
-
-\begin{center}
-\begin{tabular}{lll}
- \textbf{name} & \textbf{usage} & \textbf{outcome} \\ 
- pcabort & \lstinline$\pcabort$ & \pcabort\\
- pccontinue & \lstinline$\pccontinue$ & \pccontinue \\
- pccomment & \lstinline$\pccomment{comment}$ & \pccomment{comment} \\
- pcdo & \lstinline$\pcdo$ & \pcdo \\
- pcdone & \lstinline$\pcdone$ & \pcdone \\
- pcfail & \lstinline$\pcfail$ & \pcfail \\
- pcfalse & \lstinline$\pcfalse$ & \pcfalse \\
- pcif & \lstinline$\pcif$ & \pcif \\
- pcfi & \lstinline$\pcfi$ & \pcfi \\
- pcendif & \lstinline$\pcendif$ & \pcendif \\ 
- pcelse & \lstinline$\pcelse$ & \pcelse \\
- pcelseif & \lstinline$\pcelseif$ & \pcelseif \\ 
- pcfor  & \lstinline$\pcfor$ & \pcfor \\
- pcendfor  & \lstinline$\pcendfor$ & \pcendfor \\ 
- pcforeach  & \lstinline$\pcforeach$ & \pcforeach \\
- pcendforeach  & \lstinline$\pcendforeach$ & \pcendforeach \\ 
- pcglobvar & \lstinline$\pcglobvar$ & \pcglobvar \\
- pcin & \lstinline$\pcin$ & \pcin \\
- pcnew & \lstinline$\pcnew$ & \pcnew \\
- pcnull & \lstinline$\pcnull$ & \pcnull \\
- pcparse & \lstinline$\pcparse$ & \pcparse \\
- pcrepeat & \lstinline$\pcrepeat{10}$ & \pcrepeat{10} \\
- pcreturn & \lstinline$\pcreturn$ & \pcreturn \\ 
- pcuntil & \lstinline$\pcuntil$ & \pcuntil \\
- pcthen & \lstinline$\pcthen$ & \pcthen \\
- pctrue & \lstinline$\pctrue$ & \pctrue \\
- pcwhile & \lstinline$\pcwhile$ & \pcwhile \\
- pcendwhile & \lstinline$\pcendwhile$ & \pcendwhile \\
-\end{tabular}
-\end{center}
-Note that \lstinline{\pcdo}, \lstinline{\pcin} and \lstinline{\pcthen} have a leading space. This is due to their usual usage scenarios
-such as
-\begin{center}
-\pseudocode{\pcfor i \pcin \{1,\ldots,10\}}
-\end{center}
-Furthermore all constants have a trailing space. This can be removed by adding the optional parameter [] such as
-\begin{center}
-\pseudocode{\pcfor i \pcin[] \{1,\ldots,10\}}
-\end{center}
-\begin{lstlisting}
-\pseudocode{\pcfor i \pcin[] \{1,\ldots,10\}}
-\end{lstlisting}
-
-\index{highlight keywords}
-\index{emphasize|see highlight keywords}
-\index{\textbackslash highlightkeyword}
-In order to change the font you can overwrite the command \lstinline{\highlightkeyword} which is defined as
-\begin{lstlisting}
-\newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
-\end{lstlisting}
-
-\subsubsection{Automatic Syntax Highlighting}
-The pseudocode command comes with an experimental feature to automatically highlight keywords. This can be activated via
-the option \enquote{syntaxhighlight=auto}. The preset list of keywords it looks for are
-\begin{lstlisting}
-for ,foreach ,return ,{ do }, in ,new ,if ,null ,null,true ,true,until ,{ to },false ,false,{ then },repeat ,else ,done ,done,fi 
-\end{lstlisting}
-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}.
-Via the option \enquote{keywords} you can provide a custom list of keywords.
-Thus the following bubblesort variant (taken from \url{http://en.wikipedia.org/wiki/Bubble_sort}) 
-\begin{center}
-\fbox{\procedure[syntaxhighlight=auto]{Bubblesort(A : list of items)}{
-   n \gets \mathsf{length}(A) \\
-   repeat \\
-   \t s \gets false \\
-   \t  for i = 1 to n-1 do \\
-   \t\t  \pccomment{if this pair is out of order} \\
-   \t\t   if A[i-1] > A[i] then \\
-   \t\t\t \pccomment{swap them and remember something changed} \\
-   \t\t\t     \mathsf{swap}( A[i-1], A[i] ) \\
-   \t\t\t       s \gets true \\
-   until \neg s }
-}
-\end{center}
-can be typeset as
-\begin{lstlisting}
-\procedure[syntaxhighlight=auto]{Bubblesort(A : list of items)}{
-   n \gets \mathsf{length}(A) \\
-   repeat \\
-   \t s \gets false \\
-   \t  for i = 1 to n-1 do \\
-   \t\t  \pccomment{if this pair is out of order} \\
-   \t\t   if A[i-1] > A[i] then \\
-   \t\t\t \pccomment{swap them and remember something changed} \\
-   \t\t\t     \mathsf{swap}( A[i-1], A[i] ) \\
-   \t\t\t       s \gets true \\
-   until \neg s }
-\end{lstlisting}
-
-\index{addkeywords}
-You can also define additional keywords using the \enquote{addkeywords} option. This would allow us to specify \enquote{length} and \enquote{swap} in the above example. Combined with automatic spacing we could thus get
-\begin{center}
-\procedure[space=keep,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
-n \gets length(A) \\
-repeat \\
-    s \gets false \\
-    for i=1 to n-1 do \\
-        \pccomment{if this pair is out of order} \\
-        if A[i-1]>A[i] then \\
-            \pccomment{swap them and remember something changed} \\
-            swap(A[i-1], A[i]) \\
-            s \gets true \\
-until \neg{}s }
-\end{center}
-Simply by writing (note the \lstinline$\neg{}$ in order to not have a space before $s$):
-\begin{lstlisting}
-\procedure[space=keep,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
-n \gets length(A) \\
-repeat \\
-    s \gets false \\
-    for i=1 to n-1 do \\
-        \pccomment{if this pair is out of order} \\
-        if A[i-1]>A[i] then \\
-            \pccomment{swap them and remember something changed} \\
-            swap(A[i-1], A[i]) \\
-            s \gets true \\
-until \neg{}s }
-\end{lstlisting}
-Also note that a simple \lstinline$\fbox$ around the above \lstinline$\procedure$ command has the effect that the automatic spacing fails. 
-For this also see Section~\ref{sec:keepindent-problem}. As an alternative we could use automatic spacing and insert \enquote{group end}
-keywords such as \enquote{fi}:
-\begin{center}
-\fbox{\procedure[space=auto,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
-n \gets length(A) \\
-repeat \\
-    s \gets false \\
-    for i=1 to n-1 do \\
-        \pccomment{assuming this pair is out of order} \\
-        if A[i-1]>A[i] then \\
-            \pccomment{swap them and remember something changed} \\
-            swap(A[i-1], A[i]) \\
-            s \gets true \\
-        endif \\
-     endfor \\
-until \neg s }}
-\end{center}
-The last example is generated as (note that here fbox is fine.)
-\begin{lstlisting}
-\fbox{\procedure[space=auto,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
-n \gets length(A) \\
-repeat \\
-    s \gets false \\
-    for i=1 to n-1 do \\
-        \pccomment{assuming this pair is out of order} \\
-        if A[i-1]>A[i] then \\
-            \pccomment{swap them and remember something changed} \\
-            swap(A[i-1], A[i]) \\
-            s \gets true \\
-        endif \\
-     endfor \\
-until \neg s }}
-\end{lstlisting}
-
-\subsection{Alternative Keywords}
-\index{altkeywords}
-There is a second keyword list that you can add keywords to which are highlighted not via \lstinline$\highlightkeyword$ but via \lstinline$\highlightaltkeyword$
-where alt stands for alternate. This allows you to have two different keyword styles which are by default defined as
-\begin{lstlisting}
-\newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
-\newcommand{\highlightaltkeyword}[1]{\ensuremath{\mathsf{#1}}}
-\end{lstlisting}
-This allows you to rewrite the above example and highlight the different nature of swap and length.
-\begin{center}
-\fbox{\procedure[space=auto,syntaxhighlight=auto,altkeywords={swap,length}]{Bubblesort(A : list of items)}{
-n \gets length(A) \\
-repeat \\
-    s \gets false \\
-    for i=1 to n-1 do \\
-        \pccomment{assuming this pair is out of order} \\
-        if A[i-1]>A[i] then \\
-            \pccomment{swap them and remember something changed} \\
-            swap(A[i-1], A[i]) \\
-            s \gets true \\
-        endif \\
-     endfor \\
-until \neg s }}
-\end{center}
-\begin{lstlisting}
-\procedure[space=auto,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
-n \gets length(A) \\
-repeat \\
-    s \gets false \\
-    for i=1 to n-1 do \\
-        \pccomment{assuming this pair is out of order} \\
-        if A[i-1]>A[i] then \\
-            \pccomment{swap them and remember something changed} \\
-            swap(A[i-1], A[i]) \\
-            s \gets true \\
-        endif \\
-     endfor \\
-until \neg s }
-\end{lstlisting}
-
-\subsection{Draft Mode}
-\index{nodraft}
-\index{performance}
-\index{draft mode}
-Automatic syntax highlighting is a somewhat expensive operation as it requires several rounds of regular expression matching.
-In order to speed up compilation the pseudocode command will not attempt automatic highlighting when the document is in draft mode.
-When in draft mode and you want to force a specific instance of \lstinline$\pseudocode$ to render the code with automatic syntax
-highlighting you can use the option \lstinline$nodraft$.
-
-
-\section{Line Numbering}
-\index{line numbering}
-\index{\textbackslash pcln}
-\index{\textbackslash pclnr}
-\index{\textbackslash pcrln}
-The pseudocode command allows to insert line numbers into pseudocode. You can either manually control line numbering or simply turn on the option
-\enquote{linenumbering}.
-\begin{center}
-\fbox{%
-\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
-  b \sample \bin \\
- (\pk,\sk) \sample \kgen\secparam)  \\
-  \label{tmp:line:label}   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-  c \sample \enc(\pk,m_b)  \\
-  b' \sample \adv(\secparam, \pk, c)  \\
- \pcreturn b = b' }
-}
-\end{center}
-is generated by 
-\begin{lstlisting}
-\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
-  b \sample \bin \\
- (\pk,\sk) \sample \kgen\secparam)  \\
-  \label{tmp:line:label}   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-  c \sample \enc(\pk,m_b)  \\
-  b' \sample \adv(\secparam, \pk, c)  \\
- \pcreturn b = b' }
-\end{lstlisting}
-Note how you can use labels such as \lstinline$\label{tmp:line:label}$ which now points to \ref{tmp:line:label}.
-
-\subsection{Manually Inserting Line Numbers}
-In order to manually insert line numbers use the command \lstinline$\pcln$.
-\begin{center}
-\fbox{%
-\procedure{$\indcpa_\enc^\adv$}{%
- \pcln  b \sample \bin \\
- \pcln   (\pk,\sk) \sample \kgen\secparam)  \\
- \pcln\label{tmp:line:label2}   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-}
-\end{center}
-is generated by 
-\begin{lstlisting}
-\procedure{$\indcpa_\enc^\adv$}{%
- \pcln  b \sample \bin \\
- \pcln   (\pk,\sk) \sample \kgen\secparam)  \\
- \pcln\label{tmp:line:label2}   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-\end{lstlisting}
-Note that the label \emph{tmp:line:label2} now points to line number \ref{tmp:line:label2}.
-
-
-
-\subsection{Start Values}
-You can specify the start value (-1) of the counter by setting the option \enquote{lnstart}.
-\begin{lstlisting}
-\procedure[lnstart=10,linenumbering]{Header}{Body}
-\end{lstlisting}
-\begin{center}
-\fbox{%
-\procedure[lnstart=10,linenumbering]{$\indcpa_\enc^\adv$}{%
-  b \sample \bin \\
-   (\pk,\sk) \sample \kgen\secparam)  \\
-   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-   c \sample \enc(\pk,m_b)  \\
-   b' \sample \adv(\secparam, \pk, c)  \\
-   \pcreturn b = b' }
-}
-\end{center}
-
-\subsection{Separators}
-\index{\textbackslash pclnseparator}
-The commands \lstinline$\pclnseparator$ defines the separator between the pseudocode and the line numbering. By
-default the left separator is set to (:) colon. Also see Section~\ref{sec:protocol:separator}.
-
-
-\section{Subprocedures}
-\index{subprocedure}
-The pseudocode package allows the typesetting of sub procedures such as
-
-\begin{center}
-\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
-   b \sample \bin  \\
-   (\pk,\sk) \sample \kgen(\secparam)  \\
-   (m_0,m_1) \sample  \begin{subprocedure}%
- \dbox{\procedure{$\adv(\secparam, \pk, c)$}{%
-  	 \text{Step 1}  \\
-  	 \text{Step 2}  \\
-	 \pcreturn m_0, m_1 }}
-  \end{subprocedure}  \\
-   c \sample \enc(\pk,m_b)  \\
-   b' \sample \adv(\secparam, \pk, c)  \\
-   \pcreturn b = b' }
- \end{center}
- 
-To create a subprocedure use the \emph{subprocedure} environment. The above example is generated via
- \begin{lstlisting}
-\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
-   b \sample \bin  \\
-   (\pk,\sk) \sample \kgen(\secparam)  \\
-   (m_0,m_1) \sample \begin{subprocedure}%
- \dbox{\procedure{$\adv(\secparam, \pk, c)$}{%
-  	 \text{Step 1}  \\
-  	 \text{Step 2}  \\
-	 \pcreturn m_0, m_1 }}
-  \end{subprocedure}  \\
-   c \sample \enc(\pk,m_b)  \\
-   b' \sample \adv(\secparam, \pk, c)  \\
-   \pcreturn b = b' }
-\end{lstlisting}
-Here the dbox command (from the dashbox package) is used to generate a dashed box around the sub procedure. 
-
-\subsection{Numbering in Subprocedures}
-Subprocedures as normal pseudocode allow you to create line numbers. By default the line numbering starts with 1 in a subprocedure while
-ensuring that the outer numbering remains intact. Also note that the linenumbering on the outer procedure in the above example is inherited
-by the subprocedure. For more control, either use manual numbering or set the option \enquote{linenumbering=off} on the subprocedure.
-
-\begin{center}
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \begin{subprocedure}%
- \dbox{\procedure{$\adv(\secparam, \pk, c)$}{%
-  	\pcln \text{Step 1}  \\
-  	\pcln \text{Step 2}  \\
-	\pcln \pcreturn m_0, m_1 }}
-  \end{subprocedure}  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
- \end{center}
-  \begin{lstlisting}
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \begin{subprocedure}%
-  \dbox{\procedure{$\adv(\secparam, \pk, c)$}{%
-  	\pcln \text{Step 1}  \\
-  	\pcln \text{Step 2}  \\
-	\pcln \pcreturn m_0, m_1 }}
-  \end{subprocedure}  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-\end{lstlisting}
-
-
-\section{Stacking Procedures}
-You can stack procedures horizontally or vertically using the environments \enquote{pchstack} and \enquote{pcvstack}. 
-\begin{lstlisting}
-\begin{pchstack}[center] body \end{pchstack}
-\begin{pcvstack}[center] body \end{pcvstack}
-\end{lstlisting}
-
-The following example displays two procedures next to one another. As a spacing between two horizontally outlined procedures
-use \lstinline{\pchspace} which takes an optional length as a parameter.
-
-\begin{pchstack}[center]
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-
-\pchspace
-
- \procedure{Oracle $O$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-\end{pchstack}
-
-\begin{lstlisting}
-\begin{pchstack}[center]
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-
-\pchspace
-
- \procedure{Oracle $O$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-\end{pchstack}
-\end{lstlisting}
-
-
-Similarly you can stack two procedures vertically using the \enquote{pcvstack} environment. As a spacing between two vertically stacked procedures
-use \lstinline{\pcvspace} which takes an optional length as a parameter.
-
-
-\begin{pcvstack}[center]
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-
-\pcvspace
-
- \procedure{Oracle $O$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-\end{pcvstack}
-
-
-\begin{lstlisting}
-\begin{pcvstack}[center]
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-
-\pcvspace
-
- \procedure{Oracle $O$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-\end{pcvstack}
-\end{lstlisting}
-
-
-Horizontal and vertical stacking can be combined
-\begin{pchstack}[center]
-
-\begin{pcvstack}%
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^{O,H_1,H_2}(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-
-\pcvspace
-
-\begin{pchstack}
- \procedure{Oracle $O$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-
- \procedure{Oracle $H_1$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-
- \procedure{Oracle $H_2$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-\end{pchstack}
-\end{pcvstack}
-
-\pchspace
-
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-
-\end{pchstack}
-
-
-\begin{lstlisting}
-\begin{pchstack}[center]
-\begin{pcvstack}
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^{O,H_1,H_2}(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-
-\pcvspace
-
-\begin{pchstack}
- \procedure{Oracle $O$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-
- \procedure{Oracle $H_1$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-
- \procedure{Oracle $H_2$}{%
-  \pcln  \text{line 1}  \\
-  \pcln  \text{line 2}  
-}
-\end{pchstack}
-\end{pcvstack}
-
-\pchspace
-
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-
-\end{pchstack}
-\end{lstlisting}
-
-\section{Divisions and Linebreaks}
-\index{linebreaks}
-\index{\textbackslash hline}
-Within the pseudocode command you generate linebreaks as \lstinline$\\$. In order to specify the linewidth you can add an optional argument
-\begin{lstlisting}
-\\[height]
-\end{lstlisting}
-Furthermore, you can add, for example a horizontal line by using the second optional argument and write
-\begin{lstlisting}
-\\[][\hline]
-\end{lstlisting}
-
-\begin{center}
-\fbox{
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\[2\baselineskip][\hline\hline]
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-}
-\end{center}
-
-\begin{lstlisting}
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\[2\baselineskip][\hline\hline]
-  \pcln  (\pk,\sk) \sample \kgen(\secparam)  \\
-  \pcln  (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c)  \\
- \pcln   \pcreturn b = b' }
-\end{lstlisting}
-
-\section{Matrices and Math Environments within pseudocode}
-
-In order to work its magic, cryptocode (in particular within the \lstinline{\pseudocode} command) mingles with a few low level commands such as
-\lstinline{\\} or \lstinline{\halign}. The effect of this is, that when you use certain math environments, for example, to create matrices, within pseudocode
-the result may be unexpected. Consider the following example
-
-\begin{lstlisting}
-\pseudocode{
-\text{compute } P = \begin{pmatrix}
-    A \\ B + C
-\end{pmatrix}
-}
-\end{lstlisting}
-
-which, somewhat unexpectedly, yields
-
-\begin{center}
-\fbox{
-\pseudocode{
-\text{compute } P = \begin{pmatrix}
-    A \\ B + C
-\end{pmatrix}
-}
-}
-\end{center}
-
-That is, the alignment is somewhat off. In order, to allow for the \emph{pmatrix} environment to properly work without interference from \lstinline{\pseudocode}
-you can wrap it into a \emph{pcmbox} environment (where pcmbox is short for pseudocode math box). This ensures that the low-level changes introduced by  \lstinline{\pseudocode} are not active.
-
-\begin{lstlisting}
-\pseudocode{
-\text{compute } P = \begin{pcmbox}\begin{pmatrix}
-    A \\ B + C
-\end{pmatrix}\end{pcmbox}
-}
-\end{lstlisting}
-
-\begin{center}
-\fbox{
-\pseudocode{
-\text{compute } P = \begin{pcmbox}\begin{pmatrix}
-    A \\ B + C
-\end{pmatrix}\end{pcmbox}
-}
-}
-\end{center}
-
-
-\section{Fancy Code with Overlays}
-
-Consider the \indcpa\ game. Here we have a single adversary $\adv$ that is called twice, first to output two messages then
-given the ciphertext of one of the messages to \enquote{guess} which one was encrypted. Often this is not visualized.
-Sometimes an additional state $\state$ is passed as we have in the following example on the left. On the right,
-we visualize the same thing in a bit more fancy way.
-
-\begin{center}
-
-\pchstack{
-
-\procedure{$\indcpa_\enc^\adv$}{%
-  \pcln  b \sample \bin  \\
-  \pcln  (\pk,\sk) \sample \kgen (\secparam)  \\
-  \pcln  (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start}  \\
- \pcln   c \sample \enc(\pk,m_b)  \\
- \pcln   b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end} \\
- \pcln   \pcreturn b = b' }
-
-
-\pchspace[1cm]
-
-\begin{pcimage}
-\procedure{$\indcpa_\enc^\adv$}{%
-	\pcln  b \sample \bin  \\
-	\pcln  (\pk,\sk) \sample \kgen (\secparam)  \\
-	\pcln  (m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start}  \\
-	\pcln   c \sample \enc(\pk,m_b)  \\
-	\pcln   b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end} \\
-	\pcln   \pcreturn b = b' }
-	
-\pcdraw{
-	\path[->] (start) edge[bend left=50] node[right]{$\state$} (start|-end);
-}
-\end{pcimage}
-
-}
-\end{center}
-
-The image on the right is generated by:
-\begin{lstlisting}
-\begin{pcimage}
-\procedure{$\indcpa_\enc^\adv$}{%
-	\pcln  b \sample \bin  \\
-	\pcln  (\pk,\sk) \sample \kgen (\secparam)  \\
-	\pcln  (m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start}  \\
-	\pcln   c \sample \enc(\pk,m_b)  \\
-	\pcln   b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end} \\
-	\pcln   \pcreturn b = b' }
-	
-\pcdraw{
-	\path[->] (start) edge[bend left=50] node[right]{$\state$} (start|-end);
-}
-\end{pcimage}
-\end{lstlisting}
-
-In order to achieve the above effect cryptocode utilizes TIKZ underneath. The
-\lstinline$pcnode$ command generates TIKZ nodes and additionally we wrapped the 
-pseudocode (or procedure) command in an \lstinline$\begin{pcimage}\end{pcimage}$ environment
-which allows us to utilize these nodes later, for example using the  \lstinline$\pcdraw$
-command. We can achieve a similar effect without an additional pcimage environment as
-
-\begin{lstlisting}
-\procedure{$\indcpa_\enc^\adv$}{%
-	\pcln  b \sample \bin  \\
-	\pcln  (\pk,\sk) \sample \kgen (\secparam)  \\
-	\pcln  (m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start}  \\
-	\pcln   c \sample \enc(\pk,m_b)  \\
-	\pcln   b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end}[draw={
-		\path[->] (start) edge[bend left=50] node[right]{$\state$} (start|-end);
-	}] \\
-	\pcln   \pcreturn b = b' }
-\end{lstlisting}
-
-\pagebreak
-\subsection{Example: Explain your Code}
-As an exmaple of what you can do with this, let us put an explanation to a line of the code.
-
-\begin{center}
-\begin{pcimage}
-\procedure{$\indcpa_\enc^\adv$}{%
-	\pcln  b \sample \bin  \\
-	\pcln  (\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen}  \\
-	\pcln  (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-	\pcln   c \sample \enc(\pk,m_b)  \\
-	\pcln   b' \sample \adv(\secparam, \pk, c, \state) \\
-	\pcln   \pcreturn b = b' }
-
-\pcdraw{
-  \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
-      at ([shift={(+3,+1)}]kgen) {
-		\begin{varwidth}{3cm}
-			$\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
-		\end{varwidth}
-  };
-}
-\end{pcimage}
-\end{center}
-
-\begin{lstlisting}
-\begin{center}
-\begin{pcimage}
-\procedure{$\indcpa_\enc^\adv$}{%
-	\pcln  b \sample \bin  \\
-	\pcln  (\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen}  \\
-	\pcln  (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
-	\pcln   c \sample \enc(\pk,m_b)  \\
-	\pcln   b' \sample \adv(\secparam, \pk, c, \state) \\
-	\pcln   \pcreturn b = b' }
-
-\pcdraw{
-  \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
-      at ([shift={(+3,+1)}]kgen) {
-		\begin{varwidth}{3cm}
-			$\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
-		\end{varwidth}
-  };
-}
-\end{pcimage}
-\end{center}
-\end{lstlisting}
-
-
-\chapter{Tabbing Mode}
-\label{chap:tabbing}
-\index{\&}
-\index{Tabbing Mode}
-\index{\textbackslash $"<$}
-\index{\textbackslash $">$}
-In the following chapter we discuss how to create multiple columns within a \lstinline$pseudocode$ command.
-Within a \lstinline$pseudocode$ command you can switch to a new column by inserting a \lstinline$\>$. 
-This is similar to using an \lstinline$align$ environment and placing a tabbing character (\&). Also,
-similarly to using \lstinline$align$ you should ensure that the number of \lstinline$\>$ are identical
-on each line.
-\begin{center}
-\fbox{%
-\pseudocode{%
- \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
-  b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
-}
-\end{center}
-\begin{lstlisting}
-\pseudocode{%
- \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
-  b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
-\end{lstlisting}
-As you can see the first column is left aligned the second right, the third left and so forth.
-In order to get only left aligned columns you could thus simply always skip a column by
-using \lstinline$\>\>$. You can also use \lstinline$\<$ a shorthand for \lstinline$\>\>$.
-\begin{center}
-\fbox{%
-\pseudocode{%
- \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
-  b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
-}
-\end{center}
-\begin{lstlisting}
-\pseudocode{%
- \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
-  b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
-\end{lstlisting}
-
-\paragraph{Column Spacing}
-\index{colsep}
-\index{addtolength}
-You can control the space between columns using the option \enquote{colsep=2em}. Note that when doing so you should
-additionally use \enquote{addtolength=5em} (where 5em depends on the number of columns) in order to avoid having
-overfull hboxes.
-\begin{center}
-\fbox{%
-\pseudocode[colsep=1em,addtolength=10em]{%
- \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
-  b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
-}
-\end{center}
-\begin{lstlisting}
-\pseudocode{%
-\pseudocode[colsep=1em,addtolength=10em]{%
- \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
-  b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
-\end{lstlisting}
-
-This is basically all you need to know in order to go on to writing protocols with the
-cryptocode package. So unless you want to know a bit more about tabbing (switching columns)
-and learn some of the internals, feel free to proceed to Chapter~\ref{chap:protocols}.
-
-
-\section{Tabbing in Detail}
-At the heart of the pseudocode package is an align (or rather a flalign*) environment which allows you to use basic math writing. Usually an align (or flalign) environment uses \& as tabbing characters. The pseudocode comes in two modes the first of which changes the default align behavior. That is, it automatically adds a tabbing character to the beginning and end of each line and changes the tabbing character to \lstinline$\>$. This mode is called mintabmode and is active by default.
-
-In mintabmode in order to make use of extra columns in the align environment (which we will use shortly in order to write protocols) you can use \lstinline$\>$ as you would use \& normally. But, don't forget that there is an alignment tab already placed at the beginning and end of each line. So the following example
-\begin{center}
-\fbox{%
-\pseudocode{%
- \textbf{Alice} \> \> \textbf{Bob}  \\
- b \sample \bin \> \> \\
- \> \xrightarrow{\text{send over } b} \>  \\
- \> \> \text{do something}}
-}
-\end{center}
-is generated by
-\begin{lstlisting}
-\pseudocode{%
- \textbf{Alice} \> \> \textbf{Bob}  \\
- b \sample \bin \> \> \\
- \> \xrightarrow{\text{send over } b} \>  \\
- \> \> \text{do something}}
-\end{lstlisting}
-
-In Chapter~\ref{chap:protocols} we'll discuss how to write protocols in detail.
-The next two sections are rather technical, so feel free to skip them.
-
-
-\subsection{Overriding The Tabbing Character}
-\index{\textbackslash pctabname}
-If you don't like \lstinline$\>$ as the tabbing character you can choose a custom command by overwriting \lstinline$\pctabname$.
-For example
-\begin{lstlisting}
-\renewcommand{\pctabname}{\myTab}
-
-\pseudocode{%
- \textbf{Alice} \myTab \myTab \textbf{Bob}  \\
- b \sample \bin \myTab \myTab \\
- \myTab \xrightarrow{\text{send over } b} \myTab  \\
- \myTab \myTab \text{do something}}
-\end{lstlisting}
-
-\subsection{Custom Line Spacing and Horizontal Rules}
-\index{\textbackslash pclb}
-As explained underlying the pseudocode command is an flalign environment. This would allow the use
-of \lstinline$\\[spacing]$ to specifiy the spacing between two lines or of \lstinline$[\\\hline]$ 
-to insert a horizontal rule. In order to achieve the same effect within the pseudocode command you
-can use \lstinline$\\[spacing][\hline]$. You can also use \lstinline$\pclb$ to get a line break which
-does not insert the additional alignment characters. 
-
-\chapter{Protocols}
-\label{chap:protocols}
-
-The pseudocode package can also be used to write protocols such as
-\begin{center}
-\fbox{%
-\procedure{My Protocol}{%
- \textbf{Alice} \> \> \textbf{Bob}  \\
- b \sample \bin \> \> \\
- \> \xrightarrow{\text{send over } b} \>  \\
- \> \> \text{do something}    \\
- \> \xleftarrow{\text{send over sth. else}} \>   \\
- \text{finalize} \> \>}
- }
-\end{center}
-which uses the tabbing feature of align and is generated as
-\begin{lstlisting}
-\procedure{My Protocol}{%
- \textbf{Alice} \> \> \textbf{Bob}  \\
- b \sample \bin \> \> \\
- \> \xrightarrow{\text{send over } b} \>  \\
- \> \> \text{do something}    \\
- \> \xleftarrow{\text{send over sth. else}} \>   \\
- \text{finalize} \> \>}
-}
-\end{lstlisting}
-
-\index{\textbackslash sendmessageright*}
-\index{\textbackslash sendmessageright}
-\index{\textbackslash sendmessageleft*}
-\index{\textbackslash sendmessageleft}
-In order to get nicer message arrows use the commands \lstinline$\sendmessageright*{message}$ and \lstinline$\sendmessageleft*{message}$.
-Both take an additional optional argument specifying the length of the arrow and both are run
-in math mode.
-\begin{lstlisting}
-\sendmessageright*[3.5cm]{message}
-\sendmessageleft*[3.5cm]{message}
-\end{lstlisting}
-
-
-\begin{center}
-\fbox{%
-\procedure{My Protocol}{%
- \textbf{Alice} \> \> \textbf{Bob}  \\
- b \sample \bin \> \> \\
- \> \sendmessageright*{\text{send over } b} \>  \\
- \> \> \text{do something}    \\
- \> \sendmessageleft*{\text{send over sth. else}} \>   \\
- \text{finalize} \> \> }
- }
-\end{center}
-\begin{lstlisting}
-\procedure{My Protocol}{%
- \textbf{Alice} \> \> \textbf{Bob}  \\
- b \sample \bin \> \> \\
- \> \sendmessageright*{\text{send over } b} \>  \\
- \> \> \text{do something}    \\
- \> \sendmessageleft*{\text{send over sth. else}} \>   \\
- \text{finalize} \> \> }
-\end{lstlisting}
-
-Besides the starred version there is also the unstarred version which allows more flexibility. Note that a crucial difference between
-the starred and unstarred versions are that  \lstinline$\sendmessageleft*{message}$ wraps an aligned environment around the message.
-\begin{center}
-\procedure{My Protocol}{%
- \textbf{Alice} \> \> \textbf{Bob}  \\
- b \sample \bin \> \> \\
- \> \sendmessageright{centercol=3,top=send over $b$,bottom=Text below,topstyle={draw,solid,yshift=0.25cm},style={dashed}} \>  \\
- \> \> \text{do something}    \\
- \> \sendmessageleft{length=8cm,top=send over sth. else} \>   \\
- \text{finalize} \> \> }
-\end{center}
-\begin{lstlisting}
-\procedure{My Protocol}{%
- \textbf{Alice} \> \> \textbf{Bob}  \\
- b \sample \bin \> \> \\
- \> \sendmessageright{centercol=3,top=send over $b$,bottom=Text below,topstyle={draw,solid,yshift=0.25cm},style={dashed}} \>  \\
- \> \> \text{do something}    \\
- \> \sendmessageleft{length=8cm,top=send over sth. else} \>   \\
- \text{finalize} \> \> }
-\end{lstlisting}
-The unstarred commands take key-value pairs. The following keys are available:
-\begin{description}
-\item[top]
-The content to display on top of the arrow. 
-\item[bottom]
-The content to display below the arrow.
-\item[left]
-The content to display on the left of the arrow.
-\item[right]
-The content to display on the right of the arrow.
-\item[topstyle]
-The TIKZ style to be used for the top node.
-\item[bottomstyle]
-The TIKZ style to be used for the bottom node.
-\item[rightstyle]
-The TIKZ style to be used for the right node.
-\item[leftstyle]
-The TIKZ style to be used for the left node.
-\item[length]
-The length of the arrow.
-\item[style]
-The style of the arrow.
-\item[width]
-The width of the column
-\item[centercol]
-Can be used to ensure that the message is displayed in the center. This should be set to the
-column index. In the above example, the message column is the third column (note that there is
-a column left of alice that  is automatically inserted.).
-\end{description}
-
-
-\section{Tabbing}
-When typesetting protocols you might find that using two tabs instead of a single tab usually provides
-a better result as this ensures that all columns are left aligned. 
-For this you can use \lstinline$\<$ instead of \lstinline$\>$ (see Chapter~\ref{chap:tabbing}).
-
-Following is once more the example from before but now with double tapping. 
-\begin{center}
-\fbox{%
-\procedure{My Protocol}{%
- \textbf{Alice} \< \< \textbf{Bob}  \\
- b \sample \bin \< \< \\
- \< \sendmessageright*{\text{send over } b} \<  \\
- \< \< \text{do something}    \\
- \< \sendmessageleft*{\text{send over sth. else}} \<   \\
- \text{finalize} \< \< }
- }
-\end{center}
-
-\section{Multiline Messages}
-Using the send message commands you can easily generate multiline messages as the command
-wraps an \emph{aligned} environment around the message.
-\begin{center}
-\fbox{%
-\procedure{My Protocol}{%
- \textbf{Alice} \< \< \textbf{Bob}  \\
- b \sample \bin \< \< \\
- \< \sendmessageright*{\text{send over } b\\ \text{second line}} \<  \\
- \< \< \text{do something}    \\
- \< \sendmessageleft*{&\text{left aligned}\\ &\text{multiline message}} \<   \\
- \text{finalize} \< \<}
- }
-\end{center}
-\begin{lstlisting}
-\procedure{My Protocol}{%
- \textbf{Alice} \< \< \textbf{Bob}  \\
- b \sample \bin \< \< \\
- \< \sendmessageright*{\text{send over } b\\ \text{second line}} \<  \\
- \< \< \text{do something}    \\
- \< \sendmessageleft*{&\text{left aligned}\\ &\text{multiline message}} \<   \\
- \text{finalize} \< \<}
-\end{lstlisting}
-
-
-
-\subsection{Multiplayer Protocols}
-
-You are not limited to two players. In order to send messages skipping players use \lstinline$\sendmessagerightx$ and \lstinline$\sendmessageleftx$.
-\begin{lstlisting}
-\sendmessagerightx[width]{columnspan}{Text}
-\sendmessageleftx[width]{columnspan}{Text}
-\end{lstlisting}
-
-\begin{center}
-\fbox{%
-\procedure{Multiparty Protocol}{%
- \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\
- \text{work} \< \< \< \< \\
- \< \sendmessageright{top=Work result} \< \< \< \\
- \< \< \text{work} \< \< \\
- \< \< \<  \sendmessageright{top=Work result,bottom=Bottom message} \< \\
- \< \<  \< \< \text{work} \\
- \< \sendmessageleftx[7cm]{8}{\text{A long message for Alice}} \< \\
- \text{finalize} \< \< \< \< }
-}
-\end{center}
-
-\begin{lstlisting}
-\begin{center}
-\procedure{Multiparty Protocol}{%
- \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\
- \text{work} \< \< \< \< \\
- \< \sendmessageright{top=Work result} \< \< \< \\
- \< \< \text{work} \< \< \\
- \< \< \<  \sendmessageright{top=Work result,bottom=Bottom message} \< \\
- \< \<  \< \< \text{work} \\
- \< \sendmessageleftx[7cm]{8}{\text{A long message for Alice}} \< \\
- \text{finalize} \< \< \< \< }
-\end{lstlisting}
-Note that for the last message from Charlie to Alice we needed to specify the number of passed
-over colums (\lstinline$\sendmessageleftx[7cm]{8}{message}$). As we were passing
-4 \lstinline$\<$ where each creates 2 columns, the total was 8 columns.
-
-
-\subsection{Divisions}
-You can use \lstinline$\pcintertext$ in order to divide protocols (or other pseudocode for that matter).
-\begin{lstlisting}
-\pcintertext[dotted|center]{Division Text}
-\end{lstlisting}
-Note that in order to use the \lstinline$\pcintertext$ you need to use \lstinline$\pclb$ as the line break for the line
-before. Also see Chapter~\ref{chap:tabbing}.
-
-\begin{center}
-\fbox{%
-\procedure{My Protocol}{%
-\textbf{Alice} \< \< \textbf{Bob}  \\
- b \sample \bin \< \<  \pclb
- \pcintertext[dotted]{Some Division} \\
- \< \sendmessageright*{\text{send over } b} \<  \\
- \< \< \text{do something} \pclb
- \pcintertext[dotted]{Another Division} \\
- \< \sendmessageleft*{\text{message}} \<   \\
- \text{finalize} \< \< }
-}
-\end{center}
-
-\begin{lstlisting}
-\procedure{My Protocol}{%
-\textbf{Alice} \< \< \textbf{Bob}  \\
- b \sample \bin \< \<  \pclb
- \pcintertext[dotted]{Some Division} \\
- \< \sendmessageright*{\text{send over } b} \<  \\
- \< \< \text{do something} \pclb
- \pcintertext[dotted]{Another Division} \\
- \< \sendmessageleft*{\text{message}} \<   \\
- \text{finalize} \< \< }
-\end{lstlisting}
-
-
-
-\section{Line Numbering in Protocols}
-Protocols can be numbered similarly to plain pseudocode. Additionally to the \lstinline$\pcln$ there are the commands \lstinline$\pclnr$ and \lstinline$\pcrln$. The first
-allows you to right align line numbers but uses the same counter as \lstinline$\pcln$. The second uses a different counter.
-
-\begin{center}
-\fbox{%
-\procedure{My Protocol}{%
-\pcln  \textbf{Alice} \< \< \textbf{Bob} \< \\
-\pcln b \sample \bin \< \< \< \\
- \< \sendmessageright*{\text{send over } b} \< \< \pclnr\\
- \< \< \text{do something} \<  \pclnr \\
- \< \sendmessageleft*{\text{send over sth. else}} \<\<  \pclnr \\
-\pcln \text{finalize} \< \< \<}
-}
-\end{center}
-Which is generated as
-\begin{lstlisting}
-\procedure{My Protocol}{%
-\pcln  \textbf{Alice} \< \< \textbf{Bob} \< \\
-\pcln b \sample \bin \< \< \< \\
- \< \sendmessageright*{\text{send over } b} \< \< \pclnr\\
- \< \< \text{do something} \<  \pclnr \\
- \< \sendmessageleft*{\text{send over sth. else}} \<\<  \pclnr \\
-\pcln \text{finalize} \< \< \<}
-\end{lstlisting}
-
-
-
-And using \lstinline$\pcrln$:
-\begin{center}
-\fbox{%
-\procedure{My Protocol}{%
-\pcln  \textbf{Alice} \< \< \textbf{Bob} \<  \\
-\pcln b \sample \bin \< \< \< \\
- \< \sendmessageright*{\text{send over } b} \<\<  \pcrln\\
- \< \< \text{do something}   \< \pcrln \\
- \< \sendmessageleft*{\text{send over sth. else}} \<  \< \pcrln \\
-\pcln \text{finalize} \< \< \< }
-}
-\end{center}
-Which is generated as
-\begin{lstlisting}
-\procedure{My Protocol}{%
-\pcln  \textbf{Alice} \< \< \textbf{Bob}  \\
-\pcln b \sample \bin \< \< \\
-\< \sendmessageright*{\text{send over } b} \<  \pcrln\\
-\< \< \text{do something}   \pcrln \\
-\< \sendmessageleft*{\text{send over sth. else}} \<  \pcrln \\
-\pcln \text{finalize} \< \< }
-\end{lstlisting}
-
-
-
-
-\subsection{Separators}
-\label{sec:protocol:separator}
-The commands \lstinline$\pclnseparator$ and \lstinline$\pcrlnseparator$ define the separators between the pseudocode and line numbering. By default the left separator is set to (:) colon and the right separator is set to a space of 3 pt.
-
-
-\section{Sub Protocols}
-
-Use the \enquote{subprocedure} function also to create sub protocols. 
-
-\begin{center}
-\fbox{%
-\procedure{My Protocol}{%
- \textbf{Alice} \< \< \textbf{Bob}  \\
- b \sample \bin \< \< \\
- \< \sendmessageright*{\text{send over } b} \<  \\
- \< \< \text{do something}    \\
- \<\< \dbox{\begin{subprocedure}\procedure{Subprotocol}{
- \< \< \textbf{Charlie}  \\
-\text{something more} \< \<  \\
- \< \sendmessageright*[1.5cm]{\text{message}} \<  \\
- \< \< \text{some processing}  \\
- \< \< \text{more processing}  \\ 
- \< \sendmessageleft*[1.5cm]{\text{message}} \<  \\
- \< \sendmessageright*[1.5cm]{\text{message}} \<  \\
- \< \sendmessageleft*[1.5cm]{\text{message}} \<  \\
-}\end{subprocedure}}  \\
- \< \sendmessageleft*{\text{send over sth. else}} \<   \\
- \text{finalize} \< \< }
-}
-\end{center}
-
-
-\begin{lstlisting}
-\procedure{My Protocol}{%
- \textbf{Alice} \< \< \textbf{Bob}  \\
- b \sample \bin \< \< \\
- \< \sendmessageright*{\text{send over } b} \<  \\
- \< \< \text{do something}    \\
- \<\< \dbox{\begin{subprocedure}\procedure{Subprotocol}{
- \< \< \textbf{Charlie}  \\
-\text{something more} \< \<  \\
- \< \sendmessageright*[1.5cm]{\text{message}} \<  \\
- \< \< \text{some processing}  \\
- \< \< \text{more processing}  \\ 
- \< \sendmessageleft*[1.5cm]{\text{message}} \<  \\
- \< \sendmessageright*[1.5cm]{\text{message}} \<  \\
- \< \sendmessageleft*[1.5cm]{\text{message}} \<  \\
-}\end{subprocedure}}  \\
- \< \sendmessageleft*{\text{send over sth. else}} \<   \\
- \text{finalize} \< \< }
-\end{lstlisting}
-
-
-
-
-
-
-\chapter{Game Based Proofs}
-\label{chap:gbproofs}
-
-\section{Basics}
-\index{gameproof}
-\index{gameprocedure}
-
-Besides displaying pseudocode the package also comes with commands to display game based proofs. A proof
-is wrapped in the \emph{gameproof} environment. 
-\begin{lstlisting}
-\begin{gameproof}
-proof goes here
-\end{gameproof}
-\end{lstlisting}
-Within the proof environment you can use the command \lstinline$\gameprocedure$ which works similarly to the pseudocode
-command and produces a heading of the form $\pcgamename_{\text{counter}}$ where counter is a consecutive counter.
-Thus, we can create the following setup
-\begin{center}
-\begin{gameproof}
-\gameprocedure[linenumbering,mode=text]{%
- Step 1  \\
- Step 2  
- }
-\gameprocedure[mode=text]{%
- Step 1  \\
- Step 2  
- }
-\end{gameproof}
-\end{center}
-by using
-\begin{lstlisting}
-\begin{gameproof}
-\gameprocedure[linenumbering,mode=text]{%
- Step 1  \\
- Step 2  
- }
-\gameprocedure[mode=text]{%
- Step 1  \\
- Step 2  
- }
-\end{gameproof}
-\end{lstlisting}
-
-
-
-\subsection{Highlight Changes}
-\index{highlight game change}
-\index{\textbackslash gamechange}
-In order to highlight changes from one game to the next use \lstinline$\gamechange$.
-\begin{center}
-\begin{gameproof}
-\gameprocedure[linenumbering,mode=text]{%
- Step 1  \\
- Step 2  
- }
-\gameprocedure[mode=text]{%
- Step 1  \\
- \gamechange{Step 2}
- }
-\end{gameproof}
-\end{center}
-\begin{lstlisting}
-\begin{gameproof}
-\gameprocedure[linenumbering,mode=text]{%
- Step 1  \\
- Step 2  
- }
-\gameprocedure[mode=text]{%
- Step 1  \\
- \gamechange{Step 2}
- }
-\end{gameproof}
-\end{lstlisting}
-
-\subsection{Boxed games}
-\index{\textbackslash tbxgameprocedure}
-Use \lstinline$\tbxgameprocedure$ in order to create two consecutive games where the second game is \emph{boxed}. Use
-\lstinline$\pcbox$ to create boxed statements.
-\begin{center}
-\begin{gameproof}
-\gameprocedure{%
- \pcln  \text{Step 1}  \\
- \pcln  \text{Step 2}  
- }
-\tbxgameprocedure{%
-   \text{Step 1}; \pcbox{\text{Alternative step 1}}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
-\gameprocedure{%
-  \text{Step 1}  \\
-  \text{\gamechange{Step 2}}  
- } 
-\end{gameproof}
-\end{center}
-
-\begin{lstlisting}
-\begin{gameproof}
-\gameprocedure{%
- \pcln  \text{Step 1}  \\
- \pcln  \text{Step 2}  
- }
-\tbxgameprocedure{%
-   \text{Step 1}; \pcbox{\text{Alternative step 1}}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
-\gameprocedure{%
- \pcln  \text{Step 1}  \\
- \pcln  \text{\gamechange{Step 2}}  
- } 
-\end{gameproof}
-\end{lstlisting}
-
-\subsection{Reduction Hints}
-\index{\textbackslash addgamehop}
-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
-the difference between two games is bound by the security of some pseudorandom generator $\mathsf{PRG}$. To give a hint
-within the pseudocode that the difference between two games is down to ``something'' you can use the \lstinline$\addgamehop$
-command.
-\begin{lstlisting}
-\addgamehop{startgame}{endgame}{options}
-\end{lstlisting}
-Here options allows you to specify the hint as well as the style. The following options are available
-\begin{description}
-\item[hint]
-The hint text
-\item[nodestyle]
-A TIKZ style to be used for the node.
-\item[pathstyle]
-A TIKZ style to be used for the path.
-\item[edgestyle]
-A TIKZ style to be used for the edge. This defaults to \enquote{bend left}.
-\end{description}
-
-\vspace{1ex}
-\begin{center}
-\begin{gameproof}
-\gameprocedure{%
- \pcln  \text{Step 1}  \\
- \pcln  \text{Step 2}  
- }
-\gameprocedure{%
-   \text{Step 1}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
-\addgamehop{1}{2}{hint=\footnotesize some hint,nodestyle=red}
-\end{gameproof}
-\end{center}
-\begin{lstlisting}
-\begin{gameproof}
-\gameprocedure{%
- \pcln  \text{Step 1}  \\
- \pcln  \text{Step 2}  
- }
-\gameprocedure{%
-   \text{Step 1}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
-\addgamehop{1}{2}{hint=\footnotesize some hint,nodestyle=red}
-\end{gameproof}
-\end{lstlisting}
-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
-use 
-\begin{lstlisting}
-\addgamehop{1}{2}{hint=\footnotesize some hint,edgestyle=}
-\end{lstlisting}
-
-
-
-If game proofs do not fit into a single picture you can specify start and end hints using the commands
-\begin{lstlisting}
-\addstartgamehop[first game]{options}
-\addendgamehop[last game]{options}
-\end{lstlisting}
-
-\begin{center}
-\begin{gameproof}
-\gameprocedure{%
- \pcln  \text{Step 1}  \\
- \pcln  \text{Step 2}  
- }
-\gameprocedure{%
-   \text{Step 1}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
- \addstartgamehop{hint=\footnotesize some hint,edgestyle=}
-\addgamehop{1}{2}{hint=\footnotesize some hint}
- \addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
-\end{gameproof}
-\end{center}
-
-
-\begin{lstlisting}
-\begin{gameproof}
-\gameprocedure{%
- \pcln  \text{Step 1}  \\
- \pcln  \text{Step 2}  
- }
-\gameprocedure{%
-   \text{Step 1}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
- \addstartgamehop{hint=\footnotesize some hint,edgestyle=}
-\addgamehop{1}{2}{hint=\footnotesize some hint}
- \addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
-\end{gameproof}
-\end{lstlisting}
-
-\subsection{Numbering and Names}
-By default the \emph{gameproof} environment starts to count from 1 onwards. Its optional parameters allow you to specify a custom
-name for your game and the starting number.
-\begin{lstlisting}
-\begin{gameproof}[options]
-\end{lstlisting}
-
-\begin{center}
-\begin{gameproof}[nr=5,name=\mathsf{MyGame},arg=(1^n)]
-\gameprocedure{%
- \pcln  \text{Step 1}  \\
- \pcln  \text{Step 2}  
- }
-\gameprocedure{%
-   \text{Step 1}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
-\addstartgamehop{hint=\footnotesize some ingoing hint}
-\addgamehop{6}{7}{hint=\footnotesize some hint}
- \addendgamehop{hint=\footnotesize some outgoing hint}
-\end{gameproof}
-\end{center}
-
-\begin{lstlisting}
-\begin{gameproof}[nr=5,name=$\mathsf{MyGame}$,arg=$(1^n)$]
-\gameprocedure{%
- \pcln  \text{Step 1}  \\
- \pcln  \text{Step 2}  
- }
-\gameprocedure{%
-   \text{Step 1}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
-\addstartgamehop{hint=\footnotesize some ingoing hint}
-\addgamehop{6}{7}{hint=\footnotesize some hint}
- \addendgamehop{hint=\footnotesize some outgoing hint}
-\end{gameproof}
-\end{lstlisting}
-
-
-\subsection{Default Name and Argument}
-The default name and argument are controlled via the commands \lstinline$\pcgamename$ and \lstinline$\gameprocedurearg$.
-
-\begin{center}
-\begin{tabular}{ll}
-\textbf{Command} & \textbf{Default} \\
-\lstinline$\pcgamename$ & \lstinline$\mathsf{Game}$ \\
-\lstinline$\gameprocedurearg$ & \lstinline$(\secpar)$
-\end{tabular}
-\end{center}
-
-
-\subsection{Two Directional Games}
-\index{\textbackslash bxgameprocedure}
-\index{\textbackslash addloopgamehop}
-You can use the \lstinline$\bxgameprocedure$ to generate games for going in two directions. Use the \lstinline$\addloopgamehop$
-to add the gamehop in the middle.
-
-\vspace{1cm}
-\begin{center}
-\begin{gameproof}
-\bxgameprocedure{4}{%
- \pcln  \text{Step 1}; \pcbox{Alternative} \\
- \pcln  \text{Step 2}  
- }
-\bxgameprocedure{3}{%
-   \text{Step 1}; \pcbox{Alternative}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
- \addstartgamehop{hint=\footnotesize some hint,edgestyle=}
-\addgamehop{1}{2}{hint=\footnotesize some hint,edgestyle=}
- \addloopgamehop{hint=\footnotesize some loop hint}
- \addgamehop{2}{1}{hint=\footnotesize some hint}
-\end{gameproof}
-\end{center}
-
-
-\begin{lstlisting}
-\begin{gameproof}
-\bxgameprocedure{4}{%
- \pcln  \text{Step 1}; \pcbox{Alternative} \\
- \pcln  \text{Step 2}  
- }
-\bxgameprocedure{3}{%
-   \text{Step 1}; \pcbox{Alternative}  \\
-   \gamechange{\text{Step 2 is different}}  
- }
- \addstartgamehop{hint=\footnotesize some hint,edgestyle=}
-\addgamehop{1}{2}{hint=\footnotesize some hint,edgestyle=}
- \addloopgamehop{hint=\footnotesize some loop hint}
- \addgamehop{2}{1}{hint=\footnotesize some hint}
-\end{gameproof}
-\end{lstlisting}
-
-\subsection{Styling game procedures}
-It may come in handy to define default style arguments for the underlying pseudocode 
-command used by \lstinline$\gameprocedure$. For this you can
-define the default arguments by calling \lstinline{\setgameproceduredefaultstyle} to 
-for example:
-
-\begin{lstlisting}
-\setgameproceduredefaultstyle{beginline=\vphantom{\bin^\prg_\prg}
-\end{lstlisting}
-
-The default is to not set any options.
-
-\section{Game Descriptions}
-Cryptocode also comes with an environment to provide textual descriptions of games such as
-
-
- \begin{gamedescription}[name=MyGame,nr=2]
-\describegame
- 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.
-
-\describegame[inhint=reduction target]
- This is the second game. The arrow at the side indicates the reduction target.
- \end{gamedescription}
- 
- The above example is generated as
- 
-\begin{lstlisting}
-\begin{gamedescription}[name=MyGame,nr=2]
-\describegame
-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.
-
-\describegame[inhint=reduction target]
-This is the second game. The arrow at the side indicates the reduction target.
-\end{gamedescription}
-\end{lstlisting}
-
-The \emph{gamedescription} environment takes an optional argument to specify name and counter (defaults to Game and 0). The command 
-\lstinline$\describegame$ starts a new game description and can allows you to provide a reduction hint using the option parameter \emph{inhint}.
-
-\begin{center}
-\begin{tabular}{ll}
-\textbf{Parameter} & \textbf{Description} \\
-\lstinline$inhint$ & Displays an ingoing arrow to denote the reduction target for this game hop.\\
-\lstinline$length$ & Allows to control the length of the arrow. \\
-\lstinline$nodestyle$ & Allows to control the style of the node. \\
-\lstinline$hint$ &  Instead of having an ingoing arrow, this adds an outgoing arrow. \\
-\end{tabular}
-\end{center}
-
-
-\chapter{Black-box Reductions}
-\label{chap:bbr}
-\index{bbrenv}
-\index{bbrbox}
-\index{\textbackslash bbrinput}
-\index{\textbackslash bbroutput}
-
-The cryptocode package comes with support for drawing basic black box reductions. A reduction is
-always of the following form.
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-\begin{bbrbox}[name=Box Name]
-% The Box's content
-\end{bbrbox}
-% Commands to display communication, input output etc
-\end{bbrenv}
-\end{lstlisting}
-That is, a \enquote{bbrenv} (where bbr is short for black-box reduction) environment which takes a single
-\enquote{bbrbox} environment and some additional commands. 
-
-The following is a simple example drawing one (black)box with some code and input output:
-
-\begin{bbrenv}[1cm]{A}[1cm]
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-
-This box is generated as
-\begin{lstlisting}
-\begin{bbrenv}[1cm]{A}[1cm]
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-\end{lstlisting}
-
-The commands \lstinline$bbrinput$ and \lstinline$bbroutput$ allow to specify input and output for the latest
-\enquote{bbrenv} environment. The optional parameters for the \lstinline$bbrenv$ environment allow to specify leading and trailing space (this
-may become necessary when using inputs and outputs).
-The single argument to the bbrenv environment needs to specify a unique identifier
-(unique for the current reduction). This id is used as an internal TIKZ node name (\url{https://www.ctan.org/pkg/pgf}).
-\begin{lstlisting}
-\begin{bbrenv}[vspace before]{UNIQUE IDENTIFIER}[vspace after]
-\end{lstlisting}
-As we are drawing a TIKZ image, note that we can easily later customize the image using the labels that we
-have specified on the way. 
-
-\begin{bbrenv}[1cm]{A}[1cm]
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\filldraw[fill=blue] (A.north) circle (4pt);
-	\filldraw[fill=blue] (A.west) circle (4pt);
-	\filldraw[fill=blue] (A.east) circle (4pt);
-	\filldraw[fill=blue] (A.south) circle (4pt);
-\end{bbrenv}
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\filldraw[fill=blue] (A.north) circle (4pt);
-	\filldraw[fill=blue] (A.west) circle (4pt);
-	\filldraw[fill=blue] (A.east) circle (4pt);
-	\filldraw[fill=blue] (A.south) circle (4pt);
-\end{bbrenv}
-\end{lstlisting}
-
-The \enquote{bbrbox} takes as single argument a comma separated list of key value pairs. In the example we have used
-\begin{lstlisting}
-name=Box Name
-\end{lstlisting}
-to specify the label. The following options are available
-
-\index{namepos}
-\index{namestyle}
-\index{abovesep}
-\index{minheight}
-\index{xshift}
-\index{yshift}
-\begin{center}
-\begin{tabular}{ll}
-\textbf{Option} & \textbf{Description} \\ \hline
-name & Specifies the box's label \\
-namepos & Specifies the position (left, center, right, top left, top center, top right, middle) \\
-namestyle & Specifies the style of the name \\
-abovesep & Space above box (defaults to \lstinline$\baselineskip$) \\
-minheight & The minimal height \\
-addheight & Additional height at the end of the box \\
-xshift & Allows horizontal positioning \\
-yshift & Allows horizontal positioning \\
-style & allows to customize the node
-\end{tabular}
-\end{center}
-
-
-\section{Nesting of Boxes}
-Boxes can be nested. For this simply insert a bbrenv (together with a single bbrbox) environment into an
-existing bbrbox.
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Inner Box]
-		\pseudocode{
-			\text{inner step 1} \\
-			\text{inner step 2} 
-		}
-		\end{bbrbox}
-	\end{bbrenv}
-
-	\pseudocode{
-		\text{step 4} \\
-		\text{step 5} 
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Inner Box]
-		\pseudocode{
-			\text{inner step 1} \\
-			\text{inner step 2} 
-		}
-		\end{bbrbox}
-	\end{bbrenv}
-
-	\pseudocode{
-		\text{step 4} \\
-		\text{step 5} 
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-\end{lstlisting}
-
-\section{Messages and Queries}
-\index{\textbackslash bbrmsgto}
-\index{\textbackslash bbrmsgfrom}
-\index{\textbackslash bbrqryto}
-\index{\textbackslash bbrqryfrom}
-
-You can send messages and queries to boxes. For this use the commands 
-\begin{lstlisting}
-\bbrmsgto{options}
-\bbrmsgfrom{options}
-\bbrqryto{options}
-\bbrqryfrom{options}
-\end{lstlisting}
-By convention messages are on the left of boxes and queries on the right. Commands ending on to
-make an arrow to the right while commands ending on from make an arrow to the left. The \emph{options}
-define how the message is drawn and consists of a key-value pairs separated by \enquote{,}.
-
-For example, to draw a message with a label on top and on the side use
-\begin{lstlisting}
-\bbrmsgto{top=Top Label, side=Side Label}
-\end{lstlisting}
-If your label contains a \enquote{,} (comma), then group the label in $\{\}$ (curly brackets).
-\begin{lstlisting}
-\bbrmsgto{top=Top Label, side={Side, Label}}
-\end{lstlisting}
-
-Following is a complete example. Notice that cryptocode takes care of the vertical positioning.
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Inner Box]
-		\pseudocode{
-			\text{inner step 1} \\
-			\text{inner step 2} 
-		}
-		\end{bbrbox}
-		
-		\bbrmsgto{top={$m_0,m_1$}}
-		\bbrmsgfrom{top=$q$}
-
-
-		\bbrqryto{top={$m_0,m_1$}}
-		\bbrqryfrom{top=$q$}
-
-	\end{bbrenv}
-
-	\pseudocode{
-		\text{step 4} \\
-		\text{step 5} 
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Inner Box]
-		\pseudocode{
-			\text{inner step 1} \\
-			\text{inner step 2} 
-		}
-		\end{bbrbox}
-		
-		\bbrmsgto{top={$m_0,m_1$}}
-		\bbrmsgfrom{top=$q$}
-
-
-		\bbrqryto{top={$m_0,m_1$}}
-		\bbrqryfrom{top=$q$}
-
-	\end{bbrenv}
-
-	\pseudocode{
-		\text{step 4} \\
-		\text{step 5} 
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-\end{lstlisting}
-
-\subsection{Options}
-Besides specifying labels for top, side and bottom you can further specify how cryptocode renders the message.
-Remember that underneath the reduction commands is a TIKZ image (\url{https://www.ctan.org/pkg/pgf/}).
-For each label position (top, side, bottom) a node is generated. You can provide additional properties for
-this node using the options:
-\begin{itemize}
-\item topstyle
-\item sidestyle
-\item bottomstyle
-\end{itemize}
-You can additionally provide custom names for the nodes for later reference using
-\begin{itemize}
-\item topname
-\item sidename
-\item osidename
-\item bottomname
-\end{itemize}
-The \enquote{osidename} allows you to provide a name for the \enquote{other side}. 
-Via the option \enquote{length} you can specify the length of the arrow.
-
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Inner Box]
-		\pseudocode{
-			\text{inner step 1} \\
-			\text{inner step 2} \\
-		}
-		\end{bbrbox}
-		
-		\bbrmsgto{top={$m_0,m_1$},side=Side Label, bottom=$b$, length=2cm,
-				  topstyle={draw, solid}, sidestyle={red}, bottomstyle={draw, dashed}}
-
-	\end{bbrenv}
-
-	\pseudocode{
-		\text{step 4} \\
-		\text{step 5} \\
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Box Name]
-	\pseudocode{
-		\text{step 1} \\
-		\text{step 2} \\
-		\pcfor \text{some condition} \pcdo \\
-		\pcind\text{step 3} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Inner Box]
-		\pseudocode{
-			\text{inner step 1} \\
-			\text{inner step 2} \\
-		}
-		\end{bbrbox}
-		
-		\bbrmsgto{top={$m_0,m_1$},side=Side Label, bottom=$b$, length=2cm,
-				  topstyle={draw, solid}, sidestyle={red}, bottomstyle={draw, dashed}}
-
-	\end{bbrenv}
-
-	\pseudocode{
-		\text{step 4} \\
-		\text{step 5} \\
-	}
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-\end{lstlisting}
-
-
-\subsection{Add Space}
-\index{\textbackslash bbrmsgspace}
-\index{\textbackslash bbrqryspace}
-If the spacing between messages is not sufficient you can use the \lstinline$bbrmsgspace$ and
-\lstinline$bbrqryspace$ commands to add additional space.
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-
-		\end{bbrbox}
-		
-		\bbrmsgto{top=$m$}
-		\bbrmsgspace{1.5cm}
-		\bbrmsgfrom{top=$\sigma$}
-
-		\bbrqryto{top=$m$}
-		\bbrqryspace{1cm}
-		\bbrqryfrom{top=$\sigma$}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-
-		\end{bbrbox}
-		
-		\bbrmsgto{top=$m$}
-		\bbrmsgspace{1.5cm}
-		\bbrmsgfrom{top=$\sigma$}
-
-		\bbrqryto{top=$m$}
-		\bbrqryspace{1cm}
-		\bbrqryfrom{top=$\sigma$}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-\end{lstlisting}
-
-
-\subsection{Loops}
-\index{\textbackslash bbrloop}
-Often an adversary may send poly many queries to an oracle, or a reduction sends many queries to an adversary.
-Consider the following setting
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-
-		\end{bbrbox}
-		
-		\bbrmsgto{top=$m$,sidename=BeginLoop}
-		\bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-
-		\end{bbrbox}
-		
-		\bbrmsgto{top=$m$}
-		\bbrmsgfrom{top=$\sigma$}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-\end{lstlisting}
-
-First note that by specifying the minheight and xshift option we shifted the adversary box a bit to the right
-and enlarged its box. Further we specified custom names for the node on the  side of the two messages. We
-can now use the \lstinline$bbrloop$ command to visualize that these two messages are exchanged $q$ many times
-\begin{lstlisting}
-\bbrloop{BeginLoop}{EndLoop}{center=$q$}
-\end{lstlisting}
-The \lstinline$bbrloop$ command takes two node names and a config which allows you to specify if the label is
-to be shown on the left, center or right. Here is the result.
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-
-		\end{bbrbox}
-		
-		\bbrmsgto{top=$m$,sidename=BeginLoop}
-		\bbrmsgspace{0.5cm}
-		\bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
-		\bbrloop{BeginLoop}{EndLoop}{center=$q$}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-
-		\end{bbrbox}
-		
-		\bbrmsgto{top=$m$,sidename=BeginLoop}
-		\bbrmsgspace{0.5cm}
-		\bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
-		\bbrloop{BeginLoop}{EndLoop}{center=$q$}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-\end{lstlisting}
-
-\subsection{Intertext}
-\index{\textbackslash bbrmsgtxt}
-\index{\textbackslash bbrqrytxt}
-
-If your reduction needs to do some extra work between queries use the \lstinline$\bbrmsgtxt$
-and \lstinline$\bbrqrytxt$ commands.
-\begin{lstlisting}
-\bbrmsgtxt[options]{Text}
-\bbrqrytxt[options]{Text}
-\end{lstlisting}
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-
-		\end{bbrbox}
-		
-		\bbrmsgto{top=$m$}
-		\bbrmsgtxt{\pseudocode{
-			do \\
-			some \\
-			work
-		}}
-		\bbrmsgfrom{top=$\sigma$}
-
-		\bbrqryto{top=$m$}
-		\bbrqrytxt[beforeskip=0.5cm,nodestyle={draw,dashed},xshift=2cm]{\pseudocode{
-			do \\
-			some \\
-			work
-		}}
-		\bbrqryfrom{top=$\sigma$}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-
-		\end{bbrbox}
-		
-		\bbrmsgto{top=$m$}
-		\bbrmsgtxt{\pseudocode{
-			do \\
-			some \\
-			work
-		}}
-		\bbrmsgfrom{top=$\sigma$}
-
-		\bbrqryto{top=$m$}
-		\bbrqrytxt[beforeskip=0.5cm,nodestyle={draw,dashed},xshift=2cm]{\pseudocode{
-			do \\
-			some \\
-			work
-		}}
-		\bbrqryfrom{top=$\sigma$}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-\end{bbrenv}
-\end{lstlisting}
-
-\section{Oracles}
-\index{bbroracle}
-\index{hdistance}
-\index{vdistance}
-Each box can have one or more oracles which are drawn on the right hand side of the box. An oracle
-is created similarly to a \emph{bbrenv} environment using the \emph{bbroracle} environment. Oracles
-go behind the single \emph{bbrbox} environment within an \emph{bbrenv} enviornment.
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-		\end{bbrbox}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbroracle}{OraA}
-		\begin{bbrbox}[name=Oracle 1]
-		\end{bbrbox}
-	\end{bbroracle}
-
-	\begin{bbroracle}{OraB}[vdistance=2cm,hdistance=3cm]
-		\begin{bbrbox}[name=Oracle 2]
-		\end{bbrbox}
-	\end{bbroracle}
-\end{bbrenv}
-
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
-		\end{bbrbox}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbroracle}{OraA}
-		\begin{bbrbox}[name=Oracle 1]
-		\end{bbrbox}
-	\end{bbroracle}
-
-	\begin{bbroracle}{OraB}[vdistance=2cm,hdistance=3cm]
-		\begin{bbrbox}[name=Oracle 2]
-		\end{bbrbox}
-	\end{bbroracle}
-\end{bbrenv}
-\end{lstlisting}
-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 \lstinline$\baselineskip$.
-
-
-\subsection{Communicating with Oracles}
-\index{\textbackslash bbroracleqryfrom}
-\index{\textbackslash bbroracleqryto}
-As oracles use the \emph{bbrbox} environment we can directly use the established ways to send messages and
-queries to oracles. In addition you can use the \lstinline$\bbroracleqryfrom$ and \lstinline$\bbroracleqryto$.
-\begin{lstlisting}
-\bbroracleqryfrom{options}
-\bbroracleqryto{options}
-\end{lstlisting}
-Here options allow you to specify where the label goes (top, bottom). In addition you can use
-\lstinline$\bbroracleqryspace$ to generate extra space between oracle messages. Note
-that oracle messages need to be added after the closing \lstinline$\end{bbroracle}$ command.
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=3cm]
-		\end{bbrbox}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbroracle}{OraA}
-		\begin{bbrbox}[name=Oracle 1,minheight=1cm]
-		\end{bbrbox}
-	\end{bbroracle}
-	\bbroracleqryfrom{top=$m$}
-	\bbroracleqryto{top=$b$}
-
-	\begin{bbroracle}{OraB}
-		\begin{bbrbox}[name=Oracle 2,minheight=1cm]
-		\end{bbrbox}
-	\end{bbroracle}
-	\bbroracleqryfrom{bottom=$m$}
-	\bbroracleqryto{bottom=$b$}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Reduction]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\begin{bbrenv}{B}
-		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=3cm]
-		\end{bbrbox}
-
-	\end{bbrenv}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbroracle}{OraA}
-		\begin{bbrbox}[name=Oracle 1,minheight=1cm]
-		\end{bbrbox}
-	\end{bbroracle}
-	\bbroracleqryfrom{top=$m$}
-	\bbroracleqryto{top=$b$}
-
-	\begin{bbroracle}{OraB}
-		\begin{bbrbox}[name=Oracle 2,minheight=1cm]
-		\end{bbrbox}
-	\end{bbroracle}
-	\bbroracleqryfrom{bottom=$m$}
-	\bbroracleqryto{bottom=$b$}
-\end{bbrenv}
-\end{lstlisting}
-
-\section{Challengers}
-\index{bbrchallenger}
-\index{hdistance}
-\index{vdistance}
-Each box can have one or more challengers which are drawn on the left hand side of the box. Challengers
-behave identically to oracles with the exception that they are to the left of the box. A challenger
-is created similarly to a \emph{bbrenv} environment using the \emph{bbrchallenger} environment. Challengers
-go behind the single \emph{bbrbox} environment within an \emph{bbrenv} enviornment.
-
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Adversary,minheight=2cm]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbrchallenger}{ChaA}
-		\begin{bbrbox}[name=Challenger,minheight=2cm]
-		
-		\end{bbrbox}
-	\end{bbrchallenger}
-\end{bbrenv}
-
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Adversary,minheight=2cm]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbrchallenger}{ChaA}
-		\begin{bbrbox}[name=Challenger,minheight=2cm]
-		
-		\end{bbrbox}
-	\end{bbrchallenger}
-\end{bbrenv}
-\end{lstlisting}
-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 \lstinline$\baselineskip$.
-
-
-\subsection{Communicating with Challengers}
-\index{\textbackslash bbrchallengerqryfrom}
-\index{\textbackslash bbrchallengerqryto}
-As challengers use the \emph{bbrbox} environment we can directly use the established ways to send messages and
-queries to oracles. In addition you can use the \lstinline$\bbrchallengerqryfrom$ and \lstinline$\bbrchallengerqryto$.
-\begin{lstlisting}
-\bbrchallengerqryfrom{options}
-\bbrchallengerqryto{options}
-\end{lstlisting}
-Here options allow you to specify where the label goes (top, bottom). In addition you can use
-\lstinline$\bbrchallengerqryspace$ to generate extra space between oracle messages. Note
-that challenger messages need to be added after the closing \lstinline$\end{bbrchallenger}$ command.
-
-\vspace{2em}
-\begin{bbrenv}[1cm]{A}[0.5cm]
-	\begin{bbrbox}[name=Adversary,minheight=2cm]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbrchallenger}{ChaA}
-		\begin{bbrbox}[name=Challenger,minheight=2cm]
-		
-		\end{bbrbox}
-	\end{bbrchallenger}
-
-	\bbrchallengerqryfrom{top=$m$}
-	\bbrchallengerqryto{bottom=$b$}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{A}
-	\begin{bbrbox}[name=Adversary,minheight=2cm]
-	\pseudocode{
-		\text{Do something} 
-	}
-
-	\end{bbrbox}
-	\bbrinput{input}
-	\bbroutput{output}
-
-	\begin{bbrchallenger}{ChaA}
-		\begin{bbrbox}[name=Challenger,minheight=2cm]
-		
-		\end{bbrbox}
-	\end{bbrchallenger}
-
-	\bbrchallengerqryfrom{top=$m$}
-	\bbrchallengerqryto{bottom=$b$}
-\end{bbrenv}
-\end{lstlisting}
-
-\section{Examples}
-A reduction for full domain hash.
-
-
-\begin{bbrenv}{Red}
-
-	\begin{bbrbox}[name=\textsc{Reduction }$\bdv$]
-
-		\pseudocode{
-			j \sample [q] 
-		}
-		
-		\vspace{2ex}
-		\emph{/* begin simulation */}
-		
-		\begin{bbrenv}{Adv}
-			\begin{bbrbox}[name=$\adv$,minheight=7.5cm,style={fill=black},namestyle={color=white},xshift=3cm,yshift=0.75cm]
-			\end{bbrbox}
-
-			\bbrinput{$\fk$}
-			\bbroutput{$\sigma$}			
-			
-			\bbrmsgfrom{top=$m_1$}
-			\bbrmsgto{bottom=$\$$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-			
-			\bbrmsgvdots
-			
-			\bbrmsgfrom{top=$m_{j-1}$}
-			\bbrmsgto{bottom=$\$$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-			
-			\bbrmsgfrom{top=$m_j$}
-			\bbrmsgto{bottom=$y$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-
-			\bbrmsgfrom{top=$m_{j+1}$}
-			\bbrmsgto{bottom=$\$$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-
-			\bbrmsgvdots
-			
-			\bbrmsgfrom{top=$m_q$}
-			\bbrmsgto{bottom=$\$$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-
-			\begin{bbroracle}{Sign}
-				\begin{bbrbox}[name=Sign,namepos=center,style={draw},minheight=1cm]
-				\end{bbrbox}
-			\end{bbroracle}
-
-			\bbroracleqryto{top=$m$}
-			\bbroracleqryfrom{top=$\sigma$}			
-
-		\end{bbrenv}
-		
-	
-		\pcdraw{
-			\node[left=2cm of Adv.north west] (startsim) {};
-			\node[left=2cm of Adv.south west] (endsim) {};			
-			\draw[->,thick] (startsim) -- (endsim);
-			\node[rotate=90, left=2.75cm of Adv.west,anchor=center] () {\textsc{Simulation of Random Oracle}};
-		}
-		
-		\vspace{-3ex}
-		\emph{/* end simulation */}
-		
-		\pseudocode{
-		 y \gets \sigma
-		}
-
-	\end{bbrbox}
-	\bbrqryfrom{beforeskip=0.25cm,top={$(\fk, y)$},side={\dbox{\pseudocode{
-	  \fk \sample \fash.\kgen(\secparam) \\ x \sample \bin^{\fash.\il(\secpar)} \\ y \gets \fash.\eval(\fk, x)} 
-	}}}
-	\bbrqryto{beforeskip=10.75cm,side=\pseudocode{y \in \fash^{-1}(\fk, x)}}
-\end{bbrenv}
-
-\begin{lstlisting}
-\begin{bbrenv}{Red}
-
-	\begin{bbrbox}[name=\textsc{Reduction }$\bdv$]
-
-		\pseudocode{
-			j \sample [q] 
-		}
-		
-		\vspace{2ex}
-		\emph{/* begin simulation */}
-		
-		\begin{bbrenv}{Adv}
-			\begin{bbrbox}[name=$\adv$,minheight=7.5cm,style={fill=black},namestyle={color=white},xshift=3cm,yshift=0.75cm]
-			\end{bbrbox}
-
-			\bbrinput{$\fk$}
-			\bbroutput{$\sigma$}			
-			
-			\bbrmsgfrom{top=$m_1$}
-			\bbrmsgto{bottom=$\$$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-			
-			\bbrmsgvdots
-			
-			\bbrmsgfrom{top=$m_{j-1}$}
-			\bbrmsgto{bottom=$\$$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-			
-			\bbrmsgfrom{top=$m_j$}
-			\bbrmsgto{bottom=$y$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-
-			\bbrmsgfrom{top=$m_{j+1}$}
-			\bbrmsgto{bottom=$\$$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-
-			\bbrmsgvdots
-			
-			\bbrmsgfrom{top=$m_q$}
-			\bbrmsgto{bottom=$\$$,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip}
-
-			\begin{bbroracle}{Sign}
-				\begin{bbrbox}[name=Sign,namepos=center,style={draw},minheight=1cm]
-				\end{bbrbox}
-			\end{bbroracle}
-
-			\bbroracleqryto{top=$m$}
-			\bbroracleqryfrom{top=$\sigma$}			
-
-		\end{bbrenv}
-		
-	
-		\pcdraw{
-			\node[left=2cm of Adv.north west] (startsim) {};
-			\node[left=2cm of Adv.south west] (endsim) {};			
-			\draw[->,thick] (startsim) -- (endsim);
-			\node[rotate=90, left=2.75cm of Adv.west,anchor=center] () {\textsc{Simulation of Random Oracle}};
-		}
-		
-		\vspace{-3ex}
-		\emph{/* end simulation */}
-		
-		\pseudocode{
-		 y \gets \sigma
-		}
-
-	\end{bbrbox}
-	\bbrqryfrom{beforeskip=0.25cm,top={$(\fk, y)$},side={\dbox{\pseudocode{
-	  \fk \sample \fash.\kgen(\secparam) \\ x \sample \bin^{\fash.\il(\secpar)} \\ y \gets \fash.\eval(\fk, x)} 
-	}}}
-	\bbrqryto{beforeskip=10.75cm,side=\pseudocode{y \in \fash^{-1}(\fk, x)}}
-\end{bbrenv}
-\end{lstlisting}
-
-
-\chapter{Known Issues}
-
-\section{Pseudocode KeepSpacing within Commands}
-\label{sec:keepindent-problem}
-\index{\textbackslash fbox}
-\index{framebox}
-The \enquote{space=keep} option of pseudocode which should output spacing identical to that of the input 
-will fail, if the pseudocode command is called from within another command. An example is to
-wrap the \lstinline$\pseudocode$ command with an \lstinline$\fbox$. As a workaround for generating frame boxes you should hence
-use a package such as \emph{mdframed} (\url{https://www.ctan.org/pkg/mdframed}) which provides a frame environment.
-
-\begin{mdframed}
-\pseudocode[space=keep,mode=text]{        Pseudocode                with         - spaces -}
-\end{mdframed}
-\begin{lstlisting}
-\pseudocode[space=keep,mode=text]{        Pseudocode                with         - spaces -}
-\end{lstlisting}
-
-As an alternative you could use a \emph{savebox} (in combination with the \lstinline$lrbox$ environment):
- 
-\newsavebox{\mypcbox}
-\begin{lrbox}{\mypcbox}%
-\pseudocode[space=keep,mode=text]{        Pseudocode                with         - spaces -}%
-\end{lrbox}
-\fbox{\usebox{\mypcbox}}
-
-\begin{lstlisting}
-\newsavebox{\mypcbox}
-\begin{lrbox}{\mypcbox}%
-\pseudocode[space=keep,mode=text]{        Pseudocode                with         - spaces -}%
-\end{lrbox}
-\fbox{\usebox{\mypcbox}}
-\end{lstlisting}
-
-\section{AMSFonts}
-\index{amsfonts}
-\index{noamsfonts|see {package options}}
-\index{package options!noamsfonts}
-Some packages are not happy with the \enquote{amsfonts} package. Cryptocode will attempt to load amsfonts if it is loaded
-with either the \enquote{sets} or the \enquote{probability} option. In order to not load amsfonts you can additionally add the
-\enquote{noamsfonts} at the very end. Note that in this case you should ensure that the command \lstinline$\mathbb$ is defined
-as this is used by most of the commands in \enquote{sets} and some of the commands in \enquote{probability}.
-
-\section{Hyperref}
-The hyperref package (\url{https://www.ctan.org/pkg/hyperref}) should be loaded before cryptocode. If this is not possible
-call the \lstinline$\pcfixhyperref$ after \lstinline$\begin{document}$. 
-
-\printindex
-
-
-
-\end{document}
-

Added: trunk/Master/texmf-dist/source/latex/cryptocode/cryptocode.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/cryptocode/cryptocode.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/cryptocode/cryptocode.dtx	2020-07-10 21:20:21 UTC (rev 55800)
@@ -0,0 +1,9392 @@
+%\iffalse
+%<*package>
+\NeedsTeXFormat{LaTeX2e}
+\DeclareRelease{v0.30}{2018-11-11}{cryptocode-2018-11-11.sty}
+\DeclareRelease{v0.32}{2020-04-24}{cryptocode-2020-04-24.sty}
+\DeclareCurrentRelease{v0.40}{2020-07-10}
+\ProvidesPackage{cryptocode}
+  [2020/07/10 v0.40 Cryptocode LaTeX package for typesetting pseudocode, algorithms and protocols as well as cryptographic proofs.]
+%</package>
+%\fi
+% \iffalse
+% Doc-Source file to use with LaTeX2e
+% Copyright (C) 2020 Arno Mittelbach, all rights reserved.
+% \fi
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+\usepackage[usenames]{xcolor}
+\usepackage{hypdoc}
+\usepackage[
+	n,
+	operators,
+	advantage,
+	sets,
+	adversary,
+	landau,
+	probability,
+	notions,	
+	logic,
+	ff,
+	mm,
+	primitives,
+	events,
+	complexity,
+	oracles,
+	asymptotics,
+	keys]{cryptocode}
+
+\createpseudocodeblock{pcb}{center,boxed}{}{}{}
+\createprocedureblock{procb}{center,boxed}{}{}{}
+\usepackage{csquotes}
+\usepackage{fullpage}
+\usepackage{dashbox}
+\usepackage{textcomp}
+\usepackage{url}
+\usepackage{xspace}
+
+\usetikzlibrary{shapes.callouts}
+
+\usepackage{listings}
+
+\usepackage{trace}
+
+\usepackage{makeidx}
+\usepackage{mdframed}	
+
+\definecolor{mygreen}{rgb}{0,0.6,0}
+\definecolor{mygray}{rgb}{0.1,0.1,0.1}
+\definecolor{verylightgray}{rgb}{0.9,0.9,0.9}
+\definecolor{mymauve}{rgb}{0.58,0,0.82}
+
+\let\amipagebreak\pagebreak
+
+\setlength{\textwidth}{386pt}
+\addtolength\marginparwidth{50pt}
+\addtolength\oddsidemargin{40pt}
+\addtolength\evensidemargin{40pt}
+
+\lstset{language=[LaTeX]TeX,
+ backgroundcolor=\color{verylightgray},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
+ rulecolor=\color{lightgray},
+ basicstyle=\scriptsize,        % the size of the fonts that are used for the code
+ breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
+ breaklines=true,                 % sets automatic line breaking
+ captionpos=b,                    % sets the caption-position to bottom
+ commentstyle=\color{mygreen},    % comment style
+ escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
+ extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
+ frame=single,                    % adds a frame around the code
+ keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
+ keywordstyle=\color{blue},       % keyword style
+ numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)
+ numbersep=5pt,                   % how far the line-numbers are from the code
+ numberstyle=\scriptsize\color{mygray}, % the style that is used for the line-numbers
+ rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
+ showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
+ showstringspaces=false,          % underline spaces within strings only
+ showtabs=false,                  % show tabs within strings adding particular underscores
+ stepnumber=1,                    % the step between two line-numbers. If it's 1, each line will be numbered
+ stringstyle=\color{mymauve},     % string literal style
+ frameround=ftff,
+ belowskip=-0.8 \baselineskip,
+ aboveskip=1em,
+ tabsize=2,                       % sets default tabsize to 2 spaces
+ title=\lstname        }  
+
+ \CodelineIndex
+\CodelineIndex
+\RecordChanges
+\begin{document}
+\DocInput{cryptocode.dtx}
+\end{document}
+%</driver>
+%\fi
+%
+% \changes{v0.10}{2015/03/30}{Initial version}
+% \changes{v0.11}{2016/11/30}{changed command pckeystyle to ensure that subscripts on $\sk$ and $\pk$ are aligned the same 
+%   before, $(\sk_R, \pk_R)$ had slightly misaligned subscripts due to Tex treating 
+%   subscripts on composite objects with descenders differently than without.} 
+% ^^A see \url{https://groups.google.com/forum/#!msg/comp.text.tex/IaXu_xBG06Q/CibRPH5GCAAJ}
+%
+% \changes{v0.11}{2016/11/30}{Added \textbackslash{}NAND command.}
+% \changes{v0.11}{2016/11/30}{Added \emph{pcmbox} environment for matrices in pseudocode.}
+%
+% \changes{v0.20}{2016/12/02}{Changed \emph{minheight} for bbrbox environment to actually reflect a minimum height in tikz.
+% The old minheight which added space at the bottom was preserved as \emph{addheight}.}
+% \changes{v0.20}{2016/12/02}{Added namepos middle for bbrbox.}
+% \changes{v0.20}{2016/12/02}{Added \textbackslash{}pcfail.}
+% \changes{v0.20}{2016/12/02}{Added valign to pseudocode to allow minipage vertical alignment.}
+% \changes{v0.20}{2016/12/02}{Ensure line numbers are right aligned to allow for two digit linenumbers having the same width.}
+%
+% \changes{v0.04}{2017/08/26}{added \textbackslash{}pcabort.}
+% \changes{v0.04}{2017/08/26}{better control whitespace for \textbackslash{}pcif, \textbackslash{}pcelse, \textbackslash{}pcelseif.}
+%
+% \changes{v0.05}{2017/10/02}{side and oside support to \textbackslash{}bbroracleqryto and \textbackslash{}bbroracleqryfrom}
+% \changes{v0.05}{2017/10/02}{add bottom to namepos in bbrbox}
+% \changes{v0.05}{2017/10/02}{names for brrinput and bbroutput}
+% \changes{v0.05}{2017/10/02}{angle for bbrloop}
+% \changes{v0.05}{2017/10/02}{fix length for bbrinput}
+% \changes{v0.05}{2017/10/02}{introduce hoffset for bbrinput}
+% 
+% \changes{v0.06}{2017/12/21}{added \textbackslash{}pcunless}
+%
+% \changes{v0.30}{2018/11/11}{replace obsolete l3regex}
+% 
+% \changes{v0.31}{2018/11/26}{added \textbackslash{}tprob (variants for prob and co for in-text)}
+% \changes{v0.31}{2018/11/26}{added \textbackslash{}prp}
+%
+% \changes{v0.32}{2020/01/11}{allow to control spacing with \textbackslash{}pcfor}
+% \changes{v0.32}{2020/01/11}{allow overwriting rule command in pseudocode via headlinecmd (defaults to \textbackslash{}hrule)}
+%
+% \changes{v0.40}{2020/06/20}{Bigger refactoring. Not completely backwards compatible. In particular, optimized spacing of pseudocode blocks and black box reductions.}
+% \changes{v0.40}{2020/06/20}{Switched to mathtools \emph{DeclarePairedDelimiter} for paired operators.
+% Each paired operator comes in two forms, e.g, \emph{abs} and \emph{tabs} the latter to be used in flowtext
+% which does not scale the outer delimiters.} 
+% \changes{v0.40}{2020/06/20}{Adjusted spacing via \textbackslash{}pcaboveskip and \textbackslash{}pcbelowskip which are
+% added to \textbackslash{}pseudocode blocks and \emph{pchstack} environments}
+% \changes{v0.40}{2020/06/20}{Added block forms for pseudocode and procedure commands (\textbackslash{}pseudocodeblock and \textbackslash{}procedureblock).}
+% \changes{v0.40}{2020/06/20}{Added minlineheight option to \textbackslash{}pseudocode.}
+% \changes{v0.40}{2020/06/20}{Added headheight option to \textbackslash{}pseudocode.}
+% \changes{v0.40}{2020/06/20}{Added \textbackslash{}argmax and \textbackslash{}argmin to operators.}
+% \changes{v0.40}{2020/06/20}{Added \textbackslash{}pindist, \textbackslash{}sindist, and \textbackslash{}cindist to operators.}
+% \changes{v0.40}{2020/06/20}{Added aboveskip and belowskip option to \textbackslash{}pchstack and \textbackslash{}pcvstack.}
+% \changes{v0.40}{2020/06/20}{Added boxed, inline, noindent options to \textbackslash{}pchstack and \textbackslash{}pcvstack.}
+% \changes{v0.40}{2020/06/20}{Added space option to \textbackslash{}pchstack and \textbackslash{}pcvstack.}
+% \changes{v0.40}{2020/06/20}{Renamed horizontal spacing commands \textbackslash{}beforepcskip and \textbackslash{}afterpcskip to \textbackslash{}pcbeforeskip and \textbackslash{}pcafterskip.}
+% \changes{v0.40}{2020/06/20}{Added command \textbackslash{}pcsetargs to define default arguments for pseudocode blocks.}
+% \changes{v0.40}{2020/06/20}{Added command \textbackslash{}pcsethstackargs and \textbackslash{}pcsetvstackargs to define default arguments for hstack and vstack environments.}
+% \changes{v0.40}{2020/06/20}{Adapted bbrenv environment to take key value option list. Old format is still supported but deprecated.}
+% \changes{v0.40}{2020/06/20}{Added additional polynomials.}
+% \changes{v0.40}{2020/06/20}{Added additional adversaries.}
+% \changes{v0.40}{2020/06/20}{Added additional complexity classes.}
+% \changes{v0.40}{2020/06/20}{Added oracles package option.}
+% \changes{v0.40}{2020/06/20}{Fixed spacing issues with black box reduction messages.}
+% \changes{v0.40}{2017/10/02}{Added clockwise, leftstyle, centerstyle, rightstyle for bbrloop. Adjusted placing of center.}
+% \changes{v0.40}{2017/10/02}{Added fixedoffset, fixedboffset, islast for reduction messages.}
+%
+%
+%
+%
+%
+% \author{Arno Mittelbach\\
+% \texttt{mail at arno-mittelbach.de}\\
+% \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.}}
+% \title{\Huge Cryptocode \\ \large\textsc{Typesetting Cryptography}}
+%
+%
+% \maketitle
+%
+%
+%
+%
+% \begin{abstract}
+% \thispagestyle{empty}
+% The cryptocode package provides a set of macros to ease the typesetting of 
+% 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).
+% This includes simple predefined commands for typesetting probabilities and \enquote{commonly encountered math} 
+% as well as for concepts such as 
+% a security parameter $\secparam$ or advantage terms $\advantage{prf}{\adv,\prf} = \negl$. Furthermore, it includes 
+% environments to layout game-based proofs or black-box reductions.
+%
+% \vspace{2em}
+% \begin{center}
+% \fbox{
+% \pseudocode{%
+% \textbf{ Alice} \< \< \textbf{ Bob}  \\[0.1\baselineskip][\hline]
+%  \<\< \\[-0.5\baselineskip]
+%  x \sample \ZZ_q \< \< \\
+%  X \gets g^x \<\< \\[-4ex]
+%  \< \sendmessageright*{\GG,q,g,X} \< \\[-2ex]
+%  \<\< y \sample \ZZ_q \\
+%  \<\< Y \gets g^y \\[-4ex]
+%  \< \sendmessageleft*{Y} \< \\
+%  \key_A \gets Y^x \<\< \key_B \gets X^y }
+% }
+% \end{center}
+%
+%
+% \end{abstract}
+% \newpage
+%
+% \pagenumbering{roman}
+%
+% \tableofcontents
+% \thispagestyle{empty}
+% \newpage
+%
+% \pagenumbering{arabic}
+%
+%
+% \section{Cryptocode by Example}
+%
+% The cryptocode package provides a set of commands to ease the typesetting of 
+% pseudocode, protocols, game-based proofs and black-box reductions. In addition it comes
+% with a large number of predefined commands. In this section we present the various features of 
+% cryptocode by giving small examples. But first, let's load the package
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\usepackage[
+	n, % or lambda
+	advantage,
+	operators,
+	sets,
+	adversary,
+	landau,
+	probability,
+	notions,
+	logic,
+	ff,
+	mm,
+	primitives,
+	events,
+	complexity,
+	oracles,
+	asymptotics,
+	keys
+]{cryptocode}\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% Note that all the options refer to a set of commands. That is, without any options cryptocode will provide the mechanisms
+% for writing pseudocode, protocols, game-based proofs and black-box reductions but not define additional commands,
+% such as |\pk| or |\sk| (for typesetting public and private/secret keys) which are part of the keys option.
+% We discuss the various options and associated commands in Section~\ref{chap:commands}.
+%
+%
+% \subsection{Pseudocode}
+% The cryptocode package tries to make writing pseudocode easy and enjoyable. The
+% |\pseudocode| command takes a single parameter where you can start writing
+% code in mathmode using \lstinline{\\} as line breaks. Following is an $\indcpa$ game
+% definition using various commands from cryptocode to ease writing keys (\lstinline{\pk,\sk}),
+% sampling (\lstinline{\sample}), and more:
+%
+% \medskip
+% \pseudocode[linenumbering]{
+%   b \sample \bin  \\
+%   (\pk,\sk) \sample \kgen (\secparam)  \\
+%   (\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
+%   c \sample \enc(\pk,m_b)  \\
+%   b' \sample \adv(\secparam, \pk, c, \state)  \\
+%   \pcreturn b = b' }
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+ \pseudocode[linenumbering]{
+   b \sample \bin  \\
+   (\pk,\sk) \sample \kgen (\secparam)  \\
+   (\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
+   c \sample \enc(\pk,m_b)  \\
+   b' \sample \adv(\secparam, \pk, c, \state)  \\
+   \pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% \amipagebreak
+% 
+% In many cases, we want to set pseudocode blocks in-between paragraphs with spacing
+% similar to how we would offset equations. For this, and for laying out multiple code
+% blocks, cryptocode offers \enquote{stacking} environments |\pchstack| and |\pcvstack|.
+% For typesetting a code block nicely centered and boxed
+% \begin{pchstack}[center,boxed]
+% \pseudocode[linenumbering]{
+%   b \sample \bin  \\
+%   (\pk,\sk) \sample \kgen (\secparam)  \\
+%   (\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
+%   c \sample \enc(\pk,m_b)  \\
+%   b' \sample \adv(\secparam, \pk, c, \state)  \\
+%   \pcreturn b = b' }
+% \end{pchstack}
+% you could thus use:
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\begin{pchstack}[center,boxed]
+	\pseudocode[linenumbering]{
+	b \sample \bin  \\
+	(\pk,\sk) \sample \kgen (\secparam)  \\
+	(\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
+	c \sample \enc(\pk,m_b)  \\
+	b' \sample \adv(\secparam, \pk, c, \state)  \\
+	\pcreturn b = b' }
+\end{pchstack}\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% As this is a common task, cryptocode offers the |\pseudocodeblock| command which 
+% is a shorthand for the above (without the frame). In case you want to provide different
+% options or a shorter command (say |\pcb|) you can easily define the command via
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+ \createpseudocodeblock{pcb}{center,boxed}{}{}{}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% The above could now be written, more succinctly as
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\pcb[linenumbering]{
+	b \sample \bin  \\
+	(\pk,\sk) \sample \kgen (\secparam)  \\
+	(\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
+	c \sample \enc(\pk,m_b)  \\
+	b' \sample \adv(\secparam, \pk, c, \state)  \\
+	\pcreturn b = b' 
+}\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% 
+%
+% The pseudocode command (and its block variant) takes a single mandatory argument (the code) plus an optional argument
+% which allows you to specify options in a key=value fashion. In the above example we used the linenumbering
+% option.
+%
+% \medskip
+%
+% It is easy to define a heading for your code. Either specify the header using the option \enquote{head} or use 
+% the |\procedure| command (or its block variant |\procedureblock|) which takes an additional argument to specify the headline.
+% 
+% \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secpar)$}{
+%   b \sample \bin  \\
+%   (\pk,\sk) \sample \kgen (\secparam)  \\
+%   (\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
+%   c \sample \enc(\pk,m_b)  \\
+%   b' \sample \adv(\secparam, \pk, c, \state) \\
+%   \pcreturn b = b' }
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secpar)$}{
+	b \sample \bin  \\
+	(\pk,\sk) \sample \kgen (\secparam)  \\
+	(\state,m_0,m_1) \sample \adv(\secparam, \pk, c)   \\
+	c \sample \enc(\pk,m_b)  \\
+	b' \sample \adv(\secparam, \pk, c, \state) \\
+	\pcreturn b = b' } 
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% Similarly to before, we can define a shorthand and boxed variant as
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+ \createprocedureblock{procb}{center,boxed}{}{}{}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+%
+% There is a lot more that we will discuss in detail in Section~\ref{chap:pseudocode}. Here, for example,
+% is the same code with an overlay explanation and a division of the pseudocode.
+%
+% \begin{pcimage}
+% \procb[linenumbering]{$\indcpa_\enc^\adv(\secpar)$}{
+% 	 b \sample \bin  \\
+% 	 (\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen}  \pclb
+% 	\pcintertext[dotted]{Setup Completed} 
+% 	 (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+% 	  c \sample \enc(\pk,m_b)  \\
+% 	  b' \sample \adv(\secparam, \pk, c, \state) \\
+% 	  \pcreturn b = b' }
+%
+% \pcdraw{
+%   \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
+%       at ([shift={(+3,-1)}]kgen) {
+% 		\begin{varwidth}{3cm}
+% 			$\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
+% 		\end{varwidth}
+%   };
+% }
+% \end{pcimage}
+%
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+ \begin{pcimage}
+ \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secpar)$}{%
+ 	 b \sample \bin  \\
+ 	 (\pk,\sk) \sample \kgen(\secparam)\pcnode{kgen}  \pclb
+ 	 \pcintertext[dotted]{Setup Completed} 
+ 	 (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+ 	  c \sample \enc(\pk,m_b)  \\
+ 	  b' \sample \adv(\secparam, \pk, c, \state) \\
+ 	  \pcreturn b = b' }
+
+ \pcdraw{
+   \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
+       at ([shift={(+3,-1)}]kgen) {
+ 		\begin{varwidth}{3cm}
+ 			$\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
+ 		\end{varwidth}
+   };
+ }
+ \end{pcimage}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Stacking}
+%
+% To arrange multiple procedures, cryptocode offers horizontal and vertical stacking
+% environments |\pchstack| and |\pcvstack|. In the example below we arrange four
+% code blocks in three columns equispaced with 1cm distance and stack two procedures
+% in the center column.
+%
+% \begin{pchstack}[center,space=1cm]
+%   \procedure{A}{
+%	  a \sample A \\
+%     \pcreturn a
+%   }
+%   
+%   \begin{pcvstack}[boxed,space=0.5cm]
+%   \procedure{B.1}{
+%	  b \sample B \\
+%     \pcreturn b
+%   }	
+%   \procedure{B.1}{
+%	  b \sample B \\
+%     \pcreturn b
+%   }	
+%	\end{pcvstack}
+%
+%   \procedure{C}{
+%	  c \sample C \\
+%     \pcreturn c
+%   }
+% \end{pchstack}
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\begin{pchstack}[center,space=1cm]
+	\procedure{A}{
+	   a \sample A \\
+	  \pcreturn a
+	}
+	
+	\begin{pcvstack}[boxed,space=0.5cm]
+		\procedure{B.1}{
+		b \sample B \\
+		\pcreturn b
+		}	
+		\procedure{B.1}{
+		b \sample B \\
+		\pcreturn b
+		}	
+	\end{pcvstack}
+ 
+	\procedure{C}{
+	   c \sample C \\
+	  \pcreturn c
+	}
+\end{pchstack}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Columns}
+% The |\pseudocode| and |\procedure| commands allow the usage of multiple columns.
+% You switch to a new column by inserting a |\>|. This is similar to using an |align|
+% environment and placing a tabbing \& character.\footnote{In fact, the \emph{pseudocode} command
+% is based on amsmath's flalign environment.}
+% \pcb{
+%  \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
+%   b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock{%
+  \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
+   b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% As you can see the first column is left aligned the second right, the third left and so forth.
+% In order to get only left aligned columns you could thus always skip a column by
+% using |\>\>| or you can alternatively use |\<| as a shorthand for |\>\>|.
+% \pcb{
+%  \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
+%   b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
+%
+% \subsection{Protocols}
+% Using columns makes it easy to write even complex protocols. Following is a simple
+% three-party protocol.
+% \pcb{
+%  \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\[][\hline]
+%  \text{work} \< \< \< \< \\
+%  \< \sendmessageright{top=Work result,topstyle=red} \< \< \< \\
+%  \< \< \text{work} \< \< \\
+%  \< \< \<  \sendmessageright{top=Work result,bottom=Bottom message} \< \\
+%  \< \<  \< \< \text{work} \\
+%  \< \sendmessageleftx{8}{\text{A long message for Alice}} \< \\
+%  \text{finalize} \< \< \< \< }
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+ \pseudocodeblock{
+  \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\[][\hline]
+  \text{work} \< \< \< \< \\
+  \< \sendmessageright{top=Work result,topstyle=red} \< \< \< \\
+  \< \< \text{work} \< \< \\
+  \< \< \<  \sendmessageright{top=Work result,bottom=Bottom message} \< \\
+  \< \<  \< \< \text{work} \\
+  \< \sendmessageleftx{8}{\text{A long message for Alice}} \< \\
+  \text{finalize} \< \< \< \< }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% The commands |\sendmessageright| and |\sendmessageleft| are very flexible and
+% allow to style the sending of messages in various ways. Also note the |\\[][\hline]| at the end of the
+% first line. Here the first optional argument allows us to specify the lineheight (similarly to the behavior in an
+% align environment) while the second optional argument allows us to, for example, draw a horizontal line.
+%
+% \medskip
+% In multi-player protocols such as the one
+% above the commands  |\sendmessagerightx| and |\sendmessageleftx| (note the x at the end)
+% allow to send messages over multiple columns. In the example, as we were using |\<| the
+% final message thus spans 8 columns. 
+%
+% \medskip
+% For basic protocols you might also utilize the |\sendmessageright*| and |\sendmessageleft*|
+% commands which simply take a message which is displayed (in math mode) on top.
+% \pcb{
+% \textbf{ Alice} \< \< \textbf{ Bob}  \\[0.1\baselineskip][\hline]
+%  \<\< \\[-0.5\baselineskip]
+% x \sample \ZZ_q \< \< \\
+%  X \gets g^x \<\< \\
+%  \< \sendmessageright*{\GG,q,g,X} \< \\
+%  \<\< y \sample \ZZ_q \\
+%  \<\< Y \gets g^y \\
+%  \< \sendmessageleft*{Y} \< \\
+%  \key_A \gets Y^x \<\< \key_B \gets X^y 
+% }
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\pseudocodeblock{
+	\textbf{ Alice} \< \< \textbf{ Bob}  \\[0.1\baselineskip][\hline]
+	\<\< \\[-0.5\baselineskip]
+	x \sample \ZZ_q \< \< \\
+	X \gets g^x \<\< \\
+	\< \sendmessageright*{\GG,q,g,X} \< \\
+	\<\< y \sample \ZZ_q \\
+	\<\< Y \gets g^y \\
+	\< \sendmessageleft*{Y} \< \\
+	\key_A \gets Y^x \<\< \key_B \gets X^y }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% We will discuss protocols in greater detail in Section~\ref{chap:protocols}.
+%
+% \subsection{Game-Based Proofs}
+% Cryptocode supports authors in visualizing game-based proofs. It defines an environment
+% |gameproof| which allows to wrap a number of game procedures displaying helpful
+% information as to what changes from game to game and to what each step is reduced.
+%
+%\begin{gameproof}
+%	\begin{pchstack}[center,space=1em]
+%		\gameprocedure[linenumbering,minlineheight=1.5em]{%
+%		  \text{Step 1}  \\
+%		  \\
+%		  \text{Step 2}  
+%		 }
+%		 
+%		\tbxgameprocedure[minlineheight=1.5em]{%
+%		   \text{Step 1} \\
+%		   \pcbox{\text{From game 3 on}}  \\
+%		   \gamechange{\text{Step 3 is different}}  
+%		 }
+%		 
+%		\gameprocedure[minlineheight=1.5em]{%
+%		  \text{Step 1}  \\
+%		  \text{From game 3 on}\\
+%		  \text{\gamechange{Step 3 adapted again}}  
+%		 } 
+%		 
+%	\end{pchstack}
+%\end{gameproof}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{gameproof}
+	\begin{pchstack}[center,space=1em]
+		\gameprocedure[linenumbering,minlineheight=1.5em]{%
+		  \text{Step 1}  \\
+		  \\
+		  \text{Step 3}  
+		 }
+		 
+		\tbxgameprocedure[minlineheight=1.5em]{%
+		   \text{Step 1} \\
+		   \pcbox{\text{From game 3 on}}  \\
+		   \gamechange{\text{Step 3 is different}}  
+		 }
+		 
+		\gameprocedure[minlineheight=1.5em]{%
+		  \text{Step 1}  \\
+		  \text{From game 3 on}\\
+		  \text{\gamechange{Step 3 adapted again}}  
+		 } 
+		 
+	\end{pchstack}
+\end{gameproof}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Note that we made use of the option \enquote{mode=text} in the above example which tells the underlying pseudocode 
+% 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}.
+%
+% \subsection{Black-Box Reductions}
+% Cryptocode provides a strucured syntax to visualize black-box reductions. Basically cryptocode
+% provides an environment to draw boxes that may have oracles and/or challengers and that can be communicated with.
+% Cryptocode makes heavy use of TIKZ (\url{https://www.ctan.org/pkg/pgf}) for this, which gives you 
+% quite some control over how things should look like. Additionally, as you can specify node names
+% (for example the outer box in the next example is called \enquote{A}) you can easily extend the pictures
+% by using plain TIKZ commands. Following is an example reduction. We discuss the details in Section~\ref{chap:bbr}.
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Reduction]
+% 	\pseudocode{
+% 		\text{Do something} \\
+% 		\text{Step 2} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+% 		\begin{bbrbox}[name=Adversary,minheight=2.25cm]
+% 		\end{bbrbox}
+%
+% 		\bbrmsgto{top=$m$}
+% 		\bbrmsgfrom{top=$\sigma$}
+% 		\bbrmsgtxt{\pseudocode{%
+% 			\text{more work} 
+% 		}}
+% 		\bbrmsgto{top=$m$}
+% 		\bbrmsgfrom{top=$\sigma$}
+%
+% 		\bbrqryto{side=$m$}
+% 		\bbrqryfrom{side=$b$}
+% 	\end{bbrenv}
+%
+% 	\pseudocode{
+% 		\text{finalize} 
+% 	}	
+%
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+%
+% 	\begin{bbroracle}{OraA}
+% 		\begin{bbrbox}[name=Oracle 1,minheight=1cm]
+% 		\end{bbrbox}
+% 	\end{bbroracle}
+% 	\bbroracleqryto{top=$m$}
+% 	\bbroracleqryfrom{top=$b$}
+%
+% 	\begin{bbroracle}{OraB}
+% 		\begin{bbrbox}[name=Oracle 2,minheight=1cm]
+% 		\end{bbrbox}
+% 	\end{bbroracle}
+% 	\bbroracleqryto{top=$m$}
+% 	\bbroracleqryfrom{top=$b$}
+% \end{bbrenv}
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\begin{bbrenv}{A}
+	\begin{bbrbox}[name=Reduction]
+	\pseudocode{
+		\text{Do something} \\
+		\text{Step 2} 
+	}
+
+	\begin{bbrenv}{B}
+		\begin{bbrbox}[name=Adversary,minheight=2.25cm]
+		\end{bbrbox}
+
+		\bbrmsgto{top=$m$}
+		\bbrmsgfrom{top=$\sigma$}
+		\bbrmsgtxt{\pseudocode{%
+			\text{more work} 
+		}}
+		\bbrmsgto{top=$m$}
+		\bbrmsgfrom{top=$\sigma$}
+
+		\bbrqryto{side=$m$}
+		\bbrqryfrom{side=$b$}
+	\end{bbrenv}
+
+	\pseudocode{
+		\text{finalize} 
+	}	
+
+	\end{bbrbox}
+	\bbrinput{input}
+	\bbroutput{output}
+
+	\begin{bbroracle}{OraA}
+		\begin{bbrbox}[name=Oracle 1,minheight=1cm]
+		\end{bbrbox}
+	\end{bbroracle}
+	\bbroracleqryto{top=$m$}
+	\bbroracleqryfrom{top=$b$}
+
+	\begin{bbroracle}{OraB}
+		\begin{bbrbox}[name=Oracle 2,minheight=1cm]
+		\end{bbrbox}
+	\end{bbroracle}
+	\bbroracleqryto{top=$m$}
+	\bbroracleqryfrom{top=$b$}
+\end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \amipagebreak
+% \section{Notation Macros}
+% \label{chap:commands}
+% \index{package options}
+% In this section we'll discuss the various commands for notation that can be 
+% loaded via package options.
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\usepackage[
+	n, % or lambda
+	advantage,
+	operators,
+	sets,
+	adversary,
+	landau,
+	probability,
+	notions,
+	logic,
+	ff,
+	mm,
+	primitives,
+	events,
+	complexity,
+	oracles,
+	asymptotics,
+	keys
+	]{cryptocode}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \textbf{Remark. } 
+% Note that the available command sets are far from complete and 
+% reflect my own work (especially once you get to cryptographic notions and primitives). 
+% In case you feel that something should be added feel free to drop me an email,
+% or better yet, open an issue and pull request on github (\url{https://github.com/arnomi/cryptocode}).
+%
+% \subsection{Security Parameter}
+% \index{security parameter|see {package options}}
+% \index{package options!security parameter}
+% In cryptography we make use of a security parameter which is usually denoted by $1^n$ or $1^\lambda$. The cryptocode
+% package, when loading either option \enquote{n} or option \enquote{lambda} will define the commands
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+ 	\secpar
+	\secparam
+	\SECPAR
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% The first command provides the \enquote{letter}, i.e., either $n$ or $\lambda$, whereas |\secparam| prints
+% |\1^\secpar| (i.e., $\secparam$ for option \enquote{n}). Finally, |\SECPAR| yields $N_0$ (resp.~$\Lambda$) 
+% and is meant to be used in sentences such as, \enquote{there exists $\SECPAR\in\NN$ such that for all $\secpar \geq \SECPAR$, ...}
+%
+% \subsection{Advantage Terms}
+% Load the package option ``advantage'' in order to define the command |\advantage| used to specify advantage terms such as:
+% \[
+% \advantage{prf}{\adv,\prf} 
+% \]
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ 	\advantage{prf}{\adv,\prf} 
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Specify an optional third parameter to replace the $(\secpar)$. 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ 	\advantage{prf}{\adv,\prf}[(arg)]
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% In order to redefine the styles in which superscript and subscript are set, or in case
+% you want to replace the term $\pcadvantagename$, redefine:
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+	\renewcommand{\pcadvantagename}{\mathsf{Adv}} 
+	\renewcommand{\pcadvantagesuperstyle}[1]{\mathrm{\MakeLowercase{#1}}}
+ 	\renewcommand{\pcadvantagesubstyle}[1]{#1}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Math Operators}
+% \index{operators|see {package options}}
+% \index{package options!operators}
+% \index{math operators|see {package options}}
+% \index{\textbackslash{} sample}
+% \index{\textbackslash{} floor}
+% \index{\textbackslash{} tfloor}
+% \index{\textbackslash{} ceil}
+% \index{\textbackslash{} tceil}
+% \index{\textbackslash{} Angle}
+% \index{\textbackslash{} tAngle}
+% \index{\textbackslash{} abs}	
+% \index{\textbackslash{} tabs}	
+% \index{\textbackslash{} norm}
+% \index{\textbackslash{} tnorm}
+% \index{\textbackslash{} concat}
+% \index{\textbackslash{} emptystring}
+% \index{\textbackslash{} argmax}
+% \index{\textbackslash{} argmin}
+% \index{\textbackslash{} pindist}
+% \index{\textbackslash{} cindist}
+% \index{\textbackslash{} sindist}
+% The \enquote{operators} option provides the following list of commands:
+%
+% \begin{center}
+% \begin{tabular}{l p{5cm} l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} & \textbf{Example}  \\\hline
+% |\sample| & Sampling from a distribution, or running a randomized procedure & $\sample$ & $b \sample \bin$ \\
+% |\floor{42.5}| & Rounding down & $\floor{42.5}$ &  \\
+% |\ceil{41.5}| & Rounding up & $\ceil{41.5}$ &  \\
+% |\Angle{x,y}| & Vector product & $\Angle{x,y}$ &  \\
+% |\abs{\frac{a}{b}}| & Absolute number & $\abs{\frac{a}{b}}$ &  \\
+% |\norm{x}| & Norm & $\norm{x}$ & \\
+% |\concat| & Verbose concatenation (I usually prefer simply \verb$\|$) & $\concat$ & $x \gets a\concat b$ \\
+% |\emptystring| & The empty string & $\emptystring$ & $x \gets \emptystring$ \\
+% |\argmax| & arg max & $\argmax$ & $\argmax_{x \in S} f(x)$ \\
+% |\argmin| & arg min & $\argmin$ & $\argmin_{x \in S} f(x)$ \\
+% |\pindist| & Perfect indistinguishability & $\pindist$ & $X \pindist Y$ \\
+% |\sindist| & Statistical indistinguishability & $\sindist$ & $X \sindist Y$ \\
+% |\cindist| & Computational indistinguishability & $\cindist$ & $X \cindist Y$
+% \end{tabular}
+% \end{center}
+%
+% The paired operators |\floor|, |\ceil|, |\Angle|, |\norm|, and |\abs| also
+% come in a form for flow text which does not scale the outer delimter. These
+% are |\tfloor|, |\tceil|, |\tAngle|, |\tnorm|, and |\tabs|.
+%
+% Note that $\argmax$ and $\argmin$ in block formulas will set their subscripts as limits, i.e.,:
+%
+% \[ \argmax_{x \in S} f(x) \]
+%
+% \subsection{Adversaries}
+% \index{adversary|see {package options}}
+% \index{package options!adversary}
+% The \enquote{adversary} option provides the following list of commands:
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\adv| & Adversary & $\adv$  \\
+% |\bdv| & Adversary & $\bdv$  \\
+% |\cdv| & Adversary & $\cdv$  \\
+% |\ddv| & Adversary & $\ddv$  \\
+% |\edv| & Adversary & $\edv$  \\
+% |\mdv| & Adversary & $\mdv$  \\
+% |\pdv| & Adversary & $\pdv$  \\
+% |\rdv| & Adversary & $\rdv$  \\
+% |\sdv| & Adversary & $\sdv$  
+% \end{tabular}
+% \end{center}
+% 
+% \noindent The style in which an adversary is rendered is controlled via 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pcadvstyle}[1]{\ensuremath{\mathcal{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+%
+% \subsection{Landau}
+% \index{Landau|see {package options}}
+% \index{package options!Landau}
+% The \enquote{landau} option provides the following list of commands:
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\bigO{n^2}| & Big O(micron) notation & $\bigO{n^2}$  \\
+% |\smallO{n^2}| & small o(micron) notation & $\smallO{n^2}$  \\
+% |\bigOmega{n^2}| & Big Omega notation & $\bigOmega{n^2}$  \\
+% |\bigTheta{n^2}| & Big  Theta & $\bigTheta{n^2}$  \\
+% |\orderOf| & On the order of & $f(n) \orderOf g(n)$
+% \end{tabular}
+% \end{center}
+%
+%
+% \subsection{Probabilities}
+% \index{probability|see {package options}}
+% \index{package options!probabilities}
+% The \enquote{probability} option provides commands for writing probabilities. Use
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \prob{X=x}
+ \probsub{x\sample{\bin^n}}{x=5}
+ \condprob{X=x}{A=b}
+ \condprobsub{x\sample{\bin^n}}{x=5}{A=b}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% to write basic probabilities, probabilities with explicit probability spaces and conditional probabilities.
+% \begin{align*}
+% & \prob{X=x} \\
+% & \probsub{x\sample{\bin^n}}{X=x} \\
+% & \condprob{X=x}{A=b} \\
+% & \condprobsub{x\sample{\bin^n}}{x=5}{A=b}
+% \end{align*}
+% You can control the probability symbol (Pr) by redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\probname}{Pr}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% The probability commands have a flowtext version |\tprob{X=X}| or |\tcondprob{X=x}{Y=y}|
+% which does not scale the delimiters.
+% In case the probability space is more complex, you can use 
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+  \probsublong{x,y\sample\set{1,2,3,4,5,6}, z = x + y}{z = 7} 
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% which yields
+% \[ \probsublong{x,y\sample\set{1,2,3,4,5,6}, z = x + y}{z = 7}.\]
+%
+%
+% For specifying expectations the following commands are defined
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \expect{X}
+ \expsub{x,y\sample\set{1,\ldots,6}}{x+y}
+ \condexp{X+Y}{Y>3}
+ \condexpsub{x,y\sample\set{1,\ldots,6}}{x+y}{y>3}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% yielding
+% \begin{align*}
+% & \expect{X} \\
+% & \expsub{x,y\sample\set{1,\ldots,6}}{x+y} \\
+% & \condexp{X+Y}{Y>3} \\
+% & \condexpsub{x,y\sample\set{1,\ldots,6}}{x+y}{y>3} 
+% \end{align*}
+% Again flowtext versions such as |\texpect{X}| are available.
+% To control the expactation symbol ($\mathbb{E}$), redefine
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\expectationname}{\ensuremath{\mathbb{E}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% The support $\supp{X}$ of a random variable $X$ can be written as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \supp{X}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% where again the name can be controlled via
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\supportname}{Supp}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% For denoting entropy and min-entropy use
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \entropy{X}
+ \minentropy{X}
+ \condentropy{X}{Y=5}
+ \condminentropy{X}{Y=5}
+ \condavgminentropy(X}{Y=5}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% This yields 
+% \begin{align*}
+% & \entropy{X} \\
+% & \minentropy{X} \\
+% & \condentropy{X}{Y=5} \\
+% & \condminentropy{X}{Y=5} \\
+% & \condavgminentropy{X}{Y=5}
+% \end{align*}
+%
+% \subsection{Sets}
+% \index{sets|see {package options}}
+% \index{package options!sets}
+% The \enquote{sets} option provides commands for basic mathematical sets.
+% You can write sets and sequences as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \set{1, \ldots, 10}
+ \sequence{1, \ldots, 10}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% which are typeset as
+% \begin{align*}
+% & \set{1, \ldots, 10} \\
+% & \sequence{1, \ldots, 10}
+% \end{align*}
+% In addition, the following commands are provided
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\bin| & The set containing 0 and 1 & $\bin$  \\
+% |\NN| & Natural numbers & $\NN$  \\
+% |\ZZ| & Integers & $\ZZ$  \\
+% |\QQ| & Rational numbers & $\QQ$  \\
+% |\CC| & Complex numbers & $\CC$  \\
+% |\RR| & Reals & $\RR$  \\
+% |\PP| & & $\PP$  \\
+% |\FF| & & $\FF$  \\
+% |\GG| & & $\GG$  \\
+% \end{tabular}
+% \end{center}
+%
+% The style in which sets are being set can be adapted by redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pcsetstyle}[1]{\ensuremath{\mathbb{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Cryptographic Notions}
+% \index{notions|see {package options}}
+% \index{package options!notions}
+% \index{Crypto notions|see {package options}}
+% The \enquote{notions} option defines the following list of commands:
+%
+% \begin{center}
+% \begin{tabular}{l p{8cm} l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\indcpa| & IND-CPA security for encryption schemes & $\indcpa$  \\
+% |\indcca| & IND-CCA security for encryption schemes & $\indcca$  \\
+% |\indccai| & IND-CCA1 security for encryption schemes & $\indccai$  \\
+% |\indccaii| &  IND-CCA2 security for encryption schemes & $\indccaii$  \\
+% |\ind| & IND security & $\ind$  \\
+% |\priv| & PRIV security for deterministic public-key encryption schemes & $\priv$  \\
+% |\prvcda| & PRV-CDA security (for deterministic public-key encryption schemes)& $\prvcda$  \\
+% |\prvrcda| & PRV\$-CDA security (for deterministic public-key encryption schemes) & $\prvrcda$  \\
+% |\kiae| & Key independent authenticated encryption & $\kiae$  \\
+% |\kdae| & Key dependent authenticated encryption & $\kdae$  \\
+% |\mle| & Message locked encryption & $\mle$  \\
+% |\uce| & Universal computational extractors & $\uce$  \\
+% |\eufcma| & Existential unforgeability under chosen message attack & $\eufcma$  \\
+% |\eufnacma| & Non-adaptive existential unforgeability under chosen message attack  & $\eufnacma$  \\
+% |\seufcma| & Strong existential unforgeability under chosen message attack & $\seufcma$  \\
+% |\eufko| &  Existential unforgeability under key only attack & $\eufko$  
+% \end{tabular}
+% \end{center}
+%
+% The style in which notions are displayed can be controlled via redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pcnotionstyle}[1]{\ensuremath{\mathrm{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Logic}
+% \index{logic|see {package options}}
+% \index{package options!logic}
+% The \enquote{logic} option provides the following list of commands:
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\AND| & Logical AND & $\AND$  \\
+% |\NAND| & Logical NAND & $\NAND$  \\
+% |\OR| & Logical OR & $\OR$  \\
+% |\NOR| & Logical NOR & $\NOR$  \\
+% |\XOR| & Logical XOR & $\XOR$  \\
+% |\XNOR| & Logical XNOR & $\XNOR$  \\
+% |\notimplies| & Negated implication & $\notimplies$ \\ 
+% |\NOT| & not & $\NOT$  \\
+% |\xor| & exclusive or & $\xor$  \\
+% |\false| & false & $\false$  \\
+% |\true| & true & $\true$  
+% \end{tabular}
+% \end{center}
+%
+%
+% \subsection{Function Families}
+% \index{ff|see {package options}}
+% \index{package options!ff}
+% \index{function families|see {package options}}
+% The \enquote{ff} option provides the following list of commands:
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\kgen| & Key generation & $\kgen$  \\
+% |\pgen| & Parameter generation & $\pgen$  \\
+% |\eval| & Evaluation & $\eval$  \\
+% |\invert| & Inversion & $\invert$  \\
+% |\il| & Input length & $\il$  \\
+% |\ol| & Output length & $\ol$  \\
+% |\kl| & Key length & $\kl$  \\
+% |\nl| & Nonce length & $\nl$  \\
+% |\rl| & Randomness length & $\rl$  
+% \end{tabular}
+% \end{center}
+%
+% The style in which these are displayed can be controlled via redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+%
+% \subsection{Machine Model}
+% \index{machine model|see {package options}}
+% \index{package options!mm}
+% \index{mm|see {package options}}
+% The \enquote{mm} option provides the following list of commands:
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\CRKT| & A circuit & $\CRKT$  \\
+% |\TM| & A Turing machine & $\TM$  \\
+% |\PROG| & A program & $\PROG$  \\
+% |\uTM| & A universal Turing machine & $\uTM$  \\
+% |\uC| & A universal Circuit & $\uC$  \\
+% |\uP| & A universal Program & $\uP$  \\
+% |\tmtime| & Time (of a TM) & $\tmtime$  \\
+% |\ppt| & Probabilistic polynomial time & $\ppt$  
+% \end{tabular}
+% \end{center}
+%
+% The style in which these are displayed can be controlled via redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pcmachinemodelstyle}[1]{\ensuremath{\mathsf{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \amipagebreak
+% \subsection{Crypto Primitives}
+% \index{primitives|see {package options}}
+% \index{package options!primitives}
+% \index{Crypto primitives|see {package options}}
+% The \enquote{primitives} option provides the following list of commands:
+%
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\prover| & Proover & $\prover$  \\
+% |\verifier| & Verifier & $\verifier$  \\
+% |\nizk| & Non interactie zero knowledge & $\nizk$  \\
+% |\hash| & A hash function & $\hash$  \\
+% |\gash| & A hash function& $\gash$  \\
+% |\fash| & A hash function & $\fash$  \\
+% |\pad| & A padding function & $\pad$  \\
+% |\enc| & Encryption  & $\enc$  \\
+% |\dec| & Decryption & $\dec$  \\
+% |\sig| & Signing & $\sig$  \\
+% |\sign| & Signing & $\sign$  \\
+% |\verify| & Verifying & $\verify$  \\
+% |\owf| & One-way function & $\owf$  \\
+% |\prf| & Pseudorandom function & $\prf$  \\
+% |\prp| & Pseudorandom permutation & $\prp$  \\
+% |\prg| & Pseudorandom generator & $\prg$  \\
+% |\obf| & Obfuscation & $\obf$  \\
+% |\iO| & Indistinguishability obfuscation & $\iO$  \\
+% |\diO| & Differing inputs obfuscation & $\diO$  \\
+% |\mac| & Message authentication & $\mac$  \\
+% |\puncture| & Puncturing & $\puncture$  \\
+% |\source| & A source & $\source$  \\
+% |\predictor| & A predictor & $\predictor$  \\
+% |\sam| & A sampler & $\sam$  \\
+% |\distinguisher| & A distinguisher & $\distinguisher$  \\
+% |\dist| & A distinguisher& $\dist$  \\
+% |\simulator| & A simulator & $\simulator$  \\
+% |\extractor| & An extractor & $\extractor$  \\
+% |\ext| & Shorthand for |\extractor| & $\ext$  
+% \end{tabular}
+% \end{center}
+%
+% The style in which these are displayed can be controlled via redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Oracles}
+% \index{oracles|see {package options}}
+% \index{package options!oracles}
+% The \enquote{oracles} option provides the following list of commands:
+%
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\oracle| & Generic oracle & $\oracle$  \\
+% |\oracle[LoR]| & Custom oracle & $\oracle[LoR]$  \\
+% |\ro| & Random oracle & $\ro$  \\
+% |\Oracle{\sign}| & Oracle version of procedure & $\Oracle{\sign}$  
+% \end{tabular}
+% \end{center}
+%
+% The style in which these are displayed can be controlled via redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pcoraclestyle}[1]{\ensuremath{\mathsf{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Events}
+% \index{events|see {package options}}
+% \index{package options!events}
+% The \enquote{events} option provides the following list of commands. 
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\event{E}| & Event \event{E} & $\event{E}$  \\
+% |\nevent{E}| & Negated event \event{E} & $\nevent{E}$  \\
+% |\bad| & Bad event & $\bad$  \\
+% |\nbad| & Bad event & $\nbad$  
+% \end{tabular}
+% \end{center}
+%
+% \subsection{Complexity}
+% \index{complexity|see {package options}}
+% \index{package options!complexity}
+% The \enquote{complexity} option provides the following list of commands:
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Result} \\\hline
+% |\complclass{myClass}| &  $\complclass{myClass}$  \\
+% |\cocomplclass{myClass}| &  $\cocomplclass{myClass}$  \\
+% |\npol| &  $\npol$  \\
+% |\conpol| &  $\conpol$  \\
+% |\pol| &  $\pol$  \\
+% |\bpp| & $\bpp$  \\
+% |\ppoly| & $\ppoly$  \\
+% |\NC{1}| &  $\NC1$  \\
+% |\AC{1}| & $\AC1$  \\
+% |\TC{1}| & $\TC1$ \\
+% |\AM| &  $\AM$  \\
+% |\coAM| &  $\coAM$ \\  
+% |\PH| &  $\PH$  \\
+% |\csigma{1}| &  $\csigma{1}$  \\
+% |\cpi{1}| &  $\cpi{1}$  \\
+% |\cosigma{1}| &  $\cosigma{1}$  \\
+% |\copi{1}| &  $\copi{1}$  
+% \end{tabular}
+% \end{center}
+%
+% The style in which these are displayed can be controlled via redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pccomplexitystyle}[1]{\ensuremath{\mathsf{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \amipagebreak
+% \subsection{Asymptotics}
+% \index{asymptotics|see {package options}}
+% \index{package options!asymptotics}
+% The \enquote{asymptotics} option provides the following list of commands:
+%
+% \begin{center}
+% \begin{tabular}{l l p{7.5cm}}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |\negl| & A negligible function & $\negl$  (\secpar\ is |\secpar|) \\
+% |\negl[x]| & A negligible function & $\negl[x]$ \\
+% |\negl[]| & A negligible function & $\negl[]$ \\
+% |\poly| & A polynomial & $\poly$ (\secpar\ is |\secpar|) \\
+% |\poly[x]| & A polynomial & $\poly[x]$ \\
+% |\poly[]| & A polynomial & $\poly[]$ \\
+% |\pp| & some polynomial $\pp$ & $\pp$  \\
+% |\pp[t]| & some custom polynomial $\pp[t]$ & $\pp[t]$  \\
+% |\cc| & some polynomial $\cc$ & $\cc$  \\
+% |\ee| & some polynomial $\ee$ & $\ee$  \\
+% |\kk| & some polynomial $\kk$ & $\kk$  \\
+% |\mm| & some polynomial $\mm$ & $\mm$  \\
+% |\nn| & some polynomial $\nn$ & $\nn$  \\
+% |\qq| & some polynomial $\qq$ &  $\qq$  \\
+% |\rr| & some polynomial $\rr$ &  $\rr$  
+% \end{tabular}
+% \end{center}
+%
+% The style in which these are displayed can be controlled via redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pcpolynomialstyle}[1]{\ensuremath{\mathrm{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Keys}
+% \index{keys|see {package options}}
+% \index{package options!keys}
+% The \enquote{keys} option provides the following list of commands:
+%
+%
+% \begin{center}
+% \begin{tabular}{l l l}
+% \textbf{Command} & \textbf{Description} & \textbf{Result} \\\hline
+% |pk| &public key & $\pk$  \\
+% |vk| &  verification key& $\vk$  \\
+% |sk| & secret key&  $\sk$  \\
+% |key| & a plain key& $\key$  \\
+% |key[xk]| & custom key & $\key[xk]$  \\
+% |hk| & hash key&  $\hk$  \\
+% |gk| &gash key & $\gk$  \\
+% |fk| & function key & $\fk$  \\
+% |st| & state & $\st$  \\
+% |state| & state & $\state$  \\
+% |state{myState}| & custom state & $\state{myState}$  
+% \end{tabular}
+% \end{center}
+%
+% The style in which these are displayed can be controlled via redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pckeystyle}[1]{\ensuremath{\mathsf{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+%
+% \amipagebreak
+% \section{Pseudocode}
+% \label{chap:pseudocode}
+%
+% \subsection{Basics}
+% \index{\textbackslash pseudocode}
+%
+% The cryptocode package provides the command |\pseudocode| for typesetting algorithms.
+% Consider the following definition of an IND-CPA game
+%
+% \begin{pchstack}[center]
+% \pseudocode{%
+%    b \sample \bin  \\
+%    (\pk,\sk) \sample \kgen (\secparam)  \\
+%    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+%    c \sample \enc(\pk,m_b)  \\
+%    b' \sample \adv(\secparam, \pk, c)  \\
+%    \pcreturn b = b' }
+% \end{pchstack}
+% which is generated by 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{pchstack}[center] 
+\pseudocode{
+    b \sample \bin  \\
+    (\pk,\sk) \sample \kgen (\secparam)  \\
+    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+    c \sample \enc(\pk,m_b)  \\
+    b' \sample \adv(\secparam, \pk, c)  \\
+	\pcreturn b = b' }
+\end{pchstack}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% First note that |\pseudocode| on its own does not space itself. For laying out
+% one (or multiple) code blocks cryptocode
+% defines stacking environemnts such as |\pchstack| and |\pcvstack| that we discuss
+% in Section~\ref{chap:stacking}. Wrapping a single pseudocode in a |\pchstack|
+% as in the above example generates a nicely offset code block. 
+%
+% \medskip
+% As code blocks are most often not used in flow text, cryptocode offers the shorthand
+% |\pseudocodeblock| which centers and offsets a pseudocode block as above. We thus
+% get the very same by writing
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\pseudocodeblock{
+    b \sample \bin  \\
+    (\pk,\sk) \sample \kgen (\secparam)  \\
+    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+    c \sample \enc(\pk,m_b)  \\
+    b' \sample \adv(\secparam, \pk, c)  \\
+	\pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% We can also define custom block commands, for example, the following defines
+% a command |\pcb| that offsets and centers code and draws a tight fitting box around the code block:
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\createpseudocodeblock{pcb}{center,boxed}{}{}{}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% (We discuss creating custom pseudocode commands in detail in Section~\ref{sec:custom:pc:command}).
+% If we now use |\pcb| as just defined in the above example, we obtain the following
+% nicely spaced and boxed result.
+% \pcb{
+%    b \sample \bin  \\
+%    (\pk,\sk) \sample \kgen (\secparam)  \\
+%    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+%    c \sample \enc(\pk,m_b)  \\
+%    b' \sample \adv(\secparam, \pk, c)  \\
+%    \pcreturn b = b' }
+% which is generated as
+% \iffalse
+%<*example> 
+% \fi
+ \begin{lstlisting}
+ \pcb{
+    b \sample \bin  \\
+    (\pk,\sk) \sample \kgen (\secparam)  \\
+    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+    c \sample \enc(\pk,m_b)  \\
+    b' \sample \adv(\secparam, \pk, c)  \\
+    \pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \textbf{Remark. } In the following we will use this boxed representation for the examples, but 
+% use |\pseudocodeblock| in the corresponding code listings.
+%
+% \medskip
+% As you can see, the pseudocode command provides a math based environment where you can simply start typing your pseudocode
+% separating lines by |\\|.
+%
+%
+%
+% \subsubsection{Customizing Pseudocode}
+% \index{lnstart}
+% \index{head}
+% \index{lnstartright}
+% \index{linenumbering}
+% \index{syntaxhighlight}
+% \index{keywords}
+% \index{keywordsindent}
+% \index{codesize}
+% \index{keywordsunindent}
+% \index{keywordsuninindent}
+% \index{addkeywords}
+% \index{altkeywords}
+% \index{mode}
+% \index{space}
+% \index{xshift}
+% \index{colsep}
+% \index{addtolength}
+% \index{nodraft}
+% \index{yshift}
+% \index{bodylinesep}
+% \index{headlinesep}
+% \index{jot}
+% \index{beginline}
+% \index{endline}
+% \index{minlineheight}
+% \index{\textbackslash{}pcminlineheight}
+%
+% Besides the mandatory argument the |\pseudocode| command can take an optional argument which consists of a list of key=value pairs
+% separated by commas.
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocode[options]{body}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% The following parameters are available:
+% \begin{description}
+% \item[head]
+% A header for the code
+% \item[width]
+% An exact width. If no width is specified, cryptocode tries to automatically compute the correct width.
+% \item[lnstart]
+% The starting line number when using line numbering.
+% \item[lnstartright]
+% The starting line number for right aligned line numberswhen using line numbering.
+% \item[linenumbering]
+% Enables line numbering.
+%
+% \item[skipfirstln]
+% Starts line numbering on the second line.
+%
+% \item[minlineheight]
+% Specify a minimum height for each line. Can be globally set by redefining |\pcminlineheight|.
+%
+% \item[syntaxhighlight]
+% When set to \enquote{auto} cryptocode will attempt to automatically hightlight keywords such as \enquote{for}, \enquote{foreach}
+% and \enquote{return}. Note that this feature should be regarded as experimental. In particular, it is rather slow.
+% \item[keywords]
+% Provide a comma separated list of keywords for automatic syntax highlighting. To customize the behavior of automatic spacing 
+% you can provide keywords as
+% \begin{description}
+% \item[keywordsindent]
+% After seeing this keyword all following lines will be indented one extra level.
+% \item[keywordsunindent]
+% After seeing this keyword the current and all following lines will be unindented one extra level.
+% \item[keywordsuninindent]
+% After seeing this keyword the current line will be unindented one level.
+% \end{description}
+% \item[addkeywords]
+% Provide additional keywords for automatic syntax highlighting.
+% \item[altkeywords]
+% Provide a second list of keywords for automatic syntax highlighting that are highlighted differently.
+% \item[mode]
+% When set to text pseudocode will not start in math mode but in text mode.
+% \item[space]
+% Allows you to enable automatic spacing mode. If set to \enquote{keep} the spaces in the input are preserved.
+% If set to \enquote{auto} it will try to detect spacing according to keywords such as \enquote{if} and \enquote{fi}.
+% \item[codesize]
+% Allows to specify the fontsize for the pseudocode. Set to |\scriptsize| for a smaller size.
+%
+% \item[colspace]
+% Allows to insert spacing between columns. In particular this allows to also overlap columns by inserting negative space.
+%
+% \item[jot]
+% Allows to specify extra space between each line. Use |jot=1mm|.
+%
+% \item[beginline]
+% Allows to specify a macro that is placed at the beginning of each line.
+%
+% \item[endline]
+% Allows to specify a macro that is placed at the end of each line.
+%
+% \item[xshift]
+% Allows horizontal shifting
+% \item[yshift]
+% Allows horizontal shifting
+%
+% \item[headlinesep]
+% Specifies the distance between header and the line. By default set to 0pt which can be globally overwritten by setting length |\pcheadlinesep|.
+% \item[bodylinesep]
+% Specifies the distance between body and the line. By default set to |0.3\baselineskip| which can be globally overwritten by setting length |\pcbodylinesep|.
+% \item[colsep]
+% Defines the space between columns.
+%
+% \item[headheight]
+% Specifies the height of the header. By default set to 3.25ex which can be globally overwritten by setting length |\pcheadheight|.
+%
+% \item[headlinecmd]
+% Allows to overwrite which command is used to draw the bar below the headline. Defaults to |\hrule|.
+%
+% \item[addtolength]
+% Is added to the automatically computed width of the pseudocode (which does not take colsep into account). 
+%
+% \item[valign]
+% 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}.
+%
+% \item[nodraft]
+% Forces syntax highlighting also in draft mode.
+% \end{description}
+% The following code 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock[linenumbering,syntaxhighlight=auto,head=Header]{ return null }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% creates 
+% \begin{center}
+% \pcb[linenumbering,syntaxhighlight=auto,head=Header]{ return null }
+% \end{center}
+%
+% \subsubsection{Customized Pseudocode Commands}\label{sec:custom:pc:command}
+% \index{\textbackslash procedure}
+% \index{\textbackslash createpseudocodecommand}
+% \index{\textbackslash createprocedurecommand}
+%
+% Besides the  |\pseudocode| and |\pseudocodeblock|  command the command  |\procedure|
+% (and its block variant |\procedureblock| provides easy access to generate code with a header. 
+% They take the following form
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedure[options]{Header}{Body}
+ \procedureblock[options]{Header}{Body}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection*{Examples}
+% \procb{$\indcpa_\enc^\adv(\secpar)$}{
+%    b \sample \bin  \\
+%    (\pk,\sk) \sample \kgen(\secparam)  \\
+%    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+%    c \sample \enc(\pk,m_b)  \\
+%    b' \sample \adv(\secparam, \pk, c)  \\
+%    \pcreturn b = b' }
+% which is generated as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock{$\indcpa_\enc^\adv(\secpar)$}{
+    b \sample \bin  \\
+    (\pk,\sk) \sample \kgen(\secparam)  \\
+    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+    c \sample \enc(\pk,m_b)  \\
+    b' \sample \adv(\secparam, \pk, c)  \\
+    \pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% 
+% 
+% \medskip
+% You can define customized pseudocode commands which either take one optional argument and two mandatory arguments (as the procedure command)
+% or one optional and one mandatory argument (as the pseudocode command). The following
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\createpseudocodecommand{mypseudocode}{}{}{linenumbering}
+\createprocedurecommand{myprocedure}{}{}{linenumbering}
+\createpseudocodeblock{pcb}{center,boxed}{}{}{linenumbering}
+\createprocedureblock{procb}{center,boxed}{}{}{linenumbering}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% creates the commands |\mypseudocode| and |\myprocedure| with line numbering always enabled as well
+% as the block commands |\pcb| and |\procb| also with line numbering enabled. The created commands
+% have an identical interface as the |\pseudocode| (resp.~|\procedure|) command.
+% The two arguments that we kept empty when generating the commands allows us to specify commands that are executed at the
+% very beginning when the command is called (first empty argument) and a prefix for the header.
+% For example, the command created as 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\createprocedureblock{expproc}{center,boxed}{}{$\mathrm{Experiment}$\xspace}{linenumbering}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% could be used as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \expproc{$\indcpa_\enc^\adv(\secpar)$}{
+    b \sample \bin  \\
+    (\pk,\sk) \sample \kgen(\secparam)  \\
+    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+    c \sample \enc(\pk,m_b)  \\
+    b' \sample \adv(\secparam, \pk, c)  \\
+    \pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% This results in
+% \createprocedureblock{expproc}{center,boxed}{}{$\mathrm{Experiment}$\xspace}{linenumbering}
+%  \expproc{$\indcpa_\enc^\adv(\secpar)$}{%
+% b \sample \bin  \\
+%(\pk,\sk) \sample \kgen(\secparam)  \\
+%(m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+%c \sample \enc(\pk,m_b)  \\
+%b' \sample \adv(\secparam, \pk, c)  \\
+% \pcreturn b = b' }
+%
+%
+% \subsection{Indentation}
+% \index{indentation}
+% \index{\textbackslash pcind}
+% \index{\textbackslash t}
+%
+% In order to indent code use |\pcind| or short |\t|. You can also use customized spacing such as |\quad| or |\hspace|
+% when using the pseudocode command in math mode.
+% \pcb{
+%    \pcfor i = 1..10 \pcdo  \\
+%    \pcind T[i] \sample \bin^n \\
+%    \pcfor i = 1..10 \pcdo  \\
+%    \t T[i] \sample \bin^n }
+% which is generated as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock{
+    \pcfor i = 1..10 \pcdo  \\
+    \pcind T[i] \sample \bin^n  \\
+    \pcfor i = 1..10 \pcdo  \\
+    \t T[i] \sample \bin^n }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% You can specify multiple levels via the optional first argument
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \t[level] % \pcind[level]
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% \pcb{
+%    \pcfor i = 1..10 \pcdo  \\
+%    \t T[i] \sample \bin^n  \\
+%    \t\t T[i] \sample \bin^n \\
+%    \t[3] T[i] \sample \bin^n \\
+%    \t[4] T[i] \sample \bin^n \\
+%    \t[5] T[i] \sample \bin^n }
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock{
+    \pcfor i = 1..10 \pcdo  \\
+    \t T[i] \sample \bin^n  \\
+    \t\t T[i] \sample \bin^n \\
+    \t[3] T[i] \sample \bin^n \\
+    \t[4] T[i] \sample \bin^n \\
+    \t[5] T[i] \sample \bin^n }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \index{\textbackslash pcindentname}
+% You can customize the indentation shortcut by redefining
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \renewcommand{\pcindentname}{t}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection*{Automatic Indentation}
+% The pseudocode command comes with an option \enquote{space=auto} which tries to detect the correct indentation from the use of
+% keywords. When it sees one of the following keywords
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pcif, \pcfor, \pcwhile, \pcrepeat, \pcforeach
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% it will increase the indentation starting from the next line. It will again remove the indentation on seeing 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pcfi, \pcendif, \pcendfor, \pcendwhile, \pcuntil, \pcendforeach
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Additionally, on seeing
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pcelse, \pcelseif
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% it will remove the indentation for that particular line. Thus the following 
+% \pcb[space=auto]{%
+% \pcfor a \in [10] \pcdo \\
+% 	\pcfor a \in [10] \pcdo \\
+% 		\pcfor a \in [10] \pcdo \\
+% 			\pcif a = b \pcthen \\
+% 				\text{some operation} \\
+% 			\pcelseif a = c \pcthen \\
+% 				\text{some operation} \\
+% 			\pcelse \\
+% 				\text{some default operation} \\
+% 			\pcfi \\
+% 		\pcendfor \\
+% 	\pcendfor \\
+% \pcendfor \\
+% \pcreturn a}
+% can be obtained by:
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock[space=auto]{%
+ \pcfor a \in [10] \pcdo \\
+ 	\pcfor a \in [10] \pcdo \\
+ 		\pcfor a \in [10] \pcdo \\
+ 			\pcif a = b \pcthen \\
+ 				\text{some operation} \\
+ 			\pcelseif a = c \pcthen \\
+ 				\text{some operation} \\
+ 			\pcelse \\
+ 				\text{some default operation} \\
+ 			\pcfi \\
+ 		\pcendfor \\
+ 	\pcendfor \\
+ \pcendfor \\
+ \pcreturn a}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Note that the manual indentation in the above example is not necessary for the outcome. Further note that the same
+% works when using automatic syntax highlighting (see Section~\ref{sec:syntaxhighlight}).
+%
+% \subsubsection*{Keep Input Indentation (experimental)}
+% \label{sec:keepindent}
+% The pseudocode package comes with an \emph{experimental} feature that preserves the spacing in the input. This can be enabled with
+% the option \enquote{space=keep}. 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{center}
+ \pseudocode[space=keep]{%
+ \pcfor i = 1..10 \pcdo  \\
+     T[i] \sample \bin^n  \\
+         T[i] \sample \bin^n \\
+             T[i] \sample \bin^n \\
+                 T[i] \sample \bin^n \\
+					 T[i] \sample \bin^n }
+ \end{center}					 
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% This yields the following result
+% \begin{center}
+% \pseudocode[space=keep]{%
+% \pcfor i = 1..10 \pcdo  \\
+%     T[i] \sample \bin^n  \\
+%         T[i] \sample \bin^n \\
+%             T[i] \sample \bin^n \\
+%                 T[i] \sample \bin^n \\
+%                     T[i] \sample \bin^n }
+% \end{center}
+%
+% Note that automatic spacing only works when the |\pseudocode| command is not wrapped within another command.
+% Thus in order to get a frame box |\fbox{\pseudocode[space=keep]{code}}| will not work but you would need to use
+% an environment such as one offered by the \emph{mdframed} package ((\url{https://www.ctan.org/pkg/mdframed}). Also see
+% Section~\ref{sec:keepindent-problem}.
+%
+% \subsection{Textmode}
+% \index{text mode}
+%
+% By default pseudocode enables \LaTeX' math mode. You can change this behavior and tell the pseudocode command to interpret the content
+% in text mode by setting the option \enquote{mode=text}.
+% \begin{center}
+% \fbox{\pseudocode[mode=text]{%
+% This is \\
+% \t simply text}}
+% \end{center}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock[mode=text]{%
+ This is \\
+ \t simply text}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Syntax Highlighting}
+% \label{sec:syntaxhighlight}
+%
+% \index{\textbackslash pcabort}
+% \index{\textbackslash pcfail}
+% \index{\textbackslash pccontinue}
+% \index{\textbackslash pccomment}
+% \index{\textbackslash pcdo}
+% \index{\textbackslash pcdone}
+% \index{\textbackslash pcelse}
+% \index{\textbackslash pcelseif}
+% \index{\textbackslash pcfi}
+% \index{\textbackslash pcendif}
+% \index{\textbackslash pcforeach}
+% \index{\textbackslash pcendforeach}
+% \index{\textbackslash pcglobvar}
+% \index{\textbackslash pcif}
+% \index{\textbackslash pcin}
+% \index{\textbackslash pcnew}
+% \index{\textbackslash pcnull}
+% \index{\textbackslash pcparse}
+% \index{\textbackslash pcrepeat}
+% \index{\textbackslash pcuntil}
+% \index{\textbackslash pcreturn}
+% \index{\textbackslash pcthen}
+% \index{\textbackslash pctrue}
+% \index{\textbackslash pcwhile}
+% \index{\textbackslash pcendwhile}
+%
+%
+% In the above examples we have used commands |\pcreturn| and |\pcfor| to highlight certain keywords.
+% Besides the \emph{pcreturn}, \emph{pcfor} and \emph{pcdo} (where the pc stands for pseudocode) that were used in the above 
+% examples the package defines the following set of constants:
+%
+% \begin{center}
+% \begin{tabular}{lll}
+%  \textbf{command}  & \textbf{outcome} \\ 
+%   |\pcabort| & \pcabort\\
+%   |\pccontinue| & \pccontinue \\
+%   |\pccomment{comment}| & \pccomment{comment} \\
+%   |\pccomment[2em]{comment}| & \pccomment[2em]{comment} \\
+%   |\pclinecomment{comment}| & \pclinecomment{comment} \\
+%   |\pcdo| & \pcdo \\
+%   |\pcdone| & \pcdone \\
+%   |\pcfail| & \pcfail \\
+%   |\pcfalse| & \pcfalse \\
+%   |\pcif| & \pcif \\
+%   |\pcfi| & \pcfi \\
+%   |\pcendif| & \pcendif \\ 
+%   |\pcelse| & \pcelse \\
+%   |\pcelseif| & \pcelseif \\ 
+% |\pcfor| & \pcfor \\
+% |\pcendfor| & \pcendfor \\ 
+% |\pcforeach| & \pcforeach \\
+% |\pcendforeach| & \pcendforeach \\ 
+%   |\pcglobvar| & \pcglobvar \\
+%   |\pcin| & \pcin \\
+%   |\pcnew| & \pcnew \\
+%   |\pcnull| & \pcnull \\
+%   |\pcparse| & \pcparse \\
+%   |\pcrepeat{10}| & \pcrepeat{10} \\
+%   |\pcreturn| & \pcreturn \\ 
+%   |\pcuntil| & \pcuntil \\
+%   |\pcthen| & \pcthen \\
+%   |\pctrue| & \pctrue \\
+%   |\pcwhile| & \pcwhile \\
+%   |\pcendwhile| & \pcendwhile \\
+% \end{tabular}
+% \end{center}
+% Note that |\pcdo|, |\pcin| and |\pcthen| have a leading space. This is due to their usual usage scenarios
+% such as
+% \pseudocodeblock{\pcfor i \pcin \{1,\ldots,10\}}
+% Furthermore all constants have a trailing space. This can be removed by adding the optional parameter [] such as
+% \pseudocodeblock{\pcfor i \pcin[] \{1,\ldots,10\}}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock{\pcfor i \pcin[] \{1,\ldots,10\}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \index{highlight keywords}
+% \index{emphasize|see highlight keywords}
+% \index{\textbackslash highlightkeyword}
+% In order to change the font you can overwrite the command \lstinline{\highlightkeyword} which is defined as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Automatic Syntax Highlighting (Experimental)}
+% The pseudocode command comes with an experimental (and rather slow) feature to automatically highlight keywords. 
+% This can be activated via
+% the option \enquote{syntaxhighlight=auto}. The preset list of keywords it looks for are
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+for,foreach,{return },return,{ do },{ in },new,if, null, true,{until },{ to }, false,{ then},repeat,else if,elseif,while,else,done
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% 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}.
+% Via the option \enquote{keywords} you can provide a custom list of keywords.
+% Thus the following bubblesort variant (taken from \url{http://en.wikipedia.org/wiki/Bubble_sort}) 
+% \procb[syntaxhighlight=auto]{Bubblesort(A : list of items)}{
+%    n \gets \mathsf{length}(A) \\
+%    repeat \\
+%    \t s \gets false \\
+%    \t  for i = 1 to n-1 do \\
+%    \t\t  \pclinecomment{if this pair is out of order} \\
+%    \t\t   if A[i-1] > A[i] then \\
+%    \t\t\t \pclinecomment{swap them and remember something changed} \\
+%    \t\t\t     \mathsf{swap}( A[i-1], A[i] ) \\
+%    \t\t\t       s \gets true \\
+%    until \neg s }
+% \noindent can be typeset as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock[syntaxhighlight=auto]{Bubblesort(A : list of items)}{
+    n \gets \mathsf{length}(A) \\
+    repeat \\
+    \t s \gets false \\
+    \t  for i = 1 to n-1 do \\
+    \t\t  \pclinecomment{if this pair is out of order} \\
+    \t\t   if A[i-1] > A[i] then \\
+    \t\t\t \pclinecomment{swap them and remember something changed} \\
+    \t\t\t     \mathsf{swap}( A[i-1], A[i] ) \\
+    \t\t\t       s \gets true \\
+    until \neg s }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \index{addkeywords}
+% You can also define additional keywords using the \enquote{addkeywords} option. 
+% This would allow us to specify \enquote{length} and \enquote{swap} in the above example. 
+% \procb[syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
+%    n \gets \mathsf{length}(A) \\
+%    repeat \\
+%    \t s \gets false \\
+%    \t  for i = 1 to n-1 do \\
+%    \t\t  \pclinecomment{if this pair is out of order} \\
+%    \t\t   if A[i-1] > A[i] then \\
+%    \t\t\t \pclinecomment{swap them and remember something changed} \\
+%    \t\t\t     \mathsf{swap}( A[i-1], A[i] ) \\
+%    \t\t\t       s \gets true \\
+%    until \neg s }
+% can be typeset as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock[syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
+    n \gets \mathsf{length}(A) \\
+    repeat \\
+    \t s \gets false \\
+    \t  for i = 1 to n-1 do \\
+    \t\t  \pclinecomment{if this pair is out of order} \\
+    \t\t   if A[i-1] > A[i] then \\
+    \t\t\t \pclinecomment{swap them and remember something changed} \\
+    \t\t\t     \mathsf{swap}( A[i-1], A[i] ) \\
+    \t\t\t       s \gets true \\
+    until \neg s }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% We can also combine automatic syntax highlighting with automatic spacing in which case we need
+% to insert \enquote{group end} keywords:
+% \procb[space=auto,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
+% n \gets length(A) \\
+% repeat \\
+%     s \gets false \\
+%     for i=1 to n-1 do \\
+%         \pclinecomment{assuming this pair is out of order} \\
+%         if A[i-1]>A[i] then \\
+%             \pclinecomment{swap them and remember something changed} \\
+%             swap(A[i-1], A[i]) \\
+%             s \gets true \\
+%         endif \\
+%      endfor \\
+% until \neg s }
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock[space=auto,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
+ n \gets length(A) \\
+ repeat \\
+     s \gets false \\
+     for i=1 to n-1 do \\
+         \pclinecomment{assuming this pair is out of order} \\
+         if A[i-1]>A[i] then \\
+             \pclinecomment{swap them and remember something changed} \\
+             swap(A[i-1], A[i]) \\
+             s \gets true \\
+         endif \\
+      endfor \\
+ until \neg s }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection*{Alternative Keywords}
+% \index{altkeywords}
+% There is a second keyword list that you can add keywords to which are highlighted not via |\highlightkeyword| but via |\highlightaltkeyword|
+% where alt stands for alternate. This allows you to have two different keyword styles which are by default defined as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
+ \newcommand{\highlightaltkeyword}[1]{\ensuremath{\mathsf{#1}}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% This allows you to rewrite the above example and emphasize the different nature of swap and length.
+% \procb[space=auto,syntaxhighlight=auto,altkeywords={swap,length}]{Bubblesort(A : list of items)}{
+% n \gets length(A) \\
+% repeat \\
+%     s \gets false \\
+%     for i=1 to n-1 do \\
+%         \pclinecomment{assuming this pair is out of order} \\
+%         if A[i-1]>A[i] then \\
+%             \pclinecomment{swap them and remember something changed} \\
+%             swap(A[i-1], A[i]) \\
+%             s \gets true \\
+%         endif \\
+%      endfor \\
+% until \neg s }
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock[space=auto,syntaxhighlight=auto,addkeywords={swap,length}]{Bubblesort(A : list of items)}{
+ n \gets length(A) \\
+ repeat \\
+     s \gets false \\
+     for i=1 to n-1 do \\
+         \pclinecomment{assuming this pair is out of order} \\
+         if A[i-1]>A[i] then \\
+             \pclinecomment{swap them and remember something changed} \\
+             swap(A[i-1], A[i]) \\
+             s \gets true \\
+         endif \\
+      endfor \\
+ until \neg s }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection*{Draft Mode}
+% \index{nodraft}
+% \index{performance}
+% \index{draft mode}
+% Automatic syntax highlighting is a somewhat expensive operation as it requires several rounds of regular expression matching.
+% In order to speed up compilation the pseudocode command will not attempt automatic highlighting when the document is in draft mode.
+% When in draft mode and you want to force a specific instance of |\pseudocode| to render the code with automatic syntax
+% highlighting you can use the option |nodraft|.
+%
+%
+% \subsection{Line Numbering}
+% \index{line numbering}
+% \index{\textbackslash pcln}
+% \index{\textbackslash pclnr}
+% \index{\textbackslash pcrln}
+% The pseudocode command allows to insert line numbers into pseudocode. 
+% You can either manually control line numbering or simply turn on the option
+% |linenumbering|.
+% \procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+%   b \sample \bin \\
+%  (\pk,\sk) \sample \kgen(\secparam)  \\
+%   \label{my:line:label}   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+%   c \sample \enc(\pk,m_b)  \\
+%   b' \sample \adv(\secparam, \pk, c)  \\
+%  \pcreturn b = b' }
+% is generated by 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+   b \sample \bin \\
+  (\pk,\sk) \sample \kgen(\secparam)  \\
+   \label{my:line:label}   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+   c \sample \enc(\pk,m_b)  \\
+   b' \sample \adv(\secparam, \pk, c)  \\
+  \pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Note that you can use labels. In the above example |\label{my:line:label}| points to~\ref{my:line:label}.
+%
+% \subsubsection{Skipping Line Numbers}
+% \index{skipfirstln}
+% \index{\textbackslash pcskipln}
+%
+% When using automatic line numbering, you can skip line numbers by inserting a |\pcskipln| command.
+% This causes the line number on the \emph{next line} to be supressed. In order to suppress the first
+% line number use the option |skipfirstln|. Thus the following 
+% \pcb[linenumbering,skipfirstln,mode=text]{
+%  \pclinecomment{Some comment on first line} \\
+%  Some code \pcskipln\\
+%  \pclinecomment{Some other comment } \\
+%  Some code }
+% is generated by 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock[linenumbering,skipfirstln,mode=text]{
+	\pclinecomment{Some comment on first line} \\
+	Some code \pcskipln\\
+	\pclinecomment{Some other comment } \\
+	Some code }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+%
+% \subsubsection{Manually Inserting Line Numbers}
+% In order to manually insert line numbers use the command |\pcln|.
+% \procb{$\indcpa_\enc^\adv(\secparam)$}{%
+%  \pcln  b \sample \bin \\
+%  \pcln   (\pk,\sk) \sample \kgen(\secparam)  \\
+%  \pcln\label{my:line:label2}   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+%  \pcln   c \sample \enc(\pk,m_b)  \\
+%  \pcln   b' \sample \adv(\secparam, \pk, c)  \\
+%  \pcln   \pcreturn b = b' }
+% is generated by 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedure{$\indcpa_\enc^\adv(\secparam)$}{
+  \pcln  b \sample \bin \\
+  \pcln   (\pk,\sk) \sample \kgen(\secparam)  \\
+  \pcln\label{my:line:label2}   (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+  \pcln   c \sample \enc(\pk,m_b)  \\
+  \pcln   b' \sample \adv(\secparam, \pk, c)  \\
+  \pcln   \pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Note that labels also work when manually placing line numbers. In the above example
+% label \emph{my:line:label2} points to line number~\ref{my:line:label2}.
+%
+%
+%
+% \subsubsection{Start Values}
+% You can specify the start value (minus one) of the counter by setting the option |lnstart|.
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedure[lnstart=10,linenumbering]{Header}{Body}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% \procb[lnstart=10,linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+%   b \sample \bin \\
+%    (\pk,\sk) \sample \kgen(\secparam)  \\
+%    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+%    c \sample \enc(\pk,m_b)  \\
+%    b' \sample \adv(\secparam, \pk, c)  \\
+%    \pcreturn b = b' }
+%
+% \subsubsection{Separators}
+% \index{\textbackslash pclnseparator}
+% The command |\pclnseparator| defines the separator between code and line number. By
+% default the left separator is set to (:) colon. Also see Section~\ref{sec:protocol:separator}.
+%
+% \subsubsection{Style}
+% \index{\textbackslash pclnstyle}
+% The style in which line numbers are set can be controlled by redefining |\pclnstyle|.
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\renewcommand\pclnstyle[1]{\text{\scriptsize#1}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% For example, to set line numbers in normal font and dot separated use
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\renewcommand{\pclnstyle}[1]{\text{#1}}
+\renewcommand{\pclnseparator}{.}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% { 
+% \renewcommand{\pclnstyle}[1]{\text{#1}}
+% \renewcommand{\pclnseparator}{.}
+%	\procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+%   b \sample \bin \\
+%    (\pk,\sk) \sample \kgen(\secparam)  \\
+%    (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+%    c \sample \enc(\pk,m_b)  \\
+%    b' \sample \adv(\secparam, \pk, c)  \\
+%    \pcreturn b = b' }}
+%
+%
+% \subsection{Subprocedures}
+% \index{subprocedure}
+% The pseudocode package allows the typesetting of subprocedures such as
+%
+% \procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+%    b \sample \bin  \\
+%    (\pk,\sk) \sample \kgen(\secparam)  \\
+%    (m_0,m_1) \sample  \begin{subprocedure}%
+%  \dbox{\procedure{$\adv(\secparam, \pk, c)$}{%
+%   	 \text{Step 1}  \\
+%   	 \text{Step 2}  \\
+% 	 \pcreturn m_0, m_1 }}
+%   \end{subprocedure}  \\
+%    c \sample \enc(\pk,m_b)  \\
+%    b' \sample \adv(\secparam, \pk, c)  \\
+%    \pcreturn b = b' }
+%
+% To create a subprocedure use the |subprocedure| environment. The above example is generated via
+% \iffalse
+%<*example>
+% \fi
+  \begin{lstlisting}
+ \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+    b \sample \bin  \\
+    (\pk,\sk) \sample \kgen(\secparam)  \\
+    (m_0,m_1) \sample \begin{subprocedure}%
+  \dbox{\procedure{$\adv(\secparam, \pk, c)$}{%
+   	 \text{Step 1}  \\
+   	 \text{Step 2}  \\
+ 	 \pcreturn m_0, m_1 }}
+   \end{subprocedure}  \\
+    c \sample \enc(\pk,m_b)  \\
+    b' \sample \adv(\secparam, \pk, c)  \\
+    \pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Here the dbox command (from the dashbox package) is used to generate a dashed box around the sub procedure. 
+%
+% \subsubsection{Numbering in Subprocedures}
+% As subprocedures are simply normal pseudocode blocks, you can use easily add line numbers. 
+% By default the line numbering starts with 1 in a subprocedure while
+% ensuring that the outer numbering remains intact. Also note that the linenumbering on the outer procedure in the above example is inherited
+% by the subprocedure. For more control, either use manual numbering or set the 
+% option \enquote{linenumbering=off} on the |\pseudocode| command within the subprocedure.
+%
+%
+%
+% \subsection{Stacking Procedures}\label{chap:stacking}
+% You can stack procedures horizontally or vertically using the environments \enquote{pchstack} and \enquote{pcvstack}. 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{pchstack}[options] body \end{pchstack}
+ \begin{pcvstack}[options] body \end{pcvstack}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% The following example displays two procedures next to one another. To space two horizontally outlined procedures
+% use the |space| option or manually insert spaces via |\pchspace| which takes an optional length as a parameter.
+%
+% \begin{pchstack}[boxed,center,space=1em]
+% \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{
+%     b \sample \bin  \\
+%     (\pk,\sk) \sample \kgen(\secparam)  \\
+%     (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+%     c \sample \enc(\pk,m_b)  \\
+%     b' \sample \adv(\secparam, \pk, c)  \\
+%     \pcreturn b = b' }
+%
+%  \procedure[linenumbering,mode=text]{Oracle $O$}{
+%     Some code  \\
+%     Some more code
+% }
+% \end{pchstack}
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\begin{pchstack}[boxed,center,space=1em]
+	\procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+		b \sample \bin  \\
+		(\pk,\sk) \sample \kgen(\secparam)  \\
+		(m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+		c \sample \enc(\pk,m_b)  \\
+		b' \sample \adv(\secparam, \pk, c)  \\
+		\pcreturn b = b' }
+
+	% alternatively use \pchspace for spacing
+
+	\procedure[linenumbering,mode=text]{Oracle $O$}{%
+   		Some code  \\
+   		Some more code
+ 	}
+ \end{pchstack}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% Similarly you can stack two procedures vertically using the \enquote{pcvstack} environment. As a spacing 
+% between two vertically stacked procedures again use either the |space| option or
+% insert space manually via |\pcvspace| which takes an optional length as a parameter.
+%
+% \begin{pcvstack}[boxed,center,space=0.5em]
+% \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+%	  b \sample \bin  \\
+%     (\pk,\sk) \sample \kgen(\secparam)  \\
+%     (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+%     c \sample \enc(\pk,m_b)  \\
+%     b' \sample \adv(\secparam, \pk, c)  \\
+%     \pcreturn b = b' }
+%
+%  \procedure[linenumbering,mode=text]{Oracle $O$}{
+%     Some code  \\
+%     Some more code
+% }
+% \end{pcvstack}
+%
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{pcvstack}[boxed,center,space=0.5em]]
+	\procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+		b \sample \bin  \\
+		(\pk,\sk) \sample \kgen(\secparam)  \\
+		(m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+		c \sample \enc(\pk,m_b)  \\
+		b' \sample \adv(\secparam, \pk, c)  \\
+		\pcreturn b = b' }
+
+	% alternatively use \pcvspace for spacing
+
+	\procedure[linenumbering,mode=text]{Oracle $O$}{%
+   		Some code  \\
+   		Some more code
+ 	}
+\end{pcvstack}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% Horizontal and vertical stacking can be combined
+% \begin{pcvstack}[boxed,center,space=1em]
+%
+% \begin{pchstack}[space=2em,center]
+% \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+%	  b \sample \bin  \\
+%     (\pk,\sk) \sample \kgen(\secparam)  \\
+%     (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+%     c \sample \enc(\pk,m_b)  \\
+%     b' \sample \adv(\secparam, \pk, c)  \\
+%     \pcreturn b = b' }
+%
+% \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+%	  b \sample \bin  \\
+%     (\pk,\sk) \sample \kgen(\secparam)  \\
+%     (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+%     c \sample \enc(\pk,m_b)  \\
+%     b' \sample \adv(\secparam, \pk, c)  \\
+%     \pcreturn b = b' }
+% \end{pchstack}
+%
+% \begin{pchstack}[space=0.25em]
+%  \procedure[linenumbering,mode=text]{Oracle $O$}{
+%     Some code  \\
+%     Some more code
+% }
+%
+%  \procedure[linenumbering,mode=text]{Oracle $H_1$}{
+%     Some code  \\
+%     Some more code
+% }
+%
+%  \procedure[linenumbering,mode=text]{Oracle $H_2$}{
+%     Some code  \\
+%     Some more code
+% }
+% \end{pchstack}
+% \end{pcvstack}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{pcvstack}[boxed,center,space=1em]
+	\begin{pchstack}[center,space=2em]
+	
+		\procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{
+			b \sample \bin  \\
+			(\pk,\sk) \sample \kgen(\secparam)  \\
+			(m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+			c \sample \enc(\pk,m_b)  \\
+			b' \sample \adv(\secparam, \pk, c)  \\
+			\pcreturn b = b' }
+
+		% alternatively use \pchspace for spacing
+	
+		\procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+			b \sample \bin  \\
+			(\pk,\sk) \sample \kgen(\secparam)  \\
+			(m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+			c \sample \enc(\pk,m_b)  \\
+			b' \sample \adv(\secparam, \pk, c)  \\
+			\pcreturn b = b' }
+	
+	\end{pchstack}
+	
+	% alternatively use \pcvspace for spacing
+	
+	\begin{pchstack}[space=0.25em]
+		\procedure[linenumbering,mode=text]{Oracle $O$}{
+			Some code  \\
+			Some more code
+		}
+
+		\procedure[linenumbering,mode=text]{Oracle $H_1$}{
+			Some code  \\
+			Some more code
+		}
+
+		\procedure[linenumbering,mode=text]{Oracle $H_2$}{
+			Some code  \\
+			Some more code
+		}
+	\end{pchstack}
+\end{pcvstack}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Stacking Options}
+% \index{center}
+% \index{boxed}
+% \index{space}
+% \index{noindent}
+% \index{aboveskip}
+% \index{belowskip}
+%
+% The following keys are available on both |pchstack| and |pcvstack| environments
+% \begin{description}
+% \item[center]
+% Centers the stack.
+% 
+% \item[boxed]
+% Draws a box around the stack.
+% 
+% \item[space]
+% Controls the space between two pseudocode blocks within a stack. The default is 0pt
+% which can be adapted globally by redefining |\pchstackspace| or |\pcvstackspace|.
+%
+% \item[noindent]
+% Does not indent the stack. Only applies if option |center| is not used.
+%
+% \item[inline]
+% Ensures that no paragraph is added by |pchstack|. This cannot be used together with either |center| or |noindent|.
+%
+% \item[aboveskip]
+% By default the outer most stack adds vertical space above. The default space added
+% is |\abovedisplayskip| and can be adapted by redefining |\pcaboveskip|.
+%
+% \item[belowskip]
+% By default the outer most stack adds vertical space below. The default space added
+% is |\belowdisplayskip| and can be adapted by redefining |\pcbelowskip|. Note that
+% the defualt space below will not be added when used in a floating environment such as a figure.
+% However, when manually setting belowskip it will always be added.
+% \end{description}
+%
+% \subsection{Default Arguments}
+% \index{\textbackslash pcsetargs}
+% \index{\textbackslash pcsethstackargs}
+% \index{\textbackslash pcsetvstackargs}
+%
+% You can set the default arguments to be used with pseudocode blocks via |\pcsetargs|.
+% This is especially handy in stacking environments to add arguments to all enclosed
+% code blocks.
+% \begin{pchstack}[space=1em,center,boxed]
+% \renewcommand\pclnstyle[1]{#1}
+% \pcsetargs{linenumbering,mode=text,minlineheight=1cm,codesize=\Large{}}
+% \procedure{Some Procedue A}{%
+%	  Step 1\\
+%	  Step 2 }
+%
+%\procedure{Some Procedue B}{%
+%\text{Step 1}\\
+%\scriptsize$\begin{pcmbox}\begin{pmatrix}     A \\ B + C \end{pmatrix}\end{pcmbox}$\\
+%\text{Step 3}}
+%
+%
+%\procedure{Some Procedue C}{
+%	Step 1\\
+%	 Step 2 }
+%
+% \end{pchstack}
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\begin{pchstack}[space=1em,center,boxed]
+	% Do not change size to scriptsize for line numbers
+	\renewcommand\pclnstyle[1]{#1}
+
+	% set default arguments for all pseudocode blocks in this hstack
+	\pcsetargs{linenumbering,mode=text,minlineheight=1cm,codesize=\Large{}}
+
+	\procedure{Some Procedue A}{
+		Step 1\\
+		Step 2 }
+
+	\procedure{Some Procedue B}{
+		\text{Step 1}\\
+		\scriptsize$\begin{pcmbox}\begin{pmatrix}A \\ B + C \end{pmatrix}\end{pcmbox}$\\
+		\text{Step 3}}
+
+	\procedure{Some Procedue C}{
+		Step 1\\
+		 Step 2 }
+\end{pchstack}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection*{Default Arguments for Stacking}
+% Similarly to |\pcsetargs| you can define default arguments for |hstack| and |vstack|
+% environments via |\pcsethstackargs| and |\pcsetvstackargs|.
+%
+% \subsection{Divisions and Linebreaks}
+% \index{linebreaks}
+% \index{\textbackslash hline}
+% Within the pseudocode command you generate linebreaks as |\\|. In order to specify the linewidth you can add an optional argument
+% \iffalse
+%<*example>
+% \fi
+% \begin{lstlisting}
+ \\[height]
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Furthermore, you can add horizontal lines by using the second optional argument and write
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \\[][\hline]
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{
+%     b \sample \bin  \\[2\baselineskip][\hline\hline]
+%     (\pk,\sk) \sample \kgen(\secparam)  \\
+%     (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+%     c \sample \enc(\pk,m_b)  \\
+%     b' \sample \adv(\secparam, \pk, c)  \\
+%     \pcreturn b = b' }
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+     b \sample \bin  \\[2\baselineskip][\hline\hline]
+     (\pk,\sk) \sample \kgen(\secparam)  \\
+     (m_0,m_1) \sample \adv^O(\secparam, \pk)  \\
+     c \sample \enc(\pk,m_b)  \\
+     b' \sample \adv(\secparam, \pk, c)  \\
+     \pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Optimizing Layout}
+%
+% In case you are laying out multiple procedures horizontally, procedures may be slightly
+% misaligned if the procedure headings are not of the same height. As an example, Consider
+% the following setup
+%
+%\begin{pchstack}[center,space=1ex]
+%\procedure[linenumbering]{Procedure $A$}{
+%\text{do}\\
+%\text{some} \\
+%\text{work}
+%}
+%
+%\procedure[linenumbering]{Procedure $B^{F^{h^*}}_{G_1}$}{
+%\text{do}\\
+%\text{some} \\
+%\text{work}
+%}
+%\end{pchstack}
+%
+% Here the sub and double superscripts in Procedure $B$ make the header slightly larger than 
+% the maximum alotted space provided for headers which causes procedure $B$ to be slightly
+% shifted to the bottom. The best way to remedy such a situation is to use a combination
+% of the |headheight| and |headlinesep| properties to increase the header space in both procedures
+% and shift back the headline for a more compact visualization. As we here want to set some
+% arguments for all procedure blocks within the stacking environment we can use |\pcsetargs|.
+%
+%\begin{pchstack}[center,space=1ex]
+%\pcsetargs{headheight=5ex,headlinesep=-1ex}
+%
+%\procedure[linenumbering]{Procedure $A$}{
+%\text{do}\\
+%\text{some} \\
+%\text{work}
+%}
+%
+%\procedure[linenumbering]{Procedure $B^{F^{h^*}}_{G_1}$}{
+%\text{do}\\
+%\text{some} \\
+%\text{work}
+%}
+%\end{pchstack}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{pchstack}[center,space=1ex]
+	\pcsetargs{headheight=5ex,headlinesep=-1ex}
+
+	\procedure[linenumbering]{Procedure $A$}{
+		\text{do}\\
+		\text{some} \\
+		\text{work}
+	}
+
+	\procedure[linenumbering]{Procedure $B^{F^{h^*}}_{G_1}$}{
+		\text{do}\\
+		\text{some} \\
+		\text{work}
+	}
+\end{pchstack}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Matrices and Math Environments within Pseudocode}
+%
+% In order to work its magic, cryptocode (in particular within the \lstinline{\pseudocode} command) mingles with a few low level commands such as
+% \lstinline{\\} or \lstinline{\halign}. The effect of this is, that when you use certain math environments, for example, to create matrices, within pseudocode
+% the result may be unexpected. Consider the following example
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock{
+ \text{compute } P = \begin{pmatrix}
+     A \\ B + C
+ \end{pmatrix}
+ }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% which, somewhat unexpectedly, yields
+% \pcb{
+% \text{compute } P = \begin{pmatrix}
+%     A \\ B + C
+% \end{pmatrix}
+% }
+%
+% Here, the alignment is somewhat off. In order, to allow for the \emph{pmatrix} environment 
+% to properly work without interference from |\pseudocode|
+% you can wrap it into a |pcmbox| environment (where pcmbox is short for pseudocode math box). 
+% This ensures that the low-level changes introduced by |\pseudocode| are not active.
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock{
+ \text{compute } P = \begin{pcmbox}\begin{pmatrix}
+     A \\ B + C
+ \end{pmatrix}\end{pcmbox}
+ }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \begin{center}
+% \fbox{
+% \pseudocode{
+% \text{compute } P = \begin{pcmbox}\begin{pmatrix}
+%     A \\ B + C
+% \end{pmatrix}\end{pcmbox}
+% }
+% }
+% \end{center}
+%
+% \subsection{Fancy Code with Overlays}
+%
+% Consider the \indcpa\ game. Here we have a single adversary $\adv$ that is called twice, first to output two messages and
+% which is then given the ciphertext of one of the messages in order to \enquote{guess} which one was encrypted. 
+% Often this is not visualized.
+% Sometimes an additional state $\state$ is passed as we have in the following example on the left. On the right,
+% we visualize the same idea in a slightly more fancy way.
+%
+% \begin{pchstack}[center,space=1cm]
+%
+% \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+%     b \sample \bin  \\
+%     (\pk,\sk) \sample \kgen (\secparam)  \\
+%     (\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start}  \\
+%     c \sample \enc(\pk,m_b)  \\
+%     b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end} \\
+%     \pcreturn b = b' }
+%
+% \begin{pcimage}
+% \procedure[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+% 	  b \sample \bin  \\
+% 	  (\pk,\sk) \sample \kgen (\secparam)  \\
+% 	 (m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start}  \\
+% 	  c \sample \enc(\pk,m_b)  \\
+% 	  b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end} \\
+% 	  \pcreturn b = b' }
+%
+% \pcdraw{
+% 	\path[->] (start) edge[bend left=50] node[right]{$\state$} (start|-end);
+% }
+% \end{pcimage}
+% \end{pchstack}
+%
+% The image on the right is generated by:
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{pcimage}
+	\procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+		b \sample \bin  \\
+		(\pk,\sk) \sample \kgen (\secparam)  \\
+		(m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start}  \\
+		c \sample \enc(\pk,m_b)  \\
+		b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end} \\
+		\pcreturn b = b' }
+
+	\pcdraw{
+		\path[->] (start) edge[bend left=50] node[right]{$\state$} (start|-end);
+	}
+ \end{pcimage}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% In order to achieve the above effect cryptocode utilizes TIKZ underneath. The
+% |\pcnode| command generates TIKZ nodes and additionally we wrapped the 
+% pseudocode (or procedure) command in an |\begin{pcimage}\end{pcimage}| environment
+% which allows us to utilize these nodes later, for example using the  |\pcdraw|
+% command. We can achieve a similar effect without an additional pcimage environment by
+% using the optional argument of |\pcnode| for the TIKZ code.
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+	b \sample \bin  \\
+	(\pk,\sk) \sample \kgen (\secparam)  \\
+	(m_0,m_1) \sample \adv(\secparam, \pk, c) \pcnode{start}  \\
+	c \sample \enc(\pk,m_b)  \\
+	b' \sample \adv(\secparam, \pk, c, \state) \pcnode{end}[draw={
+ 		\path[->] (start) edge[bend left=50] node[right]{$\state$} (start|-end);
+ 	}] \\
+ 	\pcreturn b = b' }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection*{Example: Explain your Code}
+% As an exmaple of what you can do with this, let us put an explanation to a line of the code.
+%
+% \begin{pcimage}
+% \procb[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+% 	b \sample \bin  \\
+% 	 (\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen}  \\
+% 	 (m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+% 	  c \sample \enc(\pk,m_b)  \\
+% 	  b' \sample \adv(\secparam, \pk, c, \state) \\
+% 	  \pcreturn b = b' }
+%
+% \pcdraw{
+%   \node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
+%       at ([shift={(+3,+1)}]kgen) {
+% 		\begin{varwidth}{3cm}
+% 			$\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
+% 		\end{varwidth}
+%   };
+% }
+% \end{pcimage}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{pcimage}
+\procedureblock[linenumbering]{$\indcpa_\enc^\adv(\secparam)$}{%
+ 	b \sample \bin  \\
+ 	(\pk,\sk) \sample \kgen (\secparam)\pcnode{kgen}  \\
+ 	(m_0,m_1) \sample \adv(\secparam, \pk, c)  \\
+ 	 c \sample \enc(\pk,m_b)  \\
+ 	 b' \sample \adv(\secparam, \pk, c, \state) \\
+ 	 \pcreturn b = b' }
+
+\pcdraw{
+	\node[rectangle callout,callout absolute pointer=(kgen),fill=orange]
+		at ([shift={(+3,+1)}]kgen) {
+		\begin{varwidth}{3cm}
+			$\kgen(\secparam)$ samples a public key $\pk$ and a private key $\sk$.
+		\end{varwidth}
+	};
+}
+\end{pcimage}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \amipagebreak
+% \section{Tabbing Mode}
+% \label{chap:tabbing}
+% \index{\&}
+% \index{Tabbing Mode}
+% \index{\textbackslash\textlangle{}}
+% \index{\textbackslash\textrangle{}}
+% In the following section we discuss how to create multiple columns within a |\pseudocode| command.
+% Within a |\pseudocode| command you can switch to a new column by inserting a |\>|. 
+% This is similar to using an |align| environment and placing a tabbing character (\&). Also,
+% similarly to using |align| you should ensure that the number of |\>| are identical
+% on each line.
+% \pcb{%
+%  \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
+%   b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\pseudocodeblock{
+  \textbf{First} \> \textbf{Second} \> \textbf{Third} \> \textbf{Fourth} \\
+   b \sample \bin \> b \sample \bin \> b \sample \bin \> b \sample \bin}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% As you can see the first column is left aligned the second right, the third left and so forth.
+% In order to get only left aligned columns you could thus simply always skip a column by
+% using |\>\>|. You can also use |\<| a shorthand for |\>\>|.
+% \pcb{%
+%  \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
+%   b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\pseudocodeblock{
+  \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
+   b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \paragraph{Column Spacing}
+% \index{colsep}
+% \index{addtolength}
+% You can control the space between columns using the option \enquote{colsep=2em}. Note that when doing so you should
+% additionally use \enquote{addtolength=5em} (where 5em depends on the number of columns) in order to avoid having
+% overfull hboxes.
+% \pcb[colsep=1em,addtolength=10em]{%
+%  \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
+%   b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock[colsep=1em,addtolength=10em]{%
+  \textbf{First} \< \textbf{Second} \< \textbf{Third} \< \textbf{Fourth} \\
+   b \sample \bin \< b \sample \bin \< b \sample \bin \< b \sample \bin}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% This is basically all you need to know in order to go on to writing protocols with the
+% cryptocode package. So unless you want to know a bit more about tabbing (switching columns)
+% and learn some of the internals, feel free to proceed to Section~\ref{chap:protocols}.
+%
+% \subsection{Tabbing in Detail}
+% \index{mintabmode}
+% At the heart of the pseudocode package is an align (or rather a flalign*) environment which allows you to use basic math notation. 
+% Usually an align (or flalign) environment uses \& as tabbing characters. 
+% The pseudocode comes in two modes the first of which changes the default align behavior. 
+% That is, it automatically adds a tabbing character to the beginning and end of each line 
+% and changes the tabbing character to |\>|. This mode is called \emph{mintabmode} and is active by default.
+%
+% In mintabmode in order to make use of extra columns in the align environment 
+% (which we will use shortly in order to write protocols) you can use |\>| as you would use \& normally. 
+% But, don't forget that there is an alignment tab already placed at the beginning and end of each line. So the following example
+% \pcb{%
+%  \textbf{Alice} \> \> \textbf{Bob}  \\
+%  b \sample \bin \> \> \\
+%  \> \xrightarrow{\text{send over } b} \>  \\
+%  \> \> \text{do something}}
+% is generated by
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocodeblock{
+  \textbf{Alice} \> \> \textbf{Bob}  \\
+  b \sample \bin \> \> \\
+  \> \xrightarrow{\text{send over } b} \>  \\
+  \> \> \text{do something}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Overriding The Tabbing Character}
+% \index{\textbackslash pctabname}
+% If you don't like |\>| as the tabbing character you can choose a custom command by overwriting |\pctabname|.
+% For example
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\renewcommand{\pctabname}{\myTab}
+
+\pseudocode{
+	\textbf{Alice} \myTab \myTab \textbf{Bob}  \\
+	b \sample \bin \myTab \myTab \\
+	\myTab \xrightarrow{\text{send over } b} \myTab  \\
+	\myTab \myTab \text{do something}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Custom Line Spacing and Horizontal Rules}
+% \index{\textbackslash pclb}
+% As explained, underlying the pseudocode command is an flalign environment. This would allow the use
+% of |\\[spacing]| to specifiy the spacing between two lines or of |[\\\hline]| 
+% to insert a horizontal rule. In order to achieve the same effect within the pseudocode command you
+% can use |\\[spacing][\hline]|. You can also use |\pclb| to get a line break which
+% does not insert the additional alignment characters. 
+%
+% \amipagebreak
+% \section{Protocols}
+% \label{chap:protocols}
+%
+% Using tabbing, we can use |\pseudocode| to also layout protocols such as
+% \procb{My Protocol}{
+%  \textbf{Alice} \> \> \textbf{Bob}  \\
+%  b \sample \bin \> \> \\
+%  \> \xrightarrow{\text{send over } b} \>  \\
+%  \> \> \text{do something}    \\
+%  \> \xleftarrow{\text{send over sth. else}} \>   \\
+%  \text{finalize} \> \>}
+% which is generated as
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\procedureblock{My Protocol}{
+	\textbf{Alice} \> \> \textbf{Bob}  \\
+	b \sample \bin \> \> \\
+	\> \xrightarrow{\text{send over } b} \>  \\
+	\> \> \text{do something}    \\
+	\> \xleftarrow{\text{send over sth. else}} \>   \\
+	\text{finalize} \> \>}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% \index{\textbackslash sendmessage}%
+% \index{\textbackslash sendmessage*}%
+% \index{\textbackslash sendmessageright*}
+% \index{\textbackslash sendmessageright}
+% \index{\textbackslash sendmessageleft*}
+% \index{\textbackslash sendmessageleft}
+% In order to get nicer message arrows use the commands |\sendmessageright*{message}|, |\sendmessageleft*{message}|, and
+% |\sendmessagerightleft*{message}|.
+% All three take an additional optional argument specifying the length of the arrow and all 
+% wrap their mandatory argument in an |aligned| environment.
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \sendmessageright*[3.5cm]{message}
+ \sendmessageleft*[3.5cm]{message}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \procb{My Protocol}{
+%  \textbf{Alice} \> \> \textbf{Bob}  \\
+%  b \sample \bin \> \> \\
+%  \> \sendmessageright*{\text{send over } b} \>  \\
+%  \> \> \text{do something}    \\
+%  \> \sendmessageleft*{\text{send over sth. else}} \>   \\
+%  \text{finalize} \> \> }
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock{My Protocol}{%
+	\textbf{Alice} \> \> \textbf{Bob}  \\
+	b \sample \bin \> \> \\
+	\> \sendmessageright*{\text{send over } b} \>  \\
+	\> \> \text{do something}    \\
+	\> \sendmessageleft*{\text{send over sth. else}} \>   \\
+	\text{finalize} \> \> }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% To obtain granular control over how messages are set use the |\sendmessage| and 
+% |\sendmessage*| commands. These take two parameters, the first being the message style
+% for the underlying TIKZ path (e.g., |->| for messages to the right) and the second
+% a key value list of arguments. The difference between the starred version and the
+% unstarred version is that the starred version wraps its labels in an |aligned|
+% environment. Following is an example, that showcases various message options.
+% \procedureblock{My Protocol}{
+%  \textbf{Alice} \> \> \textbf{Bob}  \\
+%  b \sample \bin \> \> \\
+%  \> \sendmessage{->}{centercol=3,top=send over $b$,bottom=Text below,topstyle={draw,solid,yshift=0.25cm},style={dashed}} \>  \\
+%  \> \> \text{do something}    \\
+%  \> \sendmessage{<-}{length=8cm,top=send over sth. else} \>   \\
+%  \> \sendmessage*{<->}{length=8cm,top={{a,b, c\\c,d, e}},bottom={foo}} \>   \\
+%  \> \sendmessage{<->}{length=8cm,top=\pseudocode[linenumbering]{\text{you can also}\\\text{use pseudocode}},bottom={foo}} \>   \\  
+%  \text{finalize} \> \> }
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\procedureblock{My Protocol}{
+	\textbf{Alice} \> \> \textbf{Bob}  \\
+	b \sample \bin \> \> \\
+	\> \sendmessage{->}{centercol=3,top=send over $b$,bottom=Text below,topstyle={draw,solid,yshift=0.25cm},style={dashed}} \>  \\
+	\> \> \text{do something}    \\
+	\> \sendmessage{<-}{length=8cm,top=send over sth. else} \>   \\
+	\> \sendmessage*{<->}{length=8cm,top={{a,b, c\\c,d, e}},bottom={foo}} \>   \\
+	\> \sendmessage{<->}{length=8cm,top=\pseudocode[linenumbering]{\text{you can also}\\\text{use pseudocode}},bottom={foo}} \>   \\  
+	\text{finalize} \> \> }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% |sendmessage| and |sendmessage*| support the following options:
+% \begin{description}
+% \item[top]
+% The content to display on top of the arrow. 
+% \item[bottom]
+% The content to display below the arrow.
+% \item[left]
+% The content to display on the left of the arrow.
+% \item[right]
+% The content to display on the right of the arrow.
+% \item[topstyle]
+% The TIKZ style to be used for the top node.
+% \item[bottomstyle]
+% The TIKZ style to be used for the bottom node.
+% \item[rightstyle]
+% The TIKZ style to be used for the right node.
+% \item[leftstyle]
+% The TIKZ style to be used for the left node.
+% \item[length]
+% The length of the arrow.
+% \item[style]
+% The style of the arrow.
+% \item[width]
+% The width of the column
+% \item[centercol]
+% Can be used to ensure that the message is displayed in the center. This should be set to the
+% column index. In the above example, the message column is the third column (note that there is
+% a column left of alice that  is automatically inserted).
+% \end{description}
+%
+% \subsection{Tabbing}
+% When typesetting protocols you might find that using two tabs instead of a single tab usually provides
+% a better result as this ensures that all columns are left aligned. 
+% For this you can use |\<| instead of |\>| (see Section~\ref{chap:tabbing}).
+%
+% \medskip
+% Following is once more the example from before but now with double tapping. 
+% \procb{My Protocol}{
+%  \textbf{Alice} \< \< \textbf{Bob}  \\
+%  b \sample \bin \< \< \\
+%  \< \sendmessageright*{\text{send over } b} \<  \\
+%  \< \< \text{do something}    \\
+%  \< \sendmessageleft*{\text{send over sth. else}} \<   \\
+%  \text{finalize} \< \< }
+%
+% \subsection{Multiline Messages}
+% Using the starred send message commands you can easily generate multiline messages as the command
+% wraps an \emph{aligned} environment around the message.
+% \procb{My Protocol}{%
+%  \textbf{Alice} \< \< \textbf{Bob}  \\
+%  b \sample \bin \< \< \\
+%  \< \sendmessageright*{\text{send over } b\\ \text{second line}} \<  \\
+%  \< \< \text{do something}    \\
+% \< \sendmessage*{<-}{top={\>\text{left aligned}\\ \> \text{multiline message}}} \<   \\
+%  \text{finalize} \< \<}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock{My Protocol}{%
+	\textbf{Alice} \< \< \textbf{Bob}  \\
+	b \sample \bin \< \< \\
+	\< \sendmessageright*{\text{send over } b\\ \text{second line}} \<  \\
+	\< \< \text{do something}    \\
+	\< \sendmessage*{<-}{top={\>\text{left aligned}\\ \> \text{multiline message}}} \<   \\
+	\text{finalize} \< \<}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \textbf{Remark. } When using |\sendmessage*| the tabbing character |&| cannot be used.
+% Instead use the |\>| command as defined within |\pseudocode|.
+%
+% \subsubsection{Multiplayer Protocols}
+%
+% You are not limited to two players. In order to send messages skipping players 
+% use |\sendmessagerightx| and |\sendmessageleftx|.
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \sendmessagerightx[width]{columnspan}{Text}
+ \sendmessageleftx[width]{columnspan}{Text}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \procb{Multiparty Protocol}{
+%  \textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\
+%  \text{work} \< \< \< \< \\
+%  \< \sendmessageright{top=Work result} \< \< \< \\
+%  \< \< \text{work} \< \< \\
+%  \< \< \<  \sendmessageright{top=Work result,bottom=Bottom message} \< \\
+%  \< \<  \< \< \text{work} \\
+%  \< \sendmessageleftx[7cm]{8}{\text{A long message for Alice}} \< \\
+%  \text{finalize} \< \< \< \< }
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \procedureblock{Multiparty Protocol}{%
+	\textbf{Alice} \< \< \textbf{Bob} \< \< \textbf{Charlie} \\
+	\text{work} \< \< \< \< \\
+	\< \sendmessageright{top=Work result} \< \< \< \\
+	\< \< \text{work} \< \< \\
+	\< \< \<  \sendmessageright{top=Work result,bottom=Bottom message} \< \\
+	\< \<  \< \< \text{work} \\
+	\< \sendmessageleftx[7cm]{8}{\text{A long message for Alice}} \< \\
+	\text{finalize} \< \< \< \< }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Note that for the last message from Charlie to Alice we needed to specify the number of passed
+% over colums (|\sendmessageleftx[7cm]{8}{message}|). As we were passing
+% 4 |\<| where each creates 2 columns, the total was 8 columns.
+%
+% \subsubsection{Divisions}
+% You can use |\pcintertext| in order to divide protocols (or other pseudocode for that matter).
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pcintertext[dotted|center]{Division Text}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Note that in order to use the |\pcintertext| you need to use |\pclb| as the line break for the line
+% before. Also see Section~\ref{chap:tabbing}.
+%
+% \procb{My Protocol}{
+% \textbf{Alice} \< \< \textbf{Bob}  \\
+%  b \sample \bin \< \<  \pclb
+%  \pcintertext[dotted]{Some Division} \\
+%  \< \sendmessageright*{\text{send over } b} \<  \\
+%  \< \< \text{do something} \pclb
+%  \pcintertext[dotted]{Another Division} \\
+%  \< \sendmessageleft*{\text{message}} \<   \\
+%  \text{finalize} \< \< }
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\procedureblock{My Protocol}{%
+	\textbf{Alice} \< \< \textbf{Bob}  \\
+	b \sample \bin \< \<  \pclb
+	\pcintertext[dotted]{Some Division} \\
+	\< \sendmessageright*{\text{send over } b} \<  \\
+	\< \< \text{do something} \pclb
+	\pcintertext[dotted]{Another Division} \\
+	\< \sendmessageleft*{\text{message}} \<   \\
+	\text{finalize} \< \< }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Line Numbering in Protocols}
+% Protocols can be numbered similarly to plain pseudocode. Additionally to the 
+% |\pcln| there are the commands |\pclnr| and |\pcrln|. The first
+% allows you to right align line numbers but uses the same counter as 
+% |\pcln|. The second uses a different counter.
+%
+% \procb{My Protocol}{%
+% \pcln  \textbf{Alice} \< \< \textbf{Bob} \< \\
+% \pcln b \sample \bin \< \< \< \\
+%  \< \sendmessageright*{\text{send over } b} \< \< \pclnr\\
+%  \< \< \text{do something} \<  \pclnr \\
+%  \< \sendmessageleft*{\text{send over sth. else}} \<\<  \pclnr \\
+% \pcln \text{finalize} \< \< \<}
+% Which is generated as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\procedureblock{My Protocol}{
+	\pcln  \textbf{Alice} \< \< \textbf{Bob} \< \\
+	\pcln b \sample \bin \< \< \< \\
+	\< \sendmessageright*{\text{send over } b} \< \< \pclnr\\
+	\< \< \text{do something} \<  \pclnr \\
+	\< \sendmessageleft*{\text{send over sth. else}} \<\<  \pclnr \\
+	\pcln \text{finalize} \< \< \<}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% And using |\pcrln| we obtain:
+% \procb{My Protocol}{%
+% \pcln  \textbf{Alice} \< \< \textbf{Bob} \<  \\
+% \pcln b \sample \bin \< \< \< \\
+%  \< \sendmessageright*{\text{send over } b} \<\<  \pcrln\\
+%  \< \< \text{do something}   \< \pcrln \\
+%  \< \sendmessageleft*{\text{send over sth. else}} \<  \< \pcrln \\
+% \pcln \text{finalize} \< \< \< }
+% This is generated as
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\procedureblock{My Protocol}{%
+	\pcln  \textbf{Alice} \< \< \textbf{Bob}  \\
+	\pcln b \sample \bin \< \< \\
+	\< \sendmessageright*{\text{send over } b} \<  \pcrln\\
+	\< \< \text{do something}   \pcrln \\
+	\< \sendmessageleft*{\text{send over sth. else}} \<  \pcrln \\
+	\pcln \text{finalize} \< \< }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Separators}
+% \label{sec:protocol:separator}
+% The commands |\pclnseparator| and |\pcrlnseparator| define the separators between code and line number. 
+% By default the left separator is set to (:) colon and the right separator is set to an empty string.
+%
+% \subsubsection{Spacing}
+% Spacings after the left separator and in front of the right separator can be controlled by 
+% |\pclnspace| and |\pclnrspace| which are set to 1em and 0.5em, respectively.
+%
+% \subsection{Sub Protocols}
+%
+% Use the |subprocedure| environemnt to also create sub protocols. 
+%
+% \procb{My Protocol}{
+%  \textbf{Alice} \< \< \textbf{Bob}  \\
+%  b \sample \bin \< \< \\
+%  \< \sendmessageright*{\text{send over } b} \<  \\
+%  \< \< \text{do something}    \\
+%  \<\< \dbox{\begin{subprocedure}\procedure{Subprotocol}{
+%  \< \< \textbf{Charlie}  \\
+% \text{something more} \< \<  \\
+%  \< \sendmessageright*[1.5cm]{\text{message}} \<  \\
+%  \< \< \text{some processing}  \\
+%  \< \< \text{more processing}  \\ 
+%  \< \sendmessageleft*[1.5cm]{\text{message}} \<  \\
+%  \< \sendmessageright*[1.5cm]{\text{message}} \<  \\
+%  \< \sendmessageleft*[1.5cm]{\text{message}} \<  \\
+% }\end{subprocedure}}  \\
+%  \< \sendmessageleft*{\text{send over sth. else}} \<   \\
+%  \text{finalize} \< \< }
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\procedureblock{My Protocol}{
+	\textbf{Alice} \< \< \textbf{Bob}  \\
+	b \sample \bin \< \< \\
+	\< \sendmessageright*{\text{send over } b} \<  \\
+	\< \< \text{do something}    \\
+	\<\< \dbox{\begin{subprocedure}\procedure{Subprotocol}{
+	\< \< \textbf{Charlie}  \\
+	\text{something more} \< \<  \\
+	\< \sendmessageright*[1.5cm]{\text{message}} \<  \\
+	\< \< \text{some processing}  \\
+	\< \< \text{more processing}  \\ 
+	\< \sendmessageleft*[1.5cm]{\text{message}} \<  \\
+	\< \sendmessageright*[1.5cm]{\text{message}} \<  \\
+	\< \sendmessageleft*[1.5cm]{\text{message}} \<  \\
+	}\end{subprocedure}}  \\
+	\< \sendmessageleft*{\text{send over sth. else}} \<   \\
+	\text{finalize} \< \< }
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \amipagebreak
+% \section{Game-Based Proofs}
+% \label{chap:gbproofs}
+%
+% \subsection{Basics}
+% \index{gameproof}
+% \index{\textbackslash \pcgame}
+% \index{gameprocedure}
+%
+% Besides displaying pseudocode the package also comes with commands to help presetn game-based proofs. 
+% The |gameproof| environment wraps the pseudocode block of a game-based proof.
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+\begin{gameproof}
+ 	proof goes here
+\end{gameproof}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Within a |gameproof| environment use the command |\gameprocedure| which works similarly to the pseudocode
+% command and produces a heading of the form $\pcgame[\text{counter}](\secpar)$ where counter is a consecutive counter.
+% Thus, we can create the following setup
+% \begin{gameproof}
+% \begin{pchstack}[space=1em,center,boxed]
+% \gameprocedure[linenumbering,mode=text]{%
+%  Step 1  \\
+%  Step 2  
+%  }
+% \gameprocedure[mode=text]{%
+%  Step 1  \\
+%  Step 2  
+%  }
+% \end{pchstack}
+% \end{gameproof}
+% by using
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{gameproof}
+\begin{pchstack}[space=1em,center,boxed]
+	\gameprocedure[linenumbering,mode=text]{%
+		Step 1  \\
+		Step 2  
+	}
+	\gameprocedure[mode=text]{%
+		Step 1  \\
+		Step 2  
+	}
+\end{pchstack}
+\end{gameproof}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% For discussing individual games, cryptocode provides the |\pcgame| command which
+% without argument prints \pcgame\ and with (optional) argument |\pcgame[n]| prints \pcgame[n].
+%
+% \subsubsection{Highlight Changes}
+% \index{highlight game change}
+% \index{\textbackslash gamechange}
+% In order to highlight changes from one game to the next use |\gamechange|.
+% \begin{gameproof}
+% \begin{pchstack}[space=1em,center,boxed]	
+% \gameprocedure[linenumbering,mode=text]{%
+%  Step 1  \\
+%  Step 2  
+%  }
+% \gameprocedure[mode=text]{%
+%  Step 1  \\
+%  \gamechange{Step 2}
+%  }
+% \end{pchstack}
+% \end{gameproof}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{gameproof}
+\begin{pchstack}[space=1em,center,boxed]
+	\gameprocedure[linenumbering,mode=text]{%
+		Step 1  \\
+		Step 2  
+	}
+	\gameprocedure[mode=text]{%
+		Step 1  \\
+		\gamechange{Step 2}
+	}
+\end{pchstack}	
+\end{gameproof}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% The background color can be controlled by redefining |\gamechangecolor| which by default
+% is defined as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+	\definecolor{gamechangecolor}{gray}{0.90}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \textbf{Remark. } Note that |\gamechange| is always in text mode.
+%
+% \subsubsection{Boxed Games}
+% \index{\textbackslash tbxgameprocedure}
+% \index{\textbackslash pcbox}
+% Use |\tbxgameprocedure| in order to create two consecutive games where the second game is \emph{boxed}. Use
+% |\pcbox| to create boxed statements.
+%\begin{gameproof}
+%\begin{pchstack}[space=1em,boxed,center]
+%	\gameprocedure[linenumbering]{
+%		\text{Step 1}  \\
+%		\text{Step 2}  
+%	}
+%	\tbxgameprocedure{
+%		\text{Step 1}; \pcbox{\text{Alternative step 1}}  \\
+%		\gamechange{\text{Step 2 is different}}  
+%	}
+%	\gameprocedure{
+%		\text{Step 1}  \\
+%		\text{\gamechange{Step 2}}  
+%	} 
+%\end{pchstack}
+%\end{gameproof}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{gameproof}
+\begin{pchstack}[space=1em,boxed,center]
+	\gameprocedure[linenumbering]{
+		\text{Step 1}  \\
+		\text{Step 2}  
+	}
+	\tbxgameprocedure{
+		\text{Step 1}; \pcbox{\text{Alternative step 1}}  \\
+		\gamechange{\text{Step 2 is different}}  
+	}
+	\gameprocedure{
+		\text{Step 1}  \\
+		\text{\gamechange{Step 2}}  
+	} 
+\end{pchstack}
+\end{gameproof}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Reduction Hints}
+% \index{\textbackslash addgamehop}
+% 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
+% the difference between two games is bound by the security of some pseudorandom generator $\mathsf{PRG}$. To give a hint
+% within the pseudocode that the difference between two games is down to ``something'' you can use the |\addgamehop|
+% command.
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \addgamehop{startgame}{endgame}{options}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Here options allows you to specify the hint as well as the style. The following options are available
+% \begin{description}
+% \item[hint]
+% The hint text
+% \item[nodestyle]
+% A TIKZ style to be used for the node.
+% \item[pathstyle]
+% A TIKZ style to be used for the path.
+% \item[edgestyle]
+% A TIKZ style to be used for the edge. This defaults to \enquote{bend left}.
+% \end{description}
+%
+%\begin{gameproof}
+%\begin{pchstack}[center,space=2em,aboveskip=1.5em]
+%	\gameprocedure[linenumbering]{
+%		\text{Step 1}  \\
+%		\text{Step 2}  
+%	}
+%	\tbxgameprocedure{
+%		\text{Step 1}  \\
+%		\gamechange{\text{Step 2 is different}}  
+%	}
+%\end{pchstack}
+%
+%\addgamehop{1}{2}{hint=\footnotesize some hint,nodestyle=red}
+%\addgamehop{2}{3}{hint=\footnotesize some other hint,nodestyle=red}
+%\end{gameproof}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{gameproof}
+\begin{pchstack}[center,space=2em]
+	\gameprocedure[linenumbering]{
+		\text{Step 1}  \\
+		\text{Step 2}  
+	}
+	\tbxgameprocedure{
+		\text{Step 1}  \\
+		\gamechange{\text{Step 2 is different}}  
+	}
+\end{pchstack}
+
+\addgamehop{1}{2}{hint=\footnotesize some hint,nodestyle=red}
+\addgamehop{2}{3}{hint=\footnotesize some other hint}
+\end{gameproof}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% 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
+% use 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \addgamehop{1}{2}{hint=\footnotesize some hint,edgestyle=}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% If game proofs do not fit into a single picture you can specify start and end hints using the commands
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \addstartgamehop[first game]{options}
+ \addendgamehop[last game]{options}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+%\begin{gameproof}
+%\begin{pchstack}[center,space=2em,aboveskip=1em]
+% 	\gameprocedure[linenumbering]{
+%		\text{Step 1}  \\
+%		\text{Step 2}  
+%  	}
+%	\gameprocedure{%
+%		\text{Step 1}  \\
+%		\gamechange{\text{Step 2 is different}}  
+%	}
+%\addstartgamehop{hint=\footnotesize some hint,edgestyle=}
+%\addgamehop{1}{2}{hint=\footnotesize some hint}
+%\addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
+%\end{pchstack}
+%\end{gameproof}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{gameproof}
+\begin{pchstack}[center,space=2em]
+ 	\gameprocedure[linenumbering]{
+		\text{Step 1}  \\
+		\text{Step 2}  
+  	}
+	\gameprocedure{
+		\text{Step 1}  \\
+		\gamechange{\text{Step 2 is different}}  
+	}
+\end{pchstack}
+
+\addstartgamehop{hint=\footnotesize some hint,edgestyle=}
+\addgamehop{1}{2}{hint=\footnotesize some hint}
+\addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
+\end{gameproof}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Numbering and Names}
+% By default the |gameproof| environment starts to count from 1 onwards. Its optional parameters allow you to specify a custom
+% name for the game as well as defining the starting number. 
+% \iffalse
+%<*example>
+% \fi
+% \begin{lstlisting}
+ \begin{gameproof}[options]
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% The following parameters are available which, as usual, are provided in a key=value based form.
+% \begin{description}
+% \item[nr]
+% The starting number minus 1. Thus, when setting nr=5, the first game will be \pcgame[6].
+% \item[name]
+% The name for the game
+% \item[arg]
+% The argument to be used for the game.
+% \end{description}
+%
+%\begin{gameproof}[nr=5,name=\mathsf{MyGame},arg=(1^n)]
+%\begin{pchstack}[center,space=2em,aboveskip=2.5em]
+%	\gameprocedure[linenumbering]{
+%		\text{Step 1}  \\
+%		\text{Step 2} }
+%	\gameprocedure{
+%		\text{Step 1}  \\
+%		\gamechange{\text{Step 2 is different}} }
+%\end{pchstack}
+%
+%\addstartgamehop{hint=\footnotesize some ingoing hint,edgestyle=}
+%\addgamehop{6}{7}{hint=\footnotesize some hint}
+%\addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
+%\end{gameproof}
+%
+% \iffalse
+%<*example>
+% \fi
+% \begin{lstlisting}
+\begin{gameproof}[nr=5,name=\mathsf{MyGame},arg=(1^n)]
+\begin{pchstack}[center,space=2em]
+	\gameprocedure[linenumbering]{
+		\text{Step 1}  \\
+		\text{Step 2} }
+	\gameprocedure{
+		\text{Step 1}  \\
+		\gamechange{\text{Step 2 is different}} }
+\end{pchstack}
+
+\addstartgamehop{hint=\footnotesize some ingoing hint,edgestyle=}
+\addgamehop{6}{7}{hint=\footnotesize some hint}
+\addendgamehop{hint=\footnotesize some outgoing hint,edgestyle=}
+\end{gameproof}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Default Name and Argument}
+% The default name and argument are controlled via the commands |\pcgamename| and |\gameprocedurearg|.
+%
+% \begin{center}
+% \begin{tabular}{ll}
+% \textbf{Command} & \textbf{Default} \\
+% |\pcgamename| & |\mathsf{Game}| \\
+% |\gameprocedurearg| & |\secpar|
+% \end{tabular}
+% \end{center}
+%
+% \subsubsection{Bi-Directional Games}
+% \index{\textbackslash bxgameprocedure}
+% \index{\textbackslash addloopgamehop}
+% You can use the |\bxgameprocedure| to generate games for going in two directions. Use the |\addloopgamehop|
+% to add the gamehop in the middle.
+%
+% \vspace{1cm}
+% \begin{center}
+% \begin{gameproof}
+% \bxgameprocedure{4}{%
+%  \pcln  \text{Step 1}; \pcbox{Alternative} \\
+%  \pcln  \text{Step 2}  
+%  }
+% \bxgameprocedure{3}{%
+%    \text{Step 1}; \pcbox{Alternative}  \\
+%    \gamechange{\text{Step 2 is different}}  
+%  }
+%  \addstartgamehop{hint=\footnotesize some hint,edgestyle=}
+% \addgamehop{1}{2}{hint=\footnotesize some hint,edgestyle=}
+%  \addloopgamehop{hint=\footnotesize some loop hint}
+%  \addgamehop{2}{1}{hint=\footnotesize some hint}
+% \end{gameproof}
+% \end{center}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{gameproof}
+ \bxgameprocedure{4}{%
+  \pcln  \text{Step 1}; \pcbox{Alternative} \\
+  \pcln  \text{Step 2}  
+  }
+ \bxgameprocedure{3}{%
+    \text{Step 1}; \pcbox{Alternative}  \\
+    \gamechange{\text{Step 2 is different}}  
+  }
+  \addstartgamehop{hint=\footnotesize some hint,edgestyle=}
+ \addgamehop{1}{2}{hint=\footnotesize some hint,edgestyle=}
+  \addloopgamehop{hint=\footnotesize some loop hint}
+  \addgamehop{2}{1}{hint=\footnotesize some hint}
+ \end{gameproof}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Styling Game Procedures}
+% It may come in handy to define default style arguments for the underlying pseudocode 
+% command used by |\gameprocedure|. For this you can
+% define the default arguments by calling \lstinline{\setgameproceduredefaultstyle} to 
+% for example:
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \setgameproceduredefaultstyle{beginline=\vphantom{\bin^\prg_\prg}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% The default is to not set any options.
+%
+% \subsection{Game Descriptions}
+% Cryptocode also comes with an environment to provide textual descriptions of games such as
+%
+%  \begin{gamedescription}[name=MyGame,nr=2]
+% \describegame
+%  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.
+%
+% \describegame[inhint=reduction target]
+%  This is the fourt game. The arrow at the side indicates the reduction target.
+%  \end{gamedescription}
+%
+%  The above example is generated as
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{gamedescription}[name=MyGame,nr=2]
+ \describegame
+ 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.
+
+ \describegame[inhint=reduction target]
+ This is the second game. The arrow at the side indicates the reduction target.
+ \end{gamedescription}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% The |gamedescription| environment takes an optional argument to specify name and counter (defaults to Game and 0). The command 
+% |\describegame| starts a new game description and can allows you to provide a reduction hint using the option parameter |inhint|.
+%
+% \begin{description}
+% \item[inhint]  Displays an ingoing arrow to denote the reduction target for this game hop.
+% \item[length] Allows to control the length of the arrow. \\
+% \item[nodestyle] Allows to control the style of the node. \\
+% \item[hint]  Instead of having an ingoing arrow, this adds an outgoing arrow. \\
+% \end{description}
+%
+% \amipagebreak
+% \section{Black-Box Reductions}
+% \label{chap:bbr}
+% \index{bbrenv}
+% \index{bbrbox}
+% \index{\textbackslash bbrinput}
+% \index{\textbackslash bbroutput}
+%
+% The cryptocode package comes with support for drawing basic black box reductions. A reduction 
+% always takes the following form.
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ \begin{bbrbox}[name=Box Name]
+ % The Box's content
+ \end{bbrbox}
+ % Commands to display communication, input output etc
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% That is, a |bbrenv| environment (where bbr is short for black-box reduction) which takes a single
+% |bbrbox| environment plus some additional commands. 
+% 
+% \medskip
+% Following is a simple example with a single (black)box and some code plus inputs outputs:
+%
+% \begin{bbrenv}[aboveskip=0.75cm,belowskip=0.75cm]{A}
+% 	\begin{bbrbox}[name=Box Name]
+% 	\pseudocode{
+% 		\text{step 1} \\
+% 		\text{step 2} \\
+% 		\pcfor \text{some condition} \pcdo \\
+% 		\t\text{step 3} 
+% 	}
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+% \end{bbrenv}
+%
+% \noindent This box is generated as
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}[aboveskip=1cm,belowskip=1cm]{A}
+ 	\begin{bbrbox}[name=Box Name]
+ 	\pseudocode{
+ 		\text{step 1} \\
+ 		\text{step 2} \\
+ 		\pcfor \text{some condition} \pcdo \\
+ 		\t\text{step 3} 
+ 	}
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% The commands |bbrinput| and |bbroutput| allow to specify input and output for the latest
+% |bbrenv| environment. The optional parameter for the |bbrenv| environment allows to specify leading and trailing space (this
+% may become necessary when using inputs and outputs). For this provide |aboveskip| and |belowskip| keys.
+% (Note that in an earlier version of cryptocode you could write |\begin{bbrenv}[1cm]{A}[1cm]|. While this format
+% is still supported it should be regarded deprecated.)
+% The single mandatory argument to the bbrenv environment needs to specify a unique identifier
+% (unique for the current reduction). This id is used as an internal TIKZ node name (\url{https://www.ctan.org/pkg/pgf}).
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{bbrenv}[options]{UNIQUE IDENTIFIER}
+% deprecated version	
+\begin{bbrenv}[vspace before]{UNIQUE IDENTIFIER}[vspace after]
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% As we are drawing a TIKZ image, note that we can easily later customize the image using the labels that we
+% have specified on the way. 
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=1cm]{A}
+% 	\begin{bbrbox}[name=Box Name]
+% 	\pseudocode{
+% 		\text{step 1} \\
+% 		\text{step 2} \\
+% 		\pcfor \text{some condition} \pcdo \\
+% 		\pcind\text{step 3} 
+% 	}
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+%
+% 	\filldraw[fill=blue] (A.north) circle (4pt);
+% 	\filldraw[fill=blue] (A.west) circle (4pt);
+% 	\filldraw[fill=blue] (A.east) circle (4pt);
+% 	\filldraw[fill=blue] (A.south) circle (4pt);
+% \end{bbrenv}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Box Name]
+ 	\pseudocode{
+ 		\text{step 1} \\
+ 		\text{step 2} \\
+ 		\pcfor \text{some condition} \pcdo \\
+ 		\pcind\text{step 3} 
+ 	}
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+
+ 	\filldraw[fill=blue] (A.north) circle (4pt);
+ 	\filldraw[fill=blue] (A.west) circle (4pt);
+ 	\filldraw[fill=blue] (A.east) circle (4pt);
+ 	\filldraw[fill=blue] (A.south) circle (4pt);
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% The |bbrbox| takes as single argument a comma separated list of key value pairs. In the example we used
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ name=Box Name
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% to specify the label. The following options are available
+%
+% \index{namepos}
+% \index{namestyle}
+% \index{abovesep}
+% \index{minheight}
+% \index{xshift}
+% \index{yshift}
+% \begin{center}
+% \begin{tabular}{ll}
+% \textbf{Option} & \textbf{Description} \\ \hline
+% name & Specifies the box's label \\
+% namepos & Specifies the position (left, center, right, top left, top center, top right, middle) \\
+% namestyle & Specifies the style of the name \\
+% abovesep & Space above box (defaults to |\baselineskip|) \\
+% minheight & The minimal height \\
+% addheight & Additional height at the end of the box \\
+% xshift & Allows horizontal positioning \\
+% yshift & Allows horizontal positioning \\
+% style & allows to customize the node
+% \end{tabular}
+% \end{center}
+%
+% \subsection{Nesting of Boxes}
+% Boxes can be nested. For this simply insert a |bbrenv| (together with a single bbrbox) environment into an
+% existing bbrbox.
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Box Name]
+% 	\pseudocode{
+% 		\text{step 1} \\
+% 		\text{step 2} \\
+% 		\pcfor \text{some condition} \pcdo \\
+% 		\pcind\text{step 3} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+% 		\begin{bbrbox}[name=Inner Box]
+% 		\pseudocode{
+% 			\text{inner step 1} \\
+% 			\text{inner step 2} 
+% 		}
+% 		\end{bbrbox}
+% 	\end{bbrenv}
+%
+% 	\pseudocode{
+% 		\text{step 4} \\
+% 		\text{step 5} 
+% 	}
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Box Name]
+ 	\pseudocode{
+ 		\text{step 1} \\
+ 		\text{step 2} \\
+ 		\pcfor \text{some condition} \pcdo \\
+ 		\pcind\text{step 3} 
+ 	}
+
+ 	\begin{bbrenv}{B}
+ 		\begin{bbrbox}[name=Inner Box]
+ 		\pseudocode{
+ 			\text{inner step 1} \\
+ 			\text{inner step 2} 
+ 		}
+ 		\end{bbrbox}
+ 	\end{bbrenv}
+
+ 	\pseudocode{
+ 		\text{step 4} \\
+ 		\text{step 5} 
+ 	}
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Messages and Queries}
+% \index{\textbackslash bbrmsgto}
+% \index{\textbackslash bbrmsgfrom}
+% \index{\textbackslash bbrmsgtofrom}
+% \index{\textbackslash bbrmsgfromto}
+% \index{\textbackslash bbrqryto}
+% \index{\textbackslash bbrqryfrom}
+% \index{\textbackslash bbrqrytofrom}
+% \index{\textbackslash bbrqryfromto}
+%
+% You can send messages and queries to boxes. For this use the commands 
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \bbrmsgto{options}
+ \bbrmsgfrom{options}
+ \bbrmsgtofrom{options}{options} 
+ \bbrmsgfromto{options}{options} 
+ \bbrqryto{options}
+ \bbrqryfrom{options}
+ \bbrqrytofrom{options}{options}
+ \bbrqryfromto{options}{options} 
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% By convention messages are on the left of boxes and queries on the right. Commands ending on |to|
+% make an arrow to the right while commands ending on |from| make an arrow to the left. The |options|
+% define how the message is drawn and consists of a key-value list. The |tofrom| and |fromto| variants
+% draw two messages (back and forth) that are more compactly set together. Here usually, the fist message
+% should be drawn on top (|top=Label|) while the second message should be drawn on the bottom (|bottom=Label|).
+% 
+% \medskip
+% For example, to draw a message with a label on top and on the side use
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \bbrmsgto{top=Top Label, side=Side Label}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% If your label contains a \enquote{,} (comma), then group the label in $\{\}$ (curly brackets).
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \bbrmsgto{top=Top Label, side={Side, Label}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% Following is a complete example. Notice that cryptocode takes care of the vertical positioning.
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Box Name]
+% 	\pseudocode{
+% 		\text{step 1} \\
+% 		\text{step 2} \\
+% 		\pcfor \text{some condition} \pcdo \\
+% 		\pcind\text{step 3} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+% 		\begin{bbrbox}[name=Inner Box]
+% 		\pseudocode{
+% 			\text{inner step 1} \\
+% 			\text{inner step 2} 
+% 		}
+% 		\end{bbrbox}
+%
+% 		\bbrmsgto{top={$m_0,m_1$}}
+% 		\bbrmsgfrom{top=$q$}
+%
+% 		\bbrqrytofrom{top={$m_0,m_1$}}{bottom=$q$}
+%
+% 	\end{bbrenv}
+%
+% 	\pseudocode{
+% 		\text{step 4} \\
+% 		\text{step 5} 
+% 	}
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Box Name]
+ 	\pseudocode{
+ 		\text{step 1} \\
+ 		\text{step 2} \\
+ 		\pcfor \text{some condition} \pcdo \\
+ 		\pcind\text{step 3} 
+ 	}
+
+ 	\begin{bbrenv}{B}
+ 		\begin{bbrbox}[name=Inner Box]
+ 		\pseudocode{
+ 			\text{inner step 1} \\
+ 			\text{inner step 2} 
+ 		}
+ 		\end{bbrbox}
+
+ 		\bbrmsgto{top={$m_0,m_1$}}
+ 		\bbrmsgfrom{top=$q$}
+
+ 		\bbrqrytofrom{top={$m_0,m_1$}}{bottom=$q$}
+
+ 	\end{bbrenv}
+
+ 	\pseudocode{
+ 		\text{step 4} \\
+ 		\text{step 5} 
+ 	}
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Options}
+% Following is a list of all available options. Remember that underneath the reduction 
+% commands is a TIKZ image (\url{https://www.ctan.org/pkg/pgf/}) and for each label 
+% position (top, side, bottom) a node is generated which can be further customized
+% via low-level TIKZ.
+%
+% \begin{description}
+% \item[top] Label on top
+% \item[bottom] Label on the bottom
+% \item[side] Label on the far side of the box. For challengers and oracles, on the side of the box.
+% \item[oside] Label on the \enquote{other} side. 
+% \item[topstyle] Style for label on top
+% \item[bottomstyle] Style for label on bottom 
+% \item[sidestyle] Style for label on side
+% \item[osidestyle] Style for label on other side
+% \item[edgestyle] Style for edge
+% \item[length] Length of arrow
+% \item[topname] Name for node on top
+% \item[bottomname] Name for node on bottom
+% \item[sidename] Name for node on side
+% \item[osidename] Name for node on other side
+% \item[aboveskip] Space before message 
+% \item[belowskip] Space after message 
+% \item[fixedoffset] Ignores automatic spacing and sets the message at the provided offset from the top.
+% \item[fixedboffset] Ignores automatic spacing and sets the message at the provided offset from the bottom.
+% \item[islast] Places the message at the bottom.
+% \end{description}
+%
+%
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Box Name]
+% 	\pseudocode{
+% 		\text{step 1} \\
+% 		\text{step 2} \\
+% 		\pcfor \text{some condition} \pcdo \\
+% 		\pcind\text{step 3} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+% 		\begin{bbrbox}[name=Inner Box]
+% 		\pseudocode{
+% 			\text{inner step 1} \\
+% 			\text{inner step 2} \\
+% 		}
+% 		\end{bbrbox}
+%
+% 		\bbrmsgto{top={$m_0,m_1$},side=Side Label, bottom=$b$, length=2cm,
+% 				  topstyle={draw, solid}, sidestyle={red}, bottomstyle={draw, dashed}}
+%
+% 	\end{bbrenv}
+%
+% 	\pseudocode{
+% 		\text{step 4} \\
+% 		\text{step 5} \\
+% 	}
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Box Name]
+ 	\pseudocode{
+ 		\text{step 1} \\
+ 		\text{step 2} \\
+ 		\pcfor \text{some condition} \pcdo \\
+ 		\pcind\text{step 3} 
+ 	}
+
+ 	\begin{bbrenv}{B}
+ 		\begin{bbrbox}[name=Inner Box]
+ 		\pseudocode{
+ 			\text{inner step 1} \\
+ 			\text{inner step 2} \\
+ 		}
+ 		\end{bbrbox}
+
+ 		\bbrmsgto{top={$m_0,m_1$},side=Side Label, bottom=$b$, length=2cm,
+ 				  topstyle={draw, solid}, sidestyle={red}, bottomstyle={draw, dashed}}
+
+ 	\end{bbrenv}
+
+ 	\pseudocode{
+ 		\text{step 4} \\
+ 		\text{step 5} \\
+ 	}
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+%
+% \subsubsection{First Message}
+% \index{\textbackslash bbrfirstmessageoffset}
+% The first message is offset by |\bbrfirstmessageoffset| which defaults to 1ex.
+%
+% \subsubsection{Add Space}
+% \index{\textbackslash bbrmsgspace}
+% \index{\textbackslash bbrqryspace}
+% If the spacing between messages is not sufficient you can use the |bbrmsgspace| and
+% |bbrqryspace| commands to add additional space.
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Reduction]
+% 	\pseudocode{
+% 		\text{Do something} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+%
+% 		\begin{bbrbox}[name=Adversary,minheight=15ex,xshift=4cm]
+%
+% 		\end{bbrbox}
+%
+% 		\bbrmsgto{top=$m$}
+% 		\bbrmsgspace{1.5cm}
+% 		\bbrmsgfrom{top=$\sigma$}
+%
+% 		\bbrqryto{top=$m$}
+% 		\bbrqryspace{1cm}
+% 		\bbrqryfrom{top=$\sigma$}
+%
+% 	\end{bbrenv}
+%
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Reduction]
+ 	\pseudocode{
+ 		\text{Do something} 
+ 	}
+
+ 	\begin{bbrenv}{B}
+
+ 		\begin{bbrbox}[name=Adversary,minheight=15ex,xshift=4cm]
+
+ 		\end{bbrbox}
+
+ 		\bbrmsgto{top=$m$}
+ 		\bbrmsgspace{1.5cm}
+ 		\bbrmsgfrom{top=$\sigma$}
+
+ 		\bbrqryto{top=$m$}
+ 		\bbrqryspace{1cm}
+ 		\bbrqryfrom{top=$\sigma$}
+
+ 	\end{bbrenv}
+
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% Note that for placing a message at the bottom, |islast| or fixed offsets often allow 
+% obtain more accurate results.
+%
+%	\begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+%		\begin{bbrbox}[name=Reduction]
+%		\pseudocode{
+%			\text{Do something} 
+%		}
+%
+%		\begin{bbrenv}{B}
+%
+%			\begin{bbrbox}[name=Adversary,minheight=15ex,xshift=4cm]
+%
+%			\end{bbrbox}
+%
+%			\bbrmsgto{top=$m$}
+%			\bbrmsgfrom{top=$\sigma$,islast}
+%
+%			\bbrqryto{top=$m$,fixedoffset=4ex}
+%			\bbrqryfrom{top=$\sigma$,fixedboffset=4ex}
+%
+%		\end{bbrenv}
+%
+%		\end{bbrbox}
+%		\bbrinput{input}
+%		\bbroutput{output}
+%	\end{bbrenv}
+% \iffalse
+%<*example>
+% \fi
+\begin{lstlisting}
+	\begin{bbrenv}{A}
+		\begin{bbrbox}[name=Reduction]
+		\pseudocode{
+			\text{Do something} 
+		}
+
+		\begin{bbrenv}{B}
+
+			\begin{bbrbox}[name=Adversary,minheight=15ex,xshift=4cm]
+
+			\end{bbrbox}
+
+			\bbrmsgto{top=$m$}
+			\bbrmsgfrom{top=$\sigma$,islast}
+
+			\bbrqryto{top=$m$,fixedoffset=4ex}
+			\bbrqryfrom{top=$\sigma$,fixedboffset=4ex}
+
+		\end{bbrenv}
+
+		\end{bbrbox}
+		\bbrinput{input}
+		\bbroutput{output}
+	\end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsubsection{Loops}
+% \index{\textbackslash bbrloop}
+% Often an adversary may send poly many queries to an oracle, or a reduction sends many queries to an adversary.
+% Consider the following setting
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Reduction]
+% 	\pseudocode{
+% 		\text{Do something} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+%
+% 		\begin{bbrbox}[name=Adversary,minheight=10ex,xshift=4cm]
+%
+% 		\end{bbrbox}
+%
+% 		\bbrmsgto{top=$m$,sidename=BeginLoop}
+% 		\bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
+%
+% 	\end{bbrenv}
+%
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Reduction]
+ 	\pseudocode{
+ 		\text{Do something} 
+ 	}
+
+ 	\begin{bbrenv}{B}
+
+ 		\begin{bbrbox}[name=Adversary,minheight=10ex,xshift=4cm]
+
+ 		\end{bbrbox}
+
+ 		\bbrmsgto{top=$m$}
+ 		\bbrmsgfrom{top=$\sigma$}
+
+ 	\end{bbrenv}
+
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% First note that by specifying the minheight and xshift option we shifted the adversary box a bit to the right
+% and enlarged its box. Further we specified custom names for the node on the  side of the two messages. We
+% can now use the |bbrloop| command to visualize that these two messages are exchanged $q$ many times
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \bbrloop{BeginLoop}{EndLoop}{center=$q$}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% The |bbrloop| command takes two node names and a config which allows you to specify if the label is
+% to be shown on the left, center or right. Here is the result.
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Reduction]
+% 	\pseudocode{
+% 		\text{Do something} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+%
+% 		\begin{bbrbox}[name=Adversary,minheight=10ex,xshift=4cm]
+%
+% 		\end{bbrbox}
+%
+% 		\bbrmsgto{top=$m$,sidename=BeginLoop}
+% 		\bbrmsgspace{0.5cm}
+% 		\bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
+% 		\bbrloop{BeginLoop}{EndLoop}{center=$q$}
+%
+% 	\end{bbrenv}
+%
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Reduction]
+ 	\pseudocode{
+ 		\text{Do something} 
+ 	}
+
+ 	\begin{bbrenv}{B}
+
+ 		\begin{bbrbox}[name=Adversary,minheight=10ex,xshift=4cm]
+
+ 		\end{bbrbox}
+
+ 		\bbrmsgto{top=$m$,sidename=BeginLoop}
+ 		\bbrmsgspace{0.5cm}
+ 		\bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
+ 		\bbrloop{BeginLoop}{EndLoop}{center=$q$}
+
+ 	\end{bbrenv}
+
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% The |\bbrloop| command supports the following parameters:
+% \begin{description}
+% \item[center]
+% Label displayed within the loop
+% \item[left]
+% Label displayed left of the loop
+% \item[right]
+% Label displayed right of the loop
+% \item[centerstyle]
+% Style for center label
+% \item[leftstyle]
+% Style for left label
+% \item[rightstyle]
+% Style for right label
+% \item[clockwise]
+% Loop going in clockwise direction
+% \item[angle]
+% Angle of the arrows
+% \end{description}
+%
+% \subsubsection{Intertext}
+% \index{\textbackslash bbrmsgtxt}
+% \index{\textbackslash bbrqrytxt}
+%
+% If your reduction needs to do some extra work between queries use the |\bbrmsgtxt|
+% and |\bbrqrytxt| commands.
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \bbrmsgtxt[options]{Text}
+ \bbrqrytxt[options]{Text}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Reduction]
+% 	\pseudocode{
+% 		\text{Do something} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+%
+% 		\begin{bbrbox}[name=Adversary,minheight=12ex,xshift=4cm]
+%
+% 		\end{bbrbox}
+%
+% 		\bbrmsgto{top=$m$}
+% 		\bbrmsgtxt{\pseudocode{
+% 			do \\
+% 			some \\
+% 			work
+% 		}}
+% 		\bbrmsgfrom{top=$\sigma$}
+%
+% 		\bbrqryto{top=$m$}
+% 		\bbrqrytxt[nodestyle={draw,dashed},xshift=2cm]{\pseudocode{
+% 			do \\
+% 			some \\
+% 			work
+% 		}}
+% 		\bbrqryfrom{top=$\sigma$}
+%
+% 	\end{bbrenv}
+%
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Reduction]
+ 	\pseudocode{
+ 		\text{Do something} 
+ 	}
+
+ 	\begin{bbrenv}{B}
+
+ 		\begin{bbrbox}[name=Adversary,minheight=12ex,xshift=4cm]
+
+ 		\end{bbrbox}
+
+ 		\bbrmsgto{top=$m$}
+ 		\bbrmsgtxt{\pseudocode{
+ 			do \\
+ 			some \\
+ 			work
+ 		}}
+ 		\bbrmsgfrom{top=$\sigma$}
+
+ 		\bbrqryto{top=$m$}
+ 		\bbrqrytxt[nodestyle={draw,dashed},xshift=2cm]{\pseudocode{
+ 			do \\
+ 			some \\
+ 			work
+ 		}}
+ 		\bbrqryfrom{top=$\sigma$}
+
+ 	\end{bbrenv}
+
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Oracles}
+% \index{bbroracle}
+% \index{hdistance}
+% \index{vdistance}
+% Each box can have one or more oracles which are drawn on the right hand side of the box. An oracle
+% is created similarly to a |bbrenv| environment using the |bbroracle| environment. Oracles
+% go behind the single |bbrbox| environment within an |bbrenv| enviornment.
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Reduction]
+% 	\pseudocode{
+% 		\text{Do something} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+% 		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
+% 		\end{bbrbox}
+%
+% 	\end{bbrenv}
+%
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+%
+% 	\begin{bbroracle}{OraA}
+% 		\begin{bbrbox}[name=Oracle 1]
+% 		\end{bbrbox}
+% 	\end{bbroracle}
+%
+% 	\begin{bbroracle}{OraB}[vdistance=2cm,hdistance=3cm]
+% 		\begin{bbrbox}[name=Oracle 2]
+% 		\end{bbrbox}
+% 	\end{bbroracle}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Reduction]
+ 	\pseudocode{
+ 		\text{Do something} 
+ 	}
+
+ 	\begin{bbrenv}{B}
+ 		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
+ 		\end{bbrbox}
+
+ 	\end{bbrenv}
+
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+
+ 	\begin{bbroracle}{OraA}
+ 		\begin{bbrbox}[name=Oracle 1]
+ 		\end{bbrbox}
+ 	\end{bbroracle}
+
+ 	\begin{bbroracle}{OraB}[vdistance=2cm,hdistance=3cm]
+ 		\begin{bbrbox}[name=Oracle 2]
+ 		\end{bbrbox}
+ 	\end{bbroracle}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% 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|.
+%
+% \subsubsection{Communicating with Oracles}
+% \index{\textbackslash bbroracleqryfrom}
+% \index{\textbackslash bbroracleqryto}
+% \index{\textbackslash bbroracleqrytofrom}
+% \index{\textbackslash bbroracleqryfromto}
+% As oracles use the \emph{bbrbox} environment we can directly use the established ways to send messages and
+% queries to oracles. In addition you can use the |\bbroracleqryfrom| and |\bbroracleqryto|.
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \bbroracleqryfrom{options}
+ \bbroracleqryto{options}
+ \bbroracleqrytofrom{options}{options}
+ \bbroracleqryfromto{options}{options}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Here options allow you to specify where the label goes (top, bottom). In addition you can use
+% |\bbroracleqryspace| to generate extra space between oracle messages. Note
+% that oracle messages need to be added after the closing |\end{bbroracle}| command.
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Reduction]
+% 	\pseudocode{
+% 		\text{Do something} 
+% 	}
+%
+% 	\begin{bbrenv}{B}
+% 		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=3cm]
+% 		\end{bbrbox}
+%
+% 	\end{bbrenv}
+%
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+%
+% 	\begin{bbroracle}{OraA}
+% 		\begin{bbrbox}[name=Oracle 1,minheight=1cm]
+% 		\end{bbrbox}
+% 	\end{bbroracle}
+% 	\bbroracleqryto{top=$m$}
+% 	\bbroracleqryfrom{top=$b$}
+%
+% 	\begin{bbroracle}{OraB}
+% 		\begin{bbrbox}[name=Oracle 2,minheight=1cm]
+% 		\end{bbrbox}
+% 	\end{bbroracle}
+% 	\bbroracleqrytofrom{top=$m$}{bottom=$b$}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Reduction]
+ 	\pseudocode{
+ 		\text{Do something} 
+ 	}
+
+ 	\begin{bbrenv}{B}
+ 		\begin{bbrbox}[name=Adversary,minheight=3cm,xshift=3cm]
+ 		\end{bbrbox}
+
+ 	\end{bbrenv}
+
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+
+ 	\begin{bbroracle}{OraA}
+ 		\begin{bbrbox}[name=Oracle 1,minheight=1cm]
+ 		\end{bbrbox}
+ 	\end{bbroracle}
+ 	\bbroracleqrytotop=$m$}
+ 	\bbroracleqryfrom{top=$b$}
+
+ 	\begin{bbroracle}{OraB}
+ 		\begin{bbrbox}[name=Oracle 2,minheight=1cm]
+ 		\end{bbrbox}
+ 	\end{bbroracle}
+ 	\bbroracleqrytofrom{top=$m$}{bottom=$b$}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Challengers}
+% \index{bbrchallenger}
+% \index{hdistance}
+% \index{vdistance}
+% Each box can have one or more challengers which are drawn on the left hand side of the box. Challengers
+% behave identically to oracles with the exception that they are to the left of the box. A challenger
+% is created similarly to a \emph{bbrenv} environment using the \emph{bbrchallenger} environment. Challengers
+% go behind the single \emph{bbrbox} environment within an \emph{bbrenv} enviornment.
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Adversary,minheight=2cm]
+% 	\pseudocode{
+% 		\text{Do something} 
+% 	}
+%
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+%
+% 	\begin{bbrchallenger}{ChaA}
+% 		\begin{bbrbox}[name=Challenger,minheight=2cm]
+%
+% 		\end{bbrbox}
+% 	\end{bbrchallenger}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Adversary,minheight=2cm]
+ 	\pseudocode{
+ 		\text{Do something} 
+ 	}
+
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+
+ 	\begin{bbrchallenger}{ChaA}
+ 		\begin{bbrbox}[name=Challenger,minheight=2cm]
+
+ 		\end{bbrbox}
+ 	\end{bbrchallenger}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% 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|.
+%
+% \subsubsection{Communicating with Challengers}
+% \index{\textbackslash bbrchallengerqryfrom}
+% \index{\textbackslash bbrchallengerqryto}
+% \index{\textbackslash bbrchallengerqrytofrom}
+% \index{\textbackslash bbrchallengerqryfromto}
+% As challengers use the \emph{bbrbox} environment we can directly use the established ways to send messages and
+% queries to oracles. In addition you can use the |\bbrchallengerqryfrom| and |\bbrchallengerqryto|.
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \bbrchallengerqryfrom{options}
+ \bbrchallengerqryto{options}
+ \bbrchallengerqrytofrom{options}{options}
+ \bbrchallengerqryfromto{options}{options}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+% Here options allow you to specify where the label goes (top, bottom). In addition you can use
+% |\bbrchallengerqryspace| to generate extra space between oracle messages. Note
+% that challenger messages need to be added after the closing |\end{bbrchallenger}| command.
+%
+% \begin{bbrenv}[aboveskip=1cm,belowskip=0.5cm]{A}
+% 	\begin{bbrbox}[name=Adversary,minheight=2cm]
+% 	\pseudocode{
+% 		\text{Do something} 
+% 	}
+%
+% 	\end{bbrbox}
+% 	\bbrinput{input}
+% 	\bbroutput{output}
+%
+% 	\begin{bbrchallenger}{ChaA}
+% 		\begin{bbrbox}[name=Challenger,minheight=2cm]
+%
+% 		\end{bbrbox}
+% 	\end{bbrchallenger}
+%
+% 	\bbrchallengerqrytofrom{top=$m$}{bottom=$b$}
+% \end{bbrenv}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \begin{bbrenv}{A}
+ 	\begin{bbrbox}[name=Adversary,minheight=2cm]
+ 	\pseudocode{
+ 		\text{Do something} 
+ 	}
+
+ 	\end{bbrbox}
+ 	\bbrinput{input}
+ 	\bbroutput{output}
+
+ 	\begin{bbrchallenger}{ChaA}
+ 		\begin{bbrbox}[name=Challenger,minheight=2cm]
+
+ 		\end{bbrbox}
+ 	\end{bbrchallenger}
+
+ 	\bbrchallengerqryfromto{top=$m$}{bottom=$b$}
+ \end{bbrenv}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{Examples}
+% A reduction sketch for full domain hash.
+%
+%\begin{bbrenv}{Red}
+%
+% 	\begin{bbrbox}[name=\textsc{Reduction }$\bdv$]
+%
+% 		\pseudocode{
+% 			j \sample [q] 
+% 		}
+%
+% 		\vspace{2ex}
+% 		\emph{/* begin simulation */}
+%
+% 		\begin{bbrenv}[aboveskip=2em]{Adv}
+% 			\begin{bbrbox}[name=$\adv$,minheight=8.5cm,style={fill=black},namestyle={color=white},xshift=3cm]
+% 			\end{bbrbox}
+%
+% 			\bbrinput{$\fk$}
+% 			\bbroutput{$\sigma$}			
+%
+% 			\bbrmsgfrom{top=$m_1$,afterskip=-0.5\baselineskip}
+% 			\bbrmsgto{bottom=$\$$,afterskip=0.5\baselineskip}
+%
+% 			\bbrmsgvdots
+%
+% 			\bbrmsgfrom{top=$m_{j-1}$,beforeskip=0.5\baselineskip,afterskip=-0.5\baselineskip}
+% 			\bbrmsgto{bottom=$\$$,afterskip=1.5\baselineskip}
+%
+% 			\bbrmsgfrom{top=$m_j$,afterskip=-0.5\baselineskip}
+% 			\bbrmsgto{bottom=$y$,afterskip=1.5\baselineskip}
+%
+% 			\bbrmsgfrom{top=$m_{j+1}$,afterskip=-0.5\baselineskip}
+% 			\bbrmsgto{bottom=$\$$,afterskip=0.5\baselineskip}
+%
+% 			\bbrmsgvdots
+%
+% 			\bbrmsgfrom{top=$m_q$,beforeskip=0.5\baselineskip,afterskip=-0.5\baselineskip}
+% 			\bbrmsgto{bottom=$\$$}
+%
+% 			\begin{bbroracle}{Sign}
+% 				\begin{bbrbox}[name=Sign,namepos=center,style={draw},minheight=1cm]
+% 				\end{bbrbox}
+% 			\end{bbroracle}
+%
+% 			\bbroracleqryto{top=$m$}
+% 			\bbroracleqryfrom{top=$\sigma$}			
+%
+% 		\end{bbrenv}
+%
+% 		\pcdraw{
+% 			\node[left=2cm of Adv.north west] (startsim) {};
+% 			\node[left=2cm of Adv.south west] (endsim) {};			
+% 			\draw[->,thick] (startsim) -- (endsim);
+% 			\node[rotate=90, left=2.75cm of Adv.west,anchor=center] () {\textsc{Simulation of Random Oracle}};
+% 		}
+%
+% 		\emph{/* end simulation */}
+%
+% 		\pseudocode{
+% 		 y \gets \sigma
+% 		}
+%
+% 	\end{bbrbox}
+% 	\bbrqryfrom{beforeskip=0.25cm,top={$(\fk, y)$},side={\dbox{\pseudocode{
+% 	  \fk \sample \fash.\kgen(\secparam) \\ x \sample \bin^{\fash.\il(\secpar)} \\ y \gets \fash.\eval(\fk, x)} 
+% 	}}}
+% 	\bbrqryto{beforeskip=11.75cm,side=\pseudocode{y \in \fash^{-1}(\fk, x)}}
+% \end{bbrenv}
+% 	
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+\begin{bbrenv}{Red}
+
+	\begin{bbrbox}[name=\textsc{Reduction }$\bdv$]
+
+		\pseudocode{
+			j \sample [q] 
+		}
+
+		\vspace{2ex}
+		\emph{/* begin simulation */}
+
+		\begin{bbrenv}[aboveskip=2em]{Adv}
+			\begin{bbrbox}[name=$\adv$,minheight=8.5cm,style={fill=black},namestyle={color=white},xshift=3cm]
+			\end{bbrbox}
+
+			\bbrinput{$\fk$}
+			\bbroutput{$\sigma$}			
+
+			\bbrmsgfrom{top=$m_1$,afterskip=-0.5\baselineskip}
+			\bbrmsgto{bottom=$\$$,afterskip=0.5\baselineskip}
+
+			\bbrmsgvdots
+
+			\bbrmsgfrom{top=$m_{j-1}$,beforeskip=0.5\baselineskip,afterskip=-0.5\baselineskip}
+			\bbrmsgto{bottom=$\$$,afterskip=1.5\baselineskip}
+
+			\bbrmsgfrom{top=$m_j$,afterskip=-0.5\baselineskip}
+			\bbrmsgto{bottom=$y$,afterskip=1.5\baselineskip}
+
+			\bbrmsgfrom{top=$m_{j+1}$,afterskip=-0.5\baselineskip}
+			\bbrmsgto{bottom=$\$$,afterskip=0.5\baselineskip}
+
+			\bbrmsgvdots
+
+			\bbrmsgfrom{top=$m_q$,beforeskip=0.5\baselineskip,afterskip=-0.5\baselineskip}
+			\bbrmsgto{bottom=$\$$}
+
+			\begin{bbroracle}{Sign}
+				\begin{bbrbox}[name=Sign,namepos=center,style={draw},minheight=1cm]
+				\end{bbrbox}
+			\end{bbroracle}
+
+			\bbroracleqryto{top=$m$}
+			\bbroracleqryfrom{top=$\sigma$}			
+
+		\end{bbrenv}
+
+		\pcdraw{
+			\node[left=2cm of Adv.north west] (startsim) {};
+			\node[left=2cm of Adv.south west] (endsim) {};			
+			\draw[->,thick] (startsim) -- (endsim);
+			\node[rotate=90, left=2.75cm of Adv.west,anchor=center] () {\textsc{Simulation of Random Oracle}};
+		}
+
+		\emph{/* end simulation */}
+
+		\pseudocode{
+			y \gets \sigma
+		}
+
+	\end{bbrbox}
+	\bbrqryfrom{beforeskip=0.25cm,top={$(\fk, y)$},side={\dbox{\pseudocode{
+		\fk \sample \fash.\kgen(\secparam) \\ x \sample \bin^{\fash.\il(\secpar)} \\ y \gets \fash.\eval(\fk, x)} 
+	}}}
+	\bbrqryto{beforeskip=11.75cm,side=\pseudocode{y \in \fash^{-1}(\fk, x)}}
+\end{bbrenv}
+
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \amipagebreak
+% \section{Known Issues}
+%
+% \subsection{Pseudocode KeepSpacing within Commands}
+% \label{sec:keepindent-problem}
+% \index{\textbackslash fbox}
+% \index{framebox}
+% The (experimental) \enquote{space=keep} option of pseudocode which should output spacing identical to that of the input 
+% will fail, if the pseudocode command is called from within another command. An example is to
+% wrap the |\pseudocode| command in an |\fbox| or in a stacking environment such as |\pchstack|. 
+% As a workaround for generating frame boxes you should hence
+% use a package such as \emph{mdframed} (\url{https://www.ctan.org/pkg/mdframed}) which provides a frame environment.
+%
+% \begin{mdframed}
+% \pseudocode[space=keep,mode=text]{        Pseudocode                with         - spaces -}
+% \end{mdframed}
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \pseudocode[space=keep,mode=text]{        Pseudocode                with         - spaces -}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% As an alternative you could use a \emph{savebox} (in combination with the |lrbox| environment):
+%
+% \newsavebox{\mypcbox}
+% \begin{lrbox}{\mypcbox}%
+% \pseudocode[space=keep,mode=text]{        Pseudocode                with         - spaces -}%
+% \end{lrbox}
+% \fbox{\usebox{\mypcbox}}
+%
+% \iffalse
+%<*example>
+% \fi
+ \begin{lstlisting}
+ \newsavebox{\mypcbox}
+ \begin{lrbox}{\mypcbox}%
+ \pseudocode[space=keep,mode=text]{        Pseudocode                with         - spaces -}%
+ \end{lrbox}
+ \fbox{\usebox{\mypcbox}}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% \subsection{AMSFonts}
+% \index{amsfonts}
+% \index{noamsfonts|see {package options}}
+% \index{package options!noamsfonts}
+% Some packages are not happy with the \enquote{amsfonts} package. Cryptocode will attempt to load amsfonts if it is loaded
+% with either the \enquote{sets} or the \enquote{probability} option. In order to not load amsfonts you can additionally add the
+% \enquote{noamsfonts} at the very end. Note that in this case you should ensure that the command |\mathbb| is defined
+% as this is used by most of the commands in \enquote{sets} and some of the commands in \enquote{probability}.
+%
+% \subsection{Hyperref}
+% The hyperref package (\url{https://www.ctan.org/pkg/hyperref}) should be loaded before cryptocode. If this is not possible
+% call the |\pcfixhyperref| after |\begin{document}|. 
+%
+%
+%\StopEventually{%
+%  \PrintChanges
+%  \PrintIndex
+%}
+%
+%
+% \amipagebreak
+%\section{Implementation}
+%
+% Following is the implementation of cryptocode. The source code documentation is 
+% a work in progress.
+%
+%    \begin{macrocode}
+%<*cryptocode.sty>
+%    \end{macrocode}
+%
+% Note that most macros are prefixed with \emph{pc}
+% short for pseudocode. This is a general design choice to not conflict
+% with macros defined by other packages. One exception are the macros
+% defined via the various package options.
+%
+%
+% Load amsmath and mathtools early on, before defining various macros.
+% 	 \begin{macrocode}
+\RequirePackage{amsmath}
+\RequirePackage{mathtools}
+%    \end{macrocode}
+%
+%
+% \subsection{Package Options}
+%
+%\begin{macro}{\@pc at opt@amsfonts}
+% Definitions of boolean flags used to determin whether or not to load amsfonts.
+% 	 \begin{macrocode}
+\newif\if at pc@opt at amsfonts
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\@pc at opt@advantage}
+% Whether or not to define commands for the given option.
+% 	 \begin{macrocode}
+\newif\if at pc@opt at advantage
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\@pc at opt@centernot}
+% Whether or not to load centernot
+% 	 \begin{macrocode}
+\newif\if at pc@opt at centernot
+%    \end{macrocode}
+%\end{macro}
+%
+%
+% \subsubsection{operators}
+%
+%\begin{macro}{\sample}
+%\begin{macro}{\floor}
+%\begin{macro}{\tfloor}
+%\begin{macro}{\ceil}
+%\begin{macro}{\tceil}
+%\begin{macro}{\Angle}
+%\begin{macro}{\tAngle}
+%\begin{macro}{\abs}	
+%\begin{macro}{\tabs}	
+%\begin{macro}{\norm}
+%\begin{macro}{\tnorm}
+%\begin{macro}{\concat}
+%\begin{macro}{\emptystring}
+%\begin{macro}{\argmax}
+%\begin{macro}{\argmin}
+%\begin{macro}{\pindist}
+%\begin{macro}{\cindist}
+%\begin{macro}{\sindist}
+% Definitions of macros for the \emph{operators} pacakge option.
+%
+%    \begin{macrocode}
+\DeclareOption{operators}{
+\providecommand{\sample}{\hskip2.3pt{\gets\!\!\mbox{\scriptsize${\$}$\normalsize}}\,}
+
+\DeclarePairedDelimiter\pc at floor{\lfloor}{\rfloor}
+\providecommand{\floor}[1]{\pc at floor*{#1}}
+\providecommand{\tfloor}[1]{\pc at floor{#1}}
+
+\DeclarePairedDelimiter\pc at ceil{\lceil}{\rceil}
+\providecommand{\ceil}[1]{\pc at ceil*{#1}}
+\providecommand{\tceil}[1]{\pc at ceil{#1}}
+
+\DeclarePairedDelimiter\pc at Angle{\langle}{\rangle}
+\providecommand{\Angle}[1]{\pc at Angle*{#1}}
+\providecommand{\tAngle}[1]{\pc at Angle{#1}}
+
+\DeclarePairedDelimiter\pc at abs{\lvert}{\rvert}
+\providecommand{\abs}[1]{\pc at abs*{#1}}
+\providecommand{\tabs}[1]{\pc at abs{#1}}
+
+\DeclarePairedDelimiter\pc at norm{\lVert}{\rVert}
+\providecommand{\norm}[1]{\pc at norm*{#1}}
+\providecommand{\tnorm}[1]{\pc at tnorm{#1}}
+
+\providecommand{\concat}{\ensuremath{\|}}
+\providecommand{\emptystring}{\ensuremath{\varepsilon}}
+
+\DeclareMathOperator*{\argmax}{arg\,max}
+\DeclareMathOperator*{\argmin}{arg\,min}
+
+%indistinguishability
+\newcommand{\@pc at oset}[3][0ex]{%
+  \mathrel{\mathop{#3}\limits^{
+    \vbox to#1{\kern-2\ex@
+    \hbox{$\scriptstyle#2$}\vss}}}}
+    
+\newcommand{\pindist}{\@pc at oset{\text{p}}{\lower.2ex\hbox{$=$}}}
+\newcommand{\sindist}{\@pc at oset{\text{s}}{\lower.1ex\hbox{$\approx$}}}
+\newcommand{\cindist}{\@pc at oset{\text{c}}{\lower.1ex\hbox{$\approx$}}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{adversary}
+%
+%\begin{macro}{\adversary}
+%\begin{macro}{\adv}
+%\begin{macro}{\bdv}
+%\begin{macro}{\cdv}
+%\begin{macro}{\ddv}
+%\begin{macro}{\edv}
+%\begin{macro}{\mdv}
+%\begin{macro}{\pdv}
+%\begin{macro}{\rdv}
+%\begin{macro}{\sdv}	
+% Definitions of adversaries $\adv$ (|\adv|), $\bdv$ (|\bdv|), etc.~together with a style |\pcadvstyle|.
+%    \begin{macrocode}
+\DeclareOption{adversary}{
+\providecommand{\adversary}[1]{\pcadvstyle{#1}}
+
+\providecommand{\adv}{\pcadvstyle{A}}
+\providecommand{\bdv}{\pcadvstyle{B}}
+\providecommand{\cdv}{\pcadvstyle{C}}
+\providecommand{\ddv}{\pcadvstyle{D}}
+\providecommand{\edv}{\pcadvstyle{E}}
+\providecommand{\mdv}{\pcadvstyle{M}}
+\providecommand{\pdv}{\pcadvstyle{P}}
+\providecommand{\rdv}{\pcadvstyle{R}}
+\providecommand{\sdv}{\pcadvstyle{S}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{landau}
+%
+%\begin{macro}{\bigO}
+%\begin{macro}{\smallO}
+%\begin{macro}{\bigOmega}
+%\begin{macro}{\smallOmega}
+%\begin{macro}{\bigsmallO}	
+%\begin{macro}{\bigTheta}	
+%\begin{macro}{\orderOf}	
+% Defines several \emph{Landau symbols}. 
+%    \begin{macrocode}
+\DeclareOption{landau}{
+\providecommand{\bigO}[1]{\ensuremath{\mathcal{O}\pc at olrk*{#1}}}
+\providecommand{\smallO}[1]{\ensuremath{\text{o}\pc at olrk*{#1}}}
+\providecommand{\bigOmega}[1]{\ensuremath{\Omega\pc at olrk*{#1}}}
+\providecommand{\smallOmega}[1]{\ensuremath{\omega\pc at olrk*{#1}}}
+\providecommand{\bigsmallO}[1]{%
+\PackageWarning{cryptocode}{bigsmallO is deprecated. Use bigTheta instead.}%
+\ensuremath{\Theta\pc at olrk*{#1}}}
+\providecommand{\bigTheta}[1]{\ensuremath{\Theta\pc at olrk*{#1}}}
+\providecommand{\orderOf}{\ensuremath{\sim}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{probability}
+%
+%\begin{macro}{\probname}
+%\begin{macro}{\expectationname}
+%\begin{macro}{\supportname}
+%\begin{macro}{\tprob}
+%\begin{macro}{\prob}
+%\begin{macro}{\tprobsub}
+%\begin{macro}{\probsub}
+%\begin{macro}{\probsublong}
+%\begin{macro}{\tcondprob}
+%\begin{macro}{\condprob}
+%\begin{macro}{\tcondprobsub}
+%\begin{macro}{\condprobsub}
+%\begin{macro}{\texpect}
+%\begin{macro}{\expect}
+%\begin{macro}{\texpsub}
+%\begin{macro}{\expsub}
+%\begin{macro}{\tcondexp}
+%\begin{macro}{\condexp}
+%\begin{macro}{\tcondexpsub}
+%\begin{macro}{\condexpsub}
+%\begin{macro}{\supp}
+%\begin{macro}{\entropy}
+%\begin{macro}{\condentropy}
+%\begin{macro}{\minentropy}
+%\begin{macro}{\condminentropy}
+%\begin{macro}{\condavgminentropy}
+% The \emph{probability} package option defines various macros for typesetting																				
+% probabilities.
+%
+% Sets flags |\@pc at opt@amsfontstrue|.
+%    \begin{macrocode}
+\DeclareOption{probability}{
+\@pc at opt@amsfontstrue
+
+\providecommand{\probname}{Pr}
+\providecommand{\expectationname}{\ensuremath{\mathbb{E}}}
+\providecommand{\supportname}{Supp}
+
+\providecommand{\tprob}[1]{\ensuremath{\operatorname{\probname}\pc at elrk{#1}}}
+\providecommand{\prob}[1]{\ensuremath{\operatorname{\probname}\pc at elrk*{#1}}}
+
+\providecommand{\tprobsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\pc at elrk{#2}}}
+\providecommand{\probsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\pc at elrk*{#2}}}
+\providecommand{\probsublong}[2]{\ensuremath{\prob{#2\,:\,#1}}}
+
+\providecommand{\tcondprob}[2]{\ensuremath{\tprob{#1\,\left|\,#2\vphantom{#1}\right.}}}
+\providecommand{\condprob}[2]{\ensuremath{\prob{#1\,\left|\,#2\vphantom{#1}\right.}}}
+
+\providecommand{\tcondprobsub}[3]{\ensuremath{\tprobsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+\providecommand{\condprobsub}[3]{\ensuremath{\probsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+
+\providecommand{\texpect}[1]{\ensuremath{\operatorname{\expectationname}\pc at elrk{#1}}}
+\providecommand{\expect}[1]{\ensuremath{\operatorname{\expectationname}\pc at elrk*{#1}}}
+
+\providecommand{\texpsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\pc at elrk{#2}}}
+\providecommand{\expsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\pc at elrk*{#2}}}
+
+\providecommand{\tcondexp}[2]{\ensuremath{\texpect{#1\,\left|\,#2\vphantom{#1}\right.}}}
+\providecommand{\condexp}[2]{\ensuremath{\expect{#1\,\left|\,#2\vphantom{#1}\right.}}}
+
+\providecommand{\tcondexpsub}[3]{\ensuremath{\texpsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+\providecommand{\condexpsub}[3]{\ensuremath{\expsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+
+\providecommand{\supp}[1]{\ensuremath{\operatorname{Supp}\pc at olrk*{#1}}}
+
+\providecommand{\entropy}[1]{\ensuremath{\operatorname{H}\pc at olrk*{#1}}}
+\providecommand{\condentropy}[2]{%
+\ensuremath{\operatorname{H}\pc at olrk*{#1\,\left|\,#2\vphantom{#1}\right.}}}    	
+
+\providecommand{\minentropy}[1]{\ensuremath{\operatorname{H_\infty}\pc at olrk*{#1}}}
+\providecommand{\tminentropy}[1]{\ensuremath{\operatorname{H_\infty}\pc at olrk{#1}}}
+\providecommand{\condminentropy}[2]{%
+\ensuremath{\operatorname{H_\infty}\pc at olrk*{#1\,\left|\,#2\vphantom{#1}\right.}}}    
+\providecommand{\tcondminentropy}[2]{%
+\ensuremath{\operatorname{H_\infty}\pc at olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}    
+\providecommand{\condavgminentropy}[2]{%
+\ensuremath{\operatorname{\tilde{H}_\infty}\pc at olrk*{#1\,\left|\,#2\vphantom{#1}\right.}}}        	
+\providecommand{\tcondavgminentropy}[2]{%
+\ensuremath{\operatorname{\tilde{H}_\infty}\pc at olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}        	
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{sets}
+%
+%\begin{macro}{\NN}
+%\begin{macro}{\ZZ}
+%\begin{macro}{\CC}
+%\begin{macro}{\QQ}
+%\begin{macro}{\RR}
+%\begin{macro}{\PP}
+%\begin{macro}{\FF}
+%\begin{macro}{\GG}
+%\begin{macro}{\set}
+%\begin{macro}{\sequence}
+%\begin{macro}{\bin}
+% The \emph{sets} option defines various macros for standard sets such as
+% natural numbers |\NN| (\NN). The style can be configured via |\pcsetstyle|.
+%
+% As we usually work with bit strings, the macro |\bin| defines the set \bin.
+% Sets the flags |\@pc at opt@amsfontstrue|.
+%    \begin{macrocode}
+\DeclareOption{sets}{
+\@pc at opt@amsfontstrue
+
+\providecommand\NN{\pcsetstyle{N}}
+\providecommand\ZZ{\pcsetstyle{Z}}
+\providecommand\CC{\pcsetstyle{C}}
+\providecommand\QQ{\pcsetstyle{Q}}
+\providecommand\RR{\pcsetstyle{R}}
+\providecommand\PP{\pcsetstyle{P}}
+\providecommand\FF{\pcsetstyle{F}}
+\providecommand\GG{\pcsetstyle{G}}           
+
+\providecommand{\set}[1]{\ensuremath{\pc at clrk*{#1}}}
+\providecommand{\sequence}[1]{\ensuremath{\pc at olrk*{#1}}}
+\providecommand{\bin}{\ensuremath{\{0,1\}}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+% \subsubsection{noamsfonts}
+%
+%\begin{macro}{\@pc at opt@amsfontsfalse}
+% Package option \emph{noamsfonts} ensures that ams fonts are not loaded.
+% For this flag |\@pc at opt@amsfontsfalse| is set to false.
+%    \begin{macrocode}
+\DeclareOption{noamsfonts}{
+	\@pc at opt@amsfontsfalse
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+% \subsubsection{notions}
+%
+%\begin{macro}{\indcpa}
+%\begin{macro}{\indcca}
+%\begin{macro}{\indccai}
+%\begin{macro}{\indccaii}
+%\begin{macro}{\priv}
+%\begin{macro}{\ind}
+%\begin{macro}{\indcda}
+%\begin{macro}{\prvcda}
+%\begin{macro}{\prvrcda}
+%\begin{macro}{\kiae}
+%\begin{macro}{\kdae}
+%\begin{macro}{\mle}
+%\begin{macro}{\uce}
+%\begin{macro}{\eufcma}
+%\begin{macro}{\eufko}
+%\begin{macro}{\eufnacma}
+%\begin{macro}{\seufcma}
+% The \emph{notion} package option defines various cryptographic security
+% notions. 
+% The style to be can be defined via |\pcnotionstyle|.
+%    \begin{macrocode}
+\DeclareOption{notions}{
+\providecommand{\indcpa}{\pcnotionstyle{IND\pcmathhyphen{}CPA}}
+\providecommand{\indcca}{\pcnotionstyle{IND\pcmathhyphen{}CCA}}
+\providecommand{\indccai}{\pcnotionstyle{IND\pcmathhyphen{}CCA1}}
+\providecommand{\indccaii}{\pcnotionstyle{IND\pcmathhyphen{}CCA2}}
+\providecommand{\priv}{\pcnotionstyle{PRIV}}
+\providecommand{\ind}{\pcnotionstyle{IND}}
+\providecommand{\indcda}{\pcnotionstyle{IND\pcmathhyphen{}CDA}}
+\providecommand{\prvcda}{\pcnotionstyle{PRV\pcmathhyphen{}CDA}}
+\providecommand{\prvrcda}{\pcnotionstyle{PRV\$\pcmathhyphen{}CDA}}
+\providecommand{\kiae}{\pcnotionstyle{KIAE}}
+\providecommand{\kdae}{\pcnotionstyle{KDAE}}
+\providecommand{\mle}{\pcnotionstyle{MLE}}	
+\providecommand{\uce}{\pcnotionstyle{UCE}}
+
+\providecommand{\eufcma}{\pcnotionstyle{EUF\pcmathhyphen{}CMA}}
+\providecommand{\eufnacma}{\pcnotionstyle{EUF\pcmathhyphen{}naCMA}}
+\providecommand{\seufcma}{\pcnotionstyle{SUF\pcmathhyphen{}CMA}}
+
+\providecommand{\eufko}{\pcnotionstyle{EUF\pcmathhyphen{}KO}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+% \subsubsection{logic}
+%
+%\begin{macro}{\AND}
+%\begin{macro}{\OR}
+%\begin{macro}{\NOR}
+%\begin{macro}{\NOT}
+%\begin{macro}{\NAND}
+%\begin{macro}{\XOR}
+%\begin{macro}{\XNOR}
+%\begin{macro}{\xor}
+%\begin{macro}{\false}
+%\begin{macro}{\true}
+%\begin{macro}{\notimplies}
+%    \begin{macrocode}
+\DeclareOption{logic}{
+% load centernot needed for notimplies
+\@pc at opt@centernottrue
+
+\providecommand{\AND}{\ensuremath{\mathrm{AND}}}
+\providecommand{\OR}{\ensuremath{\mathrm{OR}}}
+\providecommand{\NOR}{\ensuremath{\mathrm{NOR}}}
+\providecommand{\NOT}{\ensuremath{\mathrm{NOT}}}
+\providecommand{\NAND}{\ensuremath{\mathrm{NAND}}}        
+\providecommand{\XOR}{\ensuremath{\mathrm{XOR}}}		
+\providecommand{\XNOR}{\ensuremath{\mathrm{XNOR}}}		
+\providecommand{\xor}{\ensuremath{\oplus}}        
+\providecommand{\false}{\mathsf{false}} 
+\providecommand{\true}{\mathsf{true}}
+\providecommand{\notimplies}{\centernot\implies}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{ff (function families)}
+%
+%
+%\begin{macro}{\kgen}
+%\begin{macro}{\pgen}
+%\begin{macro}{\eval}
+%\begin{macro}{\invert}
+%\begin{macro}{\il}
+%\begin{macro}{\ol}
+%\begin{macro}{\kl}
+%\begin{macro}{\nl}
+%\begin{macro}{\rl}
+% The \emph{ff} option defines macros for function families.
+% Algorithms are typeset via |\pcalgostyle|.
+%    \begin{macrocode}
+\DeclareOption{ff}{
+\providecommand{\kgen}{\pcalgostyle{KGen}}
+\providecommand{\pgen}{\pcalgostyle{Pgen}}
+\providecommand{\eval}{\pcalgostyle{Eval}}
+\providecommand{\invert}{\pcalgostyle{Inv}}	
+
+\providecommand{\il}{\pcalgostyle{il}}
+\providecommand{\ol}{\pcalgostyle{ol}}
+\providecommand{\kl}{\pcalgostyle{kl}}
+\providecommand{\nl}{\pcalgostyle{nl}}
+\providecommand{\rl}{\pcalgostyle{rl}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{mm (machine models)}
+%
+%
+%\begin{macro}{\pcmachinemodelstyle}
+%\begin{macro}{\CRKT}
+%\begin{macro}{\TM}
+%\begin{macro}{\PROG}
+%\begin{macro}{\uTM}
+%\begin{macro}{\uC}
+%\begin{macro}{\uP}
+%\begin{macro}{\csize}
+%\begin{macro}{\tmtime}
+%\begin{macro}{\ppt}
+% The \emph{mm} option defines macros for machine models.
+%    \begin{macrocode}
+\DeclareOption{mm}{
+\providecommand{\CRKT}{\pcmachinemodelstyle{C}}
+\providecommand{\TM}{\pcmachinemodelstyle{M}}
+\providecommand{\PROG}{\pcmachinemodelstyle{P}}
+
+\providecommand{\uTM}{\pcmachinemodelstyle{UM}}
+\providecommand{\uC}{\pcmachinemodelstyle{UC}}
+\providecommand{\uP}{\pcmachinemodelstyle{UEval}}
+
+\providecommand{\csize}{\pcmachinemodelstyle{size}}        
+\providecommand{\tmtime}{\pcmachinemodelstyle{time}}
+\providecommand{\ppt}{\pcalgostyle{PPT}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+% \subsubsection{advantage}
+%
+% The \emph{advantage} option defines an |\advantage| command for typesetting
+% advantage declarations of adversaries.
+%    \begin{macrocode}
+\DeclareOption{advantage}{
+\@pc at opt@advantagetrue
+}
+%    \end{macrocode}
+%
+%
+% \subsubsection{primitives}
+%
+%\begin{macro}{\prover}
+%\begin{macro}{\verifier}
+%\begin{macro}{\nizk}
+%\begin{macro}{\hash}
+%\begin{macro}{\gash}
+%\begin{macro}{\fash}
+%\begin{macro}{\enc}
+%\begin{macro}{\dec}
+%\begin{macro}{\sig}
+%\begin{macro}{\sign}
+%\begin{macro}{\verify}
+%\begin{macro}{\obf}
+%\begin{macro}{\iO}
+%\begin{macro}{\diO}
+%\begin{macro}{\owf}
+%\begin{macro}{\prf}
+%\begin{macro}{\prp}
+%\begin{macro}{\prg}
+%\begin{macro}{\mac}
+%\begin{macro}{\puncture}
+%\begin{macro}{\source}
+%\begin{macro}{\predictor}
+%\begin{macro}{\sam}
+%\begin{macro}{\dist}
+%\begin{macro}{\distinguisher}
+%\begin{macro}{\simulator}
+%\begin{macro}{\ext}
+%\begin{macro}{\extractor}
+% The \emph{primitives} package option defines various cryptographic primitives.
+%    \begin{macrocode}
+\DeclareOption{primitives}{
+%    \end{macrocode}
+% Zero knowledge
+%    \begin{macrocode}	
+\providecommand{\prover}{\pcalgostyle{P}}
+\providecommand{\verifier}{\pcalgostyle{V}}
+\providecommand{\nizk}{\pcalgostyle{NIZK}}
+%    \end{macrocode}
+% Hash
+%    \begin{macrocode}
+\providecommand{\hash}{\pcalgostyle{H}}
+\providecommand{\gash}{\pcalgostyle{G}}
+\providecommand{\fash}{\pcalgostyle{F}}
+\providecommand{\pad}{\pcalgostyle{pad}}
+%    \end{macrocode}
+% Encryption
+%    \begin{macrocode}
+\providecommand{\enc}{\pcalgostyle{Enc}}
+\providecommand{\dec}{\pcalgostyle{Dec}}
+%    \end{macrocode}
+% Signatures
+%    \begin{macrocode}
+\providecommand{\sig}{\pcalgostyle{Sig}}
+\providecommand{\sign}{\pcalgostyle{Sign}}
+\providecommand{\verify}{\pcalgostyle{Vf}}
+%    \end{macrocode}
+% Obfuscation
+%    \begin{macrocode}
+\providecommand{\obf}{\pcalgostyle{O}}
+\providecommand{\iO}{\pcalgostyle{iO}}
+\providecommand{\diO}{\pcalgostyle{diO}}
+%    \end{macrocode}
+% One-wayness
+%    \begin{macrocode}
+\providecommand{\owf}{\pcalgostyle{OWF}}
+\providecommand{\owp}{\pcalgostyle{OWP}}
+\providecommand{\tdf}{\pcalgostyle{TF}}
+\providecommand{\inv}{\pcalgostyle{Inv}}
+\providecommand{\hcf}{\pcalgostyle{HC}}
+%    \end{macrocode}
+% Pseudorandomness
+%    \begin{macrocode}
+\providecommand{\prf}{\pcalgostyle{PRF}}
+\providecommand{\prp}{\pcalgostyle{PRP}}
+\providecommand{\prg}{\pcalgostyle{PRG}}
+%    \end{macrocode}
+% Message authentication code
+%    \begin{macrocode}
+\providecommand{\mac}{\pcalgostyle{MAC}}
+%    \end{macrocode}
+% Puncture
+%    \begin{macrocode}
+\providecommand{\puncture}{\pcalgostyle{Puncture}}
+%    \end{macrocode}
+% Misc
+%    \begin{macrocode}
+\providecommand{\source}{\pcalgostyle{S}}
+\providecommand{\predictor}{\pcalgostyle{P}}
+\providecommand{\sam}{\pcalgostyle{Sam}}
+\providecommand{\dist}{\pcalgostyle{D}}
+\providecommand{\distinguisher}{\pcalgostyle{Dist}}
+\providecommand{\simulator}{\pcalgostyle{Sim}}
+\providecommand{\ext}{\pcalgostyle{Ext}}
+\providecommand{\extractor}{\ext}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{oracles}
+%
+%\begin{macro}{\Oracle}
+%\begin{macro}{\oracle}
+%\begin{macro}{\ro}
+% The \emph{oracles} package option defines macros for typesetting oracles.
+%    \begin{macrocode}
+\DeclareOption{oracles}{
+\providecommand{\Oracle}[1]{\pcalgostyle{O{#1}}}
+
+\def\oracle{\bgroup\oracle@}
+\newcommand{\oracle@}[1][]{\ifthenelse{\equal{#1}{}}{\oracle@@{O}}{\oracle@@{#1}}}
+\def\oracle@@#1{\pcoraclestyle{#1}\egroup}
+
+\providecommand{\ro}{\pcoraclestyle{RO}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+% \subsubsection{events}
+%
+%\begin{macro}{\event}
+%\begin{macro}{\nevent}
+%\begin{macro}{\bad}
+%\begin{macro}{\nbad}
+% The \emph{events} package option defines macros for typesetting
+% events (probabilistic).
+% Also defines |\bad| as a \emph{bad event} often used in game based proofs.
+%    \begin{macrocode}
+\DeclareOption{events}{
+\providecommand{\event}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\nevent}[1]{\ensuremath{\overline{\event{#1}}}}
+
+\providecommand{\bad}{\ensuremath{\event{bad}}}
+\providecommand{\nbad}{\ensuremath{\nevent{bad}}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+% \subsubsection{complexity}
+%
+%\begin{macro}{\complclass}
+%\begin{macro}{\cocomplclass}
+%\begin{macro}{\npol}
+%\begin{macro}{\conpol}
+%\begin{macro}{\pol}
+%\begin{macro}{\bpp}
+%\begin{macro}{\ppoly}
+%\begin{macro}{\AM}
+%\begin{macro}{\coAM}
+%\begin{macro}{\AC}
+%\begin{macro}{\NC}
+%\begin{macro}{\TC}
+%\begin{macro}{\PH}
+%\begin{macro}{\csigma}
+%\begin{macro}{\cpi}
+%\begin{macro}{\cosigma}
+%\begin{macro}{\copi}
+% The \emph{complexity} package option defines various complexity classes.
+% The style can be adjusted via |\pccomplexitystyle|
+%    \begin{macrocode}
+\DeclareOption{complexity}{
+\providecommand{\complclass}[1]{\pccomplexitystyle{#1}}
+\providecommand{\cocomplclass}[1]{\pccomplexitystyle{co}\pcmathhyphen{}\pccomplexitystyle{#1}}
+
+\providecommand{\npol}{\pccomplexitystyle{NP}}
+\providecommand{\conpol}{\cocomplclass{NP}}
+\providecommand{\pol}{\pccomplexitystyle{P}}
+\providecommand{\bpp}{\pccomplexitystyle{BPP}}
+\providecommand{\ppoly}{\ensuremath{\pol/\mathrm{poly}}}
+
+\providecommand{\AM}{\pccomplexitystyle{AM}}
+\providecommand{\coAM}{\cocomplclass{AM}}
+
+\providecommand{\AC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{AC}}{\pccomplexitystyle{AC}^{#1}}}}
+\providecommand{\NC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{NC}}{\pccomplexitystyle{NC}^{#1}}}}
+\providecommand{\TC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{TC}}{\pccomplexitystyle{TC}^{#1}}}}
+
+\providecommand{\PH}{\pccomplexitystyle{PH}}
+\providecommand{\csigma}[1]{\pccomplexitystyle{\Sigma}^p_{#1}}
+\providecommand{\cpi}[1]{\pccomplexitystyle{\Pi}^p_{#1}}
+\providecommand{\cosigma}[1]{\cocomplclass{\Sigma}^p_{#1}}
+\providecommand{\copi}[1]{\cocomplclass{\Pi}^p_{#1}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+% \subsubsection{asymptotics}
+%
+%\begin{macro}{\negl}
+%\begin{macro}{\poly}
+%\begin{macro}{\cc}
+%\begin{macro}{\ee}
+%\begin{macro}{\kk}
+%\begin{macro}{\mm}
+%\begin{macro}{\nn}
+%\begin{macro}{\pp}
+%\begin{macro}{\qq}
+%\begin{macro}{\rr}
+% The \emph{asymptotics} package option defines \enquote{polynomials} \cc\ (|\cc|), 
+% \ee\ (|\ee|), \kk\, (|\kk|), \mm\ (|\mm|), \nn\ (|\nn|), \pp\ (|\pp|), and \qq\ (|\qq|) as well as macros |\negl| and |\poly|.
+%    \begin{macrocode}
+\DeclareOption{asymptotics}{
+\providecommand{\negl}[1][\secpar]{%
+\pcpolynomialstyle{negl}\ifthenelse{\equal{#1}{}}{}{\pc at olrk*{#1}}}
+
+\providecommand{\poly}[1][\secpar]{%
+\pcpolynomialstyle{poly}\ifthenelse{\equal{#1}{}}{}{\pc at olrk*{#1}}}
+
+\def\pp{\bgroup\pp@}
+\newcommand{\pp@}[1][]{\ifthenelse{\equal{#1}{}}{\pp@@{p}}{\pp@@{#1}}}
+\def\pp@@#1{\pcpolynomialstyle{#1}\egroup}
+
+
+\providecommand{\cc}{\pcpolynomialstyle{c}}
+\providecommand{\ee}{\pcpolynomialstyle{e}}
+\providecommand{\kk}{\pcpolynomialstyle{k}}
+\providecommand{\mm}{\pcpolynomialstyle{m}}
+\providecommand{\nn}{\pcpolynomialstyle{n}}
+\providecommand{\qq}{\pcpolynomialstyle{q}}
+\providecommand{\rr}{\pcpolynomialstyle{r}}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{keys}
+%
+%\begin{macro}{\pk}
+%\begin{macro}{\vk}
+%\begin{macro}{\sk}
+%\begin{macro}{\key}
+%\begin{macro}{\hk}
+%\begin{macro}{\gk}
+%\begin{macro}{\fk}
+%\begin{macro}{\st}
+%\begin{macro}{\state}
+% The \emph{keys} package option defines various \enquote{keys} such as
+% a symmetric and general purpose \key\ (|\key|) or an asymmetric key pair
+% \pk, \sk\ (|\pk| and |\sk|)
+%    \begin{macrocode}
+\DeclareOption{keys}{
+\providecommand{\pk}{\pckeystyle{pk}}
+\providecommand{\vk}{\pckeystyle{vk}}
+\providecommand{\sk}{\pckeystyle{sk}}
+
+\def\key{\bgroup\key@}
+\newcommand{\key@}[1][]{\ifthenelse{\equal{#1}{}}{\key@@{k}}{\key@@{#1}}}
+\def\key@@#1{\pckeystyle{#1}\egroup}
+
+\providecommand{\hk}{\pckeystyle{hk}}
+\providecommand{\gk}{\pckeystyle{gk}}
+\providecommand{\fk}{\pckeystyle{fk}}
+
+\providecommand{\st}{\pckeystyle{st}}
+
+\def\state{\bgroup\state@}
+\newcommand{\state@}[1][]{\ifthenelse{\equal{#1}{}}{\state@@{state}}{\state@@{#1}}}
+\def\state@@#1{\pckeystyle{#1}\egroup}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+% \subsubsection{Security parameter}
+%
+%
+%\begin{macro}{\SECPAR}
+%\begin{macro}{\secpar}
+%\begin{macro}{\secparam}
+% The \emph{n} option defines security parameter macros |\secpar| and |\secparam|
+% using $n$.
+% See also \enquote{lambda} package option.
+%    \begin{macrocode}
+\DeclareOption{n}{
+	\providecommand{\SECPAR}{\ensuremath{{N_0}}}
+	\providecommand{\secpar}{\ensuremath{n}}
+	\providecommand{\secparam}{\ensuremath{1^\secpar}}
+}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+%
+%\begin{macro}{\SECPAR}
+%\begin{macro}{\secpar}
+%\begin{macro}{\secparam}
+% The \emph{n} option defines security parameter macros |\secpar| and |\secparam|
+% using $\lambda$.
+% See also \enquote{n} package option.
+%    \begin{macrocode}
+\DeclareOption{lambda}{
+	\renewcommand{\SECPAR}{\ensuremath{\Lambda}}
+	\renewcommand{\secpar}{\ensuremath{\lambda}}
+	\renewcommand{\secparam}{\ensuremath{1^\secpar}}
+}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \subsection{Preamble and Option Parsing}
+%
+% Print a warning in case an undefined package option is provided.
+%    \begin{macrocode}
+\DeclareOption*{%
+	\PackageError{cryptocode}{Unknown option ‘\CurrentOption’}%
+}
+%    \end{macrocode}
+%
+% By default, only the \emph{n} option (security parameter as $n$ and $1^n$) is loaded
+%    \begin{macrocode}
+\ExecuteOptions{n}
+%    \end{macrocode}
+%
+% We are now ready to process all package options
+%    \begin{macrocode}
+\ProcessOptions\relax
+%    \end{macrocode}
+%
+% The cryptocode package depends on various external packages which are
+% loaded next. Note that the \emph{amsfonts} package is optional and can be
+% disabled via the \emph{noamsfonts} package option.
+%
+% Note that amsmath and mathtools have been loaded already earlier.
+%    \begin{macrocode}
+\RequirePackage{etex}
+\if at pc@opt at amsfonts
+	\RequirePackage{amsfonts}
+\fi
+\if at pc@opt at centernot
+	\RequirePackage{centernot}
+\fi
+\RequirePackage{xcolor}
+\RequirePackage{calc}
+\RequirePackage{tikz}
+\usetikzlibrary{positioning,calc}
+\RequirePackage{ifthen}
+\RequirePackage{xargs}
+\RequirePackage{pgf}
+\RequirePackage{forloop}
+\RequirePackage{array}
+\RequirePackage{xparse}
+\RequirePackage{expl3}
+\RequirePackage{pbox}
+\RequirePackage{varwidth}
+\RequirePackage{suffix}
+\RequirePackage{etoolbox}
+\RequirePackage{environ}
+\RequirePackage{xkeyval}
+%    \end{macrocode}
+%
+%
+%
+%\begin{macro}{\pcadvantagesuperstyle}
+%\begin{macro}{\pcadvantagename}
+%\begin{macro}{\pcadvantagesubstyle}
+%\begin{macro}{\advantage}
+% The \emph{advantage} option defines an |\advantage| command for typesetting
+% advantage declarations of adversaries.
+%    \begin{macrocode}
+\if at pc@opt at advantage
+\providecommand{\pcadvantagesuperstyle}[1]{\mathrm{\MakeLowercase{#1}}}
+\providecommand{\pcadvantagesubstyle}[1]{#1}
+\providecommand{\pcadvantagename}{\mathsf{Adv}}
+
+\newcommandx*{\advantage}[3][3=(\secpar)]{\ensuremath{\pcadvantagename^{\pcadvantagesuperstyle{#1}}_{\pcadvantagesubstyle{#2}}#3}}
+\fi
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+% \subsection{Global Macros}
+%
+%
+% 
+%
+% \subsubsection{Styles}
+%
+%
+%
+%\begin{macro}{\pcalgostyle}
+%\begin{macro}{\pcsetstyle}
+%\begin{macro}{\pccomplexitystyle}
+%\begin{macro}{\pcpolynomialstyle}
+%\begin{macro}{\pcadvstyle}
+%\begin{macro}{\pcnotionstyle}
+%\begin{macro}{\pckeystyle}
+%\begin{macro}{\pcmachinemodelstyle}
+%\begin{macro}{\pcoraclestyle}
+% Definition of styles for algorithms, sets, complexity classes, polynomials,
+% adversaries, notions, keys, and machine models.
+%    \begin{macrocode}
+\providecommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\pcsetstyle}[1]{\ensuremath{\mathbb{#1}}}
+\providecommand{\pccomplexitystyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\pcpolynomialstyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\pcadvstyle}[1]{\ensuremath{\mathcal{#1}}}
+\providecommand{\pcnotionstyle}[1]{\ensuremath{\mathrm{#1}}}
+\providecommand{\pckeystyle}[1]{\ensuremath{\mathsf{\protect\vphantom{p}#1}}}
+\providecommand{\pcmachinemodelstyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\pcoraclestyle}[1]{\ensuremath{\mathsf{#1}}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{Order of Growth}
+%
+%\begin{macro}{\pc at olrk}
+%\begin{macro}{\pc at olrk*}
+%\begin{macro}{\pc at elrk}
+%\begin{macro}{\pc at elrk*}
+%\begin{macro}{\pc at clrk}
+%\begin{macro}{\pc at clrk*}
+% Define order of growth helper macros. These are optionally defined depending
+% on the loaded package options.
+%    \begin{macrocode}
+\DeclarePairedDelimiter\pc at olrk{(}{)}
+\DeclarePairedDelimiter\pc at elrk{[}{]}
+\DeclarePairedDelimiter\pc at clrk{\{}{\}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+% 
+% \subsubsection{Spacing}
+%
+%\begin{macro}{\pcaboveskip}
+%\begin{macro}{\pcbelowskip}
+%\begin{macro}{\pcbeforeskip}
+%\begin{macro}{\pcafterskip}
+% Control the spacing before (resp.~after) pseudocode and stacking blocks both
+% vertically and horizontally.
+%    \begin{macrocode}
+\newlength\pcaboveskip
+\setlength\pcaboveskip{\abovedisplayskip}
+
+\newlength\pcbelowskip
+\setlength\pcbelowskip{\belowdisplayskip}
+
+\newlength\pcbeforeskip
+\newlength\pcafterskip
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+% \subsubsection{Keywords and Highlighting}
+%
+%
+%\begin{macro}{\highlightkeyword}
+%\begin{macro}{\highlightaltkeyword}
+% Commands for highlighting primary and secondary keywords.
+% Both commands take an optional first parameter to control spacing
+%    \begin{macrocode}
+\newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
+\newcommand{\highlightaltkeyword}[2][\ ]{\ensuremath{\mathsf{#2}}#1}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\pcglobvar}
+%\begin{macro}{\pcnew}
+%\begin{macro}{\pcwhile}
+%\begin{macro}{\pcendwhile}
+%\begin{macro}{\pcdo}
+%\begin{macro}{\pcif}
+%\begin{macro}{\pcunless}
+%\begin{macro}{\pcelse}
+%\begin{macro}{\pcelseif}
+%\begin{macro}{\pcfi}
+%\begin{macro}{\pcendif}
+%\begin{macro}{\pcendfor}
+%\begin{macro}{\pcthen}
+%\begin{macro}{\pcreturn}
+%\begin{macro}{\pcin}
+%\begin{macro}{\pcfor}
+%\begin{macro}{\pcrepeat}
+%\begin{macro}{\pcrepeatuntil}
+%\begin{macro}{\pcforeach}
+%\begin{macro}{\pcendforeach}
+%\begin{macro}{\pcuntil}
+%\begin{macro}{\pccontinue}
+%\begin{macro}{\pcfalse}
+%\begin{macro}{\pctrue}
+%\begin{macro}{\pcnull}
+%\begin{macro}{\pcdone}
+%\begin{macro}{\pcparse}
+%\begin{macro}{\pcfail}
+%\begin{macro}{\pcabort}
+% All predefined (highlightable) keywords.
+%    \begin{macrocode}
+\newcommand{\pcglobvar}{\highlightkeyword{gbl}}
+\newcommand{\pcnew}{\highlightkeyword{new}}
+\newcommand{\pcwhile}{\@pc at increaseindent\highlightkeyword{while}}
+\newcommand{\pcendwhile}{\@pc at decreaseindent\highlightkeyword{endwhile}}
+\newcommandx*{\pcdo}[2][1=\ ,2=]{#1\highlightkeyword[#2]{do}}
+\newcommandx*{\pcif}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{if}}
+\newcommandx*{\pcunless}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{unless}}
+\newcommandx*{\pcelse}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else}}
+\newcommandx*{\pcelseif}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else if}}
+\newcommand{\pcfi}{\@pc at decreaseindent\highlightkeyword{fi}}
+\newcommand{\pcendif}{\@pc at decreaseindent\highlightkeyword{endif}}
+\newcommand{\pcendfor}{\@pc at decreaseindent\highlightkeyword{endfor}}
+\newcommandx*{\pcthen}[2][1=\ ,2=\ ]{#1\highlightkeyword[#2]{then}}
+\newcommand{\pcreturn}{\highlightkeyword{return}}
+\newcommandx*{\pcin}[2][1=\ ,2=]{#1\highlightkeyword[#2]{in}}
+\newcommandx*{\pcfor}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{for}}
+\newcommand{\pcrepeat}[1]{%
+\@pc at increaseindent\ensuremath{%
+\highlightkeyword{repeat} #1\ \highlightkeyword{times}%
+}}
+\newcommand{\pcrepeatuntil}[2]{%
+\ensuremath{\highlightkeyword{repeat}\ #1\ \highlightkeyword{until}\ #2}}
+\newcommand{\pcforeach}{\@pc at increaseindent\highlightkeyword{foreach}}
+\newcommand{\pcendforeach}{\@pc at decreaseindent\highlightkeyword{endforeach}}
+\newcommand{\pcuntil}{\@pc at decreaseindent\highlightkeyword{until}}
+\newcommand{\pccontinue}{\highlightkeyword{continue}}
+\newcommandx*{\pcfalse}[2][1=\ ,2=]{\highlightkeyword[#2]{false}}
+\newcommandx*{\pctrue}[2][1=\ ,2=]{\highlightkeyword[#2]{true}}
+\newcommandx*{\pcnull}[2][1=\ ,2=]{\highlightkeyword[#2]{null}}
+\newcommand{\pcdone}{\highlightkeyword{done}}
+\newcommand{\pcparse}{\highlightkeyword{parse}}
+\newcommand{\pcfail}{\highlightkeyword{fail}}
+\newcommand{\pcabort}{\highlightkeyword{abort}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+% \subsubsection{Misc}
+%
+% 
+%\begin{macro}{\pcmathhyphen}
+% Definition of a hyphen to be used within math formulas.
+%    \begin{macrocode}
+\mathchardef\pcmathhyphen ="2D
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\pccomment}
+%\begin{macro}{\pclinecomment}
+% Programming style line comment prefixing the comment with a double slash.
+% An optional first parameter allows to control the spacing before the comment
+% (defaults to 1em).
+%    \begin{macrocode}
+\newcommand{\pccomment}[2][1em]{\hspace{#1}{\mbox{/\!\!/ } \text{\scriptsize#2}}}
+\newcommand{\pclinecomment}[2][0em]{\hspace{#1}{\mbox{/\!\!/ } \text{\scriptsize#2}}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsection{Internal Helper Functions}
+%
+%
+%\begin{macro}{\@expandedsetkeys}
+%^^A https://tex.stackexchange.com/questions/27172/how-can-i-detect-if-im-inside-or-outside-of-a-float-environment
+%    \begin{macrocode}
+\newcommand\@pc at ifinfloat[2]{\ifnum\@floatpenalty<0\relax#1\else#2\fi}
+%    \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@expandedsetkeys}
+% Calls |\setkeys| from the xkeyval package but before exapands argument number 4.
+% Arguments \marg{families} \marg{na} \marg{first set of keys} \marg{keys to be expanded} \marg{final set of keys}
+%    \begin{macrocode}
+\newcommand*\@expandedsetkeys[5]{\expandafter\@expandedsetkeys@\expandafter{#4}{#1}{#2}{#3}{#5}}
+\def\@expandedsetkeys@#1#2#3#4#5{\setkeys{#2}[#3]{#4,#1,#5}}
+%    \end{macrocode}
+%\end{macro}
+%
+%    \begin{macrocode}
+\newenvironment{@pc at withspaces}
+ {\obeyspaces\begingroup\lccode`~=` \lowercase{\endgroup\let~}\ }
+ {}
+%    \end{macrocode}
+%
+%\begin{macro}{\@pc at settowidthofalign}
+%\begin{macro}{\@pc at settowidthofaligned}
+% Commands to measure width of an align (resp. aligned) environment. Takes two arguments
+% a length in which to store the resulting width and the content.
+%    \begin{macrocode}
+\newcommand{\@pc at settowidthofalign}[2]{%
+  \setbox\z@=\vbox{\@pseudocodecodesize
+    \begin{flalign*}
+    #2
+    \ifmeasuring@\else\global\let\got at maxcolwd\maxcolumn at widths\fi
+    \end{flalign*}
+  }%
+  \begingroup
+  \def\or{+}\edef\x{\endgroup#1=\dimexpr\got at maxcolwd\relax}\x}
+
+\newcommand{\@pc at settowidthofaligned}[2]{%
+\settowidth{#1}{\@pseudocodesubcodesize$\begin{aligned}#2\end{aligned}$}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\@pc at ifdraft}
+% Check for draft mode.
+%    \begin{macrocode}
+\def\@pc at ifdraft{\ifdim\overfullrule>\z@
+  \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\@pc at executeblindly}
+% Run stuff in an empty box
+%    \begin{macrocode}
+\newcommand{\@pc at executeblindly}[1]{%
+ \setbox\z@=\vbox{#1 }}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+% We need to fiddle with the label command to use it in |\pseudocode|. To
+% access the original, we store it in
+%    \begin{macrocode}
+\AtBeginDocument{
+	\let\@pc at original@label\ltx at label
+}
+%    \end{macrocode}
+%
+%
+%\begin{macro}{\@pc at globaladdtolength}
+%\begin{macro}{\@pc at globalsetlength}
+% A helper command to set (resp.~add to) the length to a given value globally
+% even when being within a scoped grouping. 
+%    \begin{macrocode}
+\newcommand*{\@pc at globaladdtolength}[2]{%
+\addtolength{#1}{#2}%
+\global#1=#1\relax}
+
+\newcommand*{\@pc at globalsetlength}[2]{%
+\setlength{#1}{#2}%
+\global#1=#1\relax}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%
+%
+%\begin{macro}{@pc at global@pc at cnt}
+%\begin{macro}{@pc at global@pc at nestcnt}
+% A global counter storing the number of times the pseudocode command was triggered.
+%    \begin{macrocode}
+\newcounter{@pc at global@pc at cnt}
+\newcounter{@pc at global@pc at nestcnt}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%
+%
+% Fix hyperref package.. gnarl http://tex.stackexchange.com/questions/130319/incompatibility-between-etoolbox-and-hyperref
+%    \begin{macrocode}
+\providecommand{\pcfixhyperref}{
+\global\let\textlabel\label
+\global\let\@pc at original@label\textlabel
+ %\global\let\@pc at original@label\relax
+ %\global\let\label\relax
+}
+%    \end{macrocode}
+%
+%
+%
+%
+%
+% \subsection{Stacking}
+%
+% In the following we define two stacking environments |pchstack| and |pcvstack| 
+% to layout multiple pseudocode blocks.
+%
+%
+%
+% \subsubsection{Manual Spacing}
+%
+%    \begin{macrocode}
+%
+\newcommand{\pchspace}[1][1em]{\hspace{#1}}
+\newcommand{\pcvspace}[1][\baselineskip]{\par\vspace{#1}}
+%
+%    \end{macrocode}
+%
+%
+% \subsubsection{Misc}
+%
+%\begin{macro}{@pc at stackdepth}
+%\begin{macro}{\@pc at incstackdepth}
+%\begin{macro}{\@pc at decstackdepth}
+% Counter to keep track of nesting level of stacks.
+%    \begin{macrocode}
+\newcounter{@pc at stackdepth}
+\newcommand{\@pc at incstackdepth}{\addtocounter{@pc at stackdepth}{1}}
+\newcommand{\@pc at decstackdepth}{\addtocounter{@pc at stackdepth}{-1}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+% \subsubsection{Stacking Options}
+%
+%\begin{macro}{center}
+%\begin{macro}{\@pc at centerstack}
+% Allows to center the stack.
+%    \begin{macrocode}
+\newcommand{\@pc at centerstack}{false}
+\define at key{pcstack}{center}[true]{\ifthenelse{\equal{#1}{true}}
+{\renewcommand{\@pc at centerstack}{true}}
+{\renewcommand{\@pc at centerstack}{false}}}%
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{boxed}
+%\begin{macro}{\@pc at boxedstack}
+% Allows to draw a box around the stack.
+%    \begin{macrocode}
+\newcommand{\@pc at boxedstack}{false}
+\define at key{pcstack}{boxed}[true]{\ifthenelse{\equal{#1}{true}}
+{\renewcommand{\@pc at boxedstack}{true}}
+{\renewcommand{\@pc at boxedstack}{false}}}%
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{noindent}
+%\begin{macro}{\@pc at noindentstack}
+% Allows to draw a box around the stack.
+%    \begin{macrocode}
+\newcommand{\@pc at noindentstack}{false}
+\define at key{pcstack}{noindent}[true]{\ifthenelse{\equal{#1}{true}}
+{\renewcommand{\@pc at noindentstack}{true}}
+{\renewcommand{\@pc at noindentstack}{false}}}%
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{inline}
+%\begin{macro}{\@pc at inlinestack}
+% Allows to keep the pchstack inline and not creating a paragraph.
+%    \begin{macrocode}
+\newcommand{\@pc at inlinestack}{false}
+\define at key{pcstack}{inline}[true]{\ifthenelse{\equal{#1}{true}}
+{\renewcommand{\@pc at inlinestack}{true}}
+{\renewcommand{\@pc at inlinestack}{false}}}%
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{space}
+%\begin{macro}{\pchstackspace}
+%\begin{macro}{\pcvstackspace}
+%\begin{macro}{\@pc at centerstack}
+% Introduces horizontal (resp.~vertical) space in-between pseudocode blocks
+% in stacking environments .
+%    \begin{macrocode}
+\providecommand{\pchstackspace}{0pt}
+\providecommand{\pcvstackspace}{0pt}
+\newcommand{\@pc at stackspace@forpseudocode}{}
+\newlength{\@pc at stackspace@len}
+\newcommand*{\@pc at stackspace}{0pt}
+\newcommand*{\@pc at reset@stackspace}{\setlength{\@pc at stackspace@len}{\@pc at stackspace}}
+\define at key{pcstack}{space}[0pt]{\renewcommand*{\@pc at stackspace}{#1}}%
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{aboveskip}
+%\begin{macro}{\@pc at applyaboveskipinstack}
+%\begin{macro}{\@pc at addabovespaceunlessstacking}
+% By default |\pcaboveskip| is applied on the outer most stacking environment.
+% Can be overriden using |aboveskip|.	
+%    \begin{macrocode}
+\newcommand{\@pc at addabovespaceunlessstacking}{%
+\ifthenelse{\value{@pc at stackdepth}=0}{\par\addvspace{\pcaboveskip}}{}}
+
+\newcommand{\@pc at applyaboveskipinstack}{\@pc at addabovespaceunlessstacking}
+\let\org at pc@applyaboveskipinstack\@pc at applyaboveskipinstack
+
+\define at key{pcstack}{aboveskip}[default]{\ifthenelse{\equal{#1}{default}}
+{\renewcommand{\@pc at applyaboveskipinstack}{\org at pc@applyaboveskipinstack}}
+{\renewcommand{\@pc at applyaboveskipinstack}{\vspace{#1}}}}%
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{belowskip}
+%\begin{macro}{\@pc at applybelowskipinstack}		
+%\begin{macro}{\@pc at addbelowspaceunlessstacking}		
+% By default |\pcbelowskip| is applied on the outer most stacking environment.
+% Can be overriden using |belowskip|.
+%    \begin{macrocode}
+\newcommand{\@pc at addbelowspaceunlessstacking}{%
+\ifthenelse{\value{@pc at stackdepth}=0}
+	{\@pc at ifinfloat{}{\par\addvspace{\pcbelowskip}}}
+	{}}
+
+\newcommand{\@pc at applybelowskipinstack}{\@pc at addbelowspaceunlessstacking}
+\let\org at pc@applybelowskipinstack\@pc at addbelowspaceunlessstacking
+
+\define at key{pcstack}{belowskip}[default]{\ifthenelse{\equal{#1}{default}}
+{\renewcommand{\@pc at applybelowskipinstack}{\org at pc@applybelowskipinstack}}
+{\renewcommand{\@pc at applybelowskipinstack}{\par\addvspace{#1}}}}%
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{\pcbeforehstackskip}
+%\begin{macro}{\pcafterhstackskip}
+%Allows adding global skips before and after |\pchstack| blocks.
+%    \begin{macrocode}
+\newlength{\pcbeforehstackskip}
+\newlength{\pcafterhstackskip}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\@pc at boxedstack}
+% For |\pchstack| and |\pcvstack| we use a box to store temporary results.
+%    \begin{macrocode}
+\newsavebox{\@pc at stackcontentbox}%
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\pcsethstackargs}
+%\begin{macro}{\pcsetvstackargs}
+%    \begin{macrocode}
+\newcommand*\@pc at hstack@defaultargs{}
+\newcommand*\pcsethstackargs[1]{\renewcommand*\@pc at hstack@defaultargs{#1}}
+\newcommand*\@pc at vstack@defaultargs{}
+\newcommand*\pcsetvstackargs[1]{\renewcommand*\@pc at vstack@defaultargs{#1}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+% \subsubsection{The Stacking Environments}
+%
+%\begin{macro}{pccenter}
+%    \begin{macrocode}
+\newenvironment{pccenter}{%
+\setlength\topsep{0pt}\setlength\parskip{0pt}%
+\begin{center}}{\end{center}}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{environment}{pchstack}
+% A stacking environment for horizontally stacked pseudocode blocks.
+%    \begin{macrocode}
+\NewEnviron{pchstack}[1][]{%
+%Ensure that the parameters are defaulted
+\begingroup%
+% parse args this is the same as 
+% \setkeys{pcstack}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pchstackspace,#1}%
+% expect that we expand the default args
+\@expandedsetkeys{pcstack}{}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pchstackspace}{\@pc at hstack@defaultargs}{#1}%
+\@pc at reset@stackspace%
+%add above skip except when in inline mode
+\ifthenelse{\equal{\@pc at inlinestack}{true}}{}{\@pc at applyaboveskipinstack}%
+\@pc at incstackdepth%
+\renewcommand{\@pc at stackspace@forpseudocode}{\hspace{\@pc at stackspace}}%
+%Store main content in a box
+\ifthenelse{\equal{\@pc at boxedstack}{true}}%
+{\sbox{\@pc at stackcontentbox}
+   {\fbox{\mbox{\hspace{\pcbeforehstackskip}\BODY\hspace{\pcafterhstackskip}\hspace{-\@pc at stackspace}}}}}%
+{\sbox{\@pc at stackcontentbox}
+   {\mbox{\hspace{\pcbeforehstackskip}\BODY\hspace{\pcafterhstackskip}\hspace{-\@pc at stackspace}}}}%
+% handle noindent
+\ifthenelse{\equal{\@pc at noindentstack}{true}}{\par\noindent\ignorespaces}{}%
+%set content either centered or directly
+\ifthenelse{\equal{\@pc at centerstack}{true}}%
+{\begin{pccenter}\usebox{\@pc at stackcontentbox}\end{pccenter}}
+{\usebox{\@pc at stackcontentbox}}%
+% cleanup
+\@pc at decstackdepth%
+\ifthenelse{\equal{\@pc at inlinestack}{true}}{}{\@pc at applybelowskipinstack}%
+\endgroup%reset space outside group
+\@pc at reset@stackspace%
+\@pc at stackspace@forpseudocode%
+%ignore any spaces after, to allow staying within paragraph
+\ignorespacesafterend\noindent%	
+}
+%    \end{macrocode}
+%\end{environment}
+%
+%
+%\begin{environment}{pchstack}
+% A stacking environment for vertically stacked pseudocode blocks.
+%    \begin{macrocode}
+\NewEnviron{pcvstack}[1][]{%
+%Ensure that the parameters are defaulted
+\begingroup%
+% parse args this is the same as 
+% \setkeys{pcstack}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pcvstackspace,#1}
+% expect that we expand the default args
+\@expandedsetkeys{pcstack}{}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pcvstackspace}{\@pc at vstack@defaultargs}{#1}%
+\@pc at reset@stackspace%
+\@pc at applyaboveskipinstack%
+\@pc at incstackdepth%
+\renewcommand{\@pc at stackspace@forpseudocode}{\par\vspace{\@pc at stackspace}}%
+%Store main content in a box
+\sbox{\@pc at stackcontentbox}{%
+\ifthenelse{\equal{\@pc at boxedstack}{true}}%
+{\fbox{\raisebox{\dimexpr\ht\strutbox-\height}{\begin{varwidth}[t]{2\linewidth}\BODY\end{varwidth}}}}%
+{\raisebox{\dimexpr\ht\strutbox-\height}{\begin{varwidth}[t]{2\linewidth}\BODY\end{varwidth}}}%
+\vspace{-\@pc at stackspace}}%
+% handle noindent
+\ifthenelse{\equal{\@pc at noindentstack}{true}}{\par\noindent\ignorespaces}{}%
+% display content
+\ifthenelse{\equal{\@pc at centerstack}{true}}%
+{\begin{pccenter}\usebox{\@pc at stackcontentbox}\end{pccenter}}%
+{\usebox{\@pc at stackcontentbox}}%
+% cleanup
+\@pc at decstackdepth%
+\@pc at applybelowskipinstack%
+\endgroup%reset space outside group
+\@pc at reset@stackspace%
+\@pc at stackspace@forpseudocode%
+%ignore any spaces after, to allow staying within paragraph
+\ignorespacesafterend\noindent%	
+}
+%    \end{macrocode}
+%\end{environment}
+%
+%
+%
+% \subsection{The pseudocode command}
+%
+%
+%
+% Define internal lengths used for measurements within pseudocode.
+%    \begin{macrocode}
+\newlength{\@pc at minipage@length}
+\newlength{\@pc at alt@minipage at length}
+\newlength{\@pc at length@tmp at width@vstack}
+%    \end{macrocode}
+%
+%
+% Define flags used in game based proofs.
+%    \begin{macrocode}
+\newcommand{\@withingame}{false}
+\newcommand{\@withinbxgame}{false}
+\newcommand{\@withingamedescription}{false}
+%    \end{macrocode}
+%
+%
+%\begin{macro}{\@bxgameheader}
+% Define a placeholder command which will take the current game header.
+%    \begin{macrocode}
+\newcommand{\@bxgameheader}{}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\@pc at beginnewline}
+% An internal helper that is called at the beginning of each new line.
+%    \begin{macrocode}
+\newlength\@pseudocodecodeminlineheight at len
+\newcommand{\@pc at beginnewline}{%
+\@pseudocodecodeatbeginline\@pseudocodelinenumber\@pc at and\@pcln at stephiddenlncnt%
+\setlength{\@pseudocodecodeminlineheight at len}{\@pseudocodecodeminlineheight}%
+\vphantom{\rule[0.5ex-0.5\@pseudocodecodeminlineheight at len]{0pt}{\@pseudocodecodeminlineheight at len}}%
+%checkspace
+\ifthenelse{\equal{\@pseudocodespace}{auto}}%
+{\expandafter\pcind\expandafter[\value{@pc at indentationlevel}]}%
+{}%
+%reset column counter
+\setcounter{pccolumncounter}{2}%
+%beginmode
+\@pc at modebegin}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\@pc at and@wrap at end}
+%\begin{macro}{\@pc at and@wrap at start}
+% Every pseudocode line is wrapped in between |\@pc at and@wrap at start| and
+% |\@pc at and@wrap at end|. 
+%    \begin{macrocode}
+\newcommand{\@pc at and@wrap at start}{\@pc at beginnewline}
+\newcommand{\@pc at and@wrap at end}{\@pc at modeend&\@pseudocodecodeatendline}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{\@pc at and}
+% An internal helper to store the ampersand. As this is a special character
+% this is the easiest in order to place custom alignment tags.
+%    \begin{macrocode}
+\newcommand{\@pc at and}{&}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\pcind}
+% An indentation macro to be used within pseudocode. 
+% As writing |\pcind| is a bit cumbersome, there is a shorthand that can
+% be defined via |\pcindentname| (defaults to t). See below.
+%    \begin{macrocode}
+\newlength{\@pcindentwidth}
+\providecommand{\pcind}[1][1]{%
+\setlength{\@pcindentwidth}{\widthof{\ensuremath{\quad}}*#1}%
+\ensuremath{\mathmakebox[\@pcindentwidth]{}}}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\pctabname}
+%\begin{macro}{\pcdbltabname}
+%\begin{macro}{\pcindentname}
+% Shorthands for alignment tabs and indentation. These are defined only within
+% the pseudocode scope.
+%    \begin{macrocode}
+\newcommand{\pctabname}{>}
+\newcommand{\pcdbltabname}{<}
+\newcommand{\pcindentname}{t}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+
+%
+% The following commands handle line numbering within the pseudocode command. The
+% pseudocode command itself does need to do some counter magic. We start
+% with a definition of various helper counters.
+% The H version of counters is needed to make hyperref happy
+%    \begin{macrocode}
+\newcounter{pclinenumber}
+\newcounter{Hpclinenumber} 
+\newcounter{@pclinenumber}
+\newcounter{H at pclinenumber} 
+\newcounter{@pclinenumbertmp}
+\newcounter{pcgamecounter}
+\newcounter{Hpcgamecounter}
+\newcounter{pcrlinenumber}
+\newcounter{Hpcrlinenumber}
+\newcounter{@pcrlinenumbertmp}
+%    \end{macrocode}
+%
+% The following implements some counter magic. When using automatic linenumbering
+% line numbers are nicely aligned before the first alignment tag. This, however
+% confuses hyperref and we thus have a second counter that is updated after the
+% first tag. This is done with the |\@pcln at stephiddenlncnt|
+%    \begin{macrocode}
+\renewcommand{\the at pclinenumber}{\thepclinenumber}
+\providecommand{\@pcln at stephiddenlncnt}{%
+\refstepcounter{@pclinenumber}%
+\stepcounter{H at pclinenumber}%
+}
+%    \end{macrocode}
+%
+%
+%\begin{macro}{\pclnseparator}
+%\begin{macro}{\pcrlnseparator}
+% Define separators between line numbers and code (left and right).
+% Note that line numbers can be displayed either to the left or to the right
+% of code.
+%    \begin{macrocode}
+\providecommand{\pclnseparator}{:}
+\providecommand{\pcrlnseparator}{}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{\pclnspace}
+%\begin{macro}{\pclnrspace}
+% Define spacing between line numbers and code (left and right).
+%    \begin{macrocode}
+\providecommand{\pclnspace}{1em}
+\providecommand{\pclnrspace}{0.5em}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{\pclnstyle}
+%    \begin{macrocode}
+\providecommand\pclnstyle[1]{\text{\scriptsize#1}}
+%    \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{pcln}
+% Manually place (left aligned) line numbers.
+% This command is also used by the automatic placement of line numbers.
+%    \begin{macrocode}
+\providecommand{\pcln}{%
+\ifthenelse{\equal{\@pc at skiplnmarker}{1}}{\ifmeasuring@\else\@pc at resetskipln{}\fi}{%
+\refstepcounter{pclinenumber}%
+\stepcounter{Hpclinenumber}%
+\ifthenelse{\value{pclinenumber}<10}{\hspace{1ex}}{}%
+\pclnstyle{\arabic{pclinenumber}}\pclnseparator\hspace{\pclnspace}%
+}}%
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\pcskipln}
+%\begin{macro}{\@pc at skiplnmarker}
+%\begin{macro}{skipfirstln}
+% allow to skip numbering single lines if linenumbering=on 
+%    \begin{macrocode}
+\def\@pc at skiplnmarker{}
+\providecommand{\pcskipln}{\ifmeasuring@\else\global\def\@pc at skiplnmarker{1}\fi}
+\newcommand{\@pc at resetskipln}{\global\def\@pc at skiplnmarker{}}
+\define at key{pseudocode}{skipfirstln}[1]{\global\def\@pc at skiplnmarker{1}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{\pclnr}
+%\begin{macro}{\pcrln}
+% Manual placement of right aligned line numbers using the same counter
+% (|\pclnr|) or a separate counter (|\pcrln|).
+%    \begin{macrocode}
+\providecommand{\pclnr}{%
+\refstepcounter{pclinenumber}%
+\stepcounter{Hpclinenumber}%
+\hspace{\pclnrspace}\pcrlnseparator\pclnstyle{\arabic{pclinenumber}}}
+
+\providecommand{\pcrln}{
+\refstepcounter{pcrlinenumber}%
+\stepcounter{Hpcrlinenumber}%
+\hspace{\pclnrspace}\pcrlnseparator\pclnstyle{\arabic{pcrlinenumber}}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+% 
+% \subsubsection{Options}
+%
+%
+% The following commands define a bunch of placeholders (plus their default values) 
+% that are defined via the various options of the pseudocode command.
+%    \begin{macrocode}
+\newcommand*\@pseudocodehead{}
+\newcommand*\@pseudocodewidth{}
+\newcommand*\@pseudocodexshift{0pt}
+\newcommand*\@pseudocodeyshift{0pt}
+\newcommand*\@pseudocodelinenumber{}
+\newcommand*\@pseudocodebeforeskip{0ex}
+\newcommand*\@pseudocodeafterskip{0ex}
+\newcommand*\@pseudocodelnstart{0}
+\newcommand*\@pseudocodelnstartright{0}
+\newcommand*\@pseudocodesyntaxhighlighting{}
+\newcommand*\@pseudocodenodraft{false}
+\newcommand*\@pseudocodecolspace{} % empty per default, use length,
+
+\newcommand*\@pseudocodeheadlinecmd{\hrule}
+
+%    \end{macrocode}
+
+%\begin{macro}{headlinesep}
+%\begin{macro}{\pcheadlinesep}
+%\begin{macro}{\@pseudocodeheadlinesep}
+% Distance between header and line. 
+%    \begin{macrocode}
+\newlength\pcheadlinesep
+\setlength\pcheadlinesep{0pt}
+\newcommand*\@pseudocodeheadlinesep{0em}
+\define at key{pseudocode}{headlinesep}[0em]{\renewcommand*\@pseudocodeheadlinesep{#1}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{bodylinesep}
+%\begin{macro}{\pcbodylinesep}
+%\begin{macro}{\@pseudocodebodylinesep}
+%    \begin{macrocode}
+\newlength\pcbodylinesep
+\setlength\pcbodylinesep{0.3\baselineskip}
+\newcommand*\@pseudocodebodylinesep{0em}
+\define at key{pseudocode}{bodylinesep}[0em]{\renewcommand*\@pseudocodebodylinesep{#1}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{headheight}
+%\begin{macro}{\pcheadheight}
+%\begin{macro}{\@pc at headheightskip}
+%\begin{macro}{\@pseudocodeheadheight}
+%    \begin{macrocode}
+\newlength\@pseudocodeheadheight at len
+\newcommand{\@pc at headheightskip}{%
+\setlength{\@pseudocodeheadheight at len}{\@pseudocodeheadheight}%
+\vphantom{\rule[0.5ex-0.5\@pseudocodeheadheight at len]{0pt}{\@pseudocodeheadheight at len}}%
+}
+\newlength\pcheadheight
+\setlength{\pcheadheight}{3.25ex}
+\newcommand*\@pseudocodeheadheight{\pcheadheight}
+\define at key{pseudocode}{headheight}[0em]{\renewcommand*\@pseudocodeheadheight{#1}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+
+
+%
+%    \begin{macrocode}
+
+\newcommand*\@pseudocodecolsep{0em}
+\newcommand*\@pseudocodeaddtolength{2pt}
+
+\newcommand*\@pseudocodecodeatbeginline{}
+\newcommand*\@pseudocodecodeatendline{}
+\newcommand*\@pseudocodecodejot{0em}
+\newcommand*\@pseudocodecodesize{\small}
+\newcommand*\@pseudocodesubcodesize{\footnotesize}
+
+\newcommand*\@pseudocodeminipagealign{t}
+
+%
+% Define keywords for the automatic syntax highlighting
+% the accompanying add provides additional keywords.
+% The space version for automatic spacing
+\newcommand*\@pseudocodekeywordsindent{for ,foreach ,if ,repeat ,while }
+\newcommand*\@pseudocodekeywordsunindent{endfor,endforeach,fi,endif,until,endwhile}
+\newcommand*\@pseudocodekeywordsuninindent{else if ,elseif ,else }
+\newcommand*\@pseudocodekeywords{for,foreach,{return },return,{ do },{ in },new,if, null, true,{until },{ to }, false,{ then},repeat,else if,elseif,while,else,done}
+\newcommand*\@pseudocodeaddkeywords{}
+\newcommand*\@pseudocodealtkeywords{}
+\begin{@pc at withspaces}
+\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}
+\end{@pc at withspaces}
+%    \end{macrocode}
+%
+%
+% Specification of the various options of the |\pseudocode| command.
+%    \begin{macrocode}
+\define at key{pseudocode}{beginline}[]{\renewcommand*\@pseudocodecodeatbeginline{#1}}
+\define at key{pseudocode}{endline}[]{\renewcommand*\@pseudocodecodeatendline{#1}}
+\define at key{pseudocode}{jot}[0em]{\renewcommand*\@pseudocodecodejot{#1}}
+\define at key{pseudocode}{codesize}[\small]{\renewcommand*\@pseudocodecodesize{#1}}
+\define at key{pseudocode}{subcodesize}[\small]{\renewcommand*\@pseudocodesubcodesize{#1}}
+\define at key{pseudocode}{head}[]{\renewcommand*\@pseudocodehead{#1}}
+\define at key{pseudocode}{width}[]{\renewcommand*\@pseudocodewidth{#1}}
+\define at key{pseudocode}{valign}[t]{\renewcommand*\@pseudocodeminipagealign{#1}}
+\define at key{pseudocode}{xshift}[]{\renewcommand*\@pseudocodexshift{#1}}
+\define at key{pseudocode}{yshift}[]{\renewcommand*\@pseudocodeyshift{#1}}
+\define at key{pseudocode}{colspace}[]{\renewcommand*\@pseudocodecolspace{#1}}
+\define at key{pseudocode}{linenumbering}[on]{\ifthenelse{\equal{#1}{on}}{\renewcommand*\@pseudocodelinenumber{\pcln}}{\renewcommand*\@pseudocodelinenumber{}}}
+\define at key{pseudocode}{beforeskip}[]{\renewcommand*\@pseudocodebeforeskip{#1}}
+\define at key{pseudocode}{afterskip}[]{\renewcommand*\@pseudocodeafterskip{#1}}
+\define at key{pseudocode}{lnstart}[0]{\renewcommand*\@pseudocodelnstart{#1}}
+\define at key{pseudocode}{lnstartright}[0]{\renewcommand*\@pseudocodelnstartright{#1}}
+\define at key{pseudocode}{colsep}[0em]{\renewcommand*\@pseudocodecolsep{#1}}
+\define at key{pseudocode}{headlinecmd}[\hrule]{\renewcommand*\@pseudocodeheadlinecmd{#1}}
+\define at key{pseudocode}{addtolength}[2pt]{\renewcommand*\@pseudocodeaddtolength{#1}}
+\define at key{pseudocode}{nodraft}[true]{\renewcommand*\@pseudocodenodraft{#1}}
+\define at key{pseudocode}{keywords}[]{\renewcommand*\@pseudocodekeywords{#1}}
+\define at key{pseudocode}{keywordsindent}[]{\renewcommand*\@pseudocodekeywordsindent{#1}}
+\define at key{pseudocode}{keywordsunindent}[]{\renewcommand*\@pseudocodekeywordsunindent{#1}}
+\define at key{pseudocode}{keywordsuninindent}[]{\renewcommand*\@pseudocodekeywordsuninindent{#1}}
+\define at key{pseudocode}{addkeywords}[]{\renewcommand*\@pseudocodeaddkeywords{#1}}
+\define at key{pseudocode}{altkeywords}[]{\renewcommand*\@pseudocodealtkeywords{#1}}
+\define at key{pseudocode}{syntaxhighlight}[]{\renewcommand*\@pseudocodesyntaxhighlighting{#1}}
+%    \end{macrocode}
+%
+%
+%
+%\begin{macro}{mode}
+% The \oarg{mode} key (with values \meta{text} or \meta{math} (default)) specifies
+% whether within a pseudocode block input is by default typeset in text mode or in
+% math mode.
+% The |\@pc...| variables are variables that help typesetting each line in a pseudocode block. 
+%    \begin{macrocode}
+\newcommand{\@pc at modebegin}{}
+\newcommand{\@pc at modeend}{}
+\define at key{pseudocode}{mode}[math]{%
+\ifthenelse{\equal{#1}{text}}{%
+\renewcommand*\@pc at modebegin{\begin{varwidth}{\textwidth}%
+%introduce line magic for text mode
+\let\@pc at lb\\%
+\renewcommandx*{\\}[2][1=,2=]{\@pc at modeend\@pc at and \@pseudocodecodeatendline\ifthenelse{\equal{####1}{}}{\@pc at lb}{\@pc at lb[####1]}####2 \@pc at beginnewline}%
+\def\pclb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+\def\pcolb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+}%
+\renewcommand*\@pc at modeend{\end{varwidth}}%
+}{\renewcommand{\@pc at modebegin}{}\renewcommand{\@pc at modeend}{}}}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{minlineheight}
+%\begin{macro}{\pcminlineheight}
+%\begin{macro}{\@pseudocodecodeminlineheight}
+% Control the minimal line height of pseudocode blocks.
+%    \begin{macrocode}
+\providecommand{\pcminlineheight}{0pt}
+\newcommand*\@pseudocodecodeminlineheight{\pcminlineheight}
+\define at key{pseudocode}{minlineheight}[0pt]{\renewcommand*\@pseudocodecodeminlineheight{#1}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%
+% \subsubsection{Automatic Syntax Highlighting and Spacing (Experimental)}
+%
+%
+%
+%
+% Experimental LaTex3 string substitution helpers for automatic keyword
+% highlighting. The regex parsing is (regrettably) super slow.
+%    \begin{macrocode}
+\ExplSyntaxOn
+\tl_new:N \l_pc_strsub_input_tl
+\tl_new:N \l_pc_strsub_search_tl
+\tl_new:N \l_pc_strsub_replace_tl
+
+\NewDocumentCommand{\@pc at stringsubstitution}{mmm}
+ {
+  \tl_set:Nn \l_pc_strsub_input_tl { #1 }
+  \tl_set:Nn \l_pc_strsub_search_tl { #2 }
+  \tl_set:Nn \l_pc_strsub_replace_tl { #3 }
+ %  \tl_show_analysis:N  \l_pc_strsub_input_tl % uncomment for debugging
+ %  \tl_show_analysis:N  \l_pc_strsub_search_tl % uncomment for debugging
+ %  \tl_show_analysis:N  \l_pc_strsub_replace_tl % uncomment for debugging
+   \regex_replace_all:nnN
+      { \u{l_pc_strsub_search_tl} } %only match if keyword does not have a word character preceding
+      { \u{l_pc_strsub_replace_tl} }
+      \l_pc_strsub_input_tl
+       %  \tl_show_analysis:N \l_tmpa_tl % uncomment for debugging
+      \tl_use:N \l_pc_strsub_input_tl    
+ }  
+\ExplSyntaxOff
+%    \end{macrocode}
+%
+%
+%
+%\begin{macro}{\@pc at syntaxhighlight}
+%\begin{macro}{\@pc at highlight}
+%\begin{macro}{\@pc at highlightindent}
+%\begin{macro}{\@pc at highlightunindent}
+%\begin{macro}{\@pc at highlightuninindent}
+%\begin{macro}{\@pc at althighlight}
+% This is the core of the (experimental) automatic syntax highlighting and
+% automatic spacing. The code is ugly, and very slow. 
+% It is not really recommended to be used in larger projects.
+%    \begin{macrocode}
+\newcommand{\@pc at syntaxhighlight}[1]{%
+%don't highlight during measuring runs for performance improvements.
+\ifmeasuring@#1\else%
+\ifthenelse{\equal{\@pseudocodesyntaxhighlighting}{auto}}{%
+\def\@shtmp{#1}% first step
+% Depending on space mode, we might later run the indent/unindent/... lists
+% if not, we add them now to tmp lists in order to have a complete list.
+\ifthenelse{\equal{\@pseudocodespace}{keep}}
+   {\edef\@tmpkeywords{\@pseudocodekeywordsspace,\@pseudocodeaddkeywords}}
+   {\ifthenelse{\equal{\@pseudocodespace}{auto}}
+      {\edef\@tmpkeywords{\@pseudocodekeywords,\@pseudocodeaddkeywords}}
+      {\edef\@tmpkeywords{\@pseudocodekeywords,\@pseudocodekeywordsindent,\@pseudocodekeywordsunindent,\@pseudocodekeywordsuninindent,\@pseudocodeaddkeywords}}}
+\foreach \@pckw in \@tmpkeywords{%
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlight\expandafter{\@pckw}}}%
+}}% alt keywords
+\foreach \@pckw in \@pseudocodealtkeywords{%
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at althighlight\expandafter{\@pckw}}}%
+}}%
+% if automatic spacing
+\ifthenelse{\equal{\@pseudocodespace}{auto}}
+{%
+\foreach \@pckw in \@pseudocodekeywordsindent{% indentation keywords
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightindent\expandafter{\@pckw}}}%
+}}%
+\foreach \@pckw in \@pseudocodekeywordsunindent{% unindentation keywords
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightunindent\expandafter{\@pckw}}}%
+}}%
+\foreach \@pckw in \@pseudocodekeywordsuninindent{% uninindentation keywords
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightuninindent\expandafter{\@pckw}}}%
+}}%
+}{}%
+% return result
+\@shtmp%
+}{#1}% nothing to highlight
+\fi}
+
+\newcommand{\@pc at highlight}[1]{%
+\ifthenelse{\equal{\@pseudocodespace}{keep}}
+    {\highlightkeyword[]{#1}}%
+    {\highlightkeyword[]{\@pc at stringsubstitution{#1}{ }{~}}}%
+}
+
+\newcommand{\@pc at highlightindent}[1]{%
+\@pc at increaseindent\@pc at highlight{#1}%
+}
+
+\newcommand{\@pc at highlightunindent}[1]{%
+\@pc at decreaseindent\@pc at highlight{#1}%
+}
+
+\newcommand{\@pc at highlightuninindent}[1]{%
+\@pc at tmpdecreaseindent\@pc at highlight{#1}%
+}
+
+\newcommand{\@pc at althighlight}[1]{%
+\ifthenelse{\equal{\@pseudocodespace}{keep}}
+    {\highlightaltkeyword{#1}}%
+    {\highlightaltkeyword{\@pc at stringsubstitution{#1}{ }{~}}}%
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+% \subsubsection{Helper Variables}
+%
+%\begin{macro}{\@pc at thecontent}
+%\begin{macro}{\@pc at colspace}
+% Helper variables used within pseudocode
+%    \begin{macrocode}
+\newcommand{\@pc at thecontent}{}
+\newcommand{\@pc at colspace}{}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%
+%\begin{macro}{\@withinspaces}
+%\begin{macro}{\@keepspaces}
+% Helper variables for controlling automatic spacing
+%    \begin{macrocode}
+\newcommand{\@withinspaces}{false}%
+\newcommand{\@keepspaces}{%
+\renewcommand{\@withinspaces}{true}\@pc at withspaces%
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%    \begin{macrocode}
+\newcommand*\@pseudocodespace{}
+\define at key{pcspace}{space}[]{\ifthenelse{\equal{#1}{keep}}{\@keepspaces}{}\renewcommand*\@pseudocodespace{#1}}
+
+
+\newcommand*\@pc at defaultargs{}
+\newcommand*\pcsetargs[1]{\renewcommand*\@pc at defaultargs{#1}}
+
+% automatic indentation
+\newcounter{@pc at indentationlevel}
+\newcommand{\@pc at increaseindent}{\addtocounter{@pc at indentationlevel}{1}}
+\newcommand{\@pc at decreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}\addtocounter{@pc at indentationlevel}{-1}}
+\newcommand{\@pc at tmpdecreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}}
+
+\newcounter{pccolumncounter}
+\setcounter{pccolumncounter}{2}
+
+% store original halign
+\let\@pc at halign\halign%
+%    \end{macrocode}
+%
+% \subsubsection{The Actual Pseudocode Command}
+%
+%    \begin{macrocode}
+% Check if the pseudocode command is called with an optional argument
+\providecommand{\pseudocode}{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+\@ifnextchar[%]
+  {\@pseudocodeA}%
+  {\@pseudocode[]}%
+}
+
+\def\@pseudocodeA[#1]{%
+\setkeys*{pcspace}{#1}%test if there is a space assignment within the keys .. make the necessary arrangements and call the actual method
+\@pseudocode[#1]%
+}
+
+\def\@pseudocode[#1]#2{%
+\begingroup%
+% reset skip marker before parsing options, as this might set it
+\@pc at resetskipln%
+% parse options
+% this is the same as %\setkeys{pseudocode}[space]{\@pc at defaultargs,#1}%ignore the space key.
+% expect that we expand the default args
+\@expandedsetkeys{pseudocode}{space}{head=}{\@pc at defaultargs}{#1}%
+% check draft mode and disable syntax highlighting
+\@pc at ifdraft{\ifthenelse{\equal{\@pseudocodenodraft}{true}}{}{\renewcommand\@pseudocodesyntaxhighlighting{}}}{}%
+%
+%
+\addtocounter{@pc at global@pc at nestcnt}{1}%
+% allow for tikz usage
+\@pc at ensureremember%
+%
+% create tabbing command
+\ifcsname \pctabname\endcsname%
+\expandafter\renewcommand\csname \pctabname\endcsname{\@pc at modeend&\@pc at colspace\@pc at modebegin}%
+\else%
+\expandafter\newcommand\csname \pctabname\endcsname{\@pc at modeend&\@pc at colspace\@pc at modebegin}%
+\fi%
+\ifcsname \pcdbltabname\endcsname%
+\expandafter\renewcommand\csname \pcdbltabname\endcsname{\@pc at modeend&&\@pc at colspace\@pc at modebegin}%
+\else%
+\expandafter\newcommand\csname \pcdbltabname\endcsname{\@pc at modeend&&\@pc at colspace\@pc at modebegin}%
+\fi%
+% create colspace command if necessary (must be empty for multicolumns
+\ifthenelse{\equal{\@pseudocodecolspace}{}}
+ {}
+ {\renewcommand{\@pc at colspace}{\hspace{\@pseudocodecolspace}}}%
+%
+%adjust row width
+\addtolength{\jot}{\@pseudocodecodejot}%
+% create indent command
+\expandafter\let\csname \pcindentname\endcsname\pcind%
+%
+%store and wrap (do syntax highlighting) argument 
+\renewcommand{\@pc at thecontent}{\@pc at and@wrap at start\@pc at syntaxhighlight{#2}\@pc at and@wrap at end}%
+%
+%take care of counters
+\stepcounter{@pc at global@pc at cnt}%
+\setcounter{pclinenumber}{\@pseudocodelnstart}%
+\setcounter{pcrlinenumber}{\@pseudocodelnstartright}%
+\setlength{\@pc at minipage@length}{0pt}%
+\setlength{\@pc at alt@minipage at length}{0pt}%
+\setcounter{@pclinenumbertmp}{\value{pclinenumber}}%
+\setcounter{@pcrlinenumbertmp}{\value{pcrlinenumber}}%
+%reset column counter
+\setcounter{pccolumncounter}{2}%
+%
+% vertical space
+\vspace{\@pseudocodeyshift}%
+%
+%
+%
+% line magic
+\ifthenelse{\value{@pc at global@pc at nestcnt}=1}{%
+\let\@pc at halign\halign%
+\newenvironment{pcmbox}{\let\halign\@pc at halign}{}%
+\def\halign{%
+\renewcommand{\label}[1]{\ifmeasuring@\else\@pc at original@label{####1}\fi}%
+\let\@pc at lb\\%
+\renewcommandx*{\\}[2][1=,2=]{\@pc at modeend\@pc at and\@pseudocodecodeatendline \ifthenelse{\equal{####1}{}}{\@pc at lb}{\@pc at lb[####1]}####2 \@pc at beginnewline}%
+\def\pclb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+\@pc at halign}%
+}{}%
+%
+%align column separation
+\renewcommand*{\minalignsep}{\@pseudocodecolsep}%
+%
+%as the following block will execute the pseudocode we need to store the skip command
+\edef\@pc at org@skiplnmarker{\@pc at skiplnmarker}%
+% if no width is set compute width and store in circuitlength
+\ifthenelse{\equal{\@pseudocodewidth}{}}{%
+% compute length of pseudocode
+\ifthenelse{\value{@pcsubprogstep}=0}{%
+\@pc at settowidthofalign{\@pc at minipage@length}{\@pc at thecontent}%
+}{%
+\@pc at settowidthofaligned{\@pc at minipage@length}{\@pc at thecontent}%	
+}%
+%compute length of header
+\ifthenelse{\equal{\@withingame}{true}}%
+{\ifthenelse{\equal{\@pc at secondheader}{true}}%
+  {\addtolength{\@pc at alt@minipage at length}{\widthof{x\ensuremath{\@pc at gametitle[1]\@pc at gametitle[1]}}}}
+  {\addtolength{\@pc at alt@minipage at length}{\widthof{\ensuremath{\@pc at gametitle[1]}}}}}%
+{\addtolength{\@pc at alt@minipage at length}{\widthof{\@pseudocodehead}}}%
+% use header length if longer and add some points for good measure
+\ifdim\@pc at alt@minipage at length>\@pc at minipage@length%
+\setlength{\@pc at minipage@length}{\@pc at alt@minipage at length}%
+\fi%
+\addtolength{\@pc at minipage@length}{\@pseudocodeaddtolength}%
+}{\addtolength{\@pc at minipage@length}{\@pseudocodewidth}}%
+% reset counter and skip command
+\setcounter{pclinenumber}{\value{@pclinenumbertmp}}%
+\setcounter{pcrlinenumber}{\value{@pcrlinenumbertmp}}%
+\setcounter{@pc at indentationlevel}{0}%
+\edef\@pc at skiplnmarker{\@pc at org@skiplnmarker}%
+% begin actual output
+%
+%
+%do the actual mini page
+\hspace{\pcbeforeskip}\hspace{\@pseudocodexshift}%
+\ifthenelse{\equal{\@pseudocodeminipagealign}{t}}{%
+\raisebox{\dimexpr\ht\strutbox-\height}{\@pc at pseudocodeminipage{t}}%
+}{%
+\@pc at pseudocodeminipage{\@pseudocodeminipagealign}%
+}%
+\hspace{\pcafterskip}%
+% tikz usage
+\@pc at releaseremember%
+\addtocounter{@pc at global@pc at nestcnt}{-1}%
+\endgroup%
+% close spacing and potentially a single group generated by the space tester
+\ifthenelse{\equal{\@withinspaces}{true}}{\end at pc@withspaces}{}%
+\endgroup%
+%insert space from stacking
+\@pc at stackspace@forpseudocode%
+}
+
+\newcommand{\@pc at pseudocodeminipage}[1]{%
+\begin{minipage}[#1]{\@pc at minipage@length}%
+\ifthenelse{\value{@pcsubprogstep}=0}{%
+\pc at display@pseudocode{\@pseudocodehead}{\@pc at thecontent}%
+}{% if sub procedure
+\pc at display@subcode{\@pseudocodehead}{\@pc at thecontent}%
+}%
+\end{minipage}%
+}
+
+
+\newcommand{\@pc at display@gameheader}[1]{%
+\tikz{\gdef\i{\thepcgamecounter}%
+\node[anchor=base,text depth=0pt, inner sep=0.05em,outer sep=0pt] (gamenode\i) {#1}; 
+\ifthenelse{\equal{\@withinbxgame}{true}}
+  {\node[draw,anchor=base, above=2ex of gamenode\i] (bgamenode\i) {\@bxgameheader};}
+  {}%
+}%
+}
+
+\let\pclb\relax
+%
+\newcommand{\pc at display@pseudocode}[2]{%
+\ifthenelse{\equal{#1}{}}{\vspace{-\baselineskip}\@pseudocodecodesize{}}{%
+\ifthenelse{\equal{\@withingame}{true}}
+	{\ifthenelse{\equal{\@pc at secondheader}{true}}
+ {\@pc at display@gameheader{#1}\addtocounter{pcgamecounter}{1}\fboxsep=1pt\fbox{\vphantom{#1}\@pc at display@gameheader{#1}}}
+ {\@pc at display@gameheader{#1}}}
+	{#1}%
+\@pc at headheightskip\vspace{\pcheadlinesep}\vspace{\@pseudocodeheadlinesep}\@pseudocodeheadlinecmd%
+\vspace{-\baselineskip}\vspace{\pcbodylinesep}\vspace{\@pseudocodebodylinesep}\@pseudocodecodesize}%
+\begin{flalign*}#2\end{flalign*}%
+}
+
+
+\newcommand{\pc at display@subcode}[2]{%
+\begingroup%
+\ifthenelse{\equal{#1}{}}{}{#1\@pc at headheightskip%
+\vspace{\pcheadlinesep}\vspace{\@pseudocodeheadlinesep}\@pseudocodeheadlinecmd{}%
+\vspace{\pcbodylinesep}\vspace{\@pseudocodebodylinesep}}%
+\@pseudocodesubcodesize%
+$\begin{aligned}#2\end{aligned}$%
+\endgroup%
+}
+
+
+\newcommand{\@pc at gettikzwidth}[2]{ % #1 = width, #2 = height
+ \pgfextractx{\@tempdima}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
+ {\pgfpointanchor{current bounding box}{north east}}}
+ \global#1=\@tempdima
+ \pgfextracty{\@tempdima}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
+ {\pgfpointanchor{current bounding box}{north east}}}
+ \global#2=\@tempdima
+}
+
+
+%    \end{macrocode}
+%
+% \subsection{Create Pseudocode/Procedure Commands}
+%
+%    \begin{macrocode}
+%
+% parameter reordering
+\def\@pseudocodeB#1#2[#3]#4{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1#4},#2,#3]}
+\def\@pseudocodeC#1#2#3{\setkeys*{pcspace}{#2}\@pseudocode[head={#1#3},#2]}
+%for no headers
+\def\@pseudocodeE#1#2[#3]{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1},#2,#3]}
+\def\@pseudocodeF#1#2{\setkeys*{pcspace}{#2}\@pseudocode[head={#1},#2]}
+%
+%    \end{macrocode}
+%
+%\begin{macro}{\createprocedurecommand}
+% Define pseudocode command with parameters: 
+% \begin{enumerate}
+% \item name
+% \item code to execute after begingroup
+% \item head prefix
+% \item other config
+% \end{enumerate}
+%    \begin{macrocode}
+\newcommand*{\@pc at createproc@headmode}{text}
+\newcommand{\createprocedurecommand}[4]{
+	\expandafter\gdef\csname #1\endcsname{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+#2%
+\@ifnextchar[%]
+  {\@pseudocodeB{#3}{#4}}
+  {\@pseudocodeC{#3}{#4}}%
+}%
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\createpseudocodecommand}
+%    \begin{macrocode}
+\newcommand{\createpseudocodecommand}[4]{
+	\expandafter\gdef\csname #1\endcsname{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+#2%
+\@ifnextchar[%]
+  {\@pseudocodeE{#3}{#4}}
+  {\@pseudocodeF{#3}{#4}}%
+}%
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%
+%
+%\begin{macro}{\createpseudocodeblock}
+% Creates a command that has pseudocode wrapped in an |\pchstack|.
+% \item name
+% \item options for |\pchstack|
+% \item code to execute after begingroup
+% \item head prefix
+% \item other config
+%    \begin{macrocode}
+\newcommand{\createpseudocodeblock}[5]{
+\createpseudocodecommand{#1 at pc}{#3}{#4}{#5}
+\expandafter\gdef\csname #1\endcsname{%
+\@ifnextchar[%]
+  {\csname #1@@\endcsname}
+  {\csname #1@\endcsname}
+}%
+\expandafter\gdef\csname #1@\endcsname##1{%
+\begin{pchstack}[#2]
+\csname #1 at pc\endcsname{##1}
+\end{pchstack}
+}
+\expandafter\gdef\csname #1@@\endcsname[##1]##2{%
+\begin{pchstack}[#2]
+\csname #1 at pc\endcsname[##1]{##2}
+\end{pchstack}
+}
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\createprocedureblock}
+% Creates a command that has procedure wrapped in an |\pchstack|.
+% \item name
+% \item options for |\pchstack|
+% \item code to execute after begingroup
+% \item head prefix
+% \item other config
+%    \begin{macrocode}
+\newcommand{\createprocedureblock}[5]{
+\createprocedurecommand{#1 at pc}{#3}{#4}{#5}
+\expandafter\gdef\csname #1\endcsname{%
+\@ifnextchar[%]
+	{\csname #1@@\endcsname}
+	{\csname #1@\endcsname}
+}%
+\expandafter\gdef\csname #1@\endcsname##1##2{%
+\begin{pchstack}[#2]
+\csname #1 at pc\endcsname{##1}{##2}
+\end{pchstack}
+}
+\expandafter\gdef\csname #1@@\endcsname[##1]##2##3{%
+\begin{pchstack}[#2]
+\csname #1 at pc\endcsname[##1]{##2}{##3}
+\end{pchstack}
+}
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\procedure}
+%\begin{macro}{\pseudocodeblock}
+%\begin{macro}{\procedureblock}
+% Create |\procedure| command.
+%    \begin{macrocode}
+\createprocedurecommand{procedure}{}{}{}
+\createpseudocodeblock{pseudocodeblock}{center}{}{}{}
+\createprocedureblock{procedureblock}{center}{}{}{}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+% \subsection{Subprocedures}
+%
+%    \begin{macrocode}
+
+%
+% subprocedures
+\newcounter{@pcsubprogcnt1}
+\newcounter{@pcrsubprogcnt1}
+\newcounter{@pcsubprogcnt2}
+\newcounter{@pcrsubprogcnt2}
+\newcounter{@pcsubprogcnt3}
+\newcounter{@pcrsubprogcnt3}
+\newcounter{@pcsubprogcnt4}
+\newcounter{@pcrsubprogcnt4}
+\newcounter{@pcsubprogcnt5}
+\newcounter{@pcrsubprogcnt5}
+\newcounter{@pcsubprogcnt6}
+\newcounter{@pcrsubprogcnt6}
+\newcounter{@pcsubprogcnt7}
+\newcounter{@pcrsubprogcnt7}
+\newcounter{@pcsubprogcnt8}
+\newcounter{@pcrsubprogcnt8}
+\newcounter{@pcsubprogcnt9}
+\newcounter{@pcrsubprogcnt9}
+\newcounter{@pcsubprogstep}
+
+\newenvironment{subprocedure}{%
+\addtocounter{@pcsubprogstep}{1}%
+% store old counter values
+\setcounter{@pcsubprogcnt\the at pcsubprogstep}{\value{pclinenumber}}%
+\setcounter{@pcrsubprogcnt\the at pcsubprogstep}{\value{pcrlinenumber}}%
+}{%
+\setcounter{pclinenumber}{\value{@pcsubprogcnt\the at pcsubprogstep}}%
+\setcounter{pcrlinenumber}{\value{@pcrsubprogcnt\the at pcsubprogstep}}%
+\addtocounter{@pcsubprogstep}{-1}}
+
+
+%    \end{macrocode}
+%
+% \subsection{Protocols}
+%
+%    \begin{macrocode}
+
+%
+% send message
+\newcommand{\pcshortmessageoffset}{0.5cm}
+\newcommand{\pcdefaultmessagelength}{3.5cm}
+\newcommand{\pcdefaultlongmessagelength}{6cm}
+\newcommand{\pcbeforemessageskip}{0pt}
+\newcommand{\pcaftermessageskip}{10pt}
+\newlength{\pcmessagearrow}
+
+\newcommand*\@pcsendmessagelength{\pcdefaultmessagelength}
+\newcommand*\@pcsendmessagecol{}
+\newcommand*\@pcsendmessagewidth{}
+\newcommand*\@pcsendmessagestyle{}
+\newcommand*\@pcsendmessagetop{}
+\newcommand*\@pcsendmessagebottom{}
+\newcommand*\@pcsendmessageright{}
+\newcommand*\@pcsendmessageleft{}
+\newcommand*\@pcsendmessagetopname{t}
+\newcommand*\@pcsendmessagebottomname{b}
+\newcommand*\@pcsendmessagerightname{r}
+\newcommand*\@pcsendmessageleftname{l}
+\newcommand*\@pcsendmessagetopstyle{}
+\newcommand*\@pcsendmessagebottomstyle{}
+\newcommand*\@pcsendmessagerightstyle{}
+\newcommand*\@pcsendmessageleftstyle{}
+\newcommand*\@pcsendmessagebeforeskip{\pcbeforemessageskip}
+\newcommand*\@pcsendmessageafterskip{\pcaftermessageskip}
+
+\define at key{pcsendmessage}{centercol}[]{\renewcommand*\@pcsendmessagecol{#1}}
+\define at key{pcsendmessage}{width}[]{\renewcommand*\@pcsendmessagewidth{#1}}
+\define at key{pcsendmessage}{style}[]{\renewcommand*\@pcsendmessagestyle{#1}}
+\define at key{pcsendmessage}{length}[]{\renewcommand*\@pcsendmessagelength{#1}}
+\define at key{pcsendmessage}{top}[]{\renewcommand*\@pcsendmessagetop{#1}}
+\define at key{pcsendmessage}{bottom}[]{\renewcommand*\@pcsendmessagebottom{#1}}
+\define at key{pcsendmessage}{right}[]{\renewcommand*\@pcsendmessageright{#1}}
+\define at key{pcsendmessage}{left}[]{\renewcommand*\@pcsendmessageleft{#1}}
+\define at key{pcsendmessage}{topname}[]{\renewcommand*\@pcsendmessagetopname{#1}}
+\define at key{pcsendmessage}{bottomname}[]{\renewcommand*\@pcsendmessagebottomname{#1}}
+\define at key{pcsendmessage}{rightname}[]{\renewcommand*\@pcsendmessagerightname{#1}}
+\define at key{pcsendmessage}{leftname}[]{\renewcommand*\@pcsendmessageleftname{#1}}
+\define at key{pcsendmessage}{topstyle}[]{\renewcommand*\@pcsendmessagetopstyle{#1}}
+\define at key{pcsendmessage}{bottomstyle}[]{\renewcommand*\@pcsendmessagebottomstyle{#1}}
+\define at key{pcsendmessage}{rightstyle}[]{\renewcommand*\@pcsendmessagerightstyle{#1}}
+\define at key{pcsendmessage}{leftstyle}[]{\renewcommand*\@pcsendmessageleftstyle{#1}}
+\define at key{pcsendmessage}{beforeskip}[]{\renewcommand*\@pcsendmessagebeforeskip{#1}}
+\define at key{pcsendmessage}{afterskip}[]{\renewcommand*\@pcsendmessageafterskip{#1}}
+
+\newcommand*\@pcsendmessagealignedtop{false}
+\define at key{pcsendmessage}{topaligned}[true]{\renewcommand*\@pcsendmessagealignedtop{#1}}
+\newcommand*\@pcsendmessagealignedbottom{false}
+\define at key{pcsendmessage}{bottomaligned}[true]{\renewcommand*\@pcsendmessagealignedbottom{#1}}
+\newcommand*\@pcsendmessagealignedleft{false}
+\define at key{pcsendmessage}{leftaligned}[true]{\renewcommand*\@pcsendmessagealignedleft{#1}}
+\newcommand*\@pcsendmessagealignedright{false}
+\define at key{pcsendmessage}{rightaligned}[true]{\renewcommand*\@pcsendmessagealignedright{#1}}
+
+
+\newcommand{\@pc at centerincol}[2]{%
+\ifmeasuring@%
+#2%
+\else%
+\makebox[\ifcase\expandafter #1\maxcolumn at widths\fi]{$\displaystyle#2$}%
+\fi%
+}
+
+\newcommand{\centerincol}[1]{\@pc at centerincol{\thepccolumncounter}{#1}}
+
+\newcommand{\@do at sendmessage}[1]{%
+\ifthenelse{\equal{\@pcsendmessagecol}{}}{%
+\ifthenelse{\equal{\@pcsendmessagewidth}{}}{#1}{% we have some width
+\makebox[\@pcsendmessagewidth]{$\displaystyle#1$}%
+}}{%we know the column to center on
+\@pc at centerincol{\@pcsendmessagecol}{#1}%
+}%
+}
+
+\newcommand*{\sendmessage}[2]{%
+\begingroup\setkeys{pcsendmessage}{#2}%
+\tikzset{PCSENDMSG-PATH-STYLE/.style/.expand once=\@pcsendmessagestyle}%
+\tikzset{PCSENDMSG-TOP-STYLE/.style/.expand once=\@pcsendmessagetopstyle}%
+\tikzset{PCSENDMSG-BOTTOM-STYLE/.style/.expand once=\@pcsendmessagebottomstyle}%
+\tikzset{PCSENDMSG-LEFT-STYLE/.style/.expand once=\@pcsendmessageleftstyle}%
+\tikzset{PCSENDMSG-RIGHT-STYLE/.style/.expand once=\@pcsendmessagerightstyle}%
+%
+%
+\ifthenelse{\equal{\@pcsendmessagealignedtop}{true}}
+{\ifthenelse{\equal{\@pcsendmessagetop}{}}
+	{\let\@pc at fin@sendmessagetop\@pcsendmessagetop}%
+	{\newcommand{\@pc at fin@sendmessagetop}{\let\halign\@pc at halign$\begin{aligned}\@pcsendmessagetop\end{aligned}$}}}
+	{\let\@pc at fin@sendmessagetop\@pcsendmessagetop}%
+%
+\ifthenelse{\equal{\@pcsendmessagealignedbottom}{true}}
+{\ifthenelse{\equal{\@pcsendmessagebottom}{}}
+	{\let\@pc at fin@sendmessagebottom\@pcsendmessagebottom}%
+	{\newcommand{\@pc at fin@sendmessagebottom}{\let\halign\@pc at halign$\begin{aligned}\@pcsendmessagebottom\end{aligned}$}}}
+	{\let\@pc at fin@sendmessagebottom\@pcsendmessagebottom}%
+%
+\ifthenelse{\equal{\@pcsendmessagealignedright}{true}}
+{\ifthenelse{\equal{\@pcsendmessageright}{}}
+	{\let\@pc at fin@sendmessageright\@pcsendmessageright}
+	{\newcommand{\@pc at finsendmessageright}{\let\halign\@pc at halign$\begin{aligned}\@pcsendmessageright\end{aligned}$}}}
+	{\let\@pc at fin@sendmessageright\@pcsendmessageright}%
+%
+\ifthenelse{\equal{\@pcsendmessagealignedleft}{true}}
+{\ifthenelse{\equal{\@pcsendmessageleft}{}}
+	{\let\@pc at fin@sendmessageleft\@pcsendmessageleft}
+	{\newcommand{\@pc at fin@sendmessageleft}{\let\halign\@pc at halign$\begin{aligned}\@pcsendmessageleft\end{aligned}$}}}
+	{\let\@pc at fin@sendmessageleft\@pcsendmessageleft}%
+%restore halign
+%
+\addtocounter{@pcsubprogstep}{1}%
+\hspace{\@pcsendmessagebeforeskip}%
+\begin{varwidth}{\linewidth}
+\@do at sendmessage{
+	\begin{tikzpicture}%
+	 \node[PCSENDMSG-LEFT-STYLE] (\@pcsendmessageleftname) {\@pc at fin@sendmessageleft};
+	 \node[right=\@pcsendmessagelength of \@pcsendmessageleftname,PCSENDMSG-RIGHT-STYLE] (\@pcsendmessagerightname) {\@pc at fin@sendmessageright};
+	 \path[#1,PCSENDMSG-PATH-STYLE] (\@pcsendmessageleftname) edge[] node[above,PCSENDMSG-TOP-STYLE] (\@pcsendmessagetopname) {\@pc at fin@sendmessagetop} node[below,PCSENDMSG-BOTTOM-STYLE] (\@pcsendmessagebottomname) {\@pc at fin@sendmessagebottom} (\@pcsendmessagerightname); 
+	\end{tikzpicture}%
+}%
+\end{varwidth}
+\addtocounter{@pcsubprogstep}{-1}%
+\hspace{\@pcsendmessageafterskip}%
+\endgroup%
+}
+
+\WithSuffix\newcommand\sendmessage*[2]{%
+\sendmessage{#1}{topaligned,leftaligned,bottomaligned,rightaligned,#2}%
+}
+
+\newcommandx*{\sendmessageright}[2][1=->]{%
+\sendmessage{#1}{#2}%
+}
+
+\newcommandx*{\sendmessageleft}[2][1=<-]{%
+\sendmessage{#1}{#2}%
+}
+
+\WithSuffix\newcommand\sendmessageleft*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{<-}{length=#1}%
+\endgroup%
+}
+
+
+\WithSuffix\newcommand\sendmessageright*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{->}{length=#1}%
+\endgroup%
+}
+
+\WithSuffix\newcommand\sendmessagerightleft*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{<->}{length=#1}%
+\endgroup%
+}
+
+\DeclareExpandableDocumentCommand{\sendmessagerightx}{O{\pcdefaultlongmessagelength}mO{}m}{%
+\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xrightarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
+}
+
+\DeclareExpandableDocumentCommand{\sendmessageleftx}{O{\pcdefaultlongmessagelength}mO{}m}{%
+\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xleftarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
+}
+
+%
+% Division
+\DeclareExpandableDocumentCommand{\pcintertext}{O{}m}{\intertext{%
+\ifthenelse{\equal{#1}{center}}{\makebox[\linewidth][c]{#2}}{}%
+\ifthenelse{\equal{#1}{dotted}}{\dotfill#2\dotfill}{}%
+\ifthenelse{\equal{#1}{}}{#2}{}%
+}\@pc at beginnewline}
+
+
+
+%    \end{macrocode}
+%
+% \subsection{Tikz within Pseudocode}
+%
+%    \begin{macrocode}
+
+%
+% remember pictues
+\newcounter{@pc at remember}
+
+\newcommand{\@pc at ensureremember}{%
+\ifthenelse{\value{@pc at remember}=0}{\tikzstyle{every picture}+=[remember picture]}{}%
+\addtocounter{@pc at remember}{1}}
+
+\newcommand{\@pc at releaseremember}{%
+\addtocounter{@pc at remember}{-1}%
+\ifthenelse{\value{@pc at remember}=0}{\tikzstyle{every picture}-=[remember picture]}{}%
+}
+
+
+%
+% pcimage
+\newenvironment{pcimage}{%
+\begingroup\@pc at ensureremember%
+}{%
+\@pc at releaseremember\endgroup%
+}
+
+\newcommand*\@pcnodecontent{}
+\newcommand*\@pcnodestyle{}
+\newcommand*\@pcnodedraw{}
+\define at key{pcnode}{content}[]{\renewcommand*\@pcnodecontent{#1}}
+\define at key{pcnode}{style}[]{\renewcommand*\@pcnodestyle{#1}}
+\define at key{pcnode}{draw}[]{\renewcommand*\@pcnodedraw{#1}}
+
+\newcommandx*{\pcnode}[2][2=]{%
+\begingroup\setkeys{pcnode}{#2}%
+\tikzset{PCNODE-STYLE/.style/.expand once=\@pcnodestyle}%
+\begin{tikzpicture}[inner sep=0ex,baseline=0pt]%
+\node[PCNODE-STYLE] (#1) {\@pcnodecontent}; %
+\end{tikzpicture}%
+\ifdefempty{\@pcnodedraw}{}{%
+\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt]\@pcnodedraw\end{tikzpicture}
+}%
+\endgroup}
+
+\newcommandx*{\pcdraw}[2][2=]{%
+\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#2]
+#1
+\end{tikzpicture}}
+
+%    \end{macrocode}
+%
+% \subsection{Black Box Reductions}
+%
+%    \begin{macrocode}
+
+%
+% Reductions
+\newcommand{\@bb at lastbox}{}
+\newcommand{\@bb at lastoracle}{}
+\newcommand{\@bb at lastchallenger}{}
+
+\newlength{\@bb at message@voffset}
+\newlength{\@bb at query@voffset}
+\newlength{\@bb at oraclequery@voffset}
+\newlength{\@bb at challengerquery@voffset}
+
+\newcounter{@bb at oracle@cnt}
+\newcounter{@bb at oracle@nestcnt}
+\newcounter{@bb at challenger@cnt}
+\newcounter{@bb at challenger@nestcnt}
+
+\newcounter{@bb at env@nestcnt}
+
+\newcommand{\bbroraclenodenameprefix}{ora-}
+\newcommand{\bbrchallengernodenameprefix}{challenger-}
+\newcommand{\bbrenvnodenameprefix}{env-}
+%    \end{macrocode}
+
+
+
+%\begin{macro}{aboveskip}
+%\begin{macro}{\@pc at bbrenvaboveskip}
+%    \begin{macrocode}
+\newcommand*\@pc at bbrenvaboveskip{0pt}
+\define at key{pcbbrenv}{aboveskip}[0pt]{\renewcommand*\@pc at bbrenvaboveskip{#1}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{belowskip}
+%\begin{macro}{\@pc at bbrenvbelowskip}
+%    \begin{macrocode}
+\newcommand*\@pc at bbrenvbelowskip{0pt}
+\define at key{pcbbrenv}{belowskip}[0pt]{\renewcommand*\@pc at bbrenvbelowskip{#1}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+
+%\begin{macro}{\@pc at bbrenv@legacyargcheck}
+%\begin{macro}{\@pc at bbrenv@argstring}
+% ensures that first command can still be 5cm which is rewritten as aboveskip=5cm
+%    \begin{macrocode}
+\newcommand*\@pc at bbrenv@argstring{}
+\def\@pc at bbrenv@remfinalequals#1=#2=\relax{\renewcommand*\@pc at bbrenv@argstring{#1=#2}}
+\def\@pc at bbrenv@legacyargcheck#1=#2\relax{%
+\ifthenelse{\equal{#2}{}}
+	{\PackageWarning{cryptocode}{Deprecated option for bbrenv. Please use key value list as first parameter with keys aboveskip and/or belowskip.}%
+\renewcommand*\@pc at bbrenv@argstring{aboveskip=#1}}
+	{\@pc at bbrenv@remfinalequals#1=#2\relax}%
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\bbrfirstmessageoffset}
+% offset of the first message from top
+%    \begin{macrocode}
+\providecommand{\bbrfirstmessageoffset}{1ex}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%\begin{environment}{bbrenv}
+% Black Box Reduction Environment
+%    \begin{macrocode}
+\newenvironmentx{bbrenv}[3][1={aboveskip=0pt,belowskip=0pt},3=0pt]{%
+\addtocounter{@bb at env@nestcnt}{1}%
+\renewcommand{\@bb at lastbox}{#2}%
+% parse args and allow old style #1=0pt
+\@pc at bbrenv@legacyargcheck#1=\relax%
+\@expandedsetkeys{pcbbrenv}{}{belowskip=#3}{\@pc at bbrenv@argstring}{}%
+%
+% reset lengths
+\@pc at globalsetlength{\@bb at message@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at query@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at oraclequery@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at challengerquery@voffset}{\bbrfirstmessageoffset}%
+%
+%reset oracle counter and oracle query offset
+\ifthenelse{\value{@bb at oracle@nestcnt}=0}
+ {\setcounter{@bb at oracle@cnt}{0}}{}%
+\ifthenelse{\value{@bb at challenger@nestcnt}=0}
+  {\setcounter{@bb at challenger@cnt}{0}}{}%
+%
+\vspace{\@pc at bbrenvaboveskip}%
+\ifthenelse{\value{@bb at env@nestcnt}=1}
+ {\@pc at ensureremember%
+\begin{tikzpicture}
+}{\tikz\bgroup}
+}{%
+\ifthenelse{\value{@bb at env@nestcnt}=1}
+{\end{tikzpicture}%
+\@pc at releaseremember%
+}{\egroup}%
+\vspace{\@pc at bbrenvbelowskip}%
+\addtocounter{@bb at env@nestcnt}{-1}%
+% reset lengths
+\@pc at globalsetlength{\@bb at message@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at query@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at oraclequery@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at challengerquery@voffset}{\bbrfirstmessageoffset}%
+}
+%    \end{macrocode}
+%\end{environment}
+
+%
+%
+
+%
+% black box reduction box
+% option keys
+%    \begin{macrocode}
+\newcommand*\bbrboxname{}
+\newcommand*\bbrboxnamepos{right}
+\newcommand*\bbrboxnamestyle{}
+\newcommand*\@bbrboxnamepos{below right=0.5ex and -0.5ex of \@bb at lastbox.north east,anchor=north east}
+\newcommand*\bbrboxabovesep{\baselineskip}
+\newcommand*\@bbrboxnameposoffset{below left=\bbrboxabovesep of phantomname.south west}
+\newcommand*\bbrboxstyle{draw}
+\newcommand*\bbrboxafterskip{}
+\newcommand*\bbrboxminheight{0cm}
+\newcommand*\bbrboxminwidth{2cm}
+\newcommand*\bbrboxxshift{0cm}
+\newcommand*\bbrboxyshift{0cm}
+\define at key{bbrbox}{abovesep}[]{\renewcommand*\bbrboxabovesep{#1}}
+\define at key{bbrbox}{name}[]{\renewcommand*\bbrboxname{#1}}
+\define at key{bbrbox}{namestyle}[]{\renewcommand*\bbrboxnamestyle{#1}}
+\define at key{bbrbox}{namepos}[]{\renewcommand*\bbrboxnamepos{#1}}
+\define at key{bbrbox}{style}[draw]{\renewcommand*\bbrboxstyle{#1}}
+\define at key{bbrbox}{minwidth}[]{\renewcommand*\bbrboxminwidth{#1}}
+\define at key{bbrbox}{addheight}[]{\renewcommand*\bbrboxafterskip{#1}}
+\define at key{bbrbox}{minheight}[]{\renewcommand*\bbrboxminheight{#1}}
+\define at key{bbrbox}{xshift}[]{\renewcommand*\bbrboxxshift{#1}}
+\define at key{bbrbox}{yshift}[]{\renewcommand*\bbrboxyshift{#1}}
+
+
+\NewEnviron{bbrbox}[1][]{%
+\setkeys{bbrbox}{#1}%
+
+\ifthenelse{\equal{\bbrboxnamepos}{center}}
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north,anchor=north}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{left}}
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north west,anchor=north west}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{top right}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north east,anchor=south east}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{}
+\ifthenelse{\equal{\bbrboxnamepos}{top center}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north,anchor=south}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{top left}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north west,anchor=south west}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{middle}}
+ {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=south}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{bottom}}
+ {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=north}}{} 
+
+
+\tikzset{BBRBOXSTYLE/.style/.expand once=\bbrboxstyle}%
+\tikzset{BBRBOXNAMEPOS/.style/.expand once=\@bbrboxnamepos}%
+\tikzset{BBRBOXNAMESTYLE/.style/.expand once=\bbrboxnamestyle}%
+\tikzset{BBRBOXNAMEPOSOFFSET/.style/.expand once=\@bbrboxnameposoffset}%
+
+\coordinate[inner sep=0pt,outer sep=0pt] (\@bb at lastbox-tmpouter) {};
+\node at (\@bb at lastbox-tmpouter) {}; %this empty node seems needed to get the xyshift right.
+\node[inner sep=.3333em,anchor=north,BBRBOXSTYLE,minimum height=\bbrboxminheight,below right=\bbrboxyshift and \bbrboxxshift of \@bb at lastbox-tmpouter] (\@bb at lastbox)  \bgroup
+	\tikz{
+		\node[inner sep=0pt,outer sep=0pt,minimum height=0cm] (phantomname) {}; %minimum width
+		\node[BBRBOXNAMEPOSOFFSET,minimum height=0cm] (\@bb at lastbox-inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}};
+		\ifthenelse{\equal{\bbrboxafterskip}{}}{}{
+			\node[below=0cm of \@bb at lastbox-inner,minimum height=\bbrboxafterskip] {};
+		}
+		\node[inner sep=0pt,outer sep=0pt,at=(\@bb at lastbox-inner.south west),minimum height=0cm] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width
+	}
+\egroup;
+\ifthenelse{\equal{\bbrboxnamepos}{none}}
+{}{\node[BBRBOXNAMEPOS,BBRBOXNAMESTYLE, inner sep=0.2ex, outer sep=0pt, overlay] () {\bbrboxname};}
+}
+
+
+\newcommand*\bbroraclevdistance{\baselineskip}
+\newcommand*\bbroraclehdistance{1.5cm}
+\define at key{bbroracle}{distance}[]{\renewcommand*\bbroraclehdistance{#1}}
+\define at key{bbroracle}{hdistance}[]{\renewcommand*\bbroraclehdistance{#1}}
+\define at key{bbroracle}{vdistance}[]{\renewcommand*\bbroraclevdistance{#1}}
+
+
+% ORACLES
+\newenvironmentx{bbroracle}[2][2=]{%
+	\begingroup
+	\setkeys{bbroracle}{#2}
+	%reset query boolean. This is a bit crude and does not allow nesting oracles 
+	%in oracles but should be good enough 
+	\gdef\@bbr at first@oraclequery{true}	
+	%add to nesting cout
+	\addtocounter{@bb at oracle@nestcnt}{1}
+	%if first oracle, then put it to the right, else stack them vertically
+	\addtocounter{@bb at oracle@cnt}{1}
+	\ifthenelse{\value{@bb at oracle@cnt}=1}{
+	\setlength{\@bb at tmplength@b}{\bbroraclevdistance-\baselineskip}
+	\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
+	}{
+% compute distance of top of last box to bottom of last oracle
+	\coordinate (@bbtmpcoord) at (\@bb at lastbox.north east);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordA}
+	\coordinate (@bbtmpcoord) at (\bbroraclenodenameprefix \@bb at lastoracle.south west);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordB}
+	\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB+\bbroraclevdistance}
+	\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
+	}
+	\global\def\@bb at lastoracle{#1}
+	\begin{bbrenv}{#1}
+}{
+	\end{bbrenv}
+	\egroup;
+
+	\addtocounter{@bb at oracle@nestcnt}{-1}
+	\endgroup
+}
+
+
+\newcommand*\bbrchallengerhdistance{1.5cm}
+\newcommand*\bbrchallengervdistance{\baselineskip}
+\define at key{bbrchallenger}{distance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
+\define at key{bbrchallenger}{hdistance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
+\define at key{bbrchallenger}{vdistance}[]{\renewcommand*\bbrchallengervdistance{#1}}
+
+
+% Challenger
+\newenvironmentx{bbrchallenger}[2][2=]{%
+\begingroup%
+\setkeys{bbrchallenger}{#2}%
+%reset query boolean. This is a bit crude and does not allow nesting oracles 
+%in oracles but should be good enough 	
+\gdef\@bbr at first@challengerquery{true}%
+%add to nesting cout
+\addtocounter{@bb at challenger@nestcnt}{1}%
+%if first oracle, then put it to the right, else stack them vertically
+\addtocounter{@bb at challenger@cnt}{1}%
+\ifthenelse{\value{@bb at challenger@cnt}=1}{%
+\setlength{\@bb at tmplength@b}{\bbrchallengervdistance-\baselineskip}%
+\node[inner sep=0pt,outer sep=0pt,below left=\@bb at tmplength@b and \bbrchallengerhdistance of \@bb at lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
+}{%
+\coordinate (@bbtmpcoord) at (\@bb at lastbox.north west);%
+\path (@bbtmpcoord);%
+\pgfgetlastxy{\XCoord}{\YCoordA}%
+\coordinate (@bbtmpcoord) at (\bbrchallengernodenameprefix \@bb at lastchallenger.south east);%
+\path (@bbtmpcoord);%
+\pgfgetlastxy{\XCoord}{\YCoordB}%
+\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB+\bbrchallengervdistance}%
+\node[inner sep=0pt,below left=\@bb at tmplength@b and \bbrchallengerhdistance of \@bb at lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
+}%
+\global\def\@bb at lastchallenger{#1}
+\begin{bbrenv}{#1}%
+}{
+\end{bbrenv}%
+\egroup;%
+\addtocounter{@bb at challenger@nestcnt}{-1}%
+\endgroup%
+\let\msgfrom\bbrchallengerqueryto%
+}
+
+
+\newcommand*\bbrinputlength{0.5cm}
+\newcommand*\bbrinputhoffset{0.5cm}
+\newcommand*\bbrinputbottom{}
+\newcommand*\bbrinputtop{}
+\newcommand*\bbrinputedgestyle{}
+\newcommand*\bbrinputtopstyle{}
+\newcommand*\bbrinputbottomstyle{}
+\newcommand*\bbrinputnodestyle{}
+\newcommand*\bbrinputnodename{}
+\define at key{bbrinput}{length}[]{\renewcommand*\bbrinputlength{#1}}
+\define at key{bbrinput}{hoffset}[]{\renewcommand*\bbrinputhoffset{#1}}
+\define at key{bbrinput}{name}[]{\renewcommand*\bbrinputnodename{#1}}
+\define at key{bbrinput}{top}[]{\renewcommand*\bbrinputtop{#1}}
+\define at key{bbrinput}{bottom}[]{\renewcommand*\bbrinputbottom{#1}}
+
+
+\newcommand{\@bb at inputsetup}[1]{
+	%load keys	
+	\begingroup % for local keys
+
+	\setkeys{bbrinput}{#1}%
+
+	\tikzset{BBRINPUT-NODESTYLE/.style/.expand once=\bbrinputedgestyle}%	
+	\tikzset{BBRINPUT-TOPSTYLE/.style/.expand once=\bbrinputtopstyle}%	
+	\tikzset{BBRINPUT-BOTTOMSTYLE/.style/.expand once=\bbrinputbottomstyle}%			
+	\tikzset{BBRINPUT-EDGESTYLE/.style/.expand once=\bbrinputedgestyle}%
+
+}
+
+\newcommand{\@bb at inputfinalize}{
+	\endgroup
+}
+
+\newcommandx*{\bbrinput}[2][2=]{%
+\@bb at inputsetup{#2}
+\ifthenelse{\equal{\bbrinputnodename}{}}
+  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-input}}{} 
+  
+\node[overlay,above right={\bbrinputlength} and {\bbrinputhoffset} of \@bb at lastbox.north west, anchor=south,BBRINPUT-NODESTYLE] (\bbrinputnodename) {#1};
+\path[->] (\bbrinputnodename.south)  edge[BBRINPUT-EDGESTYLE] node[above,anchor=east,BBRINPUT-TOPSTYLE] () {\bbrinputtop} node[below,anchor=west,BBRINPUT-BOTTOMSTYLE] () {\bbrinputbottom} (\bbrinputnodename.south|-\@bb at lastbox.north);
+\@bb at inputfinalize
+}
+
+\newcommandx*{\bbroutput}[2][2=]{%
+\@bb at inputsetup{#2}
+\ifthenelse{\equal{\bbrinputnodename}{}}
+  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-output}}{} 
+  
+\node[overlay,below right={\bbrinputlength} and {\bbrinputhoffset} of \@bb at lastbox.south west, anchor=north] (\bbrinputnodename) {#1};
+\draw[->] (\bbrinputnodename.north|-\@bb at lastbox.south)  -- (\bbrinputnodename.north|-\bbrinputnodename.north);
+\@bb at inputfinalize
+}
+
+\newenvironment{bbrpic}[1][]{%
+\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#1]%
+}{%
+\end{tikzpicture}}
+
+%
+% communication
+%temporary lengths
+\newlength{\@bb at com@tmpoffset}
+\newlength{\@bb at tmplength@b}
+
+%keys
+\newcommand*\@bbrcomsidestyle{}
+\newcommand*\@bbrcomosidestyle{}
+\newcommand*\@bbrcomtopstyle{}
+\newcommand*\@bbrcombottomstyle{}
+\newcommand*\@bbrcomside{}
+\newcommand*\@bbrcomoside{}
+\newcommand*\@bbrcomtop{}
+\newcommand*\@bbrcombottom{}
+\newcommand*\@bbrcomedgestyle{}
+\newcommand*\@bbrcomlength{1.25cm}
+\newcommand*\@bbrcomtopname{bbrcomtop}
+\newcommand*\@bbrcombottomname{bbrcombottom}
+\newcommand*\@bbrcomsidename{bbrcomside}
+\newcommand*\@bbrcomosidename{bbrcomoside}
+\newcommand*\@bbrcombeforeskip{0pt}
+\newcommand*\@bbrcomafterskip{0ex}
+\define at key{bbrcom}{sidestyle}[]{\renewcommand*\@bbrcomsidestyle{#1}}
+\define at key{bbrcom}{osidestyle}[]{\renewcommand*\@bbrcomosidestyle{#1}}
+\define at key{bbrcom}{topstyle}[]{\renewcommand*\@bbrcomtopstyle{#1}}
+\define at key{bbrcom}{bottomstyle}[]{\renewcommand*\@bbrcombottomstyle{#1}}
+\define at key{bbrcom}{side}[]{\renewcommand*\@bbrcomside{#1}}
+\define at key{bbrcom}{oside}[]{\renewcommand*\@bbrcomoside{#1}}
+\define at key{bbrcom}{top}[]{\renewcommand*\@bbrcomtop{#1}}
+\define at key{bbrcom}{bottom}[]{\renewcommand*\@bbrcombottom{#1}}
+\define at key{bbrcom}{edgestyle}[]{\renewcommand*\@bbrcomedgestyle{#1}}
+\define at key{bbrcom}{length}[]{\renewcommand*\@bbrcomlength{#1}}
+\define at key{bbrcom}{topname}[]{\renewcommand*\@bbrcomtopname{#1}}
+\define at key{bbrcom}{bottomname}[]{\renewcommand*\@bbrcombottomname{#1}}
+\define at key{bbrcom}{sidename}[]{\renewcommand*\@bbrcomsidename{#1}}
+\define at key{bbrcom}{osidename}[]{\renewcommand*\@bbrcomosidename{#1}}
+\define at key{bbrcom}{beforeskip}[]{\renewcommand*\@bbrcombeforeskip{#1}}
+\define at key{bbrcom}{aboveskip}[]{\renewcommand*\@bbrcombeforeskip{#1}}
+\define at key{bbrcom}{afterskip}[]{\renewcommand*\@bbrcomafterskip{#1}}
+\define at key{bbrcom}{belowskip}[]{\renewcommand*\@bbrcomafterskip{#1}}
+%    \end{macrocode}
+
+
+%\begin{macro}{\@bbrcomfixedoffset}
+%\begin{macro}{\@bbrcomfixedboffset}
+%\begin{macro}{fixedoffset}
+%\begin{macro}{fixedboffset}
+% Provide means for fixed message offset from top or bottom
+%    \begin{macrocode}
+\newcommand*\@bbrcomfixedoffset{}
+\newcommand*\@bbrcomfixedboffset{false}
+\define at key{bbrcom}{fixedoffset}[]{\renewcommand*\@bbrcomfixedoffset{#1}}
+\define at key{bbrcom}{fixedboffset}[]{\renewcommand*\@bbrcomfixedoffset{#1}\renewcommand*\@bbrcomfixedboffset{true}}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%    \begin{macrocode}
+%
+%
+\newcommand*\@bbrbasenodestyle{}
+\newcommand*\@bbrbasenodename{bbrtmpname}
+\define at key{bbrabase}{nodestyle}[]{\renewcommand*\@bbrbasenodestyle{#1}}
+\define at key{bbrabase}{nodename}[]{\renewcommand*\@bbrbasenodename{#1}}
+
+\newcommand*\@bbr at first@msg{true}
+\newcommand*\@bbr at first@query{true}
+\newcommand*\@bbr at first@oraclequery{true}
+\newcommand*\@bbr at first@challengerquery{true}
+
+%    \end{macrocode}
+%
+%
+%\begin{macro}{\@bbr at intermessage@skip}
+%\begin{macro}{\@bbr at intermessage@medskip}
+%\begin{macro}{\@bbr at intermessage@shortskip}
+%\begin{macro}{\@bbr at intermessage@veryshortskip}
+% Skip between two messages.
+%    \begin{macrocode}
+\newcommand*\@bbr at intermessage@skip{4ex}
+\newcommand*\@bbr at intermessage@veryshortskip{1ex}
+\newcommand*\@bbr at intermessage@shortskip{1.5ex}
+\newcommand*\@bbr at intermessage@medskip{2.5ex}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{islast}
+%\begin{macro}{\@bbrcomislast}
+% Sets the message from the bottom of the box with the same distance as the first message.
+%    \begin{macrocode}
+\newcommand*\@bbrcomislast{false}
+\define at key{bbrcom}{islast}[true]{\renewcommand*\@bbrcomislast{#1}}
+
+\newcommand*\@bbrcom at check@islast{%
+\ifthenelse{\equal{\@bbrcomislast}{true}}
+	{\renewcommand*\@bbrcomfixedoffset{\bbrfirstmessageoffset}\renewcommand*\@bbrcomfixedboffset{true}}
+	{}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\@bbr at lastskip}
+% marker to set whether next skip is a short or a long one
+%    \begin{macrocode}
+\def\@bbr at lastskip{0pt}
+%    \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@bb at comsetup}
+% Sets up communication parameters for message/query commands. Parameters are
+% \marg{key value list}, \marg{length}, \marg{command for adding space}
+% \marg{true if first message}
+%    \begin{macrocode}
+\newcommand{\@bb at comsetup}[4]{
+	% check if is first message and mark as false
+	\edef\@tmp at bbr@isfirst{#4}
+	\renewcommand#4{false}
+	
+	%load keys	
+	\begingroup % for local keys
+
+	\setkeys{bbrcom}{#1}%
+
+	%set styles
+	\tikzset{BBRCOM-SIDESTYLE/.style/.expand once=\@bbrcomsidestyle}%
+	\tikzset{BBRCOM-OSIDESTYLE/.style/.expand once=\@bbrcomosidestyle}%
+	\tikzset{BBRCOM-TOPSTYLE/.style/.expand once=\@bbrcomtopstyle}%
+	\tikzset{BBRCOM-BOTTOMSTYLE/.style/.expand once=\@bbrcombottomstyle}%
+	\tikzset{BBRCOM-EDGESTYLE/.style/.expand once=\@bbrcomedgestyle}%
+
+	\@bbrcom at check@islast{}
+
+	% increase space
+	#3{\@bbrcombeforeskip}
+	\ifthenelse{\equal{\@bbrcomfixedoffset}{}}
+	{
+		\ifthenelse{\equal{\@tmp at bbr@isfirst}{true}}
+			{}{#3{\@bbr at lastskip}}
+
+		\setlength{\@bb at com@tmpoffset}{#2}%
+	}
+	{
+		\setlength{\@bb at com@tmpoffset}{\@bbrcomfixedoffset}%
+	}
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\@bb at comfinalize}
+%    \begin{macrocode}
+\newcommand{\@bb at comfinalize}[1]{
+	#1{\@bbrcomafterskip}
+	\endgroup
+	\def\@bbr at lastskip{\@bbr at intermessage@skip}
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\@bbrmsg}
+% 9 -> true if first message
+% 10 -> anchor from bottom
+%    \begin{macrocode}	
+\newcommand{\@bbrmsg}[9]{
+	\@bb at comsetup{#1}{#7}{#8}{#9}
+	%
+	\ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
+	{
+		% from bottom
+		\ifthenelse{\equal{#4}{north east}}{\def\@bbr at tmp@bottomanchor{south east}}{}
+		\ifthenelse{\equal{#4}{north west}}{\def\@bbr at tmp@bottomanchor{south west}}{}	
+		\node[#3=-\@bb at com@tmpoffset and \@bbrcomlength of \@bb at lastbox.\@bbr at tmp@bottomanchor,anchor=#6,BBRCOM-SIDESTYLE] (\@bbrcomsidename) {\@bbrcomside};
+	}
+	{
+		% from top
+		\node[#3=\@bb at com@tmpoffset and \@bbrcomlength of \@bb at lastbox.#4,anchor=#6,BBRCOM-SIDESTYLE] (\@bbrcomsidename) {\@bbrcomside};
+	}
+	\path[#2] (\@bbrcomsidename.#6) edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\@bbrcomtopname) {\@bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\@bbrcombottomname) {\@bbrcombottom} (\@bb at lastbox.#5|-\@bbrcomsidename) -- (\@bb at lastbox.#5|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {};
+	%
+	\@bb at comfinalize{#8}
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\bbrmsgto}
+%\begin{macro}{\bbrmsgfrom}
+%\begin{macro}{\bbrmsgtofrom}
+%\begin{macro}{\bbrmsgfromto}
+%    \begin{macrocode}	
+\newcommandx{\bbrmsgto}[1]{%
+\@bbrmsg{#1}{->}{below left}{north west}{west}{east}{\@bb at message@voffset}{\bbrmsgspace}{\@bbr at first@msg}
+}
+\newcommandx{\bbrmsgfrom}[1]{%
+\@bbrmsg{#1}{<-}{below left}{north west}{west}{east}{\@bb at message@voffset}{\bbrmsgspace}{\@bbr at first@msg}
+}
+
+\newcommandx{\bbrmsgtofrom}[2]{%
+\bbrmsgto{#1}
+\bbrmsgspace{-\@bbr at intermessage@skip}
+\bbrmsgspace{\@bbr at intermessage@shortskip}
+\bbrmsgfrom{#2}
+\bbrmsgspace{\@bbr at intermessage@medskip}
+}
+
+\newcommandx{\bbrmsgfromto}[2]{%
+\bbrmsgfrom{#1}
+\bbrmsgspace{-\@bbr at intermessage@skip}
+\bbrmsgspace{\@bbr at intermessage@shortskip}
+\bbrmsgto{#2}
+\bbrmsgspace{\@bbr at intermessage@medskip}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{\bbrmsgvdots}
+%    \begin{macrocode}	
+\newcommandx{\bbrmsgvdots}{%
+	\bbrmsgtxt[xshift=\@bbrcomlength/2,afterskip=\@bbr at intermessage@skip]{$\vdots$}
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{macro}{\bbrqryto}
+%\begin{macro}{\bbrqryfrom}
+%\begin{macro}{\bbrqrytofrom}
+%\begin{macro}{\bbrqryfromto}
+%    \begin{macrocode}	
+\newcommandx{\bbrqryto}[1]{%
+\@bbrmsg{#1}{<-}{below right}{north east}{east}{west}{\@bb at query@voffset}{\bbrqryspace}{\@bbr at first@query}
+}
+\newcommandx{\bbrqryfrom}[1]{%
+\@bbrmsg{#1}{->}{below right}{north east}{east}{west}{\@bb at query@voffset}{\bbrqryspace}{\@bbr at first@query}
+}
+
+\newcommand*{\bbrqrytofrom}[2]{%
+\bbrqryto{#1}
+\bbrqryspace{-\@bbr at intermessage@skip}
+\bbrqryspace{\@bbr at intermessage@shortskip}
+\bbrqryfrom{#2}
+\bbrqryspace{\@bbr at intermessage@medskip}
+}
+
+\newcommand*{\bbrqryfromto}[2]{%
+\bbrqryfrom{#1}
+\bbrqryspace{-\@bbr at intermessage@skip}
+\bbrqryspace{\@bbr at intermessage@shortskip}
+\bbrqryto{#2}
+\bbrqryspace{\@bbr at intermessage@medskip}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\@bbroracleqry}
+%    \begin{macrocode}	
+\newcommand{\@bbroracleqry}[4]{
+	\@bb at comsetup{#1}{#3}{#4}{\@bbr at first@oraclequery}
+	%
+	\ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
+	{
+		% from bottom
+		\path[#2] (\@bb at lastoracle.south west) -- ++ (0,\@bb at 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} (\@bb at lastbox.east|-\@bbrcomsidename) -- (\@bb at lastbox.east|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=east,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
+	}
+	{
+		\path[#2] (\@bb at lastoracle.north west) -- ++ (0,-\@bb at 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} (\@bb at lastbox.east|-\@bbrcomsidename) -- (\@bb at lastbox.east|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=east,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
+	}
+	%
+	\@bb at comfinalize{#4}
+}
+%    \end{macrocode}	
+%\end{macro}
+%
+%
+%\begin{macro}{\bbroracleqryto}
+%\begin{macro}{\bbroracleqryfrom}
+%\begin{macro}{\bbroracleqrytofrom}
+%\begin{macro}{\bbroracleqryfromto}
+%    \begin{macrocode}	
+\newcommand{\bbroracleqryfrom}[1]{
+	\@bbroracleqry{#1}{->}{\@bb at oraclequery@voffset}{\bbroracleqryspace}
+}
+
+\newcommand{\bbroracleqryto}[1]{
+	\@bbroracleqry{#1}{<-}{\@bb at oraclequery@voffset}{\bbroracleqryspace}
+}
+
+\newcommand*{\bbroracleqrytofrom}[2]{%
+\bbroracleqryto{#1}
+\bbroracleqryspace{-\@bbr at intermessage@skip}
+\bbroracleqryspace{\@bbr at intermessage@shortskip}
+\bbroracleqryfrom{#2}
+\bbroracleqryspace{\@bbr at intermessage@medskip}
+}
+
+\newcommand*{\bbroracleqryfromto}[2]{%
+\bbroracleqryfrom{#1}
+\bbroracleqryspace{-\@bbr at intermessage@skip}
+\bbroracleqryspace{\@bbr at intermessage@shortskip}
+\bbroracleqryto{#2}
+\bbroracleqryspace{\@bbr at intermessage@medskip}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{\@bbrchallengerqry}
+%    \begin{macrocode}	
+\newcommand{\@bbrchallengerqry}[4]{
+	\@bb at comsetup{#1}{#3}{#4}{\@bbr at first@challengerquery}
+	%
+	\ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
+	{
+		\path[#2] (\@bb at lastchallenger.south east) -- ++ (0,\@bb at 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} (\@bb at lastbox.west|-\@bbrcomsidename) -- (\@bb at lastbox.west|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=west,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
+	}
+	{
+		\path[#2] (\@bb at lastchallenger.north east) -- ++ (0,-\@bb at 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} (\@bb at lastbox.west|-\@bbrcomsidename) -- (\@bb at lastbox.west|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=west,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
+	}
+	%
+	\@bb at comfinalize{#4}
+}
+%    \end{macrocode}	
+%\end{macro}
+%
+%
+%
+%\begin{macro}{\bbroracleqryto}
+%\begin{macro}{\bbroracleqryfrom}
+%\begin{macro}{\bbroracleqrytofrom}
+%\begin{macro}{\bbroracleqryfromto}
+%    \begin{macrocode}	
+\newcommand{\bbrchallengerqryfrom}[1]{
+	\@bbrchallengerqry{#1}{<-}{\@bb at challengerquery@voffset}{\bbrchallengerqryspace}
+}
+
+\newcommand{\bbrchallengerqryto}[1]{
+	\@bbrchallengerqry{#1}{->}{\@bb at challengerquery@voffset}{\bbrchallengerqryspace}
+}
+
+\newcommand*{\bbrchallengerqrytofrom}[2]{%
+\bbrchallengerqryto{#1}
+\bbrchallengerqryspace{-\@bbr at intermessage@skip}
+\bbrchallengerqryspace{\@bbr at intermessage@shortskip}
+\bbrchallengerqryfrom{#2}
+\bbrchallengerqryspace{\@bbr at intermessage@medskip}
+}
+
+\newcommand*{\bbrchallengerqryfromto}[2]{%
+\bbrchallengerqryfrom{#1}
+\bbrchallengerqryspace{-\@bbr at intermessage@skip}
+\bbrchallengerqryspace{\@bbr at intermessage@shortskip}
+\bbrchallengerqryto{#2}
+\bbrchallengerqryspace{\@bbr at intermessage@medskip}
+}
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%    \begin{macrocode}	
+
+
+\newcommand*\bbrcomloopleft{}
+\newcommand*\bbrcomloopleftstyle{}
+\newcommand*\bbrcomloopright{}
+\newcommand*\bbrcomlooprightstyle{}
+\newcommand*\bbrcomloopcenter{}
+\newcommand*\bbrcomloopcenterstyle{}
+\newcommand*\bbrcomloopclockwise{false}
+\newcommand*\bbrcomloopangle{50}
+\define at key{bbrcomloop}{left}[]{\renewcommand*\bbrcomloopleft{#1}}
+\define at key{bbrcomloop}{leftstyle}[]{\renewcommand*\bbrcomloopleftstyle{#1}}
+\define at key{bbrcomloop}{right}[]{\renewcommand*\bbrcomloopright{#1}}
+\define at key{bbrcomloop}{rightstyle}[]{\renewcommand*\bbrcomlooprightstyle{#1}}
+\define at key{bbrcomloop}{center}[]{\renewcommand*\bbrcomloopcenter{#1}}
+\define at key{bbrcomloop}{centerstyle}[]{\renewcommand*\bbrcomloopcenterstyle{#1}}
+\define at key{bbrcomloop}{angle}[]{\renewcommand*\bbrcomloopangle{#1}}
+\define at key{bbrcomloop}{clockwise}[true]{\renewcommand*\bbrcomloopclockwise{#1}}
+
+\newcommand{\bbrloop}[3]{
+	\begingroup % for local keys
+	\setkeys{bbrcomloop}{#3}%
+
+	\tikzset{BBRLOOP-LEFTSTYLE/.style/.expand once=\bbrcomloopleftstyle}%
+	\tikzset{BBRLOOP-RIGHTSTYLE/.style/.expand once=\bbrcomlooprightstyle}%
+	\tikzset{BBRLOOP-CENTERSTYLE/.style/.expand once=\bbrcomloopcenterstyle}%
+
+
+	\ifthenelse{\equal{\bbrcomloopclockwise}{true}}
+	{
+		\path[->] (#1) edge[bend left=\bbrcomloopangle] node[midway,left,inner sep=0,outer sep=0,BBRLOOP-LEFTSTYLE] (bbrleft) {\bbrcomloopleft} (#2);
+		\path[->] (#2) edge[bend left=\bbrcomloopangle] node[midway,right,inner sep=0,outer sep=0,BBRLOOP-RIGHTSTYLE] (bbrright) {\bbrcomloopright} (#1);
+	}
+	{
+		\path[->] (#1) edge[bend right=\bbrcomloopangle] node[midway,left,inner sep=0,outer sep=0,] (bbrleft) {\bbrcomloopleft} (#2);
+		\path[->] (#2) edge[bend right=\bbrcomloopangle] node[midway,right,inner sep=0,outer sep=0,] (bbrright) {\bbrcomloopright} (#1);
+	}
+	\node[at=($(bbrleft.west)!0.5!(bbrright.east)$),anchor=center,BBRLOOP-CENTERSTYLE]() {\bbrcomloopcenter};
+
+	\endgroup
+}
+
+\newcommand*\bbrintertexthoffset{1.5cm}
+\define at key{bbrintertext}{xshift}[]{\renewcommand*\bbrintertexthoffset{#1}}
+
+\newcommand{\@bb at intertextsetup}[1]{
+	%load keys	
+	\begingroup % for local keys
+
+	% fix align environment (e.g. for use of pseudocode)
+	% ^^A https://tex.stackexchange.com/questions/36954/spurious-space-above-align-environment-at-top-of-page-minipage
+	%\pretocmd\start at align{%
+	  %\if at minipage\kern-0.5\abovedisplayskip\fi
+	%}{}{}
+
+	\setkeys{bbrcom,bbrabase,bbrintertext}{#1}%
+	\@bbrcom at check@islast{}
+
+	\tikzset{BBRBASE-NODESTYLE/.style/.expand once=\@bbrbasenodestyle}%
+}
+
+\newcommand{\@bb at intertextfinalize}[1]{
+	#1{\@bbrcomafterskip}
+	\endgroup
+	\def\@bbr at lastskip{\@bbr at intermessage@veryshortskip}
+}
+%    \end{macrocode}
+
+%\begin{macro}{\@bbrintertext}
+% 7 -> whether or not this is the first msg/query
+%    \begin{macrocode}
+\newcommand{\@bbrintertext}[7]{
+	\edef\@tmp at bbr@isfirst{#7}
+	\renewcommand#7{false}
+
+	\@bb at intertextsetup{#1}
+
+	% increase space
+	#5{\@bbrcombeforeskip}
+	\ifthenelse{\equal{\@bbrcomfixedoffset}{}}
+	{
+		\ifthenelse{\equal{\@tmp at bbr@isfirst}{true}}
+			{}{#5{\@bbr at intermessage@veryshortskip}}
+
+		\setlength{\@bb at com@tmpoffset}{#4}%
+	}
+	{
+		\setlength{\@bb at com@tmpoffset}{\@bbrcomfixedoffset}%
+	}
+
+	%
+	\ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
+	{
+		% from bottom
+		\ifthenelse{\equal{#3}{north east}}{\def\@bbr at tmp@bottomanchor{south east}}{}
+		\ifthenelse{\equal{#3}{north west}}{\def\@bbr at tmp@bottomanchor{south west}}{}	
+		
+		\node[#2=-\@bb at com@tmpoffset and \bbrintertexthoffset of \@bb at lastbox.\@bbr at tmp@bottomanchor, inner sep=0, outer sep=0, BBRBASE-NODESTYLE] (\@bbrbasenodename) {#6};
+	}
+	{
+		\node[#2=\@bb at com@tmpoffset and \bbrintertexthoffset of \@bb at lastbox.#3, inner sep=0, outer sep=0, BBRBASE-NODESTYLE] (\@bbrbasenodename) {#6};
+	}
+	%
+	% compute height of node
+	\coordinate (@bbtmpcoord) at (\@bbrbasenodename.north);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordA}
+	\coordinate (@bbtmpcoord) at (\@bbrbasenodename.south);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordB}
+
+	% update voffset
+	\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB}
+	#5{\the\@bb at tmplength@b}
+
+	\@bb at intertextfinalize{#5}
+}
+%    \end{macrocode}
+%\end{macro}
+
+%    \begin{macrocode}
+\newcommand{\bbrmsgtxt}[2][]{
+	\@bbrintertext{#1}{below left}{north west}{\@bb at message@voffset}{\bbrmsgspace}{#2}{\@bbr at first@msg}
+}
+
+\newcommand{\bbrqrytxt}[2][]{
+	\@bbrintertext{#1}{below right}{north east}{\@bb at query@voffset}{\bbrqryspace}{#2}{\@bbr at first@query}
+}
+
+\newcommand{\bbrchallengertxt}[2][]{
+\begingroup
+\setlength{\@bb at tmplength@b}{\bbrchallengerhdistance/2}%
+\renewcommand{\bbrintertexthoffset}{\the\@bb at tmplength@b}%
+\@bbrintertext{#1}{below left}{north west}{\@bb at challengerquery@voffset}{\bbrchallengerqryspace}{#2}{\@bbr at first@challengerquery}
+\endgroup
+}
+
+\newcommand{\bbroracletxt}[2][]{
+\begingroup
+\setlength{\@bb at tmplength@b}{\bbroraclehdistance/2}%
+\renewcommand{\bbrintertexthoffset}{\the\@bb at tmplength@b}%
+\@bbrintertext{#1}{below left}{north west}{\@bb at oraclequery@voffset}{\bbroracleqryspace}{#2}{\@bbr at first@oraclequery}
+\endgroup
+}
+
+\newcommand{\bbrmsgspace}[1]{
+\@pc at globaladdtolength{\@bb at message@voffset}{#1}
+}
+
+\newcommand{\bbrqryspace}[1]{
+\@pc at globaladdtolength{\@bb at query@voffset}{#1}
+}
+
+\newcommand{\bbroracleqryspace}[1]{
+\@pc at globaladdtolength{\@bb at oraclequery@voffset}{#1}
+}
+
+\newcommand{\bbrchallengerqryspace}[1]{
+\@pc at globaladdtolength{\@bb at challengerquery@voffset}{#1}
+}
+
+
+%    \end{macrocode}
+%
+% \subsection{Game-Based Proofs}
+%
+%    \begin{macrocode}
+
+\newcounter{pcstartgamecounter}
+%
+%
+%    \end{macrocode}
+%
+%
+%\begin{macro}{gamechange}
+% Highlighting of changes between games. Highlight color can be set via
+% |\gamechangecolor|
+%    \begin{macrocode}
+\definecolor{gamechangecolor}{gray}{0.90}
+\newcommand{\gamechange}[2][gamechangecolor]{%
+{\setlength{\fboxsep}{0pt}\colorbox{#1}{\ifmmode$\displaystyle#2$\else#2\fi}}%
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\pcbox}
+% A simple box for conditional (ie., boxed) lines.
+%    \begin{macrocode}
+\newcommand{\pcbox}[1]{%
+{\setlength{\fboxsep}{3pt}\fbox{$\displaystyle#1$}}
+}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%
+%
+%\begin{macro}{\pcgame}
+%\begin{macro}{\pcgamename}
+%\begin{macro}{\pcgameprocedurestyle}
+%    \begin{macrocode}
+\newcommand*{\pcgamename}{Game}
+\newcommand*{\pcgameprocedurestyle}[1]{\ensuremath{\mathsf{#1}}}
+
+\def\pcgame{\bgroup\pcgame@}
+\newcommand{\pcgame@}[1][]{\ifthenelse{\equal{#1}{}}{\pcgame@@}{\pcgame@@@{#1}}}
+\def\pcgame@@{\pcgameprocedurestyle{\pcgamename}\egroup}
+\def\pcgame@@@#1{\ensuremath{\pcgameprocedurestyle{\pcgamename_{\normalfont{#1}}}}\egroup}
+
+%    \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%
+%\begin{macro}{\@pc at gametitle}
+% Creates the header/title of a game
+%    \begin{macrocode}
+\newcommand\@pc at gametitle[1][]{\ifthenelse{\equal{#1}{}}
+{\ensuremath{\pcgame[\thepcgamecounter]\gameprocedurearg}}
+{\ensuremath{\pcgame[#1]\gameprocedurearg}}}
+%    \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\gameprocedurearg}
+%    \begin{macrocode}
+\newcommand*{\gameprocedurearg}{\ensuremath{(\secpar)}}
+%    \end{macrocode}
+%\end{macro}
+%
+%
+%\begin{environment}{gameproof}
+%    \begin{macrocode}
+\newcommand*\@pcgameproofgamenr{0}
+\define at key{pcgameproof}{nr}[]{\renewcommand*\@pcgameproofgamenr{#1}}
+\define at key{pcgameproof}{name}[]{\renewcommand*\pcgamename{\ensuremath{#1}}}
+\define at key{pcgameproof}{arg}[]{\renewcommand*\gameprocedurearg{\ensuremath{#1}}}
+
+\newenvironment{gameproof}[1][]{%
+\begingroup%
+\setkeys{pcgameproof}{#1}%
+\@pc at ensureremember%
+\setcounter{pcgamecounter}{\@pcgameproofgamenr}%
+\setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}%
+}{\@pc at releaseremember\endgroup}
+%    \end{macrocode}
+%\end{environment}
+%
+%
+%
+%    \begin{macrocode}
+\newcommand{\setgameproceduredefaultstyle}[1]{%
+\PackageWarning{cryptocode}{Deprecated command setgameproceduredefaultstyle. Use pcsetargs instead.}%
+\pcsetargs{#1}}
+
+\createpseudocodecommand{gameprocedure}
+  {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}}
+  {\@pc at gametitle}
+  {}
+
+\def\@bxgame at pseudocodeA[#1]#2#3{\setkeys*{pcspace}{#1}\renewcommand{\@bxgameheader}{\@pc at gametitle[#2]}%
+\@pseudocode[head=\@pc at gametitle,#1]{#3}}
+\def\@bxgame at pseudocodeB#1#2{\renewcommand{\@bxgameheader}{\@pc at gametitle[#1]}%
+\@pseudocode[head=\@pc at gametitle]{#2}}
+
+\newcommand{\bxgameprocedure}{
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+\renewcommand{\@withingame}{true}%
+\renewcommand{\@withinbxgame}{true}%
+\stepcounter{pcgamecounter}%
+\@ifnextchar[%]
+  {\@bxgame at pseudocodeA}
+  {\@bxgame at pseudocodeB}%
+}
+
+\newcommand{\@pc at secondheader}{}
+
+%tbx top boxed
+\createpseudocodecommand{tbxgameprocedure}
+  {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}%
+\renewcommand{\@pc at secondheader}{true}}
+{\@pc at gametitle}
+{}
+
+
+\newcommand*\@pcgamehopnodestyle{}
+\newcommand*\@pcgamehopedgestyle{bend left}
+\newcommand*\@pcgamehoppathestyle{}
+\newcommand*\@pcgamehophint{}
+\newcommand*\@pcgamehophintbelow{}
+\newcommand*\@pcgamehopinhint{}
+\newcommand*\@pcgamehoplength{1.5cm}
+\define at key{pcgamehop}{nodestyle}[]{\renewcommand*\@pcgamehopnodestyle{#1}}
+\define at key{pcgamehop}{edgestyle}[]{\renewcommand*\@pcgamehopedgestyle{#1}}
+\define at key{pcgamehop}{pathstyle}[]{\renewcommand*\@pcgamehoppathestyle{#1}}
+\define at key{pcgamehop}{hint}[]{\renewcommand*\@pcgamehophint{#1}}
+\define at key{pcgamehop}{belowhint}[]{\renewcommand*\@pcgamehophintbelow{#1}}
+\define at key{pcgamehop}{inhint}[]{\renewcommand*\@pcgamehopinhint{#1}}
+\define at key{pcgamehop}{length}[]{\renewcommand*\@pcgamehoplength{#1}}
+
+
+\newcommand{\@pc at setupgamehop}[1]{
+\begingroup\setkeys{pcgamehop}{#1}%
+\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
+\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
+\tikzset{GAMEHOP-EDGE-STYLE/.style/.expand once=\@pcgamehopedgestyle}%
+}
+
+\newcommand{\@pc at finalizegamehop}{
+\endgroup
+}
+
+\newcommandx*{\addgamehop}[3]{%
+\begingroup%
+\ifthenelse{#1<#2}%
+  {\ifthenelse{\equal{\@withingamedescription}{true}}%
+   {\renewcommand*\@pcgamehopedgestyle{bend right=20}\renewcommand*\@pcgamehopnodestyle{rotate=90}}{}%
+  }%
+  {\renewcommand*\@pcgamehopedgestyle{bend right}}%
+\@pc at setupgamehop{#3}%
+\begin{tikzpicture}[overlay]%
+\ifthenelse{#1<#2}{%
+       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#2);
+}{%
+ 	 \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+	 node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
+}%
+\end{tikzpicture}%
+\@pc at finalizegamehop%
+\endgroup%
+}
+\newcommandx*{\addstartgamehop}[2][1=\thepcstartgamecounter]{%
+\@pc at setupgamehop{#2}
+\begin{tikzpicture}[overlay]
+       \node[left=\@pcgamehoplength of gamenode#1] (tmpgamenode0) {};
+       \path[->,GAMEHOP-PATH-STYLE] (tmpgamenode0) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#1);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+\newcommandx*{\addendgamehop}[2][1=\thepcgamecounter]{%
+\@pc at setupgamehop{#2}
+\begin{tikzpicture}[overlay]
+       \node[right=\@pcgamehoplength of gamenode#1] (tmpgamenode#1) {};
+       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (tmpgamenode#1);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+\newcommandx*{\addbxgamehop}[3]{%
+\@pc at setupgamehop{#3}
+\begin{tikzpicture}[overlay]
+       \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE]] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+\newcommandx*{\addloopgamehop}[2][1=\thepcgamecounter]{%
+\@pc at setupgamehop{#2}
+\begin{tikzpicture}[overlay]
+       \node (looptemp1)  [right=0.5cm of gamenode#1] {};
+       \draw[->,GAMEHOP-PATH-STYLE] (gamenode#1) -- (looptemp1|-gamenode#1) -- node[right,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[left,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (looptemp1|-bgamenode#1)-- (bgamenode#1);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+
+
+%    \end{macrocode}
+%
+% \subsubsection{Game Descriptions}
+%
+%    \begin{macrocode}
+
+\newenvironment{gamedescription}[1][]{%
+\begingroup%
+\setkeys{pcgameproof}{#1}
+\renewcommand{\@withingamedescription}{true}%
+\@pc at ensureremember%
+\setcounter{pcgamecounter}{\@pcgameproofgamenr}%
+\setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}%
+\begin{description}%
+}{\end{description}\@pc at releaseremember\endgroup}
+
+\newcommandx*{\describegame}[1][1=]{%
+\addtocounter{pcgamecounter}{1}%
+\item[%
+\pcdraw{
+\gdef\i{\thepcgamecounter}%
+\node[inner sep=0.0em,outer sep=0, xshift=-1ex, yshift=0.5ex] (gamenode\i) {}; 
+}%
+\@pc at gametitle:]%
+\begingroup\setkeys{pcgamehop}{#1}%
+\ifthenelse{\equal{}{\@pcgamehophint}}
+  {}
+  {\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
+\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
+\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
+\draw[->,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,-\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE]  {\@pcgamehophint};
+}}%
+\ifthenelse{\equal{}{\@pcgamehopinhint}}
+  {}
+  {\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
+\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
+\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
+\draw[<-,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE]  {\@pcgamehopinhint};
+}%
+}%
+\endgroup%
+}
+%
+% \end{macrocode}
+%
+%
+%
+%    \begin{macrocode}
+%</cryptocode.sty>
+%    \end{macrocode}
+%\Finale
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/source/latex/cryptocode/cryptocode.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/cryptocode/cryptocode.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/cryptocode/cryptocode.ins	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/cryptocode/cryptocode.ins	2020-07-10 21:20:21 UTC (rev 55800)
@@ -0,0 +1,32 @@
+% cryptocode.ins generated using makedtx version 1.2 2020/6/20 20:14
+\input docstrip
+
+\preamble
+
+ cryptocode.dtx
+ Copyright 2020 Mittelbach, Arno
+
+ This work may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either version 1.3
+ of this license or (at your option) any later version.
+ The latest version of this license is in
+   http://www.latex-project.org/lppl.txt
+ and version 1.3 or later is part of all distributions of LaTeX
+ version 2005/12/01 or later.
+
+ This work has the LPPL maintenance status `maintained'.
+
+ The Current Maintainer of this work is Mittelbach, Arno.
+
+ This work consists of the files cryptocode.dtx and cryptocode.ins and the derived files 
+ cryptocode.sty and cryptocode.pdf.
+
+\endpreamble
+
+\askforoverwritefalse
+
+\generate{\file{cryptocode.sty}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{cryptocode.dtx}{cryptocode.sty,package}}
+}
+
+\endbatchfile

Added: trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2018-11-11.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2018-11-11.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2018-11-11.sty	2020-07-10 21:20:21 UTC (rev 55800)
@@ -0,0 +1,2040 @@
+ %% Copyright 2018 Arno Mittelbach
+  %
+  % This work may be distributed and/or modified under the
+  % conditions of the LaTeX Project Public License, either version 1.3
+  % of this license or (at your option) any later version.
+  % The latest version of this license is in
+  %   http://www.latex-project.org/lppl.txt
+  % and version 1.3 or later is part of all distributions of LaTeX
+  % version 2005/12/01 or later.
+  %
+  % This work has the LPPL maintenance status `maintained'.
+  % 
+  % The Current Maintainer of this work is Arno Mittelbach.
+  %
+  % This work consists of the files cryptocode.tex and cryptocode.sty
+  %
+  % Changelog
+  %
+  % 2016/11/30
+  % - changed \pckeystyle to ensure that subscripts on \sk and \pk are aligned the same 
+  %   before, $(\sk_R, \pk_R)$ had slightly misaligned subscripts due to Tex treating 
+  %   subscripts on composite objects with descenders differently than without.
+  %   see https://groups.google.com/forum/#!msg/comp.text.tex/IaXu_xBG06Q/CibRPH5GCAAJ
+  % - added \NAND
+  % - added pcmbox environment for matrices in pseudocode
+  %
+  % 2016/12/02
+  % - changed minheight for bbrbox environment to actually reflect a minimum height in tikz
+  %   the old minheight which added space at the bottom was preserved as addheight
+  % - added namepos middle for bbrbox
+  % - added pcfail
+  % - added valign to pseudocode to allow minipage vertical alignment
+  % - added \setgameproceduredefaultstyle
+  % - ensure line numbers are right aligned to allow for two digit linenumbers having the same width
+  %
+  % 2017/08/26
+  % - added \pcabort
+  % - better control whitespace for \pcif, \pcelse, \pcelseif
+  %
+  % 2017/10/02
+  % - side and oside support to \bbroracleqryto and \bbroracleqryfrom
+  % - add bottom to namepos in bbrbox
+  % - names for brrinput and bbroutput
+  % - angle for bbrloop
+  % - fix length for bbrinput
+  % - introduce hoffset for bbrinput
+  % 
+  % 2017/12/21
+  % - added \pcunless
+  %
+  % 2018/11/11
+  % replace obsolete l3regex
+  %
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{cryptocode}
+  [2018/11/11 v0.3.0 Cryptocode LaTeX package for typesetting pseudocode, algorithms and protocols as well as cryptographic proofs.]
+
+
+\def\hi{Hello, this is cryptocode.}
+\let\myDate\date
+
+\RequirePackage{amsmath}
+\RequirePackage{mathtools}
+%\usepackage{l3tl-analysis} % uncomment for debugging
+
+%%%
+% option modes
+\newif\ifpc at orderofgrowth
+\newif\ifpc at algorithmstyle
+\newif\ifpc at amsfonts
+\newif\ifpc at advantage
+\newif\ifpc at primitives
+
+%%%
+% 
+\DeclareOption{operators}{
+	\providecommand{\sample}{\hskip2.3pt{\gets\!\!\mbox{\tiny${\$}$\normalsize}}\,}
+	
+	\providecommand{\floor}[1]{\ensuremath{\left\lfloor #1\right\rfloor}}
+	\providecommand{\ceil}[1]{\ensuremath{\left\lceil #1\right\rceil}}
+	\providecommand{\Angle}[1]{\ensuremath{\left\langle #1\right\rangle}}
+	\providecommand{\abs}[1]{\ensuremath{\left\lvert #1 \right\rvert}}
+	\providecommand{\norm}[1]{\ensuremath{\left\|#1\right\|}}
+	\providecommand{\concat}{\ensuremath{\|}}
+	
+	\providecommand{\emptystring}{\ensuremath{\varepsilon}}
+}
+
+\DeclareOption{adversary}{
+	\providecommand{\pcadvstyle}[1]{\mathcal{#1}}
+	
+	\providecommand{\adv}{\ensuremath{\pcadvstyle{A}}}
+	\providecommand{\bdv}{\ensuremath{\pcadvstyle{B}}}
+	\providecommand{\cdv}{\ensuremath{\pcadvstyle{C}}}
+	\providecommand{\ddv}{\ensuremath{\pcadvstyle{D}}}
+	\providecommand{\mdv}{\ensuremath{\pcadvstyle{M}}}
+	\providecommand{\pdv}{\ensuremath{\pcadvstyle{P}}}
+	\providecommand{\rdv}{\ensuremath{\pcadvstyle{R}}}
+	\providecommand{\sdv}{\ensuremath{\pcadvstyle{S}}}
+}
+
+\DeclareOption{landau}{
+	\pc at orderofgrowthtrue
+	
+	\providecommand{\bigO}[1]{\ensuremath{\mathcal{O}\olrk{#1}}}
+        \providecommand{\smallO}[1]{\ensuremath{\text{o}\olrk{#1}}}
+        \providecommand{\bigOmega}[1]{\ensuremath{\Omega\olrk{#1}}}
+        \providecommand{\smallOmega}[1]{\ensuremath{\omega\olrk{#1}}}
+        \providecommand{\bigsmallO}[1]{\ensuremath{\Theta\olrk{#1}}}
+}
+
+\DeclareOption{probability}{
+	\pc at orderofgrowthtrue
+	\pc at amsfontstrue
+
+	\providecommand{\probname}{Pr}
+	\providecommand{\expectationname}{\ensuremath{\mathbb{E}}}
+	\providecommand{\supportname}{Supp}
+
+	\providecommand{\prob}[1]{\ensuremath{\operatorname{\probname}\elrk{#1}}}
+	\providecommand{\probsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\elrk{#2}}}
+	\providecommand{\condprob}[2]{\ensuremath{\prob{#1\,\left|\,#2\vphantom{#1}\right.}}}
+	\providecommand{\condprobsub}[3]{\ensuremath{\probsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+   
+	\providecommand{\expect}[1]{\ensuremath{\operatorname{\expectationname}\elrk{#1}}}
+	\providecommand{\expsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\elrk{#2}}}
+	\providecommand{\condexp}[2]{\ensuremath{\expect{#1\,\left|\,#2\vphantom{#1}\right.}}}
+	\providecommand{\condexpsub}[3]{\ensuremath{\expsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+
+	\providecommand{\supp}[1]{  \ensuremath{\operatorname{Supp}\olrk{#1}}}
+	
+	\providecommand{\entropy}[1]{\ensuremath{\operatorname{H}\olrk{#1}}}
+   	\providecommand{\condentropy}[2]{\ensuremath{\operatorname{H}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}    	
+	\providecommand{\minentropy}[1]{\ensuremath{\operatorname{H_\infty}\olrk{#1}}}
+    	\providecommand{\condminentropy}[2]{\ensuremath{\operatorname{H_\infty}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}    
+    	\providecommand{\condavgminentropy}[2]{\ensuremath{\operatorname{\tilde{H}_\infty}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}        	
+}
+
+\DeclareOption{sets}{
+        \pc at orderofgrowthtrue
+        \pc at amsfontstrue
+
+        \providecommand\NN{\mathbb{N}}
+        \providecommand\ZZ{\mathbb{Z}}
+        \providecommand\CC{\mathbb{C}}
+        \providecommand\QQ{\mathbb{Q}}
+        \providecommand\RR{\mathbb{R}}
+        \providecommand\PP{\mathbb{P}}
+        \providecommand\FF{\mathbb{F}}
+        \providecommand\GG{\mathbb{G}}            
+
+        \providecommand{\set}[1]{\ensuremath{\clrk{#1}}}
+	\providecommand{\sequence}[1]{\ensuremath{\olrk{#1}}}
+	\providecommand{\bin}{\ensuremath{\{0,1\}}}
+}
+
+\DeclareOption{noamsfonts}{
+	\pc at amsfontsfalse
+}
+
+
+\DeclareOption{notions}{
+	\providecommand{\pcnotionstyle}[1]{\ensuremath{\mathrm{#1}}}
+		
+	\providecommand{\indcpa}{\pcnotionstyle{IND\pcmathhyphen{}CPA}}
+	\providecommand{\indcca}{\pcnotionstyle{IND\pcmathhyphen{}CCA}}
+	\providecommand{\indccai}{\pcnotionstyle{IND\pcmathhyphen{}CCA1}}
+	\providecommand{\indccaii}{\pcnotionstyle{IND\pcmathhyphen{}CCA2}}
+	\providecommand{\priv}{\pcnotionstyle{PRIV}}
+	\providecommand{\ind}{\pcnotionstyle{IND}}
+	\providecommand{\indcda}{\pcnotionstyle{IND\pcmathhyphen{}CDA}}
+	\providecommand{\prvcda}{\pcnotionstyle{PRV\pcmathhyphen{}CDA}}
+	\providecommand{\prvrcda}{\pcnotionstyle{PRV\$\pcmathhyphen{}CDA}}
+	\providecommand{\kiae}{\pcnotionstyle{KIAE}}
+	\providecommand{\kdae}{\pcnotionstyle{KDAE}}
+	\providecommand{\mle}{\pcnotionstyle{MLE}}	
+	\providecommand{\uce}{\pcnotionstyle{UCE}}
+}
+
+\DeclareOption{logic}{
+        \providecommand{\AND}{\ensuremath{\mathrm{AND}}}
+        \providecommand{\OR}{\ensuremath{\mathrm{OR}}}
+        \providecommand{\NOR}{\ensuremath{\mathrm{NOR}}}
+        \providecommand{\NOT}{\ensuremath{\mathrm{NOT}}}
+        \providecommand{\NAND}{\ensuremath{\mathrm{NAND}}}        
+		\providecommand{\XOR}{\ensuremath{\mathrm{XOR}}}		
+		\providecommand{\XNOR}{\ensuremath{\mathrm{XNOR}}}		
+		\providecommand{\xor}{\ensuremath{\oplus}}        
+        \providecommand{\false}{\mathsf{false}} 
+        \providecommand{\true}{\mathsf{true}}
+}
+
+
+% Function Families
+\DeclareOption{ff}{
+	\pc at algorithmstyletrue
+
+	\providecommand{\kgen}{\pcalgostyle{KGen}}
+	\providecommand{\pgen}{\pcalgostyle{Pgen}}
+	\providecommand{\eval}{\pcalgostyle{Eval}}
+	\providecommand{\invert}{\pcalgostyle{Inv}}	
+	
+	\providecommand{\il}{\pcalgostyle{il}}
+	\providecommand{\ol}{\pcalgostyle{ol}}
+	\providecommand{\kl}{\pcalgostyle{kl}}
+	\providecommand{\nl}{\pcalgostyle{nl}}
+	\providecommand{\rl}{\pcalgostyle{rl}}
+}
+
+% Machine Model
+\DeclareOption{mm}{
+	\pc at algorithmstyletrue
+	
+	\providecommand{\pcmachinemodelstyle}[1]{\ensuremath{\mathsf{#1}}}
+
+        \providecommand{\CRKT}{\pcmachinemodelstyle{C}}
+        \providecommand{\TM}{\pcmachinemodelstyle{M}}
+        \providecommand{\PROG}{\pcmachinemodelstyle{P}}
+        
+        \providecommand{\uTM}{\pcmachinemodelstyle{UM}}
+        \providecommand{\uC}{\pcmachinemodelstyle{UC}}
+        \providecommand{\uP}{\pcmachinemodelstyle{UEval}}
+
+        \providecommand{\csize}{\pcmachinemodelstyle{size}}        
+        \providecommand{\tmtime}{\pcmachinemodelstyle{time}}
+        \providecommand{\ppt}{\pcalgostyle{PPT}}
+}
+
+\DeclareOption{advantage}{
+	\pc at advantagetrue
+}
+
+\DeclareOption{primitives}{
+	\pc at primitivestrue
+	\pc at algorithmstyletrue
+}
+
+\DeclareOption{events}{
+	\providecommand{\event}[1]{\ensuremath{\mathsf{#1}}}
+	\providecommand{\nevent}[1]{\ensuremath{\overline{\event{#1}}}}
+
+	\providecommand{\bad}{\ensuremath{\event{bad}}}
+}
+
+\DeclareOption{complexity}{
+	\providecommand{\pccomplexitystyle}[1]{\ensuremath{\mathsf{#1}}}
+
+	\providecommand{\npol}{\pccomplexitystyle{NP}}
+	\providecommand{\conpol}{\ensuremath{\mathsf{co}}\pccomplexitystyle{NP}}
+	\providecommand{\pol}{\pccomplexitystyle{P}}
+	\providecommand{\bpp}{\pccomplexitystyle{BPP}}
+	\providecommand{\ppoly}{\ensuremath{\pol/\mathrm{poly}}}
+
+	\providecommand{\AM}{\pccomplexitystyle{AM}}
+	\providecommand{\coAM}{\ensuremath{\mathsf{co}}\pccomplexitystyle{AM}}
+
+	\providecommand{\AC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{AC}}{\pccomplexitystyle{AC}^{#1}}}}
+	\providecommand{\NC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{NC}}{\pccomplexitystyle{NC}^{#1}}}}
+	\providecommand{\TC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{TC}}{\pccomplexitystyle{TC}^{#1}}}}
+}
+
+\DeclareOption{asymptotics}{
+	\pc at orderofgrowthtrue
+
+	\providecommand{\pcpolynomialstyle}[1]{\mathsf{#1}}
+	
+	\providecommand{\negl}[1][\secpar]{\ensuremath{\pcpolynomialstyle{negl}\ifthenelse{\equal{#1}{}}{}{\olrk{#1}}}}
+  	\providecommand{\poly}[1][\secpar]{\ensuremath{\pcpolynomialstyle{poly}\ifthenelse{\equal{#1}{}}{}{\olrk{#1}}}}
+	
+	\providecommand{\pp}{\ensuremath{\pcpolynomialstyle{p}}}
+	\providecommand{\qq}{\ensuremath{\pcpolynomialstyle{q}}}	
+}
+
+\DeclareOption{keys}{
+            \providecommand{\pckeystyle}[1]{\ensuremath{\mathsf{\protect\vphantom{p}#1}}}
+            
+            \providecommand{\pk}{\pckeystyle{pk}}
+            \providecommand{\vk}{\pckeystyle{vk}}
+            \providecommand{\sk}{\pckeystyle{sk}}
+            \providecommand{\key}{\pckeystyle{k}}
+            \providecommand{\hk}{\pckeystyle{hk}}
+            \providecommand{\gk}{\pckeystyle{gk}}
+            \providecommand{\fk}{\pckeystyle{fk}}
+            
+            \providecommand{\st}{\pckeystyle{st}}
+            \providecommand{\state}{\pckeystyle{state}}            
+}
+
+\DeclareOption{n}{
+	\providecommand{\secpar}{\ensuremath{n}}
+	\providecommand{\secparam}{\ensuremath{1^\secpar}}
+}
+
+\DeclareOption{lambda}{
+	\renewcommand{\secpar}{\ensuremath{\lambda}}
+	\renewcommand{\secparam}{\ensuremath{1^\secpar}}
+}
+
+\DeclareOption*{%
+	\PackageError{crypto code}{Unknown option ‘\CurrentOption’}%
+}
+
+\ExecuteOptions{n}
+
+\ProcessOptions\relax
+
+\RequirePackage{etex}
+
+%amsfonts
+\ifpc at amsfonts
+	\RequirePackage{amsfonts}
+\fi
+\RequirePackage{xcolor}
+\RequirePackage{calc}
+\RequirePackage{tikz}
+\usetikzlibrary{positioning,calc}
+\RequirePackage{ifthen}
+\RequirePackage{xargs}
+\RequirePackage{pgf}
+%\RequirePackage{mathabx}
+\RequirePackage{forloop}
+\RequirePackage{array}
+\RequirePackage{xparse}
+\RequirePackage{expl3}
+\RequirePackage{pbox}
+\RequirePackage{varwidth}
+\RequirePackage{suffix}
+\RequirePackage{etoolbox}
+\RequirePackage{environ}
+%\RequirePackage{xspace}
+\RequirePackage{xkeyval}
+
+\ifpc at advantage
+	\newcommand{\pcadvantagesuperstyle}[1]{\mathrm{\MakeLowercase{#1}}}
+	\newcommand{\pcadvantagesubstyle}[1]{#1}
+	\newcommandx*{\advantage}[3][3=(\secpar)]{\ensuremath{\mathsf{Adv}^{\pcadvantagesuperstyle{#1}}_{\pcadvantagesubstyle{#2}}#3}}
+\fi
+
+\ifpc at primitives	
+	% zero knowledge
+	\providecommand{\prover}{\pcalgostyle{P}}
+	\providecommand{\verifier}{\pcalgostyle{V}}
+	\providecommand{\nizk}{\pcalgostyle{NIZK}}
+	
+	% hash
+	\providecommand{\hash}{\pcalgostyle{H}}
+	\providecommand{\gash}{\pcalgostyle{G}}
+	\providecommand{\fash}{\pcalgostyle{F}}
+	
+	% encryption
+	\providecommand{\enc}{\pcalgostyle{Enc}}
+	\providecommand{\dec}{\pcalgostyle{Dec}}
+	
+	% signatures
+	\providecommand{\sig}{\pcalgostyle{Sig}}
+	\providecommand{\verify}{\pcalgostyle{Vf}}
+	
+	% obfuscation
+	\providecommand{\obf}{\pcalgostyle{O}}
+	\providecommand{\iO}{\pcalgostyle{iO}}
+	\providecommand{\diO}{\pcalgostyle{diO}}
+	
+	% PRF, PRG
+	\providecommand{\prf}{\pcalgostyle{PRF}}
+	\providecommand{\prg}{\pcalgostyle{PRG}}
+	
+	% Mac
+	\providecommand{\mac}{\pcalgostyle{MAC}}
+	
+	% puncture
+	\providecommand{\puncture}{\pcalgostyle{Puncture}}
+	
+	% Misc
+	\providecommand{\source}{\pcalgostyle{S}}
+	\providecommand{\predictor}{\pcalgostyle{P}}
+	\providecommand{\sam}{\pcalgostyle{Sam}}
+	\providecommand{\dist}{\pcalgostyle{D}}
+	\providecommand{\distinguisher}{\pcalgostyle{Dist}}
+	\providecommand{\simulator}{\pcalgostyle{Sim}}
+	\providecommand{\ext}{\pcalgostyle{Ext}}
+	\providecommand{\extractor}{\ext}	
+\fi
+
+%%
+% math hyphen
+\mathchardef\pcmathhyphen ="2D
+
+%%%
+% order of growth helper
+\ifpc at orderofgrowth
+\providecommand{\olrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus 0.5mu\left(\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right)\fi}
+
+\providecommand{\elrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus0.5mu\left[\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right]\fi}
+
+\providecommand{\clrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus0.5mu\left\{\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right\}\fi}
+\fi
+
+\ifpc at algorithmstyle
+	\providecommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
+\fi
+
+%%%
+% create command to measure width of align
+%
+\newcommand{\@settowidthofalign}[2]{%
+  \setbox\z@=\vbox{\@pseudocodecodesize
+    \begin{flalign*}
+    #2
+    \ifmeasuring@\else\global\let\got at maxcolwd\maxcolumn at widths\fi
+    \end{flalign*}
+  }%
+  \begingroup
+  \def\or{+}\edef\x{\endgroup#1=\dimexpr\got at maxcolwd\relax}\x}
+
+\newcommand{\@settowidthofaligned}[2]{%
+\settowidth{#1}{\@pseudocodesubcodesize$\begin{aligned}#2\end{aligned}$}}
+
+% check for draft mode
+\def\@pc at ifdraft{\ifdim\overfullrule>\z@
+  \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
+
+% run stuff in an empty box
+\newcommand{\@pcexecuteblindly}[1]{%
+ \setbox\z@=\vbox{#1 }}
+
+% copy label command
+\AtBeginDocument{
+	\let\pc at original@label\ltx at label
+}
+
+
+%%%%%%
+\newcommand*{\@pc at globaladdtolength}[2]{%
+\addtolength{#1}{#2}%
+\global#1=#1\relax}
+
+\newcommand*{\@pc at globalsetlength}[2]{%
+\setlength{#1}{#2}%
+\global#1=#1\relax}
+
+
+
+%%%%%
+% spaces before and after pseudo codes (left and right)
+\providecommand{\beforepcskip}{2pt}
+\providecommand{\afterpcskip}{0pt}
+
+%%%
+% a global counter of the number of times the pseudocode command was triggered
+\newcounter{@pc at global@pc at cnt}
+\newcounter{@pc at global@pc at nestcnt}
+
+%%%
+% Fix hyperref package.. gnarl http://tex.stackexchange.com/questions/130319/incompatibility-between-etoolbox-and-hyperref
+\providecommand{\pcfixhyperref}{
+\global\let\textlabel\label
+\global\let\pc at original@label\textlabel
+%\global\let\pc at original@label\relax
+%\global\let\label\relax
+}
+
+\newcounter{@spacecounter}
+\providecommand{\spacetoindent}{1}
+\newenvironment{@withspaces}
+ {\obeyspaces\begingroup\lccode`~=` \lowercase{\endgroup\let~}\ }
+ {}
+
+%%%%%%%%%%%%%%
+% a latex3 string substitution.
+\ExplSyntaxOn
+\tl_new:N \l_pc_strsub_input_tl
+\tl_new:N \l_pc_strsub_search_tl
+\tl_new:N \l_pc_strsub_replace_tl
+
+\NewDocumentCommand{\@pc at stringsubstitution}{mmm}
+ {
+  \tl_set:Nn \l_pc_strsub_input_tl { #1 }
+  \tl_set:Nn \l_pc_strsub_search_tl { #2 }
+  \tl_set:Nn \l_pc_strsub_replace_tl { #3 }
+%  \tl_show_analysis:N  \l_pc_strsub_input_tl % uncomment for debugging
+%  \tl_show_analysis:N  \l_pc_strsub_search_tl % uncomment for debugging
+%  \tl_show_analysis:N  \l_pc_strsub_replace_tl % uncomment for debugging
+   \regex_replace_all:nnN
+      { (\W)\u{l_pc_strsub_search_tl} } %only match if keyword does not have a word character preceding
+      { \1\u{l_pc_strsub_replace_tl} }
+      \l_pc_strsub_input_tl
+      %  \tl_show_analysis:N \l_tmpa_tl % uncomment for debugging
+      \tl_use:N \l_pc_strsub_input_tl    
+ }
+ 
+ % same as \@pc at stringsubstitution but without requiring the extra non word character
+ \NewDocumentCommand{\@pc at spacesubstitution}{mmm}
+ {
+  \tl_set:Nn \l_pc_strsub_input_tl { #1 }
+  \tl_set:Nn \l_pc_strsub_search_tl { #2 }
+  \tl_set:Nn \l_pc_strsub_replace_tl { #3 }
+%  \tl_show_analysis:N  \l_pc_strsub_input_tl % uncomment for debugging
+%  \tl_show_analysis:N  \l_pc_strsub_search_tl % uncomment for debugging
+%  \tl_show_analysis:N  \l_pc_strsub_replace_tl % uncomment for debugging
+   \regex_replace_all:nnN
+      { \u{l_pc_strsub_search_tl} } 
+      { \u{l_pc_strsub_replace_tl} }
+      \l_pc_strsub_input_tl
+      %  \tl_show_analysis:N \l_tmpa_tl % uncomment for debugging
+      \tl_use:N \l_pc_strsub_input_tl    
+ }
+ 
+\NewDocumentCommand{\@pc at centercolifnec}{m}%
+{%
+#1%
+}
+ 
+ 
+ 
+\ExplSyntaxOff
+
+%%%%%%%%
+% line numbers
+%%%%%%%%
+% The following commands handle line numbering within the pseudocode command. The
+% pseudocode command itself does need to do some counter magic
+\newcounter{pclinenumber}
+\newcounter{Hpclinenumber} % make hyperref happy
+\newcounter{@pclinenumber}
+\newcounter{H at pclinenumber} % make hyperref happy
+\newcounter{@pclinenumbertmp}
+\newcounter{pcgamecounter}
+\newcounter{Hpcgamecounter}
+\newcounter{pcrlinenumber}
+\newcounter{Hpcrlinenumber}
+\newcounter{@pcrlinenumbertmp}
+
+% separators
+\providecommand{\pclnseparator}{:}
+\providecommand{\pcrlnseparator}{\hspace{1pt}}
+
+% spacing for linenumbers
+\providecommand{\pclnspace}{0pt}
+\providecommand{\pclnrspace}{5pt}
+
+\renewcommand{\the at pclinenumber}{\thepclinenumber}
+\providecommand{\@pcln}{%
+\refstepcounter{@pclinenumber}%
+\stepcounter{H at pclinenumber}%
+}
+
+% left align line numbers
+\providecommand{\pcln}[1][]{%
+\refstepcounter{pclinenumber}%
+\stepcounter{Hpclinenumber}%
+\ifthenelse{\equal{#1}{}}{}{%
+%keep hyperref happy
+\ifmeasuring@\else\pc at original@label{#1}\fi%
+}%
+\ifthenelse{\value{pclinenumber}<10}{\hspace{1ex}}{}%
+\hspace{\pclnspace}\text{\scriptsize\arabic{pclinenumber}}\pclnseparator\quad}%
+
+% allow to skip numbering single lines if linenumbering=on 
+\providecommand{\pcnoln}{%
+}
+
+% right align line numbers (same counter)
+\providecommand{\pclnr}{%
+\refstepcounter{pclinenumber}%
+\quad\text{\scriptsize\pcrlnseparator\arabic{pclinenumber}}\hspace{5pt}}
+
+% right align line numbers different counter
+\providecommand{\pcrln}{
+\refstepcounter{pcrlinenumber}%
+\stepcounter{Hpcrlinenumber}%
+\text{\scriptsize\pcrlnseparator\arabic{pcrlinenumber}}\hspace{\pclnrspace}}
+
+
+%%%
+% indentation
+\newlength{\@pcindentwidth}
+\providecommand{\pcind}[1][1]{%
+\setlength{\@pcindentwidth}{\widthof{\ensuremath{\quad}}*#1}%
+\ensuremath{\mathmakebox[\@pcindentwidth]{}}}
+
+
+% create length
+\newlength{\@pc at minipage@length}
+\newlength{\@pc at alt@minipage at length}
+
+% backward games
+\newcommand{\@withingame}{false}
+\newcommand{\@withinbxgame}{false}
+\newcommand{\@bxgameheader}{}
+\newcommand{\@withingamedescription}{false}
+
+
+%%%%%%%%%%%%
+% The pseudocode Command
+%%%%%
+\newlength{\@pc at length@tmp at width@vstack}
+
+
+\newcommand{\@pc at beginnewline}{%
+\@pseudocodecodeatbeginline\@pseudocodelinenumber\@pc at and\@pcln%
+%checkspace
+\ifthenelse{\equal{\@pseudocodespace}{auto}}%
+{\expandafter\pcind\expandafter[\value{@pc at indentationlevel}]}%
+{}%
+%reset column counter
+\setcounter{pccolumncounter}{2}%
+%beginmode
+\@pc at modebegin}
+\newcommand{\@pc at and}{&}
+\newcommand{\@pc at and@wrap at end}{\@pc at modeend&\@pseudocodecodeatendline}
+\newcommand{\@pc at and@wrap at start}{\@pc at beginnewline}
+\newcommand{\pctabname}{>}
+\newcommand{\pcdbltabname}{<}
+\newcommand{\pcindentname}{t}
+
+
+
+\newcommand*\@pseudocodehead{}
+\newcommand*\@pseudocodewidth{}
+\newcommand*\@pseudocodexshift{0pt}
+\newcommand*\@pseudocodeyshift{0pt}
+\newcommand*\@pseudocodelinenumber{}
+\newcommand*\@pseudocodebeforeskip{0ex}
+\newcommand*\@pseudocodeafterskip{0ex}
+\newcommand*\@pseudocodelnstart{0}
+\newcommand*\@pseudocodelnstartright{0}
+\newcommand*\@pseudocodesyntaxhighlighting{}
+\newcommand*\@pseudocodenodraft{false}
+\newcommand*\@pseudocodecolspace{} % empty per default, use length,
+
+\newcommand*\@pseudocodeheadlinesep{0em}
+\newcommand*\@pseudocodebodylinesep{-0.5\baselineskip}
+
+\newcommand*\@pseudocodecolsep{0em}
+\newcommand*\@pseudocodeaddtolength{2pt}
+
+\newcommand*\@pseudocodecodeatbeginline{}
+\newcommand*\@pseudocodecodeatendline{}
+\newcommand*\@pseudocodecodejot{0em}
+\newcommand*\@pseudocodecodesize{\small}
+\newcommand*\@pseudocodesubcodesize{\footnotesize}
+
+\newcommand*\@pseudocodeminipagealign{t}
+
+%%%%%%%%%%%%%%
+% Define keywords for the automatic syntax highlighting
+% the accompanying add provides additional keywords.
+% The space version for automatic spacing
+\newcommand*\@pseudocodekeywordsindent{for ,foreach ,if ,repeat ,while }
+\newcommand*\@pseudocodekeywordsunindent{endfor,endforeach,fi,endif,until ,endwhile}
+\newcommand*\@pseudocodekeywordsuninindent{else if,elseif, else}
+\newcommand*\@pseudocodekeywords{return ,{ do }, in ,new ,null ,null,true ,true,{ to },false ,false,{ then },done ,done}
+\newcommand*\@pseudocodeaddkeywords{}
+\newcommand*\@pseudocodealtkeywords{}
+\begin{@withspaces}
+\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}
+\end{@withspaces}
+
+
+\define at key{pseudocode}{beginline}[]{\renewcommand*\@pseudocodecodeatbeginline{#1}}
+\define at key{pseudocode}{endline}[]{\renewcommand*\@pseudocodecodeatendline{#1}}
+\define at key{pseudocode}{jot}[0em]{\renewcommand*\@pseudocodecodejot{#1}}
+\define at key{pseudocode}{codesize}[\small]{\renewcommand*\@pseudocodecodesize{#1}}
+\define at key{pseudocode}{subcodesize}[\small]{\renewcommand*\@pseudocodesubcodesize{#1}}
+\define at key{pseudocode}{head}[]{\renewcommand*\@pseudocodehead{#1}}
+\define at key{pseudocode}{width}[]{\renewcommand*\@pseudocodewidth{#1}}
+\define at key{pseudocode}{valign}[t]{\renewcommand*\@pseudocodeminipagealign{#1}}
+\define at key{pseudocode}{xshift}[]{\renewcommand*\@pseudocodexshift{#1}}
+\define at key{pseudocode}{yshift}[]{\renewcommand*\@pseudocodeyshift{#1}}
+\define at key{pseudocode}{colspace}[]{\renewcommand*\@pseudocodecolspace{#1}}
+\define at key{pseudocode}{linenumbering}[on]{\ifthenelse{\equal{#1}{on}}{\renewcommand*\@pseudocodelinenumber{\pcln}}{\renewcommand*\@pseudocodelinenumber{}}}
+\define at key{pseudocode}{beforeskip}[]{\renewcommand*\@pseudocodebeforeskip{#1}}
+\define at key{pseudocode}{afterskip}[]{\renewcommand*\@pseudocodeafterskip{#1}}
+\define at key{pseudocode}{lnstart}[0]{\renewcommand*\@pseudocodelnstart{#1}}
+\define at key{pseudocode}{lnstartright}[0]{\renewcommand*\@pseudocodelnstartright{#1}}
+\define at key{pseudocode}{colsep}[0em]{\renewcommand*\@pseudocodecolsep{#1}}
+\define at key{pseudocode}{headlinesep}[0em]{\renewcommand*\@pseudocodeheadlinesep{#1}}
+\define at key{pseudocode}{bodylinesep}[0em]{\renewcommand*\@pseudocodebodylinesep{#1}}
+\define at key{pseudocode}{addtolength}[2pt]{\renewcommand*\@pseudocodeaddtolength{#1}}
+\define at key{pseudocode}{mode}[math]{%
+\ifthenelse{\equal{#1}{text}}{%
+\renewcommand*\@pc at modebegin{\begin{varwidth}{\textwidth}%
+%introduce line magic for text mode
+\let\@pc at lb\\%
+\renewcommandx*{\\}[2][1=,2=]{\@pc at modeend\@pc at and \@pseudocodecodeatendline\ifthenelse{\equal{####1}{}}{\@pc at lb}{\@pc at lb[####1]}####2 \@pc at beginnewline}%
+\def\pclb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+\def\pcolb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+}%
+\renewcommand*\@pc at modeend{\end{varwidth}}
+}{}%
+}
+\define at key{pseudocode}{nodraft}[true]{\renewcommand*\@pseudocodenodraft{#1}}
+\define at key{pseudocode}{keywords}[]{\renewcommand*\@pseudocodekeywords{#1}}
+\define at key{pseudocode}{keywordsindent}[]{\renewcommand*\@pseudocodekeywordsindent{#1}}
+\define at key{pseudocode}{keywordsunindent}[]{\renewcommand*\@pseudocodekeywordsunindent{#1}}
+\define at key{pseudocode}{keywordsuninindent}[]{\renewcommand*\@pseudocodekeywordsuninindent{#1}}
+\define at key{pseudocode}{addkeywords}[]{\renewcommand*\@pseudocodeaddkeywords{#1}}
+\define at key{pseudocode}{altkeywords}[]{\renewcommand*\@pseudocodealtkeywords{#1}}
+\define at key{pseudocode}{syntaxhighlight}[]{\renewcommand*\@pseudocodesyntaxhighlighting{#1}}
+
+\newcommand{\@pc at modebegin}{}
+\newcommand{\@pc at modeend}{}
+\newcommand{\@pc at thecontent}{}
+
+\newcommand{\@pc at syntaxhighlight}[1]{%
+\ifthenelse{\equal{\@pseudocodesyntaxhighlighting}{auto}}{%
+\def\@shtmp{#1}% first step
+\ifthenelse{\equal{\@pseudocodespace}{keep}}
+   {\edef\@tmpkeywords{\@pseudocodekeywordsspace,\@pseudocodeaddkeywords}}
+   {\ifthenelse{\equal{\@pseudocodespace}{auto}}
+      {\edef\@tmpkeywords{\@pseudocodekeywords,\@pseudocodeaddkeywords}}
+      {\edef\@tmpkeywords{\@pseudocodekeywords,\@pseudocodekeywordsindent,\@pseudocodekeywordsunindent,\@pseudocodekeywordsuninindent,\@pseudocodeaddkeywords}}}
+\foreach \@pckw in \@tmpkeywords{%
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlight\expandafter{\@pckw}}}%
+}% alt keywords
+}%
+\foreach \@pckw in \@pseudocodealtkeywords{%
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at althighlight\expandafter{\@pckw}}}%
+}%
+}%
+%%%%
+% if automatic spacing
+\ifthenelse{\equal{\@pseudocodespace}{auto}}
+{%
+\foreach \@pckw in \@pseudocodekeywordsindent{% indentation keywords
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightindent\expandafter{\@pckw}}}%
+}}%
+\foreach \@pckw in \@pseudocodekeywordsunindent{% unindentation keywords
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightunindent\expandafter{\@pckw}}}%
+}}%
+\foreach \@pckw in \@pseudocodekeywordsuninindent{% uninindentation keywords
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightuninindent\expandafter{\@pckw}}}%
+}}%
+}{}%
+% return result
+\@shtmp%
+}{#1}% nothing to highlight
+}
+
+\newcommand{\@pc at highlight}[1]{%
+\ifthenelse{\equal{\@pseudocodespace}{keep}}
+    {\highlightkeyword[]{#1}}%
+    {\highlightkeyword[]{\@pc at spacesubstitution{#1}{ }{~}}}%
+}
+
+\newcommand{\@pc at highlightindent}[1]{%
+\@pc at increaseindent\@pc at highlight{#1}%
+}
+
+\newcommand{\@pc at highlightunindent}[1]{%
+\@pc at decreaseindent\@pc at highlight{#1}%
+}
+
+\newcommand{\@pc at highlightuninindent}[1]{%
+\@pc at tmpdecreaseindent\@pc at highlight{#1}%
+}
+
+\newcommand{\@pc at althighlight}[1]{%
+\ifthenelse{\equal{\@pseudocodespace}{keep}}
+    {\highlightaltkeyword{#1}}%
+    {\highlightaltkeyword{\@pc at spacesubstitution{#1}{ }{~}}}%
+}
+
+\newcommand{\@pc at colspace}{}
+
+%%%%%%%%%%%%%%%%%
+% Allow for spacing
+\newcommand{\@withinspaces}{false}%
+\newcommand{\@keepspaces}{%
+\renewcommand{\@withinspaces}{true}\@withspaces%
+}
+\newcommand{\@pc at endgroupafterpc}{}
+
+\newcommand*\@pseudocodespace{}
+\define at key{pcspace}{space}[]{\ifthenelse{\equal{#1}{keep}}{\@keepspaces}{}\renewcommand*\@pseudocodespace{#1}}
+
+%%% automatic indentation
+\newcounter{@pc at indentationlevel}
+\newcommand{\@pc at increaseindent}{\addtocounter{@pc at indentationlevel}{1}}
+\newcommand{\@pc at decreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}\addtocounter{@pc at indentationlevel}{-1}}
+\newcommand{\@pc at tmpdecreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}}
+
+\newcounter{pccolumncounter}
+\setcounter{pccolumncounter}{2}
+
+% store original halign
+\let\@pc at halign\halign%
+
+%% Check if the pseudocode command is called with an optional argument
+\providecommand{\pseudocode}{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+\@ifnextchar[%]
+  {\@pseudocodeA}%
+  {\@pseudocode[]}%
+}
+
+\def\@pseudocodeA[#1]{%
+\setkeys*{pcspace}{#1}%test if there is a space assignment within the keys .. make the necessary arrangements and call the actual method
+\@pseudocode[#1]%
+}
+
+\def\@pseudocode[#1]#2{%
+\begingroup%
+\setkeys{pseudocode}[space]{#1}%ignore the space key.
+% check draft mode and disable syntax highlighting
+\@pc at ifdraft{\ifthenelse{\equal{\@pseudocodenodraft}{true}}{}{\renewcommand\@pseudocodesyntaxhighlighting{}}}{}%
+%
+%
+\addtocounter{@pc at global@pc at nestcnt}{1}%
+% allow for tikz usage
+\@pc at ensureremember%
+%
+% create tabbing command
+\ifcsname \pctabname\endcsname%
+\expandafter\renewcommand\csname \pctabname\endcsname{\@pc at modeend&\@pc at colspace\@pc at modebegin}%
+\else%
+\expandafter\newcommand\csname \pctabname\endcsname{\@pc at modeend&\@pc at colspace\@pc at modebegin}%
+\fi%
+\ifcsname \pcdbltabname\endcsname%
+\expandafter\renewcommand\csname \pcdbltabname\endcsname{\@pc at modeend&&\@pc at colspace\@pc at modebegin}%
+\else%
+\expandafter\newcommand\csname \pcdbltabname\endcsname{\@pc at modeend&&\@pc at colspace\@pc at modebegin}%
+\fi%
+% create colspace command if necessary (must be empty for multicolumns
+\ifthenelse{\equal{\@pseudocodecolspace}{}}
+ {}
+ {\renewcommand{\@pc at colspace}{\hspace{\@pseudocodecolspace}}}%
+%
+%adjust row width
+\addtolength{\jot}{\@pseudocodecodejot}%
+% create indent command
+\expandafter\let\csname \pcindentname\endcsname\pcind%
+%
+%store and wrap (do syntax highlighting) argument 
+\renewcommand{\@pc at thecontent}{\@pc at and@wrap at start\@pc at syntaxhighlight{#2}\@pc at and@wrap at end}%
+%
+%take care of counters
+\stepcounter{@pc at global@pc at cnt}%
+\setcounter{pclinenumber}{\@pseudocodelnstart}%
+\setcounter{pcrlinenumber}{\@pseudocodelnstartright}%
+\setlength{\@pc at minipage@length}{0pt}%
+\setlength{\@pc at alt@minipage at length}{0pt}%
+\setcounter{@pclinenumbertmp}{\value{pclinenumber}}%
+\setcounter{@pcrlinenumbertmp}{\value{pcrlinenumber}}%
+%reset column counter
+\setcounter{pccolumncounter}{2}%
+%
+% vertical space
+\vspace{\@pseudocodeyshift}%
+%\setlength{\abovedisplayskip}{0pt}%
+%\setlength{\belowdisplayskip}{0pt}%
+%\setlength{\abovedisplayshortskip}{0pt}%
+%\setlength{\belowdisplayshortskip}{0pt}%
+%
+%
+% line magic
+\ifthenelse{\value{@pc at global@pc at nestcnt}=1}{%
+\let\@pc at halign\halign%
+\newenvironment{pcmbox}{\let\halign\@pc at halign}{}%
+\def\halign{%
+\renewcommand{\label}[1]{\ifmeasuring@\else\pc at original@label{####1}\fi}%
+\let\@pc at lb\\%
+\renewcommandx*{\\}[2][1=,2=]{\@pc at modeend\@pc at and\@pseudocodecodeatendline \ifthenelse{\equal{####1}{}}{\@pc at lb}{\@pc at lb[####1]}####2 \@pc at beginnewline}%
+\def\pclb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+\@pc at halign}%
+}{}%
+%
+%align column separation
+\renewcommand*{\minalignsep}{\@pseudocodecolsep}%
+%
+% if no width is set compute width and store in circuitlength
+\ifthenelse{\equal{\@pseudocodewidth}{}}{%
+% compute length of pseudocode
+\ifthenelse{\value{@pcsubprogstep}=0}{%
+\@settowidthofalign{\@pc at minipage@length}{\@pc at thecontent}%
+}{%
+\@settowidthofaligned{\@pc at minipage@length}{\@pc at thecontent}%	
+}%
+%compute length of header
+\addtolength{\@pc at alt@minipage at length}{\widthof{\@pseudocodehead}}%
+% use header length if longer and add some points for good measure
+\ifdim\@pc at alt@minipage at length>\@pc at minipage@length%
+\setlength{\@pc at minipage@length}{\@pc at alt@minipage at length}%
+\fi%
+\addtolength{\@pc at minipage@length}{\@pseudocodeaddtolength}%
+}{\addtolength{\@pc at minipage@length}{\@pseudocodewidth}}%
+% reset counter
+\setcounter{pclinenumber}{\value{@pclinenumbertmp}}%
+\setcounter{pcrlinenumber}{\value{@pcrlinenumbertmp}}%
+\setcounter{@pc at indentationlevel}{0}%
+% begin actual output
+%
+%
+%do the actual mini page
+\hspace{\@pseudocodexshift}%
+\begin{minipage}[\@pseudocodeminipagealign]{\@pc at minipage@length}%
+\ifthenelse{\value{@pcsubprogstep}=0}{%
+\pc at display@pseudocode{\@pseudocodehead}{\@pc at thecontent}%
+}{% if sub procedure
+\pc at display@subcode{\@pseudocodehead}{\@pc at thecontent}%
+}%
+\end{minipage}%
+\hspace{\afterpcskip}%
+% tikz usage
+\@pc at releaseremember%
+\addtocounter{@pc at global@pc at nestcnt}{-1}%
+\endgroup%
+% close spacing and potentially a single group generated by the space tester
+\ifthenelse{\equal{\@withinspaces}{true}}{\end at withspaces}{}%
+\endgroup%
+}
+
+\newcommand{\@pc at gameheader}[2]{%
+\tikz{\gdef\i{\thepcgamecounter}%
+\node[anchor=base,#2,inner sep=0.05em,outer sep=0] (gamenode\i) {#1\vphantom{$\sum^A_{A_b}$}}; 
+\ifthenelse{\equal{\@withinbxgame}{true}}
+  {\node[draw,anchor=base, above=0.1cm of gamenode\i] (bgamenode\i) {\@bxgameheader\vphantom{$\sum^A_{A_b}$}};}
+  {}%
+}%
+}
+
+\let\pclb\relax
+%
+\newcommand{\pc at display@pseudocode}[2]{%
+\ifthenelse{\equal{#1}{}}{\vspace{-1\baselineskip}\@pseudocodecodesize}{%
+\ifthenelse{\equal{\@withingame}{true}}{%
+\@pc at gameheader{#1}{}\ifthenelse{\equal{\@pc at secondheader}{true}}{\addtocounter{pcgamecounter}{1}\@pc at gameheader{#1}{draw}}{}%
+\vspace{0.2em}%
+}{#1\vphantom{$\sum^A_{A_b}$}}%
+\vspace{\@pseudocodeheadlinesep}\hrule\vspace{\@pseudocodebodylinesep}\@pseudocodecodesize}%
+\begin{flalign*}#2\end{flalign*}%
+}
+
+
+\newcommand{\pc at display@subcode}[2]{%
+\begingroup%
+\ifthenelse{\equal{#1}{}}{}{#1\vphantom{$\sum^A_{A_b}$} %
+\vspace{\@pseudocodeheadlinesep}\hrule \vspace{\baselineskip}\vspace{\@pseudocodebodylinesep}}%
+\@pseudocodesubcodesize%
+$\begin{aligned}#2\end{aligned}$%
+\endgroup%
+}
+
+
+\newcommand{\@pc at gettikzwidth}[2]{ % #1 = width, #2 = height
+ \pgfextractx{\@tempdima}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
+ {\pgfpointanchor{current bounding box}{north east}}}
+ \global#1=\@tempdima
+ \pgfextracty{\@tempdima}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
+ {\pgfpointanchor{current bounding box}{north east}}}
+ \global#2=\@tempdima
+}
+
+
+%%%%%%%%%%%%%%%%%%%
+% remember pictues
+\newcounter{@pc at remember}
+
+\newcommand{\@pc at ensureremember}{%
+\ifthenelse{\value{@pc at remember}=0}{\tikzstyle{every picture}+=[remember picture]}{}%
+\addtocounter{@pc at remember}{1}}
+
+\newcommand{\@pc at releaseremember}{%
+\addtocounter{@pc at remember}{-1}%
+\ifthenelse{\value{@pc at remember}=0}{\tikzstyle{every picture}-=[remember picture]}{}%
+}
+
+
+%%%%%%%%%%%%%%%%%%%
+% pcimage
+\newenvironment{pcimage}{%
+\begingroup\@pc at ensureremember%
+}{%
+\@pc at releaseremember\endgroup%
+}
+
+\newcommand*\@pcnodecontent{}
+\newcommand*\@pcnodestyle{}
+\newcommand*\@pcnodedraw{}
+\define at key{pcnode}{content}[]{\renewcommand*\@pcnodecontent{#1}}
+\define at key{pcnode}{style}[]{\renewcommand*\@pcnodestyle{#1}}
+\define at key{pcnode}{draw}[]{\renewcommand*\@pcnodedraw{#1}}
+
+\newcommandx*{\pcnode}[2][2=]{%
+\begingroup\setkeys{pcnode}{#2}%
+\tikzset{PCNODE-STYLE/.style/.expand once=\@pcnodestyle}%
+\begin{tikzpicture}[inner sep=0ex,baseline=0pt]%
+\node[PCNODE-STYLE] (#1) {\@pcnodecontent}; %
+\end{tikzpicture}%
+\ifdefempty{\@pcnodedraw}{}{%
+\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt]\@pcnodedraw\end{tikzpicture}
+}%
+\endgroup}
+
+\newcommandx*{\pcdraw}[2][2=]{%
+\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#2]
+#1
+\end{tikzpicture}}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%
+% Reductions
+\newcommand{\@bb at lastbox}{}
+\newcommand{\@bb at lastoracle}{}
+\newcommand{\@bb at lastchallenger}{}
+
+
+\newlength{\@bb at message@hoffset}
+\newlength{\@bb at query@hoffset}
+\newlength{\@bb at oraclequery@hoffset}
+\newlength{\@bb at challengerquery@hoffset}
+
+\newcounter{@bb at oracle@cnt}
+\newcounter{@bb at oracle@nestcnt}
+\newcounter{@bb at challenger@cnt}
+\newcounter{@bb at challenger@nestcnt}
+
+\newcounter{@bb at env@nestcnt}
+
+\newcommand{\bbroraclenodenameprefix}{ora-}
+\newcommand{\bbrchallengernodenameprefix}{challenger-}
+\newcommand{\bbrenvnodenameprefix}{env-}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Black Box Reduction Environment
+\newenvironmentx{bbrenv}[3][1=0pt,3=0pt]{%
+\addtocounter{@bb at env@nestcnt}{1}%
+\renewcommand{\@bb at lastbox}{#2}%
+%
+% reset lengths
+\@pc at globalsetlength{\@bb at message@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at query@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at oraclequery@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at challengerquery@hoffset}{0pt}%
+%
+%reset oracle counter and oracle query offset
+\ifthenelse{\value{@bb at oracle@nestcnt}=0}
+ {\setcounter{@bb at oracle@cnt}{0}}{}%
+\ifthenelse{\value{@bb at challenger@nestcnt}=0}
+  {\setcounter{@bb at challenger@cnt}{0}}{}%
+%
+\def\@bbendskip{#3}%
+\vspace{#1}%
+\ifthenelse{\value{@bb at env@nestcnt}=1}
+ {\@pc at ensureremember%
+\begin{tikzpicture}
+}{\tikz\bgroup}
+}{%
+\ifthenelse{\value{@bb at env@nestcnt}=1}
+{\end{tikzpicture}%
+\@pc at releaseremember%
+}{\egroup}%
+\vspace{\@bbendskip}%
+\addtocounter{@bb at env@nestcnt}{-1}%
+% reset lengths
+\@pc at globalsetlength{\@bb at message@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at query@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at oraclequery@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at challengerquery@hoffset}{0pt}%
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% black box reduction box
+% option keys
+\newcommand*\bbrboxname{}
+\newcommand*\bbrboxnamepos{right}
+\newcommand*\bbrboxnamestyle{}
+\newcommand*\@bbrboxnamepos{below right=0.5ex and -0.5ex of \@bb at lastbox.north east,anchor=north east}
+\newcommand*\bbrboxabovesep{\baselineskip}
+\newcommand*\@bbrboxnameposoffset{below left=\bbrboxabovesep of phantomname.south west}
+\newcommand*\bbrboxstyle{draw}
+\newcommand*\bbrboxafterskip{}
+\newcommand*\bbrboxminheight{0cm}
+\newcommand*\bbrboxminwidth{2cm}
+\newcommand*\bbrboxxshift{0cm}
+\newcommand*\bbrboxyshift{0cm}
+\define at key{bbrbox}{abovesep}[]{\renewcommand*\bbrboxabovesep{#1}}
+\define at key{bbrbox}{name}[]{\renewcommand*\bbrboxname{#1}}
+\define at key{bbrbox}{namestyle}[]{\renewcommand*\bbrboxnamestyle{#1}}
+\define at key{bbrbox}{namepos}[]{\renewcommand*\bbrboxnamepos{#1}}
+\define at key{bbrbox}{style}[draw]{\renewcommand*\bbrboxstyle{#1}}
+\define at key{bbrbox}{minwidth}[]{\renewcommand*\bbrboxminwidth{#1}}
+\define at key{bbrbox}{addheight}[]{\renewcommand*\bbrboxafterskip{#1}}
+\define at key{bbrbox}{minheight}[]{\renewcommand*\bbrboxminheight{#1}}
+\define at key{bbrbox}{xshift}[]{\renewcommand*\bbrboxxshift{#1}}
+\define at key{bbrbox}{yshift}[]{\renewcommand*\bbrboxyshift{#1}}
+
+
+\NewEnviron{bbrbox}[1][]{%
+\setkeys{bbrbox}{#1}%
+
+\ifthenelse{\equal{\bbrboxnamepos}{center}}
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north,anchor=north}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{left}}
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north west,anchor=north west}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{top right}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north east,anchor=south east}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{}
+\ifthenelse{\equal{\bbrboxnamepos}{top center}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north,anchor=south}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{top left}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north west,anchor=south west}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{middle}}
+ {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=south}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{bottom}}
+ {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=north}}{} 
+
+
+\tikzset{BBRBOXSTYLE/.style/.expand once=\bbrboxstyle}%
+\tikzset{BBRBOXNAMEPOS/.style/.expand once=\@bbrboxnamepos}%
+\tikzset{BBRBOXNAMESTYLE/.style/.expand once=\bbrboxnamestyle}%
+\tikzset{BBRBOXNAMEPOSOFFSET/.style/.expand once=\@bbrboxnameposoffset}%
+
+\node[inner sep=0pt,outer sep=0pt] (\@bb at lastbox-tmpouter) {};
+\node[inner sep=.3333em,anchor=north,BBRBOXSTYLE,minimum height=\bbrboxminheight,below right=\bbrboxyshift and \bbrboxxshift of \@bb at lastbox-tmpouter] (\@bb at lastbox)  \bgroup
+	\tikz{
+		\node[inner sep=0pt,outer sep=0pt,minimum height=0cm] (phantomname) {}; %minimum width
+		\node[BBRBOXNAMEPOSOFFSET,minimum height=0cm] (\@bb at lastbox-inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}};
+		\ifthenelse{\equal{\bbrboxafterskip}{}}{}{
+			\node[below=0cm of \@bb at lastbox-inner,minimum height=\bbrboxafterskip] {};
+		}
+		\node[inner sep=0pt,outer sep=0pt,at=(\@bb at lastbox-inner.south west),minimum height=0cm] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width
+	}
+\egroup;
+\ifthenelse{\equal{\bbrboxnamepos}{none}}
+{}{\node[BBRBOXNAMEPOS,BBRBOXNAMESTYLE, inner sep=0.2ex, outer sep=0pt, overlay] () {\bbrboxname};}
+}
+
+
+\newcommand*\bbroraclevdistance{\baselineskip}
+\newcommand*\bbroraclehdistance{1.5cm}
+\define at key{bbroracle}{distance}[]{\renewcommand*\bbroraclehdistance{#1}}
+\define at key{bbroracle}{hdistance}[]{\renewcommand*\bbroraclehdistance{#1}}
+\define at key{bbroracle}{vdistance}[]{\renewcommand*\bbroraclevdistance{#1}}
+
+
+% ORACLES
+\newenvironmentx{bbroracle}[2][2=]{%
+	\begingroup
+	\setkeys{bbroracle}{#2}
+	%add to nesting cout
+	\addtocounter{@bb at oracle@nestcnt}{1}
+	%if first oracle, then put it to the right, else stack them vertically
+	\addtocounter{@bb at oracle@cnt}{1}
+	\ifthenelse{\value{@bb at oracle@cnt}=1}{
+	\setlength{\@bb at tmplength@b}{\bbroraclevdistance-\baselineskip}
+	\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
+	}{
+% compute distance of top of last box to bottom of last oracle
+	\coordinate (@bbtmpcoord) at (\@bb at lastbox.north east);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordA}
+	\coordinate (@bbtmpcoord) at (\bbroraclenodenameprefix \@bb at lastoracle.south west);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordB}
+	\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB+\bbroraclevdistance}
+	\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
+	}
+	\global\def\@bb at lastoracle{#1}
+	\begin{bbrenv}{#1}
+}{
+	\end{bbrenv}
+	\egroup;
+
+	\addtocounter{@bb at oracle@nestcnt}{-1}
+	\endgroup
+}
+
+
+\newcommand*\bbrchallengerhdistance{1.5cm}
+\newcommand*\bbrchallengervdistance{\baselineskip}
+\define at key{bbrchallenger}{distance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
+\define at key{bbrchallenger}{hdistance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
+\define at key{bbrchallenger}{vdistance}[]{\renewcommand*\bbrchallengervdistance{#1}}
+
+
+% Challenger
+\newenvironmentx{bbrchallenger}[2][2=]{%
+\begingroup%
+\setkeys{bbrchallenger}{#2}%
+%add to nesting cout
+\addtocounter{@bb at challenger@nestcnt}{1}%
+%if first oracle, then put it to the right, else stack them vertically
+\addtocounter{@bb at challenger@cnt}{1}%
+\ifthenelse{\value{@bb at challenger@cnt}=1}{%
+\setlength{\@bb at tmplength@b}{\bbrchallengervdistance-\baselineskip}%
+\node[inner sep=0pt,below left=\@bb at tmplength@b and \bbrchallengerhdistance of \@bb at lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
+}{%
+\coordinate (@bbtmpcoord) at (\@bb at lastbox.north west);%
+\path (@bbtmpcoord);%
+\pgfgetlastxy{\XCoord}{\YCoordA}%
+\coordinate (@bbtmpcoord) at (\bbrchallengernodenameprefix \@bb at lastchallenger.south east);%
+\path (@bbtmpcoord);%
+\pgfgetlastxy{\XCoord}{\YCoordB}%
+\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB+\bbrchallengervdistance}%
+\node[inner sep=0pt,below left=\@bb at tmplength@b and \bbrchallengerhdistance of \@bb at lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
+}%
+\global\def\@bb at lastchallenger{#1}
+\begin{bbrenv}{#1}%
+}{
+\end{bbrenv}%
+\egroup;%
+\addtocounter{@bb at challenger@nestcnt}{-1}%
+\endgroup%
+\let\msgfrom\bbrchallengerqueryto%
+}
+
+
+\newcommand*\bbrinputlength{0.5cm}
+\newcommand*\bbrinputhoffset{0.5cm}
+\newcommand*\bbrinputbottom{}
+\newcommand*\bbrinputtop{}
+\newcommand*\bbrinputedgestyle{}
+\newcommand*\bbrinputtopstyle{}
+\newcommand*\bbrinputbottomstyle{}
+\newcommand*\bbrinputnodestyle{}
+\newcommand*\bbrinputnodename{}
+\define at key{bbrinput}{length}[]{\renewcommand*\bbrinputlength{#1}}
+\define at key{bbrinput}{hoffset}[]{\renewcommand*\bbrinputhoffset{#1}}
+\define at key{bbrinput}{name}[]{\renewcommand*\bbrinputnodename{#1}}
+\define at key{bbrinput}{top}[]{\renewcommand*\bbrinputtop{#1}}
+\define at key{bbrinput}{bottom}[]{\renewcommand*\bbrinputbottom{#1}}
+
+
+\newcommand{\@bb at inputsetup}[1]{
+	%load keys	
+	\begingroup % for local keys
+
+	\setkeys{bbrinput}{#1}%
+
+	\tikzset{BBRINPUT-NODESTYLE/.style/.expand once=\bbrinputedgestyle}%	
+	\tikzset{BBRINPUT-TOPSTYLE/.style/.expand once=\bbrinputtopstyle}%	
+	\tikzset{BBRINPUT-BOTTOMSTYLE/.style/.expand once=\bbrinputbottomstyle}%			
+	\tikzset{BBRINPUT-EDGESTYLE/.style/.expand once=\bbrinputedgestyle}%
+
+}
+
+\newcommand{\@bb at inputfinalize}{
+	\endgroup
+}
+
+\newcommandx*{\bbrinput}[2][2=]{%
+\@bb at inputsetup{#2}
+\ifthenelse{\equal{\bbrinputnodename}{}}
+  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-input}}{} 
+  
+\node[overlay,above right={\bbrinputlength} and {\bbrinputhoffset} of \@bb at lastbox.north west, anchor=south,BBRINPUT-NODESTYLE] (\bbrinputnodename) {#1};
+\path[->] (\bbrinputnodename.south)  edge[BBRINPUT-EDGESTYLE] node[above,anchor=east,BBRINPUT-TOPSTYLE] () {\bbrinputtop} node[below,anchor=west,BBRINPUT-BOTTOMSTYLE] () {\bbrinputbottom} (\bbrinputnodename.south|-\@bb at lastbox.north);
+\@bb at inputfinalize
+}
+
+\newcommandx*{\bbroutput}[2][2=]{%
+\@bb at inputsetup{#2}
+\ifthenelse{\equal{\bbrinputnodename}{}}
+  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-output}}{} 
+  
+\node[overlay,below right={\bbrinputlength} and {\bbrinputhoffset} of \@bb at lastbox.south west, anchor=north] (\bbrinputnodename) {#1};
+\draw[->] (\bbrinputnodename.north|-\@bb at lastbox.south)  -- (\bbrinputnodename.north|-\bbrinputnodename.north);
+\@bb at inputfinalize
+}
+
+\newenvironment{bbrpic}[1][]{%
+\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#1]%
+}{%
+\end{tikzpicture}}
+
+%%%%%%%%%%%
+% communication
+%temporary lengths
+\newlength{\@bb at com@tmpoffset}
+\newlength{\@bb at tmplength@b}
+\newcommand{\@bb at firstmessageheight}{0.25\baselineskip}
+\newcommand{\@bb at msglength}{1.25cm}
+\newcommand{\@bb at qrylength}{1.5cm}
+
+%keys
+\newcommand*\bbrcomnsidestyle{}
+\newcommand*\bbrcomtopstyle{}
+\newcommand*\bbrcombottomstyle{}
+\newcommand*\bbrcomside{}
+\newcommand*\bbrcomoside{}
+\newcommand*\bbrcomtop{}
+\newcommand*\bbrcombottom{}
+\newcommand*\bbrcomedgestyle{}
+\newcommand*\bbrcomlength{1.25cm}
+\newcommand*\bbrcomtopname{bbrcomtop}
+\newcommand*\bbrcombottomname{bbrcombottom}
+\newcommand*\bbrcomsidename{bbrcomside}
+\newcommand*\bbrcomosidename{bbrcomoside}
+\newcommand*\bbrcombeforeskip{0pt}
+\newcommand*\bbrcomafterskip{0pt}
+\define at key{bbrcom}{sidestyle}[]{\renewcommand*\bbrcomnsidestyle{#1}}
+\define at key{bbrcom}{topstyle}[]{\renewcommand*\bbrcomtopstyle{#1}}
+\define at key{bbrcom}{bottomstyle}[]{\renewcommand*\bbrcombottomstyle{#1}}
+\define at key{bbrcom}{side}[]{\renewcommand*\bbrcomside{#1}}
+\define at key{bbrcom}{oside}[]{\renewcommand*\bbrcomoside{#1}}
+\define at key{bbrcom}{top}[]{\renewcommand*\bbrcomtop{#1}}
+\define at key{bbrcom}{bottom}[]{\renewcommand*\bbrcombottom{#1}}
+\define at key{bbrcom}{edgestyle}[]{\renewcommand*\bbrcomedgestyle{#1}}
+\define at key{bbrcom}{length}[]{\renewcommand*\bbrcomlength{#1}}
+\define at key{bbrcom}{topname}[]{\renewcommand*\bbrcomtopname{#1}}
+\define at key{bbrcom}{bottomname}[]{\renewcommand*\bbrcombottomname{#1}}
+\define at key{bbrcom}{sidename}[]{\renewcommand*\bbrcomsidename{#1}}
+\define at key{bbrcom}{osidename}[]{\renewcommand*\bbrcomosidename{#1}}
+\define at key{bbrcom}{beforeskip}[]{\renewcommand*\bbrcombeforeskip{#1}}
+\define at key{bbrcom}{afterskip}[]{\renewcommand*\bbrcomafterskip{#1}}
+
+\newcommand*\bbrbasenodestyle{}
+\newcommand*\bbrbasenodename{bbrtmpname}
+\define at key{bbrabase}{nodestyle}[]{\renewcommand*\bbrbasenodestyle{#1}}
+\define at key{bbrabase}{nodename}[]{\renewcommand*\bbrbasenodename{#1}}
+
+
+\newcommand{\@bb at comsetup}[3]{
+	%load keys	
+	\begingroup % for local keys
+
+	\setkeys{bbrcom}{#1}%
+
+	%set styles
+	\tikzset{BBRCOM-SIDESTYLE/.style/.expand once=\bbrcomnsidestyle}%
+	\tikzset{BBRCOM-TOPSTYLE/.style/.expand once=\bbrcomtopstyle}%
+	\tikzset{BBRCOM-BOTTOMSTYLE/.style/.expand once=\bbrcombottomstyle}%
+	\tikzset{BBRCOM-EDGESTYLE/.style/.expand once=\bbrcomedgestyle}%
+
+	% increase space
+	\ifthenelse{\lengthtest{#2<\@bb at firstmessageheight}}
+ 	{#3{\@bb at firstmessageheight}}
+	{
+	  #3{1.25\baselineskip}
+	  \ifthenelse{\equal{\bbrcomtop}{}}{}{#3{0.5\baselineskip}}	
+           }
+
+	#3{\bbrcombeforeskip}
+
+	\setlength{\@bb at com@tmpoffset}{#2}%
+}
+
+\newcommand{\@bb at comfinalize}[1]{
+	\ifthenelse{\equal{\bbrcombottom}{}}{}{#1{\baselineskip}}	
+	#1{\bbrcomafterskip}
+	\endgroup
+}
+
+\newcommand{\@bbrmsg}[8]{
+	\@bb at comsetup{#1}{#7}{#8}
+	%
+	\node[#3=\@bb at com@tmpoffset and \bbrcomlength of \@bb at lastbox.#4,anchor=#6,BBRCOM-SIDESTYLE] (\bbrcomsidename) {\bbrcomside};
+	\path[#2] (\bbrcomsidename.#6)  edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb at lastbox.#5|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {};
+	%
+	\@bb at comfinalize{#8}
+}
+
+\newcommandx{\bbrmsgto}[1]{%
+\@bbrmsg{#1}{->}{below left}{north west}{west}{east}{\@bb at message@hoffset}{\bbrmsgspace}
+}
+\newcommandx{\bbrmsgfrom}[1]{%
+\@bbrmsg{#1}{<-}{below left}{north west}{west}{east}{\@bb at message@hoffset}{\bbrmsgspace}
+}
+\newcommandx{\bbrmsgvdots}{%
+	\bbrmsgtxt[xshift=\bbrcomlength/2,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip]{$\vdots$}
+}
+
+
+\newcommandx{\bbrqryto}[1]{%
+\@bbrmsg{#1}{<-}{below right}{north east}{east}{west}{\@bb at query@hoffset}{\bbrqryspace}
+}
+\newcommandx{\bbrqryfrom}[1]{%
+\@bbrmsg{#1}{->}{below right}{north east}{east}{west}{\@bb at query@hoffset}{\bbrqryspace}
+}
+
+\newcommand{\@bbroracleqry}[4]{
+	\@bb at comsetup{#1}{#3}{#4}
+	%
+
+	\path[#2] (\@bb at lastoracle.north west) -- ++ (0,-\@bb at com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){\bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb at lastbox.east|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {\bbrcomoside};
+	%
+	\@bb at comfinalize{#4}
+}
+
+\newcommand{\bbroracleqryfrom}[1]{
+	\@bbroracleqry{#1}{->}{\@bb at oraclequery@hoffset}{\bbroracleqryspace}
+}
+
+\newcommand{\bbroracleqryto}[1]{
+	\@bbroracleqry{#1}{<-}{\@bb at oraclequery@hoffset}{\bbroracleqryspace}
+}
+
+\newcommand{\@bbrchallengerqry}[4]{
+	\@bb at comsetup{#1}{#3}{#4}
+	%
+
+	\path[#2] (\@bb at lastchallenger.north east) -- ++ (0,-\@bb at com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){\bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb at lastbox.west|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {\bbrcomoside};
+	%
+	\@bb at comfinalize{#4}
+}
+
+\newcommand{\bbrchallengerqryfrom}[1]{
+	\@bbrchallengerqry{#1}{<-}{\@bb at challengerquery@hoffset}{\bbrchallengerqryspace}
+}
+
+\newcommand{\bbrchallengerqryto}[1]{
+	\@bbrchallengerqry{#1}{->}{\@bb at challengerquery@hoffset}{\bbrchallengerqryspace}
+}
+
+
+
+\newcommand*\bbrcomloopleft{}
+\newcommand*\bbrcomloopright{}
+\newcommand*\bbrcomloopcenter{}
+\newcommand*\bbrcomloopangle{50}
+\define at key{bbrcomloop}{left}[]{\renewcommand*\bbrcomloopleft{#1}}
+\define at key{bbrcomloop}{right}[]{\renewcommand*\bbrcomloopright{#1}}
+\define at key{bbrcomloop}{center}[]{\renewcommand*\bbrcomloopcenter{#1}}
+\define at key{bbrcomloop}{angle}[]{\renewcommand*\bbrcomloopangle{#1}}
+
+\newcommand{\bbrloop}[3]{
+	\begingroup % for local keys
+	\setkeys{bbrcomloop}{#3}%
+
+	\path[->] (#1) edge[bend right=\bbrcomloopangle] node[midway,left] (bbrleft) {\bbrcomloopleft} (#2);
+	\path[->] (#2) edge[bend right=\bbrcomloopangle] node[midway,right] (bbrright) {\bbrcomloopright} (#1);
+	\node[at=($(bbrleft.north west)!0.5!(bbrright.north east)$),anchor=north]() {\bbrcomloopcenter};
+
+	\endgroup
+}
+
+\newcommand*\bbrintertexthoffset{1.5cm}
+\define at key{bbrintertext}{xshift}[]{\renewcommand*\bbrintertexthoffset{#1}}
+
+\newcommand{\@bb at intertextsetup}[1]{
+	%load keys	
+	\begingroup % for local keys
+
+	\setkeys{bbrcom,bbrabase,bbrintertext}{#1}%
+
+	\tikzset{BBRBASE-NODESTYLE/.style/.expand once=\bbrbasenodestyle}%
+}
+
+\newcommand{\@bb at intertextfinalize}[1]{
+	#1{\bbrcomafterskip}
+	\endgroup
+}
+
+\newcommand{\@bbrintertext}[6]{
+	\@bb at intertextsetup{#1}
+
+	% increase space
+	\ifthenelse{\lengthtest{#4<\@bb at firstmessageheight}}
+ 	{#5{\@bb at firstmessageheight}}
+	{#5{1\baselineskip}}
+
+	\setlength{\@bb at com@tmpoffset}{#4+\bbrcombeforeskip}%
+
+	%
+	\node[#2=\@bb at com@tmpoffset and \bbrintertexthoffset of \@bb at lastbox.#3,BBRBASE-NODESTYLE] (\bbrbasenodename) {#6};
+	%
+	% compute height of node
+	\coordinate (@bbtmpcoord) at (\bbrbasenodename.north);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordA}
+	\coordinate (@bbtmpcoord) at (\bbrbasenodename.south);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordB}
+
+	% update hoffset
+	\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB}
+	#5{\the\@bb at tmplength@b}
+
+	\@bb at intertextfinalize{#5}
+}
+
+\newcommand{\bbrmsgtxt}[2][]{
+	\@bbrintertext{#1}{below left}{north west}{\@bb at message@hoffset}{\bbrmsgspace}{#2}
+}
+
+\newcommand{\bbrqrytxt}[2][]{
+	\@bbrintertext{#1}{below right}{north east}{\@bb at query@hoffset}{\bbrqryspace}{#2}
+}
+
+\newcommand{\bbrchallengertxt}[2][]{
+\begingroup
+\setlength{\@bb at tmplength@b}{\bbrchallengerhdistance/2}%
+\renewcommand{\bbrintertexthoffset}{\the\@bb at tmplength@b}%
+	\@bbrintertext{#1}{below left}{north west}{\@bb at challengerquery@hoffset}{\bbrchallengerqryspace}{#2}
+\endgroup
+}
+
+\newcommand{\bbroracletxt}[2][]{
+\begingroup
+\setlength{\@bb at tmplength@b}{\bbroraclehdistance/2}%
+\renewcommand{\bbrintertexthoffset}{\the\@bb at tmplength@b}%
+	\@bbrintertext{#1}{below left}{north west}{\@bb at oraclequery@hoffset}{\bbroracleqryspace}{#2}
+\endgroup
+}
+
+\newcommand{\bbrmsgspace}[1]{
+\@pc at globaladdtolength{\@bb at message@hoffset}{#1}
+}
+
+\newcommand{\bbrqryspace}[1]{
+\@pc at globaladdtolength{\@bb at query@hoffset}{#1}
+}
+
+\newcommand{\bbroracleqryspace}[1]{
+\@pc at globaladdtolength{\@bb at oraclequery@hoffset}{#1}
+}
+
+\newcommand{\bbrchallengerqryspace}[1]{
+\@pc at globaladdtolength{\@bb at challengerquery@hoffset}{#1}
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% stacking
+\providecommand{\pccenteraboveskip}{0.5\baselineskip plus 0.25\baselineskip minus 0.25\baselineskip}
+\providecommand{\pccenterbelowskip}{0.5\baselineskip plus 0.25\baselineskip minus 0.25\baselineskip}
+\newenvironment{pccenter}{%
+\setlength\topsep{0pt}\setlength\parskip{0pt}%
+\begin{center}\vspace{\pccenteraboveskip}%
+}{%
+\vspace{\pccenteraboveskip}%
+\end{center}}
+
+
+%%%%%%%%%%%%%%%%%%%%%
+% horizontal stacking
+% space before hstacks
+\newlength{\pcbeforehstackskip}
+
+\NewEnviron{pchstack}[1][]{%
+% write out content
+\ifthenelse{\equal{#1}{center}}{%
+\begin{pccenter}\mbox{\hspace{\pcbeforehstackskip}\BODY}\end{pccenter}}{%
+\mbox{\hspace{\pcbeforehstackskip}\BODY}}%
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%
+\NewEnviron{pcvstack}[1][]{%
+% display minipage
+\ifthenelse{\equal{#1}{center}}{\begin{pccenter}}{}%
+\begin{varwidth}[t]{2\linewidth}\hspace{0pt}\BODY\end{varwidth}% hspace needed for proper vertical positioning .. strange as it is.
+\ifthenelse{\equal{#1}{center}}{\end{pccenter}}{}%
+}
+
+
+% spacing for stacking
+\newcommand{\pchspace}[1][1em]{\hspace{#1}}
+\newcommand{\pcvspace}[1][\baselineskip]{\par\vspace{#1}}
+
+
+
+
+
+%%%%
+% subprocedures
+\newcounter{@pcsubprogcnt1}
+\newcounter{@pcrsubprogcnt1}
+\newcounter{@pcsubprogcnt2}
+\newcounter{@pcrsubprogcnt2}
+\newcounter{@pcsubprogcnt3}
+\newcounter{@pcrsubprogcnt3}
+\newcounter{@pcsubprogcnt4}
+\newcounter{@pcrsubprogcnt4}
+\newcounter{@pcsubprogcnt5}
+\newcounter{@pcrsubprogcnt5}
+\newcounter{@pcsubprogcnt6}
+\newcounter{@pcrsubprogcnt6}
+\newcounter{@pcsubprogcnt7}
+\newcounter{@pcrsubprogcnt7}
+\newcounter{@pcsubprogcnt8}
+\newcounter{@pcrsubprogcnt8}
+\newcounter{@pcsubprogcnt9}
+\newcounter{@pcrsubprogcnt9}
+\newcounter{@pcsubprogstep}
+
+\newenvironment{subprocedure}{%
+\addtocounter{@pcsubprogstep}{1}%
+% store old counter values
+\setcounter{@pcsubprogcnt\the at pcsubprogstep}{\value{pclinenumber}}%
+\setcounter{@pcrsubprogcnt\the at pcsubprogstep}{\value{pcrlinenumber}}%
+}{%
+\setcounter{pclinenumber}{\value{@pcsubprogcnt\the at pcsubprogstep}}%
+\setcounter{pcrlinenumber}{\value{@pcrsubprogcnt\the at pcsubprogstep}}%
+\addtocounter{@pcsubprogstep}{-1}}
+
+
+%%%%%
+% parameter reordering
+\def\@pseudocodeB#1#2[#3]#4{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1#4},#2,#3]}
+\def\@pseudocodeC#1#2#3{\setkeys*{pcspace}{#2}\@pseudocode[head={#1#3},#2]}
+%for no headers
+\def\@pseudocodeE#1#2[#3]{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1},#2,#3]}
+\def\@pseudocodeF#1#2{\setkeys*{pcspace}{#2}\@pseudocode[head={#1},#2]}
+
+%%%%%%%%%
+% Define pseudocode command: 
+% #1 name
+% #2 code to execute after begingroup
+% #3 head prefix
+% #4 other config
+\newcommand{\createprocedurecommand}[4]{
+	\expandafter\gdef\csname #1\endcsname{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+#2%
+\@ifnextchar[%]
+  {\@pseudocodeB{#3}{#4}}
+  {\@pseudocodeC{#3}{#4}}%
+}%
+}
+
+\newcommand{\createpseudocodecommand}[4]{
+	\expandafter\gdef\csname #1\endcsname{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+#2%
+\@ifnextchar[%]
+  {\@pseudocodeE{#3}{#4}}
+  {\@pseudocodeF{#3}{#4}}%
+}%
+}
+
+
+%%%%%%
+% create procedure
+\createprocedurecommand{procedure}{}{}{}
+
+
+
+
+%%%
+% send message
+\newcommand{\pcshortmessageoffset}{0.5cm}
+\newcommand{\pcdefaultmessagelength}{3.5cm}
+\newcommand{\pcdefaultlongmessagelength}{6cm}
+\newcommand{\pcbeforemessageskip}{0pt}
+\newcommand{\pcaftermessageskip}{10pt}
+\newlength{\pcmessagearrow}
+
+\newcommand*\@pcsendmessagelength{\pcdefaultmessagelength}
+\newcommand*\@pcsendmessagecol{}
+\newcommand*\@pcsendmessagewidth{}
+\newcommand*\@pcsendmessagestyle{}
+\newcommand*\@pcsendmessagetop{}
+\newcommand*\@pcsendmessagebottom{}
+\newcommand*\@pcsendmessageright{}
+\newcommand*\@pcsendmessageleft{}
+\newcommand*\@pcsendmessagetopname{t}
+\newcommand*\@pcsendmessagebottomname{b}
+\newcommand*\@pcsendmessagerightname{r}
+\newcommand*\@pcsendmessageleftname{l}
+\newcommand*\@pcsendmessagetopstyle{}
+\newcommand*\@pcsendmessagebottomstyle{}
+\newcommand*\@pcsendmessagerightstyle{}
+\newcommand*\@pcsendmessageleftstyle{}
+\newcommand*\@pcsendmessagebeforeskip{\pcbeforemessageskip}
+\newcommand*\@pcsendmessageafterskip{\pcaftermessageskip}
+\define at key{pcsendmessage}{centercol}[]{\renewcommand*\@pcsendmessagecol{#1}}
+\define at key{pcsendmessage}{width}[]{\renewcommand*\@pcsendmessagewidth{#1}}
+\define at key{pcsendmessage}{style}[]{\renewcommand*\@pcsendmessagestyle{#1}}
+\define at key{pcsendmessage}{length}[]{\renewcommand*\@pcsendmessagelength{#1}}
+\define at key{pcsendmessage}{top}[]{\renewcommand*\@pcsendmessagetop{#1}}
+\define at key{pcsendmessage}{bottom}[]{\renewcommand*\@pcsendmessagebottom{#1}}
+\define at key{pcsendmessage}{right}[]{\renewcommand*\@pcsendmessageright{#1}}
+\define at key{pcsendmessage}{left}[]{\renewcommand*\@pcsendmessageleft{#1}}
+\define at key{pcsendmessage}{topname}[]{\renewcommand*\@pcsendmessagetopname{#1}}
+\define at key{pcsendmessage}{bottomname}[]{\renewcommand*\@pcsendmessagebottomname{#1}}
+\define at key{pcsendmessage}{rightname}[]{\renewcommand*\@pcsendmessagerightname{#1}}
+\define at key{pcsendmessage}{leftname}[]{\renewcommand*\@pcsendmessageleftname{#1}}
+\define at key{pcsendmessage}{topstyle}[]{\renewcommand*\@pcsendmessagetopstyle{#1}}
+\define at key{pcsendmessage}{bottomstyle}[]{\renewcommand*\@pcsendmessagebottomstyle{#1}}
+\define at key{pcsendmessage}{rightstyle}[]{\renewcommand*\@pcsendmessagerightstyle{#1}}
+\define at key{pcsendmessage}{leftstyle}[]{\renewcommand*\@pcsendmessageleftstyle{#1}}
+\define at key{pcsendmessage}{beforeskip}[]{\renewcommand*\@pcsendmessagebeforeskip{#1}}
+\define at key{pcsendmessage}{afterskip}[]{\renewcommand*\@pcsendmessageafterskip{#1}}
+
+
+\newcommand{\@pc at centerincol}[2]{%
+\ifmeasuring@%
+#2%
+\else%
+\makebox[\ifcase\expandafter #1\maxcolumn at widths\fi]{$\displaystyle#2$}%
+\fi%
+}
+
+\newcommand{\centerincol}[1]{\@pc at centerincol{\thepccolumncounter}{#1}}
+
+\newcommand{\@do at sendmessage}[1]{%
+\ifthenelse{\equal{\@pcsendmessagecol}{}}{%
+\ifthenelse{\equal{\@pcsendmessagewidth}{}}{#1}{% we have some width
+\makebox[\@pcsendmessagewidth]{$\displaystyle#1$}%
+}}{%we know the column to center on
+\@pc at centerincol{\@pcsendmessagecol}{#1}%
+}%
+}
+
+\newcommandx*{\sendmessage}[2]{%
+\begingroup\setkeys{pcsendmessage}{#2}%
+\tikzset{PCSENDMSG-PATH-STYLE/.style/.expand once=\@pcsendmessagestyle}%
+\tikzset{PCSENDMSG-TOP-STYLE/.style/.expand once=\@pcsendmessagetopstyle}%
+\tikzset{PCSENDMSG-BOTTOM-STYLE/.style/.expand once=\@pcsendmessagebottomstyle}%
+\tikzset{PCSENDMSG-LEFT-STYLE/.style/.expand once=\@pcsendmessageleftstyle}%
+\tikzset{PCSENDMSG-RIGHT-STYLE/.style/.expand once=\@pcsendmessagerightstyle}%
+%restore halign
+%
+\hspace{\@pcsendmessagebeforeskip}%
+\begin{varwidth}{\linewidth}
+\@do at sendmessage{
+	\begin{tikzpicture}%
+	 \node[PCSENDMSG-LEFT-STYLE] (\@pcsendmessageleftname) {\@pcsendmessageleft};
+	 \node[right=\@pcsendmessagelength of \@pcsendmessageleftname,PCSENDMSG-RIGHT-STYLE] (\@pcsendmessagerightname) {\@pcsendmessageright};
+	 \path[#1,PCSENDMSG-PATH-STYLE] (\@pcsendmessageleftname) edge[] node[above,PCSENDMSG-TOP-STYLE] (\@pcsendmessagetopname) {\@pcsendmessagetop} node[below,PCSENDMSG-BOTTOM-STYLE] (\@pcsendmessagebottomname) {\@pcsendmessagebottom} (\@pcsendmessagerightname); 
+	\end{tikzpicture}%
+}%
+\end{varwidth}
+\hspace{\@pcsendmessageafterskip}%
+\endgroup%
+}
+
+\newcommandx*{\sendmessageright}[2][1=->]{%
+\sendmessage{#1}{#2}%
+}
+
+\newcommandx*{\sendmessageleft}[2][1=<-]{%
+\sendmessage{#1}{#2}%
+}
+
+\WithSuffix\newcommand\sendmessageleft*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{<-}{length=#1}%
+\endgroup%
+}
+
+
+\WithSuffix\newcommand\sendmessageright*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{->}{length=#1}%
+\endgroup%
+}
+
+
+
+\DeclareExpandableDocumentCommand{\sendmessagerightx}{O{\pcdefaultlongmessagelength}mO{}m}{%
+\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xrightarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
+}
+
+\DeclareExpandableDocumentCommand{\sendmessageleftx}{O{\pcdefaultlongmessagelength}mO{}m}{%
+\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xleftarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
+}
+
+%%%
+% Division
+\DeclareExpandableDocumentCommand{\pcintertext}{O{}m}{\intertext{%
+\ifthenelse{\equal{#1}{center}}{\makebox[\linewidth][c]{#2}}{}%
+\ifthenelse{\equal{#1}{dotted}}{\dotfill#2\dotfill}{}%
+\ifthenelse{\equal{#1}{}}{#2}{}%
+}\@pc at beginnewline}
+
+
+
+%%%
+% Games
+%
+\newcounter{pcstartgamecounter}
+
+
+\newcommand*{\pcgameprocedurestyle}{} % define pseudocode arguments for game procedures
+
+\newcommand*{\pcgamename}{\ensuremath{\mathsf{Game}}}
+\newcommand*{\gameprocedurearg}{\ensuremath{(\secpar)}}
+\newcommand*\@pcgameproofgamenr{0}
+\define at key{pcgameproof}{nr}[]{\renewcommand*\@pcgameproofgamenr{#1}}
+\define at key{pcgameproof}{name}[]{\renewcommand*\pcgamename{\ensuremath{#1}}}
+\define at key{pcgameproof}{arg}[]{\renewcommand*\gameprocedurearg{\ensuremath{#1}}}
+
+\newenvironment{gameproof}[1][]{%
+\begingroup%
+\setkeys{pcgameproof}{#1}%
+\@pc at ensureremember%
+\setcounter{pcgamecounter}{\@pcgameproofgamenr}%
+\setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}%
+}{\@pc at releaseremember\endgroup}
+
+\newcommand{\setgameproceduredefaultstyle}[1]{%
+\createpseudocodecommand{gameprocedure}
+  {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}}
+  {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}}
+  {#1}
+}
+\setgameproceduredefaultstyle{}
+
+\def\@bxgame at pseudocodeA[#1]#2#3{\setkeys*{pcspace}{#1}\renewcommand{\@bxgameheader}{$\pcgamename_{#2}$\gameprocedurearg}%
+\@pseudocode[head=\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg},#1]{#3}}
+\def\@bxgame at pseudocodeB#1#2{\renewcommand{\@bxgameheader}{$\pcgamename_{#1}$\gameprocedurearg}%
+\@pseudocode[head=\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}]{#2}}
+
+\newcommand{\bxgameprocedure}{
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+\renewcommand{\@withingame}{true}%
+\renewcommand{\@withinbxgame}{true}%
+\stepcounter{pcgamecounter}%
+\@ifnextchar[%]
+  {\@bxgame at pseudocodeA}
+  {\@bxgame at pseudocodeB}%
+}
+
+\newcommand{\@pc at secondheader}{}
+
+%tbx top boxed
+\createpseudocodecommand{tbxgameprocedure}
+  {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}%%
+\renewcommand{\@pc at secondheader}{true}}
+  {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}}
+{}
+
+
+\newcommand*\@pcgamehopnodestyle{}
+\newcommand*\@pcgamehopedgestyle{bend left}
+\newcommand*\@pcgamehoppathestyle{}
+\newcommand*\@pcgamehophint{}
+\newcommand*\@pcgamehophintbelow{}
+\newcommand*\@pcgamehopinhint{}
+\newcommand*\@pcgamehoplength{1.5cm}
+\define at key{pcgamehop}{nodestyle}[]{\renewcommand*\@pcgamehopnodestyle{#1}}
+\define at key{pcgamehop}{edgestyle}[]{\renewcommand*\@pcgamehopedgestyle{#1}}
+\define at key{pcgamehop}{pathstyle}[]{\renewcommand*\@pcgamehoppathestyle{#1}}
+\define at key{pcgamehop}{hint}[]{\renewcommand*\@pcgamehophint{#1}}
+\define at key{pcgamehop}{belowhint}[]{\renewcommand*\@pcgamehophintbelow{#1}}
+\define at key{pcgamehop}{inhint}[]{\renewcommand*\@pcgamehopinhint{#1}}
+\define at key{pcgamehop}{length}[]{\renewcommand*\@pcgamehoplength{#1}}
+
+
+\newcommand{\@pc at setupgamehop}[1]{
+\begingroup\setkeys{pcgamehop}{#1}%
+\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
+\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
+\tikzset{GAMEHOP-EDGE-STYLE/.style/.expand once=\@pcgamehopedgestyle}%
+}
+
+\newcommand{\@pc at finalizegamehop}{
+\endgroup
+}
+
+\newcommandx*{\addgamehop}[3]{%
+\begingroup%
+\ifthenelse{#1<#2}%
+  {\ifthenelse{\equal{\@withingamedescription}{true}}%
+   {\renewcommand*\@pcgamehopedgestyle{bend right=20}\renewcommand*\@pcgamehopnodestyle{rotate=90}}{}%
+  }%
+  {\renewcommand*\@pcgamehopedgestyle{bend right}}%
+\@pc at setupgamehop{#3}%
+\begin{tikzpicture}[overlay]%
+\ifthenelse{#1<#2}{%
+       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#2);
+}{%
+ 	 \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+	 node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
+}%
+\end{tikzpicture}%
+\@pc at finalizegamehop%
+\endgroup%
+}
+\newcommandx*{\addstartgamehop}[2][1=\thepcstartgamecounter]{%
+\@pc at setupgamehop{#2}
+\begin{tikzpicture}[overlay]
+       \node[left=\@pcgamehoplength of gamenode#1] (tmpgamenode0) {};
+       \path[->,GAMEHOP-PATH-STYLE] (tmpgamenode0) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#1);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+\newcommandx*{\addendgamehop}[2][1=\thepcgamecounter]{%
+\@pc at setupgamehop{#2}
+\begin{tikzpicture}[overlay]
+       \node[right=\@pcgamehoplength of gamenode#1] (tmpgamenode#1) {};
+       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (tmpgamenode#1);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+\newcommandx*{\addbxgamehop}[3]{%
+\@pc at setupgamehop{#3}
+\begin{tikzpicture}[overlay]
+       \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE]] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+\newcommandx*{\addloopgamehop}[2][1=\thepcgamecounter]{%
+\@pc at setupgamehop{#2}
+\begin{tikzpicture}[overlay]
+       \node (looptemp1)  [right=0.5cm of gamenode#1] {};
+       \draw[->,GAMEHOP-PATH-STYLE] (gamenode#1) -- (looptemp1|-gamenode#1) -- node[right,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[left,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (looptemp1|-bgamenode#1)-- (bgamenode#1);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+
+
+%%%%%%%% 
+% game description
+\newenvironment{gamedescription}[1][]{%
+\begingroup%
+\setkeys{pcgameproof}{#1}
+\renewcommand{\@withingamedescription}{true}%
+\@pc at ensureremember%
+\setcounter{pcgamecounter}{\@pcgameproofgamenr}%
+\setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}%
+\begin{description}%
+}{\end{description}\@pc at releaseremember\endgroup}
+
+\newcommandx*{\describegame}[1][1=]{%
+\addtocounter{pcgamecounter}{1}%
+\item[%
+\pcdraw{
+\gdef\i{\thepcgamecounter}%
+\node[inner sep=0.0em,outer sep=0, xshift=-1ex, yshift=0.5ex] (gamenode\i) {}; 
+}%
+\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}:]%
+\begingroup\setkeys{pcgamehop}{#1}%
+\ifthenelse{\equal{}{\@pcgamehophint}}
+  {}
+  {\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
+\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
+\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
+\draw[->,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,-\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE]  {\@pcgamehophint};
+}}%
+\ifthenelse{\equal{}{\@pcgamehopinhint}}
+  {}
+  {\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
+\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
+\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
+\draw[<-,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE]  {\@pcgamehopinhint};
+}%
+}%
+\endgroup%
+}
+
+
+
+
+
+
+%%%%%%%% 
+% basic pseudocode constants
+
+\newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
+\newcommand{\highlightaltkeyword}[1]{\ensuremath{\mathsf{#1}}}
+
+\newcommand{\pcglobvar}{\highlightkeyword{gbl}}
+\newcommand{\pcnew}{\highlightkeyword{new}}
+\newcommand{\pcwhile}{\@pc at increaseindent\highlightkeyword{while}}
+\newcommand{\pcendwhile}{\@pc at decreaseindent\highlightkeyword{endwhile}}
+\newcommandx*{\pcdo}[2][1=\ ,2=]{#1\highlightkeyword[#2]{do}}
+\newcommandx*{\pcif}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{if}}
+\newcommandx*{\pcunless}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{unless}}
+\newcommandx*{\pcelse}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else}}
+\newcommandx*{\pcelseif}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else if}}
+\newcommand{\pcfi}{\@pc at decreaseindent\highlightkeyword{fi}}
+\newcommand{\pcendif}{\@pc at decreaseindent\highlightkeyword{endif}}
+\newcommand{\pcendfor}{\@pc at decreaseindent\highlightkeyword{endfor}}
+\newcommandx*{\pcthen}[2][1=\ ,2=\ ]{#1\highlightkeyword[#2]{then}}
+\newcommand{\pcreturn}{\highlightkeyword{return}}
+\newcommandx*{\pcin}[2][1=\ ,2=]{#1\highlightkeyword[#2]{in}}
+\newcommand{\pcfor}{\@pc at increaseindent\highlightkeyword{for}}
+\newcommand{\pcrepeat}[1]{\@pc at increaseindent\ensuremath{\highlightkeyword{repeat} #1\ \highlightkeyword{times}}}
+\newcommand{\pcrepeatuntil}[2]{\ensuremath{\highlightkeyword{repeat}\ #1\ \highlightkeyword{until}\ #2}}
+\newcommand{\pcforeach}{\@pc at increaseindent\highlightkeyword{foreach}}
+\newcommand{\pcendforeach}{\@pc at decreaseindent\highlightkeyword{endforeach}}
+\newcommand{\pcuntil}{\@pc at decreaseindent\highlightkeyword{until}}
+\newcommand{\pccontinue}{\highlightkeyword{continue}}
+\newcommandx*{\pcfalse}[2][1=\ ,2=]{\highlightkeyword[#2]{false}}
+\newcommandx*{\pctrue}[2][1=\ ,2=]{\highlightkeyword[#2]{true}}
+\newcommandx*{\pcnull}[2][1=\ ,2=]{\highlightkeyword[#2]{null}}
+\newcommand{\pccomment}[1]{{\mbox{/\!\!/ } \text{\scriptsize#1}}}
+\newcommand{\pcdone}{\highlightkeyword{done}}
+\newcommand{\pcparse}{\highlightkeyword{parse}}
+\newcommand{\pcfail}{\highlightkeyword{fail}}
+\newcommand{\pcabort}{\highlightkeyword{abort}}
+
+%%%
+% highlighting 
+\definecolor{gamechangecolor}{gray}{0.90}
+\newcommand{\gamechange}[2][gamechangecolor]{%
+{\setlength{\fboxsep}{0pt}\colorbox{#1}{\ifmmode$\displaystyle#2$\else#2\fi}}%
+}
+
+%%%
+% boxing
+\newcommand{\pcbox}[1]{%
+{\setlength{\fboxsep}{3pt}\fbox{$\displaystyle#1$}}
+}
+
+\endinput
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2018-11-11.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2020-04-24.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2020-04-24.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2020-04-24.sty	2020-07-10 21:20:21 UTC (rev 55800)
@@ -0,0 +1,2074 @@
+ %% Copyright 2018 Arno Mittelbach
+  %
+  % This work may be distributed and/or modified under the
+  % conditions of the LaTeX Project Public License, either version 1.3
+  % of this license or (at your option) any later version.
+  % The latest version of this license is in
+  %   http://www.latex-project.org/lppl.txt
+  % and version 1.3 or later is part of all distributions of LaTeX
+  % version 2005/12/01 or later.
+  %
+  % This work has the LPPL maintenance status `maintained'.
+  % 
+  % The Current Maintainer of this work is Arno Mittelbach.
+  %
+  % This work consists of the files cryptocode.tex and cryptocode.sty
+  %
+  % Changelog
+  %
+  % 2016/11/30
+  % - changed \pckeystyle to ensure that subscripts on \sk and \pk are aligned the same 
+  %   before, $(\sk_R, \pk_R)$ had slightly misaligned subscripts due to Tex treating 
+  %   subscripts on composite objects with descenders differently than without.
+  %   see https://groups.google.com/forum/#!msg/comp.text.tex/IaXu_xBG06Q/CibRPH5GCAAJ
+  % - added \NAND
+  % - added pcmbox environment for matrices in pseudocode
+  %
+  % 2016/12/02
+  % - changed minheight for bbrbox environment to actually reflect a minimum height in tikz
+  %   the old minheight which added space at the bottom was preserved as addheight
+  % - added namepos middle for bbrbox
+  % - added pcfail
+  % - added valign to pseudocode to allow minipage vertical alignment
+  % - added \setgameproceduredefaultstyle
+  % - ensure line numbers are right aligned to allow for two digit linenumbers having the same width
+  %
+  % 2017/08/26
+  % - added \pcabort
+  % - better control whitespace for \pcif, \pcelse, \pcelseif
+  %
+  % 2017/10/02
+  % - side and oside support to \bbroracleqryto and \bbroracleqryfrom
+  % - add bottom to namepos in bbrbox
+  % - names for brrinput and bbroutput
+  % - angle for bbrloop
+  % - fix length for bbrinput
+  % - introduce hoffset for bbrinput
+  % 
+  % 2017/12/21
+  % - added \pcunless
+  %
+  % 2018/11/11
+  % replace obsolete l3regex
+  %
+  % 2018/11/26 TODO: document
+  % added tprob (variants for prob and co for in-text)
+  %
+  % 2018/12/21 
+  % added \prp
+  %
+  % 2020/01/11
+  % - allow to control spacing with \pcfor
+  % - allow overwriting rule command in pseudocode via headlinecmd (defaults to \hrule)
+  %
+  % 2020/04/24
+  % - fix spacing of pchstack[center]. Can be controlled via \pccenterbelowskip and \pccenteraboveskip
+  %
+  %
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{cryptocode}
+  [2018/11/11 v0.3.0 Cryptocode LaTeX package for typesetting pseudocode, algorithms and protocols as well as cryptographic proofs.]
+
+
+\def\hi{Hello, this is cryptocode.}
+\let\myDate\date
+
+\RequirePackage{amsmath}
+\RequirePackage{mathtools}
+%\usepackage{l3tl-analysis} % uncomment for debugging
+
+%%%
+% option modes
+\newif\ifpc at orderofgrowth
+\newif\ifpc at algorithmstyle
+\newif\ifpc at amsfonts
+\newif\ifpc at advantage
+\newif\ifpc at primitives
+
+%%%
+% 
+\DeclareOption{operators}{
+	\providecommand{\sample}{\hskip2.3pt{\gets\!\!\mbox{\tiny${\$}$\normalsize}}\,}
+	
+	\providecommand{\floor}[1]{\ensuremath{\left\lfloor #1\right\rfloor}}
+	\providecommand{\ceil}[1]{\ensuremath{\left\lceil #1\right\rceil}}
+	\providecommand{\Angle}[1]{\ensuremath{\left\langle #1\right\rangle}}
+	\providecommand{\abs}[1]{\ensuremath{\left\lvert #1 \right\rvert}}
+	\providecommand{\norm}[1]{\ensuremath{\left\|#1\right\|}}
+	\providecommand{\concat}{\ensuremath{\|}}
+	
+	\providecommand{\emptystring}{\ensuremath{\varepsilon}}
+}
+
+\DeclareOption{adversary}{
+	\providecommand{\pcadvstyle}[1]{\mathcal{#1}}
+	
+	\providecommand{\adv}{\ensuremath{\pcadvstyle{A}}}
+	\providecommand{\bdv}{\ensuremath{\pcadvstyle{B}}}
+	\providecommand{\cdv}{\ensuremath{\pcadvstyle{C}}}
+	\providecommand{\ddv}{\ensuremath{\pcadvstyle{D}}}
+	\providecommand{\mdv}{\ensuremath{\pcadvstyle{M}}}
+	\providecommand{\pdv}{\ensuremath{\pcadvstyle{P}}}
+	\providecommand{\rdv}{\ensuremath{\pcadvstyle{R}}}
+	\providecommand{\sdv}{\ensuremath{\pcadvstyle{S}}}
+}
+
+\DeclareOption{landau}{
+	\pc at orderofgrowthtrue
+	
+	\providecommand{\bigO}[1]{\ensuremath{\mathcal{O}\olrk{#1}}}
+        \providecommand{\smallO}[1]{\ensuremath{\text{o}\olrk{#1}}}
+        \providecommand{\bigOmega}[1]{\ensuremath{\Omega\olrk{#1}}}
+        \providecommand{\smallOmega}[1]{\ensuremath{\omega\olrk{#1}}}
+        \providecommand{\bigsmallO}[1]{\ensuremath{\Theta\olrk{#1}}}
+}
+
+\DeclareOption{probability}{
+	\pc at orderofgrowthtrue
+	\pc at amsfontstrue
+
+	\providecommand{\probname}{Pr}
+	\providecommand{\expectationname}{\ensuremath{\mathbb{E}}}
+	\providecommand{\supportname}{Supp}
+
+	\providecommand{\tprob}[1]{\ensuremath{\operatorname{\probname}\telrk{#1}}}
+	\providecommand{\prob}[1]{\ensuremath{\operatorname{\probname}\elrk{#1}}}
+	
+	\providecommand{\tprobsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\telrk{#2}}}
+	\providecommand{\probsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\elrk{#2}}}
+	
+	\providecommand{\tcondprob}[2]{\ensuremath{\tprob{#1\,\left|\,#2\vphantom{#1}\right.}}}
+	\providecommand{\condprob}[2]{\ensuremath{\prob{#1\,\left|\,#2\vphantom{#1}\right.}}}
+	
+	\providecommand{\tcondprobsub}[3]{\ensuremath{\tprobsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+    \providecommand{\condprobsub}[3]{\ensuremath{\probsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+   
+	\providecommand{\texpect}[1]{\ensuremath{\operatorname{\expectationname}\telrk{#1}}}
+	\providecommand{\expect}[1]{\ensuremath{\operatorname{\expectationname}\elrk{#1}}}
+	
+	\providecommand{\texpsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\telrk{#2}}}
+	\providecommand{\expsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\elrk{#2}}}
+	
+	\providecommand{\tcondexp}[2]{\ensuremath{\texpect{#1\,\left|\,#2\vphantom{#1}\right.}}}
+	\providecommand{\condexp}[2]{\ensuremath{\expect{#1\,\left|\,#2\vphantom{#1}\right.}}}
+	
+	\providecommand{\tcondexpsub}[3]{\ensuremath{\texpsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+	\providecommand{\condexpsub}[3]{\ensuremath{\expsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+
+	\providecommand{\supp}[1]{  \ensuremath{\operatorname{Supp}\olrk{#1}}}
+	
+	\providecommand{\entropy}[1]{\ensuremath{\operatorname{H}\olrk{#1}}}
+   	\providecommand{\condentropy}[2]{\ensuremath{\operatorname{H}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}    	
+	\providecommand{\minentropy}[1]{\ensuremath{\operatorname{H_\infty}\olrk{#1}}}
+    	\providecommand{\condminentropy}[2]{\ensuremath{\operatorname{H_\infty}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}    
+    	\providecommand{\condavgminentropy}[2]{\ensuremath{\operatorname{\tilde{H}_\infty}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}        	
+}
+
+\DeclareOption{sets}{
+        \pc at orderofgrowthtrue
+        \pc at amsfontstrue
+
+        \providecommand\NN{\mathbb{N}}
+        \providecommand\ZZ{\mathbb{Z}}
+        \providecommand\CC{\mathbb{C}}
+        \providecommand\QQ{\mathbb{Q}}
+        \providecommand\RR{\mathbb{R}}
+        \providecommand\PP{\mathbb{P}}
+        \providecommand\FF{\mathbb{F}}
+        \providecommand\GG{\mathbb{G}}            
+
+        \providecommand{\set}[1]{\ensuremath{\clrk{#1}}}
+	\providecommand{\sequence}[1]{\ensuremath{\olrk{#1}}}
+	\providecommand{\bin}{\ensuremath{\{0,1\}}}
+}
+
+\DeclareOption{noamsfonts}{
+	\pc at amsfontsfalse
+}
+
+
+\DeclareOption{notions}{
+	\providecommand{\pcnotionstyle}[1]{\ensuremath{\mathrm{#1}}}
+		
+	\providecommand{\indcpa}{\pcnotionstyle{IND\pcmathhyphen{}CPA}}
+	\providecommand{\indcca}{\pcnotionstyle{IND\pcmathhyphen{}CCA}}
+	\providecommand{\indccai}{\pcnotionstyle{IND\pcmathhyphen{}CCA1}}
+	\providecommand{\indccaii}{\pcnotionstyle{IND\pcmathhyphen{}CCA2}}
+	\providecommand{\priv}{\pcnotionstyle{PRIV}}
+	\providecommand{\ind}{\pcnotionstyle{IND}}
+	\providecommand{\indcda}{\pcnotionstyle{IND\pcmathhyphen{}CDA}}
+	\providecommand{\prvcda}{\pcnotionstyle{PRV\pcmathhyphen{}CDA}}
+	\providecommand{\prvrcda}{\pcnotionstyle{PRV\$\pcmathhyphen{}CDA}}
+	\providecommand{\kiae}{\pcnotionstyle{KIAE}}
+	\providecommand{\kdae}{\pcnotionstyle{KDAE}}
+	\providecommand{\mle}{\pcnotionstyle{MLE}}	
+	\providecommand{\uce}{\pcnotionstyle{UCE}}
+}
+
+\DeclareOption{logic}{
+        \providecommand{\AND}{\ensuremath{\mathrm{AND}}}
+        \providecommand{\OR}{\ensuremath{\mathrm{OR}}}
+        \providecommand{\NOR}{\ensuremath{\mathrm{NOR}}}
+        \providecommand{\NOT}{\ensuremath{\mathrm{NOT}}}
+        \providecommand{\NAND}{\ensuremath{\mathrm{NAND}}}        
+		\providecommand{\XOR}{\ensuremath{\mathrm{XOR}}}		
+		\providecommand{\XNOR}{\ensuremath{\mathrm{XNOR}}}		
+		\providecommand{\xor}{\ensuremath{\oplus}}        
+        \providecommand{\false}{\mathsf{false}} 
+        \providecommand{\true}{\mathsf{true}}
+}
+
+
+% Function Families
+\DeclareOption{ff}{
+	\pc at algorithmstyletrue
+
+	\providecommand{\kgen}{\pcalgostyle{KGen}}
+	\providecommand{\pgen}{\pcalgostyle{Pgen}}
+	\providecommand{\eval}{\pcalgostyle{Eval}}
+	\providecommand{\invert}{\pcalgostyle{Inv}}	
+	
+	\providecommand{\il}{\pcalgostyle{il}}
+	\providecommand{\ol}{\pcalgostyle{ol}}
+	\providecommand{\kl}{\pcalgostyle{kl}}
+	\providecommand{\nl}{\pcalgostyle{nl}}
+	\providecommand{\rl}{\pcalgostyle{rl}}
+}
+
+% Machine Model
+\DeclareOption{mm}{
+	\pc at algorithmstyletrue
+	
+	\providecommand{\pcmachinemodelstyle}[1]{\ensuremath{\mathsf{#1}}}
+
+        \providecommand{\CRKT}{\pcmachinemodelstyle{C}}
+        \providecommand{\TM}{\pcmachinemodelstyle{M}}
+        \providecommand{\PROG}{\pcmachinemodelstyle{P}}
+        
+        \providecommand{\uTM}{\pcmachinemodelstyle{UM}}
+        \providecommand{\uC}{\pcmachinemodelstyle{UC}}
+        \providecommand{\uP}{\pcmachinemodelstyle{UEval}}
+
+        \providecommand{\csize}{\pcmachinemodelstyle{size}}        
+        \providecommand{\tmtime}{\pcmachinemodelstyle{time}}
+        \providecommand{\ppt}{\pcalgostyle{PPT}}
+}
+
+\DeclareOption{advantage}{
+	\pc at advantagetrue
+}
+
+\DeclareOption{primitives}{
+	\pc at primitivestrue
+	\pc at algorithmstyletrue
+}
+
+\DeclareOption{events}{
+	\providecommand{\event}[1]{\ensuremath{\mathsf{#1}}}
+	\providecommand{\nevent}[1]{\ensuremath{\overline{\event{#1}}}}
+
+	\providecommand{\bad}{\ensuremath{\event{bad}}}
+}
+
+\DeclareOption{complexity}{
+	\providecommand{\pccomplexitystyle}[1]{\ensuremath{\mathsf{#1}}}
+
+	\providecommand{\npol}{\pccomplexitystyle{NP}}
+	\providecommand{\conpol}{\ensuremath{\mathsf{co}}\pccomplexitystyle{NP}}
+	\providecommand{\pol}{\pccomplexitystyle{P}}
+	\providecommand{\bpp}{\pccomplexitystyle{BPP}}
+	\providecommand{\ppoly}{\ensuremath{\pol/\mathrm{poly}}}
+
+	\providecommand{\AM}{\pccomplexitystyle{AM}}
+	\providecommand{\coAM}{\ensuremath{\mathsf{co}}\pccomplexitystyle{AM}}
+
+	\providecommand{\AC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{AC}}{\pccomplexitystyle{AC}^{#1}}}}
+	\providecommand{\NC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{NC}}{\pccomplexitystyle{NC}^{#1}}}}
+	\providecommand{\TC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{TC}}{\pccomplexitystyle{TC}^{#1}}}}
+}
+
+\DeclareOption{asymptotics}{
+	\pc at orderofgrowthtrue
+
+	\providecommand{\pcpolynomialstyle}[1]{\mathsf{#1}}
+	
+	\providecommand{\negl}[1][\secpar]{\ensuremath{\pcpolynomialstyle{negl}\ifthenelse{\equal{#1}{}}{}{\olrk{#1}}}}
+  	\providecommand{\poly}[1][\secpar]{\ensuremath{\pcpolynomialstyle{poly}\ifthenelse{\equal{#1}{}}{}{\olrk{#1}}}}
+	
+	\providecommand{\pp}{\ensuremath{\pcpolynomialstyle{p}}}
+	\providecommand{\qq}{\ensuremath{\pcpolynomialstyle{q}}}	
+}
+
+\DeclareOption{keys}{
+            \providecommand{\pckeystyle}[1]{\ensuremath{\mathsf{\protect\vphantom{p}#1}}}
+            
+            \providecommand{\pk}{\pckeystyle{pk}}
+            \providecommand{\vk}{\pckeystyle{vk}}
+            \providecommand{\sk}{\pckeystyle{sk}}
+            \providecommand{\key}{\pckeystyle{k}}
+            \providecommand{\hk}{\pckeystyle{hk}}
+            \providecommand{\gk}{\pckeystyle{gk}}
+            \providecommand{\fk}{\pckeystyle{fk}}
+            
+            \providecommand{\st}{\pckeystyle{st}}
+            \providecommand{\state}{\pckeystyle{state}}            
+}
+
+\DeclareOption{n}{
+	\providecommand{\secpar}{\ensuremath{n}}
+	\providecommand{\secparam}{\ensuremath{1^\secpar}}
+}
+
+\DeclareOption{lambda}{
+	\renewcommand{\secpar}{\ensuremath{\lambda}}
+	\renewcommand{\secparam}{\ensuremath{1^\secpar}}
+}
+
+\DeclareOption*{%
+	\PackageError{crypto code}{Unknown option ‘\CurrentOption’}%
+}
+
+\ExecuteOptions{n}
+
+\ProcessOptions\relax
+
+\RequirePackage{etex}
+
+%amsfonts
+\ifpc at amsfonts
+	\RequirePackage{amsfonts}
+\fi
+\RequirePackage{xcolor}
+\RequirePackage{calc}
+\RequirePackage{tikz}
+\usetikzlibrary{positioning,calc}
+\RequirePackage{ifthen}
+\RequirePackage{xargs}
+\RequirePackage{pgf}
+%\RequirePackage{mathabx}
+\RequirePackage{forloop}
+\RequirePackage{array}
+\RequirePackage{xparse}
+\RequirePackage{expl3}
+\RequirePackage{pbox}
+\RequirePackage{varwidth}
+\RequirePackage{suffix}
+\RequirePackage{etoolbox}
+\RequirePackage{environ}
+%\RequirePackage{xspace}
+\RequirePackage{xkeyval}
+
+\ifpc at advantage
+	\newcommand{\pcadvantagesuperstyle}[1]{\mathrm{\MakeLowercase{#1}}}
+	\newcommand{\pcadvantagesubstyle}[1]{#1}
+	\newcommandx*{\advantage}[3][3=(\secpar)]{\ensuremath{\mathsf{Adv}^{\pcadvantagesuperstyle{#1}}_{\pcadvantagesubstyle{#2}}#3}}
+\fi
+
+\ifpc at primitives	
+	% zero knowledge
+	\providecommand{\prover}{\pcalgostyle{P}}
+	\providecommand{\verifier}{\pcalgostyle{V}}
+	\providecommand{\nizk}{\pcalgostyle{NIZK}}
+	
+	% hash
+	\providecommand{\hash}{\pcalgostyle{H}}
+	\providecommand{\gash}{\pcalgostyle{G}}
+	\providecommand{\fash}{\pcalgostyle{F}}
+	
+	% encryption
+	\providecommand{\enc}{\pcalgostyle{Enc}}
+	\providecommand{\dec}{\pcalgostyle{Dec}}
+	
+	% signatures
+	\providecommand{\sig}{\pcalgostyle{Sig}}
+	\providecommand{\verify}{\pcalgostyle{Vf}}
+	
+	% obfuscation
+	\providecommand{\obf}{\pcalgostyle{O}}
+	\providecommand{\iO}{\pcalgostyle{iO}}
+	\providecommand{\diO}{\pcalgostyle{diO}}
+	
+	% PRF, PRP, PRG
+	\providecommand{\prf}{\pcalgostyle{PRF}}
+	\providecommand{\prp}{\pcalgostyle{PRP}}
+	\providecommand{\prg}{\pcalgostyle{PRG}}
+	
+	% Mac
+	\providecommand{\mac}{\pcalgostyle{MAC}}
+	
+	% puncture
+	\providecommand{\puncture}{\pcalgostyle{Puncture}}
+	
+	% Misc
+	\providecommand{\source}{\pcalgostyle{S}}
+	\providecommand{\predictor}{\pcalgostyle{P}}
+	\providecommand{\sam}{\pcalgostyle{Sam}}
+	\providecommand{\dist}{\pcalgostyle{D}}
+	\providecommand{\distinguisher}{\pcalgostyle{Dist}}
+	\providecommand{\simulator}{\pcalgostyle{Sim}}
+	\providecommand{\ext}{\pcalgostyle{Ext}}
+	\providecommand{\extractor}{\ext}	
+\fi
+
+%%
+% math hyphen
+\mathchardef\pcmathhyphen ="2D
+
+%%%
+% order of growth helper
+\ifpc at orderofgrowth
+\providecommand{\tolrk}[1]{\ifx\nursymbol#1\else\!\!\mskip6.5mu plus 0.5mu (\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu )\fi}
+\providecommand{\olrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus 0.5mu\left(\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right)\fi}
+
+\providecommand{\telrk}[1]{\ifx\nursymbol#1\else\!\!\mskip6.5mu plus0.5mu [\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu ]\fi}
+\providecommand{\elrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus0.5mu\left[\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right]\fi}
+
+\providecommand{\tclrk}[1]{\ifx\nursymbol#1\else\!\!\mskip6.5mu plus0.5mu \{\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \}\fi}
+\providecommand{\clrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus0.5mu\left\{\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right\}\fi}
+\fi
+
+\ifpc at algorithmstyle
+	\providecommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
+\fi
+
+%%%
+% create command to measure width of align
+%
+\newcommand{\@settowidthofalign}[2]{%
+  \setbox\z@=\vbox{\@pseudocodecodesize
+    \begin{flalign*}
+    #2
+    \ifmeasuring@\else\global\let\got at maxcolwd\maxcolumn at widths\fi
+    \end{flalign*}
+  }%
+  \begingroup
+  \def\or{+}\edef\x{\endgroup#1=\dimexpr\got at maxcolwd\relax}\x}
+
+\newcommand{\@settowidthofaligned}[2]{%
+\settowidth{#1}{\@pseudocodesubcodesize$\begin{aligned}#2\end{aligned}$}}
+
+% check for draft mode
+\def\@pc at ifdraft{\ifdim\overfullrule>\z@
+  \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
+
+% run stuff in an empty box
+\newcommand{\@pcexecuteblindly}[1]{%
+ \setbox\z@=\vbox{#1 }}
+
+% copy label command
+\AtBeginDocument{
+	\let\pc at original@label\ltx at label
+}
+
+
+%%%%%%
+\newcommand*{\@pc at globaladdtolength}[2]{%
+\addtolength{#1}{#2}%
+\global#1=#1\relax}
+
+\newcommand*{\@pc at globalsetlength}[2]{%
+\setlength{#1}{#2}%
+\global#1=#1\relax}
+
+
+
+%%%%%
+% spaces before and after pseudo codes (left and right)
+\providecommand{\beforepcskip}{2pt}
+\providecommand{\afterpcskip}{0pt}
+
+%%%
+% a global counter of the number of times the pseudocode command was triggered
+\newcounter{@pc at global@pc at cnt}
+\newcounter{@pc at global@pc at nestcnt}
+
+%%%
+% Fix hyperref package.. gnarl http://tex.stackexchange.com/questions/130319/incompatibility-between-etoolbox-and-hyperref
+\providecommand{\pcfixhyperref}{
+\global\let\textlabel\label
+\global\let\pc at original@label\textlabel
+%\global\let\pc at original@label\relax
+%\global\let\label\relax
+}
+
+\newcounter{@spacecounter}
+\providecommand{\spacetoindent}{1}
+\newenvironment{@withspaces}
+ {\obeyspaces\begingroup\lccode`~=` \lowercase{\endgroup\let~}\ }
+ {}
+
+%%%%%%%%%%%%%%
+% a latex3 string substitution.
+\ExplSyntaxOn
+\tl_new:N \l_pc_strsub_input_tl
+\tl_new:N \l_pc_strsub_search_tl
+\tl_new:N \l_pc_strsub_replace_tl
+
+\NewDocumentCommand{\@pc at stringsubstitution}{mmm}
+ {
+  \tl_set:Nn \l_pc_strsub_input_tl { #1 }
+  \tl_set:Nn \l_pc_strsub_search_tl { #2 }
+  \tl_set:Nn \l_pc_strsub_replace_tl { #3 }
+%  \tl_show_analysis:N  \l_pc_strsub_input_tl % uncomment for debugging
+%  \tl_show_analysis:N  \l_pc_strsub_search_tl % uncomment for debugging
+%  \tl_show_analysis:N  \l_pc_strsub_replace_tl % uncomment for debugging
+   \regex_replace_all:nnN
+      { (\W)\u{l_pc_strsub_search_tl} } %only match if keyword does not have a word character preceding
+      { \1\u{l_pc_strsub_replace_tl} }
+      \l_pc_strsub_input_tl
+      %  \tl_show_analysis:N \l_tmpa_tl % uncomment for debugging
+      \tl_use:N \l_pc_strsub_input_tl    
+ }
+ 
+ % same as \@pc at stringsubstitution but without requiring the extra non word character
+ \NewDocumentCommand{\@pc at spacesubstitution}{mmm}
+ {
+  \tl_set:Nn \l_pc_strsub_input_tl { #1 }
+  \tl_set:Nn \l_pc_strsub_search_tl { #2 }
+  \tl_set:Nn \l_pc_strsub_replace_tl { #3 }
+%  \tl_show_analysis:N  \l_pc_strsub_input_tl % uncomment for debugging
+%  \tl_show_analysis:N  \l_pc_strsub_search_tl % uncomment for debugging
+%  \tl_show_analysis:N  \l_pc_strsub_replace_tl % uncomment for debugging
+   \regex_replace_all:nnN
+      { \u{l_pc_strsub_search_tl} } 
+      { \u{l_pc_strsub_replace_tl} }
+      \l_pc_strsub_input_tl
+      %  \tl_show_analysis:N \l_tmpa_tl % uncomment for debugging
+      \tl_use:N \l_pc_strsub_input_tl    
+ }
+ 
+\NewDocumentCommand{\@pc at centercolifnec}{m}%
+{%
+#1%
+}
+ 
+ 
+ 
+\ExplSyntaxOff
+
+%%%%%%%%
+% line numbers
+%%%%%%%%
+% The following commands handle line numbering within the pseudocode command. The
+% pseudocode command itself does need to do some counter magic
+\newcounter{pclinenumber}
+\newcounter{Hpclinenumber} % make hyperref happy
+\newcounter{@pclinenumber}
+\newcounter{H at pclinenumber} % make hyperref happy
+\newcounter{@pclinenumbertmp}
+\newcounter{pcgamecounter}
+\newcounter{Hpcgamecounter}
+\newcounter{pcrlinenumber}
+\newcounter{Hpcrlinenumber}
+\newcounter{@pcrlinenumbertmp}
+
+% separators
+\providecommand{\pclnseparator}{:}
+\providecommand{\pcrlnseparator}{\hspace{1pt}}
+
+% spacing for linenumbers
+\providecommand{\pclnspace}{0pt}
+\providecommand{\pclnrspace}{5pt}
+
+\renewcommand{\the at pclinenumber}{\thepclinenumber}
+\providecommand{\@pcln}{%
+\refstepcounter{@pclinenumber}%
+\stepcounter{H at pclinenumber}%
+}
+
+% left align line numbers
+\providecommand{\pcln}[1][]{%
+\refstepcounter{pclinenumber}%
+\stepcounter{Hpclinenumber}%
+\ifthenelse{\equal{#1}{}}{}{%
+%keep hyperref happy
+\ifmeasuring@\else\pc at original@label{#1}\fi%
+}%
+\ifthenelse{\value{pclinenumber}<10}{\hspace{1ex}}{}%
+\hspace{\pclnspace}\text{\scriptsize\arabic{pclinenumber}}\pclnseparator\quad}%
+
+% allow to skip numbering single lines if linenumbering=on 
+\providecommand{\pcnoln}{%
+}
+
+% right align line numbers (same counter)
+\providecommand{\pclnr}{%
+\refstepcounter{pclinenumber}%
+\quad\text{\scriptsize\pcrlnseparator\arabic{pclinenumber}}\hspace{5pt}}
+
+% right align line numbers different counter
+\providecommand{\pcrln}{
+\refstepcounter{pcrlinenumber}%
+\stepcounter{Hpcrlinenumber}%
+\text{\scriptsize\pcrlnseparator\arabic{pcrlinenumber}}\hspace{\pclnrspace}}
+
+
+%%%
+% indentation
+\newlength{\@pcindentwidth}
+\providecommand{\pcind}[1][1]{%
+\setlength{\@pcindentwidth}{\widthof{\ensuremath{\quad}}*#1}%
+\ensuremath{\mathmakebox[\@pcindentwidth]{}}}
+
+
+% create length
+\newlength{\@pc at minipage@length}
+\newlength{\@pc at alt@minipage at length}
+
+% backward games
+\newcommand{\@withingame}{false}
+\newcommand{\@withinbxgame}{false}
+\newcommand{\@bxgameheader}{}
+\newcommand{\@withingamedescription}{false}
+
+
+%%%%%%%%%%%%
+% The pseudocode Command
+%%%%%
+\newlength{\@pc at length@tmp at width@vstack}
+
+
+\newcommand{\@pc at beginnewline}{%
+\@pseudocodecodeatbeginline\@pseudocodelinenumber\@pc at and\@pcln%
+%checkspace
+\ifthenelse{\equal{\@pseudocodespace}{auto}}%
+{\expandafter\pcind\expandafter[\value{@pc at indentationlevel}]}%
+{}%
+%reset column counter
+\setcounter{pccolumncounter}{2}%
+%beginmode
+\@pc at modebegin}
+\newcommand{\@pc at and}{&}
+\newcommand{\@pc at and@wrap at end}{\@pc at modeend&\@pseudocodecodeatendline}
+\newcommand{\@pc at and@wrap at start}{\@pc at beginnewline}
+\newcommand{\pctabname}{>}
+\newcommand{\pcdbltabname}{<}
+\newcommand{\pcindentname}{t}
+
+
+
+\newcommand*\@pseudocodehead{}
+\newcommand*\@pseudocodewidth{}
+\newcommand*\@pseudocodexshift{0pt}
+\newcommand*\@pseudocodeyshift{0pt}
+\newcommand*\@pseudocodelinenumber{}
+\newcommand*\@pseudocodebeforeskip{0ex}
+\newcommand*\@pseudocodeafterskip{0ex}
+\newcommand*\@pseudocodelnstart{0}
+\newcommand*\@pseudocodelnstartright{0}
+\newcommand*\@pseudocodesyntaxhighlighting{}
+\newcommand*\@pseudocodenodraft{false}
+\newcommand*\@pseudocodecolspace{} % empty per default, use length,
+
+\newcommand*\@pseudocodeheadlinecmd{\hrule}
+\newcommand*\@pseudocodeheadlinesep{0em}
+\newcommand*\@pseudocodebodylinesep{-0.5\baselineskip}
+
+\newcommand*\@pseudocodecolsep{0em}
+\newcommand*\@pseudocodeaddtolength{2pt}
+
+\newcommand*\@pseudocodecodeatbeginline{}
+\newcommand*\@pseudocodecodeatendline{}
+\newcommand*\@pseudocodecodejot{0em}
+\newcommand*\@pseudocodecodesize{\small}
+\newcommand*\@pseudocodesubcodesize{\footnotesize}
+
+\newcommand*\@pseudocodeminipagealign{t}
+
+%%%%%%%%%%%%%%
+% Define keywords for the automatic syntax highlighting
+% the accompanying add provides additional keywords.
+% The space version for automatic spacing
+\newcommand*\@pseudocodekeywordsindent{for ,foreach ,if ,repeat ,while }
+\newcommand*\@pseudocodekeywordsunindent{endfor,endforeach,fi,endif,until ,endwhile}
+\newcommand*\@pseudocodekeywordsuninindent{else if,elseif, else}
+\newcommand*\@pseudocodekeywords{return ,{ do }, in ,new ,null ,null,true ,true,{ to },false ,false,{ then },done ,done}
+\newcommand*\@pseudocodeaddkeywords{}
+\newcommand*\@pseudocodealtkeywords{}
+\begin{@withspaces}
+\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}
+\end{@withspaces}
+
+
+\define at key{pseudocode}{beginline}[]{\renewcommand*\@pseudocodecodeatbeginline{#1}}
+\define at key{pseudocode}{endline}[]{\renewcommand*\@pseudocodecodeatendline{#1}}
+\define at key{pseudocode}{jot}[0em]{\renewcommand*\@pseudocodecodejot{#1}}
+\define at key{pseudocode}{codesize}[\small]{\renewcommand*\@pseudocodecodesize{#1}}
+\define at key{pseudocode}{subcodesize}[\small]{\renewcommand*\@pseudocodesubcodesize{#1}}
+\define at key{pseudocode}{head}[]{\renewcommand*\@pseudocodehead{#1}}
+\define at key{pseudocode}{width}[]{\renewcommand*\@pseudocodewidth{#1}}
+\define at key{pseudocode}{valign}[t]{\renewcommand*\@pseudocodeminipagealign{#1}}
+\define at key{pseudocode}{xshift}[]{\renewcommand*\@pseudocodexshift{#1}}
+\define at key{pseudocode}{yshift}[]{\renewcommand*\@pseudocodeyshift{#1}}
+\define at key{pseudocode}{colspace}[]{\renewcommand*\@pseudocodecolspace{#1}}
+\define at key{pseudocode}{linenumbering}[on]{\ifthenelse{\equal{#1}{on}}{\renewcommand*\@pseudocodelinenumber{\pcln}}{\renewcommand*\@pseudocodelinenumber{}}}
+\define at key{pseudocode}{beforeskip}[]{\renewcommand*\@pseudocodebeforeskip{#1}}
+\define at key{pseudocode}{afterskip}[]{\renewcommand*\@pseudocodeafterskip{#1}}
+\define at key{pseudocode}{lnstart}[0]{\renewcommand*\@pseudocodelnstart{#1}}
+\define at key{pseudocode}{lnstartright}[0]{\renewcommand*\@pseudocodelnstartright{#1}}
+\define at key{pseudocode}{colsep}[0em]{\renewcommand*\@pseudocodecolsep{#1}}
+\define at key{pseudocode}{headlinecmd}[\hrule]{\renewcommand*\@pseudocodeheadlinecmd{#1}}
+\define at key{pseudocode}{headlinesep}[0em]{\renewcommand*\@pseudocodeheadlinesep{#1}}
+\define at key{pseudocode}{bodylinesep}[0em]{\renewcommand*\@pseudocodebodylinesep{#1}}
+\define at key{pseudocode}{addtolength}[2pt]{\renewcommand*\@pseudocodeaddtolength{#1}}
+\define at key{pseudocode}{mode}[math]{%
+\ifthenelse{\equal{#1}{text}}{%
+\renewcommand*\@pc at modebegin{\begin{varwidth}{\textwidth}%
+%introduce line magic for text mode
+\let\@pc at lb\\%
+\renewcommandx*{\\}[2][1=,2=]{\@pc at modeend\@pc at and \@pseudocodecodeatendline\ifthenelse{\equal{####1}{}}{\@pc at lb}{\@pc at lb[####1]}####2 \@pc at beginnewline}%
+\def\pclb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+\def\pcolb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+}%
+\renewcommand*\@pc at modeend{\end{varwidth}}
+}{}%
+}
+\define at key{pseudocode}{nodraft}[true]{\renewcommand*\@pseudocodenodraft{#1}}
+\define at key{pseudocode}{keywords}[]{\renewcommand*\@pseudocodekeywords{#1}}
+\define at key{pseudocode}{keywordsindent}[]{\renewcommand*\@pseudocodekeywordsindent{#1}}
+\define at key{pseudocode}{keywordsunindent}[]{\renewcommand*\@pseudocodekeywordsunindent{#1}}
+\define at key{pseudocode}{keywordsuninindent}[]{\renewcommand*\@pseudocodekeywordsuninindent{#1}}
+\define at key{pseudocode}{addkeywords}[]{\renewcommand*\@pseudocodeaddkeywords{#1}}
+\define at key{pseudocode}{altkeywords}[]{\renewcommand*\@pseudocodealtkeywords{#1}}
+\define at key{pseudocode}{syntaxhighlight}[]{\renewcommand*\@pseudocodesyntaxhighlighting{#1}}
+
+\newcommand{\@pc at modebegin}{}
+\newcommand{\@pc at modeend}{}
+\newcommand{\@pc at thecontent}{}
+
+\newcommand{\@pc at syntaxhighlight}[1]{%
+\ifthenelse{\equal{\@pseudocodesyntaxhighlighting}{auto}}{%
+\def\@shtmp{#1}% first step
+\ifthenelse{\equal{\@pseudocodespace}{keep}}
+   {\edef\@tmpkeywords{\@pseudocodekeywordsspace,\@pseudocodeaddkeywords}}
+   {\ifthenelse{\equal{\@pseudocodespace}{auto}}
+      {\edef\@tmpkeywords{\@pseudocodekeywords,\@pseudocodeaddkeywords}}
+      {\edef\@tmpkeywords{\@pseudocodekeywords,\@pseudocodekeywordsindent,\@pseudocodekeywordsunindent,\@pseudocodekeywordsuninindent,\@pseudocodeaddkeywords}}}
+\foreach \@pckw in \@tmpkeywords{%
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlight\expandafter{\@pckw}}}%
+}% alt keywords
+}%
+\foreach \@pckw in \@pseudocodealtkeywords{%
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at althighlight\expandafter{\@pckw}}}%
+}%
+}%
+%%%%
+% if automatic spacing
+\ifthenelse{\equal{\@pseudocodespace}{auto}}
+{%
+\foreach \@pckw in \@pseudocodekeywordsindent{% indentation keywords
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightindent\expandafter{\@pckw}}}%
+}}%
+\foreach \@pckw in \@pseudocodekeywordsunindent{% unindentation keywords
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightunindent\expandafter{\@pckw}}}%
+}}%
+\foreach \@pckw in \@pseudocodekeywordsuninindent{% uninindentation keywords
+\ifthenelse{\equal{\@pckw}{}}{}{%
+% we are doing a simple strsub and storing the result (globally) in @shtmp
+\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                 \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+                {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
+                 }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightuninindent\expandafter{\@pckw}}}%
+}}%
+}{}%
+% return result
+\@shtmp%
+}{#1}% nothing to highlight
+}
+
+\newcommand{\@pc at highlight}[1]{%
+\ifthenelse{\equal{\@pseudocodespace}{keep}}
+    {\highlightkeyword[]{#1}}%
+    {\highlightkeyword[]{\@pc at spacesubstitution{#1}{ }{~}}}%
+}
+
+\newcommand{\@pc at highlightindent}[1]{%
+\@pc at increaseindent\@pc at highlight{#1}%
+}
+
+\newcommand{\@pc at highlightunindent}[1]{%
+\@pc at decreaseindent\@pc at highlight{#1}%
+}
+
+\newcommand{\@pc at highlightuninindent}[1]{%
+\@pc at tmpdecreaseindent\@pc at highlight{#1}%
+}
+
+\newcommand{\@pc at althighlight}[1]{%
+\ifthenelse{\equal{\@pseudocodespace}{keep}}
+    {\highlightaltkeyword{#1}}%
+    {\highlightaltkeyword{\@pc at spacesubstitution{#1}{ }{~}}}%
+}
+
+\newcommand{\@pc at colspace}{}
+
+%%%%%%%%%%%%%%%%%
+% Allow for spacing
+\newcommand{\@withinspaces}{false}%
+\newcommand{\@keepspaces}{%
+\renewcommand{\@withinspaces}{true}\@withspaces%
+}
+\newcommand{\@pc at endgroupafterpc}{}
+
+\newcommand*\@pseudocodespace{}
+\define at key{pcspace}{space}[]{\ifthenelse{\equal{#1}{keep}}{\@keepspaces}{}\renewcommand*\@pseudocodespace{#1}}
+
+%%% automatic indentation
+\newcounter{@pc at indentationlevel}
+\newcommand{\@pc at increaseindent}{\addtocounter{@pc at indentationlevel}{1}}
+\newcommand{\@pc at decreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}\addtocounter{@pc at indentationlevel}{-1}}
+\newcommand{\@pc at tmpdecreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}}
+
+\newcounter{pccolumncounter}
+\setcounter{pccolumncounter}{2}
+
+% store original halign
+\let\@pc at halign\halign%
+
+%% Check if the pseudocode command is called with an optional argument
+\providecommand{\pseudocode}{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+\@ifnextchar[%]
+  {\@pseudocodeA}%
+  {\@pseudocode[]}%
+}
+
+\def\@pseudocodeA[#1]{%
+\setkeys*{pcspace}{#1}%test if there is a space assignment within the keys .. make the necessary arrangements and call the actual method
+\@pseudocode[#1]%
+}
+
+\def\@pseudocode[#1]#2{%
+\begingroup%
+\setkeys{pseudocode}[space]{#1}%ignore the space key.
+% check draft mode and disable syntax highlighting
+\@pc at ifdraft{\ifthenelse{\equal{\@pseudocodenodraft}{true}}{}{\renewcommand\@pseudocodesyntaxhighlighting{}}}{}%
+%
+%
+\addtocounter{@pc at global@pc at nestcnt}{1}%
+% allow for tikz usage
+\@pc at ensureremember%
+%
+% create tabbing command
+\ifcsname \pctabname\endcsname%
+\expandafter\renewcommand\csname \pctabname\endcsname{\@pc at modeend&\@pc at colspace\@pc at modebegin}%
+\else%
+\expandafter\newcommand\csname \pctabname\endcsname{\@pc at modeend&\@pc at colspace\@pc at modebegin}%
+\fi%
+\ifcsname \pcdbltabname\endcsname%
+\expandafter\renewcommand\csname \pcdbltabname\endcsname{\@pc at modeend&&\@pc at colspace\@pc at modebegin}%
+\else%
+\expandafter\newcommand\csname \pcdbltabname\endcsname{\@pc at modeend&&\@pc at colspace\@pc at modebegin}%
+\fi%
+% create colspace command if necessary (must be empty for multicolumns
+\ifthenelse{\equal{\@pseudocodecolspace}{}}
+ {}
+ {\renewcommand{\@pc at colspace}{\hspace{\@pseudocodecolspace}}}%
+%
+%adjust row width
+\addtolength{\jot}{\@pseudocodecodejot}%
+% create indent command
+\expandafter\let\csname \pcindentname\endcsname\pcind%
+%
+%store and wrap (do syntax highlighting) argument 
+\renewcommand{\@pc at thecontent}{\@pc at and@wrap at start\@pc at syntaxhighlight{#2}\@pc at and@wrap at end}%
+%
+%take care of counters
+\stepcounter{@pc at global@pc at cnt}%
+\setcounter{pclinenumber}{\@pseudocodelnstart}%
+\setcounter{pcrlinenumber}{\@pseudocodelnstartright}%
+\setlength{\@pc at minipage@length}{0pt}%
+\setlength{\@pc at alt@minipage at length}{0pt}%
+\setcounter{@pclinenumbertmp}{\value{pclinenumber}}%
+\setcounter{@pcrlinenumbertmp}{\value{pcrlinenumber}}%
+%reset column counter
+\setcounter{pccolumncounter}{2}%
+%
+% vertical space
+\vspace{\@pseudocodeyshift}%
+%\setlength{\abovedisplayskip}{0pt}%
+%\setlength{\belowdisplayskip}{0pt}%
+%\setlength{\abovedisplayshortskip}{0pt}%
+%\setlength{\belowdisplayshortskip}{0pt}%
+%
+%
+% line magic
+\ifthenelse{\value{@pc at global@pc at nestcnt}=1}{%
+\let\@pc at halign\halign%
+\newenvironment{pcmbox}{\let\halign\@pc at halign}{}%
+\def\halign{%
+\renewcommand{\label}[1]{\ifmeasuring@\else\pc at original@label{####1}\fi}%
+\let\@pc at lb\\%
+\renewcommandx*{\\}[2][1=,2=]{\@pc at modeend\@pc at and\@pseudocodecodeatendline \ifthenelse{\equal{####1}{}}{\@pc at lb}{\@pc at lb[####1]}####2 \@pc at beginnewline}%
+\def\pclb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+\@pc at halign}%
+}{}%
+%
+%align column separation
+\renewcommand*{\minalignsep}{\@pseudocodecolsep}%
+%
+% if no width is set compute width and store in circuitlength
+\ifthenelse{\equal{\@pseudocodewidth}{}}{%
+% compute length of pseudocode
+\ifthenelse{\value{@pcsubprogstep}=0}{%
+\@settowidthofalign{\@pc at minipage@length}{\@pc at thecontent}%
+}{%
+\@settowidthofaligned{\@pc at minipage@length}{\@pc at thecontent}%	
+}%
+%compute length of header
+\addtolength{\@pc at alt@minipage at length}{\widthof{\@pseudocodehead}}%
+% use header length if longer and add some points for good measure
+\ifdim\@pc at alt@minipage at length>\@pc at minipage@length%
+\setlength{\@pc at minipage@length}{\@pc at alt@minipage at length}%
+\fi%
+\addtolength{\@pc at minipage@length}{\@pseudocodeaddtolength}%
+}{\addtolength{\@pc at minipage@length}{\@pseudocodewidth}}%
+% reset counter
+\setcounter{pclinenumber}{\value{@pclinenumbertmp}}%
+\setcounter{pcrlinenumber}{\value{@pcrlinenumbertmp}}%
+\setcounter{@pc at indentationlevel}{0}%
+% begin actual output
+%
+%
+%do the actual mini page
+\hspace{\@pseudocodexshift}%
+\begin{minipage}[\@pseudocodeminipagealign]{\@pc at minipage@length}%
+\ifthenelse{\value{@pcsubprogstep}=0}{%
+\pc at display@pseudocode{\@pseudocodehead}{\@pc at thecontent}%
+}{% if sub procedure
+\pc at display@subcode{\@pseudocodehead}{\@pc at thecontent}%
+}%
+\end{minipage}%
+\hspace{\afterpcskip}%
+% tikz usage
+\@pc at releaseremember%
+\addtocounter{@pc at global@pc at nestcnt}{-1}%
+\endgroup%
+% close spacing and potentially a single group generated by the space tester
+\ifthenelse{\equal{\@withinspaces}{true}}{\end at withspaces}{}%
+\endgroup%
+}
+
+\newcommand{\@pc at gameheader}[2]{%
+\tikz{\gdef\i{\thepcgamecounter}%
+\node[anchor=base,#2,inner sep=0.05em,outer sep=0] (gamenode\i) {#1\vphantom{$\sum^A_{A_b}$}}; 
+\ifthenelse{\equal{\@withinbxgame}{true}}
+  {\node[draw,anchor=base, above=0.1cm of gamenode\i] (bgamenode\i) {\@bxgameheader\vphantom{$\sum^A_{A_b}$}};}
+  {}%
+}%
+}
+
+\let\pclb\relax
+%
+\newcommand{\pc at display@pseudocode}[2]{%
+\ifthenelse{\equal{#1}{}}{\vspace{-1\baselineskip}\@pseudocodecodesize}{%
+\ifthenelse{\equal{\@withingame}{true}}{%
+\@pc at gameheader{#1}{}\ifthenelse{\equal{\@pc at secondheader}{true}}{\addtocounter{pcgamecounter}{1}\@pc at gameheader{#1}{draw}}{}%
+\vspace{0.2em}%
+}{#1\vphantom{$\sum^A_{A_b}$}}%
+\vspace{\@pseudocodeheadlinesep}\@pseudocodeheadlinecmd\vspace{\@pseudocodebodylinesep}\@pseudocodecodesize}%
+\begin{flalign*}#2\end{flalign*}%
+}
+
+
+\newcommand{\pc at display@subcode}[2]{%
+\begingroup%
+\ifthenelse{\equal{#1}{}}{}{#1\vphantom{$\sum^A_{A_b}$} %
+\vspace{\@pseudocodeheadlinesep}\@pseudocodeheadlinecmd \vspace{\baselineskip}\vspace{\@pseudocodebodylinesep}}%
+\@pseudocodesubcodesize%
+$\begin{aligned}#2\end{aligned}$%
+\endgroup%
+}
+
+
+\newcommand{\@pc at gettikzwidth}[2]{ % #1 = width, #2 = height
+ \pgfextractx{\@tempdima}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
+ {\pgfpointanchor{current bounding box}{north east}}}
+ \global#1=\@tempdima
+ \pgfextracty{\@tempdima}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
+ {\pgfpointanchor{current bounding box}{north east}}}
+ \global#2=\@tempdima
+}
+
+
+%%%%%%%%%%%%%%%%%%%
+% remember pictues
+\newcounter{@pc at remember}
+
+\newcommand{\@pc at ensureremember}{%
+\ifthenelse{\value{@pc at remember}=0}{\tikzstyle{every picture}+=[remember picture]}{}%
+\addtocounter{@pc at remember}{1}}
+
+\newcommand{\@pc at releaseremember}{%
+\addtocounter{@pc at remember}{-1}%
+\ifthenelse{\value{@pc at remember}=0}{\tikzstyle{every picture}-=[remember picture]}{}%
+}
+
+
+%%%%%%%%%%%%%%%%%%%
+% pcimage
+\newenvironment{pcimage}{%
+\begingroup\@pc at ensureremember%
+}{%
+\@pc at releaseremember\endgroup%
+}
+
+\newcommand*\@pcnodecontent{}
+\newcommand*\@pcnodestyle{}
+\newcommand*\@pcnodedraw{}
+\define at key{pcnode}{content}[]{\renewcommand*\@pcnodecontent{#1}}
+\define at key{pcnode}{style}[]{\renewcommand*\@pcnodestyle{#1}}
+\define at key{pcnode}{draw}[]{\renewcommand*\@pcnodedraw{#1}}
+
+\newcommandx*{\pcnode}[2][2=]{%
+\begingroup\setkeys{pcnode}{#2}%
+\tikzset{PCNODE-STYLE/.style/.expand once=\@pcnodestyle}%
+\begin{tikzpicture}[inner sep=0ex,baseline=0pt]%
+\node[PCNODE-STYLE] (#1) {\@pcnodecontent}; %
+\end{tikzpicture}%
+\ifdefempty{\@pcnodedraw}{}{%
+\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt]\@pcnodedraw\end{tikzpicture}
+}%
+\endgroup}
+
+\newcommandx*{\pcdraw}[2][2=]{%
+\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#2]
+#1
+\end{tikzpicture}}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%
+% Reductions
+\newcommand{\@bb at lastbox}{}
+\newcommand{\@bb at lastoracle}{}
+\newcommand{\@bb at lastchallenger}{}
+
+
+\newlength{\@bb at message@hoffset}
+\newlength{\@bb at query@hoffset}
+\newlength{\@bb at oraclequery@hoffset}
+\newlength{\@bb at challengerquery@hoffset}
+
+\newcounter{@bb at oracle@cnt}
+\newcounter{@bb at oracle@nestcnt}
+\newcounter{@bb at challenger@cnt}
+\newcounter{@bb at challenger@nestcnt}
+
+\newcounter{@bb at env@nestcnt}
+
+\newcommand{\bbroraclenodenameprefix}{ora-}
+\newcommand{\bbrchallengernodenameprefix}{challenger-}
+\newcommand{\bbrenvnodenameprefix}{env-}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Black Box Reduction Environment
+\newenvironmentx{bbrenv}[3][1=0pt,3=0pt]{%
+\addtocounter{@bb at env@nestcnt}{1}%
+\renewcommand{\@bb at lastbox}{#2}%
+%
+% reset lengths
+\@pc at globalsetlength{\@bb at message@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at query@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at oraclequery@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at challengerquery@hoffset}{0pt}%
+%
+%reset oracle counter and oracle query offset
+\ifthenelse{\value{@bb at oracle@nestcnt}=0}
+ {\setcounter{@bb at oracle@cnt}{0}}{}%
+\ifthenelse{\value{@bb at challenger@nestcnt}=0}
+  {\setcounter{@bb at challenger@cnt}{0}}{}%
+%
+\def\@bbendskip{#3}%
+\vspace{#1}%
+\ifthenelse{\value{@bb at env@nestcnt}=1}
+ {\@pc at ensureremember%
+\begin{tikzpicture}
+}{\tikz\bgroup}
+}{%
+\ifthenelse{\value{@bb at env@nestcnt}=1}
+{\end{tikzpicture}%
+\@pc at releaseremember%
+}{\egroup}%
+\vspace{\@bbendskip}%
+\addtocounter{@bb at env@nestcnt}{-1}%
+% reset lengths
+\@pc at globalsetlength{\@bb at message@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at query@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at oraclequery@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at challengerquery@hoffset}{0pt}%
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% black box reduction box
+% option keys
+\newcommand*\bbrboxname{}
+\newcommand*\bbrboxnamepos{right}
+\newcommand*\bbrboxnamestyle{}
+\newcommand*\@bbrboxnamepos{below right=0.5ex and -0.5ex of \@bb at lastbox.north east,anchor=north east}
+\newcommand*\bbrboxabovesep{\baselineskip}
+\newcommand*\@bbrboxnameposoffset{below left=\bbrboxabovesep of phantomname.south west}
+\newcommand*\bbrboxstyle{draw}
+\newcommand*\bbrboxafterskip{}
+\newcommand*\bbrboxminheight{0cm}
+\newcommand*\bbrboxminwidth{2cm}
+\newcommand*\bbrboxxshift{0cm}
+\newcommand*\bbrboxyshift{0cm}
+\define at key{bbrbox}{abovesep}[]{\renewcommand*\bbrboxabovesep{#1}}
+\define at key{bbrbox}{name}[]{\renewcommand*\bbrboxname{#1}}
+\define at key{bbrbox}{namestyle}[]{\renewcommand*\bbrboxnamestyle{#1}}
+\define at key{bbrbox}{namepos}[]{\renewcommand*\bbrboxnamepos{#1}}
+\define at key{bbrbox}{style}[draw]{\renewcommand*\bbrboxstyle{#1}}
+\define at key{bbrbox}{minwidth}[]{\renewcommand*\bbrboxminwidth{#1}}
+\define at key{bbrbox}{addheight}[]{\renewcommand*\bbrboxafterskip{#1}}
+\define at key{bbrbox}{minheight}[]{\renewcommand*\bbrboxminheight{#1}}
+\define at key{bbrbox}{xshift}[]{\renewcommand*\bbrboxxshift{#1}}
+\define at key{bbrbox}{yshift}[]{\renewcommand*\bbrboxyshift{#1}}
+
+
+\NewEnviron{bbrbox}[1][]{%
+\setkeys{bbrbox}{#1}%
+
+\ifthenelse{\equal{\bbrboxnamepos}{center}}
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north,anchor=north}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{left}}
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north west,anchor=north west}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{top right}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north east,anchor=south east}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{}
+\ifthenelse{\equal{\bbrboxnamepos}{top center}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north,anchor=south}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{top left}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north west,anchor=south west}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{middle}}
+ {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=south}}{} 
+\ifthenelse{\equal{\bbrboxnamepos}{bottom}}
+ {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=north}}{} 
+
+
+\tikzset{BBRBOXSTYLE/.style/.expand once=\bbrboxstyle}%
+\tikzset{BBRBOXNAMEPOS/.style/.expand once=\@bbrboxnamepos}%
+\tikzset{BBRBOXNAMESTYLE/.style/.expand once=\bbrboxnamestyle}%
+\tikzset{BBRBOXNAMEPOSOFFSET/.style/.expand once=\@bbrboxnameposoffset}%
+
+\node[inner sep=0pt,outer sep=0pt] (\@bb at lastbox-tmpouter) {};
+\node[inner sep=.3333em,anchor=north,BBRBOXSTYLE,minimum height=\bbrboxminheight,below right=\bbrboxyshift and \bbrboxxshift of \@bb at lastbox-tmpouter] (\@bb at lastbox)  \bgroup
+	\tikz{
+		\node[inner sep=0pt,outer sep=0pt,minimum height=0cm] (phantomname) {}; %minimum width
+		\node[BBRBOXNAMEPOSOFFSET,minimum height=0cm] (\@bb at lastbox-inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}};
+		\ifthenelse{\equal{\bbrboxafterskip}{}}{}{
+			\node[below=0cm of \@bb at lastbox-inner,minimum height=\bbrboxafterskip] {};
+		}
+		\node[inner sep=0pt,outer sep=0pt,at=(\@bb at lastbox-inner.south west),minimum height=0cm] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width
+	}
+\egroup;
+\ifthenelse{\equal{\bbrboxnamepos}{none}}
+{}{\node[BBRBOXNAMEPOS,BBRBOXNAMESTYLE, inner sep=0.2ex, outer sep=0pt, overlay] () {\bbrboxname};}
+}
+
+
+\newcommand*\bbroraclevdistance{\baselineskip}
+\newcommand*\bbroraclehdistance{1.5cm}
+\define at key{bbroracle}{distance}[]{\renewcommand*\bbroraclehdistance{#1}}
+\define at key{bbroracle}{hdistance}[]{\renewcommand*\bbroraclehdistance{#1}}
+\define at key{bbroracle}{vdistance}[]{\renewcommand*\bbroraclevdistance{#1}}
+
+
+% ORACLES
+\newenvironmentx{bbroracle}[2][2=]{%
+	\begingroup
+	\setkeys{bbroracle}{#2}
+	%add to nesting cout
+	\addtocounter{@bb at oracle@nestcnt}{1}
+	%if first oracle, then put it to the right, else stack them vertically
+	\addtocounter{@bb at oracle@cnt}{1}
+	\ifthenelse{\value{@bb at oracle@cnt}=1}{
+	\setlength{\@bb at tmplength@b}{\bbroraclevdistance-\baselineskip}
+	\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
+	}{
+% compute distance of top of last box to bottom of last oracle
+	\coordinate (@bbtmpcoord) at (\@bb at lastbox.north east);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordA}
+	\coordinate (@bbtmpcoord) at (\bbroraclenodenameprefix \@bb at lastoracle.south west);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordB}
+	\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB+\bbroraclevdistance}
+	\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
+	}
+	\global\def\@bb at lastoracle{#1}
+	\begin{bbrenv}{#1}
+}{
+	\end{bbrenv}
+	\egroup;
+
+	\addtocounter{@bb at oracle@nestcnt}{-1}
+	\endgroup
+}
+
+
+\newcommand*\bbrchallengerhdistance{1.5cm}
+\newcommand*\bbrchallengervdistance{\baselineskip}
+\define at key{bbrchallenger}{distance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
+\define at key{bbrchallenger}{hdistance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
+\define at key{bbrchallenger}{vdistance}[]{\renewcommand*\bbrchallengervdistance{#1}}
+
+
+% Challenger
+\newenvironmentx{bbrchallenger}[2][2=]{%
+\begingroup%
+\setkeys{bbrchallenger}{#2}%
+%add to nesting cout
+\addtocounter{@bb at challenger@nestcnt}{1}%
+%if first oracle, then put it to the right, else stack them vertically
+\addtocounter{@bb at challenger@cnt}{1}%
+\ifthenelse{\value{@bb at challenger@cnt}=1}{%
+\setlength{\@bb at tmplength@b}{\bbrchallengervdistance-\baselineskip}%
+\node[inner sep=0pt,below left=\@bb at tmplength@b and \bbrchallengerhdistance of \@bb at lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
+}{%
+\coordinate (@bbtmpcoord) at (\@bb at lastbox.north west);%
+\path (@bbtmpcoord);%
+\pgfgetlastxy{\XCoord}{\YCoordA}%
+\coordinate (@bbtmpcoord) at (\bbrchallengernodenameprefix \@bb at lastchallenger.south east);%
+\path (@bbtmpcoord);%
+\pgfgetlastxy{\XCoord}{\YCoordB}%
+\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB+\bbrchallengervdistance}%
+\node[inner sep=0pt,below left=\@bb at tmplength@b and \bbrchallengerhdistance of \@bb at lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
+}%
+\global\def\@bb at lastchallenger{#1}
+\begin{bbrenv}{#1}%
+}{
+\end{bbrenv}%
+\egroup;%
+\addtocounter{@bb at challenger@nestcnt}{-1}%
+\endgroup%
+\let\msgfrom\bbrchallengerqueryto%
+}
+
+
+\newcommand*\bbrinputlength{0.5cm}
+\newcommand*\bbrinputhoffset{0.5cm}
+\newcommand*\bbrinputbottom{}
+\newcommand*\bbrinputtop{}
+\newcommand*\bbrinputedgestyle{}
+\newcommand*\bbrinputtopstyle{}
+\newcommand*\bbrinputbottomstyle{}
+\newcommand*\bbrinputnodestyle{}
+\newcommand*\bbrinputnodename{}
+\define at key{bbrinput}{length}[]{\renewcommand*\bbrinputlength{#1}}
+\define at key{bbrinput}{hoffset}[]{\renewcommand*\bbrinputhoffset{#1}}
+\define at key{bbrinput}{name}[]{\renewcommand*\bbrinputnodename{#1}}
+\define at key{bbrinput}{top}[]{\renewcommand*\bbrinputtop{#1}}
+\define at key{bbrinput}{bottom}[]{\renewcommand*\bbrinputbottom{#1}}
+
+
+\newcommand{\@bb at inputsetup}[1]{
+	%load keys	
+	\begingroup % for local keys
+
+	\setkeys{bbrinput}{#1}%
+
+	\tikzset{BBRINPUT-NODESTYLE/.style/.expand once=\bbrinputedgestyle}%	
+	\tikzset{BBRINPUT-TOPSTYLE/.style/.expand once=\bbrinputtopstyle}%	
+	\tikzset{BBRINPUT-BOTTOMSTYLE/.style/.expand once=\bbrinputbottomstyle}%			
+	\tikzset{BBRINPUT-EDGESTYLE/.style/.expand once=\bbrinputedgestyle}%
+
+}
+
+\newcommand{\@bb at inputfinalize}{
+	\endgroup
+}
+
+\newcommandx*{\bbrinput}[2][2=]{%
+\@bb at inputsetup{#2}
+\ifthenelse{\equal{\bbrinputnodename}{}}
+  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-input}}{} 
+  
+\node[overlay,above right={\bbrinputlength} and {\bbrinputhoffset} of \@bb at lastbox.north west, anchor=south,BBRINPUT-NODESTYLE] (\bbrinputnodename) {#1};
+\path[->] (\bbrinputnodename.south)  edge[BBRINPUT-EDGESTYLE] node[above,anchor=east,BBRINPUT-TOPSTYLE] () {\bbrinputtop} node[below,anchor=west,BBRINPUT-BOTTOMSTYLE] () {\bbrinputbottom} (\bbrinputnodename.south|-\@bb at lastbox.north);
+\@bb at inputfinalize
+}
+
+\newcommandx*{\bbroutput}[2][2=]{%
+\@bb at inputsetup{#2}
+\ifthenelse{\equal{\bbrinputnodename}{}}
+  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-output}}{} 
+  
+\node[overlay,below right={\bbrinputlength} and {\bbrinputhoffset} of \@bb at lastbox.south west, anchor=north] (\bbrinputnodename) {#1};
+\draw[->] (\bbrinputnodename.north|-\@bb at lastbox.south)  -- (\bbrinputnodename.north|-\bbrinputnodename.north);
+\@bb at inputfinalize
+}
+
+\newenvironment{bbrpic}[1][]{%
+\begin{tikzpicture}[overlay,inner sep=0ex,baseline=0pt,#1]%
+}{%
+\end{tikzpicture}}
+
+%%%%%%%%%%%
+% communication
+%temporary lengths
+\newlength{\@bb at com@tmpoffset}
+\newlength{\@bb at tmplength@b}
+\newcommand{\@bb at firstmessageheight}{0.25\baselineskip}
+\newcommand{\@bb at msglength}{1.25cm}
+\newcommand{\@bb at qrylength}{1.5cm}
+
+%keys
+\newcommand*\bbrcomnsidestyle{}
+\newcommand*\bbrcomtopstyle{}
+\newcommand*\bbrcombottomstyle{}
+\newcommand*\bbrcomside{}
+\newcommand*\bbrcomoside{}
+\newcommand*\bbrcomtop{}
+\newcommand*\bbrcombottom{}
+\newcommand*\bbrcomedgestyle{}
+\newcommand*\bbrcomlength{1.25cm}
+\newcommand*\bbrcomtopname{bbrcomtop}
+\newcommand*\bbrcombottomname{bbrcombottom}
+\newcommand*\bbrcomsidename{bbrcomside}
+\newcommand*\bbrcomosidename{bbrcomoside}
+\newcommand*\bbrcombeforeskip{0pt}
+\newcommand*\bbrcomafterskip{0pt}
+\define at key{bbrcom}{sidestyle}[]{\renewcommand*\bbrcomnsidestyle{#1}}
+\define at key{bbrcom}{topstyle}[]{\renewcommand*\bbrcomtopstyle{#1}}
+\define at key{bbrcom}{bottomstyle}[]{\renewcommand*\bbrcombottomstyle{#1}}
+\define at key{bbrcom}{side}[]{\renewcommand*\bbrcomside{#1}}
+\define at key{bbrcom}{oside}[]{\renewcommand*\bbrcomoside{#1}}
+\define at key{bbrcom}{top}[]{\renewcommand*\bbrcomtop{#1}}
+\define at key{bbrcom}{bottom}[]{\renewcommand*\bbrcombottom{#1}}
+\define at key{bbrcom}{edgestyle}[]{\renewcommand*\bbrcomedgestyle{#1}}
+\define at key{bbrcom}{length}[]{\renewcommand*\bbrcomlength{#1}}
+\define at key{bbrcom}{topname}[]{\renewcommand*\bbrcomtopname{#1}}
+\define at key{bbrcom}{bottomname}[]{\renewcommand*\bbrcombottomname{#1}}
+\define at key{bbrcom}{sidename}[]{\renewcommand*\bbrcomsidename{#1}}
+\define at key{bbrcom}{osidename}[]{\renewcommand*\bbrcomosidename{#1}}
+\define at key{bbrcom}{beforeskip}[]{\renewcommand*\bbrcombeforeskip{#1}}
+\define at key{bbrcom}{afterskip}[]{\renewcommand*\bbrcomafterskip{#1}}
+
+\newcommand*\bbrbasenodestyle{}
+\newcommand*\bbrbasenodename{bbrtmpname}
+\define at key{bbrabase}{nodestyle}[]{\renewcommand*\bbrbasenodestyle{#1}}
+\define at key{bbrabase}{nodename}[]{\renewcommand*\bbrbasenodename{#1}}
+
+
+\newcommand{\@bb at comsetup}[3]{
+	%load keys	
+	\begingroup % for local keys
+
+	\setkeys{bbrcom}{#1}%
+
+	%set styles
+	\tikzset{BBRCOM-SIDESTYLE/.style/.expand once=\bbrcomnsidestyle}%
+	\tikzset{BBRCOM-TOPSTYLE/.style/.expand once=\bbrcomtopstyle}%
+	\tikzset{BBRCOM-BOTTOMSTYLE/.style/.expand once=\bbrcombottomstyle}%
+	\tikzset{BBRCOM-EDGESTYLE/.style/.expand once=\bbrcomedgestyle}%
+
+	% increase space
+	\ifthenelse{\lengthtest{#2<\@bb at firstmessageheight}}
+ 	{#3{\@bb at firstmessageheight}}
+	{
+	  #3{1.25\baselineskip}
+	  \ifthenelse{\equal{\bbrcomtop}{}}{}{#3{0.5\baselineskip}}	
+           }
+
+	#3{\bbrcombeforeskip}
+
+	\setlength{\@bb at com@tmpoffset}{#2}%
+}
+
+\newcommand{\@bb at comfinalize}[1]{
+	\ifthenelse{\equal{\bbrcombottom}{}}{}{#1{\baselineskip}}	
+	#1{\bbrcomafterskip}
+	\endgroup
+}
+
+\newcommand{\@bbrmsg}[8]{
+	\@bb at comsetup{#1}{#7}{#8}
+	%
+	\node[#3=\@bb at com@tmpoffset and \bbrcomlength of \@bb at lastbox.#4,anchor=#6,BBRCOM-SIDESTYLE] (\bbrcomsidename) {\bbrcomside};
+	\path[#2] (\bbrcomsidename.#6)  edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb at lastbox.#5|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {};
+	%
+	\@bb at comfinalize{#8}
+}
+
+\newcommandx{\bbrmsgto}[1]{%
+\@bbrmsg{#1}{->}{below left}{north west}{west}{east}{\@bb at message@hoffset}{\bbrmsgspace}
+}
+\newcommandx{\bbrmsgfrom}[1]{%
+\@bbrmsg{#1}{<-}{below left}{north west}{west}{east}{\@bb at message@hoffset}{\bbrmsgspace}
+}
+\newcommandx{\bbrmsgvdots}{%
+	\bbrmsgtxt[xshift=\bbrcomlength/2,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip]{$\vdots$}
+}
+
+
+\newcommandx{\bbrqryto}[1]{%
+\@bbrmsg{#1}{<-}{below right}{north east}{east}{west}{\@bb at query@hoffset}{\bbrqryspace}
+}
+\newcommandx{\bbrqryfrom}[1]{%
+\@bbrmsg{#1}{->}{below right}{north east}{east}{west}{\@bb at query@hoffset}{\bbrqryspace}
+}
+
+\newcommand{\@bbroracleqry}[4]{
+	\@bb at comsetup{#1}{#3}{#4}
+	%
+
+	\path[#2] (\@bb at lastoracle.north west) -- ++ (0,-\@bb at com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){\bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb at lastbox.east|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {\bbrcomoside};
+	%
+	\@bb at comfinalize{#4}
+}
+
+\newcommand{\bbroracleqryfrom}[1]{
+	\@bbroracleqry{#1}{->}{\@bb at oraclequery@hoffset}{\bbroracleqryspace}
+}
+
+\newcommand{\bbroracleqryto}[1]{
+	\@bbroracleqry{#1}{<-}{\@bb at oraclequery@hoffset}{\bbroracleqryspace}
+}
+
+\newcommand{\@bbrchallengerqry}[4]{
+	\@bb at comsetup{#1}{#3}{#4}
+	%
+
+	\path[#2] (\@bb at lastchallenger.north east) -- ++ (0,-\@bb at com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){\bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb at lastbox.west|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {\bbrcomoside};
+	%
+	\@bb at comfinalize{#4}
+}
+
+\newcommand{\bbrchallengerqryfrom}[1]{
+	\@bbrchallengerqry{#1}{<-}{\@bb at challengerquery@hoffset}{\bbrchallengerqryspace}
+}
+
+\newcommand{\bbrchallengerqryto}[1]{
+	\@bbrchallengerqry{#1}{->}{\@bb at challengerquery@hoffset}{\bbrchallengerqryspace}
+}
+
+
+
+\newcommand*\bbrcomloopleft{}
+\newcommand*\bbrcomloopright{}
+\newcommand*\bbrcomloopcenter{}
+\newcommand*\bbrcomloopangle{50}
+\define at key{bbrcomloop}{left}[]{\renewcommand*\bbrcomloopleft{#1}}
+\define at key{bbrcomloop}{right}[]{\renewcommand*\bbrcomloopright{#1}}
+\define at key{bbrcomloop}{center}[]{\renewcommand*\bbrcomloopcenter{#1}}
+\define at key{bbrcomloop}{angle}[]{\renewcommand*\bbrcomloopangle{#1}}
+
+\newcommand{\bbrloop}[3]{
+	\begingroup % for local keys
+	\setkeys{bbrcomloop}{#3}%
+
+	\path[->] (#1) edge[bend right=\bbrcomloopangle] node[midway,left] (bbrleft) {\bbrcomloopleft} (#2);
+	\path[->] (#2) edge[bend right=\bbrcomloopangle] node[midway,right] (bbrright) {\bbrcomloopright} (#1);
+	\node[at=($(bbrleft.north west)!0.5!(bbrright.north east)$),anchor=north]() {\bbrcomloopcenter};
+
+	\endgroup
+}
+
+\newcommand*\bbrintertexthoffset{1.5cm}
+\define at key{bbrintertext}{xshift}[]{\renewcommand*\bbrintertexthoffset{#1}}
+
+\newcommand{\@bb at intertextsetup}[1]{
+	%load keys	
+	\begingroup % for local keys
+
+	\setkeys{bbrcom,bbrabase,bbrintertext}{#1}%
+
+	\tikzset{BBRBASE-NODESTYLE/.style/.expand once=\bbrbasenodestyle}%
+}
+
+\newcommand{\@bb at intertextfinalize}[1]{
+	#1{\bbrcomafterskip}
+	\endgroup
+}
+
+\newcommand{\@bbrintertext}[6]{
+	\@bb at intertextsetup{#1}
+
+	% increase space
+	\ifthenelse{\lengthtest{#4<\@bb at firstmessageheight}}
+ 	{#5{\@bb at firstmessageheight}}
+	{#5{1\baselineskip}}
+
+	\setlength{\@bb at com@tmpoffset}{#4+\bbrcombeforeskip}%
+
+	%
+	\node[#2=\@bb at com@tmpoffset and \bbrintertexthoffset of \@bb at lastbox.#3,BBRBASE-NODESTYLE] (\bbrbasenodename) {#6};
+	%
+	% compute height of node
+	\coordinate (@bbtmpcoord) at (\bbrbasenodename.north);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordA}
+	\coordinate (@bbtmpcoord) at (\bbrbasenodename.south);
+	\path (@bbtmpcoord);
+	\pgfgetlastxy{\XCoord}{\YCoordB}
+
+	% update hoffset
+	\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB}
+	#5{\the\@bb at tmplength@b}
+
+	\@bb at intertextfinalize{#5}
+}
+
+\newcommand{\bbrmsgtxt}[2][]{
+	\@bbrintertext{#1}{below left}{north west}{\@bb at message@hoffset}{\bbrmsgspace}{#2}
+}
+
+\newcommand{\bbrqrytxt}[2][]{
+	\@bbrintertext{#1}{below right}{north east}{\@bb at query@hoffset}{\bbrqryspace}{#2}
+}
+
+\newcommand{\bbrchallengertxt}[2][]{
+\begingroup
+\setlength{\@bb at tmplength@b}{\bbrchallengerhdistance/2}%
+\renewcommand{\bbrintertexthoffset}{\the\@bb at tmplength@b}%
+	\@bbrintertext{#1}{below left}{north west}{\@bb at challengerquery@hoffset}{\bbrchallengerqryspace}{#2}
+\endgroup
+}
+
+\newcommand{\bbroracletxt}[2][]{
+\begingroup
+\setlength{\@bb at tmplength@b}{\bbroraclehdistance/2}%
+\renewcommand{\bbrintertexthoffset}{\the\@bb at tmplength@b}%
+	\@bbrintertext{#1}{below left}{north west}{\@bb at oraclequery@hoffset}{\bbroracleqryspace}{#2}
+\endgroup
+}
+
+\newcommand{\bbrmsgspace}[1]{
+\@pc at globaladdtolength{\@bb at message@hoffset}{#1}
+}
+
+\newcommand{\bbrqryspace}[1]{
+\@pc at globaladdtolength{\@bb at query@hoffset}{#1}
+}
+
+\newcommand{\bbroracleqryspace}[1]{
+\@pc at globaladdtolength{\@bb at oraclequery@hoffset}{#1}
+}
+
+\newcommand{\bbrchallengerqryspace}[1]{
+\@pc at globaladdtolength{\@bb at challengerquery@hoffset}{#1}
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% stacking
+\providecommand{\pccenteraboveskip}{0.5\baselineskip plus 0.25\baselineskip minus 0.25\baselineskip}
+\providecommand{\pccenterbelowskip}{0.5\baselineskip plus 0.25\baselineskip minus 0.25\baselineskip}
+\newenvironment{pccenter}{%
+\setlength\topsep{0pt}\setlength\parskip{0pt}%
+\begin{center}\vspace{\pccenteraboveskip}%
+}{%
+\vspace{\pccenterbelowskip}%
+\end{center}}
+
+
+%%%%%%%%%%%%%%%%%%%%%
+% horizontal stacking
+% space before hstacks
+\newlength{\pcbeforehstackskip}
+
+\NewEnviron{pchstack}[1][]{%
+% write out content
+\ifthenelse{\equal{#1}{center}}{%
+\begin{pccenter}\mbox{\hspace{\pcbeforehstackskip}\BODY}\end{pccenter}}{%
+\mbox{\hspace{\pcbeforehstackskip}\BODY}}%
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%
+\NewEnviron{pcvstack}[1][]{%
+% display minipage
+\ifthenelse{\equal{#1}{center}}{\begin{pccenter}}{}%
+\begin{varwidth}[t]{2\linewidth}\hspace{0pt}\BODY\end{varwidth}% hspace needed for proper vertical positioning .. strange as it is.
+\ifthenelse{\equal{#1}{center}}{\end{pccenter}}{}%
+}
+
+
+% spacing for stacking
+\newcommand{\pchspace}[1][1em]{\hspace{#1}}
+\newcommand{\pcvspace}[1][\baselineskip]{\par\vspace{#1}}
+
+
+
+
+
+%%%%
+% subprocedures
+\newcounter{@pcsubprogcnt1}
+\newcounter{@pcrsubprogcnt1}
+\newcounter{@pcsubprogcnt2}
+\newcounter{@pcrsubprogcnt2}
+\newcounter{@pcsubprogcnt3}
+\newcounter{@pcrsubprogcnt3}
+\newcounter{@pcsubprogcnt4}
+\newcounter{@pcrsubprogcnt4}
+\newcounter{@pcsubprogcnt5}
+\newcounter{@pcrsubprogcnt5}
+\newcounter{@pcsubprogcnt6}
+\newcounter{@pcrsubprogcnt6}
+\newcounter{@pcsubprogcnt7}
+\newcounter{@pcrsubprogcnt7}
+\newcounter{@pcsubprogcnt8}
+\newcounter{@pcrsubprogcnt8}
+\newcounter{@pcsubprogcnt9}
+\newcounter{@pcrsubprogcnt9}
+\newcounter{@pcsubprogstep}
+
+\newenvironment{subprocedure}{%
+\addtocounter{@pcsubprogstep}{1}%
+% store old counter values
+\setcounter{@pcsubprogcnt\the at pcsubprogstep}{\value{pclinenumber}}%
+\setcounter{@pcrsubprogcnt\the at pcsubprogstep}{\value{pcrlinenumber}}%
+}{%
+\setcounter{pclinenumber}{\value{@pcsubprogcnt\the at pcsubprogstep}}%
+\setcounter{pcrlinenumber}{\value{@pcrsubprogcnt\the at pcsubprogstep}}%
+\addtocounter{@pcsubprogstep}{-1}}
+
+
+%%%%%
+% parameter reordering
+\def\@pseudocodeB#1#2[#3]#4{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1#4},#2,#3]}
+\def\@pseudocodeC#1#2#3{\setkeys*{pcspace}{#2}\@pseudocode[head={#1#3},#2]}
+%for no headers
+\def\@pseudocodeE#1#2[#3]{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1},#2,#3]}
+\def\@pseudocodeF#1#2{\setkeys*{pcspace}{#2}\@pseudocode[head={#1},#2]}
+
+%%%%%%%%%
+% Define pseudocode command: 
+% #1 name
+% #2 code to execute after begingroup
+% #3 head prefix
+% #4 other config
+\newcommand{\createprocedurecommand}[4]{
+	\expandafter\gdef\csname #1\endcsname{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+#2%
+\@ifnextchar[%]
+  {\@pseudocodeB{#3}{#4}}
+  {\@pseudocodeC{#3}{#4}}%
+}%
+}
+
+\newcommand{\createpseudocodecommand}[4]{
+	\expandafter\gdef\csname #1\endcsname{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+#2%
+\@ifnextchar[%]
+  {\@pseudocodeE{#3}{#4}}
+  {\@pseudocodeF{#3}{#4}}%
+}%
+}
+
+
+%%%%%%
+% create procedure
+\createprocedurecommand{procedure}{}{}{}
+
+
+
+
+%%%
+% send message
+\newcommand{\pcshortmessageoffset}{0.5cm}
+\newcommand{\pcdefaultmessagelength}{3.5cm}
+\newcommand{\pcdefaultlongmessagelength}{6cm}
+\newcommand{\pcbeforemessageskip}{0pt}
+\newcommand{\pcaftermessageskip}{10pt}
+\newlength{\pcmessagearrow}
+
+\newcommand*\@pcsendmessagelength{\pcdefaultmessagelength}
+\newcommand*\@pcsendmessagecol{}
+\newcommand*\@pcsendmessagewidth{}
+\newcommand*\@pcsendmessagestyle{}
+\newcommand*\@pcsendmessagetop{}
+\newcommand*\@pcsendmessagebottom{}
+\newcommand*\@pcsendmessageright{}
+\newcommand*\@pcsendmessageleft{}
+\newcommand*\@pcsendmessagetopname{t}
+\newcommand*\@pcsendmessagebottomname{b}
+\newcommand*\@pcsendmessagerightname{r}
+\newcommand*\@pcsendmessageleftname{l}
+\newcommand*\@pcsendmessagetopstyle{}
+\newcommand*\@pcsendmessagebottomstyle{}
+\newcommand*\@pcsendmessagerightstyle{}
+\newcommand*\@pcsendmessageleftstyle{}
+\newcommand*\@pcsendmessagebeforeskip{\pcbeforemessageskip}
+\newcommand*\@pcsendmessageafterskip{\pcaftermessageskip}
+\define at key{pcsendmessage}{centercol}[]{\renewcommand*\@pcsendmessagecol{#1}}
+\define at key{pcsendmessage}{width}[]{\renewcommand*\@pcsendmessagewidth{#1}}
+\define at key{pcsendmessage}{style}[]{\renewcommand*\@pcsendmessagestyle{#1}}
+\define at key{pcsendmessage}{length}[]{\renewcommand*\@pcsendmessagelength{#1}}
+\define at key{pcsendmessage}{top}[]{\renewcommand*\@pcsendmessagetop{#1}}
+\define at key{pcsendmessage}{bottom}[]{\renewcommand*\@pcsendmessagebottom{#1}}
+\define at key{pcsendmessage}{right}[]{\renewcommand*\@pcsendmessageright{#1}}
+\define at key{pcsendmessage}{left}[]{\renewcommand*\@pcsendmessageleft{#1}}
+\define at key{pcsendmessage}{topname}[]{\renewcommand*\@pcsendmessagetopname{#1}}
+\define at key{pcsendmessage}{bottomname}[]{\renewcommand*\@pcsendmessagebottomname{#1}}
+\define at key{pcsendmessage}{rightname}[]{\renewcommand*\@pcsendmessagerightname{#1}}
+\define at key{pcsendmessage}{leftname}[]{\renewcommand*\@pcsendmessageleftname{#1}}
+\define at key{pcsendmessage}{topstyle}[]{\renewcommand*\@pcsendmessagetopstyle{#1}}
+\define at key{pcsendmessage}{bottomstyle}[]{\renewcommand*\@pcsendmessagebottomstyle{#1}}
+\define at key{pcsendmessage}{rightstyle}[]{\renewcommand*\@pcsendmessagerightstyle{#1}}
+\define at key{pcsendmessage}{leftstyle}[]{\renewcommand*\@pcsendmessageleftstyle{#1}}
+\define at key{pcsendmessage}{beforeskip}[]{\renewcommand*\@pcsendmessagebeforeskip{#1}}
+\define at key{pcsendmessage}{afterskip}[]{\renewcommand*\@pcsendmessageafterskip{#1}}
+
+
+\newcommand{\@pc at centerincol}[2]{%
+\ifmeasuring@%
+#2%
+\else%
+\makebox[\ifcase\expandafter #1\maxcolumn at widths\fi]{$\displaystyle#2$}%
+\fi%
+}
+
+\newcommand{\centerincol}[1]{\@pc at centerincol{\thepccolumncounter}{#1}}
+
+\newcommand{\@do at sendmessage}[1]{%
+\ifthenelse{\equal{\@pcsendmessagecol}{}}{%
+\ifthenelse{\equal{\@pcsendmessagewidth}{}}{#1}{% we have some width
+\makebox[\@pcsendmessagewidth]{$\displaystyle#1$}%
+}}{%we know the column to center on
+\@pc at centerincol{\@pcsendmessagecol}{#1}%
+}%
+}
+
+\newcommandx*{\sendmessage}[2]{%
+\begingroup\setkeys{pcsendmessage}{#2}%
+\tikzset{PCSENDMSG-PATH-STYLE/.style/.expand once=\@pcsendmessagestyle}%
+\tikzset{PCSENDMSG-TOP-STYLE/.style/.expand once=\@pcsendmessagetopstyle}%
+\tikzset{PCSENDMSG-BOTTOM-STYLE/.style/.expand once=\@pcsendmessagebottomstyle}%
+\tikzset{PCSENDMSG-LEFT-STYLE/.style/.expand once=\@pcsendmessageleftstyle}%
+\tikzset{PCSENDMSG-RIGHT-STYLE/.style/.expand once=\@pcsendmessagerightstyle}%
+%restore halign
+%
+\hspace{\@pcsendmessagebeforeskip}%
+\begin{varwidth}{\linewidth}
+\@do at sendmessage{
+	\begin{tikzpicture}%
+	 \node[PCSENDMSG-LEFT-STYLE] (\@pcsendmessageleftname) {\@pcsendmessageleft};
+	 \node[right=\@pcsendmessagelength of \@pcsendmessageleftname,PCSENDMSG-RIGHT-STYLE] (\@pcsendmessagerightname) {\@pcsendmessageright};
+	 \path[#1,PCSENDMSG-PATH-STYLE] (\@pcsendmessageleftname) edge[] node[above,PCSENDMSG-TOP-STYLE] (\@pcsendmessagetopname) {\@pcsendmessagetop} node[below,PCSENDMSG-BOTTOM-STYLE] (\@pcsendmessagebottomname) {\@pcsendmessagebottom} (\@pcsendmessagerightname); 
+	\end{tikzpicture}%
+}%
+\end{varwidth}
+\hspace{\@pcsendmessageafterskip}%
+\endgroup%
+}
+
+\newcommandx*{\sendmessageright}[2][1=->]{%
+\sendmessage{#1}{#2}%
+}
+
+\newcommandx*{\sendmessageleft}[2][1=<-]{%
+\sendmessage{#1}{#2}%
+}
+
+\WithSuffix\newcommand\sendmessageleft*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{<-}{length=#1}%
+\endgroup%
+}
+
+
+\WithSuffix\newcommand\sendmessageright*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{->}{length=#1}%
+\endgroup%
+}
+
+
+
+\DeclareExpandableDocumentCommand{\sendmessagerightx}{O{\pcdefaultlongmessagelength}mO{}m}{%
+\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xrightarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
+}
+
+\DeclareExpandableDocumentCommand{\sendmessageleftx}{O{\pcdefaultlongmessagelength}mO{}m}{%
+\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xleftarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
+}
+
+%%%
+% Division
+\DeclareExpandableDocumentCommand{\pcintertext}{O{}m}{\intertext{%
+\ifthenelse{\equal{#1}{center}}{\makebox[\linewidth][c]{#2}}{}%
+\ifthenelse{\equal{#1}{dotted}}{\dotfill#2\dotfill}{}%
+\ifthenelse{\equal{#1}{}}{#2}{}%
+}\@pc at beginnewline}
+
+
+
+%%%
+% Games
+%
+\newcounter{pcstartgamecounter}
+
+
+\newcommand*{\pcgameprocedurestyle}{} % define pseudocode arguments for game procedures
+
+\newcommand*{\pcgamename}{\ensuremath{\mathsf{Game}}}
+\newcommand*{\gameprocedurearg}{\ensuremath{(\secpar)}}
+\newcommand*\@pcgameproofgamenr{0}
+\define at key{pcgameproof}{nr}[]{\renewcommand*\@pcgameproofgamenr{#1}}
+\define at key{pcgameproof}{name}[]{\renewcommand*\pcgamename{\ensuremath{#1}}}
+\define at key{pcgameproof}{arg}[]{\renewcommand*\gameprocedurearg{\ensuremath{#1}}}
+
+\newenvironment{gameproof}[1][]{%
+\begingroup%
+\setkeys{pcgameproof}{#1}%
+\@pc at ensureremember%
+\setcounter{pcgamecounter}{\@pcgameproofgamenr}%
+\setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}%
+}{\@pc at releaseremember\endgroup}
+
+\newcommand{\setgameproceduredefaultstyle}[1]{%
+\createpseudocodecommand{gameprocedure}
+  {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}}
+  {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}}
+  {#1}
+}
+\setgameproceduredefaultstyle{}
+
+\def\@bxgame at pseudocodeA[#1]#2#3{\setkeys*{pcspace}{#1}\renewcommand{\@bxgameheader}{$\pcgamename_{#2}$\gameprocedurearg}%
+\@pseudocode[head=\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg},#1]{#3}}
+\def\@bxgame at pseudocodeB#1#2{\renewcommand{\@bxgameheader}{$\pcgamename_{#1}$\gameprocedurearg}%
+\@pseudocode[head=\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}]{#2}}
+
+\newcommand{\bxgameprocedure}{
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+\renewcommand{\@withingame}{true}%
+\renewcommand{\@withinbxgame}{true}%
+\stepcounter{pcgamecounter}%
+\@ifnextchar[%]
+  {\@bxgame at pseudocodeA}
+  {\@bxgame at pseudocodeB}%
+}
+
+\newcommand{\@pc at secondheader}{}
+
+%tbx top boxed
+\createpseudocodecommand{tbxgameprocedure}
+  {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}%%
+\renewcommand{\@pc at secondheader}{true}}
+  {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}}
+{}
+
+
+\newcommand*\@pcgamehopnodestyle{}
+\newcommand*\@pcgamehopedgestyle{bend left}
+\newcommand*\@pcgamehoppathestyle{}
+\newcommand*\@pcgamehophint{}
+\newcommand*\@pcgamehophintbelow{}
+\newcommand*\@pcgamehopinhint{}
+\newcommand*\@pcgamehoplength{1.5cm}
+\define at key{pcgamehop}{nodestyle}[]{\renewcommand*\@pcgamehopnodestyle{#1}}
+\define at key{pcgamehop}{edgestyle}[]{\renewcommand*\@pcgamehopedgestyle{#1}}
+\define at key{pcgamehop}{pathstyle}[]{\renewcommand*\@pcgamehoppathestyle{#1}}
+\define at key{pcgamehop}{hint}[]{\renewcommand*\@pcgamehophint{#1}}
+\define at key{pcgamehop}{belowhint}[]{\renewcommand*\@pcgamehophintbelow{#1}}
+\define at key{pcgamehop}{inhint}[]{\renewcommand*\@pcgamehopinhint{#1}}
+\define at key{pcgamehop}{length}[]{\renewcommand*\@pcgamehoplength{#1}}
+
+
+\newcommand{\@pc at setupgamehop}[1]{
+\begingroup\setkeys{pcgamehop}{#1}%
+\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
+\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
+\tikzset{GAMEHOP-EDGE-STYLE/.style/.expand once=\@pcgamehopedgestyle}%
+}
+
+\newcommand{\@pc at finalizegamehop}{
+\endgroup
+}
+
+\newcommandx*{\addgamehop}[3]{%
+\begingroup%
+\ifthenelse{#1<#2}%
+  {\ifthenelse{\equal{\@withingamedescription}{true}}%
+   {\renewcommand*\@pcgamehopedgestyle{bend right=20}\renewcommand*\@pcgamehopnodestyle{rotate=90}}{}%
+  }%
+  {\renewcommand*\@pcgamehopedgestyle{bend right}}%
+\@pc at setupgamehop{#3}%
+\begin{tikzpicture}[overlay]%
+\ifthenelse{#1<#2}{%
+       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#2);
+}{%
+ 	 \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+	 node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
+}%
+\end{tikzpicture}%
+\@pc at finalizegamehop%
+\endgroup%
+}
+\newcommandx*{\addstartgamehop}[2][1=\thepcstartgamecounter]{%
+\@pc at setupgamehop{#2}
+\begin{tikzpicture}[overlay]
+       \node[left=\@pcgamehoplength of gamenode#1] (tmpgamenode0) {};
+       \path[->,GAMEHOP-PATH-STYLE] (tmpgamenode0) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#1);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+\newcommandx*{\addendgamehop}[2][1=\thepcgamecounter]{%
+\@pc at setupgamehop{#2}
+\begin{tikzpicture}[overlay]
+       \node[right=\@pcgamehoplength of gamenode#1] (tmpgamenode#1) {};
+       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (tmpgamenode#1);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+\newcommandx*{\addbxgamehop}[3]{%
+\@pc at setupgamehop{#3}
+\begin{tikzpicture}[overlay]
+       \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE]] {\@pcgamehophint} 
+       node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+\newcommandx*{\addloopgamehop}[2][1=\thepcgamecounter]{%
+\@pc at setupgamehop{#2}
+\begin{tikzpicture}[overlay]
+       \node (looptemp1)  [right=0.5cm of gamenode#1] {};
+       \draw[->,GAMEHOP-PATH-STYLE] (gamenode#1) -- (looptemp1|-gamenode#1) -- node[right,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       node[left,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (looptemp1|-bgamenode#1)-- (bgamenode#1);
+\end{tikzpicture}
+\@pc at finalizegamehop
+}
+
+
+%%%%%%%% 
+% game description
+\newenvironment{gamedescription}[1][]{%
+\begingroup%
+\setkeys{pcgameproof}{#1}
+\renewcommand{\@withingamedescription}{true}%
+\@pc at ensureremember%
+\setcounter{pcgamecounter}{\@pcgameproofgamenr}%
+\setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}%
+\begin{description}%
+}{\end{description}\@pc at releaseremember\endgroup}
+
+\newcommandx*{\describegame}[1][1=]{%
+\addtocounter{pcgamecounter}{1}%
+\item[%
+\pcdraw{
+\gdef\i{\thepcgamecounter}%
+\node[inner sep=0.0em,outer sep=0, xshift=-1ex, yshift=0.5ex] (gamenode\i) {}; 
+}%
+\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}:]%
+\begingroup\setkeys{pcgamehop}{#1}%
+\ifthenelse{\equal{}{\@pcgamehophint}}
+  {}
+  {\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
+\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
+\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
+\draw[->,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,-\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE]  {\@pcgamehophint};
+}}%
+\ifthenelse{\equal{}{\@pcgamehopinhint}}
+  {}
+  {\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
+\tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
+\tikzset{GAMEHOP-NODE-STYLE/.style/.expand once=\@pcgamehopnodestyle}%
+\draw[<-,GAMEHOP-PATH-STYLE] (gamenode\thepcgamecounter) --++ (0,\@pcgamehoplength) node[midway,above,xshift=-1mm,rotate=90,GAMEHOP-NODE-STYLE]  {\@pcgamehopinhint};
+}%
+}%
+\endgroup%
+}
+
+
+
+
+
+
+%%%%%%%% 
+% basic pseudocode constants
+
+\newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
+\newcommand{\highlightaltkeyword}[1]{\ensuremath{\mathsf{#1}}}
+
+\newcommand{\pcglobvar}{\highlightkeyword{gbl}}
+\newcommand{\pcnew}{\highlightkeyword{new}}
+\newcommand{\pcwhile}{\@pc at increaseindent\highlightkeyword{while}}
+\newcommand{\pcendwhile}{\@pc at decreaseindent\highlightkeyword{endwhile}}
+\newcommandx*{\pcdo}[2][1=\ ,2=]{#1\highlightkeyword[#2]{do}}
+\newcommandx*{\pcif}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{if}}
+\newcommandx*{\pcunless}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{unless}}
+\newcommandx*{\pcelse}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else}}
+\newcommandx*{\pcelseif}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else if}}
+\newcommand{\pcfi}{\@pc at decreaseindent\highlightkeyword{fi}}
+\newcommand{\pcendif}{\@pc at decreaseindent\highlightkeyword{endif}}
+\newcommand{\pcendfor}{\@pc at decreaseindent\highlightkeyword{endfor}}
+\newcommandx*{\pcthen}[2][1=\ ,2=\ ]{#1\highlightkeyword[#2]{then}}
+\newcommand{\pcreturn}{\highlightkeyword{return}}
+\newcommandx*{\pcin}[2][1=\ ,2=]{#1\highlightkeyword[#2]{in}}
+\newcommandx*{\pcfor}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{for}}
+\newcommand{\pcrepeat}[1]{\@pc at increaseindent\ensuremath{\highlightkeyword{repeat} #1\ \highlightkeyword{times}}}
+\newcommand{\pcrepeatuntil}[2]{\ensuremath{\highlightkeyword{repeat}\ #1\ \highlightkeyword{until}\ #2}}
+\newcommand{\pcforeach}{\@pc at increaseindent\highlightkeyword{foreach}}
+\newcommand{\pcendforeach}{\@pc at decreaseindent\highlightkeyword{endforeach}}
+\newcommand{\pcuntil}{\@pc at decreaseindent\highlightkeyword{until}}
+\newcommand{\pccontinue}{\highlightkeyword{continue}}
+\newcommandx*{\pcfalse}[2][1=\ ,2=]{\highlightkeyword[#2]{false}}
+\newcommandx*{\pctrue}[2][1=\ ,2=]{\highlightkeyword[#2]{true}}
+\newcommandx*{\pcnull}[2][1=\ ,2=]{\highlightkeyword[#2]{null}}
+\newcommand{\pccomment}[1]{{\mbox{/\!\!/ } \text{\scriptsize#1}}}
+\newcommand{\pcdone}{\highlightkeyword{done}}
+\newcommand{\pcparse}{\highlightkeyword{parse}}
+\newcommand{\pcfail}{\highlightkeyword{fail}}
+\newcommand{\pcabort}{\highlightkeyword{abort}}
+
+%%%
+% highlighting 
+\definecolor{gamechangecolor}{gray}{0.90}
+\newcommand{\gamechange}[2][gamechangecolor]{%
+{\setlength{\fboxsep}{0pt}\colorbox{#1}{\ifmmode$\displaystyle#2$\else#2\fi}}%
+}
+
+%%%
+% boxing
+\newcommand{\pcbox}[1]{%
+{\setlength{\fboxsep}{3pt}\fbox{$\displaystyle#1$}}
+}
+
+\endinput
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode-2020-04-24.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty	2020-07-10 21:19:52 UTC (rev 55799)
+++ trunk/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty	2020-07-10 21:20:21 UTC (rev 55800)
@@ -1,315 +1,368 @@
- %% Copyright 2018 Arno Mittelbach
-  %
-  % This work may be distributed and/or modified under the
-  % conditions of the LaTeX Project Public License, either version 1.3
-  % of this license or (at your option) any later version.
-  % The latest version of this license is in
-  %   http://www.latex-project.org/lppl.txt
-  % and version 1.3 or later is part of all distributions of LaTeX
-  % version 2005/12/01 or later.
-  %
-  % This work has the LPPL maintenance status `maintained'.
-  % 
-  % The Current Maintainer of this work is Arno Mittelbach.
-  %
-  % This work consists of the files cryptocode.tex and cryptocode.sty
-  %
-  % Changelog
-  %
-  % 2016/11/30
-  % - changed \pckeystyle to ensure that subscripts on \sk and \pk are aligned the same 
-  %   before, $(\sk_R, \pk_R)$ had slightly misaligned subscripts due to Tex treating 
-  %   subscripts on composite objects with descenders differently than without.
-  %   see https://groups.google.com/forum/#!msg/comp.text.tex/IaXu_xBG06Q/CibRPH5GCAAJ
-  % - added \NAND
-  % - added pcmbox environment for matrices in pseudocode
-  %
-  % 2016/12/02
-  % - changed minheight for bbrbox environment to actually reflect a minimum height in tikz
-  %   the old minheight which added space at the bottom was preserved as addheight
-  % - added namepos middle for bbrbox
-  % - added pcfail
-  % - added valign to pseudocode to allow minipage vertical alignment
-  % - added \setgameproceduredefaultstyle
-  % - ensure line numbers are right aligned to allow for two digit linenumbers having the same width
-  %
-  % 2017/08/26
-  % - added \pcabort
-  % - better control whitespace for \pcif, \pcelse, \pcelseif
-  %
-  % 2017/10/02
-  % - side and oside support to \bbroracleqryto and \bbroracleqryfrom
-  % - add bottom to namepos in bbrbox
-  % - names for brrinput and bbroutput
-  % - angle for bbrloop
-  % - fix length for bbrinput
-  % - introduce hoffset for bbrinput
-  % 
-  % 2017/12/21
-  % - added \pcunless
-  %
-  % 2018/11/11
-  % replace obsolete l3regex
-  %
+%%
+%% This is file `cryptocode.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% cryptocode.dtx  (with options: `cryptocode.sty,package')
+%% 
+%%  cryptocode.dtx
+%%  Copyright 2020 Mittelbach, Arno
+%% 
+%%  This work may be distributed and/or modified under the
+%%  conditions of the LaTeX Project Public License, either version 1.3
+%%  of this license or (at your option) any later version.
+%%  The latest version of this license is in
+%%    http://www.latex-project.org/lppl.txt
+%%  and version 1.3 or later is part of all distributions of LaTeX
+%%  version 2005/12/01 or later.
+%% 
+%%  This work has the LPPL maintenance status `maintained'.
+%% 
+%%  The Current Maintainer of this work is Mittelbach, Arno.
+%% 
+%%  This work consists of the files cryptocode.dtx and cryptocode.ins and the derived files
+%%  cryptocode.sty and cryptocode.pdf.
+%% 
 \NeedsTeXFormat{LaTeX2e}
+\DeclareRelease{v0.30}{2018-11-11}{cryptocode-2018-11-11.sty}
+\DeclareRelease{v0.32}{2020-04-24}{cryptocode-2020-04-24.sty}
+\DeclareCurrentRelease{v0.40}{2020-07-10}
 \ProvidesPackage{cryptocode}
-  [2018/11/11 v0.3.0 Cryptocode LaTeX package for typesetting pseudocode, algorithms and protocols as well as cryptographic proofs.]
+  [2020/07/10 v0.40 Cryptocode LaTeX package for typesetting pseudocode, algorithms and protocols as well as cryptographic proofs.]
+\RequirePackage{amsmath}
+\RequirePackage{mathtools}
+\newif\if at pc@opt at amsfonts
+\newif\if at pc@opt at advantage
+\newif\if at pc@opt at centernot
+\DeclareOption{operators}{
+\providecommand{\sample}{\hskip2.3pt{\gets\!\!\mbox{\scriptsize${\$}$\normalsize}}\,}
 
+\DeclarePairedDelimiter\pc at floor{\lfloor}{\rfloor}
+\providecommand{\floor}[1]{\pc at floor*{#1}}
+\providecommand{\tfloor}[1]{\pc at floor{#1}}
 
-\def\hi{Hello, this is cryptocode.}
-\let\myDate\date
+\DeclarePairedDelimiter\pc at ceil{\lceil}{\rceil}
+\providecommand{\ceil}[1]{\pc at ceil*{#1}}
+\providecommand{\tceil}[1]{\pc at ceil{#1}}
 
-\RequirePackage{amsmath}
-\RequirePackage{mathtools}
-%\usepackage{l3tl-analysis} % uncomment for debugging
+\DeclarePairedDelimiter\pc at Angle{\langle}{\rangle}
+\providecommand{\Angle}[1]{\pc at Angle*{#1}}
+\providecommand{\tAngle}[1]{\pc at Angle{#1}}
 
-%%%
-% option modes
-\newif\ifpc at orderofgrowth
-\newif\ifpc at algorithmstyle
-\newif\ifpc at amsfonts
-\newif\ifpc at advantage
-\newif\ifpc at primitives
+\DeclarePairedDelimiter\pc at abs{\lvert}{\rvert}
+\providecommand{\abs}[1]{\pc at abs*{#1}}
+\providecommand{\tabs}[1]{\pc at abs{#1}}
 
-%%%
-% 
-\DeclareOption{operators}{
-	\providecommand{\sample}{\hskip2.3pt{\gets\!\!\mbox{\tiny${\$}$\normalsize}}\,}
-	
-	\providecommand{\floor}[1]{\ensuremath{\left\lfloor #1\right\rfloor}}
-	\providecommand{\ceil}[1]{\ensuremath{\left\lceil #1\right\rceil}}
-	\providecommand{\Angle}[1]{\ensuremath{\left\langle #1\right\rangle}}
-	\providecommand{\abs}[1]{\ensuremath{\left\lvert #1 \right\rvert}}
-	\providecommand{\norm}[1]{\ensuremath{\left\|#1\right\|}}
-	\providecommand{\concat}{\ensuremath{\|}}
-	
-	\providecommand{\emptystring}{\ensuremath{\varepsilon}}
+\DeclarePairedDelimiter\pc at norm{\lVert}{\rVert}
+\providecommand{\norm}[1]{\pc at norm*{#1}}
+\providecommand{\tnorm}[1]{\pc at tnorm{#1}}
+
+\providecommand{\concat}{\ensuremath{\|}}
+\providecommand{\emptystring}{\ensuremath{\varepsilon}}
+
+\DeclareMathOperator*{\argmax}{arg\,max}
+\DeclareMathOperator*{\argmin}{arg\,min}
+
+\newcommand{\@pc at oset}[3][0ex]{%
+  \mathrel{\mathop{#3}\limits^{
+    \vbox to#1{\kern-2\ex@
+    \hbox{$\scriptstyle#2$}\vss}}}}
+
+\newcommand{\pindist}{\@pc at oset{\text{p}}{\lower.2ex\hbox{$=$}}}
+\newcommand{\sindist}{\@pc at oset{\text{s}}{\lower.1ex\hbox{$\approx$}}}
+\newcommand{\cindist}{\@pc at oset{\text{c}}{\lower.1ex\hbox{$\approx$}}}
 }
+\DeclareOption{adversary}{
+\providecommand{\adversary}[1]{\pcadvstyle{#1}}
 
-\DeclareOption{adversary}{
-	\providecommand{\pcadvstyle}[1]{\mathcal{#1}}
-	
-	\providecommand{\adv}{\ensuremath{\pcadvstyle{A}}}
-	\providecommand{\bdv}{\ensuremath{\pcadvstyle{B}}}
-	\providecommand{\cdv}{\ensuremath{\pcadvstyle{C}}}
-	\providecommand{\ddv}{\ensuremath{\pcadvstyle{D}}}
-	\providecommand{\mdv}{\ensuremath{\pcadvstyle{M}}}
-	\providecommand{\pdv}{\ensuremath{\pcadvstyle{P}}}
-	\providecommand{\rdv}{\ensuremath{\pcadvstyle{R}}}
-	\providecommand{\sdv}{\ensuremath{\pcadvstyle{S}}}
+\providecommand{\adv}{\pcadvstyle{A}}
+\providecommand{\bdv}{\pcadvstyle{B}}
+\providecommand{\cdv}{\pcadvstyle{C}}
+\providecommand{\ddv}{\pcadvstyle{D}}
+\providecommand{\edv}{\pcadvstyle{E}}
+\providecommand{\mdv}{\pcadvstyle{M}}
+\providecommand{\pdv}{\pcadvstyle{P}}
+\providecommand{\rdv}{\pcadvstyle{R}}
+\providecommand{\sdv}{\pcadvstyle{S}}
 }
-
 \DeclareOption{landau}{
-	\pc at orderofgrowthtrue
-	
-	\providecommand{\bigO}[1]{\ensuremath{\mathcal{O}\olrk{#1}}}
-        \providecommand{\smallO}[1]{\ensuremath{\text{o}\olrk{#1}}}
-        \providecommand{\bigOmega}[1]{\ensuremath{\Omega\olrk{#1}}}
-        \providecommand{\smallOmega}[1]{\ensuremath{\omega\olrk{#1}}}
-        \providecommand{\bigsmallO}[1]{\ensuremath{\Theta\olrk{#1}}}
+\providecommand{\bigO}[1]{\ensuremath{\mathcal{O}\pc at olrk*{#1}}}
+\providecommand{\smallO}[1]{\ensuremath{\text{o}\pc at olrk*{#1}}}
+\providecommand{\bigOmega}[1]{\ensuremath{\Omega\pc at olrk*{#1}}}
+\providecommand{\smallOmega}[1]{\ensuremath{\omega\pc at olrk*{#1}}}
+\providecommand{\bigsmallO}[1]{%
+\PackageWarning{cryptocode}{bigsmallO is deprecated. Use bigTheta instead.}%
+\ensuremath{\Theta\pc at olrk*{#1}}}
+\providecommand{\bigTheta}[1]{\ensuremath{\Theta\pc at olrk*{#1}}}
+\providecommand{\orderOf}{\ensuremath{\sim}}
 }
-
 \DeclareOption{probability}{
-	\pc at orderofgrowthtrue
-	\pc at amsfontstrue
+\@pc at opt@amsfontstrue
 
-	\providecommand{\probname}{Pr}
-	\providecommand{\expectationname}{\ensuremath{\mathbb{E}}}
-	\providecommand{\supportname}{Supp}
+\providecommand{\probname}{Pr}
+\providecommand{\expectationname}{\ensuremath{\mathbb{E}}}
+\providecommand{\supportname}{Supp}
 
-	\providecommand{\prob}[1]{\ensuremath{\operatorname{\probname}\elrk{#1}}}
-	\providecommand{\probsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\elrk{#2}}}
-	\providecommand{\condprob}[2]{\ensuremath{\prob{#1\,\left|\,#2\vphantom{#1}\right.}}}
-	\providecommand{\condprobsub}[3]{\ensuremath{\probsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
-   
-	\providecommand{\expect}[1]{\ensuremath{\operatorname{\expectationname}\elrk{#1}}}
-	\providecommand{\expsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\elrk{#2}}}
-	\providecommand{\condexp}[2]{\ensuremath{\expect{#1\,\left|\,#2\vphantom{#1}\right.}}}
-	\providecommand{\condexpsub}[3]{\ensuremath{\expsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+\providecommand{\tprob}[1]{\ensuremath{\operatorname{\probname}\pc at elrk{#1}}}
+\providecommand{\prob}[1]{\ensuremath{\operatorname{\probname}\pc at elrk*{#1}}}
 
-	\providecommand{\supp}[1]{  \ensuremath{\operatorname{Supp}\olrk{#1}}}
-	
-	\providecommand{\entropy}[1]{\ensuremath{\operatorname{H}\olrk{#1}}}
-   	\providecommand{\condentropy}[2]{\ensuremath{\operatorname{H}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}    	
-	\providecommand{\minentropy}[1]{\ensuremath{\operatorname{H_\infty}\olrk{#1}}}
-    	\providecommand{\condminentropy}[2]{\ensuremath{\operatorname{H_\infty}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}    
-    	\providecommand{\condavgminentropy}[2]{\ensuremath{\operatorname{\tilde{H}_\infty}\olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}        	
+\providecommand{\tprobsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\pc at elrk{#2}}}
+\providecommand{\probsub}[2]{\ensuremath{\operatorname{\probname}_{#1}\pc at elrk*{#2}}}
+\providecommand{\probsublong}[2]{\ensuremath{\prob{#2\,:\,#1}}}
+
+\providecommand{\tcondprob}[2]{\ensuremath{\tprob{#1\,\left|\,#2\vphantom{#1}\right.}}}
+\providecommand{\condprob}[2]{\ensuremath{\prob{#1\,\left|\,#2\vphantom{#1}\right.}}}
+
+\providecommand{\tcondprobsub}[3]{\ensuremath{\tprobsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+\providecommand{\condprobsub}[3]{\ensuremath{\probsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+
+\providecommand{\texpect}[1]{\ensuremath{\operatorname{\expectationname}\pc at elrk{#1}}}
+\providecommand{\expect}[1]{\ensuremath{\operatorname{\expectationname}\pc at elrk*{#1}}}
+
+\providecommand{\texpsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\pc at elrk{#2}}}
+\providecommand{\expsub}[2]{\ensuremath{\operatorname{\expectationname}_{#1}\pc at elrk*{#2}}}
+
+\providecommand{\tcondexp}[2]{\ensuremath{\texpect{#1\,\left|\,#2\vphantom{#1}\right.}}}
+\providecommand{\condexp}[2]{\ensuremath{\expect{#1\,\left|\,#2\vphantom{#1}\right.}}}
+
+\providecommand{\tcondexpsub}[3]{\ensuremath{\texpsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+\providecommand{\condexpsub}[3]{\ensuremath{\expsub{#1}{#2\,\left|\,#3\vphantom{#1}\right.}}}
+
+\providecommand{\supp}[1]{\ensuremath{\operatorname{Supp}\pc at olrk*{#1}}}
+
+\providecommand{\entropy}[1]{\ensuremath{\operatorname{H}\pc at olrk*{#1}}}
+\providecommand{\condentropy}[2]{%
+\ensuremath{\operatorname{H}\pc at olrk*{#1\,\left|\,#2\vphantom{#1}\right.}}}     
+
+\providecommand{\minentropy}[1]{\ensuremath{\operatorname{H_\infty}\pc at olrk*{#1}}}
+\providecommand{\tminentropy}[1]{\ensuremath{\operatorname{H_\infty}\pc at olrk{#1}}}
+\providecommand{\condminentropy}[2]{%
+\ensuremath{\operatorname{H_\infty}\pc at olrk*{#1\,\left|\,#2\vphantom{#1}\right.}}}
+\providecommand{\tcondminentropy}[2]{%
+\ensuremath{\operatorname{H_\infty}\pc at olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}
+\providecommand{\condavgminentropy}[2]{%
+\ensuremath{\operatorname{\tilde{H}_\infty}\pc at olrk*{#1\,\left|\,#2\vphantom{#1}\right.}}}         
+\providecommand{\tcondavgminentropy}[2]{%
+\ensuremath{\operatorname{\tilde{H}_\infty}\pc at olrk{#1\,\left|\,#2\vphantom{#1}\right.}}}         
 }
-
 \DeclareOption{sets}{
-        \pc at orderofgrowthtrue
-        \pc at amsfontstrue
+\@pc at opt@amsfontstrue
 
-        \providecommand\NN{\mathbb{N}}
-        \providecommand\ZZ{\mathbb{Z}}
-        \providecommand\CC{\mathbb{C}}
-        \providecommand\QQ{\mathbb{Q}}
-        \providecommand\RR{\mathbb{R}}
-        \providecommand\PP{\mathbb{P}}
-        \providecommand\FF{\mathbb{F}}
-        \providecommand\GG{\mathbb{G}}            
+\providecommand\NN{\pcsetstyle{N}}
+\providecommand\ZZ{\pcsetstyle{Z}}
+\providecommand\CC{\pcsetstyle{C}}
+\providecommand\QQ{\pcsetstyle{Q}}
+\providecommand\RR{\pcsetstyle{R}}
+\providecommand\PP{\pcsetstyle{P}}
+\providecommand\FF{\pcsetstyle{F}}
+\providecommand\GG{\pcsetstyle{G}}
 
-        \providecommand{\set}[1]{\ensuremath{\clrk{#1}}}
-	\providecommand{\sequence}[1]{\ensuremath{\olrk{#1}}}
-	\providecommand{\bin}{\ensuremath{\{0,1\}}}
+\providecommand{\set}[1]{\ensuremath{\pc at clrk*{#1}}}
+\providecommand{\sequence}[1]{\ensuremath{\pc at olrk*{#1}}}
+\providecommand{\bin}{\ensuremath{\{0,1\}}}
 }
-
 \DeclareOption{noamsfonts}{
-	\pc at amsfontsfalse
+\@pc at opt@amsfontsfalse
 }
+\DeclareOption{notions}{
+\providecommand{\indcpa}{\pcnotionstyle{IND\pcmathhyphen{}CPA}}
+\providecommand{\indcca}{\pcnotionstyle{IND\pcmathhyphen{}CCA}}
+\providecommand{\indccai}{\pcnotionstyle{IND\pcmathhyphen{}CCA1}}
+\providecommand{\indccaii}{\pcnotionstyle{IND\pcmathhyphen{}CCA2}}
+\providecommand{\priv}{\pcnotionstyle{PRIV}}
+\providecommand{\ind}{\pcnotionstyle{IND}}
+\providecommand{\indcda}{\pcnotionstyle{IND\pcmathhyphen{}CDA}}
+\providecommand{\prvcda}{\pcnotionstyle{PRV\pcmathhyphen{}CDA}}
+\providecommand{\prvrcda}{\pcnotionstyle{PRV\$\pcmathhyphen{}CDA}}
+\providecommand{\kiae}{\pcnotionstyle{KIAE}}
+\providecommand{\kdae}{\pcnotionstyle{KDAE}}
+\providecommand{\mle}{\pcnotionstyle{MLE}} 
+\providecommand{\uce}{\pcnotionstyle{UCE}}
 
+\providecommand{\eufcma}{\pcnotionstyle{EUF\pcmathhyphen{}CMA}}
+\providecommand{\eufnacma}{\pcnotionstyle{EUF\pcmathhyphen{}naCMA}}
+\providecommand{\seufcma}{\pcnotionstyle{SUF\pcmathhyphen{}CMA}}
 
-\DeclareOption{notions}{
-	\providecommand{\pcnotionstyle}[1]{\ensuremath{\mathrm{#1}}}
-		
-	\providecommand{\indcpa}{\pcnotionstyle{IND\pcmathhyphen{}CPA}}
-	\providecommand{\indcca}{\pcnotionstyle{IND\pcmathhyphen{}CCA}}
-	\providecommand{\indccai}{\pcnotionstyle{IND\pcmathhyphen{}CCA1}}
-	\providecommand{\indccaii}{\pcnotionstyle{IND\pcmathhyphen{}CCA2}}
-	\providecommand{\priv}{\pcnotionstyle{PRIV}}
-	\providecommand{\ind}{\pcnotionstyle{IND}}
-	\providecommand{\indcda}{\pcnotionstyle{IND\pcmathhyphen{}CDA}}
-	\providecommand{\prvcda}{\pcnotionstyle{PRV\pcmathhyphen{}CDA}}
-	\providecommand{\prvrcda}{\pcnotionstyle{PRV\$\pcmathhyphen{}CDA}}
-	\providecommand{\kiae}{\pcnotionstyle{KIAE}}
-	\providecommand{\kdae}{\pcnotionstyle{KDAE}}
-	\providecommand{\mle}{\pcnotionstyle{MLE}}	
-	\providecommand{\uce}{\pcnotionstyle{UCE}}
+\providecommand{\eufko}{\pcnotionstyle{EUF\pcmathhyphen{}KO}}
 }
+\DeclareOption{logic}{
+\@pc at opt@centernottrue
 
-\DeclareOption{logic}{
-        \providecommand{\AND}{\ensuremath{\mathrm{AND}}}
-        \providecommand{\OR}{\ensuremath{\mathrm{OR}}}
-        \providecommand{\NOR}{\ensuremath{\mathrm{NOR}}}
-        \providecommand{\NOT}{\ensuremath{\mathrm{NOT}}}
-        \providecommand{\NAND}{\ensuremath{\mathrm{NAND}}}        
-		\providecommand{\XOR}{\ensuremath{\mathrm{XOR}}}		
-		\providecommand{\XNOR}{\ensuremath{\mathrm{XNOR}}}		
-		\providecommand{\xor}{\ensuremath{\oplus}}        
-        \providecommand{\false}{\mathsf{false}} 
-        \providecommand{\true}{\mathsf{true}}
+\providecommand{\AND}{\ensuremath{\mathrm{AND}}}
+\providecommand{\OR}{\ensuremath{\mathrm{OR}}}
+\providecommand{\NOR}{\ensuremath{\mathrm{NOR}}}
+\providecommand{\NOT}{\ensuremath{\mathrm{NOT}}}
+\providecommand{\NAND}{\ensuremath{\mathrm{NAND}}}
+\providecommand{\XOR}{\ensuremath{\mathrm{XOR}}} 
+\providecommand{\XNOR}{\ensuremath{\mathrm{XNOR}}} 
+\providecommand{\xor}{\ensuremath{\oplus}}
+\providecommand{\false}{\mathsf{false}}
+\providecommand{\true}{\mathsf{true}}
+\providecommand{\notimplies}{\centernot\implies}
 }
-
-
-% Function Families
 \DeclareOption{ff}{
-	\pc at algorithmstyletrue
+\providecommand{\kgen}{\pcalgostyle{KGen}}
+\providecommand{\pgen}{\pcalgostyle{Pgen}}
+\providecommand{\eval}{\pcalgostyle{Eval}}
+\providecommand{\invert}{\pcalgostyle{Inv}} 
 
-	\providecommand{\kgen}{\pcalgostyle{KGen}}
-	\providecommand{\pgen}{\pcalgostyle{Pgen}}
-	\providecommand{\eval}{\pcalgostyle{Eval}}
-	\providecommand{\invert}{\pcalgostyle{Inv}}	
-	
-	\providecommand{\il}{\pcalgostyle{il}}
-	\providecommand{\ol}{\pcalgostyle{ol}}
-	\providecommand{\kl}{\pcalgostyle{kl}}
-	\providecommand{\nl}{\pcalgostyle{nl}}
-	\providecommand{\rl}{\pcalgostyle{rl}}
+\providecommand{\il}{\pcalgostyle{il}}
+\providecommand{\ol}{\pcalgostyle{ol}}
+\providecommand{\kl}{\pcalgostyle{kl}}
+\providecommand{\nl}{\pcalgostyle{nl}}
+\providecommand{\rl}{\pcalgostyle{rl}}
 }
-
-% Machine Model
 \DeclareOption{mm}{
-	\pc at algorithmstyletrue
-	
-	\providecommand{\pcmachinemodelstyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\CRKT}{\pcmachinemodelstyle{C}}
+\providecommand{\TM}{\pcmachinemodelstyle{M}}
+\providecommand{\PROG}{\pcmachinemodelstyle{P}}
 
-        \providecommand{\CRKT}{\pcmachinemodelstyle{C}}
-        \providecommand{\TM}{\pcmachinemodelstyle{M}}
-        \providecommand{\PROG}{\pcmachinemodelstyle{P}}
-        
-        \providecommand{\uTM}{\pcmachinemodelstyle{UM}}
-        \providecommand{\uC}{\pcmachinemodelstyle{UC}}
-        \providecommand{\uP}{\pcmachinemodelstyle{UEval}}
+\providecommand{\uTM}{\pcmachinemodelstyle{UM}}
+\providecommand{\uC}{\pcmachinemodelstyle{UC}}
+\providecommand{\uP}{\pcmachinemodelstyle{UEval}}
 
-        \providecommand{\csize}{\pcmachinemodelstyle{size}}        
-        \providecommand{\tmtime}{\pcmachinemodelstyle{time}}
-        \providecommand{\ppt}{\pcalgostyle{PPT}}
+\providecommand{\csize}{\pcmachinemodelstyle{size}}
+\providecommand{\tmtime}{\pcmachinemodelstyle{time}}
+\providecommand{\ppt}{\pcalgostyle{PPT}}
 }
-
 \DeclareOption{advantage}{
-	\pc at advantagetrue
+\@pc at opt@advantagetrue
 }
-
 \DeclareOption{primitives}{
-	\pc at primitivestrue
-	\pc at algorithmstyletrue
+\providecommand{\prover}{\pcalgostyle{P}}
+\providecommand{\verifier}{\pcalgostyle{V}}
+\providecommand{\nizk}{\pcalgostyle{NIZK}}
+\providecommand{\hash}{\pcalgostyle{H}}
+\providecommand{\gash}{\pcalgostyle{G}}
+\providecommand{\fash}{\pcalgostyle{F}}
+\providecommand{\pad}{\pcalgostyle{pad}}
+\providecommand{\enc}{\pcalgostyle{Enc}}
+\providecommand{\dec}{\pcalgostyle{Dec}}
+\providecommand{\sig}{\pcalgostyle{Sig}}
+\providecommand{\sign}{\pcalgostyle{Sign}}
+\providecommand{\verify}{\pcalgostyle{Vf}}
+\providecommand{\obf}{\pcalgostyle{O}}
+\providecommand{\iO}{\pcalgostyle{iO}}
+\providecommand{\diO}{\pcalgostyle{diO}}
+\providecommand{\owf}{\pcalgostyle{OWF}}
+\providecommand{\owp}{\pcalgostyle{OWP}}
+\providecommand{\tdf}{\pcalgostyle{TF}}
+\providecommand{\inv}{\pcalgostyle{Inv}}
+\providecommand{\hcf}{\pcalgostyle{HC}}
+\providecommand{\prf}{\pcalgostyle{PRF}}
+\providecommand{\prp}{\pcalgostyle{PRP}}
+\providecommand{\prg}{\pcalgostyle{PRG}}
+\providecommand{\mac}{\pcalgostyle{MAC}}
+\providecommand{\puncture}{\pcalgostyle{Puncture}}
+\providecommand{\source}{\pcalgostyle{S}}
+\providecommand{\predictor}{\pcalgostyle{P}}
+\providecommand{\sam}{\pcalgostyle{Sam}}
+\providecommand{\dist}{\pcalgostyle{D}}
+\providecommand{\distinguisher}{\pcalgostyle{Dist}}
+\providecommand{\simulator}{\pcalgostyle{Sim}}
+\providecommand{\ext}{\pcalgostyle{Ext}}
+\providecommand{\extractor}{\ext}
 }
+\DeclareOption{oracles}{
+\providecommand{\Oracle}[1]{\pcalgostyle{O{#1}}}
 
+\def\oracle{\bgroup\oracle@}
+\newcommand{\oracle@}[1][]{\ifthenelse{\equal{#1}{}}{\oracle@@{O}}{\oracle@@{#1}}}
+\def\oracle@@#1{\pcoraclestyle{#1}\egroup}
+
+\providecommand{\ro}{\pcoraclestyle{RO}}
+}
 \DeclareOption{events}{
-	\providecommand{\event}[1]{\ensuremath{\mathsf{#1}}}
-	\providecommand{\nevent}[1]{\ensuremath{\overline{\event{#1}}}}
+\providecommand{\event}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\nevent}[1]{\ensuremath{\overline{\event{#1}}}}
 
-	\providecommand{\bad}{\ensuremath{\event{bad}}}
+\providecommand{\bad}{\ensuremath{\event{bad}}}
+\providecommand{\nbad}{\ensuremath{\nevent{bad}}}
 }
-
 \DeclareOption{complexity}{
-	\providecommand{\pccomplexitystyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\complclass}[1]{\pccomplexitystyle{#1}}
+\providecommand{\cocomplclass}[1]{\pccomplexitystyle{co}\pcmathhyphen{}\pccomplexitystyle{#1}}
 
-	\providecommand{\npol}{\pccomplexitystyle{NP}}
-	\providecommand{\conpol}{\ensuremath{\mathsf{co}}\pccomplexitystyle{NP}}
-	\providecommand{\pol}{\pccomplexitystyle{P}}
-	\providecommand{\bpp}{\pccomplexitystyle{BPP}}
-	\providecommand{\ppoly}{\ensuremath{\pol/\mathrm{poly}}}
+\providecommand{\npol}{\pccomplexitystyle{NP}}
+\providecommand{\conpol}{\cocomplclass{NP}}
+\providecommand{\pol}{\pccomplexitystyle{P}}
+\providecommand{\bpp}{\pccomplexitystyle{BPP}}
+\providecommand{\ppoly}{\ensuremath{\pol/\mathrm{poly}}}
 
-	\providecommand{\AM}{\pccomplexitystyle{AM}}
-	\providecommand{\coAM}{\ensuremath{\mathsf{co}}\pccomplexitystyle{AM}}
+\providecommand{\AM}{\pccomplexitystyle{AM}}
+\providecommand{\coAM}{\cocomplclass{AM}}
 
-	\providecommand{\AC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{AC}}{\pccomplexitystyle{AC}^{#1}}}}
-	\providecommand{\NC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{NC}}{\pccomplexitystyle{NC}^{#1}}}}
-	\providecommand{\TC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{TC}}{\pccomplexitystyle{TC}^{#1}}}}
+\providecommand{\AC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{AC}}{\pccomplexitystyle{AC}^{#1}}}}
+\providecommand{\NC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{NC}}{\pccomplexitystyle{NC}^{#1}}}}
+\providecommand{\TC}[1]{\ensuremath{\ifthenelse{\equal{#1}{}}{\pccomplexitystyle{TC}}{\pccomplexitystyle{TC}^{#1}}}}
+
+\providecommand{\PH}{\pccomplexitystyle{PH}}
+\providecommand{\csigma}[1]{\pccomplexitystyle{\Sigma}^p_{#1}}
+\providecommand{\cpi}[1]{\pccomplexitystyle{\Pi}^p_{#1}}
+\providecommand{\cosigma}[1]{\cocomplclass{\Sigma}^p_{#1}}
+\providecommand{\copi}[1]{\cocomplclass{\Pi}^p_{#1}}
 }
-
 \DeclareOption{asymptotics}{
-	\pc at orderofgrowthtrue
+\providecommand{\negl}[1][\secpar]{%
+\pcpolynomialstyle{negl}\ifthenelse{\equal{#1}{}}{}{\pc at olrk*{#1}}}
 
-	\providecommand{\pcpolynomialstyle}[1]{\mathsf{#1}}
-	
-	\providecommand{\negl}[1][\secpar]{\ensuremath{\pcpolynomialstyle{negl}\ifthenelse{\equal{#1}{}}{}{\olrk{#1}}}}
-  	\providecommand{\poly}[1][\secpar]{\ensuremath{\pcpolynomialstyle{poly}\ifthenelse{\equal{#1}{}}{}{\olrk{#1}}}}
-	
-	\providecommand{\pp}{\ensuremath{\pcpolynomialstyle{p}}}
-	\providecommand{\qq}{\ensuremath{\pcpolynomialstyle{q}}}	
+\providecommand{\poly}[1][\secpar]{%
+\pcpolynomialstyle{poly}\ifthenelse{\equal{#1}{}}{}{\pc at olrk*{#1}}}
+
+\def\pp{\bgroup\pp@}
+\newcommand{\pp@}[1][]{\ifthenelse{\equal{#1}{}}{\pp@@{p}}{\pp@@{#1}}}
+\def\pp@@#1{\pcpolynomialstyle{#1}\egroup}
+
+\providecommand{\cc}{\pcpolynomialstyle{c}}
+\providecommand{\ee}{\pcpolynomialstyle{e}}
+\providecommand{\kk}{\pcpolynomialstyle{k}}
+\providecommand{\mm}{\pcpolynomialstyle{m}}
+\providecommand{\nn}{\pcpolynomialstyle{n}}
+\providecommand{\qq}{\pcpolynomialstyle{q}}
+\providecommand{\rr}{\pcpolynomialstyle{r}}
 }
+\DeclareOption{keys}{
+\providecommand{\pk}{\pckeystyle{pk}}
+\providecommand{\vk}{\pckeystyle{vk}}
+\providecommand{\sk}{\pckeystyle{sk}}
 
-\DeclareOption{keys}{
-            \providecommand{\pckeystyle}[1]{\ensuremath{\mathsf{\protect\vphantom{p}#1}}}
-            
-            \providecommand{\pk}{\pckeystyle{pk}}
-            \providecommand{\vk}{\pckeystyle{vk}}
-            \providecommand{\sk}{\pckeystyle{sk}}
-            \providecommand{\key}{\pckeystyle{k}}
-            \providecommand{\hk}{\pckeystyle{hk}}
-            \providecommand{\gk}{\pckeystyle{gk}}
-            \providecommand{\fk}{\pckeystyle{fk}}
-            
-            \providecommand{\st}{\pckeystyle{st}}
-            \providecommand{\state}{\pckeystyle{state}}            
+\def\key{\bgroup\key@}
+\newcommand{\key@}[1][]{\ifthenelse{\equal{#1}{}}{\key@@{k}}{\key@@{#1}}}
+\def\key@@#1{\pckeystyle{#1}\egroup}
+
+\providecommand{\hk}{\pckeystyle{hk}}
+\providecommand{\gk}{\pckeystyle{gk}}
+\providecommand{\fk}{\pckeystyle{fk}}
+
+\providecommand{\st}{\pckeystyle{st}}
+
+\def\state{\bgroup\state@}
+\newcommand{\state@}[1][]{\ifthenelse{\equal{#1}{}}{\state@@{state}}{\state@@{#1}}}
+\def\state@@#1{\pckeystyle{#1}\egroup}
 }
-
 \DeclareOption{n}{
-	\providecommand{\secpar}{\ensuremath{n}}
-	\providecommand{\secparam}{\ensuremath{1^\secpar}}
+\providecommand{\SECPAR}{\ensuremath{{N_0}}}
+\providecommand{\secpar}{\ensuremath{n}}
+\providecommand{\secparam}{\ensuremath{1^\secpar}}
 }
-
 \DeclareOption{lambda}{
-	\renewcommand{\secpar}{\ensuremath{\lambda}}
-	\renewcommand{\secparam}{\ensuremath{1^\secpar}}
+\renewcommand{\SECPAR}{\ensuremath{\Lambda}}
+\renewcommand{\secpar}{\ensuremath{\lambda}}
+\renewcommand{\secparam}{\ensuremath{1^\secpar}}
 }
-
 \DeclareOption*{%
-	\PackageError{crypto code}{Unknown option ‘\CurrentOption’}%
+\PackageError{cryptocode}{Unknown option ‘\CurrentOption’}%
 }
-
 \ExecuteOptions{n}
-
 \ProcessOptions\relax
-
 \RequirePackage{etex}
-
-%amsfonts
-\ifpc at amsfonts
-	\RequirePackage{amsfonts}
+\if at pc@opt at amsfonts
+\RequirePackage{amsfonts}
 \fi
+\if at pc@opt at centernot
+\RequirePackage{centernot}
+\fi
 \RequirePackage{xcolor}
 \RequirePackage{calc}
 \RequirePackage{tikz}
@@ -317,7 +370,6 @@
 \RequirePackage{ifthen}
 \RequirePackage{xargs}
 \RequirePackage{pgf}
-%\RequirePackage{mathabx}
 \RequirePackage{forloop}
 \RequirePackage{array}
 \RequirePackage{xparse}
@@ -327,82 +379,79 @@
 \RequirePackage{suffix}
 \RequirePackage{etoolbox}
 \RequirePackage{environ}
-%\RequirePackage{xspace}
 \RequirePackage{xkeyval}
+\if at pc@opt at advantage
+\providecommand{\pcadvantagesuperstyle}[1]{\mathrm{\MakeLowercase{#1}}}
+\providecommand{\pcadvantagesubstyle}[1]{#1}
+\providecommand{\pcadvantagename}{\mathsf{Adv}}
 
-\ifpc at advantage
-	\newcommand{\pcadvantagesuperstyle}[1]{\mathrm{\MakeLowercase{#1}}}
-	\newcommand{\pcadvantagesubstyle}[1]{#1}
-	\newcommandx*{\advantage}[3][3=(\secpar)]{\ensuremath{\mathsf{Adv}^{\pcadvantagesuperstyle{#1}}_{\pcadvantagesubstyle{#2}}#3}}
+\newcommandx*{\advantage}[3][3=(\secpar)]{\ensuremath{\pcadvantagename^{\pcadvantagesuperstyle{#1}}_{\pcadvantagesubstyle{#2}}#3}}
 \fi
+\providecommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\pcsetstyle}[1]{\ensuremath{\mathbb{#1}}}
+\providecommand{\pccomplexitystyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\pcpolynomialstyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\pcadvstyle}[1]{\ensuremath{\mathcal{#1}}}
+\providecommand{\pcnotionstyle}[1]{\ensuremath{\mathrm{#1}}}
+\providecommand{\pckeystyle}[1]{\ensuremath{\mathsf{\protect\vphantom{p}#1}}}
+\providecommand{\pcmachinemodelstyle}[1]{\ensuremath{\mathsf{#1}}}
+\providecommand{\pcoraclestyle}[1]{\ensuremath{\mathsf{#1}}}
+\DeclarePairedDelimiter\pc at olrk{(}{)}
+\DeclarePairedDelimiter\pc at elrk{[}{]}
+\DeclarePairedDelimiter\pc at clrk{\{}{\}}
+\newlength\pcaboveskip
+\setlength\pcaboveskip{\abovedisplayskip}
 
-\ifpc at primitives	
-	% zero knowledge
-	\providecommand{\prover}{\pcalgostyle{P}}
-	\providecommand{\verifier}{\pcalgostyle{V}}
-	\providecommand{\nizk}{\pcalgostyle{NIZK}}
-	
-	% hash
-	\providecommand{\hash}{\pcalgostyle{H}}
-	\providecommand{\gash}{\pcalgostyle{G}}
-	\providecommand{\fash}{\pcalgostyle{F}}
-	
-	% encryption
-	\providecommand{\enc}{\pcalgostyle{Enc}}
-	\providecommand{\dec}{\pcalgostyle{Dec}}
-	
-	% signatures
-	\providecommand{\sig}{\pcalgostyle{Sig}}
-	\providecommand{\verify}{\pcalgostyle{Vf}}
-	
-	% obfuscation
-	\providecommand{\obf}{\pcalgostyle{O}}
-	\providecommand{\iO}{\pcalgostyle{iO}}
-	\providecommand{\diO}{\pcalgostyle{diO}}
-	
-	% PRF, PRG
-	\providecommand{\prf}{\pcalgostyle{PRF}}
-	\providecommand{\prg}{\pcalgostyle{PRG}}
-	
-	% Mac
-	\providecommand{\mac}{\pcalgostyle{MAC}}
-	
-	% puncture
-	\providecommand{\puncture}{\pcalgostyle{Puncture}}
-	
-	% Misc
-	\providecommand{\source}{\pcalgostyle{S}}
-	\providecommand{\predictor}{\pcalgostyle{P}}
-	\providecommand{\sam}{\pcalgostyle{Sam}}
-	\providecommand{\dist}{\pcalgostyle{D}}
-	\providecommand{\distinguisher}{\pcalgostyle{Dist}}
-	\providecommand{\simulator}{\pcalgostyle{Sim}}
-	\providecommand{\ext}{\pcalgostyle{Ext}}
-	\providecommand{\extractor}{\ext}	
-\fi
+\newlength\pcbelowskip
+\setlength\pcbelowskip{\belowdisplayskip}
 
-%%
-% math hyphen
+\newlength\pcbeforeskip
+\newlength\pcafterskip
+\newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
+\newcommand{\highlightaltkeyword}[2][\ ]{\ensuremath{\mathsf{#2}}#1}
+\newcommand{\pcglobvar}{\highlightkeyword{gbl}}
+\newcommand{\pcnew}{\highlightkeyword{new}}
+\newcommand{\pcwhile}{\@pc at increaseindent\highlightkeyword{while}}
+\newcommand{\pcendwhile}{\@pc at decreaseindent\highlightkeyword{endwhile}}
+\newcommandx*{\pcdo}[2][1=\ ,2=]{#1\highlightkeyword[#2]{do}}
+\newcommandx*{\pcif}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{if}}
+\newcommandx*{\pcunless}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{unless}}
+\newcommandx*{\pcelse}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else}}
+\newcommandx*{\pcelseif}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else if}}
+\newcommand{\pcfi}{\@pc at decreaseindent\highlightkeyword{fi}}
+\newcommand{\pcendif}{\@pc at decreaseindent\highlightkeyword{endif}}
+\newcommand{\pcendfor}{\@pc at decreaseindent\highlightkeyword{endfor}}
+\newcommandx*{\pcthen}[2][1=\ ,2=\ ]{#1\highlightkeyword[#2]{then}}
+\newcommand{\pcreturn}{\highlightkeyword{return}}
+\newcommandx*{\pcin}[2][1=\ ,2=]{#1\highlightkeyword[#2]{in}}
+\newcommandx*{\pcfor}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{for}}
+\newcommand{\pcrepeat}[1]{%
+\@pc at increaseindent\ensuremath{%
+\highlightkeyword{repeat} #1\ \highlightkeyword{times}%
+}}
+\newcommand{\pcrepeatuntil}[2]{%
+\ensuremath{\highlightkeyword{repeat}\ #1\ \highlightkeyword{until}\ #2}}
+\newcommand{\pcforeach}{\@pc at increaseindent\highlightkeyword{foreach}}
+\newcommand{\pcendforeach}{\@pc at decreaseindent\highlightkeyword{endforeach}}
+\newcommand{\pcuntil}{\@pc at decreaseindent\highlightkeyword{until}}
+\newcommand{\pccontinue}{\highlightkeyword{continue}}
+\newcommandx*{\pcfalse}[2][1=\ ,2=]{\highlightkeyword[#2]{false}}
+\newcommandx*{\pctrue}[2][1=\ ,2=]{\highlightkeyword[#2]{true}}
+\newcommandx*{\pcnull}[2][1=\ ,2=]{\highlightkeyword[#2]{null}}
+\newcommand{\pcdone}{\highlightkeyword{done}}
+\newcommand{\pcparse}{\highlightkeyword{parse}}
+\newcommand{\pcfail}{\highlightkeyword{fail}}
+\newcommand{\pcabort}{\highlightkeyword{abort}}
 \mathchardef\pcmathhyphen ="2D
-
-%%%
-% order of growth helper
-\ifpc at orderofgrowth
-\providecommand{\olrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus 0.5mu\left(\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right)\fi}
-
-\providecommand{\elrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus0.5mu\left[\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right]\fi}
-
-\providecommand{\clrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus0.5mu\left\{\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right\}\fi}
-\fi
-
-\ifpc at algorithmstyle
-	\providecommand{\pcalgostyle}[1]{\ensuremath{\mathsf{#1}}}
-\fi
-
-%%%
-% create command to measure width of align
-%
-\newcommand{\@settowidthofalign}[2]{%
+\newcommand{\pccomment}[2][1em]{\hspace{#1}{\mbox{/\!\!/ } \text{\scriptsize#2}}}
+\newcommand{\pclinecomment}[2][0em]{\hspace{#1}{\mbox{/\!\!/ } \text{\scriptsize#2}}}
+\newcommand\@pc at ifinfloat[2]{\ifnum\@floatpenalty<0\relax#1\else#2\fi}
+\newcommand*\@expandedsetkeys[5]{\expandafter\@expandedsetkeys@\expandafter{#4}{#1}{#2}{#3}{#5}}
+\def\@expandedsetkeys@#1#2#3#4#5{\setkeys{#2}[#3]{#4,#1,#5}}
+\newenvironment{@pc at withspaces}
+ {\obeyspaces\begingroup\lccode`~=` \lowercase{\endgroup\let~}\ }
+ {}
+\newcommand{\@pc at settowidthofalign}[2]{%
   \setbox\z@=\vbox{\@pseudocodecodesize
     \begin{flalign*}
     #2
@@ -412,24 +461,15 @@
   \begingroup
   \def\or{+}\edef\x{\endgroup#1=\dimexpr\got at maxcolwd\relax}\x}
 
-\newcommand{\@settowidthofaligned}[2]{%
+\newcommand{\@pc at settowidthofaligned}[2]{%
 \settowidth{#1}{\@pseudocodesubcodesize$\begin{aligned}#2\end{aligned}$}}
-
-% check for draft mode
 \def\@pc at ifdraft{\ifdim\overfullrule>\z@
   \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
-
-% run stuff in an empty box
-\newcommand{\@pcexecuteblindly}[1]{%
+\newcommand{\@pc at executeblindly}[1]{%
  \setbox\z@=\vbox{#1 }}
-
-% copy label command
 \AtBeginDocument{
-	\let\pc at original@label\ltx at label
+\let\@pc at original@label\ltx at label
 }
-
-
-%%%%%%
 \newcommand*{\@pc at globaladdtolength}[2]{%
 \addtolength{#1}{#2}%
 \global#1=#1\relax}
@@ -437,92 +477,150 @@
 \newcommand*{\@pc at globalsetlength}[2]{%
 \setlength{#1}{#2}%
 \global#1=#1\relax}
-
-
-
-%%%%%
-% spaces before and after pseudo codes (left and right)
-\providecommand{\beforepcskip}{2pt}
-\providecommand{\afterpcskip}{0pt}
-
-%%%
-% a global counter of the number of times the pseudocode command was triggered
 \newcounter{@pc at global@pc at cnt}
 \newcounter{@pc at global@pc at nestcnt}
-
-%%%
-% Fix hyperref package.. gnarl http://tex.stackexchange.com/questions/130319/incompatibility-between-etoolbox-and-hyperref
 \providecommand{\pcfixhyperref}{
 \global\let\textlabel\label
-\global\let\pc at original@label\textlabel
-%\global\let\pc at original@label\relax
-%\global\let\label\relax
+\global\let\@pc at original@label\textlabel
+ %\global\let\@pc at original@label\relax
+ %\global\let\label\relax
 }
+\newcommand{\pchspace}[1][1em]{\hspace{#1}}
+\newcommand{\pcvspace}[1][\baselineskip]{\par\vspace{#1}}
+\newcounter{@pc at stackdepth}
+\newcommand{\@pc at incstackdepth}{\addtocounter{@pc at stackdepth}{1}}
+\newcommand{\@pc at decstackdepth}{\addtocounter{@pc at stackdepth}{-1}}
+\newcommand{\@pc at centerstack}{false}
+\define at key{pcstack}{center}[true]{\ifthenelse{\equal{#1}{true}}
+{\renewcommand{\@pc at centerstack}{true}}
+{\renewcommand{\@pc at centerstack}{false}}}%
+\newcommand{\@pc at boxedstack}{false}
+\define at key{pcstack}{boxed}[true]{\ifthenelse{\equal{#1}{true}}
+{\renewcommand{\@pc at boxedstack}{true}}
+{\renewcommand{\@pc at boxedstack}{false}}}%
+\newcommand{\@pc at noindentstack}{false}
+\define at key{pcstack}{noindent}[true]{\ifthenelse{\equal{#1}{true}}
+{\renewcommand{\@pc at noindentstack}{true}}
+{\renewcommand{\@pc at noindentstack}{false}}}%
+\newcommand{\@pc at inlinestack}{false}
+\define at key{pcstack}{inline}[true]{\ifthenelse{\equal{#1}{true}}
+{\renewcommand{\@pc at inlinestack}{true}}
+{\renewcommand{\@pc at inlinestack}{false}}}%
+\providecommand{\pchstackspace}{0pt}
+\providecommand{\pcvstackspace}{0pt}
+\newcommand{\@pc at stackspace@forpseudocode}{}
+\newlength{\@pc at stackspace@len}
+\newcommand*{\@pc at stackspace}{0pt}
+\newcommand*{\@pc at reset@stackspace}{\setlength{\@pc at stackspace@len}{\@pc at stackspace}}
+\define at key{pcstack}{space}[0pt]{\renewcommand*{\@pc at stackspace}{#1}}%
+\newcommand{\@pc at addabovespaceunlessstacking}{%
+\ifthenelse{\value{@pc at stackdepth}=0}{\par\addvspace{\pcaboveskip}}{}}
 
-\newcounter{@spacecounter}
-\providecommand{\spacetoindent}{1}
-\newenvironment{@withspaces}
- {\obeyspaces\begingroup\lccode`~=` \lowercase{\endgroup\let~}\ }
- {}
+\newcommand{\@pc at applyaboveskipinstack}{\@pc at addabovespaceunlessstacking}
+\let\org at pc@applyaboveskipinstack\@pc at applyaboveskipinstack
 
-%%%%%%%%%%%%%%
-% a latex3 string substitution.
-\ExplSyntaxOn
-\tl_new:N \l_pc_strsub_input_tl
-\tl_new:N \l_pc_strsub_search_tl
-\tl_new:N \l_pc_strsub_replace_tl
+\define at key{pcstack}{aboveskip}[default]{\ifthenelse{\equal{#1}{default}}
+{\renewcommand{\@pc at applyaboveskipinstack}{\org at pc@applyaboveskipinstack}}
+{\renewcommand{\@pc at applyaboveskipinstack}{\vspace{#1}}}}%
+\newcommand{\@pc at addbelowspaceunlessstacking}{%
+\ifthenelse{\value{@pc at stackdepth}=0}
+{\@pc at ifinfloat{}{\par\addvspace{\pcbelowskip}}}
+{}}
 
-\NewDocumentCommand{\@pc at stringsubstitution}{mmm}
- {
-  \tl_set:Nn \l_pc_strsub_input_tl { #1 }
-  \tl_set:Nn \l_pc_strsub_search_tl { #2 }
-  \tl_set:Nn \l_pc_strsub_replace_tl { #3 }
-%  \tl_show_analysis:N  \l_pc_strsub_input_tl % uncomment for debugging
-%  \tl_show_analysis:N  \l_pc_strsub_search_tl % uncomment for debugging
-%  \tl_show_analysis:N  \l_pc_strsub_replace_tl % uncomment for debugging
-   \regex_replace_all:nnN
-      { (\W)\u{l_pc_strsub_search_tl} } %only match if keyword does not have a word character preceding
-      { \1\u{l_pc_strsub_replace_tl} }
-      \l_pc_strsub_input_tl
-      %  \tl_show_analysis:N \l_tmpa_tl % uncomment for debugging
-      \tl_use:N \l_pc_strsub_input_tl    
- }
- 
- % same as \@pc at stringsubstitution but without requiring the extra non word character
- \NewDocumentCommand{\@pc at spacesubstitution}{mmm}
- {
-  \tl_set:Nn \l_pc_strsub_input_tl { #1 }
-  \tl_set:Nn \l_pc_strsub_search_tl { #2 }
-  \tl_set:Nn \l_pc_strsub_replace_tl { #3 }
-%  \tl_show_analysis:N  \l_pc_strsub_input_tl % uncomment for debugging
-%  \tl_show_analysis:N  \l_pc_strsub_search_tl % uncomment for debugging
-%  \tl_show_analysis:N  \l_pc_strsub_replace_tl % uncomment for debugging
-   \regex_replace_all:nnN
-      { \u{l_pc_strsub_search_tl} } 
-      { \u{l_pc_strsub_replace_tl} }
-      \l_pc_strsub_input_tl
-      %  \tl_show_analysis:N \l_tmpa_tl % uncomment for debugging
-      \tl_use:N \l_pc_strsub_input_tl    
- }
- 
-\NewDocumentCommand{\@pc at centercolifnec}{m}%
-{%
-#1%
+\newcommand{\@pc at applybelowskipinstack}{\@pc at addbelowspaceunlessstacking}
+\let\org at pc@applybelowskipinstack\@pc at addbelowspaceunlessstacking
+
+\define at key{pcstack}{belowskip}[default]{\ifthenelse{\equal{#1}{default}}
+{\renewcommand{\@pc at applybelowskipinstack}{\org at pc@applybelowskipinstack}}
+{\renewcommand{\@pc at applybelowskipinstack}{\par\addvspace{#1}}}}%
+\newlength{\pcbeforehstackskip}
+\newlength{\pcafterhstackskip}
+\newsavebox{\@pc at stackcontentbox}%
+\newcommand*\@pc at hstack@defaultargs{}
+\newcommand*\pcsethstackargs[1]{\renewcommand*\@pc at hstack@defaultargs{#1}}
+\newcommand*\@pc at vstack@defaultargs{}
+\newcommand*\pcsetvstackargs[1]{\renewcommand*\@pc at vstack@defaultargs{#1}}
+\newenvironment{pccenter}{%
+\setlength\topsep{0pt}\setlength\parskip{0pt}%
+\begin{center}}{\end{center}}
+\NewEnviron{pchstack}[1][]{%
+\begingroup%
+\@expandedsetkeys{pcstack}{}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pchstackspace}{\@pc at hstack@defaultargs}{#1}%
+\@pc at reset@stackspace%
+\ifthenelse{\equal{\@pc at inlinestack}{true}}{}{\@pc at applyaboveskipinstack}%
+\@pc at incstackdepth%
+\renewcommand{\@pc at stackspace@forpseudocode}{\hspace{\@pc at stackspace}}%
+\ifthenelse{\equal{\@pc at boxedstack}{true}}%
+{\sbox{\@pc at stackcontentbox}
+   {\fbox{\mbox{\hspace{\pcbeforehstackskip}\BODY\hspace{\pcafterhstackskip}\hspace{-\@pc at stackspace}}}}}%
+{\sbox{\@pc at stackcontentbox}
+   {\mbox{\hspace{\pcbeforehstackskip}\BODY\hspace{\pcafterhstackskip}\hspace{-\@pc at stackspace}}}}%
+\ifthenelse{\equal{\@pc at noindentstack}{true}}{\par\noindent\ignorespaces}{}%
+\ifthenelse{\equal{\@pc at centerstack}{true}}%
+{\begin{pccenter}\usebox{\@pc at stackcontentbox}\end{pccenter}}
+{\usebox{\@pc at stackcontentbox}}%
+\@pc at decstackdepth%
+\ifthenelse{\equal{\@pc at inlinestack}{true}}{}{\@pc at applybelowskipinstack}%
+\endgroup%reset space outside group
+\@pc at reset@stackspace%
+\@pc at stackspace@forpseudocode%
+\ignorespacesafterend\noindent% 
 }
- 
- 
- 
-\ExplSyntaxOff
+\NewEnviron{pcvstack}[1][]{%
+\begingroup%
+\@expandedsetkeys{pcstack}{}{center=false,boxed=false,aboveskip=default,belowskip=default,space=\pcvstackspace}{\@pc at vstack@defaultargs}{#1}%
+\@pc at reset@stackspace%
+\@pc at applyaboveskipinstack%
+\@pc at incstackdepth%
+\renewcommand{\@pc at stackspace@forpseudocode}{\par\vspace{\@pc at stackspace}}%
+\sbox{\@pc at stackcontentbox}{%
+\ifthenelse{\equal{\@pc at boxedstack}{true}}%
+{\fbox{\raisebox{\dimexpr\ht\strutbox-\height}{\begin{varwidth}[t]{2\linewidth}\BODY\end{varwidth}}}}%
+{\raisebox{\dimexpr\ht\strutbox-\height}{\begin{varwidth}[t]{2\linewidth}\BODY\end{varwidth}}}%
+\vspace{-\@pc at stackspace}}%
+\ifthenelse{\equal{\@pc at noindentstack}{true}}{\par\noindent\ignorespaces}{}%
+\ifthenelse{\equal{\@pc at centerstack}{true}}%
+{\begin{pccenter}\usebox{\@pc at stackcontentbox}\end{pccenter}}%
+{\usebox{\@pc at stackcontentbox}}%
+\@pc at decstackdepth%
+\@pc at applybelowskipinstack%
+\endgroup%reset space outside group
+\@pc at reset@stackspace%
+\@pc at stackspace@forpseudocode%
+\ignorespacesafterend\noindent% 
+}
+\newlength{\@pc at minipage@length}
+\newlength{\@pc at alt@minipage at length}
+\newlength{\@pc at length@tmp at width@vstack}
+\newcommand{\@withingame}{false}
+\newcommand{\@withinbxgame}{false}
+\newcommand{\@withingamedescription}{false}
+\newcommand{\@bxgameheader}{}
+\newlength\@pseudocodecodeminlineheight at len
+\newcommand{\@pc at beginnewline}{%
+\@pseudocodecodeatbeginline\@pseudocodelinenumber\@pc at and\@pcln at stephiddenlncnt%
+\setlength{\@pseudocodecodeminlineheight at len}{\@pseudocodecodeminlineheight}%
+\vphantom{\rule[0.5ex-0.5\@pseudocodecodeminlineheight at len]{0pt}{\@pseudocodecodeminlineheight at len}}%
+\ifthenelse{\equal{\@pseudocodespace}{auto}}%
+{\expandafter\pcind\expandafter[\value{@pc at indentationlevel}]}%
+{}%
+\setcounter{pccolumncounter}{2}%
+\@pc at modebegin}
+\newcommand{\@pc at and@wrap at start}{\@pc at beginnewline}
+\newcommand{\@pc at and@wrap at end}{\@pc at modeend&\@pseudocodecodeatendline}
+\newcommand{\@pc at and}{&}
+\newlength{\@pcindentwidth}
+\providecommand{\pcind}[1][1]{%
+\setlength{\@pcindentwidth}{\widthof{\ensuremath{\quad}}*#1}%
+\ensuremath{\mathmakebox[\@pcindentwidth]{}}}
+\newcommand{\pctabname}{>}
+\newcommand{\pcdbltabname}{<}
+\newcommand{\pcindentname}{t}
 
-%%%%%%%%
-% line numbers
-%%%%%%%%
-% The following commands handle line numbering within the pseudocode command. The
-% pseudocode command itself does need to do some counter magic
 \newcounter{pclinenumber}
-\newcounter{Hpclinenumber} % make hyperref happy
+\newcounter{Hpclinenumber}
 \newcounter{@pclinenumber}
-\newcounter{H at pclinenumber} % make hyperref happy
+\newcounter{H at pclinenumber}
 \newcounter{@pclinenumbertmp}
 \newcounter{pcgamecounter}
 \newcounter{Hpcgamecounter}
@@ -529,92 +627,36 @@
 \newcounter{pcrlinenumber}
 \newcounter{Hpcrlinenumber}
 \newcounter{@pcrlinenumbertmp}
-
-% separators
-\providecommand{\pclnseparator}{:}
-\providecommand{\pcrlnseparator}{\hspace{1pt}}
-
-% spacing for linenumbers
-\providecommand{\pclnspace}{0pt}
-\providecommand{\pclnrspace}{5pt}
-
 \renewcommand{\the at pclinenumber}{\thepclinenumber}
-\providecommand{\@pcln}{%
+\providecommand{\@pcln at stephiddenlncnt}{%
 \refstepcounter{@pclinenumber}%
 \stepcounter{H at pclinenumber}%
 }
-
-% left align line numbers
-\providecommand{\pcln}[1][]{%
+\providecommand{\pclnseparator}{:}
+\providecommand{\pcrlnseparator}{}
+\providecommand{\pclnspace}{1em}
+\providecommand{\pclnrspace}{0.5em}
+\providecommand\pclnstyle[1]{\text{\scriptsize#1}}
+\providecommand{\pcln}{%
+\ifthenelse{\equal{\@pc at skiplnmarker}{1}}{\ifmeasuring@\else\@pc at resetskipln{}\fi}{%
 \refstepcounter{pclinenumber}%
 \stepcounter{Hpclinenumber}%
-\ifthenelse{\equal{#1}{}}{}{%
-%keep hyperref happy
-\ifmeasuring@\else\pc at original@label{#1}\fi%
-}%
 \ifthenelse{\value{pclinenumber}<10}{\hspace{1ex}}{}%
-\hspace{\pclnspace}\text{\scriptsize\arabic{pclinenumber}}\pclnseparator\quad}%
-
-% allow to skip numbering single lines if linenumbering=on 
-\providecommand{\pcnoln}{%
-}
-
-% right align line numbers (same counter)
+\pclnstyle{\arabic{pclinenumber}}\pclnseparator\hspace{\pclnspace}%
+}}%
+\def\@pc at skiplnmarker{}
+\providecommand{\pcskipln}{\ifmeasuring@\else\global\def\@pc at skiplnmarker{1}\fi}
+\newcommand{\@pc at resetskipln}{\global\def\@pc at skiplnmarker{}}
+\define at key{pseudocode}{skipfirstln}[1]{\global\def\@pc at skiplnmarker{1}}
 \providecommand{\pclnr}{%
 \refstepcounter{pclinenumber}%
-\quad\text{\scriptsize\pcrlnseparator\arabic{pclinenumber}}\hspace{5pt}}
+\stepcounter{Hpclinenumber}%
+\hspace{\pclnrspace}\pcrlnseparator\pclnstyle{\arabic{pclinenumber}}}
 
-% right align line numbers different counter
 \providecommand{\pcrln}{
 \refstepcounter{pcrlinenumber}%
 \stepcounter{Hpcrlinenumber}%
-\text{\scriptsize\pcrlnseparator\arabic{pcrlinenumber}}\hspace{\pclnrspace}}
-
-
-%%%
-% indentation
-\newlength{\@pcindentwidth}
-\providecommand{\pcind}[1][1]{%
-\setlength{\@pcindentwidth}{\widthof{\ensuremath{\quad}}*#1}%
-\ensuremath{\mathmakebox[\@pcindentwidth]{}}}
-
-
-% create length
-\newlength{\@pc at minipage@length}
-\newlength{\@pc at alt@minipage at length}
-
-% backward games
-\newcommand{\@withingame}{false}
-\newcommand{\@withinbxgame}{false}
-\newcommand{\@bxgameheader}{}
-\newcommand{\@withingamedescription}{false}
-
-
-%%%%%%%%%%%%
-% The pseudocode Command
-%%%%%
-\newlength{\@pc at length@tmp at width@vstack}
-
-
-\newcommand{\@pc at beginnewline}{%
-\@pseudocodecodeatbeginline\@pseudocodelinenumber\@pc at and\@pcln%
-%checkspace
-\ifthenelse{\equal{\@pseudocodespace}{auto}}%
-{\expandafter\pcind\expandafter[\value{@pc at indentationlevel}]}%
-{}%
-%reset column counter
-\setcounter{pccolumncounter}{2}%
-%beginmode
-\@pc at modebegin}
-\newcommand{\@pc at and}{&}
-\newcommand{\@pc at and@wrap at end}{\@pc at modeend&\@pseudocodecodeatendline}
-\newcommand{\@pc at and@wrap at start}{\@pc at beginnewline}
-\newcommand{\pctabname}{>}
-\newcommand{\pcdbltabname}{<}
-\newcommand{\pcindentname}{t}
-
-
-
+\hspace{\pclnrspace}\pcrlnseparator\pclnstyle{\arabic{pcrlinenumber}}}
 \newcommand*\@pseudocodehead{}
 \newcommand*\@pseudocodewidth{}
 \newcommand*\@pseudocodexshift{0pt}
@@ -628,9 +670,28 @@
 \newcommand*\@pseudocodenodraft{false}
 \newcommand*\@pseudocodecolspace{} % empty per default, use length,
 
+\newcommand*\@pseudocodeheadlinecmd{\hrule}
+
+
+\newlength\pcheadlinesep
+\setlength\pcheadlinesep{0pt}
 \newcommand*\@pseudocodeheadlinesep{0em}
-\newcommand*\@pseudocodebodylinesep{-0.5\baselineskip}
+\define at key{pseudocode}{headlinesep}[0em]{\renewcommand*\@pseudocodeheadlinesep{#1}}
+\newlength\pcbodylinesep
+\setlength\pcbodylinesep{0.3\baselineskip}
+\newcommand*\@pseudocodebodylinesep{0em}
+\define at key{pseudocode}{bodylinesep}[0em]{\renewcommand*\@pseudocodebodylinesep{#1}}
+\newlength\@pseudocodeheadheight at len
+\newcommand{\@pc at headheightskip}{%
+\setlength{\@pseudocodeheadheight at len}{\@pseudocodeheadheight}%
+\vphantom{\rule[0.5ex-0.5\@pseudocodeheadheight at len]{0pt}{\@pseudocodeheadheight at len}}%
+}
+\newlength\pcheadheight
+\setlength{\pcheadheight}{3.25ex}
+\newcommand*\@pseudocodeheadheight{\pcheadheight}
+\define at key{pseudocode}{headheight}[0em]{\renewcommand*\@pseudocodeheadheight{#1}}
 
+
 \newcommand*\@pseudocodecolsep{0em}
 \newcommand*\@pseudocodeaddtolength{2pt}
 
@@ -642,21 +703,15 @@
 
 \newcommand*\@pseudocodeminipagealign{t}
 
-%%%%%%%%%%%%%%
-% Define keywords for the automatic syntax highlighting
-% the accompanying add provides additional keywords.
-% The space version for automatic spacing
 \newcommand*\@pseudocodekeywordsindent{for ,foreach ,if ,repeat ,while }
-\newcommand*\@pseudocodekeywordsunindent{endfor,endforeach,fi,endif,until ,endwhile}
-\newcommand*\@pseudocodekeywordsuninindent{else if,elseif, else}
-\newcommand*\@pseudocodekeywords{return ,{ do }, in ,new ,null ,null,true ,true,{ to },false ,false,{ then },done ,done}
+\newcommand*\@pseudocodekeywordsunindent{endfor,endforeach,fi,endif,until,endwhile}
+\newcommand*\@pseudocodekeywordsuninindent{else if ,elseif ,else }
+\newcommand*\@pseudocodekeywords{for,foreach,{return },return,{ do },{ in },new,if, null, true,{until },{ to }, false,{ then},repeat,else if,elseif,while,else,done}
 \newcommand*\@pseudocodeaddkeywords{}
 \newcommand*\@pseudocodealtkeywords{}
-\begin{@withspaces}
+\begin{@pc at withspaces}
 \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}
-\end{@withspaces}
-
-
+\end{@pc at withspaces}
 \define at key{pseudocode}{beginline}[]{\renewcommand*\@pseudocodecodeatbeginline{#1}}
 \define at key{pseudocode}{endline}[]{\renewcommand*\@pseudocodecodeatendline{#1}}
 \define at key{pseudocode}{jot}[0em]{\renewcommand*\@pseudocodecodejot{#1}}
@@ -674,21 +729,8 @@
 \define at key{pseudocode}{lnstart}[0]{\renewcommand*\@pseudocodelnstart{#1}}
 \define at key{pseudocode}{lnstartright}[0]{\renewcommand*\@pseudocodelnstartright{#1}}
 \define at key{pseudocode}{colsep}[0em]{\renewcommand*\@pseudocodecolsep{#1}}
-\define at key{pseudocode}{headlinesep}[0em]{\renewcommand*\@pseudocodeheadlinesep{#1}}
-\define at key{pseudocode}{bodylinesep}[0em]{\renewcommand*\@pseudocodebodylinesep{#1}}
+\define at key{pseudocode}{headlinecmd}[\hrule]{\renewcommand*\@pseudocodeheadlinecmd{#1}}
 \define at key{pseudocode}{addtolength}[2pt]{\renewcommand*\@pseudocodeaddtolength{#1}}
-\define at key{pseudocode}{mode}[math]{%
-\ifthenelse{\equal{#1}{text}}{%
-\renewcommand*\@pc at modebegin{\begin{varwidth}{\textwidth}%
-%introduce line magic for text mode
-\let\@pc at lb\\%
-\renewcommandx*{\\}[2][1=,2=]{\@pc at modeend\@pc at and \@pseudocodecodeatendline\ifthenelse{\equal{####1}{}}{\@pc at lb}{\@pc at lb[####1]}####2 \@pc at beginnewline}%
-\def\pclb{\let\\\@pc at lb\relax\@pc at modeend\\}%
-\def\pcolb{\let\\\@pc at lb\relax\@pc at modeend\\}%
-}%
-\renewcommand*\@pc at modeend{\end{varwidth}}
-}{}%
-}
 \define at key{pseudocode}{nodraft}[true]{\renewcommand*\@pseudocodenodraft{#1}}
 \define at key{pseudocode}{keywords}[]{\renewcommand*\@pseudocodekeywords{#1}}
 \define at key{pseudocode}{keywordsindent}[]{\renewcommand*\@pseudocodekeywordsindent{#1}}
@@ -697,12 +739,44 @@
 \define at key{pseudocode}{addkeywords}[]{\renewcommand*\@pseudocodeaddkeywords{#1}}
 \define at key{pseudocode}{altkeywords}[]{\renewcommand*\@pseudocodealtkeywords{#1}}
 \define at key{pseudocode}{syntaxhighlight}[]{\renewcommand*\@pseudocodesyntaxhighlighting{#1}}
-
 \newcommand{\@pc at modebegin}{}
 \newcommand{\@pc at modeend}{}
-\newcommand{\@pc at thecontent}{}
+\define at key{pseudocode}{mode}[math]{%
+\ifthenelse{\equal{#1}{text}}{%
+\renewcommand*\@pc at modebegin{\begin{varwidth}{\textwidth}%
+\let\@pc at lb\\%
+\renewcommandx*{\\}[2][1=,2=]{\@pc at modeend\@pc at and \@pseudocodecodeatendline\ifthenelse{\equal{####1}{}}{\@pc at lb}{\@pc at lb[####1]}####2 \@pc at beginnewline}%
+\def\pclb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+\def\pcolb{\let\\\@pc at lb\relax\@pc at modeend\\}%
+}%
+\renewcommand*\@pc at modeend{\end{varwidth}}%
+}{\renewcommand{\@pc at modebegin}{}\renewcommand{\@pc at modeend}{}}}
+\providecommand{\pcminlineheight}{0pt}
+\newcommand*\@pseudocodecodeminlineheight{\pcminlineheight}
+\define at key{pseudocode}{minlineheight}[0pt]{\renewcommand*\@pseudocodecodeminlineheight{#1}}
+\ExplSyntaxOn
+\tl_new:N \l_pc_strsub_input_tl
+\tl_new:N \l_pc_strsub_search_tl
+\tl_new:N \l_pc_strsub_replace_tl
 
+\NewDocumentCommand{\@pc at stringsubstitution}{mmm}
+ {
+  \tl_set:Nn \l_pc_strsub_input_tl { #1 }
+  \tl_set:Nn \l_pc_strsub_search_tl { #2 }
+  \tl_set:Nn \l_pc_strsub_replace_tl { #3 }
+ %  \tl_show_analysis:N  \l_pc_strsub_input_tl % uncomment for debugging
+ %  \tl_show_analysis:N  \l_pc_strsub_search_tl % uncomment for debugging
+ %  \tl_show_analysis:N  \l_pc_strsub_replace_tl % uncomment for debugging
+   \regex_replace_all:nnN
+      { \u{l_pc_strsub_search_tl} } %only match if keyword does not have a word character preceding
+      { \u{l_pc_strsub_replace_tl} }
+      \l_pc_strsub_input_tl
+       %  \tl_show_analysis:N \l_tmpa_tl % uncomment for debugging
+      \tl_use:N \l_pc_strsub_input_tl
+ }
+\ExplSyntaxOff
 \newcommand{\@pc at syntaxhighlight}[1]{%
+\ifmeasuring@#1\else%
 \ifthenelse{\equal{\@pseudocodesyntaxhighlighting}{auto}}{%
 \def\@shtmp{#1}% first step
 \ifthenelse{\equal{\@pseudocodespace}{keep}}
@@ -712,7 +786,6 @@
       {\edef\@tmpkeywords{\@pseudocodekeywords,\@pseudocodekeywordsindent,\@pseudocodekeywordsunindent,\@pseudocodekeywordsuninindent,\@pseudocodeaddkeywords}}}
 \foreach \@pckw in \@tmpkeywords{%
 \ifthenelse{\equal{\@pckw}{}}{}{%
-% we are doing a simple strsub and storing the result (globally) in @shtmp
 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
@@ -720,11 +793,9 @@
                 \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                 {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
                  }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlight\expandafter{\@pckw}}}%
-}% alt keywords
-}%
+}}% alt keywords
 \foreach \@pckw in \@pseudocodealtkeywords{%
 \ifthenelse{\equal{\@pckw}{}}{}{%
-% we are doing a simple strsub and storing the result (globally) in @shtmp
 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
@@ -732,15 +803,11 @@
                 \@pc at stringsubstitution\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                 {\expandafter\expandafter\expandafter\@shtmp\expandafter\expandafter\expandafter
                  }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at althighlight\expandafter{\@pckw}}}%
-}%
-}%
-%%%%
-% if automatic spacing
+}}%
 \ifthenelse{\equal{\@pseudocodespace}{auto}}
 {%
 \foreach \@pckw in \@pseudocodekeywordsindent{% indentation keywords
 \ifthenelse{\equal{\@pckw}{}}{}{%
-% we are doing a simple strsub and storing the result (globally) in @shtmp
 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
@@ -751,7 +818,6 @@
 }}%
 \foreach \@pckw in \@pseudocodekeywordsunindent{% unindentation keywords
 \ifthenelse{\equal{\@pckw}{}}{}{%
-% we are doing a simple strsub and storing the result (globally) in @shtmp
 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
@@ -762,7 +828,6 @@
 }}%
 \foreach \@pckw in \@pseudocodekeywordsuninindent{% uninindentation keywords
 \ifthenelse{\equal{\@pckw}{}}{}{%
-% we are doing a simple strsub and storing the result (globally) in @shtmp
 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \gdef\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
                  \@shtmp\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
@@ -772,15 +837,14 @@
                  }\expandafter\expandafter\expandafter{\expandafter\@pckw\expandafter}\expandafter{\expandafter\@pc at highlightuninindent\expandafter{\@pckw}}}%
 }}%
 }{}%
-% return result
 \@shtmp%
 }{#1}% nothing to highlight
-}
+\fi}
 
 \newcommand{\@pc at highlight}[1]{%
 \ifthenelse{\equal{\@pseudocodespace}{keep}}
     {\highlightkeyword[]{#1}}%
-    {\highlightkeyword[]{\@pc at spacesubstitution{#1}{ }{~}}}%
+    {\highlightkeyword[]{\@pc at stringsubstitution{#1}{ }{~}}}%
 }
 
 \newcommand{\@pc at highlightindent}[1]{%
@@ -798,23 +862,20 @@
 \newcommand{\@pc at althighlight}[1]{%
 \ifthenelse{\equal{\@pseudocodespace}{keep}}
     {\highlightaltkeyword{#1}}%
-    {\highlightaltkeyword{\@pc at spacesubstitution{#1}{ }{~}}}%
+    {\highlightaltkeyword{\@pc at stringsubstitution{#1}{ }{~}}}%
 }
-
+\newcommand{\@pc at thecontent}{}
 \newcommand{\@pc at colspace}{}
-
-%%%%%%%%%%%%%%%%%
-% Allow for spacing
 \newcommand{\@withinspaces}{false}%
 \newcommand{\@keepspaces}{%
-\renewcommand{\@withinspaces}{true}\@withspaces%
+\renewcommand{\@withinspaces}{true}\@pc at withspaces%
 }
-\newcommand{\@pc at endgroupafterpc}{}
-
 \newcommand*\@pseudocodespace{}
 \define at key{pcspace}{space}[]{\ifthenelse{\equal{#1}{keep}}{\@keepspaces}{}\renewcommand*\@pseudocodespace{#1}}
 
-%%% automatic indentation
+\newcommand*\@pc at defaultargs{}
+\newcommand*\pcsetargs[1]{\renewcommand*\@pc at defaultargs{#1}}
+
 \newcounter{@pc at indentationlevel}
 \newcommand{\@pc at increaseindent}{\addtocounter{@pc at indentationlevel}{1}}
 \newcommand{\@pc at decreaseindent}{\ifthenelse{\equal{\@pseudocodespace}{auto}}{\pcind[-1]}{}\addtocounter{@pc at indentationlevel}{-1}}
@@ -823,10 +884,7 @@
 \newcounter{pccolumncounter}
 \setcounter{pccolumncounter}{2}
 
-% store original halign
 \let\@pc at halign\halign%
-
-%% Check if the pseudocode command is called with an optional argument
 \providecommand{\pseudocode}{%
 \begingroup%
 \renewcommand{\@withinspaces}{false}%
@@ -842,16 +900,11 @@
 
 \def\@pseudocode[#1]#2{%
 \begingroup%
-\setkeys{pseudocode}[space]{#1}%ignore the space key.
-% check draft mode and disable syntax highlighting
+\@pc at resetskipln%
+\@expandedsetkeys{pseudocode}{space}{head=}{\@pc at defaultargs}{#1}%
 \@pc at ifdraft{\ifthenelse{\equal{\@pseudocodenodraft}{true}}{}{\renewcommand\@pseudocodesyntaxhighlighting{}}}{}%
-%
-%
 \addtocounter{@pc at global@pc at nestcnt}{1}%
-% allow for tikz usage
 \@pc at ensureremember%
-%
-% create tabbing command
 \ifcsname \pctabname\endcsname%
 \expandafter\renewcommand\csname \pctabname\endcsname{\@pc at modeend&\@pc at colspace\@pc at modebegin}%
 \else%
@@ -862,20 +915,12 @@
 \else%
 \expandafter\newcommand\csname \pcdbltabname\endcsname{\@pc at modeend&&\@pc at colspace\@pc at modebegin}%
 \fi%
-% create colspace command if necessary (must be empty for multicolumns
 \ifthenelse{\equal{\@pseudocodecolspace}{}}
  {}
  {\renewcommand{\@pc at colspace}{\hspace{\@pseudocodecolspace}}}%
-%
-%adjust row width
 \addtolength{\jot}{\@pseudocodecodejot}%
-% create indent command
 \expandafter\let\csname \pcindentname\endcsname\pcind%
-%
-%store and wrap (do syntax highlighting) argument 
 \renewcommand{\@pc at thecontent}{\@pc at and@wrap at start\@pc at syntaxhighlight{#2}\@pc at and@wrap at end}%
-%
-%take care of counters
 \stepcounter{@pc at global@pc at cnt}%
 \setcounter{pclinenumber}{\@pseudocodelnstart}%
 \setcounter{pcrlinenumber}{\@pseudocodelnstartright}%
@@ -883,58 +928,57 @@
 \setlength{\@pc at alt@minipage at length}{0pt}%
 \setcounter{@pclinenumbertmp}{\value{pclinenumber}}%
 \setcounter{@pcrlinenumbertmp}{\value{pcrlinenumber}}%
-%reset column counter
 \setcounter{pccolumncounter}{2}%
-%
-% vertical space
 \vspace{\@pseudocodeyshift}%
-%\setlength{\abovedisplayskip}{0pt}%
-%\setlength{\belowdisplayskip}{0pt}%
-%\setlength{\abovedisplayshortskip}{0pt}%
-%\setlength{\belowdisplayshortskip}{0pt}%
-%
-%
-% line magic
 \ifthenelse{\value{@pc at global@pc at nestcnt}=1}{%
 \let\@pc at halign\halign%
 \newenvironment{pcmbox}{\let\halign\@pc at halign}{}%
 \def\halign{%
-\renewcommand{\label}[1]{\ifmeasuring@\else\pc at original@label{####1}\fi}%
+\renewcommand{\label}[1]{\ifmeasuring@\else\@pc at original@label{####1}\fi}%
 \let\@pc at lb\\%
 \renewcommandx*{\\}[2][1=,2=]{\@pc at modeend\@pc at and\@pseudocodecodeatendline \ifthenelse{\equal{####1}{}}{\@pc at lb}{\@pc at lb[####1]}####2 \@pc at beginnewline}%
 \def\pclb{\let\\\@pc at lb\relax\@pc at modeend\\}%
 \@pc at halign}%
 }{}%
-%
-%align column separation
 \renewcommand*{\minalignsep}{\@pseudocodecolsep}%
-%
-% if no width is set compute width and store in circuitlength
+\edef\@pc at org@skiplnmarker{\@pc at skiplnmarker}%
 \ifthenelse{\equal{\@pseudocodewidth}{}}{%
-% compute length of pseudocode
 \ifthenelse{\value{@pcsubprogstep}=0}{%
-\@settowidthofalign{\@pc at minipage@length}{\@pc at thecontent}%
+\@pc at settowidthofalign{\@pc at minipage@length}{\@pc at thecontent}%
 }{%
-\@settowidthofaligned{\@pc at minipage@length}{\@pc at thecontent}%	
+\@pc at settowidthofaligned{\@pc at minipage@length}{\@pc at thecontent}% 
 }%
-%compute length of header
-\addtolength{\@pc at alt@minipage at length}{\widthof{\@pseudocodehead}}%
-% use header length if longer and add some points for good measure
+\ifthenelse{\equal{\@withingame}{true}}%
+{\ifthenelse{\equal{\@pc at secondheader}{true}}%
+  {\addtolength{\@pc at alt@minipage at length}{\widthof{x\ensuremath{\@pc at gametitle[1]\@pc at gametitle[1]}}}}
+  {\addtolength{\@pc at alt@minipage at length}{\widthof{\ensuremath{\@pc at gametitle[1]}}}}}%
+{\addtolength{\@pc at alt@minipage at length}{\widthof{\@pseudocodehead}}}%
 \ifdim\@pc at alt@minipage at length>\@pc at minipage@length%
 \setlength{\@pc at minipage@length}{\@pc at alt@minipage at length}%
 \fi%
 \addtolength{\@pc at minipage@length}{\@pseudocodeaddtolength}%
 }{\addtolength{\@pc at minipage@length}{\@pseudocodewidth}}%
-% reset counter
 \setcounter{pclinenumber}{\value{@pclinenumbertmp}}%
 \setcounter{pcrlinenumber}{\value{@pcrlinenumbertmp}}%
 \setcounter{@pc at indentationlevel}{0}%
-% begin actual output
-%
-%
-%do the actual mini page
-\hspace{\@pseudocodexshift}%
-\begin{minipage}[\@pseudocodeminipagealign]{\@pc at minipage@length}%
+\edef\@pc at skiplnmarker{\@pc at org@skiplnmarker}%
+\hspace{\pcbeforeskip}\hspace{\@pseudocodexshift}%
+\ifthenelse{\equal{\@pseudocodeminipagealign}{t}}{%
+\raisebox{\dimexpr\ht\strutbox-\height}{\@pc at pseudocodeminipage{t}}%
+}{%
+\@pc at pseudocodeminipage{\@pseudocodeminipagealign}%
+}%
+\hspace{\pcafterskip}%
+\@pc at releaseremember%
+\addtocounter{@pc at global@pc at nestcnt}{-1}%
+\endgroup%
+\ifthenelse{\equal{\@withinspaces}{true}}{\end at pc@withspaces}{}%
+\endgroup%
+\@pc at stackspace@forpseudocode%
+}
+
+\newcommand{\@pc at pseudocodeminipage}[1]{%
+\begin{minipage}[#1]{\@pc at minipage@length}%
 \ifthenelse{\value{@pcsubprogstep}=0}{%
 \pc at display@pseudocode{\@pseudocodehead}{\@pc at thecontent}%
 }{% if sub procedure
@@ -941,48 +985,40 @@
 \pc at display@subcode{\@pseudocodehead}{\@pc at thecontent}%
 }%
 \end{minipage}%
-\hspace{\afterpcskip}%
-% tikz usage
-\@pc at releaseremember%
-\addtocounter{@pc at global@pc at nestcnt}{-1}%
-\endgroup%
-% close spacing and potentially a single group generated by the space tester
-\ifthenelse{\equal{\@withinspaces}{true}}{\end at withspaces}{}%
-\endgroup%
 }
 
-\newcommand{\@pc at gameheader}[2]{%
+\newcommand{\@pc at display@gameheader}[1]{%
 \tikz{\gdef\i{\thepcgamecounter}%
-\node[anchor=base,#2,inner sep=0.05em,outer sep=0] (gamenode\i) {#1\vphantom{$\sum^A_{A_b}$}}; 
+\node[anchor=base,text depth=0pt, inner sep=0.05em,outer sep=0pt] (gamenode\i) {#1};
 \ifthenelse{\equal{\@withinbxgame}{true}}
-  {\node[draw,anchor=base, above=0.1cm of gamenode\i] (bgamenode\i) {\@bxgameheader\vphantom{$\sum^A_{A_b}$}};}
+  {\node[draw,anchor=base, above=2ex of gamenode\i] (bgamenode\i) {\@bxgameheader};}
   {}%
 }%
 }
 
 \let\pclb\relax
-%
 \newcommand{\pc at display@pseudocode}[2]{%
-\ifthenelse{\equal{#1}{}}{\vspace{-1\baselineskip}\@pseudocodecodesize}{%
-\ifthenelse{\equal{\@withingame}{true}}{%
-\@pc at gameheader{#1}{}\ifthenelse{\equal{\@pc at secondheader}{true}}{\addtocounter{pcgamecounter}{1}\@pc at gameheader{#1}{draw}}{}%
-\vspace{0.2em}%
-}{#1\vphantom{$\sum^A_{A_b}$}}%
-\vspace{\@pseudocodeheadlinesep}\hrule\vspace{\@pseudocodebodylinesep}\@pseudocodecodesize}%
+\ifthenelse{\equal{#1}{}}{\vspace{-\baselineskip}\@pseudocodecodesize{}}{%
+\ifthenelse{\equal{\@withingame}{true}}
+{\ifthenelse{\equal{\@pc at secondheader}{true}}
+ {\@pc at display@gameheader{#1}\addtocounter{pcgamecounter}{1}\fboxsep=1pt\fbox{\vphantom{#1}\@pc at display@gameheader{#1}}}
+ {\@pc at display@gameheader{#1}}}
+{#1}%
+\@pc at headheightskip\vspace{\pcheadlinesep}\vspace{\@pseudocodeheadlinesep}\@pseudocodeheadlinecmd%
+\vspace{-\baselineskip}\vspace{\pcbodylinesep}\vspace{\@pseudocodebodylinesep}\@pseudocodecodesize}%
 \begin{flalign*}#2\end{flalign*}%
 }
 
-
 \newcommand{\pc at display@subcode}[2]{%
 \begingroup%
-\ifthenelse{\equal{#1}{}}{}{#1\vphantom{$\sum^A_{A_b}$} %
-\vspace{\@pseudocodeheadlinesep}\hrule \vspace{\baselineskip}\vspace{\@pseudocodebodylinesep}}%
+\ifthenelse{\equal{#1}{}}{}{#1\@pc at headheightskip%
+\vspace{\pcheadlinesep}\vspace{\@pseudocodeheadlinesep}\@pseudocodeheadlinecmd{}%
+\vspace{\pcbodylinesep}\vspace{\@pseudocodebodylinesep}}%
 \@pseudocodesubcodesize%
 $\begin{aligned}#2\end{aligned}$%
 \endgroup%
 }
 
-
 \newcommand{\@pc at gettikzwidth}[2]{ % #1 = width, #2 = height
  \pgfextractx{\@tempdima}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}
  {\pgfpointanchor{current bounding box}{north east}}}
@@ -992,9 +1028,265 @@
  \global#2=\@tempdima
 }
 
+\def\@pseudocodeB#1#2[#3]#4{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1#4},#2,#3]}
+\def\@pseudocodeC#1#2#3{\setkeys*{pcspace}{#2}\@pseudocode[head={#1#3},#2]}
+\def\@pseudocodeE#1#2[#3]{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1},#2,#3]}
+\def\@pseudocodeF#1#2{\setkeys*{pcspace}{#2}\@pseudocode[head={#1},#2]}
+\newcommand*{\@pc at createproc@headmode}{text}
+\newcommand{\createprocedurecommand}[4]{
+\expandafter\gdef\csname #1\endcsname{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+#2%
+\@ifnextchar[%]
+  {\@pseudocodeB{#3}{#4}}
+  {\@pseudocodeC{#3}{#4}}%
+}%
+}
+\newcommand{\createpseudocodecommand}[4]{
+\expandafter\gdef\csname #1\endcsname{%
+\begingroup%
+\renewcommand{\@withinspaces}{false}%
+#2%
+\@ifnextchar[%]
+  {\@pseudocodeE{#3}{#4}}
+  {\@pseudocodeF{#3}{#4}}%
+}%
+}
+\newcommand{\createpseudocodeblock}[5]{
+\createpseudocodecommand{#1 at pc}{#3}{#4}{#5}
+\expandafter\gdef\csname #1\endcsname{%
+\@ifnextchar[%]
+  {\csname #1@@\endcsname}
+  {\csname #1@\endcsname}
+}%
+\expandafter\gdef\csname #1@\endcsname##1{%
+\begin{pchstack}[#2]
+\csname #1 at pc\endcsname{##1}
+\end{pchstack}
+}
+\expandafter\gdef\csname #1@@\endcsname[##1]##2{%
+\begin{pchstack}[#2]
+\csname #1 at pc\endcsname[##1]{##2}
+\end{pchstack}
+}
+}
+\newcommand{\createprocedureblock}[5]{
+\createprocedurecommand{#1 at pc}{#3}{#4}{#5}
+\expandafter\gdef\csname #1\endcsname{%
+\@ifnextchar[%]
+{\csname #1@@\endcsname}
+{\csname #1@\endcsname}
+}%
+\expandafter\gdef\csname #1@\endcsname##1##2{%
+\begin{pchstack}[#2]
+\csname #1 at pc\endcsname{##1}{##2}
+\end{pchstack}
+}
+\expandafter\gdef\csname #1@@\endcsname[##1]##2##3{%
+\begin{pchstack}[#2]
+\csname #1 at pc\endcsname[##1]{##2}{##3}
+\end{pchstack}
+}
+}
+\createprocedurecommand{procedure}{}{}{}
+\createpseudocodeblock{pseudocodeblock}{center}{}{}{}
+\createprocedureblock{procedureblock}{center}{}{}{}
 
-%%%%%%%%%%%%%%%%%%%
-% remember pictues
+\newcounter{@pcsubprogcnt1}
+\newcounter{@pcrsubprogcnt1}
+\newcounter{@pcsubprogcnt2}
+\newcounter{@pcrsubprogcnt2}
+\newcounter{@pcsubprogcnt3}
+\newcounter{@pcrsubprogcnt3}
+\newcounter{@pcsubprogcnt4}
+\newcounter{@pcrsubprogcnt4}
+\newcounter{@pcsubprogcnt5}
+\newcounter{@pcrsubprogcnt5}
+\newcounter{@pcsubprogcnt6}
+\newcounter{@pcrsubprogcnt6}
+\newcounter{@pcsubprogcnt7}
+\newcounter{@pcrsubprogcnt7}
+\newcounter{@pcsubprogcnt8}
+\newcounter{@pcrsubprogcnt8}
+\newcounter{@pcsubprogcnt9}
+\newcounter{@pcrsubprogcnt9}
+\newcounter{@pcsubprogstep}
+
+\newenvironment{subprocedure}{%
+\addtocounter{@pcsubprogstep}{1}%
+\setcounter{@pcsubprogcnt\the at pcsubprogstep}{\value{pclinenumber}}%
+\setcounter{@pcrsubprogcnt\the at pcsubprogstep}{\value{pcrlinenumber}}%
+}{%
+\setcounter{pclinenumber}{\value{@pcsubprogcnt\the at pcsubprogstep}}%
+\setcounter{pcrlinenumber}{\value{@pcrsubprogcnt\the at pcsubprogstep}}%
+\addtocounter{@pcsubprogstep}{-1}}
+
+
+\newcommand{\pcshortmessageoffset}{0.5cm}
+\newcommand{\pcdefaultmessagelength}{3.5cm}
+\newcommand{\pcdefaultlongmessagelength}{6cm}
+\newcommand{\pcbeforemessageskip}{0pt}
+\newcommand{\pcaftermessageskip}{10pt}
+\newlength{\pcmessagearrow}
+
+\newcommand*\@pcsendmessagelength{\pcdefaultmessagelength}
+\newcommand*\@pcsendmessagecol{}
+\newcommand*\@pcsendmessagewidth{}
+\newcommand*\@pcsendmessagestyle{}
+\newcommand*\@pcsendmessagetop{}
+\newcommand*\@pcsendmessagebottom{}
+\newcommand*\@pcsendmessageright{}
+\newcommand*\@pcsendmessageleft{}
+\newcommand*\@pcsendmessagetopname{t}
+\newcommand*\@pcsendmessagebottomname{b}
+\newcommand*\@pcsendmessagerightname{r}
+\newcommand*\@pcsendmessageleftname{l}
+\newcommand*\@pcsendmessagetopstyle{}
+\newcommand*\@pcsendmessagebottomstyle{}
+\newcommand*\@pcsendmessagerightstyle{}
+\newcommand*\@pcsendmessageleftstyle{}
+\newcommand*\@pcsendmessagebeforeskip{\pcbeforemessageskip}
+\newcommand*\@pcsendmessageafterskip{\pcaftermessageskip}
+
+\define at key{pcsendmessage}{centercol}[]{\renewcommand*\@pcsendmessagecol{#1}}
+\define at key{pcsendmessage}{width}[]{\renewcommand*\@pcsendmessagewidth{#1}}
+\define at key{pcsendmessage}{style}[]{\renewcommand*\@pcsendmessagestyle{#1}}
+\define at key{pcsendmessage}{length}[]{\renewcommand*\@pcsendmessagelength{#1}}
+\define at key{pcsendmessage}{top}[]{\renewcommand*\@pcsendmessagetop{#1}}
+\define at key{pcsendmessage}{bottom}[]{\renewcommand*\@pcsendmessagebottom{#1}}
+\define at key{pcsendmessage}{right}[]{\renewcommand*\@pcsendmessageright{#1}}
+\define at key{pcsendmessage}{left}[]{\renewcommand*\@pcsendmessageleft{#1}}
+\define at key{pcsendmessage}{topname}[]{\renewcommand*\@pcsendmessagetopname{#1}}
+\define at key{pcsendmessage}{bottomname}[]{\renewcommand*\@pcsendmessagebottomname{#1}}
+\define at key{pcsendmessage}{rightname}[]{\renewcommand*\@pcsendmessagerightname{#1}}
+\define at key{pcsendmessage}{leftname}[]{\renewcommand*\@pcsendmessageleftname{#1}}
+\define at key{pcsendmessage}{topstyle}[]{\renewcommand*\@pcsendmessagetopstyle{#1}}
+\define at key{pcsendmessage}{bottomstyle}[]{\renewcommand*\@pcsendmessagebottomstyle{#1}}
+\define at key{pcsendmessage}{rightstyle}[]{\renewcommand*\@pcsendmessagerightstyle{#1}}
+\define at key{pcsendmessage}{leftstyle}[]{\renewcommand*\@pcsendmessageleftstyle{#1}}
+\define at key{pcsendmessage}{beforeskip}[]{\renewcommand*\@pcsendmessagebeforeskip{#1}}
+\define at key{pcsendmessage}{afterskip}[]{\renewcommand*\@pcsendmessageafterskip{#1}}
+
+\newcommand*\@pcsendmessagealignedtop{false}
+\define at key{pcsendmessage}{topaligned}[true]{\renewcommand*\@pcsendmessagealignedtop{#1}}
+\newcommand*\@pcsendmessagealignedbottom{false}
+\define at key{pcsendmessage}{bottomaligned}[true]{\renewcommand*\@pcsendmessagealignedbottom{#1}}
+\newcommand*\@pcsendmessagealignedleft{false}
+\define at key{pcsendmessage}{leftaligned}[true]{\renewcommand*\@pcsendmessagealignedleft{#1}}
+\newcommand*\@pcsendmessagealignedright{false}
+\define at key{pcsendmessage}{rightaligned}[true]{\renewcommand*\@pcsendmessagealignedright{#1}}
+
+\newcommand{\@pc at centerincol}[2]{%
+\ifmeasuring@%
+#2%
+\else%
+\makebox[\ifcase\expandafter #1\maxcolumn at widths\fi]{$\displaystyle#2$}%
+\fi%
+}
+
+\newcommand{\centerincol}[1]{\@pc at centerincol{\thepccolumncounter}{#1}}
+
+\newcommand{\@do at sendmessage}[1]{%
+\ifthenelse{\equal{\@pcsendmessagecol}{}}{%
+\ifthenelse{\equal{\@pcsendmessagewidth}{}}{#1}{% we have some width
+\makebox[\@pcsendmessagewidth]{$\displaystyle#1$}%
+}}{%we know the column to center on
+\@pc at centerincol{\@pcsendmessagecol}{#1}%
+}%
+}
+
+\newcommand*{\sendmessage}[2]{%
+\begingroup\setkeys{pcsendmessage}{#2}%
+\tikzset{PCSENDMSG-PATH-STYLE/.style/.expand once=\@pcsendmessagestyle}%
+\tikzset{PCSENDMSG-TOP-STYLE/.style/.expand once=\@pcsendmessagetopstyle}%
+\tikzset{PCSENDMSG-BOTTOM-STYLE/.style/.expand once=\@pcsendmessagebottomstyle}%
+\tikzset{PCSENDMSG-LEFT-STYLE/.style/.expand once=\@pcsendmessageleftstyle}%
+\tikzset{PCSENDMSG-RIGHT-STYLE/.style/.expand once=\@pcsendmessagerightstyle}%
+\ifthenelse{\equal{\@pcsendmessagealignedtop}{true}}
+{\ifthenelse{\equal{\@pcsendmessagetop}{}}
+{\let\@pc at fin@sendmessagetop\@pcsendmessagetop}%
+{\newcommand{\@pc at fin@sendmessagetop}{\let\halign\@pc at halign$\begin{aligned}\@pcsendmessagetop\end{aligned}$}}}
+{\let\@pc at fin@sendmessagetop\@pcsendmessagetop}%
+\ifthenelse{\equal{\@pcsendmessagealignedbottom}{true}}
+{\ifthenelse{\equal{\@pcsendmessagebottom}{}}
+{\let\@pc at fin@sendmessagebottom\@pcsendmessagebottom}%
+{\newcommand{\@pc at fin@sendmessagebottom}{\let\halign\@pc at halign$\begin{aligned}\@pcsendmessagebottom\end{aligned}$}}}
+{\let\@pc at fin@sendmessagebottom\@pcsendmessagebottom}%
+\ifthenelse{\equal{\@pcsendmessagealignedright}{true}}
+{\ifthenelse{\equal{\@pcsendmessageright}{}}
+{\let\@pc at fin@sendmessageright\@pcsendmessageright}
+{\newcommand{\@pc at finsendmessageright}{\let\halign\@pc at halign$\begin{aligned}\@pcsendmessageright\end{aligned}$}}}
+{\let\@pc at fin@sendmessageright\@pcsendmessageright}%
+\ifthenelse{\equal{\@pcsendmessagealignedleft}{true}}
+{\ifthenelse{\equal{\@pcsendmessageleft}{}}
+{\let\@pc at fin@sendmessageleft\@pcsendmessageleft}
+{\newcommand{\@pc at fin@sendmessageleft}{\let\halign\@pc at halign$\begin{aligned}\@pcsendmessageleft\end{aligned}$}}}
+{\let\@pc at fin@sendmessageleft\@pcsendmessageleft}%
+\addtocounter{@pcsubprogstep}{1}%
+\hspace{\@pcsendmessagebeforeskip}%
+\begin{varwidth}{\linewidth}
+\@do at sendmessage{
+\begin{tikzpicture}%
+ \node[PCSENDMSG-LEFT-STYLE] (\@pcsendmessageleftname) {\@pc at fin@sendmessageleft};
+ \node[right=\@pcsendmessagelength of \@pcsendmessageleftname,PCSENDMSG-RIGHT-STYLE] (\@pcsendmessagerightname) {\@pc at fin@sendmessageright};
+ \path[#1,PCSENDMSG-PATH-STYLE] (\@pcsendmessageleftname) edge[] node[above,PCSENDMSG-TOP-STYLE] (\@pcsendmessagetopname) {\@pc at fin@sendmessagetop} node[below,PCSENDMSG-BOTTOM-STYLE] (\@pcsendmessagebottomname) {\@pc at fin@sendmessagebottom} (\@pcsendmessagerightname);
+\end{tikzpicture}%
+}%
+\end{varwidth}
+\addtocounter{@pcsubprogstep}{-1}%
+\hspace{\@pcsendmessageafterskip}%
+\endgroup%
+}
+
+\WithSuffix\newcommand\sendmessage*[2]{%
+\sendmessage{#1}{topaligned,leftaligned,bottomaligned,rightaligned,#2}%
+}
+
+\newcommandx*{\sendmessageright}[2][1=->]{%
+\sendmessage{#1}{#2}%
+}
+
+\newcommandx*{\sendmessageleft}[2][1=<-]{%
+\sendmessage{#1}{#2}%
+}
+
+\WithSuffix\newcommand\sendmessageleft*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{<-}{length=#1}%
+\endgroup%
+}
+
+\WithSuffix\newcommand\sendmessageright*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{->}{length=#1}%
+\endgroup%
+}
+
+\WithSuffix\newcommand\sendmessagerightleft*[2][\pcdefaultmessagelength]{%
+\begingroup%
+\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
+\sendmessage{<->}{length=#1}%
+\endgroup%
+}
+
+\DeclareExpandableDocumentCommand{\sendmessagerightx}{O{\pcdefaultlongmessagelength}mO{}m}{%
+\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xrightarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
+}
+
+\DeclareExpandableDocumentCommand{\sendmessageleftx}{O{\pcdefaultlongmessagelength}mO{}m}{%
+\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xleftarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
+}
+
+\DeclareExpandableDocumentCommand{\pcintertext}{O{}m}{\intertext{%
+\ifthenelse{\equal{#1}{center}}{\makebox[\linewidth][c]{#2}}{}%
+\ifthenelse{\equal{#1}{dotted}}{\dotfill#2\dotfill}{}%
+\ifthenelse{\equal{#1}{}}{#2}{}%
+}\@pc at beginnewline}
+
+
 \newcounter{@pc at remember}
 
 \newcommand{\@pc at ensureremember}{%
@@ -1006,9 +1298,6 @@
 \ifthenelse{\value{@pc at remember}=0}{\tikzstyle{every picture}-=[remember picture]}{}%
 }
 
-
-%%%%%%%%%%%%%%%%%%%
-% pcimage
 \newenvironment{pcimage}{%
 \begingroup\@pc at ensureremember%
 }{%
@@ -1039,18 +1328,15 @@
 \end{tikzpicture}}
 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%
-% Reductions
 \newcommand{\@bb at lastbox}{}
 \newcommand{\@bb at lastoracle}{}
 \newcommand{\@bb at lastchallenger}{}
 
+\newlength{\@bb at message@voffset}
+\newlength{\@bb at query@voffset}
+\newlength{\@bb at oraclequery@voffset}
+\newlength{\@bb at challengerquery@voffset}
 
-\newlength{\@bb at message@hoffset}
-\newlength{\@bb at query@hoffset}
-\newlength{\@bb at oraclequery@hoffset}
-\newlength{\@bb at challengerquery@hoffset}
-
 \newcounter{@bb at oracle@cnt}
 \newcounter{@bb at oracle@nestcnt}
 \newcounter{@bb at challenger@cnt}
@@ -1062,26 +1348,34 @@
 \newcommand{\bbrchallengernodenameprefix}{challenger-}
 \newcommand{\bbrenvnodenameprefix}{env-}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Black Box Reduction Environment
-\newenvironmentx{bbrenv}[3][1=0pt,3=0pt]{%
+\newcommand*\@pc at bbrenvaboveskip{0pt}
+\define at key{pcbbrenv}{aboveskip}[0pt]{\renewcommand*\@pc at bbrenvaboveskip{#1}}
+\newcommand*\@pc at bbrenvbelowskip{0pt}
+\define at key{pcbbrenv}{belowskip}[0pt]{\renewcommand*\@pc at bbrenvbelowskip{#1}}
+
+\newcommand*\@pc at bbrenv@argstring{}
+\def\@pc at bbrenv@remfinalequals#1=#2=\relax{\renewcommand*\@pc at bbrenv@argstring{#1=#2}}
+\def\@pc at bbrenv@legacyargcheck#1=#2\relax{%
+\ifthenelse{\equal{#2}{}}
+{\PackageWarning{cryptocode}{Deprecated option for bbrenv. Please use key value list as first parameter with keys aboveskip and/or belowskip.}%
+\renewcommand*\@pc at bbrenv@argstring{aboveskip=#1}}
+{\@pc at bbrenv@remfinalequals#1=#2\relax}%
+}
+\providecommand{\bbrfirstmessageoffset}{1ex}
+\newenvironmentx{bbrenv}[3][1={aboveskip=0pt,belowskip=0pt},3=0pt]{%
 \addtocounter{@bb at env@nestcnt}{1}%
 \renewcommand{\@bb at lastbox}{#2}%
-%
-% reset lengths
-\@pc at globalsetlength{\@bb at message@hoffset}{0pt}%
-\@pc at globalsetlength{\@bb at query@hoffset}{0pt}%
-\@pc at globalsetlength{\@bb at oraclequery@hoffset}{0pt}%
-\@pc at globalsetlength{\@bb at challengerquery@hoffset}{0pt}%
-%
-%reset oracle counter and oracle query offset
+\@pc at bbrenv@legacyargcheck#1=\relax%
+\@expandedsetkeys{pcbbrenv}{}{belowskip=#3}{\@pc at bbrenv@argstring}{}%
+\@pc at globalsetlength{\@bb at message@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at query@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at oraclequery@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at challengerquery@voffset}{\bbrfirstmessageoffset}%
 \ifthenelse{\value{@bb at oracle@nestcnt}=0}
  {\setcounter{@bb at oracle@cnt}{0}}{}%
 \ifthenelse{\value{@bb at challenger@nestcnt}=0}
   {\setcounter{@bb at challenger@cnt}{0}}{}%
-%
-\def\@bbendskip{#3}%
-\vspace{#1}%
+\vspace{\@pc at bbrenvaboveskip}%
 \ifthenelse{\value{@bb at env@nestcnt}=1}
  {\@pc at ensureremember%
 \begin{tikzpicture}
@@ -1091,18 +1385,15 @@
 {\end{tikzpicture}%
 \@pc at releaseremember%
 }{\egroup}%
-\vspace{\@bbendskip}%
+\vspace{\@pc at bbrenvbelowskip}%
 \addtocounter{@bb at env@nestcnt}{-1}%
-% reset lengths
-\@pc at globalsetlength{\@bb at message@hoffset}{0pt}%
-\@pc at globalsetlength{\@bb at query@hoffset}{0pt}%
-\@pc at globalsetlength{\@bb at oraclequery@hoffset}{0pt}%
-\@pc at globalsetlength{\@bb at challengerquery@hoffset}{0pt}%
+\@pc at globalsetlength{\@bb at message@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at query@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at oraclequery@voffset}{\bbrfirstmessageoffset}%
+\@pc at globalsetlength{\@bb at challengerquery@voffset}{\bbrfirstmessageoffset}%
 }
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% black box reduction box
-% option keys
+
 \newcommand*\bbrboxname{}
 \newcommand*\bbrboxnamepos{right}
 \newcommand*\bbrboxnamestyle{}
@@ -1126,47 +1417,45 @@
 \define at key{bbrbox}{xshift}[]{\renewcommand*\bbrboxxshift{#1}}
 \define at key{bbrbox}{yshift}[]{\renewcommand*\bbrboxyshift{#1}}
 
-
 \NewEnviron{bbrbox}[1][]{%
 \setkeys{bbrbox}{#1}%
 
 \ifthenelse{\equal{\bbrboxnamepos}{center}}
- {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north,anchor=north}}{} 
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north,anchor=north}}{}
 \ifthenelse{\equal{\bbrboxnamepos}{left}}
- {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north west,anchor=north west}}{} 
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb at lastbox.north west,anchor=north west}}{}
 \ifthenelse{\equal{\bbrboxnamepos}{top right}}
  {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north east,anchor=south east}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{}
 \ifthenelse{\equal{\bbrboxnamepos}{top center}}
- {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north,anchor=south}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} 
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north,anchor=south}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{}
 \ifthenelse{\equal{\bbrboxnamepos}{top left}}
- {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north west,anchor=south west}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{} 
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb at lastbox.north west,anchor=south west}\renewcommand{\@bbrboxnameposoffset}{below left=0cm of phantomname.north west}}{}
 \ifthenelse{\equal{\bbrboxnamepos}{middle}}
- {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=south}}{} 
+ {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=south}}{}
 \ifthenelse{\equal{\bbrboxnamepos}{bottom}}
- {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=north}}{} 
+ {\renewcommand{\@bbrboxnamepos}{above=0.5ex of \@bb at lastbox.base,anchor=north}}{}
 
-
 \tikzset{BBRBOXSTYLE/.style/.expand once=\bbrboxstyle}%
 \tikzset{BBRBOXNAMEPOS/.style/.expand once=\@bbrboxnamepos}%
 \tikzset{BBRBOXNAMESTYLE/.style/.expand once=\bbrboxnamestyle}%
 \tikzset{BBRBOXNAMEPOSOFFSET/.style/.expand once=\@bbrboxnameposoffset}%
 
-\node[inner sep=0pt,outer sep=0pt] (\@bb at lastbox-tmpouter) {};
+\coordinate[inner sep=0pt,outer sep=0pt] (\@bb at lastbox-tmpouter) {};
+\node at (\@bb at lastbox-tmpouter) {}; %this empty node seems needed to get the xyshift right.
 \node[inner sep=.3333em,anchor=north,BBRBOXSTYLE,minimum height=\bbrboxminheight,below right=\bbrboxyshift and \bbrboxxshift of \@bb at lastbox-tmpouter] (\@bb at lastbox)  \bgroup
-	\tikz{
-		\node[inner sep=0pt,outer sep=0pt,minimum height=0cm] (phantomname) {}; %minimum width
-		\node[BBRBOXNAMEPOSOFFSET,minimum height=0cm] (\@bb at lastbox-inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}};
-		\ifthenelse{\equal{\bbrboxafterskip}{}}{}{
-			\node[below=0cm of \@bb at lastbox-inner,minimum height=\bbrboxafterskip] {};
-		}
-		\node[inner sep=0pt,outer sep=0pt,at=(\@bb at lastbox-inner.south west),minimum height=0cm] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width
-	}
+\tikz{
+\node[inner sep=0pt,outer sep=0pt,minimum height=0cm] (phantomname) {}; %minimum width
+\node[BBRBOXNAMEPOSOFFSET,minimum height=0cm] (\@bb at lastbox-inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}};
+\ifthenelse{\equal{\bbrboxafterskip}{}}{}{
+\node[below=0cm of \@bb at lastbox-inner,minimum height=\bbrboxafterskip] {};
+}
+\node[inner sep=0pt,outer sep=0pt,at=(\@bb at lastbox-inner.south west),minimum height=0cm] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width
+}
 \egroup;
 \ifthenelse{\equal{\bbrboxnamepos}{none}}
 {}{\node[BBRBOXNAMEPOS,BBRBOXNAMESTYLE, inner sep=0.2ex, outer sep=0pt, overlay] () {\bbrboxname};}
 }
 
-
 \newcommand*\bbroraclevdistance{\baselineskip}
 \newcommand*\bbroraclehdistance{1.5cm}
 \define at key{bbroracle}{distance}[]{\renewcommand*\bbroraclehdistance{#1}}
@@ -1173,40 +1462,35 @@
 \define at key{bbroracle}{hdistance}[]{\renewcommand*\bbroraclehdistance{#1}}
 \define at key{bbroracle}{vdistance}[]{\renewcommand*\bbroraclevdistance{#1}}
 
-
-% ORACLES
 \newenvironmentx{bbroracle}[2][2=]{%
-	\begingroup
-	\setkeys{bbroracle}{#2}
-	%add to nesting cout
-	\addtocounter{@bb at oracle@nestcnt}{1}
-	%if first oracle, then put it to the right, else stack them vertically
-	\addtocounter{@bb at oracle@cnt}{1}
-	\ifthenelse{\value{@bb at oracle@cnt}=1}{
-	\setlength{\@bb at tmplength@b}{\bbroraclevdistance-\baselineskip}
-	\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
-	}{
-% compute distance of top of last box to bottom of last oracle
-	\coordinate (@bbtmpcoord) at (\@bb at lastbox.north east);
-	\path (@bbtmpcoord);
-	\pgfgetlastxy{\XCoord}{\YCoordA}
-	\coordinate (@bbtmpcoord) at (\bbroraclenodenameprefix \@bb at lastoracle.south west);
-	\path (@bbtmpcoord);
-	\pgfgetlastxy{\XCoord}{\YCoordB}
-	\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB+\bbroraclevdistance}
-	\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
-	}
-	\global\def\@bb at lastoracle{#1}
-	\begin{bbrenv}{#1}
+\begingroup
+\setkeys{bbroracle}{#2}
+\gdef\@bbr at first@oraclequery{true} 
+\addtocounter{@bb at oracle@nestcnt}{1}
+\addtocounter{@bb at oracle@cnt}{1}
+\ifthenelse{\value{@bb at oracle@cnt}=1}{
+\setlength{\@bb at tmplength@b}{\bbroraclevdistance-\baselineskip}
+\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
 }{
-	\end{bbrenv}
-	\egroup;
+\coordinate (@bbtmpcoord) at (\@bb at lastbox.north east);
+\path (@bbtmpcoord);
+\pgfgetlastxy{\XCoord}{\YCoordA}
+\coordinate (@bbtmpcoord) at (\bbroraclenodenameprefix \@bb at lastoracle.south west);
+\path (@bbtmpcoord);
+\pgfgetlastxy{\XCoord}{\YCoordB}
+\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB+\bbroraclevdistance}
+\node[inner sep=0pt,below right=\@bb at tmplength@b and \bbroraclehdistance of \@bb at lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
+}
+\global\def\@bb at lastoracle{#1}
+\begin{bbrenv}{#1}
+}{
+\end{bbrenv}
+\egroup;
 
-	\addtocounter{@bb at oracle@nestcnt}{-1}
-	\endgroup
+\addtocounter{@bb at oracle@nestcnt}{-1}
+\endgroup
 }
 
-
 \newcommand*\bbrchallengerhdistance{1.5cm}
 \newcommand*\bbrchallengervdistance{\baselineskip}
 \define at key{bbrchallenger}{distance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
@@ -1213,18 +1497,15 @@
 \define at key{bbrchallenger}{hdistance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
 \define at key{bbrchallenger}{vdistance}[]{\renewcommand*\bbrchallengervdistance{#1}}
 
-
-% Challenger
 \newenvironmentx{bbrchallenger}[2][2=]{%
 \begingroup%
 \setkeys{bbrchallenger}{#2}%
-%add to nesting cout
+\gdef\@bbr at first@challengerquery{true}%
 \addtocounter{@bb at challenger@nestcnt}{1}%
-%if first oracle, then put it to the right, else stack them vertically
 \addtocounter{@bb at challenger@cnt}{1}%
 \ifthenelse{\value{@bb at challenger@cnt}=1}{%
 \setlength{\@bb at tmplength@b}{\bbrchallengervdistance-\baselineskip}%
-\node[inner sep=0pt,below left=\@bb at tmplength@b and \bbrchallengerhdistance of \@bb at lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
+\node[inner sep=0pt,outer sep=0pt,below left=\@bb at tmplength@b and \bbrchallengerhdistance of \@bb at lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
 }{%
 \coordinate (@bbtmpcoord) at (\@bb at lastbox.north west);%
 \path (@bbtmpcoord);%
@@ -1245,7 +1526,6 @@
 \let\msgfrom\bbrchallengerqueryto%
 }
 
-
 \newcommand*\bbrinputlength{0.5cm}
 \newcommand*\bbrinputhoffset{0.5cm}
 \newcommand*\bbrinputbottom{}
@@ -1261,29 +1541,27 @@
 \define at key{bbrinput}{top}[]{\renewcommand*\bbrinputtop{#1}}
 \define at key{bbrinput}{bottom}[]{\renewcommand*\bbrinputbottom{#1}}
 
-
 \newcommand{\@bb at inputsetup}[1]{
-	%load keys	
-	\begingroup % for local keys
+\begingroup % for local keys
 
-	\setkeys{bbrinput}{#1}%
+\setkeys{bbrinput}{#1}%
 
-	\tikzset{BBRINPUT-NODESTYLE/.style/.expand once=\bbrinputedgestyle}%	
-	\tikzset{BBRINPUT-TOPSTYLE/.style/.expand once=\bbrinputtopstyle}%	
-	\tikzset{BBRINPUT-BOTTOMSTYLE/.style/.expand once=\bbrinputbottomstyle}%			
-	\tikzset{BBRINPUT-EDGESTYLE/.style/.expand once=\bbrinputedgestyle}%
+\tikzset{BBRINPUT-NODESTYLE/.style/.expand once=\bbrinputedgestyle}% 
+\tikzset{BBRINPUT-TOPSTYLE/.style/.expand once=\bbrinputtopstyle}% 
+\tikzset{BBRINPUT-BOTTOMSTYLE/.style/.expand once=\bbrinputbottomstyle}% 
+\tikzset{BBRINPUT-EDGESTYLE/.style/.expand once=\bbrinputedgestyle}%
 
 }
 
 \newcommand{\@bb at inputfinalize}{
-	\endgroup
+\endgroup
 }
 
 \newcommandx*{\bbrinput}[2][2=]{%
 \@bb at inputsetup{#2}
 \ifthenelse{\equal{\bbrinputnodename}{}}
-  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-input}}{} 
-  
+  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-input}}{}
+
 \node[overlay,above right={\bbrinputlength} and {\bbrinputhoffset} of \@bb at lastbox.north west, anchor=south,BBRINPUT-NODESTYLE] (\bbrinputnodename) {#1};
 \path[->] (\bbrinputnodename.south)  edge[BBRINPUT-EDGESTYLE] node[above,anchor=east,BBRINPUT-TOPSTYLE] () {\bbrinputtop} node[below,anchor=west,BBRINPUT-BOTTOMSTYLE] () {\bbrinputbottom} (\bbrinputnodename.south|-\@bb at lastbox.north);
 \@bb at inputfinalize
@@ -1292,8 +1570,8 @@
 \newcommandx*{\bbroutput}[2][2=]{%
 \@bb at inputsetup{#2}
 \ifthenelse{\equal{\bbrinputnodename}{}}
-  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-output}}{} 
-  
+  {\renewcommand{\bbrinputnodename}{\@bb at lastbox-output}}{}
+
 \node[overlay,below right={\bbrinputlength} and {\bbrinputhoffset} of \@bb at lastbox.south west, anchor=north] (\bbrinputnodename) {#1};
 \draw[->] (\bbrinputnodename.north|-\@bb at lastbox.south)  -- (\bbrinputnodename.north|-\bbrinputnodename.north);
 \@bb at inputfinalize
@@ -1304,218 +1582,340 @@
 }{%
 \end{tikzpicture}}
 
-%%%%%%%%%%%
-% communication
-%temporary lengths
 \newlength{\@bb at com@tmpoffset}
 \newlength{\@bb at tmplength@b}
-\newcommand{\@bb at firstmessageheight}{0.25\baselineskip}
-\newcommand{\@bb at msglength}{1.25cm}
-\newcommand{\@bb at qrylength}{1.5cm}
 
-%keys
-\newcommand*\bbrcomnsidestyle{}
-\newcommand*\bbrcomtopstyle{}
-\newcommand*\bbrcombottomstyle{}
-\newcommand*\bbrcomside{}
-\newcommand*\bbrcomoside{}
-\newcommand*\bbrcomtop{}
-\newcommand*\bbrcombottom{}
-\newcommand*\bbrcomedgestyle{}
-\newcommand*\bbrcomlength{1.25cm}
-\newcommand*\bbrcomtopname{bbrcomtop}
-\newcommand*\bbrcombottomname{bbrcombottom}
-\newcommand*\bbrcomsidename{bbrcomside}
-\newcommand*\bbrcomosidename{bbrcomoside}
-\newcommand*\bbrcombeforeskip{0pt}
-\newcommand*\bbrcomafterskip{0pt}
-\define at key{bbrcom}{sidestyle}[]{\renewcommand*\bbrcomnsidestyle{#1}}
-\define at key{bbrcom}{topstyle}[]{\renewcommand*\bbrcomtopstyle{#1}}
-\define at key{bbrcom}{bottomstyle}[]{\renewcommand*\bbrcombottomstyle{#1}}
-\define at key{bbrcom}{side}[]{\renewcommand*\bbrcomside{#1}}
-\define at key{bbrcom}{oside}[]{\renewcommand*\bbrcomoside{#1}}
-\define at key{bbrcom}{top}[]{\renewcommand*\bbrcomtop{#1}}
-\define at key{bbrcom}{bottom}[]{\renewcommand*\bbrcombottom{#1}}
-\define at key{bbrcom}{edgestyle}[]{\renewcommand*\bbrcomedgestyle{#1}}
-\define at key{bbrcom}{length}[]{\renewcommand*\bbrcomlength{#1}}
-\define at key{bbrcom}{topname}[]{\renewcommand*\bbrcomtopname{#1}}
-\define at key{bbrcom}{bottomname}[]{\renewcommand*\bbrcombottomname{#1}}
-\define at key{bbrcom}{sidename}[]{\renewcommand*\bbrcomsidename{#1}}
-\define at key{bbrcom}{osidename}[]{\renewcommand*\bbrcomosidename{#1}}
-\define at key{bbrcom}{beforeskip}[]{\renewcommand*\bbrcombeforeskip{#1}}
-\define at key{bbrcom}{afterskip}[]{\renewcommand*\bbrcomafterskip{#1}}
+\newcommand*\@bbrcomsidestyle{}
+\newcommand*\@bbrcomosidestyle{}
+\newcommand*\@bbrcomtopstyle{}
+\newcommand*\@bbrcombottomstyle{}
+\newcommand*\@bbrcomside{}
+\newcommand*\@bbrcomoside{}
+\newcommand*\@bbrcomtop{}
+\newcommand*\@bbrcombottom{}
+\newcommand*\@bbrcomedgestyle{}
+\newcommand*\@bbrcomlength{1.25cm}
+\newcommand*\@bbrcomtopname{bbrcomtop}
+\newcommand*\@bbrcombottomname{bbrcombottom}
+\newcommand*\@bbrcomsidename{bbrcomside}
+\newcommand*\@bbrcomosidename{bbrcomoside}
+\newcommand*\@bbrcombeforeskip{0pt}
+\newcommand*\@bbrcomafterskip{0ex}
+\define at key{bbrcom}{sidestyle}[]{\renewcommand*\@bbrcomsidestyle{#1}}
+\define at key{bbrcom}{osidestyle}[]{\renewcommand*\@bbrcomosidestyle{#1}}
+\define at key{bbrcom}{topstyle}[]{\renewcommand*\@bbrcomtopstyle{#1}}
+\define at key{bbrcom}{bottomstyle}[]{\renewcommand*\@bbrcombottomstyle{#1}}
+\define at key{bbrcom}{side}[]{\renewcommand*\@bbrcomside{#1}}
+\define at key{bbrcom}{oside}[]{\renewcommand*\@bbrcomoside{#1}}
+\define at key{bbrcom}{top}[]{\renewcommand*\@bbrcomtop{#1}}
+\define at key{bbrcom}{bottom}[]{\renewcommand*\@bbrcombottom{#1}}
+\define at key{bbrcom}{edgestyle}[]{\renewcommand*\@bbrcomedgestyle{#1}}
+\define at key{bbrcom}{length}[]{\renewcommand*\@bbrcomlength{#1}}
+\define at key{bbrcom}{topname}[]{\renewcommand*\@bbrcomtopname{#1}}
+\define at key{bbrcom}{bottomname}[]{\renewcommand*\@bbrcombottomname{#1}}
+\define at key{bbrcom}{sidename}[]{\renewcommand*\@bbrcomsidename{#1}}
+\define at key{bbrcom}{osidename}[]{\renewcommand*\@bbrcomosidename{#1}}
+\define at key{bbrcom}{beforeskip}[]{\renewcommand*\@bbrcombeforeskip{#1}}
+\define at key{bbrcom}{aboveskip}[]{\renewcommand*\@bbrcombeforeskip{#1}}
+\define at key{bbrcom}{afterskip}[]{\renewcommand*\@bbrcomafterskip{#1}}
+\define at key{bbrcom}{belowskip}[]{\renewcommand*\@bbrcomafterskip{#1}}
 
-\newcommand*\bbrbasenodestyle{}
-\newcommand*\bbrbasenodename{bbrtmpname}
-\define at key{bbrabase}{nodestyle}[]{\renewcommand*\bbrbasenodestyle{#1}}
-\define at key{bbrabase}{nodename}[]{\renewcommand*\bbrbasenodename{#1}}
+\newcommand*\@bbrcomfixedoffset{}
+\newcommand*\@bbrcomfixedboffset{false}
+\define at key{bbrcom}{fixedoffset}[]{\renewcommand*\@bbrcomfixedoffset{#1}}
+\define at key{bbrcom}{fixedboffset}[]{\renewcommand*\@bbrcomfixedoffset{#1}\renewcommand*\@bbrcomfixedboffset{true}}
+\newcommand*\@bbrbasenodestyle{}
+\newcommand*\@bbrbasenodename{bbrtmpname}
+\define at key{bbrabase}{nodestyle}[]{\renewcommand*\@bbrbasenodestyle{#1}}
+\define at key{bbrabase}{nodename}[]{\renewcommand*\@bbrbasenodename{#1}}
 
+\newcommand*\@bbr at first@msg{true}
+\newcommand*\@bbr at first@query{true}
+\newcommand*\@bbr at first@oraclequery{true}
+\newcommand*\@bbr at first@challengerquery{true}
 
-\newcommand{\@bb at comsetup}[3]{
-	%load keys	
-	\begingroup % for local keys
+\newcommand*\@bbr at intermessage@skip{4ex}
+\newcommand*\@bbr at intermessage@veryshortskip{1ex}
+\newcommand*\@bbr at intermessage@shortskip{1.5ex}
+\newcommand*\@bbr at intermessage@medskip{2.5ex}
+\newcommand*\@bbrcomislast{false}
+\define at key{bbrcom}{islast}[true]{\renewcommand*\@bbrcomislast{#1}}
 
-	\setkeys{bbrcom}{#1}%
+\newcommand*\@bbrcom at check@islast{%
+\ifthenelse{\equal{\@bbrcomislast}{true}}
+{\renewcommand*\@bbrcomfixedoffset{\bbrfirstmessageoffset}\renewcommand*\@bbrcomfixedboffset{true}}
+{}
+}
+\def\@bbr at lastskip{0pt}
+\newcommand{\@bb at comsetup}[4]{
+\edef\@tmp at bbr@isfirst{#4}
+\renewcommand#4{false}
 
-	%set styles
-	\tikzset{BBRCOM-SIDESTYLE/.style/.expand once=\bbrcomnsidestyle}%
-	\tikzset{BBRCOM-TOPSTYLE/.style/.expand once=\bbrcomtopstyle}%
-	\tikzset{BBRCOM-BOTTOMSTYLE/.style/.expand once=\bbrcombottomstyle}%
-	\tikzset{BBRCOM-EDGESTYLE/.style/.expand once=\bbrcomedgestyle}%
+\begingroup % for local keys
 
-	% increase space
-	\ifthenelse{\lengthtest{#2<\@bb at firstmessageheight}}
- 	{#3{\@bb at firstmessageheight}}
-	{
-	  #3{1.25\baselineskip}
-	  \ifthenelse{\equal{\bbrcomtop}{}}{}{#3{0.5\baselineskip}}	
-           }
+\setkeys{bbrcom}{#1}%
 
-	#3{\bbrcombeforeskip}
+\tikzset{BBRCOM-SIDESTYLE/.style/.expand once=\@bbrcomsidestyle}%
+\tikzset{BBRCOM-OSIDESTYLE/.style/.expand once=\@bbrcomosidestyle}%
+\tikzset{BBRCOM-TOPSTYLE/.style/.expand once=\@bbrcomtopstyle}%
+\tikzset{BBRCOM-BOTTOMSTYLE/.style/.expand once=\@bbrcombottomstyle}%
+\tikzset{BBRCOM-EDGESTYLE/.style/.expand once=\@bbrcomedgestyle}%
 
-	\setlength{\@bb at com@tmpoffset}{#2}%
+\@bbrcom at check@islast{}
+
+#3{\@bbrcombeforeskip}
+\ifthenelse{\equal{\@bbrcomfixedoffset}{}}
+{
+\ifthenelse{\equal{\@tmp at bbr@isfirst}{true}}
+{}{#3{\@bbr at lastskip}}
+
+\setlength{\@bb at com@tmpoffset}{#2}%
 }
-
+{
+\setlength{\@bb at com@tmpoffset}{\@bbrcomfixedoffset}%
+}
+}
 \newcommand{\@bb at comfinalize}[1]{
-	\ifthenelse{\equal{\bbrcombottom}{}}{}{#1{\baselineskip}}	
-	#1{\bbrcomafterskip}
-	\endgroup
+#1{\@bbrcomafterskip}
+\endgroup
+\def\@bbr at lastskip{\@bbr at intermessage@skip}
 }
-
-\newcommand{\@bbrmsg}[8]{
-	\@bb at comsetup{#1}{#7}{#8}
-	%
-	\node[#3=\@bb at com@tmpoffset and \bbrcomlength of \@bb at lastbox.#4,anchor=#6,BBRCOM-SIDESTYLE] (\bbrcomsidename) {\bbrcomside};
-	\path[#2] (\bbrcomsidename.#6)  edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb at lastbox.#5|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {};
-	%
-	\@bb at comfinalize{#8}
+\newcommand{\@bbrmsg}[9]{
+\@bb at comsetup{#1}{#7}{#8}{#9}
+\ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
+{
+\ifthenelse{\equal{#4}{north east}}{\def\@bbr at tmp@bottomanchor{south east}}{}
+\ifthenelse{\equal{#4}{north west}}{\def\@bbr at tmp@bottomanchor{south west}}{} 
+\node[#3=-\@bb at com@tmpoffset and \@bbrcomlength of \@bb at lastbox.\@bbr at tmp@bottomanchor,anchor=#6,BBRCOM-SIDESTYLE] (\@bbrcomsidename) {\@bbrcomside};
 }
-
+{
+\node[#3=\@bb at com@tmpoffset and \@bbrcomlength of \@bb at lastbox.#4,anchor=#6,BBRCOM-SIDESTYLE] (\@bbrcomsidename) {\@bbrcomside};
+}
+\path[#2] (\@bbrcomsidename.#6) edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\@bbrcomtopname) {\@bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\@bbrcombottomname) {\@bbrcombottom} (\@bb at lastbox.#5|-\@bbrcomsidename) -- (\@bb at lastbox.#5|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {};
+\@bb at comfinalize{#8}
+}
 \newcommandx{\bbrmsgto}[1]{%
-\@bbrmsg{#1}{->}{below left}{north west}{west}{east}{\@bb at message@hoffset}{\bbrmsgspace}
+\@bbrmsg{#1}{->}{below left}{north west}{west}{east}{\@bb at message@voffset}{\bbrmsgspace}{\@bbr at first@msg}
 }
 \newcommandx{\bbrmsgfrom}[1]{%
-\@bbrmsg{#1}{<-}{below left}{north west}{west}{east}{\@bb at message@hoffset}{\bbrmsgspace}
+\@bbrmsg{#1}{<-}{below left}{north west}{west}{east}{\@bb at message@voffset}{\bbrmsgspace}{\@bbr at first@msg}
 }
+
+\newcommandx{\bbrmsgtofrom}[2]{%
+\bbrmsgto{#1}
+\bbrmsgspace{-\@bbr at intermessage@skip}
+\bbrmsgspace{\@bbr at intermessage@shortskip}
+\bbrmsgfrom{#2}
+\bbrmsgspace{\@bbr at intermessage@medskip}
+}
+
+\newcommandx{\bbrmsgfromto}[2]{%
+\bbrmsgfrom{#1}
+\bbrmsgspace{-\@bbr at intermessage@skip}
+\bbrmsgspace{\@bbr at intermessage@shortskip}
+\bbrmsgto{#2}
+\bbrmsgspace{\@bbr at intermessage@medskip}
+}
 \newcommandx{\bbrmsgvdots}{%
-	\bbrmsgtxt[xshift=\bbrcomlength/2,beforeskip=-0.5\baselineskip,afterskip=-0.5\baselineskip]{$\vdots$}
+\bbrmsgtxt[xshift=\@bbrcomlength/2,afterskip=\@bbr at intermessage@skip]{$\vdots$}
 }
-
-
 \newcommandx{\bbrqryto}[1]{%
-\@bbrmsg{#1}{<-}{below right}{north east}{east}{west}{\@bb at query@hoffset}{\bbrqryspace}
+\@bbrmsg{#1}{<-}{below right}{north east}{east}{west}{\@bb at query@voffset}{\bbrqryspace}{\@bbr at first@query}
 }
 \newcommandx{\bbrqryfrom}[1]{%
-\@bbrmsg{#1}{->}{below right}{north east}{east}{west}{\@bb at query@hoffset}{\bbrqryspace}
+\@bbrmsg{#1}{->}{below right}{north east}{east}{west}{\@bb at query@voffset}{\bbrqryspace}{\@bbr at first@query}
 }
 
-\newcommand{\@bbroracleqry}[4]{
-	\@bb at comsetup{#1}{#3}{#4}
-	%
+\newcommand*{\bbrqrytofrom}[2]{%
+\bbrqryto{#1}
+\bbrqryspace{-\@bbr at intermessage@skip}
+\bbrqryspace{\@bbr at intermessage@shortskip}
+\bbrqryfrom{#2}
+\bbrqryspace{\@bbr at intermessage@medskip}
+}
 
-	\path[#2] (\@bb at lastoracle.north west) -- ++ (0,-\@bb at com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){\bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb at lastbox.east|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {\bbrcomoside};
-	%
-	\@bb at comfinalize{#4}
+\newcommand*{\bbrqryfromto}[2]{%
+\bbrqryfrom{#1}
+\bbrqryspace{-\@bbr at intermessage@skip}
+\bbrqryspace{\@bbr at intermessage@shortskip}
+\bbrqryto{#2}
+\bbrqryspace{\@bbr at intermessage@medskip}
 }
-
+\newcommand{\@bbroracleqry}[4]{
+\@bb at comsetup{#1}{#3}{#4}{\@bbr at first@oraclequery}
+\ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
+{
+\path[#2] (\@bb at lastoracle.south west) -- ++ (0,\@bb at 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} (\@bb at lastbox.east|-\@bbrcomsidename) -- (\@bb at lastbox.east|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=east,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
+}
+{
+\path[#2] (\@bb at lastoracle.north west) -- ++ (0,-\@bb at 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} (\@bb at lastbox.east|-\@bbrcomsidename) -- (\@bb at lastbox.east|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=east,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
+}
+\@bb at comfinalize{#4}
+}
 \newcommand{\bbroracleqryfrom}[1]{
-	\@bbroracleqry{#1}{->}{\@bb at oraclequery@hoffset}{\bbroracleqryspace}
+\@bbroracleqry{#1}{->}{\@bb at oraclequery@voffset}{\bbroracleqryspace}
 }
 
 \newcommand{\bbroracleqryto}[1]{
-	\@bbroracleqry{#1}{<-}{\@bb at oraclequery@hoffset}{\bbroracleqryspace}
+\@bbroracleqry{#1}{<-}{\@bb at oraclequery@voffset}{\bbroracleqryspace}
 }
 
-\newcommand{\@bbrchallengerqry}[4]{
-	\@bb at comsetup{#1}{#3}{#4}
-	%
+\newcommand*{\bbroracleqrytofrom}[2]{%
+\bbroracleqryto{#1}
+\bbroracleqryspace{-\@bbr at intermessage@skip}
+\bbroracleqryspace{\@bbr at intermessage@shortskip}
+\bbroracleqryfrom{#2}
+\bbroracleqryspace{\@bbr at intermessage@medskip}
+}
 
-	\path[#2] (\@bb at lastchallenger.north east) -- ++ (0,-\@bb at com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){\bbrcomside} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb at lastbox.west|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {\bbrcomoside};
-	%
-	\@bb at comfinalize{#4}
+\newcommand*{\bbroracleqryfromto}[2]{%
+\bbroracleqryfrom{#1}
+\bbroracleqryspace{-\@bbr at intermessage@skip}
+\bbroracleqryspace{\@bbr at intermessage@shortskip}
+\bbroracleqryto{#2}
+\bbroracleqryspace{\@bbr at intermessage@medskip}
 }
-
+\newcommand{\@bbrchallengerqry}[4]{
+\@bb at comsetup{#1}{#3}{#4}{\@bbr at first@challengerquery}
+\ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
+{
+\path[#2] (\@bb at lastchallenger.south east) -- ++ (0,\@bb at 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} (\@bb at lastbox.west|-\@bbrcomsidename) -- (\@bb at lastbox.west|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=west,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
+}
+{
+\path[#2] (\@bb at lastchallenger.north east) -- ++ (0,-\@bb at 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} (\@bb at lastbox.west|-\@bbrcomsidename) -- (\@bb at lastbox.west|-\@bbrcomsidename) node[inner sep=0pt,outer sep=0pt,anchor=west,BBRCOM-OSIDESTYLE] (\@bbrcomosidename) {\@bbrcomoside};
+}
+\@bb at comfinalize{#4}
+}
 \newcommand{\bbrchallengerqryfrom}[1]{
-	\@bbrchallengerqry{#1}{<-}{\@bb at challengerquery@hoffset}{\bbrchallengerqryspace}
+\@bbrchallengerqry{#1}{<-}{\@bb at challengerquery@voffset}{\bbrchallengerqryspace}
 }
 
 \newcommand{\bbrchallengerqryto}[1]{
-	\@bbrchallengerqry{#1}{->}{\@bb at challengerquery@hoffset}{\bbrchallengerqryspace}
+\@bbrchallengerqry{#1}{->}{\@bb at challengerquery@voffset}{\bbrchallengerqryspace}
 }
 
+\newcommand*{\bbrchallengerqrytofrom}[2]{%
+\bbrchallengerqryto{#1}
+\bbrchallengerqryspace{-\@bbr at intermessage@skip}
+\bbrchallengerqryspace{\@bbr at intermessage@shortskip}
+\bbrchallengerqryfrom{#2}
+\bbrchallengerqryspace{\@bbr at intermessage@medskip}
+}
 
+\newcommand*{\bbrchallengerqryfromto}[2]{%
+\bbrchallengerqryfrom{#1}
+\bbrchallengerqryspace{-\@bbr at intermessage@skip}
+\bbrchallengerqryspace{\@bbr at intermessage@shortskip}
+\bbrchallengerqryto{#2}
+\bbrchallengerqryspace{\@bbr at intermessage@medskip}
+}
 
 \newcommand*\bbrcomloopleft{}
+\newcommand*\bbrcomloopleftstyle{}
 \newcommand*\bbrcomloopright{}
+\newcommand*\bbrcomlooprightstyle{}
 \newcommand*\bbrcomloopcenter{}
+\newcommand*\bbrcomloopcenterstyle{}
+\newcommand*\bbrcomloopclockwise{false}
 \newcommand*\bbrcomloopangle{50}
 \define at key{bbrcomloop}{left}[]{\renewcommand*\bbrcomloopleft{#1}}
+\define at key{bbrcomloop}{leftstyle}[]{\renewcommand*\bbrcomloopleftstyle{#1}}
 \define at key{bbrcomloop}{right}[]{\renewcommand*\bbrcomloopright{#1}}
+\define at key{bbrcomloop}{rightstyle}[]{\renewcommand*\bbrcomlooprightstyle{#1}}
 \define at key{bbrcomloop}{center}[]{\renewcommand*\bbrcomloopcenter{#1}}
+\define at key{bbrcomloop}{centerstyle}[]{\renewcommand*\bbrcomloopcenterstyle{#1}}
 \define at key{bbrcomloop}{angle}[]{\renewcommand*\bbrcomloopangle{#1}}
+\define at key{bbrcomloop}{clockwise}[true]{\renewcommand*\bbrcomloopclockwise{#1}}
 
 \newcommand{\bbrloop}[3]{
-	\begingroup % for local keys
-	\setkeys{bbrcomloop}{#3}%
+\begingroup % for local keys
+\setkeys{bbrcomloop}{#3}%
 
-	\path[->] (#1) edge[bend right=\bbrcomloopangle] node[midway,left] (bbrleft) {\bbrcomloopleft} (#2);
-	\path[->] (#2) edge[bend right=\bbrcomloopangle] node[midway,right] (bbrright) {\bbrcomloopright} (#1);
-	\node[at=($(bbrleft.north west)!0.5!(bbrright.north east)$),anchor=north]() {\bbrcomloopcenter};
+\tikzset{BBRLOOP-LEFTSTYLE/.style/.expand once=\bbrcomloopleftstyle}%
+\tikzset{BBRLOOP-RIGHTSTYLE/.style/.expand once=\bbrcomlooprightstyle}%
+\tikzset{BBRLOOP-CENTERSTYLE/.style/.expand once=\bbrcomloopcenterstyle}%
 
-	\endgroup
+\ifthenelse{\equal{\bbrcomloopclockwise}{true}}
+{
+\path[->] (#1) edge[bend left=\bbrcomloopangle] node[midway,left,inner sep=0,outer sep=0,BBRLOOP-LEFTSTYLE] (bbrleft) {\bbrcomloopleft} (#2);
+\path[->] (#2) edge[bend left=\bbrcomloopangle] node[midway,right,inner sep=0,outer sep=0,BBRLOOP-RIGHTSTYLE] (bbrright) {\bbrcomloopright} (#1);
 }
+{
+\path[->] (#1) edge[bend right=\bbrcomloopangle] node[midway,left,inner sep=0,outer sep=0,] (bbrleft) {\bbrcomloopleft} (#2);
+\path[->] (#2) edge[bend right=\bbrcomloopangle] node[midway,right,inner sep=0,outer sep=0,] (bbrright) {\bbrcomloopright} (#1);
+}
+\node[at=($(bbrleft.west)!0.5!(bbrright.east)$),anchor=center,BBRLOOP-CENTERSTYLE]() {\bbrcomloopcenter};
 
+\endgroup
+}
+
 \newcommand*\bbrintertexthoffset{1.5cm}
 \define at key{bbrintertext}{xshift}[]{\renewcommand*\bbrintertexthoffset{#1}}
 
 \newcommand{\@bb at intertextsetup}[1]{
-	%load keys	
-	\begingroup % for local keys
+\begingroup % for local keys
 
-	\setkeys{bbrcom,bbrabase,bbrintertext}{#1}%
+  %\if at minipage\kern-0.5\abovedisplayskip\fi
 
-	\tikzset{BBRBASE-NODESTYLE/.style/.expand once=\bbrbasenodestyle}%
+\setkeys{bbrcom,bbrabase,bbrintertext}{#1}%
+\@bbrcom at check@islast{}
+
+\tikzset{BBRBASE-NODESTYLE/.style/.expand once=\@bbrbasenodestyle}%
 }
 
 \newcommand{\@bb at intertextfinalize}[1]{
-	#1{\bbrcomafterskip}
-	\endgroup
+#1{\@bbrcomafterskip}
+\endgroup
+\def\@bbr at lastskip{\@bbr at intermessage@veryshortskip}
 }
 
-\newcommand{\@bbrintertext}[6]{
-	\@bb at intertextsetup{#1}
+\newcommand{\@bbrintertext}[7]{
+\edef\@tmp at bbr@isfirst{#7}
+\renewcommand#7{false}
 
-	% increase space
-	\ifthenelse{\lengthtest{#4<\@bb at firstmessageheight}}
- 	{#5{\@bb at firstmessageheight}}
-	{#5{1\baselineskip}}
+\@bb at intertextsetup{#1}
 
-	\setlength{\@bb at com@tmpoffset}{#4+\bbrcombeforeskip}%
+#5{\@bbrcombeforeskip}
+\ifthenelse{\equal{\@bbrcomfixedoffset}{}}
+{
+\ifthenelse{\equal{\@tmp at bbr@isfirst}{true}}
+{}{#5{\@bbr at intermessage@veryshortskip}}
 
-	%
-	\node[#2=\@bb at com@tmpoffset and \bbrintertexthoffset of \@bb at lastbox.#3,BBRBASE-NODESTYLE] (\bbrbasenodename) {#6};
-	%
-	% compute height of node
-	\coordinate (@bbtmpcoord) at (\bbrbasenodename.north);
-	\path (@bbtmpcoord);
-	\pgfgetlastxy{\XCoord}{\YCoordA}
-	\coordinate (@bbtmpcoord) at (\bbrbasenodename.south);
-	\path (@bbtmpcoord);
-	\pgfgetlastxy{\XCoord}{\YCoordB}
+\setlength{\@bb at com@tmpoffset}{#4}%
+}
+{
+\setlength{\@bb at com@tmpoffset}{\@bbrcomfixedoffset}%
+}
 
-	% update hoffset
-	\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB}
-	#5{\the\@bb at tmplength@b}
+\ifthenelse{\equal{\@bbrcomfixedboffset}{true}}
+{
+\ifthenelse{\equal{#3}{north east}}{\def\@bbr at tmp@bottomanchor{south east}}{}
+\ifthenelse{\equal{#3}{north west}}{\def\@bbr at tmp@bottomanchor{south west}}{} 
 
-	\@bb at intertextfinalize{#5}
+\node[#2=-\@bb at com@tmpoffset and \bbrintertexthoffset of \@bb at lastbox.\@bbr at tmp@bottomanchor, inner sep=0, outer sep=0, BBRBASE-NODESTYLE] (\@bbrbasenodename) {#6};
 }
+{
+\node[#2=\@bb at com@tmpoffset and \bbrintertexthoffset of \@bb at lastbox.#3, inner sep=0, outer sep=0, BBRBASE-NODESTYLE] (\@bbrbasenodename) {#6};
+}
+\coordinate (@bbtmpcoord) at (\@bbrbasenodename.north);
+\path (@bbtmpcoord);
+\pgfgetlastxy{\XCoord}{\YCoordA}
+\coordinate (@bbtmpcoord) at (\@bbrbasenodename.south);
+\path (@bbtmpcoord);
+\pgfgetlastxy{\XCoord}{\YCoordB}
 
+\setlength{\@bb at tmplength@b}{\YCoordA-\YCoordB}
+#5{\the\@bb at tmplength@b}
+
+\@bb at intertextfinalize{#5}
+}
+
 \newcommand{\bbrmsgtxt}[2][]{
-	\@bbrintertext{#1}{below left}{north west}{\@bb at message@hoffset}{\bbrmsgspace}{#2}
+\@bbrintertext{#1}{below left}{north west}{\@bb at message@voffset}{\bbrmsgspace}{#2}{\@bbr at first@msg}
 }
 
 \newcommand{\bbrqrytxt}[2][]{
-	\@bbrintertext{#1}{below right}{north east}{\@bb at query@hoffset}{\bbrqryspace}{#2}
+\@bbrintertext{#1}{below right}{north east}{\@bb at query@voffset}{\bbrqryspace}{#2}{\@bbr at first@query}
 }
 
 \newcommand{\bbrchallengertxt}[2][]{
@@ -1522,7 +1922,7 @@
 \begingroup
 \setlength{\@bb at tmplength@b}{\bbrchallengerhdistance/2}%
 \renewcommand{\bbrintertexthoffset}{\the\@bb at tmplength@b}%
-	\@bbrintertext{#1}{below left}{north west}{\@bb at challengerquery@hoffset}{\bbrchallengerqryspace}{#2}
+\@bbrintertext{#1}{below left}{north west}{\@bb at challengerquery@voffset}{\bbrchallengerqryspace}{#2}{\@bbr at first@challengerquery}
 \endgroup
 }
 
@@ -1530,287 +1930,46 @@
 \begingroup
 \setlength{\@bb at tmplength@b}{\bbroraclehdistance/2}%
 \renewcommand{\bbrintertexthoffset}{\the\@bb at tmplength@b}%
-	\@bbrintertext{#1}{below left}{north west}{\@bb at oraclequery@hoffset}{\bbroracleqryspace}{#2}
+\@bbrintertext{#1}{below left}{north west}{\@bb at oraclequery@voffset}{\bbroracleqryspace}{#2}{\@bbr at first@oraclequery}
 \endgroup
 }
 
 \newcommand{\bbrmsgspace}[1]{
-\@pc at globaladdtolength{\@bb at message@hoffset}{#1}
+\@pc at globaladdtolength{\@bb at message@voffset}{#1}
 }
 
 \newcommand{\bbrqryspace}[1]{
-\@pc at globaladdtolength{\@bb at query@hoffset}{#1}
+\@pc at globaladdtolength{\@bb at query@voffset}{#1}
 }
 
 \newcommand{\bbroracleqryspace}[1]{
-\@pc at globaladdtolength{\@bb at oraclequery@hoffset}{#1}
+\@pc at globaladdtolength{\@bb at oraclequery@voffset}{#1}
 }
 
 \newcommand{\bbrchallengerqryspace}[1]{
-\@pc at globaladdtolength{\@bb at challengerquery@hoffset}{#1}
+\@pc at globaladdtolength{\@bb at challengerquery@voffset}{#1}
 }
 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% stacking
-\providecommand{\pccenteraboveskip}{0.5\baselineskip plus 0.25\baselineskip minus 0.25\baselineskip}
-\providecommand{\pccenterbelowskip}{0.5\baselineskip plus 0.25\baselineskip minus 0.25\baselineskip}
-\newenvironment{pccenter}{%
-\setlength\topsep{0pt}\setlength\parskip{0pt}%
-\begin{center}\vspace{\pccenteraboveskip}%
-}{%
-\vspace{\pccenteraboveskip}%
-\end{center}}
-
-
-%%%%%%%%%%%%%%%%%%%%%
-% horizontal stacking
-% space before hstacks
-\newlength{\pcbeforehstackskip}
-
-\NewEnviron{pchstack}[1][]{%
-% write out content
-\ifthenelse{\equal{#1}{center}}{%
-\begin{pccenter}\mbox{\hspace{\pcbeforehstackskip}\BODY}\end{pccenter}}{%
-\mbox{\hspace{\pcbeforehstackskip}\BODY}}%
+\newcounter{pcstartgamecounter}
+\definecolor{gamechangecolor}{gray}{0.90}
+\newcommand{\gamechange}[2][gamechangecolor]{%
+{\setlength{\fboxsep}{0pt}\colorbox{#1}{\ifmmode$\displaystyle#2$\else#2\fi}}%
 }
-
-
-%%%%%%%%%%%%%%%%%%%%%%%
-\NewEnviron{pcvstack}[1][]{%
-% display minipage
-\ifthenelse{\equal{#1}{center}}{\begin{pccenter}}{}%
-\begin{varwidth}[t]{2\linewidth}\hspace{0pt}\BODY\end{varwidth}% hspace needed for proper vertical positioning .. strange as it is.
-\ifthenelse{\equal{#1}{center}}{\end{pccenter}}{}%
+\newcommand{\pcbox}[1]{%
+{\setlength{\fboxsep}{3pt}\fbox{$\displaystyle#1$}}
 }
+\newcommand*{\pcgamename}{Game}
+\newcommand*{\pcgameprocedurestyle}[1]{\ensuremath{\mathsf{#1}}}
 
+\def\pcgame{\bgroup\pcgame@}
+\newcommand{\pcgame@}[1][]{\ifthenelse{\equal{#1}{}}{\pcgame@@}{\pcgame@@@{#1}}}
+\def\pcgame@@{\pcgameprocedurestyle{\pcgamename}\egroup}
+\def\pcgame@@@#1{\ensuremath{\pcgameprocedurestyle{\pcgamename_{\normalfont{#1}}}}\egroup}
 
-% spacing for stacking
-\newcommand{\pchspace}[1][1em]{\hspace{#1}}
-\newcommand{\pcvspace}[1][\baselineskip]{\par\vspace{#1}}
-
-
-
-
-
-%%%%
-% subprocedures
-\newcounter{@pcsubprogcnt1}
-\newcounter{@pcrsubprogcnt1}
-\newcounter{@pcsubprogcnt2}
-\newcounter{@pcrsubprogcnt2}
-\newcounter{@pcsubprogcnt3}
-\newcounter{@pcrsubprogcnt3}
-\newcounter{@pcsubprogcnt4}
-\newcounter{@pcrsubprogcnt4}
-\newcounter{@pcsubprogcnt5}
-\newcounter{@pcrsubprogcnt5}
-\newcounter{@pcsubprogcnt6}
-\newcounter{@pcrsubprogcnt6}
-\newcounter{@pcsubprogcnt7}
-\newcounter{@pcrsubprogcnt7}
-\newcounter{@pcsubprogcnt8}
-\newcounter{@pcrsubprogcnt8}
-\newcounter{@pcsubprogcnt9}
-\newcounter{@pcrsubprogcnt9}
-\newcounter{@pcsubprogstep}
-
-\newenvironment{subprocedure}{%
-\addtocounter{@pcsubprogstep}{1}%
-% store old counter values
-\setcounter{@pcsubprogcnt\the at pcsubprogstep}{\value{pclinenumber}}%
-\setcounter{@pcrsubprogcnt\the at pcsubprogstep}{\value{pcrlinenumber}}%
-}{%
-\setcounter{pclinenumber}{\value{@pcsubprogcnt\the at pcsubprogstep}}%
-\setcounter{pcrlinenumber}{\value{@pcrsubprogcnt\the at pcsubprogstep}}%
-\addtocounter{@pcsubprogstep}{-1}}
-
-
-%%%%%
-% parameter reordering
-\def\@pseudocodeB#1#2[#3]#4{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1#4},#2,#3]}
-\def\@pseudocodeC#1#2#3{\setkeys*{pcspace}{#2}\@pseudocode[head={#1#3},#2]}
-%for no headers
-\def\@pseudocodeE#1#2[#3]{\setkeys*{pcspace}{#2,#3}\@pseudocode[head={#1},#2,#3]}
-\def\@pseudocodeF#1#2{\setkeys*{pcspace}{#2}\@pseudocode[head={#1},#2]}
-
-%%%%%%%%%
-% Define pseudocode command: 
-% #1 name
-% #2 code to execute after begingroup
-% #3 head prefix
-% #4 other config
-\newcommand{\createprocedurecommand}[4]{
-	\expandafter\gdef\csname #1\endcsname{%
-\begingroup%
-\renewcommand{\@withinspaces}{false}%
-#2%
-\@ifnextchar[%]
-  {\@pseudocodeB{#3}{#4}}
-  {\@pseudocodeC{#3}{#4}}%
-}%
-}
-
-\newcommand{\createpseudocodecommand}[4]{
-	\expandafter\gdef\csname #1\endcsname{%
-\begingroup%
-\renewcommand{\@withinspaces}{false}%
-#2%
-\@ifnextchar[%]
-  {\@pseudocodeE{#3}{#4}}
-  {\@pseudocodeF{#3}{#4}}%
-}%
-}
-
-
-%%%%%%
-% create procedure
-\createprocedurecommand{procedure}{}{}{}
-
-
-
-
-%%%
-% send message
-\newcommand{\pcshortmessageoffset}{0.5cm}
-\newcommand{\pcdefaultmessagelength}{3.5cm}
-\newcommand{\pcdefaultlongmessagelength}{6cm}
-\newcommand{\pcbeforemessageskip}{0pt}
-\newcommand{\pcaftermessageskip}{10pt}
-\newlength{\pcmessagearrow}
-
-\newcommand*\@pcsendmessagelength{\pcdefaultmessagelength}
-\newcommand*\@pcsendmessagecol{}
-\newcommand*\@pcsendmessagewidth{}
-\newcommand*\@pcsendmessagestyle{}
-\newcommand*\@pcsendmessagetop{}
-\newcommand*\@pcsendmessagebottom{}
-\newcommand*\@pcsendmessageright{}
-\newcommand*\@pcsendmessageleft{}
-\newcommand*\@pcsendmessagetopname{t}
-\newcommand*\@pcsendmessagebottomname{b}
-\newcommand*\@pcsendmessagerightname{r}
-\newcommand*\@pcsendmessageleftname{l}
-\newcommand*\@pcsendmessagetopstyle{}
-\newcommand*\@pcsendmessagebottomstyle{}
-\newcommand*\@pcsendmessagerightstyle{}
-\newcommand*\@pcsendmessageleftstyle{}
-\newcommand*\@pcsendmessagebeforeskip{\pcbeforemessageskip}
-\newcommand*\@pcsendmessageafterskip{\pcaftermessageskip}
-\define at key{pcsendmessage}{centercol}[]{\renewcommand*\@pcsendmessagecol{#1}}
-\define at key{pcsendmessage}{width}[]{\renewcommand*\@pcsendmessagewidth{#1}}
-\define at key{pcsendmessage}{style}[]{\renewcommand*\@pcsendmessagestyle{#1}}
-\define at key{pcsendmessage}{length}[]{\renewcommand*\@pcsendmessagelength{#1}}
-\define at key{pcsendmessage}{top}[]{\renewcommand*\@pcsendmessagetop{#1}}
-\define at key{pcsendmessage}{bottom}[]{\renewcommand*\@pcsendmessagebottom{#1}}
-\define at key{pcsendmessage}{right}[]{\renewcommand*\@pcsendmessageright{#1}}
-\define at key{pcsendmessage}{left}[]{\renewcommand*\@pcsendmessageleft{#1}}
-\define at key{pcsendmessage}{topname}[]{\renewcommand*\@pcsendmessagetopname{#1}}
-\define at key{pcsendmessage}{bottomname}[]{\renewcommand*\@pcsendmessagebottomname{#1}}
-\define at key{pcsendmessage}{rightname}[]{\renewcommand*\@pcsendmessagerightname{#1}}
-\define at key{pcsendmessage}{leftname}[]{\renewcommand*\@pcsendmessageleftname{#1}}
-\define at key{pcsendmessage}{topstyle}[]{\renewcommand*\@pcsendmessagetopstyle{#1}}
-\define at key{pcsendmessage}{bottomstyle}[]{\renewcommand*\@pcsendmessagebottomstyle{#1}}
-\define at key{pcsendmessage}{rightstyle}[]{\renewcommand*\@pcsendmessagerightstyle{#1}}
-\define at key{pcsendmessage}{leftstyle}[]{\renewcommand*\@pcsendmessageleftstyle{#1}}
-\define at key{pcsendmessage}{beforeskip}[]{\renewcommand*\@pcsendmessagebeforeskip{#1}}
-\define at key{pcsendmessage}{afterskip}[]{\renewcommand*\@pcsendmessageafterskip{#1}}
-
-
-\newcommand{\@pc at centerincol}[2]{%
-\ifmeasuring@%
-#2%
-\else%
-\makebox[\ifcase\expandafter #1\maxcolumn at widths\fi]{$\displaystyle#2$}%
-\fi%
-}
-
-\newcommand{\centerincol}[1]{\@pc at centerincol{\thepccolumncounter}{#1}}
-
-\newcommand{\@do at sendmessage}[1]{%
-\ifthenelse{\equal{\@pcsendmessagecol}{}}{%
-\ifthenelse{\equal{\@pcsendmessagewidth}{}}{#1}{% we have some width
-\makebox[\@pcsendmessagewidth]{$\displaystyle#1$}%
-}}{%we know the column to center on
-\@pc at centerincol{\@pcsendmessagecol}{#1}%
-}%
-}
-
-\newcommandx*{\sendmessage}[2]{%
-\begingroup\setkeys{pcsendmessage}{#2}%
-\tikzset{PCSENDMSG-PATH-STYLE/.style/.expand once=\@pcsendmessagestyle}%
-\tikzset{PCSENDMSG-TOP-STYLE/.style/.expand once=\@pcsendmessagetopstyle}%
-\tikzset{PCSENDMSG-BOTTOM-STYLE/.style/.expand once=\@pcsendmessagebottomstyle}%
-\tikzset{PCSENDMSG-LEFT-STYLE/.style/.expand once=\@pcsendmessageleftstyle}%
-\tikzset{PCSENDMSG-RIGHT-STYLE/.style/.expand once=\@pcsendmessagerightstyle}%
-%restore halign
-%
-\hspace{\@pcsendmessagebeforeskip}%
-\begin{varwidth}{\linewidth}
-\@do at sendmessage{
-	\begin{tikzpicture}%
-	 \node[PCSENDMSG-LEFT-STYLE] (\@pcsendmessageleftname) {\@pcsendmessageleft};
-	 \node[right=\@pcsendmessagelength of \@pcsendmessageleftname,PCSENDMSG-RIGHT-STYLE] (\@pcsendmessagerightname) {\@pcsendmessageright};
-	 \path[#1,PCSENDMSG-PATH-STYLE] (\@pcsendmessageleftname) edge[] node[above,PCSENDMSG-TOP-STYLE] (\@pcsendmessagetopname) {\@pcsendmessagetop} node[below,PCSENDMSG-BOTTOM-STYLE] (\@pcsendmessagebottomname) {\@pcsendmessagebottom} (\@pcsendmessagerightname); 
-	\end{tikzpicture}%
-}%
-\end{varwidth}
-\hspace{\@pcsendmessageafterskip}%
-\endgroup%
-}
-
-\newcommandx*{\sendmessageright}[2][1=->]{%
-\sendmessage{#1}{#2}%
-}
-
-\newcommandx*{\sendmessageleft}[2][1=<-]{%
-\sendmessage{#1}{#2}%
-}
-
-\WithSuffix\newcommand\sendmessageleft*[2][\pcdefaultmessagelength]{%
-\begingroup%
-\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
-\sendmessage{<-}{length=#1}%
-\endgroup%
-}
-
-
-\WithSuffix\newcommand\sendmessageright*[2][\pcdefaultmessagelength]{%
-\begingroup%
-\renewcommand{\@pcsendmessagetop}{\let\halign\@pc at halign$\begin{aligned}#2\end{aligned}$}%
-\sendmessage{->}{length=#1}%
-\endgroup%
-}
-
-
-
-\DeclareExpandableDocumentCommand{\sendmessagerightx}{O{\pcdefaultlongmessagelength}mO{}m}{%
-\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xrightarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
-}
-
-\DeclareExpandableDocumentCommand{\sendmessageleftx}{O{\pcdefaultlongmessagelength}mO{}m}{%
-\multicolumn{#2}{c}{\ensuremath{\hspace{\pcbeforemessageskip}\xleftarrow[\begin{aligned}#3\end{aligned}]{\mathmakebox[#1]{\begin{aligned}#4\end{aligned}}}\hspace{\pcaftermessageskip}}}
-}
-
-%%%
-% Division
-\DeclareExpandableDocumentCommand{\pcintertext}{O{}m}{\intertext{%
-\ifthenelse{\equal{#1}{center}}{\makebox[\linewidth][c]{#2}}{}%
-\ifthenelse{\equal{#1}{dotted}}{\dotfill#2\dotfill}{}%
-\ifthenelse{\equal{#1}{}}{#2}{}%
-}\@pc at beginnewline}
-
-
-
-%%%
-% Games
-%
-\newcounter{pcstartgamecounter}
-
-
-\newcommand*{\pcgameprocedurestyle}{} % define pseudocode arguments for game procedures
-
-\newcommand*{\pcgamename}{\ensuremath{\mathsf{Game}}}
+\newcommand\@pc at gametitle[1][]{\ifthenelse{\equal{#1}{}}
+{\ensuremath{\pcgame[\thepcgamecounter]\gameprocedurearg}}
+{\ensuremath{\pcgame[#1]\gameprocedurearg}}}
 \newcommand*{\gameprocedurearg}{\ensuremath{(\secpar)}}
 \newcommand*\@pcgameproofgamenr{0}
 \define at key{pcgameproof}{nr}[]{\renewcommand*\@pcgameproofgamenr{#1}}
@@ -1824,19 +1983,19 @@
 \setcounter{pcgamecounter}{\@pcgameproofgamenr}%
 \setcounter{pcstartgamecounter}{\@pcgameproofgamenr}\stepcounter{pcstartgamecounter}%
 }{\@pc at releaseremember\endgroup}
+\newcommand{\setgameproceduredefaultstyle}[1]{%
+\PackageWarning{cryptocode}{Deprecated command setgameproceduredefaultstyle. Use pcsetargs instead.}%
+\pcsetargs{#1}}
 
-\newcommand{\setgameproceduredefaultstyle}[1]{%
 \createpseudocodecommand{gameprocedure}
   {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}}
-  {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}}
-  {#1}
-}
-\setgameproceduredefaultstyle{}
+  {\@pc at gametitle}
+  {}
 
-\def\@bxgame at pseudocodeA[#1]#2#3{\setkeys*{pcspace}{#1}\renewcommand{\@bxgameheader}{$\pcgamename_{#2}$\gameprocedurearg}%
-\@pseudocode[head=\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg},#1]{#3}}
-\def\@bxgame at pseudocodeB#1#2{\renewcommand{\@bxgameheader}{$\pcgamename_{#1}$\gameprocedurearg}%
-\@pseudocode[head=\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}]{#2}}
+\def\@bxgame at pseudocodeA[#1]#2#3{\setkeys*{pcspace}{#1}\renewcommand{\@bxgameheader}{\@pc at gametitle[#2]}%
+\@pseudocode[head=\@pc at gametitle,#1]{#3}}
+\def\@bxgame at pseudocodeB#1#2{\renewcommand{\@bxgameheader}{\@pc at gametitle[#1]}%
+\@pseudocode[head=\@pc at gametitle]{#2}}
 
 \newcommand{\bxgameprocedure}{
 \begingroup%
@@ -1851,14 +2010,12 @@
 
 \newcommand{\@pc at secondheader}{}
 
-%tbx top boxed
 \createpseudocodecommand{tbxgameprocedure}
-  {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}%%
+  {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}%
 \renewcommand{\@pc at secondheader}{true}}
-  {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}}
+{\@pc at gametitle}
 {}
 
-
 \newcommand*\@pcgamehopnodestyle{}
 \newcommand*\@pcgamehopedgestyle{bend left}
 \newcommand*\@pcgamehoppathestyle{}
@@ -1874,7 +2031,6 @@
 \define at key{pcgamehop}{inhint}[]{\renewcommand*\@pcgamehopinhint{#1}}
 \define at key{pcgamehop}{length}[]{\renewcommand*\@pcgamehoplength{#1}}
 
-
 \newcommand{\@pc at setupgamehop}[1]{
 \begingroup\setkeys{pcgamehop}{#1}%
 \tikzset{GAMEHOP-PATH-STYLE/.style/.expand once=\@pcgamehoppathestyle}%
@@ -1896,11 +2052,11 @@
 \@pc at setupgamehop{#3}%
 \begin{tikzpicture}[overlay]%
 \ifthenelse{#1<#2}{%
-       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
        node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#2);
 }{%
- 	 \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
-	 node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
+   \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
+ node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
 }%
 \end{tikzpicture}%
 \@pc at finalizegamehop%
@@ -1910,7 +2066,7 @@
 \@pc at setupgamehop{#2}
 \begin{tikzpicture}[overlay]
        \node[left=\@pcgamehoplength of gamenode#1] (tmpgamenode0) {};
-       \path[->,GAMEHOP-PATH-STYLE] (tmpgamenode0) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       \path[->,GAMEHOP-PATH-STYLE] (tmpgamenode0) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
        node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (gamenode#1);
 \end{tikzpicture}
 \@pc at finalizegamehop
@@ -1919,7 +2075,7 @@
 \@pc at setupgamehop{#2}
 \begin{tikzpicture}[overlay]
        \node[right=\@pcgamehoplength of gamenode#1] (tmpgamenode#1) {};
-       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       \path[->,GAMEHOP-PATH-STYLE] (gamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
        node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (tmpgamenode#1);
 \end{tikzpicture}
 \@pc at finalizegamehop
@@ -1927,7 +2083,7 @@
 \newcommandx*{\addbxgamehop}[3]{%
 \@pc at setupgamehop{#3}
 \begin{tikzpicture}[overlay]
-       \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE]] {\@pcgamehophint} 
+       \path[->,GAMEHOP-PATH-STYLE] (bgamenode#1) edge[GAMEHOP-EDGE-STYLE] node[above,GAMEHOP-NODE-STYLE]] {\@pcgamehophint}
        node[below,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (bgamenode#2);
 \end{tikzpicture}
 \@pc at finalizegamehop
@@ -1936,7 +2092,7 @@
 \@pc at setupgamehop{#2}
 \begin{tikzpicture}[overlay]
        \node (looptemp1)  [right=0.5cm of gamenode#1] {};
-       \draw[->,GAMEHOP-PATH-STYLE] (gamenode#1) -- (looptemp1|-gamenode#1) -- node[right,GAMEHOP-NODE-STYLE] {\@pcgamehophint} 
+       \draw[->,GAMEHOP-PATH-STYLE] (gamenode#1) -- (looptemp1|-gamenode#1) -- node[right,GAMEHOP-NODE-STYLE] {\@pcgamehophint}
        node[left,GAMEHOP-NODE-STYLE] {\@pcgamehophintbelow} (looptemp1|-bgamenode#1)-- (bgamenode#1);
 \end{tikzpicture}
 \@pc at finalizegamehop
@@ -1943,8 +2099,6 @@
 }
 
 
-%%%%%%%% 
-% game description
 \newenvironment{gamedescription}[1][]{%
 \begingroup%
 \setkeys{pcgameproof}{#1}
@@ -1960,9 +2114,9 @@
 \item[%
 \pcdraw{
 \gdef\i{\thepcgamecounter}%
-\node[inner sep=0.0em,outer sep=0, xshift=-1ex, yshift=0.5ex] (gamenode\i) {}; 
+\node[inner sep=0.0em,outer sep=0, xshift=-1ex, yshift=0.5ex] (gamenode\i) {};
 }%
-\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}:]%
+\@pc at gametitle:]%
 \begingroup\setkeys{pcgamehop}{#1}%
 \ifthenelse{\equal{}{\@pcgamehophint}}
   {}
@@ -1981,60 +2135,6 @@
 }%
 \endgroup%
 }
-
-
-
-
-
-
-%%%%%%%% 
-% basic pseudocode constants
-
-\newcommand{\highlightkeyword}[2][\ ]{\ensuremath{\mathbf{#2}}#1}
-\newcommand{\highlightaltkeyword}[1]{\ensuremath{\mathsf{#1}}}
-
-\newcommand{\pcglobvar}{\highlightkeyword{gbl}}
-\newcommand{\pcnew}{\highlightkeyword{new}}
-\newcommand{\pcwhile}{\@pc at increaseindent\highlightkeyword{while}}
-\newcommand{\pcendwhile}{\@pc at decreaseindent\highlightkeyword{endwhile}}
-\newcommandx*{\pcdo}[2][1=\ ,2=]{#1\highlightkeyword[#2]{do}}
-\newcommandx*{\pcif}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{if}}
-\newcommandx*{\pcunless}[1][1=\ ]{\@pc at increaseindent\highlightkeyword[#1]{unless}}
-\newcommandx*{\pcelse}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else}}
-\newcommandx*{\pcelseif}[1][1=\ ]{\@pc at tmpdecreaseindent\highlightkeyword[#1]{else if}}
-\newcommand{\pcfi}{\@pc at decreaseindent\highlightkeyword{fi}}
-\newcommand{\pcendif}{\@pc at decreaseindent\highlightkeyword{endif}}
-\newcommand{\pcendfor}{\@pc at decreaseindent\highlightkeyword{endfor}}
-\newcommandx*{\pcthen}[2][1=\ ,2=\ ]{#1\highlightkeyword[#2]{then}}
-\newcommand{\pcreturn}{\highlightkeyword{return}}
-\newcommandx*{\pcin}[2][1=\ ,2=]{#1\highlightkeyword[#2]{in}}
-\newcommand{\pcfor}{\@pc at increaseindent\highlightkeyword{for}}
-\newcommand{\pcrepeat}[1]{\@pc at increaseindent\ensuremath{\highlightkeyword{repeat} #1\ \highlightkeyword{times}}}
-\newcommand{\pcrepeatuntil}[2]{\ensuremath{\highlightkeyword{repeat}\ #1\ \highlightkeyword{until}\ #2}}
-\newcommand{\pcforeach}{\@pc at increaseindent\highlightkeyword{foreach}}
-\newcommand{\pcendforeach}{\@pc at decreaseindent\highlightkeyword{endforeach}}
-\newcommand{\pcuntil}{\@pc at decreaseindent\highlightkeyword{until}}
-\newcommand{\pccontinue}{\highlightkeyword{continue}}
-\newcommandx*{\pcfalse}[2][1=\ ,2=]{\highlightkeyword[#2]{false}}
-\newcommandx*{\pctrue}[2][1=\ ,2=]{\highlightkeyword[#2]{true}}
-\newcommandx*{\pcnull}[2][1=\ ,2=]{\highlightkeyword[#2]{null}}
-\newcommand{\pccomment}[1]{{\mbox{/\!\!/ } \text{\scriptsize#1}}}
-\newcommand{\pcdone}{\highlightkeyword{done}}
-\newcommand{\pcparse}{\highlightkeyword{parse}}
-\newcommand{\pcfail}{\highlightkeyword{fail}}
-\newcommand{\pcabort}{\highlightkeyword{abort}}
-
-%%%
-% highlighting 
-\definecolor{gamechangecolor}{gray}{0.90}
-\newcommand{\gamechange}[2][gamechangecolor]{%
-{\setlength{\fboxsep}{0pt}\colorbox{#1}{\ifmmode$\displaystyle#2$\else#2\fi}}%
-}
-
-%%%
-% boxing
-\newcommand{\pcbox}[1]{%
-{\setlength{\fboxsep}{3pt}\fbox{$\displaystyle#1$}}
-}
-
-\endinput
\ No newline at end of file
+\endinput
+%%
+%% End of file `cryptocode.sty'.



More information about the tex-live-commits mailing list.