6

I am quite new to latex. As part of a course we are required to submit different variations of protocols using the regulars Alice, Bob and Trudy.

I was wondering if it is possible to produce something similar to: this http://images.slideplayer.us/5/1532038/slides/slide_44.jpg

So far, I am able to display images using \includegraphics and \overleftarrow/overright arrow from mathml. But the arrows are at the bottom of the image and successive arrows are on a single straight line.

I am not sure how to break them and align them vertically.

7

TiKZ is one option

\documentclass[border=2mm,tikz]{standalone}

\usepackage{mwe}
\usepackage{amsmath}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[>=stealth]
\node[ label=below:{Alice: $K, a$}] (A) {\includegraphics[width=2cm,keepaspectratio]{example-image-a}};
\node[right=5cm of A, label=below:{Bob: $K, b$}] (B) {\includegraphics[width=2cm,keepaspectratio]{example-image-b}};
\draw[->,thick] (A.20) -- node[above]{$E(g^a\ \text{mod}\ p, K)$} (B.160);
\draw[<-,thick] (A.-20) -- node[above]{$E(g^b\ \text{mod}\ p, K)$} (B.-160);
\end{tikzpicture}
\end{document}

enter image description here

but you can find some other options (msc, pstricks, ...) searching here:

although there is no need to use them, you can use tabulars to do it

\begin{tabular}{ccc}
\includegraphics[width=2cm,keepaspectratio]{example-image-a} & 
\raisebox{5ex}{%
   \begin{tabular}{c}
   $\underrightarrow{\quad E(g^a\ \text{mod}\ p, K)\quad}$\\
   $\underleftarrow{\quad E(g^b\ \text{mod}\ p, K)\quad}$
   \end{tabular}} &
\includegraphics[width=2cm,keepaspectratio]{example-image-b} \\
Alice: $K, a$ & & Bob: $K, b$\\
\end{tabular}

enter image description here

Update:

I just wanted to mention tikzpeople package which was designed to draw more colorfull security protocols. With default alice and bob you obtain:

\documentclass[border=2mm,tikz]{standalone}

\usepackage{tikzpeople}
\usetikzlibrary{positioning}
\usepackage{amsmath}

\begin{document}

\begin{tikzpicture}[>=stealth]
\node[alice, minimum size=2cm,label=below:{Alice: $K, a$}] (alice) {};
\node[bob, mirrored, minimum size=2cm, right=5cm of alice, label=below:{Bob: $K, b$}] (bob) {};
\draw[->,thick] (alice.20) -- node[above]{$E(g^a\ \text{mod}\ p, K)$} (bob.160);
\draw[<-,thick] (alice.-20) -- node[above]{$E(g^b\ \text{mod}\ p, K)$} (bob.-160);
\end{tikzpicture}
\end{document}

enter image description here

But you can use some other characters like following ones and some other ones

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.