I'm currently struggling on how to create this picture on TikZ. I cant seem to be able to draw the arrows properly and I cant figure out how to be able to make "columns" to make the private and public. Any help is appreciated. Thank you.enter image description here

  • 4
    Hello! Please provide the code you have written so far. It may help you getting an answer. – Roland Nov 25 '20 at 0:58

Maybe you want to consider tikzpeople package to draw this kind of schemes


\begin{tikzpicture}[mylabel/.style={text width=8 mm, align=center}]
\node[bob, minimum width=1.5cm, 
    label={[mylabel, anchor=west]north east:{Public\\ n, e}}, 
    label={[mylabel, anchor=east]north west:{Private\\ d}}] (bob) {Bob};
\node[alice, minimum width=1.5cm, right=5cm of bob, mirrored,
    label={[mylabel, anchor=east]north west:{Public}}, 
    label={[mylabel, anchor=west]north east:{Private\\ M}}] (alice) {Alice};

\draw[->, thick, blue] ([yshift=2mm]bob.east) coordinate(aux-a)-- coordinate[near start] (aux) node[above, text width=1.5cm, align=center]{Alice reads e and n} (aux-a-|alice.west);

\draw[<-, thick, blue] ([yshift=-2mm]bob.east) coordinate(aux-b)-- node[below, text width=1.5cm, align=center]{Alice sends M'} coordinate[near end] (auxtwo) (aux-b-|alice.west);

\node[devil, minimum width=1.5cm, below right=5mm and 2cm of bob] (eve) {Eve};
\draw[->,red, ultra thick] (eve-|aux)--(aux);
\draw[->,red, ultra thick] (eve-|auxtwo)--(auxtwo);

enter image description here

  • 1
    Nice, attractive image! +1 – Zarko Nov 25 '20 at 8:49
  • 1
    Superb suggestion.... – MadyYuvi Nov 25 '20 at 9:21
  • ...but the evil ...it is very ugly :-(((((((( + 1 :-)))) – Sebastiano Nov 25 '20 at 22:51
  • Wow. This is very well done. Do you have any recommendations for sources I can check out on how to get better and using TikZ? We briefly went over it in my class, but we didn't get to do too much regarding it and it was quite confusing. Thank you for your work! – TurbulentLamp Nov 26 '20 at 23:57

You can start with this:


    \def\rectanglepath{-- ++(5cm,0cm)  -- ++(0cm,5cm)  -- ++(-5cm,0cm) -- cycle}
    \draw (0,0) \rectanglepath;
    \node at (2.5,4) {Bob};
    \node at (1.5,3) {private};
    \node at (3.5,3) {public};
    \node at (1.5,2.5) {d};
    \node at (3.5,2.5) {n,e};
    \node at (5.9,3) {$\xrightarrow{\makebox[1.6cm]{\minibox{Alice reads\\ e and n}}}$};

    \draw (7,0) \rectanglepath;
    \node at (9.5,4) {Alice};
    \node at (8.5,3) {private};
    \node at (10.5,3) {public};
    \node at (10.5,2.5) {M};
    \node at (6.2,1.5) {$\xleftarrow{\makebox[1.5cm]{\minibox{Alice\\ sends\\ M}}}$};
    \draw (2.4,3.5) .. controls (3,2) and (3,2) .. (2.2,0.3);
    \draw (9.6,3.5) .. controls (9.5,2) and (9.2,2) .. (10.2,0.3);
    \draw[red] (5.2,2.6) -- (5.2,-1); %red lines
    \draw[red] (6.2,0.9) -- (6.2,-1); %red lines
    \def\rectanglepath{-- ++(2cm,0cm)  -- ++(0cm,2cm)  -- ++(-2cm,0cm) -- cycle}
    \draw (4.6,-3) \rectanglepath;
    \node at (5.6,-2) {Eve};


enter image description here

What control does:

Point 1 and 2 are the endpoints of the line [red] and the curve. C1 and C2 are the control points of the curve. They attract the line into their direction, like magnets would do.

enter image description here



    \draw[red](0,0) -- (4,4);
    \draw (0,0) .. controls (0,4) and (4,0) .. (4,4);
    \draw [black, fill=white]  (0,0) circle (3pt) node[right] {1};%1st endpoint
    \draw [black, fill=white]  (4,4) circle (3pt) node[right] {2};%2st endpoint
    \draw [black, fill=white]  (0,4) circle (3pt) node[right] {C1};%controlpoint 1
    \draw [black, fill=white]  (4,0) circle (3pt) node[right] {C2};%controlpoint 2
    \draw[->, thick] (0.8,2) -- (0,3.9);
    \draw[->, thick] (3.4,2) -- (4,0.2);

  • Thank you for your work! You really know your stuff! Just one question though: what does the controls command do? – TurbulentLamp Nov 26 '20 at 23:59
  • Hello! I edited the answer to explain the control command. – Roland Nov 27 '20 at 0:29

Using @Roland answer as starting point (as OP MWE) and employ relative positioning of image elements:

\documentclass[tikz, margin=3mm]{standalone}

node distance = 3mm and 1mm,
     B/.style = {align=center},
     E/.style = {B, draw, inner xsep=3mm},
   FIT/.style = {draw, fit=#1},
     N/.style = {B, font=\large\bfseries},
  every edge quotes/.style = {auto, font=\small, align=center},
every edge/.style = {draw=gray, very thick, -{Straight Barb[scale=0.5]},
                    shorten >=2mm}, 
\node[N] (bob)   {Bob}; 
\node[B,below  left=of bob] (b1) {private\\ d};
\node[B,below right=of bob] (b2) {public\\ n, e};
\coordinate[below=of b1.south -| bob] (bob');
    \draw (bob) to [bend left] (bob');
\node[FIT=(bob) (b1) (b2)  (bob')] (fitL) {};
      right=44mm of bob -| fitL.east] (alice) {Alice};
\node[B,below  left=of alice] (a1) {private\\ d};
\node[B,below right=of alice] (a2) {public\\ n, e};
\coordinate[below=of a1.south -| alice] (alice');
    \draw (alice) to [bend right] (alice');
\node[FIT=(alice) (a1) (a2) (alice')] (fitR) {};
% messages
\draw   ([yshift= 5mm] fitL.east)    coordinate (fL)
            edge ["Alice reads\\ e and n"]  (fL -| fitR.west)
        ([yshift=-5mm] fitR.west)    coordinate (fR)
            edge ["Alice sends\\ M'" ']     (fR -| fitL.east);
% eve
\node[E, below=of $(fitL.south east)!0.5!(fitR.south west)$]  (eye) {Eve};
% looks
\draw[red, semithick, dashed]
        ([xshift=-2mm] eye.north) -- ([xshift= 3mm] fL)
        ([xshift= 2mm] eye.north) -- ([xshift=-3mm] fR);

enter image description here

  • Thank you for taking the time to respond to my post! Your work is great! Do you have any advice as to how I can get better at using TikZ? I just don't understand where to look or what to do to be able to use that many commands in TikZ. If I'm being honest, I'm still quite lost on how to use TikZ. – TurbulentLamp Nov 27 '20 at 0:01
  • @TurbulentLamp, experiences show, that the best way to learn TikZ is learning-by-doing. In this can help read package documentation (it is a detailed in so huge), for start the first tutorial, than part III (TikZ ist kein Zeichenprogramm) and than look libraries. Some inspiration how to draw something, see texample.net. When you stuck in some problem, ask in SE for help. Happy TeXing! – Zarko Nov 27 '20 at 2:27

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.