我在两张图片上都用黄色标记了问题。这是我的 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\\
\quad \vartheta_0 = F_K(\cdot)\\
\text{Wenn } b = 0\\
\quad \vartheta_1 = f(\cdot)\\
\text{Wenn } b' = b\\
\quad \text{return } 1\\
\text{Wenn } b' \neq b\\
\quad \text{return } 1\\
}
\end{bbrbox}
\begin{bbroracle}{OraA}
\begin{bbrbox}[name=$\vartheta_b(\cdot)$]
\end{bbrbox}
\end{bbroracle}
\begin{bbroracle}{OraB}
\begin{bbrbox}
\pseudocode{
x = 0 \quad b\\
x = 1 \quad a+b \rightarrow b\\
x = 2 \quad 2a+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}
你认为我可以用 bbrev 来做吗?我很困惑,希望你能帮助我。
答案1
我不熟悉该cryptocode
包,因此对于我来说,使用包绘制该算法更简单tikz
:
\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}