summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-04-23 21:15:55 +0000
committerKarl Berry <karl@freefriends.org>2015-04-23 21:15:55 +0000
commit35d31d35c8c20e4783ade23cfd2b00fdf54bdb97 (patch)
treef01d83073c416e08023935fbe1db13c7869d7afa /Master/texmf-dist
parent33aacfecb5a1f423a522744ccd34c25af25021a2 (diff)
cryptocode (23apr15)
git-svn-id: svn://tug.org/texlive/trunk@37019 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/cryptocode/README2
-rw-r--r--Master/texmf-dist/doc/latex/cryptocode/cryptocode.pdfbin623560 -> 901298 bytes
-rw-r--r--Master/texmf-dist/doc/latex/cryptocode/cryptocode.tex287
-rw-r--r--Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty324
4 files changed, 450 insertions, 163 deletions
diff --git a/Master/texmf-dist/doc/latex/cryptocode/README b/Master/texmf-dist/doc/latex/cryptocode/README
index fa65b30894b..13be19840bc 100644
--- a/Master/texmf-dist/doc/latex/cryptocode/README
+++ b/Master/texmf-dist/doc/latex/cryptocode/README
@@ -5,4 +5,4 @@ community.
The cryptocode bundle is licensed under the LaTeX Project Public License
- -- Arno Mittelbach <mail@arno-mittelbach.de> 23 Mar 2015 \ No newline at end of file
+ -- Arno Mittelbach <mail@arno-mittelbach.de> 22 Apr 2015 \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/cryptocode/cryptocode.pdf b/Master/texmf-dist/doc/latex/cryptocode/cryptocode.pdf
index 602430e15a0..20eba7122cb 100644
--- a/Master/texmf-dist/doc/latex/cryptocode/cryptocode.pdf
+++ b/Master/texmf-dist/doc/latex/cryptocode/cryptocode.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/cryptocode/cryptocode.tex b/Master/texmf-dist/doc/latex/cryptocode/cryptocode.tex
index 35c85948c70..fbbb292109f 100644
--- a/Master/texmf-dist/doc/latex/cryptocode/cryptocode.tex
+++ b/Master/texmf-dist/doc/latex/cryptocode/cryptocode.tex
@@ -112,12 +112,11 @@ It provides various predefined commands for different topics in cryptography.
In particular it provides an easy interface to write pseudocode, protocols, game based proofs
and draw black-box reductions.
-
\vspace{2em}
\begin{center}
\fbox{
\pseudocode{%
-\textbf{ Alice} \< \< \textbf{ Bob} \\[0.5\baselineskip][\hline]
+\textbf{ Alice} \< \< \textbf{ Bob} \\[0.1\baselineskip][\hline]
\<\< \\[-0.5\baselineskip]
x \sample \ZZ_q \< \< \\
X \gets g^x \<\< \\
@@ -217,6 +216,7 @@ the \lstinline$\procedure$ command which takes an additional argument to specify
b' \sample \adv(\secparam, \pk, c, \state) \\
\pcreturn b = b' }}
\end{center}
+
\begin{lstlisting}
\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
b \sample \bin \\
@@ -350,7 +350,7 @@ commands which simply take a message which is displayed.
\begin{center}
\fbox{%
\pseudocode{%
-\textbf{ Alice} \< \< \textbf{ Bob} \\[0.5\baselineskip][\hline]
+\textbf{ Alice} \< \< \textbf{ Bob} \\[0.1\baselineskip][\hline]
\<\< \\[-0.5\baselineskip]
x \sample \ZZ_q \< \< \\
X \gets g^x \<\< \\
@@ -364,7 +364,7 @@ x \sample \ZZ_q \< \< \\
\end{center}
\begin{lstlisting}
\pseudocode{%
-\textbf{ Alice} \< \< \textbf{ Bob} \\[0.5\baselineskip][\hline]
+\textbf{ Alice} \< \< \textbf{ Bob} \\[0.1\baselineskip][\hline]
\<\< \\[-0.5\baselineskip]
x \sample \ZZ_q \< \< \\
X \gets g^x \<\< \\
@@ -457,15 +457,15 @@ by using plain TIKZ commands.
\begin{bbrbox}[name=Oracle 1,minheight=1cm]
\end{bbrbox}
\end{bbroracle}
- \bbroraclequeryto{top=$m$}
- \bbroraclequeryfrom{top=$b$}
+ \bbroracleqryto{top=$m$}
+ \bbroracleqryfrom{top=$b$}
\begin{bbroracle}{OraB}
\begin{bbrbox}[name=Oracle 2,minheight=1cm]
\end{bbrbox}
\end{bbroracle}
- \bbroraclequeryto{top=$m$}
- \bbroraclequeryfrom{top=$b$}
+ \bbroracleqryto{top=$m$}
+ \bbroracleqryfrom{top=$b$}
\end{bbrenv}
\begin{lstlisting}
\begin{bbrenv}{A}
@@ -503,15 +503,15 @@ by using plain TIKZ commands.
\begin{bbrbox}[name=Oracle 1,minheight=1cm]
\end{bbrbox}
\end{bbroracle}
- \bbroraclequeryto{top=$m$}
- \bbroraclequeryfrom{top=$b$}
+ \bbroracleqryto{top=$m$}
+ \bbroracleqryfrom{top=$b$}
\begin{bbroracle}{OraB}
\begin{bbrbox}[name=Oracle 2,minheight=1cm]
\end{bbrbox}
\end{bbroracle}
- \bbroraclequeryto{top=$m$}
- \bbroraclequeryfrom{top=$b$}
+ \bbroracleqryto{top=$m$}
+ \bbroracleqryfrom{top=$b$}
\end{bbrenv}
\end{lstlisting}
We'll discuss the details in Chapter~\ref{chap:bbr}.
@@ -1012,6 +1012,7 @@ Code
\index{syntaxhighlight}
\index{keywords}
\index{keywordsindent}
+\index{codesize}
\index{keywordsunindent}
\index{keywordsuninindent}
\index{addkeywords}
@@ -1022,6 +1023,9 @@ Code
\index{colsep}
\index{addtolength}
\index{nodraft}
+\index{yshift}
+\index{bodylinesep}
+\index{headlinesep}
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 (,).
@@ -1063,8 +1067,18 @@ 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[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]
@@ -1603,7 +1617,7 @@ The pseudocode package allows the typesetting of sub procedures such as
\procedure[linenumbering]{$\indcpa_\enc^\adv$}{%
b \sample \bin \\
(\pk,\sk) \sample \kgen(\secparam) \\
- (m_0,m_1) \sample \begin{subprocedure}%
+ (m_0,m_1) \sample \begin{subprocedure}%
\dbox{\procedure{$\adv(\secparam, \pk, c)$}{%
\text{Step 1} \\
\text{Step 2} \\
@@ -1757,9 +1771,10 @@ use \lstinline{\pcvspace} which takes an optional length as a parameter.
Horizontal and vertical stacking can be combined
\begin{pchstack}[center]
-\begin{pcvstack}
+
+\begin{pcvstack}%
\procedure{$\indcpa_\enc^\adv$}{%
- \pcln b \sample \bin \\
+ \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) \\
@@ -1952,6 +1967,7 @@ command. We can achieve a similar effect without an additional pcimage environme
\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.
@@ -2587,6 +2603,7 @@ A TIKZ style to be used for the path.
A TIKZ style to be used for the edge. This defaults to \enquote{bend left}.
\end{description}
+\vspace{1ex}
\begin{center}
\begin{gameproof}
\gameprocedure{%
@@ -2806,7 +2823,7 @@ This box is generated as
The commands \lstinline$bbrinput$ and \lstinline$bbroutput$ allow to specify input and output for the latest
''bbrenv´´ environment. 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{http://www.ctan.org/tex-archive/graphics/pgf/}).
+(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}{UNIQUE IDENTIFIER}
\end{lstlisting}
@@ -2855,12 +2872,20 @@ name=Box Name
\end{lstlisting}
to specify the label. The following options are available
+\index{namepos}
+\index{namestyle}
+\index{minheight}
+\index{xshift}
+\index{yshift}
\begin{center}
\begin{tabular}{ll}
\textbf{Option} & \textbf{Description} \\ \hline
name & Specifies the box' label \\
+namepos & Specifies the position (left, center, right, top left, top center, top right) \\
+namestyle & Specifies the style of the name \\
minheight & The minimal height \\
xshift & Allows horizontal positioning \\
+yshift & Allows horizontal positioning \\
style & allows to customize the node
\end{tabular}
\end{center}
@@ -2869,6 +2894,7 @@ style & allows to customize the node
\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}{A}
\begin{bbrbox}[name=Box Name]
\pseudocode{
@@ -3027,7 +3053,7 @@ Following is a complete example. Notice that cryptocode takes care of the vertic
\subsection{Options}
Besides specifying labels for top, side and bottom you can further specify how cryptocode renders the message.
-Remember that tnderneath the reduction commands is a TIKZ image (\url{http://www.ctan.org/tex-archive/graphics/pgf/}).
+Remember that tnderneath 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}
@@ -3111,11 +3137,12 @@ Via the option \enquote{length} you can specifiy the length of the arrow.
\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
+\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}{A}
\begin{bbrbox}[name=Reduction]
\pseudocode{
@@ -3128,8 +3155,13 @@ Consider the following setting
\end{bbrbox}
- \bbrmsgto{top=$m$,sidename=BeginLoop}
- \bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
+ \bbrmsgto{top=$m$}
+ \bbrmsgspace{1.5cm}
+ \bbrmsgfrom{top=$\sigma$}
+
+ \bbrqryto{top=$m$}
+ \bbrqryspace{1cm}
+ \bbrqryfrom{top=$\sigma$}
\end{bbrenv}
@@ -3152,8 +3184,13 @@ Consider the following setting
\end{bbrbox}
\bbrmsgto{top=$m$}
+ \bbrmsgspace{1.5cm}
\bbrmsgfrom{top=$\sigma$}
+ \bbrqryto{top=$m$}
+ \bbrqryspace{1cm}
+ \bbrqryfrom{top=$\sigma$}
+
\end{bbrenv}
\end{bbrbox}
@@ -3162,14 +3199,12 @@ Consider the following setting
\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.
+
+\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}{A}
\begin{bbrbox}[name=Reduction]
\pseudocode{
@@ -3184,7 +3219,6 @@ to be shown on the left, center or right. Here is the result.
\bbrmsgto{top=$m$,sidename=BeginLoop}
\bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
- \bbrloop{BeginLoop}{EndLoop}{center=$q$}
\end{bbrenv}
@@ -3206,9 +3240,8 @@ to be shown on the left, center or right. Here is the result.
\end{bbrbox}
- \bbrmsgto{top=$m$,sidename=BeginLoop}
- \bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
- \bbrloop{BeginLoop}{EndLoop}{center=$q$}
+ \bbrmsgto{top=$m$}
+ \bbrmsgfrom{top=$\sigma$}
\end{bbrenv}
@@ -3218,11 +3251,15 @@ to be shown on the left, center or right. Here is the result.
\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.
+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}{A}
\begin{bbrbox}[name=Reduction]
\pseudocode{
@@ -3235,13 +3272,10 @@ If the spacing between messages is not sufficient you can use the \lstinline$bbr
\end{bbrbox}
- \bbrmsgto{top=$m$}
- \bbrmsgspace{1.5cm}
- \bbrmsgfrom{top=$\sigma$}
-
- \bbrqryto{top=$m$}
- \bbrqryspace{1cm}
- \bbrqryfrom{top=$\sigma$}
+ \bbrmsgto{top=$m$,sidename=BeginLoop}
+ \bbrmsgspace{0.5cm}
+ \bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
+ \bbrloop{BeginLoop}{EndLoop}{center=$q$}
\end{bbrenv}
@@ -3263,13 +3297,10 @@ If the spacing between messages is not sufficient you can use the \lstinline$bbr
\end{bbrbox}
- \bbrmsgto{top=$m$}
- \bbrmsgspace{1.5cm}
- \bbrmsgfrom{top=$\sigma$}
-
- \bbrqryto{top=$m$}
- \bbrqryspace{1cm}
- \bbrqryfrom{top=$\sigma$}
+ \bbrmsgto{top=$m$,sidename=BeginLoop}
+ \bbrmsgspace{0.5cm}
+ \bbrmsgfrom{top=$\sigma$,sidename=EndLoop}
+ \bbrloop{BeginLoop}{EndLoop}{center=$q$}
\end{bbrenv}
@@ -3279,7 +3310,6 @@ If the spacing between messages is not sufficient you can use the \lstinline$bbr
\end{bbrenv}
\end{lstlisting}
-
\subsection{Intertext}
\index{\textbackslash bbrmsgtxt}
\index{\textbackslash bbrqrytxt}
@@ -3364,7 +3394,8 @@ and \lstinline$\bbrqrytxt$ commands.
\section{Oracles}
\index{bbroracle}
-\index{distance}
+\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.
@@ -3390,7 +3421,7 @@ go behind the single \emph{bbrbox} environment within an \emph{bbrenv} enviornme
\end{bbrbox}
\end{bbroracle}
- \begin{bbroracle}{OraB}[distance=3cm]
+ \begin{bbroracle}{OraB}[vdistance=2cm,hdistance=3cm]
\begin{bbrbox}[name=Oracle 2]
\end{bbrbox}
\end{bbroracle}
@@ -3419,23 +3450,23 @@ go behind the single \emph{bbrbox} environment within an \emph{bbrenv} enviornme
\end{bbrbox}
\end{bbroracle}
- \begin{bbroracle}{OraB}
+ \begin{bbroracle}{OraB}[vdistance=2cm,hdistance=3cm]
\begin{bbrbox}[name=Oracle 2]
\end{bbrbox}
\end{bbroracle}
\end{bbrenv}
\end{lstlisting}
-Via the option \enquote{distance=length} you can control the horizontal position of the oracle. By default this value is set to 1cm.
+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 bbroraclequeryfrom}
-\index{\textbackslash bbroraclequeryto}
+\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$\bbroraclequeryfrom$ and \lstinline$\bbroraclequeryto$.
+queries to oracles. In addition you can use the \lstinline$\bbroracleqryfrom$ and \lstinline$\bbroracleqryto$.
\begin{lstlisting}
-\bbroraclequeryfrom{options}
-\bbroraclequeryto{options}
+\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
@@ -3448,7 +3479,7 @@ that oracle messages need to be added after the closing \lstinline$\end{bbroracl
}
\begin{bbrenv}{B}
- \begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
+ \begin{bbrbox}[name=Adversary,minheight=3cm,xshift=3cm]
\end{bbrbox}
\end{bbrenv}
@@ -3461,15 +3492,15 @@ that oracle messages need to be added after the closing \lstinline$\end{bbroracl
\begin{bbrbox}[name=Oracle 1,minheight=1cm]
\end{bbrbox}
\end{bbroracle}
- \bbroraclequeryfrom{top=$m$}
- \bbroraclequeryto{top=$b$}
+ \bbroracleqryfrom{top=$m$}
+ \bbroracleqryto{top=$b$}
\begin{bbroracle}{OraB}
\begin{bbrbox}[name=Oracle 2,minheight=1cm]
\end{bbrbox}
\end{bbroracle}
- \bbroraclequeryfrom{bottom=$m$}
- \bbroraclequeryto{bottom=$b$}
+ \bbroracleqryfrom{bottom=$m$}
+ \bbroracleqryto{bottom=$b$}
\end{bbrenv}
\begin{lstlisting}
@@ -3480,7 +3511,7 @@ that oracle messages need to be added after the closing \lstinline$\end{bbroracl
}
\begin{bbrenv}{B}
- \begin{bbrbox}[name=Adversary,minheight=3cm,xshift=4cm]
+ \begin{bbrbox}[name=Adversary,minheight=3cm,xshift=3cm]
\end{bbrbox}
\end{bbrenv}
@@ -3493,19 +3524,123 @@ that oracle messages need to be added after the closing \lstinline$\end{bbroracl
\begin{bbrbox}[name=Oracle 1,minheight=1cm]
\end{bbrbox}
\end{bbroracle}
- \bbroraclequeryfrom{top=$m$}
- \bbroraclequeryto{top=$b$}
+ \bbroracleqryfrom{top=$m$}
+ \bbroracleqryto{top=$b$}
\begin{bbroracle}{OraB}
\begin{bbrbox}[name=Oracle 2,minheight=1cm]
\end{bbrbox}
\end{bbroracle}
- \bbroraclequeryfrom{bottom=$m$}
- \bbroraclequeryto{bottom=$b$}
+ \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}{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}
+
+
+\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.
+
+\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}
+
+\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}
+
\chapter{Known Issues}
\section{Pseudocode KeepSpacing within Commands}
@@ -3549,6 +3684,10 @@ with either the \enquote{sets} or the \enquote{probability} option. In order to
\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
diff --git a/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty b/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty
index 72fc9e90b12..5c1edac52b2 100644
--- a/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty
+++ b/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty
@@ -15,7 +15,7 @@
% This work consists of the files cryptocode.tex and cryptocode.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cryptocode}
- [2015/03/09 v0.01 Cryptocode LaTeX package for writing pseudocode in cryptographic settings]
+ [2015/04/22 v0.1 Cryptocode LaTeX package for writing pseudocode in cryptographic settings]
\def\hi{Hello, this is Arno's crypto code package. }
@@ -247,8 +247,8 @@
}
\DeclareOption{lambda}{
- \providecommand{\secpar}{\ensuremath{\lambda}}
- \providecommand{\secparam}{\ensuremath{1^\secpar}}
+ \renewcommand{\secpar}{\ensuremath{\lambda}}
+ \renewcommand{\secparam}{\ensuremath{1^\secpar}}
}
\DeclareOption*{%
@@ -270,7 +270,7 @@
\RequirePackage{ifthen}
\RequirePackage{xargs}
\RequirePackage{pgf}
-\RequirePackage{mathabx}
+%\RequirePackage{mathabx}
\RequirePackage{forloop}
\RequirePackage{array}
\RequirePackage{xparse}
@@ -280,7 +280,7 @@
\RequirePackage{suffix}
\RequirePackage{etoolbox}
\RequirePackage{etex}
-\RequirePackage{etextools}
+%\RequirePackage{etextools}
\RequirePackage{environ}
%\RequirePackage{xspace}
\RequirePackage{xkeyval}
@@ -298,7 +298,7 @@
\providecommand{\nizk}{\pcalgostyle{NIZK}}
% hash
- \renewcommand{\hash}{\pcalgostyle{H}}
+ \providecommand{\hash}{\pcalgostyle{H}}
\providecommand{\gash}{\pcalgostyle{G}}
\providecommand{\fash}{\pcalgostyle{F}}
@@ -333,6 +333,7 @@
\providecommand{\distinguisher}{\pcalgostyle{Dist}}
\providecommand{\simulator}{\pcalgostyle{Sim}}
\providecommand{\ext}{\pcalgostyle{Ext}}
+ \providecommand{\extractor}{\ext}
\fi
%%
@@ -342,14 +343,11 @@
%%%
% order of growth helper
\ifpc@orderofgrowth
- \providecommand{\olrk}[1]{%
- \ifx\nursymbol#1\else\!\!\mskip4.5mu plus 0.5mu\left(#1\right)\fi}
- \providecommand{\elrk}[1]{%
- \ifx\nursymbol#1\else%
- \!\!\mskip4.5mu plus0.5mu\left[\mskip2.5mu plus0.5mu #1\right]\fi}
- \providecommand{\clrk}[1]{%
- \ifx\nursymbol#1\else%
- \!\!\mskip4.5mu plus0.5mu\left\{\mskip2.5mu plus0.5mu #1\right\}\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{\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@algorithmstyle
@@ -360,7 +358,7 @@
% create command to measure width of align
%
\newcommand{\@settowidthofalign}[2]{%
- \setbox\z@=\vbox{
+ \setbox\z@=\vbox{\@pseudocodecodesize
\begin{flalign*}
#2
\ifmeasuring@\else\global\let\got@maxcolwd\maxcolumn@widths\fi
@@ -370,8 +368,7 @@
\def\or{+}\edef\x{\endgroup#1=\dimexpr\got@maxcolwd\relax}\x}
\newcommand{\@settowidthofaligned}[2]{%
- \settowidth{#1}{$\begin{aligned}#2\end{aligned}$}
-}
+\settowidth{#1}{\@pseudocodesubcodesize$\begin{aligned}#2\end{aligned}$}}
% check for draft mode
\def\@pc@ifdraft{\ifdim\overfullrule>\z@
@@ -398,11 +395,6 @@
-% The size to be used by the pseudocode procedure
-\providecommand{\pcsize}{\small}
-% The size to be used by the pseudocode procedure when writing subprocedures
-\providecommand{\pcsubsize}{\footnotesize}
-
%%%%%
% spaces before and after pseudo codes (left and right)
\providecommand{\beforepcskip}{2pt}
@@ -478,6 +470,8 @@
% pseudocode command itself does need to do some counter magic
\newcounter{pclinenumber}
\newcounter{Hpclinenumber} % make hyperref happy
+\newcounter{@pclinenumber}
+\newcounter{H@pclinenumber} % make hyperref happy
\newcounter{@pclinenumbertmp}
\newcounter{pcgamecounter}
\newcounter{Hpcgamecounter}
@@ -493,6 +487,12 @@
\providecommand{\pclnspace}{0pt}
\providecommand{\pclnrspace}{5pt}
+\renewcommand{\the@pclinenumber}{\thepclinenumber}
+\providecommand{\@pcln}{%
+\refstepcounter{@pclinenumber}%
+\stepcounter{H@pclinenumber}%
+}
+
% left align line numbers
\providecommand{\pcln}[1][]{%
\refstepcounter{pclinenumber}%
@@ -529,6 +529,7 @@
\newlength{\@pc@alt@minipage@length}
% backward games
+\newcommand{\@withingame}{false}
\newcommand{\@withinbxgame}{false}
\newcommand{\@bxgameheader}{}
@@ -540,7 +541,7 @@
\newcommand{\@pc@beginnewline}{%
-\@pc@and\@pseudocodelinenumber%
+\@pseudocodelinenumber\@pc@and\@pcln%
%checkspace
\ifthenelse{\equal{\@pseudocodespace}{auto}}%
{\expandafter\pcind\expandafter[\value{@pc@indentationlevel}]}%
@@ -559,6 +560,7 @@
\newcommand*\@pseudocodehead{}
\newcommand*\@pseudocodewidth{}
\newcommand*\@pseudocodexshift{0pt}
+\newcommand*\@pseudocodeyshift{0pt}
\newcommand*\@pseudocodelinenumber{}
\newcommand*\@pseudocodebeforeskip{0ex}
\newcommand*\@pseudocodeafterskip{0ex}
@@ -567,9 +569,15 @@
\newcommand*\@pseudocodesyntaxhighlighting{}
\newcommand*\@pseudocodenodraft{false}
+\newcommand*\@pseudocodeheadlinesep{0em}
+\newcommand*\@pseudocodebodylinesep{-0.5\baselineskip}
+
\newcommand*\@pseudocodecolsep{0em}
\newcommand*\@pseudocodeaddtolength{2pt}
+\newcommand*\@pseudocodecodesize{\small}
+\newcommand*\@pseudocodesubcodesize{\footnotesize}
+
%%%%%%%%%%%%%%
% Define keywords for the automatic syntax highlighting
% the accompanying add provides additional keywords.
@@ -585,15 +593,20 @@
\end{@withspaces}
+\define@key{pseudocode}{codesize}[\small]{\renewcommand*\@pseudocodecodesize{#1}}
+\define@key{pseudocode}{subcodesize}[\small]{\renewcommand*\@pseudocodesubcodesize{#1}}
\define@key{pseudocode}{head}[]{\renewcommand*\@pseudocodehead{#1}}
\define@key{pseudocode}{width}[]{\renewcommand*\@pseudocodewidth{#1}}
\define@key{pseudocode}{xshift}[]{\renewcommand*\@pseudocodexshift{#1}}
+\define@key{pseudocode}{yshift}[]{\renewcommand*\@pseudocodeyshift{#1}}
\define@key{pseudocode}{linenumbering}[on]{\ifthenelse{\equal{#1}{on}}{\renewcommand*\@pseudocodelinenumber{\pcln}}{\renewcommand*\@pseudocodelinenumber{}}}
\define@key{pseudocode}{beforeskip}[]{\renewcommand*\@pseudocodebeforeskip{#1}}
\define@key{pseudocode}{afterskip}[]{\renewcommand*\@pseudocodeafterskip{#1}}
\define@key{pseudocode}{lnstart}[0]{\renewcommand*\@pseudocodelnstart{#1}}
\define@key{pseudocode}{lnstartright}[0]{\renewcommand*\@pseudocodelnstartright{#1}}
\define@key{pseudocode}{colsep}[0em]{\renewcommand*\@pseudocodecolsep{#1}}
+\define@key{pseudocode}{headlinesep}[0em]{\renewcommand*\@pseudocodeheadlinesep{#1}}
+\define@key{pseudocode}{bodylinesep}[0em]{\renewcommand*\@pseudocodebodylinesep{#1}}
\define@key{pseudocode}{addtolength}[2pt]{\renewcommand*\@pseudocodeaddtolength{#1}}
\define@key{pseudocode}{mode}[math]{%
\ifthenelse{\equal{#1}{text}}{%
@@ -789,6 +802,13 @@
\setcounter{@pclinenumbertmp}{\value{pclinenumber}}%
\setcounter{@pcrlinenumbertmp}{\value{pcrlinenumber}}%
%
+% vertical space
+\vspace{\@pseudocodeyshift}%
+%\setlength{\abovedisplayskip}{0pt}%
+%\setlength{\belowdisplayskip}{0pt}%
+%\setlength{\abovedisplayshortskip}{0pt}%
+%\setlength{\belowdisplayshortskip}{0pt}%
+%
%
% line magic
\ifthenelse{\value{@pc@global@pc@nestcnt}=1}{%
@@ -846,25 +866,33 @@
\endgroup%
}
-
-\let\pclb\relax
-%
-\newcommand{\pc@display@pseudocode}[2]{%
-\ifthenelse{\equal{#1}{}}{\vspace{-0.8\baselineskip}\pcsize}{%
+\newcommand{\@pc@gameheader}[2]{%
\tikz{\gdef\i{\thepcgamecounter}%
-\node[anchor=base] (gamenode\i) {\hspace{-2pt}#1\vphantom{$\sum^A_{A_b}$}};
+\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}$}};}
{}%
-}\vspace{-0.1\baselineskip}\hrule\small\vspace{-0.5\baselineskip}}%
+}%
+}
+
+\let\pclb\relax
+%
+\newcommand{\pc@display@pseudocode}[2]{%
+\ifthenelse{\equal{#1}{}}{\vspace{-1\baselineskip}\@pseudocodecodesize}{%
+\ifthenelse{\equal{\@withingame}{true}}{%
+\@pc@gameheader{#1}{}\ifthenelse{\equal{\@pc@secondheader}{true}}{\addtocounter{pcgamecounter}{1}\@pc@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@display@subcode}[2]{%
\begingroup%
-\ifthenelse{\equal{#1}{}}{}{#1\vphantom{$\sum^A_{A_b}$}\hrule \vspace{0.2\baselineskip}}%
-\pcsubsize%
+\ifthenelse{\equal{#1}{}}{}{#1\vphantom{$\sum^A_{A_b}$} %
+\vspace{\@pseudocodeheadlinesep}\hrule \vspace{\baselineskip}\vspace{\@pseudocodebodylinesep}}%
+\@pseudocodesubcodesize%
$\begin{aligned}#2\end{aligned}$%
\endgroup%
}
@@ -931,83 +959,122 @@ $\begin{aligned}#2\end{aligned}$%
% Reductions
\newcommand{\@bb@lastbox}{}
\newcommand{\@bb@lastoracle}{}
+\newcommand{\@bb@lastchallenger}{}
+
\newlength{\@bb@message@hoffset}
\newlength{\@bb@query@hoffset}
\newlength{\@bb@oraclequery@hoffset}
+\newlength{\@bb@challengerquery@hoffset}
\newcounter{@bb@oracle@cnt}
\newcounter{@bb@oracle@nestcnt}
+\newcounter{@bb@challenger@cnt}
+\newcounter{@bb@challenger@nestcnt}
+
\newcounter{@bb@env@nestcnt}
\newcommand{\bbroraclenodenameprefix}{ora-}
+\newcommand{\bbrchallengernodenameprefix}{challenger-}
\newcommand{\bbrenvnodenameprefix}{env-}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Black Box Reduction Enviconment
-\newenvironmentx{bbrenv}[3][1=0pt,3=0pt]{
-\addtocounter{@bb@env@nestcnt}{1}
-\renewcommand{\@bb@lastbox}{#2}
-
+\newenvironmentx{bbrenv}[3][1=0pt,3=0pt]{%
+\addtocounter{@bb@env@nestcnt}{1}%
+\renewcommand{\@bb@lastbox}{#2}%
+%
% reset lengths
-\setlength{\@bb@message@hoffset}{0pt}
-\setlength{\@bb@query@hoffset}{0pt}
-\@pc@globalsetlength{\@bb@oraclequery@hoffset}{0pt}
-
+\setlength{\@bb@message@hoffset}{0pt}%
+\setlength{\@bb@query@hoffset}{0pt}%
+\@pc@globalsetlength{\@bb@oraclequery@hoffset}{0pt}%
+\@pc@globalsetlength{\@bb@challengerquery@hoffset}{0pt}%
+%
%reset oracle counter and oracle query offset
-\ifthenelse{\value{@bb@oracle@nestcnt}=0}{
- \setcounter{@bb@oracle@cnt}{0}
-}{
-}
-
-\def\@bbendskip{#3}
-\vspace{#1}
-\ifthenelse{\value{@bb@env@nestcnt}=1}{
-\@pc@ensureremember
+\ifthenelse{\value{@bb@oracle@nestcnt}=0}
+ {\setcounter{@bb@oracle@cnt}{0}}{}%
+\ifthenelse{\value{@bb@challenger@nestcnt}=0}
+ {\setcounter{@bb@challenger@cnt}{0}}{}%
+%
+\def\@bbendskip{#3}%
+\vspace{#1}%
+\ifthenelse{\value{@bb@env@nestcnt}=1}
+ {\@pc@ensureremember%
\begin{tikzpicture}
}{\tikz\bgroup}
-}{
-\ifthenelse{\value{@bb@env@nestcnt}=1}{
-\end{tikzpicture}
-\@pc@releaseremember
-}{\egroup}
-\vspace{\@bbendskip}
-\addtocounter{@bb@env@nestcnt}{-1}
+}{%
+\ifthenelse{\value{@bb@env@nestcnt}=1}
+{\end{tikzpicture}%
+\@pc@releaseremember%
+}{\egroup}%
+\vspace{\@bbendskip}%
+\addtocounter{@bb@env@nestcnt}{-1}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% black box reduction box
% option keys
\newcommand*\bbrboxname{}
+\newcommand*\bbrboxnamepos{right}
+\newcommand*\bbrboxnamestyle{}
+\newcommand*\@bbrboxnamepos{below=0.5ex of \@bb@lastbox.north east,anchor=north east}
+\newcommand*\@bbrboxnameposoffset{below left=0cm of phantomname.north west}
\newcommand*\bbrboxstyle{draw}
\newcommand*\bbrboxafterskip{}
-\newcommand*\bbrboxxshift{-2cm}
+\newcommand*\bbrboxminwidth{2cm}
+\newcommand*\bbrboxxshift{0cm}
+\newcommand*\bbrboxyshift{0cm}
\define@key{bbrbox}{name}[]{\renewcommand*\bbrboxname{#1}}
+\define@key{bbrbox}{namestyle}[]{\renewcommand*\bbrboxnamestyle{#1}}
+\define@key{bbrbox}{namepos}[]{\renewcommand*\bbrboxnamepos{#1}}
\define@key{bbrbox}{style}[draw]{\renewcommand*\bbrboxstyle{#1}}
+\define@key{bbrbox}{minwidth}[]{\renewcommand*\bbrboxminwidth{#1}}
\define@key{bbrbox}{minheight}[]{\renewcommand*\bbrboxafterskip{#1}}
\define@key{bbrbox}{xshift}[]{\renewcommand*\bbrboxxshift{#1}}
+\define@key{bbrbox}{yshift}[]{\renewcommand*\bbrboxyshift{#1}}
\NewEnviron{bbrbox}[1][]{%
\setkeys{bbrbox}{#1}%
+\ifthenelse{\equal{\bbrboxnamepos}{center}}
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb@lastbox.north,anchor=north}}{}
+\ifthenelse{\equal{\bbrboxnamepos}{left}}
+ {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb@lastbox.north west,anchor=north west}\renewcommand{\@bbrboxnameposoffset}{below left=1\baselineskip of phantomname.south west}}{}
+\ifthenelse{\equal{\bbrboxnamepos}{top right}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north east,anchor=south east}}{}
+\ifthenelse{\equal{\bbrboxnamepos}{top center}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north,anchor=south}}{}
+\ifthenelse{\equal{\bbrboxnamepos}{top left}}
+ {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north west,anchor=south west}}{}
+
+
\tikzset{BBRBOXSTYLE/.style/.expand once=\bbrboxstyle}%
-\node[inner sep=0pt,outer sep=0pt] (bbrshift) {};
-\node[BBRBOXSTYLE,xshift=\bbrboxxshift] (\@bb@lastbox) at (bbrshift) \bgroup
+\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@lastbox-tmpouter) {};
+\node[inner sep=.3333em,anchor=north,BBRBOXSTYLE,below right=\bbrboxyshift and \bbrboxxshift of \@bb@lastbox-tmpouter] (\@bb@lastbox) \bgroup
\tikz{
- \node (inner) {\begin{varwidth}{\linewidth}\BODY\end{varwidth}};
- \node[right=0.05cm of inner.north east] (tmpne) {};
- \node[above left=0.cm and 0pt of tmpne.north] (name) {\bbrboxname};
+ \node[inner sep=0pt,outer sep=0pt] (phantomname) {}; %minimum width
+ \node[BBRBOXNAMEPOSOFFSET] (inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}};
\ifthenelse{\equal{\bbrboxafterskip}{}}{}{
\node[below=0cm of inner,minimum height=\bbrboxafterskip] {};
}
+ \node[inner sep=0pt,outer sep=0pt,at=(inner.south west)] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width
}
\egroup;
+\node[BBRBOXNAMEPOS,BBRBOXNAMESTYLE, inner sep=0.2ex, outer sep=0pt, overlay] () {\bbrboxname};
}
-\newcommand*\bbroracledistance{1cm}
-\define@key{bbroracle}{distance}[]{\renewcommand*\bbroracledistance{#1}}
+\newcommand*\bbroraclevdistance{\baselineskip}
+\newcommand*\bbroraclehdistance{1.5cm}
+\define@key{bbroracle}{distance}[]{\renewcommand*\bbroraclehdistance{#1}}
+\define@key{bbroracle}{hdistance}[]{\renewcommand*\bbroraclehdistance{#1}}
+\define@key{bbroracle}{vdistance}[]{\renewcommand*\bbroraclevdistance{#1}}
+
% ORACLES
\newenvironmentx{bbroracle}[2][2=]{%
@@ -1018,9 +1085,9 @@ $\begin{aligned}#2\end{aligned}$%
%if first oracle, then put it to the right, else stack them vertically
\addtocounter{@bb@oracle@cnt}{1}
\ifthenelse{\value{@bb@oracle@cnt}=1}{
- \node[below right=0cm and \bbroracledistance of \@bb@lastbox.north east] (\bbroraclenodenameprefix#1) \bgroup
+ \setlength{\@bb@tmplength@b}{\bbroraclevdistance-\baselineskip}
+ \node[inner sep=0pt,below right=\@bb@tmplength@b and \bbroraclehdistance of \@bb@lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
}{
-% \node[below0.05cm of \bbroraclenodenameprefix \@bb@lastoracle.south west, anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
% compute distance of top of last box to bottom of last oracle
\coordinate (@bbtmpcoord) at (\@bb@lastbox.north east);
\path (@bbtmpcoord);
@@ -1028,8 +1095,8 @@ $\begin{aligned}#2\end{aligned}$%
\coordinate (@bbtmpcoord) at (\bbroraclenodenameprefix \@bb@lastoracle.south west);
\path (@bbtmpcoord);
\pgfgetlastxy{\XCoord}{\YCoordB}
- \setlength{\@bb@tmplength@b}{\YCoordA-\YCoordB}
- \node[below right=\@bb@tmplength@b and \bbroracledistance of \@bb@lastbox.north east] (\bbroraclenodenameprefix#1) \bgroup
+ \setlength{\@bb@tmplength@b}{\YCoordA-\YCoordB+\bbroraclevdistance}
+ \node[inner sep=0pt,below right=\@bb@tmplength@b and \bbroraclehdistance of \@bb@lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup
}
\global\def\@bb@lastoracle{#1}
\begin{bbrenv}{#1}
@@ -1041,6 +1108,47 @@ $\begin{aligned}#2\end{aligned}$%
\endgroup
}
+
+\newcommand*\bbrchallengerhdistance{1.5cm}
+\newcommand*\bbrchallengervdistance{\baselineskip}
+\define@key{bbrchallenger}{distance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
+\define@key{bbrchallenger}{hdistance}[]{\renewcommand*\bbrchallengerhdistance{#1}}
+\define@key{bbrchallenger}{vdistance}[]{\renewcommand*\bbrchallengervdistance{#1}}
+
+
+% Challenger
+\newenvironmentx{bbrchallenger}[2][2=]{%
+\begingroup%
+\setkeys{bbrchallenger}{#2}%
+%add to nesting cout
+\addtocounter{@bb@challenger@nestcnt}{1}%
+%if first oracle, then put it to the right, else stack them vertically
+\addtocounter{@bb@challenger@cnt}{1}%
+\ifthenelse{\value{@bb@challenger@cnt}=1}{%
+\setlength{\@bb@tmplength@b}{\bbrchallengervdistance-\baselineskip}%
+\node[inner sep=0pt,below left=\@bb@tmplength@b and \bbrchallengerhdistance of \@bb@lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
+}{%
+\coordinate (@bbtmpcoord) at (\@bb@lastbox.north west);%
+\path (@bbtmpcoord);%
+\pgfgetlastxy{\XCoord}{\YCoordA}%
+\coordinate (@bbtmpcoord) at (\bbrchallengernodenameprefix \@bb@lastchallenger.south east);%
+\path (@bbtmpcoord);%
+\pgfgetlastxy{\XCoord}{\YCoordB}%
+\setlength{\@bb@tmplength@b}{\YCoordA-\YCoordB+\bbrchallengervdistance}%
+\node[inner sep=0pt,below left=\@bb@tmplength@b and \bbrchallengerhdistance of \@bb@lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup%
+}%
+\global\def\@bb@lastchallenger{#1}
+\begin{bbrenv}{#1}%
+}{
+\end{bbrenv}%
+\egroup;%
+\addtocounter{@bb@challenger@nestcnt}{-1}%
+\endgroup%
+\let\msgfrom\bbrchallengerqueryto%
+}
+
+
+
\newcommandx{\bbrinput}[2][1=0.75cm]{%
\node[above right=#1 of \@bb@lastbox.north west] (input) {#2};
\draw[->] (input) --++ (0,-0.75cm);
@@ -1056,7 +1164,7 @@ $\begin{aligned}#2\end{aligned}$%
%temporary lengths
\newlength{\@bb@com@tmpoffset}
\newlength{\@bb@tmplength@b}
-\newcommand{\@bb@firstmessageheight}{-0.15cm}
+\newcommand{\@bb@firstmessageheight}{0.25\baselineskip}
\newcommand{\@bb@msglength}{1.25cm}
\newcommand{\@bb@qrylength}{1.5cm}
@@ -1109,10 +1217,14 @@ $\begin{aligned}#2\end{aligned}$%
\tikzset{BBRCOM-EDGESTYLE/.style/.expand once=\bbrcomedgestyle}%
% increase space
- #3\baselineskip
- \ifthenelse{\equal{\bbrcomtop}{}}{}{#3\baselineskip}
+ \ifthenelse{\lengthtest{#2<\@bb@firstmessageheight}}
+ {#3{\@bb@firstmessageheight}}
+ {
+ #3{0.75\baselineskip}
+ \ifthenelse{\equal{\bbrcomtop}{}}{}{#3{0.75\baselineskip}}
+ }
- \setlength{\@bb@com@tmpoffset}{#2+\@bb@firstmessageheight+\bbrcombeforeskip}%
+ \setlength{\@bb@com@tmpoffset}{#2+\bbrcombeforeskip}%
}
\newcommand{\@bb@comfinalize}[1]{
@@ -1152,14 +1264,32 @@ $\begin{aligned}#2\end{aligned}$%
\@bb@comfinalize{#4}
}
-\newcommand{\bbroraclequeryfrom}[1]{
+\newcommand{\bbroracleqryfrom}[1]{
\@bbroracleqry{#1}{->}{\@bb@oraclequery@hoffset}{\bbroracleqryspace}
}
-\newcommand{\bbroraclequeryto}[1]{
+\newcommand{\bbroracleqryto}[1]{
\@bbroracleqry{#1}{<-}{\@bb@oraclequery@hoffset}{\bbroracleqryspace}
}
+\newcommand{\@bbrchallengerqry}[4]{
+ \@bb@comsetup{#1}{#3}{#4}
+ %
+
+ \path[#2] (\@bb@lastchallenger.north east) -- ++ (0,-\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb@lastbox.west|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {};
+ %
+ \@bb@comfinalize{#4}
+}
+
+\newcommand{\bbrchallengerqryfrom}[1]{
+ \@bbrchallengerqry{#1}{<-}{\@bb@challengerquery@hoffset}{\bbrchallengerqryspace}
+}
+
+\newcommand{\bbrchallengerqryto}[1]{
+ \@bbrchallengerqry{#1}{->}{\@bb@challengerquery@hoffset}{\bbrchallengerqryspace}
+}
+
+
\newcommand*\bbrcomloopleft{}
\newcommand*\bbrcomloopright{}
@@ -1172,9 +1302,9 @@ $\begin{aligned}#2\end{aligned}$%
\begingroup % for local keys
\setkeys{bbrcomloop}{#3}%
- \path[->] (#1) edge[bend right=50] node[left] (bbrleft) {\bbrcomloopleft} (#2);
- \path[->] (#2) edge[bend right=50] node[right] (bbrright) {\bbrcomloopright} (#1);
- \node () at ($(bbrleft)!0.5!(bbrright)$) {\bbrcomloopcenter};
+ \path[->] (#1) edge[bend right=50] node[midway,left] (bbrleft) {\bbrcomloopleft} (#2);
+ \path[->] (#2) edge[bend right=50] node[midway,right] (bbrright) {\bbrcomloopright} (#1);
+ \node[at=($(bbrleft.north west)!0.5!(bbrright.north east)$),anchor=north]() {\bbrcomloopcenter};
\endgroup
}
@@ -1231,6 +1361,22 @@ $\begin{aligned}#2\end{aligned}$%
\@bbrintertext{#1}{below right}{north east}{\@bb@query@hoffset}{\bbrqryspace}{#2}
}
+\newcommand{\bbrchallengertxt}[2][]{
+\begingroup
+\setlength{\@bb@tmplength@b}{\bbrchallengerhdistance/2}%
+\renewcommand{\bbrintertexthoffset}{\the\@bb@tmplength@b}%
+ \@bbrintertext{#1}{below left}{north west}{\@bb@challengerquery@hoffset}{\bbrchallengerqryspace}{#2}
+\endgroup
+}
+
+\newcommand{\bbroracletxt}[2][]{
+\begingroup
+\setlength{\@bb@tmplength@b}{\bbroraclehdistance/2}%
+\renewcommand{\bbrintertexthoffset}{\the\@bb@tmplength@b}%
+ \@bbrintertext{#1}{below left}{north west}{\@bb@oraclequery@hoffset}{\bbroracleqryspace}{#2}
+\endgroup
+}
+
\newcommand{\bbrmsgspace}[1]{
\@pc@globaladdtolength{\@bb@message@hoffset}{#1}
}
@@ -1243,6 +1389,9 @@ $\begin{aligned}#2\end{aligned}$%
\@pc@globaladdtolength{\@bb@oraclequery@hoffset}{#1}
}
+\newcommand{\bbrchallengerqryspace}[1]{
+\@pc@globaladdtolength{\@bb@challengerquery@hoffset}{#1}
+}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1273,9 +1422,9 @@ $\begin{aligned}#2\end{aligned}$%
%%%%%%%%%%%%%%%%%%%%%%%
\NewEnviron{pcvstack}[1][]{%
% display minipage
-\ifthenelse{\equal{#1}{center}}{\begin{pccenter}}{}
-\begin{varwidth}[t]{15cm}\BODY\end{varwidth}
-\ifthenelse{\equal{#1}{center}}{\end{pccenter}}{}
+\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}}{}%
}
@@ -1512,7 +1661,7 @@ $\begin{aligned}#2\end{aligned}$%
}{\@pc@releaseremember\endgroup}
\createpseudocodecommand{gameprocedure}
- {\stepcounter{pcgamecounter}}
+ {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}}
{\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}}
{}
@@ -1524,6 +1673,7 @@ $\begin{aligned}#2\end{aligned}$%
\newcommand{\bxgameprocedure}{
\begingroup%
\renewcommand{\@withinspaces}{false}%
+\renewcommand{\@withingame}{true}%
\renewcommand{\@withinbxgame}{true}%
\stepcounter{pcgamecounter}%
\@ifnextchar[%]
@@ -1531,15 +1681,13 @@ $\begin{aligned}#2\end{aligned}$%
{\@bxgame@pseudocodeB}%
}
+\newcommand{\@pc@secondheader}{}
+
%tbx top boxed
\createpseudocodecommand{tbxgameprocedure}
- {\addtocounter{pcgamecounter}{1}%
-\xdef\@pcfirstgamename{\thepcgamecounter}%
-\addtocounter{pcgamecounter}{1}%
-\xdef\@pcsecgamename{\thepcgamecounter}%
-}
- {\ensuremath{\pcgamename_{\@pcfirstgamename}\gameprocedurearg}%
-\ \setlength{\fboxsep}{3pt}\protect\fbox{\ensuremath{\pcgamename_{\@pcsecgamename}\gameprocedurearg}}}
+ {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}%%
+\renewcommand{\@pc@secondheader}{true}}
+ {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}}
{}