Illustrating symmetric key distribution

Yes, you can.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta}
\newcounter{pft}
\begin{document}
\begin{tikzpicture}[font=\sffamily,pics/cgram/.style={code={
\foreach \XX [count=\YY starting from 0] in {1,...,#1}
{\pgfmathsetmacro{\mycolor}{{\LstCols}[\YY]}
\node[circle,draw,minimum size=2.5em,fill=\mycolor] (c-#1-\XX) at 
({{\LstAngles}[#1-2]-\YY*360/#1}:1.5) {\setcounter{pft}{\XX}\Alph{pft}};}
\foreach \XX [evaluate=\XX as \Ymax using {int(\XX-1)}] in {2,...,#1}
{\foreach \YY  in {1,...,\Ymax}
{\pgfmathsetmacro{\mycolorA}{{\LstCols}[\XX-1]}
\pgfmathsetmacro{\mycolorB}{{\LstCols}[\YY-1]}
\path (c-#1-\XX) -- (c-#1-\YY) coordinate[pos=0.1] (aux0) coordinate[pos=0.9] (aux1);
\fill[black] (aux0) to[bend left=2] (aux1) to[bend left=2] (aux0);
\draw[{Stealth[fill=\mycolorB,length=7pt,inset=2pt]}-{Stealth[fill=\mycolorA,length=7pt,inset=2pt]}] (c-#1-\XX) -- (c-#1-\YY);
}}}}]
\def\LstCols{"red","orange","yellow","green!70!black","blue!70!white","purple!80!white"}
\def\LstAngles{180,150,135,128,150}
\path (-5,0) pic {cgram=2} (0,0.5) pic {cgram=3} (5,0) pic {cgram=4}
 (-3,-4) pic {cgram=5}  (3,-4) pic {cgram=6};
\end{tikzpicture}
\end{document}

enter image description here

Zoom in:

enter image description here

And yes, for large numbers N of nodes it becomes busy, simply since the number of connections goes like N (N-1)/2.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta}
\definecolor{colorA}{RGB}{202, 38, 49} 
\definecolor{colorB}{RGB}{222, 146, 60} 
\definecolor{colorC}{RGB}{240, 215, 68} 
\definecolor{colorD}{RGB}{126, 183, 86} 
\definecolor{colorE}{RGB}{98, 173, 233} 
\definecolor{colorF}{RGB}{158, 76, 150}  
\newcounter{pft}
\tikzset{pics/cgram/.style={code={
\foreach \XX [count=\YY starting from 0] in {1,...,#1}
{\pgfmathtruncatemacro{\iA}{mod(\XX-1,6)+1}
\pgfmathsetmacro{\mycolor}{{\LstCols}[\iA-1]}
\node[circle,draw,minimum size=2.5em,fill=\mycolor] (c-#1-\XX) at 
({-\YY*360/#1}:\pgfkeysvalueof{/tikz/cgram radius}) {\setcounter{pft}{\iA}\Alph{pft}};}
\foreach \XX [evaluate=\XX as \Ymax using {int(\XX-1)}] in {2,...,#1}
{\foreach \YY  in {1,...,\Ymax}
 {\pgfmathtruncatemacro{\iA}{mod(\XX-1,6)+1}
  \pgfmathtruncatemacro{\iB}{mod(\YY-1,6)+1}
  \pgfmathsetmacro{\mycolorA}{{\LstCols}[\iA-1]}
  \pgfmathsetmacro{\mycolorB}{{\LstCols}[\iB-1]}
 \draw[{Stealth[fill=\mycolorB,length=7pt,inset=2pt]}-{Stealth[fill=\mycolorA,length=7pt,inset=2pt]}] (c-#1-\XX) -- (c-#1-\YY);
}}
}},cgram radius/.initial=1.5}
\begin{document}
\foreach \Nmax in {2,4,...,40}
{\begin{tikzpicture}[font=\sffamily]
\draw (-11,-11) rectangle (11,11);
\def\LstCols{"colorA","colorB","colorC","colorD","colorE","colorF"}
\pgfmathsetmacro{\myradius}{sqrt(2.5*\Nmax)}
\path  pic[cgram radius=\myradius] {cgram=\Nmax};
\end{tikzpicture}}
\end{document}

enter image description here


So this is my construction for future references.

\documentclass[border=9,tikz,rgb]{standalone}

\usetikzlibrary{arrows.meta,decorations.pathreplacing}
\begin{document}

\tikzset{
    /pgf/arrow keys/colorsize/.style={fill=#1,length=10pt}
}
\def\N{70}
\tikzdeclarecoordinatesystem{sunflower}{ % #1 is the index of vertex
    \pgfmathsetmacro\sunindex{#1-.5}
    \pgfmathsetmacro\sunangle{mod(\sunindex*16.18034,10)*36}
    \pgfmathsetmacro\sunradius{sqrt(\sunindex)*50}
    \pgfpointpolar{\sunangle}{\sunradius}
}
\globalcolorstrue
\def\definesuncolor#1{
    \pgfmathtruncatemacro\sunindex{#1-.5}
    \pgfmathsetmacro\sunhue{mod(\sunindex*16.18034,10)*36}
    \pgfmathsetmacro\sunsaturation{sqrt(\sunindex/\N)}
    \definecolor{sun#1}{Hsb}{\sunhue,\sunsaturation,1}
}
\tikz{
    \foreach\i in{1,...,\N}{
        \definesuncolor{\i}
        \path(sunflower cs:\i)node(vertex\i)
            [circle,draw,minimum size=2cm,line width=6pt]{};
        \fill[sun\i](vertex\i)+(1pt,1pt)circle(1);
    }
    \foreach\i in{2,...,\N}{
        \foreach\j in{1,...,\numexpr\i-1}{
            \path[scale=.666/sqrt(\N)]
                [shift=(vertex\i)](sunflower cs:\j)coordinate(X-\i-\j)
                [shift=(vertex\j)](sunflower cs:\i)coordinate(Y-\i-\j);
            \draw[{Stealth[colorsize=sun\j]}-{Stealth[colorsize=sun\i]}]
                [line width=.1](X-\i-\j)--(Y-\i-\j);
        }
    }
    \foreach\i in{2,...,\N}{
        \foreach\j in{1,...,\numexpr\i-1}{
            \draw[{Stealth[colorsize=sun\j]}-{Stealth[colorsize=sun\i]}]
                [dash pattern=on0off9999](X-\i-\j)--(Y-\i-\j);
        }
    }
}

\end{document}

Some comments to whomever wants to play with this:

  • sunflower is the coordinate system that controls how to place vertices. It is the same algorithm that sunflower uses to place its seeds. See wikipedia
  • The color of each vertex is control by \definesuncolor#1. Currently it is defined such that the sunflower looks like the HSB wheel.
  • There are two nested-for-loops at the end. The former loop draws the edge, the later loop draws the arrow tips.
  • The position of arrow tip is controlled by (X-\i-\j) and (Y-\i-\j). Currently they are the relative positions of the vertices. So the arrows tips on each vertex also looks like the HSB wheel.