加密协议,执行示例

加密协议,执行示例

有没有一种简单(甚至困难)的方法来绘制加密协议的执行示例?我正试图在我的硕士论文中写关于 BB84 的内容,我正在寻找类似这样的内容:

在此处输入图片描述

或这个:

在此处输入图片描述

我认为最好的方法是使用表格,但我真的很纠结。提前谢谢!

编辑 1:和往常一样,我忘了输入一些代码。抱歉!

\begin{tabular}{ |p{4cm} |p{1cm}|p{1cm}|p{1cm}||p{1cm}|  }
\hline
 & 1 & 2 & 3 & 4 \\
\hline
\textbf{(1)} Alice's bitstring & 0 & 1 & 1 & 0   \\
\textbf{(1)} Alice's bases & 1 & 1 & 0 & 0   \\
\textbf{(2)} Qubits sent & $\ket{+}$ & $\ket{-}$ & $\ket{1}$ & $\ket{0}$   \\
\textbf{(3)} Bob's bases & 1 & 0 & 1 & 0\\
\textbf{(3)} Bob's measuring results & \textbf{0} & 0 & 1 & \textbf{0}\\
\hline
\end{tabular}

主要问题是最后两行。

答案1

也许是这样的:

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz, array, booktabs, amsmath, amssymb}
\usetikzlibrary{arrows.meta, calc}

\tikzset{tinyarrs/.style={
    x=.5em, y=.5em, baseline=-.333em,
    every path/.style={arrows={Latex[length=2pt, width=2pt]-Latex[length=2pt, width=2pt]}}
}}

\newcommand{\nsArrow}{\tikz[tinyarrs]{
    \path(0:0)circle(1);
    \draw(90:-1)--(90:1);
}}
\newcommand{\ewArrow}{\tikz[tinyarrs]{
    \path(0:0)circle(1);
    \draw(0:-1)--(0:1);
}}
\newcommand{\nsewArrow}{\tikz[tinyarrs]{
    \path(0:0)circle(1);
    \draw(90:-1)--(90:1);
    \draw(0:-1)--(0:1);
}}
\newcommand{\acArrow}{\tikz[tinyarrs]{
    \path(0:0)circle(1);
    \draw(45:-1)--(45:1);
}}
\newcommand{\bdArrow}{\tikz[tinyarrs]{
    \path(0:0)circle(1);
    \draw(135:-1)--(135:1);
}}
\newcommand{\acbdArrow}{\tikz[tinyarrs]{
    \path(0:0)circle(1);
    \draw(45:-1)--(45:1);
    \draw(135:-1)--(135:1);
}}

\newcommand{\drawtabbox}[1][black]{%
    \tikz[overlay, remember picture]{
        \draw[#1]([shift={(-.5em,1em)}]0,0) rectangle ++({width("0")*1pt+1em},-2.66em);
    }%
}

\newcommand{\isit}{\overset{{\color{purple}?}}{=}}

\begin{document}

\begin{tabular}{ m{35pt} c c c c c c c }

\toprule

$k$ & 
    \textcolor{lightgray}{$0$} & 
    \textcolor{darkgray}{$1$} & 
    \textcolor{darkgray}{$1$} & 
    \textcolor{darkgray}{$1$} & 
    \textcolor{lightgray}{$0$} & 
    \textcolor{lightgray}{$0$} & 
    \textcolor{darkgray}{$1$} \\
    
\midrule

$b$ & 
    \textcolor{LimeGreen!50!PineGreen}{$1_{\scriptsize\acbdArrow}$} & 
    \textcolor{LimeGreen!50!PineGreen}{$1_{\scriptsize\acbdArrow}$} &
    \textcolor{CornflowerBlue!50!RoyalBlue}{$0_{\scriptsize\nsewArrow}$} &
    \textcolor{LimeGreen!50!PineGreen}{$1_{\scriptsize\acbdArrow}$} &
    \textcolor{CornflowerBlue!50!RoyalBlue}{$0_{\scriptsize\nsewArrow}$} &
    \textcolor{CornflowerBlue!50!RoyalBlue}{$0_{\scriptsize\nsewArrow}$} &
    \textcolor{CornflowerBlue!50!RoyalBlue}{$0_{\scriptsize\nsewArrow}$} \\

\scriptsize Alice \newline prepares & 
    \textcolor{LimeGreen}{\acArrow} & 
    \textcolor{PineGreen}{\bdArrow} & 
    \textcolor{RoyalBlue}{\nsArrow} & 
    \textcolor{PineGreen}{\bdArrow} & 
    \textcolor{CornflowerBlue}{\ewArrow} & 
    \textcolor{CornflowerBlue}{\ewArrow} &
    \textcolor{RoyalBlue}{\nsArrow} \\

$q$ & 
    \textcolor{LimeGreen}{$|+\rangle$} &
    \textcolor{PineGreen}{$|-\rangle$} & 
    \textcolor{RoyalBlue}{$|1\rangle$} & 
    \textcolor{PineGreen}{$|-\rangle$} & 
    \textcolor{CornflowerBlue}{$|0\rangle$} & 
    \textcolor{CornflowerBlue}{$|0\rangle$} & 
    \textcolor{RoyalBlue}{$|1\rangle$} \\

\midrule

$\tilde{b}$ &
    \textcolor{LimeGreen!50!PineGreen}{$1_{\scriptsize\acbdArrow}$} & 
    \textcolor{CornflowerBlue!50!RoyalBlue}{$0_{\scriptsize\nsewArrow}$} &
    \textcolor{CornflowerBlue!50!RoyalBlue}{$0_{\scriptsize\nsewArrow}$} &
    \textcolor{LimeGreen!50!PineGreen}{$1_{\scriptsize\acbdArrow}$} &
    \textcolor{LimeGreen!50!PineGreen}{$1_{\scriptsize\acbdArrow}$} &
    \textcolor{CornflowerBlue!50!RoyalBlue}{$0_{\scriptsize\nsewArrow}$} &
    \textcolor{LimeGreen!50!PineGreen}{$1_{\scriptsize\acbdArrow}$} \\

\scriptsize Bob \newline measures & 
    \textcolor{LimeGreen}{\acArrow} & 
    \textcolor{CornflowerBlue}{\ewArrow} & 
    \textcolor{RoyalBlue}{\nsArrow} & 
    \textcolor{PineGreen}{\bdArrow} & 
    \textcolor{LimeGreen}{\acArrow} & 
    \textcolor{CornflowerBlue}{\ewArrow} &
    \textcolor{LimeGreen}{\acArrow} \\ 

$\tilde{q}$ &
    \textcolor{LimeGreen}{$|+\rangle$} &
    \textcolor{CornflowerBlue}{$|0\rangle$} & 
    \textcolor{RoyalBlue}{$|1\rangle$} & 
    \textcolor{PineGreen}{$|-\rangle$} & 
    \textcolor{LimeGreen}{$|+\rangle$} &
    \textcolor{CornflowerBlue}{$|0\rangle$} & 
    \textcolor{LimeGreen}{$|+\rangle$} \\
    
\midrule

$\tilde{k}$ &
    \drawtabbox[purple]\textcolor{lightgray}{$0$} & 
    \textcolor{lightgray}{$0$} & 
    \drawtabbox[purple]\textcolor{darkgray}{$1$} & 
    \drawtabbox[purple]\textcolor{darkgray}{$1$} & 
    \textcolor{lightgray}{$0$} & 
    \drawtabbox[purple]\textcolor{lightgray}{$0$} & 
    \textcolor{lightgray}{$0$} \\

$b \isit \tilde{b}$ &
    \textcolor{purple}{\checkmark} & 
    \textcolor{purple}{--} & 
    \textcolor{purple}{\checkmark} & 
    \textcolor{purple}{\checkmark} & 
    \textcolor{purple}{--} & 
    \textcolor{purple}{\checkmark} & 
    \textcolor{purple}{--} \\
    
\bottomrule

\end{tabular}

\end{document}

在此处输入图片描述

相关内容