# Cryptocode: how to place the oracle and place its arrows?

How the result should look like:

How it looks like right now:

I marked the problem with yellow on both images. Here is my MWE:

\documentclass[a4paper]{article}
\usepackage{mathtools}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{cryptocode}
\newcommand{\gen}{\text{Gen}}

\begin{document}

\begin{bbrenv}{A}
\begin{bbrbox}[name=$\mathcal{C}_\text{PRF}$]
\pseudocode{%
K \leftarrow \gen(1^n)\\
b \xleftarrow{r} \{0,1\}\\
\text{Wenn } b = 0\\
\text{Wenn } b = 0\\
\text{Wenn } b' = b\\
\text{Wenn } b' \neq b\\
}
\end{bbrbox}
\begin{bbroracle}{OraA}
\begin{bbrbox}[name=$\vartheta_b(\cdot)$]
\end{bbrbox}
\end{bbroracle}
\begin{bbroracle}{OraB}
\begin{bbrbox}
\pseudocode{
x = 1 \quad a+b \rightarrow b\\
\text{Wenn } b' = 0\\
\text{Ansonsten } b' = 1\\
\text{Ausgabe } b'
}
\end{bbrbox}
\end{bbroracle}
\bbroracleqryfrom{top=$x$}
\bbroracleqryto{top={$y$}}
\bbroracleqryfrom{top=$b'$}
\end{bbrenv}

\end{document}


Do you think I could do it with bbrev? I am lost, hope you can help.

I'm not familiar with the cryptocode package, so for me is simpler to draw this algorithm with tikz package:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
positioning,
quotes}
\usepackage{mathtools, amssymb}
\DeclareMathOperator{\gen}{gen}
\DeclareMathOperator{\PRF}{PRF}

\begin{document}
\begin{tikzpicture}[auto,
box/.style = {draw, minimum height=17mm, align=left, outer sep=0pt},
lbl/.style = {anchor=south east, outer sep=1mm},
pin edge = {Straight Barb-, draw=black},
every edge/.style = {draw, semithick, -Straight Barb}
]
\node (n1)  [box,
label={[lbl] south east:$\mathcal{C}_{\PRF}$},
pin=$1^n$]
{\begin{aligned} K \leftarrow \gen(1^n) \\ b \xleftarrow{r} \{0,1\} \\ \text{Wenn } b = 0 \text{ denn } \vartheta_0 = F_K(\cdot) \\ \text{Wenn } b = 1 \text{ denn } \vartheta_1 = f(\cdot) \\[1ex] \text{Wenn } b' = b \text{return } 1\\ \text{Wenn } b' \neq b \text{ return } 0\\[5ex] \end{aligned}
};
\node (n2)  [box, above right=-1ex and 0pt of n1.east]
{$\vartheta_b(\cdot)$};
\node (n3)  [box,
label={[lbl]south east:$\mathcal{A}$},
pin=???,
right=9mm of n1 -| n2.east]
{\begin{aligned} x = 0 \quad b \\ x = 1 \quad a+b \rightarrow b \\ x = 2 \quad 2a+b \\[1ex] \text{Wenn } b' = 0 \\ \text{ sonst } b' = 1 \\ \text{ return } b' \\[5ex] \end{aligned}
};
\draw   ([yshift=+2mm] n2.east) coordinate (aux1) edge["$x$"] (aux1 -| n3.west)
([yshift=-2mm] n2.east) coordinate (aux2) (aux2 -| n3.west) edge["$y$"] (aux2)
([yshift=-7ex] n3.west) edge["$b'$" '] ([yshift=-7ex] n1.east);
\end{tikzpicture}
\end{document}

• Thank you very much ... could you please create those $1^n$ with the arrow above the boxes that point at them? I have a lot of similar figures I have to generate, would be nice, thank you. <3 Commented Jun 22, 2020 at 19:34
• @KuroiRyū, sorry, but this part of image is not well visible, especially not at right box :-(. I will add this for the left box asap. Commented Jun 22, 2020 at 19:52
• @KuroiRyū, done. Commented Jun 22, 2020 at 20:33
• Thank you very much! Commented Jun 22, 2020 at 20:39