答案1
一种方法是使用cryptocode
包裹。
例如:
\documentclass{article}
\usepackage[operators,sets]{cryptocode}
\usepackage{amsmath}
\begin{document}
\pseudocodeblock{
\textbf{A} \<\< \textbf{B}
\\[0.1\baselineskip][\hline] \\[-0.5\baselineskip]
P = H_1(ID_a, ID_B, \pi) \\
r_A \in_R \ZZ_q \\
\dots \\
\< \sendmessageright*{m} \\
\<\< \text{Check } m \neq 0 \in G \\
\<\< \dots \\
\< \sendmessageleft*{t_B, k} \\
}
\end{document}
答案2
非常基本的方法:使用表格来组织图表,amsmath
用于“Alicw”和“Bob”的表达式以及tikz
Alice 和 Bob 之间的箭头:
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
quotes}
\tikzset{auto,
> = Straight Barb,
every path/.style = {semithick}
}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\usepackage{bm}
\begin{document}
\begin{tblr}{hline{1,Z} = {solid, 1pt},
colspec = { Q[c,$] c Q[c,$] },
row{1-3} = {mode=text},
row{4-Z} = {rowsep=1ex}
}
\SetCell[c=3]{l} some text \\
\SetCell[c=3]{l} some text \\
\SetCell[c=3]{l} some text \\
A & & B \\
\begin{gathered}[b]
a=b\\
c=d
\end{gathered}
& \tikz\draw[->] (0,0) to ["$m$"] (2.3,0);
& \begin{gathered}[t]
expression = 1\\
expression = 2\\
expression = 3\\
expression = 4
\end{gathered} \\
\bm{Z}=t_B^{r_A}
& \tikz\draw[<-] (0,0) to ["$k'$"] (2.3,0);
& k=H_2(ID_A,ID_B,m,t_B,\bm{Z},\bm{P}) \\
\begin{gathered}[b]
k\overset{?}{=}H_2(ID_A,ID_B,m,t_B,\bm{Z},\bm{P})\\
k'=H_3(ID_A,ID_B,m,t_B,\bm{Z},\bm{P})\\
\bm{K}=H_4(ID_A,ID_B,m,t_B,\bm{Z},\bm{P})
\end{gathered}
& \tikz\draw[->] (0,0) to ["$m$"] (2.3,0);
& \begin{gathered}[t]
expression = 1\\
expression = 2\\
expression = 3
\end{gathered} \\
\end{tblr}
\end{document}
单元格中的正确内容需要您自己编写。