Dirac notation is the most common way to describe quantum states and operations on states.
It is very convenient and allows for quick visual distinction between vectors, scalars and operators.
For quantum processes that involve interactions of multiple systems an even better visualisation has been proposed by Coecke
and Kissinger, in the form of a diagrammatic formalism [3].
Their notation expresses formulas in the form of diagrams, somewhat similar to Feynman diagrams, and is more general than
the circuit notation for quantum computing.

This document consists of two parts.
We give a brief summary of the diagrammatic notation of quantum processes,
tailored to readers who already know quantum physics and are not interested in general process theory.
For this audience our summary is less daunting than the encyclopaedic book by Coecke and Kissinger [3],
and on the other hand more accessible than the ultra-compact introduction of [5].
We deviate a somewhat from [3, 5] in that
we do not assume basis states to equal their own complex conjugate;
this means that we do not use symmetric notation for basis states, and it leads us to explicitly show arrows on wires
where they are usually omitted.

(2) We extend the work of Kissinger, Tull and Westerbaan [5]
which gives a diagrammatic security proof for BB84 and 6-state Quantum Key Distribution.
Their proof is based on a sequence of diagrammatic
manipulations that works when the bases used in the protocol are mutually unbiased.
We extend this result to 8-state encoding, which has been proposed as a tool in
quantum key recycling protocols [8, 6], and which does not
have mutually unbiased bases.

This manuscript is based on Zef Wolffs' bachelor thesis [9].

§ PURE STATES AND LINEAR OPERATORS

In the diagrammatic notation of Coecke and Kissinger,
time flows from the bottom to the top, just like in Feynman diagrams.
Wires represent states.
Boxes of various shapes represent operations.
Hermitian conjugation ($\dagger$) corresponds to vertical flipping.
Complex conjugation (c.c.) is horizontal flipping.
Taking the transpose is a 180$^\circ$ rotation.

Pure states.
The preparation of a pure state $\ket\qj$ is depicted as a triangle with a thin directed wire departing from it upwards.
The corresponding bra $\ket\qj\dagg=\bra\qj$, i.e. taking the inner product with $\qj$, is depicted as a thin directed
wire terminating in the vertically flipped triangle. The arrow points towards the bra.

\begin{equation}
\label{braket}
\ket\qj \quad\equiv\quad
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (2) at (0, 1) {};
\node [style=none] (3) at (0, 1) {};
\node [style=StateRight] (4) at (0, 0) {\rotatebox{90}{$\psi$}};
\node [style=none] (5) at (0, -0.25) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (3.center) to (5.center);
\draw[->] (0,-0.25) -- (0,0.8);
\end{pgfonlayer}
\end{tikzpicture}
\quad\quad\quad\quad\quad\quad
\bra\qj \quad\equiv\quad
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (1) at (0, -1) {};
\node [style=EffectRight] (2) at (0, 0.25) {\rotatebox{0}{$\psi$}};
\node [style=none] (3) at (0, 0.25) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (1.center) to (3.center);
\draw[->] (0,-1) -- (0,-0.5);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

The picture below shows $\ket\qj$, $\bra\qj$, $\ket\qj^*$ and $\bra\qj^*$.
Note that the wire connected to $\ket\qj^*$ and $\bra\qj^*$ has a downward arrow.

\begin{equation}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=StateLeft] (0) at (-2, -2.1) {\rotatebox{180}{$\psi$}};
\node [style=StateRight] (1) at (2, -2.1) {\rotatebox{90}{$\psi$}};
\node [style=EffectRight] (2) at (2, 2.025) {\rotatebox{0}{$\psi$}};
\node [style=EffectLeft] (5) at (-2, 2) {\rotatebox{270}{$\psi$}};
\node [style=none] (10) at (1.5, 2.75) {};
\node [style=none] (11) at (-1.5, 2.75) {};
\node [style=none] (14) at (-1.5, 1.5) {};
\node [style=none] (15) at (1.5, 1.5) {};
\node [style=none] (16) at (1.5, -1.5) {};
\node [style=none] (17) at (-1.5, -1.5) {};
\node [style=none] (18) at (-1.5, -3) {};
\node [style=none] (19) at (1.5, -3) {};
\node [style=none] (20) at (-2.75, -1.5) {};
\node [style=none] (21) at (-2.75, 1.5) {};
\node [style=none] (22) at (2.75, -1.5) {};
\node [style=none] (23) at (2.75, 1.5) {};
\node [style=none] (24) at (0, 2.5) {c.c.};
\node [style=none] (25) at (0, -2.5) {c.c.};
\node [style=none] (26) at (2.5, 0) {$\dagger$};
\node [style=none] (27) at (-2.5, 0) {$\dagger$};
\node [style=none] (29) at (0, 0) {\small transpose};
\node [style=none] (30) at (2, -2.25) {};
\node [style=none] (31) at (2, 2.25) {};
\node [style=none] (32) at (-2, 2.25) {};
\node [style=none] (33) at (-2, -2.25) {};
\node [style=none] (34) at (-2, -1) {};
\node [style=none] (35) at (-2, 1) {};
\node [style=none] (36) at (2, 1) {};
\node [style=none] (37) at (2, -1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
%		\draw [style=blue dir, bend right] (10.center) to (11.center);
%		\draw [style=blue dir, in=510, out=-330] (11.center) to (10.center);
%		\draw [style=blue dir, bend right] (18.center) to (19.center);
%		\draw [style=blue dir, bend right=330] (19.center) to (18.center);
%		\draw [style=blue dir, bend left] (20.center) to (21.center);
%		\draw [style=blue dir, bend left=330] (21.center) to (20.center);
%		\draw [style=blue dir, bend right] (22.center) to (23.center);
%		\draw [style=blue dir, bend right=330] (23.center) to (22.center);
\draw [style=blue dir] (15.center) to (17.center);
\draw [style=blue dir] (17.center) to (15.center);
\draw [style=blue dir] (16.center) to (14.center);
\draw [style=blue dir] (14.center) to (16.center);
\draw (32.center) to (35.center);
\draw (33.center) to (34.center);
\draw (30.center) to (37.center);
\draw (31.center) to (36.center);
\draw[->] (2,-2) -- (2,-1.25);
\draw[->] (-2,-1) -- (-2,-1.4);
\draw[->] (2,1.25) -- (2,1.4);
\draw[->] (-2,1.6) -- (-2,1.3);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

Wires are sometimes labeled with the Hilbert space in which the state lives.
Basis states $\ket i$ in some orthonormal basis are often represented as a left-right symmetric shape, since their vector representation
is typically real-valued.
We will depart from this convention because we will be working with a set of bases that does not allow for such
simultaneous real-valued representation.
We depict the decomposition $\ket\qj=\sum_i \qj_i\ket i$ as

\begin{equation}
\label{basis}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (2) at (0, 1) {};
\node [style=none] (3) at (0, 1) {};
\node [style=StateRight] (4) at (0, 0) {\rotatebox{90}{$\psi$}};
\node [style=none] (5) at (0, -0.25) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (3.center) to (5.center);
\draw[->] (0,-0.25) -- (0,0.8);
\end{pgfonlayer}
\end{tikzpicture}
\quad=\quad \sum_i \qj_i\; \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (7) at (0, 1) {};
\node [style=none] (9) at (0, -0.25) {};
\node [style=StateRight] (10) at (0, 0) {\rotatebox{90}{i}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (7.center) to (9.center);
%		\draw[->] (0,0) -- (0,0.5);
\draw[->] (0,-0.25) -- (0,0.8);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

Note that a diagram may contain summations and scalar multiplications.
A different choice of basis is indicated as a different shading or colour of the basis triangles.
The `standard' basis is white.

Inner product.
The formula $\inprod{\qj}{\phi}^* = \inprod{\phi}{\qj}$ is depicted as

[style=StateLeft] (0) at (0.05, -0.75) ;
[style=EffectLeft] (2) at (-0.05, 0.75) ;
[style=none] (3) at (0, 0.75) $\psi$;
[style=none] (4) at (0, -0.75) $\phi$;

(3.center) to (4.center);
[->] (0,0.75) – (0,0.0);

[style=StateRight] (0) at (0.05, -0.75) ;
[style=EffectRight] (2) at (-0.05, 0.75) ;
[style=none] (3) at (0, 0.75) $\phi$;
[style=none] (4) at (0, -0.75) $\psi$;

(3.center) to (4.center);
[->] (0,-0.75) – (0,0.1);

Rotation of a diagram that yields a scalar has no effect on the numerical outcome.

Tensor product.
When parts of a diagram are not connected, this indicates that the tensor product is taken.
It does not matter how these parts are arranged with respect to each other, e.g. vertically separated or
This means that disconnected parts in a diagram may be freely moved around.

\begin{equation}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=StateRight] (0) at (0.05, 1) {\rotatebox{90}{$\psi$}};
\node [style=EffectRight] (1) at (-0.05, -1) {{\rotatebox{0}{$\phi$}}};
\node [style=none] (2) at (-0.05, -2) {};
\node [style=none] (3) at (0.05, 2) {};
\node [style=none] (4) at (-0.05, -0.75) {};
\node [style=none] (5) at (0.05, 0.75) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (1) to (2.center);
\draw (0) to (3.center);
\draw (3.center) to (5.center);
\draw (4.center) to (2.center);
\draw[->] (-0.05,-2) -- (-0.05,-1.6);
\draw[->] (0.05,0.75) -- (0.05,1.7);
\end{pgfonlayer}
\end{tikzpicture} \equiv \ket{\psi}\otimes\bra{\phi} = \ket{\psi}\bra{\phi}
\quad\quad\quad\quad\quad\quad\quad\quad
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=StateRight] (0) at (-0.875, -0.5) {\rotatebox{90}{$\psi_1$}};
\node [style=StateRight] (1) at (0.9, -0.5) {\rotatebox{90}{$\psi_2$}};
\node [style=none] (2) at (0.9, 0.5) {};
\node [style=none] (3) at (-0.875, 0.5) {};
\node [style=none] (4) at (-0.875, -0.75) {};
\node [style=none] (5) at (0.9, -0.75) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (3.center) to (4.center);
\draw (2.center) to (5.center);
\draw[->] (-0.875,-0.75) -- (-0.875,0.2);
\draw[->] ( 0.9,-0.75) --   ( 0.9,0.2);
\end{pgfonlayer}
\end{tikzpicture} \;\;\equiv\;\; \ket{\qj_1} \otimes \ket{\qj_2}
\end{equation}

Two parallel wires, one of which represents the identity on Hilbert space $\cH_1$
and the other on $\cH_2$, may be drawn as a single wire for the tensor product space
$\cH_1\otimes \cH_2$.

A wire represents the identity map.
The diagrams below depict the spectral decomposition of the identity,
${\mathbf 1} = \sum_i \ket i\bra i$,
and the formula
$\inprod{\phi}{\qj}=\sum_i \inprod{\phi}{i}\inprod{i}{\qj}$
$=\sum_i \phi_i^*\qj_i$.

\begin{equation}
\label{equation:wiredecomposed}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (0, 1) {};
\node [style=none] (1) at (0, -1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (0.center) to (1.center);
\draw[->] (0,-1) -- (0,0.1);
\end{pgfonlayer}
\end{tikzpicture}
\;\;=\;\; \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (4) at (-1, 0) {$\sum\limits_{i}$};
\node [style=none] (7) at (0, 2.1) {};
\node [style=none] (8) at (0, -2.1) {};
\node [style=none] (9) at (0, 1) {};
\node [style=none] (10) at (0, -1) {};
\node [style=StateRight] (14) at (0, 1.1) {\rotatebox{90}{i}};
\node [style=EffectRight] (15) at (0, -1.1) {\rotatebox{0}{i}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (7.center) to (9.center);
\draw (8.center) to (10.center);
\draw[->] (0,-1.8) -- (0,-1.7);
\draw[->] (0,1.4) -- (0,1.8);
\end{pgfonlayer}
\end{tikzpicture}
\quad\quad\quad\quad\quad\quad\quad\quad
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=StateRight] (0) at (0.05, -0.75) {};
\node [style=EffectRight] (2) at (-0.05, 0.75) {};
\node [style=none] (3) at (0, 0.75) {$\phi$};
\node [style=none] (4) at (0, -0.75) {$\psi$};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (3.center) to (4.center);
\draw[->] (0,-0.75) -- (0,0.1);
\end{pgfonlayer}
\end{tikzpicture} \;\;=\;\; \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (4) at (-1, 0) {$\sum\limits_{i}$};
\node [style=none] (7) at (0, 2.5) {};
\node [style=none] (8) at (0, -2.5) {};
\node [style=none] (9) at (0, 1) {};
\node [style=none] (10) at (0, -1) {};
\node [style=StateRight] (14) at (0, 1.0) {\rotatebox{90}{i}};
\node [style=EffectRight] (15) at (0, -1.0) {\rotatebox{0}{i}};
\node [style=StateRight] (16) at (-0.025, -2.25) {};
\node [style=EffectRight] (17) at (-0.125, 2.25) {};
\node [style=none] (18) at (-0.075, 2.25) {$\phi$};
\node [style=none] (19) at (-0.075, -2.25) {$\psi$};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (7.center) to (9.center);
\draw (8.center) to (10.center);
\draw[->] (0,1) -- (0,1.7);
\draw[->] (0,-2) -- (0,-1.6);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

A bent around wire has the following definition,

\begin{equation}
\label{equation:bentaroundwire}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (-1, -1) {};
\node [style=none] (1) at (1, -1) {};
\node [style=none] (2) at (1, 0) {};
\node [style=none] (3) at (-1, 0) {};
\node [style=none] (4) at (0, 1) {};
\node [style=none] (5) at (0, 1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (2.center) to (1.center);
\draw (3.center) to (0.center);
\draw [in=180, out=90] (3.center) to (5.center);
\draw [in=90, out=0] (5.center) to (2.center);
\draw[->] (1,-1) -- (1,-0.2);
\draw[->] (-1,0) -- (-1,-0.3);
\end{pgfonlayer}
\end{tikzpicture} \quad\isdef\quad
\sum_i \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (2) at (0.6, -1) {};
\node [style=none] (3) at (-1, -1) {};
\node [style=none] (4) at (-1, 0.5) {};
\node [style=none] (5) at (0.6, 0.5) {};
%		\node [style=none] (6) at (-2.5, 0) {$\sum\limits_{i}$};
\node [style=EffectLeft] (7) at (-1, 0.25) {\rotatebox{-90}{i}};
\node [style=EffectRight] (8) at (0.6, 0.26) {\rotatebox{0}{i}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (5.center) to (2.center);
\draw (4.center) to (3.center);
\draw[->] (-1,0) -- (-1,-0.5);
\draw[->] (0.6,-0.6) -- (0.6,-0.4);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

This definition leads to a very handy visualisation of
the formula $\inprod{\phi}{\qj}=\sum_i \inprod{i}{\phi}^* \inprod{i}{\qj}$
as a bent-around version of (<ref>),

\begin{equation}
\label{equation:bentaroundwiresinandoutputs}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (-1, -1) {};
\node [style=none] (1) at (1, -1) {};
\node [style=none] (2) at (1, 0) {};
\node [style=none] (3) at (-1, 0) {};
\node [style=none] (4) at (0, 1) {};
\node [style=none] (5) at (0, 1) {};
\node [style=StateRight] (6) at (1, -0.75) {\rotatebox{90}{$\psi$}};
\node [style=StateLeft] (7) at (-1, -0.85) {\rotatebox{180}{$\phi$}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (2.center) to (1.center);
\draw (3.center) to (0.center);
\draw [in=180, out=90] (3.center) to (5.center);
\draw [in=90, out=0] (5.center) to (2.center);
\draw[->] (1,-1) -- (1,0);
\draw[->] (-1,0) -- (-1,-0.1);
\end{pgfonlayer}
\end{tikzpicture} \quad\equaltext{(\ref{equation:bentaroundwire})} \quad
\sum_i\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (2) at (0.5, -1) {};
\node [style=none] (3) at (-1, -1) {};
\node [style=none] (4) at (-1, 0.5) {};
\node [style=none] (5) at (0.5, 0.5) {};
%		\node [style=none] (6) at (-2.5, 0) {$\sum\limits_{i}$};
\node [style=EffectLeft] (7) at (-1, 0.25) {\rotatebox{-90}{i}};
\node [style=EffectRight] (8) at (0.5, 0.25) {\rotatebox{0}{i}};
\node [style=none] (9) at (-1, -1) {};
\node [style=none] (10) at (0.5, -1) {};
\node [style=StateRight] (11) at (0.5, -1) {\rotatebox{90}{$\psi$}};
\node [style=StateLeft] (12) at (-1, -1.1) {\rotatebox{180}{$\phi$}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (5.center) to (2.center);
\draw (4.center) to (3.center);
\draw[->] (0.5,-0.5) -- (0.5,-0.3);
\draw[->] (-1,0) -- (-1,-0.4);
\end{pgfonlayer}
\end{tikzpicture}
\quad \equaltext{(\ref{rotinprod})} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (4) at (-1, 0) {$\sum\limits_{i}$};
\node [style=none] (7) at (0, 2.5) {};
\node [style=none] (8) at (0, -2.5) {};
\node [style=none] (9) at (0, 1) {};
\node [style=none] (10) at (0, -1) {};
\node [style=StateRight] (14) at (0, 1.0) {\rotatebox{90}{i}};
\node [style=EffectRight] (15) at (0, -1.0) {\rotatebox{0}{i}};
\node [style=StateRight] (16) at (-0.025, -2.25) {};
\node [style=EffectRight] (17) at (-0.125, 2.25) {};
\node [style=none] (18) at (-0.075, 2.25) {$\phi$};
\node [style=none] (19) at (-0.075, -2.25) {$\psi$};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (7.center) to (9.center);
\draw (8.center) to (10.center);
\draw[->] (0,1) -- (0,1.7);
\draw[->] (0,-2) -- (0,-1.6);
\end{pgfonlayer}
\end{tikzpicture}
\quad
\equaltext{(\ref{equation:wiredecomposed})} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=StateRight] (0) at (0.05, -0.75) {};
\node [style=EffectRight] (2) at (-0.05, 0.75) {};
\node [style=none] (3) at (0, 0.75) {$\phi$};
\node [style=none] (4) at (0, -0.75) {$\psi$};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (3.center) to (4.center);
\draw[->] (0,-0.75) -- (0,0.1);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

More generally, it was shown
in [3] that wires can be bent in any way without affecting the numerical outcome of a diagram.
This goes by the name yanking equations. For example, the S-shape bend below is equivalent to a straight wire,

\begin{equation}
\label{equation:yankingequation}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (-2, 0) {};
\node [style=none] (1) at (-1, -1) {};
\node [style=none] (2) at (0, 0) {};
\node [style=none] (3) at (1, 1) {};
\node [style=none] (4) at (2, 0) {};
\node [style=none] (5) at (2, -1) {};
\node [style=none] (6) at (-2, 1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (5.center) to (4.center);
\draw [bend right=45] (4.center) to (3.center);
\draw [bend right=45] (3.center) to (2.center);
\draw [bend left=45] (2.center) to (1.center);
\draw [bend left=45] (1.center) to (0.center);
\draw (0.center) to (6.center);
\draw[->] (2,-1) -- (2,0);
\draw[->] (0,0) -- (0,-0.1);
\draw[->] (-2,-0.1) -- (-2,0);
\end{pgfonlayer}
\end{tikzpicture} \quad = \quad \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (0, 1) {};
\node [style=none] (1) at (0, -1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (0.center) to (1.center);
\draw[->] (0,-1) -- (0,0.1);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

This is proven diagrammatically as follows.

\begin{equation}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (-2, 0) {};
\node [style=none] (1) at (-1, -1) {};
\node [style=none] (2) at (0, 0) {};
\node [style=none] (3) at (1, 1) {};
\node [style=none] (4) at (2, 0) {};
\node [style=none] (5) at (2, -1) {};
\node [style=none] (6) at (-2, 1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (5.center) to (4.center);
\draw [bend right=45] (4.center) to (3.center);
\draw [bend right=45] (3.center) to (2.center);
\draw [bend left=45] (2.center) to (1.center);
\draw [bend left=45] (1.center) to (0.center);
\draw (0.center) to (6.center);
\draw[->] (2,-1) -- (2,0);
\draw[->] (0,0) -- (0,-0.1);
\draw[->] (-2,-0.1) -- (-2,0);
\end{pgfonlayer}
\end{tikzpicture}
\; \equaltext{(\ref{equation:wiredecomposed})} \;
\sum_{ij} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (-2, -0.5) {};
\node [style=none] (4) at (1.5, 0.5) {};
\node [style=none] (5) at (1.5, -1) {};
\node [style=none] (6) at (-2, 1) {};
\node [style=none] (7) at (0, -0.5) {};
\node [style=none] (8) at (0, 0.5) {};
\node [style=StateLeft] (9) at (0, -0.65) {\rotatebox{180}{i}};
\node [style=StateRight] (10) at (-2, -0.65) {\rotatebox{90}{i}};
\node [style=EffectLeft] (11) at (0, 0.65) {\rotatebox{-90}{j}};
\node [style=EffectRight] (12) at (1.5, 0.65) {\rotatebox{0}{j}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (5.center) to (4.center);
\draw (0.center) to (6.center);
\draw (7.center) to (8.center);
\draw[->] (-2,-0.1) -- (-2,0.1);
\draw[->] (0,0.1) -- (0,-0.1);
\draw[->] (1.5,-0.1) -- (1.5,0);
\end{pgfonlayer}
\end{tikzpicture}
\;=\; \sum_{ij} \qd_{ij} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (0, 0.75) {};
\node [style=none] (4) at (0, -0.75) {};
\node [style=none] (5) at (0, -2) {};
\node [style=none] (6) at (0, 2) {};
\node [style=StateRight] (10) at (0, 1.1) {\rotatebox{90}{i}};
\node [style=EffectRight] (12) at (0, -1.1) {\rotatebox{0}{j}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (5.center) to (4.center);
\draw (0.center) to (6.center);
\draw[->] (0,-2) -- (0,-1.7);
\draw[->] (0,1) -- (0,1.8);
\end{pgfonlayer}
\end{tikzpicture}
\;=\;  \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (4) at (-1, 0) {$\sum\limits_{i}$};
\node [style=none] (7) at (0, 2.1) {};
\node [style=none] (8) at (0, -2.1) {};
\node [style=none] (9) at (0, 1) {};
\node [style=none] (10) at (0, -1) {};
\node [style=StateRight] (14) at (0, 1.1) {\rotatebox{90}{i}};
\node [style=EffectRight] (15) at (0, -1.1) {\rotatebox{0}{i}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (7.center) to (9.center);
\draw (8.center) to (10.center);
\draw[->] (0,-1.8) -- (0,-1.7);
\draw[->] (0,1.4) -- (0,1.8);
\end{pgfonlayer}
\end{tikzpicture}
\equaltext{(\ref{equation:wiredecomposed})} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (0, 1) {};
\node [style=none] (1) at (0, -1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (0.center) to (1.center);
\draw[->] (0,-1) -- (0,0.1);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

Linear maps.
A linear map $A=\sum_{ij}\bra i A\ket j\; \ket i\bra j=\sum_{ij}a_{ij}\ket i\bra j$ is depicted as

\begin{equation}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=asym box] (0) at (0, 0) {\reflectbox{$A$}};
\node [style=none] (1) at (0, 1.5) {};
\node [style=none] (2) at (0, -1.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (1.center) to (0);
\draw (0) to (2.center);
\draw[->] (0,-1.5) -- (0,-1);
\draw[->] (0,1) -- (0,1.1);
\end{pgfonlayer}
\end{tikzpicture}
\quad = \quad  \sum_{ij} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=asym box] (0) at (0, 0) {\reflectbox{$A$}};
\node [style=none] (1) at (0,  1.3) {};
\node [style=none] (2) at (0, -1.3) {};
\node [style=EffectRight] (5) at (0,  1.5) {\rotatebox{0}{i}};
\node [style=StateRight]  (6) at (0, -1.5) {\rotatebox{90}{j}};
\node [style=StateRight] (7) at (2.7,  1.1) {\rotatebox{90}{i}};
\node [style=EffectRight] (8) at (2.7,  -1.1) {\rotatebox{0}{j}};
\node [style=none] (9) at (2.7,  2.3) {};
\node [style=none] (10) at (2.7,  -2.3) {};
\node [style=none] (11) at (2.7,  1) {};
\node [style=none] (12) at (2.7,  -1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (1.center) to (0);
\draw (0) to (2.center);
\draw (9) to (11.center);
\draw (10) to (12.center);
\draw[->] (0,-1.2) -- (0,-0.8);
\draw[->] (0,0.8) -- (0,1);
\draw[->] (2.7,1) -- (2.7,1.8);
\draw[->] (2.7,-2) -- (2.7,-1.7);
\end{pgfonlayer}
\end{tikzpicture}
\quad = \quad \
\sum_{ij}a_{ij}\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (0, 0.75) {};
\node [style=none] (4) at (0, -0.75) {};
\node [style=none] (5) at (0, -2) {};
\node [style=none] (6) at (0, 2) {};
\node [style=StateRight] (10) at (0, 1.1) {\rotatebox{90}{i}};
\node [style=EffectRight] (12) at (0, -1.1) {\rotatebox{0}{j}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (5.center) to (4.center);
\draw (0.center) to (6.center);
\draw[->] (0,-2) -- (0,-1.7);
\draw[->] (0,1) -- (0,1.8);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

where the input space and output space do not have to be the same.
The incoming and outgoing wire in the diagram above may stand for multiple wires.
Note that the shape of the $A$-box is asymmetric, so that vertical and horizontal flips
are easily recognised visually.

A linear map can be moved along a wire, as long as it is rotated along with the bends.

[style=none] (0) at (0, -0.5) ;
[style=none] (1) at (2, -2.5) ;
[style=none] (2) at (2, 0) ;
[style=none] (3) at (0, 0) ;
[style=none] (4) at (1, 1) ;
[style=none] (5) at (1, 1) ;
[style=asym box transpose] (6) at (0, -1) $A$;
[style=none] (7) at (0, -2.5) ;

(2.center) to (1.center);
(3.center) to (0.center);
[in=180, out=90] (3.center) to (5.center);
[in=90, out=0] (5.center) to (2.center);
(7) to (6.center);
[->] (2,-0.3) – (2,-0.1);
[->] (0,0) – (0,-0.2);
[->] (0,-2) – (0,-2.1);

[style=none] (0) at (-2, -2.5) ;
[style=none] (1) at (0, -0.5) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (-2, 0) ;
[style=none] (4) at (-1, 1) ;
[style=none] (5) at (-1, 1) ;
[style=asym box] (6) at (0, -1) $A$;
[style=none] (7) at (0, -2.5) ;

(2.center) to (1.center);
(3.center) to (0.center);
[in=180, out=90] (3.center) to (5.center);
[in=90, out=0] (5.center) to (2.center);
(7) to (6.center);
[->] (0,-0.2) – (0,0);
[->] (-2,0) – (-2,-0.1);
[->] (0,-2.5) – (0,-2);

The diagrammatic proof is as follows,

[style=none] (0) at (0, -0.5) ;
[style=none] (1) at (2, -2.5) ;
[style=none] (2) at (2, 0) ;
[style=none] (3) at (0, 0) ;
[style=none] (4) at (1, 1) ;
[style=none] (5) at (1, 1) ;
[style=asym box transpose] (6) at (0, -1) $A$;
[style=none] (7) at (0, -2.5) ;

(2.center) to (1.center);
(3.center) to (0.center);
[in=180, out=90] (3.center) to (5.center);
[in=90, out=0] (5.center) to (2.center);
(7) to (6.center);
[->] (2,-0.3) – (2,-0.1);
[->] (0,0) – (0,-0.2);
[->] (0,-2) – (0,-2.1);

=   ∑_ij
[style=asym box transpose] (0) at (0, 0) $A$;
[style=none] (1) at (0,  1.3) ;
[style=none] (2) at (0, -1.3) ;
[style=EffectLeft] (5) at (0,  1.5) -90i;
[style=StateLeft]  (6) at (0, -1.5) 180j;
[style=EffectRight] (7) at (2.2,  1.2) 0i;
[style=EffectLeft] (8) at (-1.5,  -2.0) -90j;
[style=none] (9) at (2.2,  -2.5) ;
[style=none] (19) at (2.2,  1.4) ;
[style=none] (10) at (-1.5,  -2.9) ;
[style=none] (20) at (-1.5,  -1.8) ;

(1.center) to (0);
(0) to (2.center);
(9) to (19);
(10) to (20);
[->] (-1.5,-2) – (-1.5,-2.7);
[->] (0,1.4) – (0,0.9);
[->] (0,-0.9) – (0,-1);
[->] (2.2,0) – (2.2,0.1);

=   ∑_ij
[style=asym box] (0) at (0, 0) $A$;
[style=none] (1) at (0,  1.3) ;
[style=none] (2) at (0, -1.3) ;
[style=EffectRight] (5) at (0,  1.5) 0j;
[style=StateRight]  (6) at (0, -1.5) 90i;
[style=EffectRight] (7) at (2.2,  1.2) 0i;
[style=EffectLeft] (8) at (-1.5,  -2.0) -90j;
[style=none] (9) at (2.2,  -2.5) ;
[style=none] (19) at (2.2,  1.5) ;
[style=none] (10) at (-1.5,  -3) ;
[style=none] (20) at (-1.5,  -1.8) ;

(1.center) to (0);
(0) to (2.center);
(9) to (19);
(10) to (20);
[->] (2.2,-0.2) – (2.2,0);
[->] (0,0.7) – (0,1);
[->] (0,-1.5) – (0,-0.9);
[->] (-1.5,-2) – (-1.5,-2.7);

[style=none] (0) at (-2, -2.5) ;
[style=none] (1) at (0, -0.5) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (-2, 0) ;
[style=none] (4) at (-1, 1) ;
[style=none] (5) at (-1, 1) ;
[style=asym box] (6) at (0, -1) $A$;
[style=none] (7) at (0, -2.5) ;

(2.center) to (1.center);
(3.center) to (0.center);
[in=180, out=90] (3.center) to (5.center);
[in=90, out=0] (5.center) to (2.center);
(7) to (6.center);
[->] (0,-0.2) – (0,0);
[->] (-2,0) – (-2,-0.1);
[->] (0,-2.5) – (0,-2);

A spider is a special linear operation from $\cH^{\otimes m}$ to $\cH^{\otimes n}$
that acts as a generalised Kronecker delta,

\begin{equation}
\label{equation:spidermultilegdecomposed}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=WhiteSpider] (0) at (0, 0) {};
\node [style=none] (1) at (-1, 1) {};
\node [style=none] (2) at (-0.5, 1) {};
\node [style=none] (3) at (1, 1) {};
\node [style=none] (4) at (-1, -1.25) {};
\node [style=none] (5) at (-0.5, -1.25) {};
\node [style=none] (6) at (1, -1.25) {};
\node [style=none] (7) at (-1, 1) {};
\node [style=none] (8) at (0, -1.25) {};
\node [style=none] (9) at (0.5, -1.25) {};
\node [style=none] (10) at (0, 1) {};
\node [style=none] (11) at (0.5, 1) {};
\node [style=none] (12) at (0, 1.5) {\small $n$ outputs};
\node [style=none] (13) at (0, -1.75) {\small $m$ inputs};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [bend left] (0) to (7.center);
\draw [bend left=15] (0) to (2.center);
\draw [bend right] (0) to (3.center);
\draw [bend right] (0) to (4.center);
\draw [bend right=15] (0) to (5.center);
\draw [bend left] (0) to (6.center);
\draw [style=new edge style 0] (10.center) to (11.center);
\draw [style=new edge style 0] (8.center) to (9.center);
\end{pgfonlayer}
\end{tikzpicture}
\quad\isdef\quad \sum_i \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
%		\node [style=none] (4) at (-4, 0) {$\sum\limits_{i}$};
\node [style=none] (7) at (-3, 2.5) {};
\node [style=none] (8) at (-3, -2.5) {};
\node [style=none] (9) at (-3, 1) {};
\node [style=none] (10) at (-3, -1) {};
\node [style=none] (14) at (-1, 2.5) {};
\node [style=none] (15) at (-1, -2.5) {};
\node [style=none] (16) at (-1, 1) {};
\node [style=none] (17) at (-1, -1) {};
\node [style=none] (26) at (2, 2.5) {};
\node [style=none] (27) at (2, -2.5) {};
\node [style=none] (28) at (2, 1) {};
\node [style=none] (29) at (2, -1) {};
\node [style=none] (32) at (0, 2) {};
\node [style=none] (33) at (1, 2) {};
\node [style=none] (34) at (0, -2) {};
\node [style=none] (35) at (1, -2) {};
\node [style=none] (36) at (-0.5, 3) {\small $n$ outputs};
\node [style=none] (37) at (-0.5, -3) {\small $m$ inputs};
\node [style=StateRight] (38) at (-3, 1) {\rotatebox{90}{i}};
\node [style=EffectRight] (39) at (-3, -1) {\rotatebox{0}{i}};
\node [style=StateRight] (40) at (-1, 1) {\rotatebox{90}{i}};
\node [style=StateRight] (41) at (2, 1) {\rotatebox{90}{i}};
\node [style=EffectRight] (42) at (-1, -1) {\rotatebox{0}{i}};
\node [style=EffectRight] (43) at (2, -1) {\rotatebox{0}{i}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (7.center) to (9.center);
\draw (8.center) to (10.center);
\draw (14.center) to (16.center);
\draw (15.center) to (17.center);
\draw (26.center) to (28.center);
\draw (27.center) to (29.center);
\draw [style=new edge style 0] (32.center) to (33.center);
\draw [style=new edge style 0] (34.center) to (35.center);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

Any combination of incoming and outgoing arrows is possible.
The arrows on the wires are often omitted when there is no ambiguity.

A special case of a spider is the spider with one input and one output, which equals the identity,

\begin{equation}
\label{equation:boringspider}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=WhiteSpider] (0) at (0, 0) {};
\node [style=none] (1) at (0, 1) {};
\node [style=none] (2) at (0, -1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (2.center) to (0);
\draw (0) to (1.center);
\draw[->] (0,0.2) -- (0,0.7);
\draw[->] (0,-0.6) -- (0,-0.5);
\end{pgfonlayer}
\end{tikzpicture} \quad=\quad  \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (0, 1) {};
\node [style=none] (1) at (0, -1) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (0.center) to (1.center);
\draw[->] (0,-1) -- (0,0.1);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

Another special case is the spider with zero inputs and one output.
It is proportional to the equal superposition of all basis states.

\begin{equation}
\label{equation:spideroneoutput}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=WhiteSpider] (0) at (0, -0.5) {};
\node [style=none] (1) at (0, 0.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (0) to (1.center);
\draw[->] (0,0) -- (0,0.3);
\end{pgfonlayer}
\end{tikzpicture} \equaltext{(\ref{equation:spidermultilegdecomposed})}
\sum_i \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (7) at (0, 1) {};
\node [style=none] (9) at (0, -0.25) {};
\node [style=StateRight] (10) at (0, 0) {\rotatebox{90}{i}};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (7.center) to (9.center);
%		\draw[->] (0,0) -- (0,0.5);
\draw[->] (0,-0.25) -- (0,0.8);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

A spider with two outgoing arrows corresponds to the maximally entangled state $\fr1{\sqrt d}\sum_i\ket{ii}$

[style=none] (0) at (0, 0) ;
[style=none] (10) at (0, 0.5) ;
[style=WhiteSpider] (20) at (-0.5, -0.5) ;
[style=none] (21) at (-1, 0) ;
[style=none] (22) at (-1, 0.5) ;

(0.center) to (10);
[out=-90, in=0]   (0.center) to (20.center);
[out=180, in=-90] (20.center) to (21.center);
(21.center) to (22.center);
[->] (-1,0.2) – (-1,0.3);
[->] (0,0.2) – (0,0.3);

=  ∑_i
[style=none] (7) at (0, 1) ;
[style=none] (9) at (0, -0.25) ;
[style=StateRight] (10) at (0, 0) 90i;

(7.center) to (9.center);

[->] (0,-0.25) – (0,0.8);

[style=none] (7) at (0, 1) ;
[style=none] (9) at (0, -0.25) ;
[style=StateRight] (10) at (0, 0) 90i;

(7.center) to (9.center);

[->] (0,-0.25) – (0,0.8);

A spider that is not connected to any lines evaluates to a scalar,
namely the dimension $d$ of the Hilbert space,

[style=WhiteSpider] (10) at (0, 0) ;

= ∑_i()=d.
An important property of spiders is that they fuse.

\begin{equation}
\label{equation:spiderfusion}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=WhiteSpider] (0) at (-0.75, 0.5) {};
\node [style=none] (1) at (-1.75, 1.5) {};
\node [style=none] (2) at (-1.25, 1.5) {};
\node [style=none] (3) at (0.25, 1.5) {};
\node [style=none] (4) at (-2, -1.75) {};
\node [style=none] (5) at (-1.5, -1.75) {};
\node [style=none] (6) at (0, 0) {};
\node [style=none] (7) at (-1.75, 1.5) {};
\node [style=none] (8) at (-1, -1.75) {};
\node [style=none] (9) at (-0.5, -1.75) {};
\node [style=none] (10) at (-0.75, 1.5) {};
\node [style=none] (11) at (-0.25, 1.5) {};
\node [style=WhiteSpider] (12) at (1, -0.5) {};
\node [style=none] (13) at (0, 0) {};
\node [style=none] (14) at (0.75, 1.5) {};
\node [style=none] (15) at (2.25, 1.5) {};
\node [style=none] (16) at (0, -1.75) {};
\node [style=none] (17) at (0.5, -1.75) {};
\node [style=none] (18) at (2, -1.75) {};
\node [style=none] (19) at (0, 0) {};
\node [style=none] (20) at (1, -1.75) {};
\node [style=none] (21) at (1.5, -1.75) {};
\node [style=none] (22) at (1.25, 1.5) {};
\node [style=none] (23) at (1.75, 1.5) {};
\node [style=none] (24) at (0.25, 2) {\small $n$ outputs};
\node [style=none] (25) at (0.25, -2.25) {\small $m$ inputs};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [bend left] (0) to (7.center);
\draw [bend left=15] (0) to (2.center);
\draw [bend right] (0) to (3.center);
\draw [bend right] (0) to (4.center);
\draw [bend right=15] (0) to (5.center);
\draw [bend left] (0) to (6.center);
\draw [style=new edge style 0] (10.center) to (11.center);
\draw [style=new edge style 0] (8.center) to (9.center);
\draw [bend left] (12) to (19.center);
\draw [bend left=15] (12) to (14.center);
\draw [bend right] (12) to (15.center);
\draw [bend right] (12) to (16.center);
\draw [bend right=15] (12) to (17.center);
\draw [bend left] (12) to (18.center);
\draw [style=new edge style 0] (22.center) to (23.center);
\draw [style=new edge style 0] (20.center) to (21.center);
\end{pgfonlayer}
\end{tikzpicture}
= \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=WhiteSpider] (0) at (0, 0) {};
\node [style=none] (1) at (-1, 1) {};
\node [style=none] (2) at (-0.5, 1) {};
\node [style=none] (3) at (1, 1) {};
\node [style=none] (4) at (-1, -1.25) {};
\node [style=none] (5) at (-0.5, -1.25) {};
\node [style=none] (6) at (1, -1.25) {};
\node [style=none] (7) at (-1, 1) {};
\node [style=none] (8) at (0, -1.25) {};
\node [style=none] (9) at (0.5, -1.25) {};
\node [style=none] (10) at (0, 1) {};
\node [style=none] (11) at (0.5, 1) {};
\node [style=none] (12) at (0, -1.75) {\small $m$ inputs};
\node [style=none] (13) at (0, 1.5) {\small $n$ outputs};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [bend left] (0) to (7.center);
\draw [bend left=15] (0) to (2.center);
\draw [bend right] (0) to (3.center);
\draw [bend right] (0) to (4.center);
\draw [bend right=15] (0) to (5.center);
\draw [bend left] (0) to (6.center);
\draw [style=new edge style 0] (10.center) to (11.center);
\draw [style=new edge style 0] (8.center) to (9.center);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

This follows directly from the definition  (<ref>).
A spider is defined with respect to a certain basis.
When that it not the standard basis, shading or colouring is applied, just as for basis states.

Equivalence between state preparation and EPR measurement.

There is a well known equivalence between on the one hand preparing a state $\ket\qj$
and on the other hand preparing a maximally entangled bipartite state
followed by projecting one of the subsystems onto $\ket{\qj^*}$.
In diagram notation this equivalence is visualised simply by bending a wire.

[style=none] (2) at (0, 1) ;
[style=none] (3) at (0, 1) ;
[style=StateRight] (4) at (0, 0) 90$\psi$;
[style=none] (5) at (0, -0.25) ;

(3.center) to (5.center);
[->] (0,-0.25) – (0,0.8);

[style=none] (0) at (-2, 0) ;
[style=none] (1) at (-1, -1) ;
[style=none] (2) at (0, 0) ;
[style=none] (6) at (-2, 1) ;
[style=none] (7) at (0, 1.5) ;
[style=EffectLeft] (8) at (-2, 0.8) -90$\psi$;

[bend left=45] (2.center) to (1.center);
[bend left=45] (1.center) to (0.center);
(0.center) to (6.center);
(2.center) to (7.center);
[->] (0,0) – (0,0.1);
[->] (-2,0.05) – (-2,0);

[style=none] (0) at (-2, 0) ;
[style=none] (1) at (-1, -1) ;
[style=none] (2) at (0, 0) ;
[style=none] (6) at (-2, 1.5) ;
[style=none] (7) at (0, 1.5) ;
[style=EffectLeft] (8) at (-2, 1.5) -90$\psi$;
[style=WhiteSpider] (9) at (-1, -1) ;
[style=WhiteSpider] (10) at (-2, 0.4) ;

[bend left=45] (2.center) to (1.center);
[bend left=45] (1.center) to (0.center);
(0.center) to (6.center);
(2.center) to (7.center);
[->] (0,0) – (0,0.1);
[->] (-2,0.9) – (-2,0.8);
[->] (-2,-0.001) – (-2,0);

=  ∑_i _i
[style=none] (0) at (-2, 0) ;
[style=none] (1) at (-1, -1) ;
[style=none] (2) at (0, 0) ;
[style=none] (6) at (-2, 1.3) ;
[style=none] (7) at (0, 1.5) ;
[style=EffectRight] (8) at (-2.1, 1) 0$i$;
[style=WhiteSpider] (9) at (-1, -1) ;

[bend left=45] (2.center) to (1.center);
[bend left=45] (1.center) to (0.center);
(0.center) to (6.center);
(2.center) to (7.center);
[->] (0,0) – (0,0.1);

[->] (-2,-0.001) – (-2,0);

[style=none] (0) at (-2, 0) ;
[style=none] (1) at (-1, -1) ;
[style=none] (2) at (0, 0) ;
[style=none] (6) at (-2, 1.3) ;
[style=none] (7) at (0, 1.5) ;
[style=EffectRight] (8) at (-2.1, 1) $\qj^*$;
[style=WhiteSpider] (9) at (-1, -1) ;

[bend left=45] (2.center) to (1.center);
[bend left=45] (1.center) to (0.center);
(0.center) to (6.center);
(2.center) to (7.center);
[->] (0,0) – (0,0.1);

[->] (-2,-0.001) – (-2,0);

In the last diagram of (<ref>) the spider creates the entangled state, and the complex conjugation
$\qj\mapsto\qj^*$ is defined with respect to the spider's basis, i.e. $\qj_i\mapsto\qj_i^*$.

In case of a set of self-conjugate basis states the arrows on the wires do not have to be drawn,
and the spider in the last diagram in (<ref>) can be omitted, resulting in a simple
picture consisting merely of the $\bra{\qj^*}$ bra and a bent wire.

Phase spiders.
Let $\qa=(\qa_i)_{i=0}^{d-1}$, with $\qa_0=0$ by convention, be a vector containing angles.
The $\qa$-phase spider is defined as

[style=WhiteSpider] (0) at (0, 0) $\alpha$;
[style=none] (1) at (-1, 1) ;
[style=none] (2) at (-0.5, 1) ;
[style=none] (3) at (1, 1) ;
[style=none] (4) at (-1, -1.25) ;
[style=none] (5) at (-0.5, -1.25) ;
[style=none] (6) at (1, -1.25) ;
[style=none] (7) at (-1, 1) ;
[style=none] (8) at (0, -1.25) ;
[style=none] (9) at (0.5, -1.25) ;
[style=none] (10) at (0, 1) ;
[style=none] (11) at (0.5, 1) ;
[style=none] (12) at (0, -1.75) $m$ inputs;
[style=none] (13) at (0, 1.5) $n$ outputs;

[bend left] (0) to (7.center);
[bend left=15] (0) to (2.center);
[bend right] (0) to (3.center);
[bend right] (0) to (4.center);
[bend right=15] (0) to (5.center);
[bend left] (0) to (6.center);
[style=new edge style 0] (10.center) to (11.center);
[style=new edge style 0] (8.center) to (9.center);

∑_j e^i_j

[style=none] (7) at (-3, 2.5) ;
[style=none] (8) at (-3, -2.5) ;
[style=none] (9) at (-3, 1) ;
[style=none] (10) at (-3, -1) ;
[style=none] (14) at (-1, 2.5) ;
[style=none] (15) at (-1, -2.5) ;
[style=none] (16) at (-1, 1) ;
[style=none] (17) at (-1, -1) ;
[style=none] (26) at (2, 2.5) ;
[style=none] (27) at (2, -2.5) ;
[style=none] (28) at (2, 1) ;
[style=none] (29) at (2, -1) ;
[style=none] (32) at (0, 2) ;
[style=none] (33) at (1, 2) ;
[style=none] (34) at (0, -2) ;
[style=none] (35) at (1, -2) ;
[style=none] (36) at (-0.5, 3) $n$ outputs;
[style=none] (37) at (-0.5, -3) $m$ inputs;
[style=StateRight] (38) at (-3, 1) 90j;
[style=EffectRight] (39) at (-3, -1) 0j;
[style=StateRight] (40) at (-1, 1) 90j;
[style=StateRight] (41) at (2, 1) 90j;
[style=EffectRight] (42) at (-1, -1) 0j;
[style=EffectRight] (43) at (2, -1) 0j;

(7.center) to (9.center);
(8.center) to (10.center);
(14.center) to (16.center);
(15.center) to (17.center);
(26.center) to (28.center);
(27.center) to (29.center);
[style=new edge style 0] (32.center) to (33.center);
[style=new edge style 0] (34.center) to (35.center);

Phase spiders fuse like normal spiders, but their phases are added.
This follows directly from definitions (<ref>) and (<ref>).

[style=WhiteSpider] (0) at (-0.75, 0.5) $\alpha$;
[style=none] (1) at (-1.75, 1.5) ;
[style=none] (2) at (-1.25, 1.5) ;
[style=none] (3) at (0.25, 1.5) ;
[style=none] (4) at (-2, -1.75) ;
[style=none] (5) at (-1.5, -1.75) ;
[style=none] (6) at (0, 0) ;
[style=none] (7) at (-1.75, 1.5) ;
[style=none] (8) at (-1, -1.75) ;
[style=none] (9) at (-0.5, -1.75) ;
[style=none] (10) at (-0.75, 1.5) ;
[style=none] (11) at (-0.25, 1.5) ;
[style=WhiteSpider] (12) at (1, -0.5) $\beta$;
[style=none] (13) at (0, 0) ;
[style=none] (14) at (0.75, 1.5) ;
[style=none] (15) at (2.25, 1.5) ;
[style=none] (16) at (0, -1.75) ;
[style=none] (17) at (0.5, -1.75) ;
[style=none] (18) at (2, -1.75) ;
[style=none] (19) at (0, 0) ;
[style=none] (20) at (1, -1.75) ;
[style=none] (21) at (1.5, -1.75) ;
[style=none] (22) at (1.25, 1.5) ;
[style=none] (23) at (1.75, 1.5) ;
[style=none] (24) at (0.25, 2) $n$ outputs;
[style=none] (25) at (0.25, -2.25) $m$ inputs;

[bend left] (0) to (7.center);
[bend left=15] (0) to (2.center);
[bend right] (0) to (3.center);
[bend right] (0) to (4.center);
[bend right=15] (0) to (5.center);
[bend left] (0) to (6.center);
[style=new edge style 0] (10.center) to (11.center);
[style=new edge style 0] (8.center) to (9.center);
[bend left] (12) to (19.center);
[bend left=15] (12) to (14.center);
[bend right] (12) to (15.center);
[bend right] (12) to (16.center);
[bend right=15] (12) to (17.center);
[bend left] (12) to (18.center);
[style=new edge style 0] (22.center) to (23.center);
[style=new edge style 0] (20.center) to (21.center);

[style=WhiteSpider] (0) at (0, 0) $\alpha{+}\beta$;
[style=none] (1) at (-1, 1) ;
[style=none] (2) at (-0.5, 1) ;
[style=none] (3) at (1, 1) ;
[style=none] (4) at (-1, -1.25) ;
[style=none] (5) at (-0.5, -1.25) ;
[style=none] (6) at (1, -1.25) ;
[style=none] (7) at (-1, 1) ;
[style=none] (8) at (0, -1.25) ;
[style=none] (9) at (0.5, -1.25) ;
[style=none] (10) at (0, 1) ;
[style=none] (11) at (0.5, 1) ;
[style=none] (12) at (0, -1.75) $m$ inputs;
[style=none] (13) at (0, 1.5) $n$ outputs;

[bend left] (0) to (7.center);
[bend left=15] (0) to (2.center);
[bend right] (0) to (3.center);
[bend right] (0) to (4.center);
[bend right=15] (0) to (5.center);
[bend left] (0) to (6.center);
[style=new edge style 0] (10.center) to (11.center);
[style=new edge style 0] (8.center) to (9.center);

The complex conjugate of a phase spider has flipped phases.

[style=WhiteSpider] (0) at (0, 0)  $\alpha$ ;

^* =
[style=WhiteSpider] (0) at (0, 0) $-\alpha$;

Qubit states; Bloch sphere; switchable Pauli operations.

Qubit states ($d=2$) correspond to spin states on the Bloch sphere.
Typically the $z$-basis is chosen as the standard basis, with $\ket 0=\ket{+z}$ and
$\ket 1=\ket{-z}$.
The Pauli spin matrices are $\qs_x={0\; 1\choose 1\;0}$,
$\qs_y={0 \; -i \choose i\; \phantom{-}0}$,
$\qs_z={1\; \phantom{-}0 \choose 0\; -1}$.
A general spin state with spherical angles $(\qy,\qf)$ is given by $\cos\fr\qy2\ket0+ e^{i\qf}\sin\fr\qy2\ket1$.
The spin states along the $x,y$ axes are given by
$\ket{\pm x}=\frac{\ket0\pm\ket 1}{\sqrt2}$,
$\ket{\pm y}=\frac{\ket0\pm i \ket 1}{\sqrt2}$.
The `$+$' state in each case represents a logical $0$.

In many qubit-based protocols it suffices to work with only the $z$-basis and the $x$-basis.
The convention in [3, 5] is to use white colour for the $z$-basis and
grey shading for the $x$-basis. The basis states are depicted as left-right symmetric, since they are real-valued
when expressed in the standard basis.
The following diagrammatic relations hold between the two bases,

[style=WhiteSpider] (0) at (0, -0.5) ;
[style=none] (1) at (0, 0.5) ;

(0) to (1.center);

= √(2)
[style=StateMidGray] (0) at (0, 0) 1350;
[style=none] (1) at (0, -0.5) ;
[style=none] (2) at (0, 1) ;

[in=270, out=90] (1.center) to (2.center);

[style=WhiteSpider] (0) at (0, -0.5) $\pi$;
[style=none] (1) at (0, 0.5) ;

(0) to (1.center);

= √(2)
[style=StateMidGray] (0) at (0, 0) -451;
[style=none] (1) at (0, -0.5) ;
[style=none] (2) at (0, 1) ;

[in=270, out=90] (1.center) to (2.center);

[style=GraySpider] (0) at (0, -0.5) ;
[style=none] (1) at (0, 0.5) ;

(0) to (1.center);

= √(2)
[style=StateMid] (0) at (0, 0) 1350;
[style=none] (1) at (0, 1) ;
[style=none] (2) at (0, -0.5) ;

(2.center) to (1.center);

[style=GraySpider] (0) at (0, -0.5) $\pi$;
[style=none] (1) at (0, 0.5) ;

(0) to (1.center);

= √(2)
[style=StateMid] (0) at (0, 0) -451;
[style=none] (1) at (0, 1) ;
[style=none] (2) at (0, -0.5) ;

(2.center) to (1.center);

Here a phase label $\pi$ is shorthand for the two-dimensional phase vector $(0,\pi)$.
a white $\pi$-spider with a single in- and output acts on a state like the Pauli operation $\qs_z$,
and a gray $\pi$-spider acts like $\qs_x$.

[style=WhiteSpider] (0) at (0, 0) $\pi$;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (0, -1.0) ;

(0) to (1.center);
(2) to (1.center);

[style=medium box] (0) at (0, 0) $\sigma_z$;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (0, -1.0) ;

(0) to (1.center);
(2) to (1.center);

[style=GraySpider] (0) at (0, 0) $\pi$;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (0, -1.0) ;

(0) to (1.center);
(2) to (1.center);

[style=medium box] (0) at (0, 0) $\sigma_x$;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (0, -1.0) ;

(0) to (1.center);
(2) to (1.center);

Switchable $\qs_z$ and $\qs_x$ operations are built as follows.
[style=WhiteSpider] (0) at (0, 0) ;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (-1, -1.0) ;
[style=StateMidGray] (3) at (1, -1) -45u;

(1) to (0.center);
(2) to (0.center);
(3.center) to (0.center);

[style=WhiteSpider] (0) at (0, 0) $u\pi$;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (0, -1.0) ;

(0) to (1.center);
(2) to (1.center);

[style=medium box] (0) at (0, 0) $\sigma_z^u$;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (0, -1.0) ;

(0) to (1.center);
(2) to (1.center);

[style=GraySpider] (0) at (0, 0)  ;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (-1, -1.0) ;
[style=StateMid] (3) at (1, -1) -45u;

(1) to (0.center);
(2) to (0.center);
(3.center) to (0.center);

[style=GraySpider] (0) at (0, 0) $u\pi$;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (0, -1.0) ;

(0) to (1.center);
(2) to (1.center);

[style=medium box] (0) at (0, 0) $\sigma_x^u$;
[style=none] (1) at (0, 1.0) ;
[style=none] (2) at (0, -1.0) ;

(0) to (1.center);
(2) to (1.center);

Here the $u\in\bits$ is a control bit that switches the Pauli operation.

Quantum One-Time Pad (QOTP) encryption [1, 4, 7] of a qubit state
works with a two-bit key $(u,v)\in\bits^2$.
The encryption operation $E$ is
E_uv|⟩_z^u _x^v |⟩which can be depicted as
E_uv|⟩  ≡  2
[style=StateRight] (0) at (0, -1) 90$\psi$;
[style=GraySpider] (1) at (0, 0) ;
[style=WhiteSpider] (2) at (0, 1.5) ;
[style=StateMid] (3) at (2, -0.5) -45v;
[style=StateMidGray] (4) at (2, 1) -45u;
[style=none] (10) at (0, 2) ;

(0.center) to (10);
[out=90, in=0] (3.center) to (1.center);
[out=90, in=0] (4.center) to (2.center);

Bell states.
The Bell states in two-qubit space are usually written as
We write them in a slightly different way which
displays the fact that the four Bell states are QOTP encryptions of each other, where the encryption acts on one of the two qubits,
|_uv⟩ = (1⊗_z^u _x^v) |00⟩+|11⟩/√(2)

[style=none] (0) at (0, -1) ;
[style=GraySpider] (1) at (0, 0) ;
[style=WhiteSpider] (2) at (0, 1.5) ;
[style=StateMid] (3) at (2, -0.5) -45v;
[style=StateMidGray] (4) at (2, 1) -45u;
[style=none] (10) at (0, 2) ;
[style=WhiteSpider] (20) at (-0.5, -1.5) ;
[style=none] (21) at (-1, -1) ;
[style=none] (22) at (-1, 2) ;

(0.center) to (10);
[out=90, in=0] (3.center) to (1.center);
[out=90, in=0] (4.center) to (2.center);

[out=-90, in=0]   (0.center) to (20.center);
[out=180, in=-90] (20.center) to (21.center);
(21.center) to (22.center);
[->] (-1,-1.1) – (-1,-1);
[->] (0,-1.1) – (0,-1);

≡  √(2) |_uv⟩.

§ MIXED STATES

In the standard formalism, mixed states are described as positive semidefinite operators on
the Hilbert space $\cH$, with trace 1.
The space of such density matrices is denoted as $\cD(\cH)$.
Because of the isomorphism
()≅⊗it is possible to express a mixed state, which is usually written in operator form
We will use tilde notation for the operator form.
] as $\tilde\qr=\sum_{ij}\qr_{ij}\ket i\bra j\in\cD(\cH)$,
as an object in $\cH\otimes\cH$, namely $\qr= \sum_{ij}\qr_{ij}\ket i^*\otimes\ket j$.
This has the advantage that it becomes possible to draw diagrams for mixed states in a way that is visually similar to pure states,
i.e. creation of a mixed state has wires extending only upward, whereas an operator box has wires up and down.
For a pure state $\ket\qj=\sum_i \qj_i \ket i$, whose density matrix is $\ket\qj\bra\qj\in\cD(\cH)$,
this yields
$\qr=\sum_{ij}\qj_i^* \qj_j \ket i^*\otimes \ket j$
$=\ket\qj^*\otimes\ket\qj$, with diagram

[style=StateLeft] (0) at (-0.5, -0.6) 180$\psi$;
[style=StateRight] (1) at (0.5, -0.5)  90$\psi$;
[style=none] (2) at (-0.5, 1) ;
[style=none] (3) at (0.5, 1) ;

(2) to (0.center);
(3) to (1.center);
[->] (0.5,0) – (0.5,0.3);
[->] (-0.5,0.5) – (-0.5,0.2);

For brevity a special notation is introduced, in which a thick-drawn wire, spider, pure state
or pure map[
A pure map is an operation on mixed states $\tilde\qr\in\cD(\cH)$
that can be represented as $A\tilde\qr A\dagg$, i.e. a linear operation on $\cH$.
indicates doubling of the object
as in (<ref>), adding a complex conjugated copy to the left.
Any thick-lined box/triangle means that it pertains to mixed states only.
It is not possible to have a thick box or spider connected to a thin wire.
The special case of pure states and pure operations
is indicated with a `hat' notation,

[style=STATERIGHT] (0) at (0, -0.5) 90$\hat{\psi} \vphantom{M^{M^2}}$;
[style=none] (1) at (0, -1) ;
[style=none] (2) at (0, 1) ;
[style=none] (3) at (-0.7, 0.5) $\cD(\mathcal{H})$;

[style=WIRE] (1.center) to (2.center);

[style=StateLeft] (0) at (-0.5, -0.6) 180$\psi$;
[style=StateRight] (1) at (0.5, -0.5)  90$\psi$;
[style=none] (2) at (-0.5, 1) ;
[style=none] (3) at (0.5, 1) ;
[style=none] (10) at (0.8, 0.7) $\mathcal{H}$;
[style=none] (11) at (-0.8, 0.7) $\mathcal{H}$;

(2) to (0.center);
(3) to (1.center);
[->] (0.5,0) – (0.5,0.3);
[->] (-0.5,0.5) – (-0.5,0.2);

[style=ASYM BOX] (0) at (0, 0) $\hat{A}$;
[style=none] (1) at (0.25, 1.5) ;
[style=none] (2) at (0.25, -1.5) ;
[style=none] (4) at (1, 1.25) $\cD({\mathcal H}_{\!4})$;
[style=none] (5) at (1, -1.25) $\cD({\mathcal H}_{\!2})$;
[style=none] (6) at (-0.75, 1.5) ;
[style=none] (7) at (-0.75, -1.5) ;
[style=none] (8) at (-1.5, 1.25) $\cD({\mathcal H}_{\!3})$;
[style=none] (9) at (-1.5, -1.25) ${\cD(\mathcal H}_{\!1})$;

[style=WIRE] (1.center) to (2.center);
[style=WIRE] (6.center) to (7.center);

[style=asym box] (1) at (1.25, 0) $A$;
[style=asym box conjugate] (2) at (-1.5, 0) $A$;
[style=none] (3) at (0.75, 0) ;
[style=none] (4) at (-0.5, 0) ;
[style=none] (13) at (-2.75, -2.25) $\mathcal{H}_1$;
[style=none] (14) at (-1, -2.25) $\mathcal{H}_1$;
[style=none] (15) at (-2.75, 2.25) $\mathcal{H}_3$;
[style=none] (16) at (-1, 2.25) $\mathcal{H}_3$;
[style=none] (17) at (-1.5, 2.25) ;
[style=none] (18) at (-2.25, 2.25) ;
[style=none] (19) at (-2.25, -2.25) ;
[style=none] (20) at (-1.5, -2.25) ;
[style=none] (21) at (0, 1.25) ;
[style=none] (22) at (-1.75, 1.25) ;
[style=none] (23) at (0.75, 0) ;
[style=none] (24) at (-0.5, 0) ;
[style=none] (25) at (-1.5, -2.25) ;
[style=none] (26) at (-2.25, -2.25) ;
[style=none] (27) at (0, -1.25) ;
[style=none] (28) at (-1.75, -1.25) ;
[style=none] (29) at (2, 2.25) ;
[style=none] (30) at (2.75, 2.25) ;
[style=none] (31) at (0, 1.1) ;
[style=none] (32) at (2.25, 1.25) ;
[style=none] (33) at (-2, 0) ;
[style=none] (34) at (1.25, 0) ;
[style=none] (35) at (2, -2.25) ;
[style=none] (36) at (2.75, -2.25) ;
[style=none] (37) at (0, -1.1) ;
[style=none] (38) at (2.25, -1.25) ;
[style=none] (39) at (-2, 0) ;
[style=none] (40) at (1.25, 0) ;
[style=none] (41) at (1.5, 2.25) $\mathcal{H}_4$;
[style=none] (42) at (3.25, 2.25) $\mathcal{H}_4$;
[style=none] (43) at (1.5, -2.25) $\mathcal{H}_2$;
[style=none] (44) at (3.25, -2.25) $\mathcal{H}_2$;

[bend right=45, looseness=0.50] (4.center) to (22.center);
[bend left] (22.center) to (18.center);
[bend left, looseness=1.25] (21.center) to (17.center);
[bend right=45, looseness=0.75] (3.center) to (21.center);
[bend left=45, looseness=0.50] (24.center) to (28.center);
[bend right] (28.center) to (26.center);
[bend right, looseness=1.25] (27.center) to (25.center);
[bend left=45, looseness=0.75] (23.center) to (27.center);
[bend right] (32.center) to (30.center);
[bend right, looseness=1.25] (31.center) to (29.center);
[bend right, looseness=1.25] (31.center) to (33.center);
[bend right, looseness=0.75] (32.center) to (34.center);
[bend left] (38.center) to (36.center);
[bend left, looseness=1.25] (37.center) to (35.center);
[bend left, looseness=1.25] (37.center) to (39.center);
[bend left, looseness=0.75] (38.center) to (40.center);

Thick spiders fuse just like thin spiders.
Non-pure states $\qr$ and non-pure operators $A$ lack the left-right separated form,
but can always be written in decomposed form, e.g.

[style=STATERIGHT] (0) at (0, -0.625) 90$\rho$;
[style=none] (1) at (0, 0.625) ;
[style=none] (2) at (0, -1.125) ;

[style=WIRE] (1.center) to (2.center);

∑_ij ρ_ij
[style=StateLeft] (0) at (-0.5, -0.6) 180$i$;
[style=StateRight] (1) at (0.5, -0.5)  90$j$;
[style=none] (2) at (-0.5, 1) ;
[style=none] (3) at (0.5, 1) ;

(2) to (0.center);
(3) to (1.center);
[->] (0.5,0) – (0.5,0.3);
[->] (-0.5,0.5) – (-0.5,0.2);

While it is not possible for a thick spider to connect to a thin wire, the reverse is possible
(thin spider, thick wire)
since two parallel identical thin wires may be interpreted as a thick one.
The term `bastard spider' is used for a thin spider connected to at least one thick wire.
A number of important examples are shown below,

[style=WhiteSpider] (0) at (0, -1) ;
[style=none] (1) at (0, 1) ;

[style=WIRE] (1) to (0.center);

= d·{}

[style=WhiteSpider] (1) at (0, 0) ;
[style=none] (2) at (0, -1.25) ;
[style=none] (3) at (0, 1.25) ;

(1) to (2.center);
[style=WIRE] (3.center) to (1);

[style=WhiteSpider] (1) at (0, 0) ;
[style=none] (2) at (0, -1.25) ;
[style=none] (3) at (0, 1.25) ;

[style=WIRE] (1) to (2.center);
(3.center) to (1);

The `encoding' operation creates the diagonal matrix element $\ket{ii}$ from the basis state $\ket i$;
`decoding' does the opposite.
These operations allow for a description of quantum-classical systems such that thick wires represent quantum states
and thin wires stand for classical states. (A classical value $i\in\{0,\ldots,d-1\}$ is transported as
the basis state $\ket i$ on a thin wire).
Encoding and decoding in the same basis acts as the identity.
Decoding in a basis complementary to the encoding (orthogonal on the Bloch sphere)
leads to a failure to convey data, which is diagrammatically visible as a disconnect,

[style=WhiteSpider] (0) at (0, -0.5) ;
[style=GraySpider] (1) at (0, 0.5) ;
[style=none] (2) at (0, 1.25) ;
[style=none] (3) at (0, -1.25) ;
[style=GraySpider] (4) at (0, -0.5) ;
[style=WhiteSpider] (5) at (0, -0.5) ;
[style=WhiteSpider] (6) at (0, 0.5) ;

(2.center) to (1);
(0) to (3.center);
[style=WIRE] (1) to (4);
[->] (0,0.9) – (0,1.1);
[->] (0,-1.25) – (0,-0.9);

[style=none] (0) at (0, 1) ;
[style=none] (1) at (0, -1) ;

(0.center) to (1.center);
[->] (0,-1) – (0,0.1);

[style=GraySpider] (0) at (0, -0.5) ;
[style=WhiteSpider] (1) at (0, 0.5) ;
[style=none] (2) at (0, -1.25) ;
[style=none] (3) at (0, 1.25) ;

[style=WIRE] (1) to (0);
(0) to (2.center);
(3.center) to (1);

= 1/2
[style=GraySpider] (0) at (0, -0.5) ;
[style=WhiteSpider] (1) at (0, 0.5) ;
[style=none] (2) at (0, -1.25) ;
[style=none] (3) at (0, 1.25) ;

(0) to (2.center);
(3.center) to (1);

The fusion of a thin spider and a thick spider leads to a bastard spider.

\begin{equation}
\label{equation:bastardspiderfusion}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (1) at (-1.75, 1.5) {};
\node [style=none] (3) at (-0.5, 1.5) {};
\node [style=none] (4) at (-2, -1.75) {};
\node [style=none] (5) at (-0.5, -1.75) {};
\node [style=none] (6) at (0, 0) {};
\node [style=none] (7) at (-1.75, 1.5) {};
\node [style=WhiteSpider] (12) at (1, -0.5) {};
\node [style=none] (13) at (0, 0) {};
\node [style=none] (14) at (1, 1.5) {};
\node [style=none] (15) at (2, 1.5) {};
\node [style=none] (16) at (0.5, -1.75) {};
\node [style=none] (18) at (1.75, -1.75) {};
\node [style=none] (19) at (0, 0) {};
\node [style=WHITESPIDER] (26) at (-1, 0.5) {};
\node [style=none] (27) at (-1.5, -1.75) {};
\node [style=none] (28) at (-1, -1.75) {};
\node [style=none] (29) at (-1.25, 1.5) {};
\node [style=none] (30) at (-0.75, 1.5) {};
\node [style=none] (31) at (1.25, 1.5) {};
\node [style=none] (32) at (1.75, 1.5) {};
\node [style=none] (33) at (0.75, -1.75) {};
\node [style=none] (34) at (1.25, -1.75) {};
\node [style=none] (35) at (0.25, 2) {\small $n$ outputs};
\node [style=none] (36) at (0, -2.25) {\small $m$ inputs};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [bend left=15] (12) to (14.center);
\draw [bend right] (12) to (15.center);
\draw [bend right=15] (12) to (16.center);
\draw [bend left] (12) to (18.center);
\draw [style=WIRE, bend left, looseness=0.75] (12) to (19.center);
\draw [style=WIRE, bend right] (19.center) to (26);
\draw [style=WIRE, bend right=15] (26) to (3.center);
\draw [style=WIRE, bend left] (26) to (7.center);
\draw [style=WIRE, bend right=15] (26) to (4.center);
\draw [style=WIRE, bend left=15] (26) to (5.center);
\draw [style=new edge style 0] (29.center) to (30.center);
\draw [style=new edge style 0] (31.center) to (32.center);
\draw [style=new edge style 0] (33.center) to (34.center);
\draw [style=new edge style 0] (27.center) to (28.center);
\end{pgfonlayer}
\end{tikzpicture} \quad=\quad \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (2) at (0.25, 1.5) {};
\node [style=none] (4) at (-1.5, -1.75) {};
\node [style=none] (5) at (-0.25, -1.75) {};
\node [style=none] (7) at (-1, 1.5) {};
\node [style=none] (14) at (1.25, 1.5) {};
\node [style=none] (15) at (2.25, 1.5) {};
\node [style=none] (17) at (0.75, -1.75) {};
\node [style=none] (18) at (2, -1.75) {};
\node [style=none] (27) at (-1, -1.75) {};
\node [style=none] (28) at (-0.5, -1.75) {};
\node [style=none] (29) at (1.15, -1.75) {};
\node [style=none] (30) at (1.65, -1.75) {};
\node [style=none] (31) at (1.5, 1.5) {};
\node [style=none] (32) at (2, 1.5) {};
\node [style=none] (33) at (-0.625, 1.5) {};
\node [style=none] (34) at (-0.125, 1.5) {};
\node [style=none] (35) at (0.75, 2) {\small $n$ outputs};
\node [style=none] (36) at (0.25, -2.25) {\small $m$ inputs};
\node [style=WhiteSpider] (37) at (1, -0.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=new edge style 0] (27.center) to (28.center);
\draw [style=new edge style 0] (29.center) to (30.center);
\draw [style=new edge style 0] (31.center) to (32.center);
\draw [style=new edge style 0] (33.center) to (34.center);
\draw [bend left=15] (37) to (18.center);
\draw (37) to (17.center);
\draw [bend right=15] (37) to (15.center);
\draw (37) to (14.center);
\draw [style=WIRE, bend right=15] (37) to (5.center);
\draw [style=WIRE, bend left=15] (37) to (2.center);
\draw [style=WIRE, bend left=15] (37) to (7.center);
\draw [style=WIRE, bend right=15] (37) to (4.center);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

Taking the trace.
The (partial) trace of a state is taken by connecting two whin wires that together make up a thick wire.
This operation is depicted with the `ground' symbol.

[style=none] (0) at (-0.5, 0.25) ;
[style=none] (1) at (0.5, 0.25) ;
[style=none] (2) at (-0.25, 0.5) ;
[style=none] (3) at (0.25, 0.5) ;
[style=none] (4) at (-0.75, 0) ;
[style=none] (5) at (0.75, 0) ;
[style=none] (6) at (0, 0) ;
[style=none] (7) at (0, -1) ;

[style=WIRE] (2.center) to (3.center);
[style=WIRE] (0.center) to (1.center);
[style=WIRE] (4.center) to (5.center);
[style=WIRE] (6.center) to (7.center);

[style=none] (1) at (0, -1) ;
[style=none] (2) at (0, 0.25) ;

[style=EFFECTRIGHT] (4) at (0, 0) 0i;

[style=WIRE] (2.center) to (1.center);

(<ref>)  ∑_i
[style=none] (2) at (0.6, -1) ;
[style=none] (3) at (-1, -1) ;
[style=none] (4) at (-1, 0.5) ;
[style=none] (5) at (0.6, 0.5) ;

[style=EffectLeft] (7) at (-1, 0.25) -90i;
[style=EffectRight] (8) at (0.6, 0.26) 0i;

(5.center) to (2.center);
(4.center) to (3.center);
[->] (-1,0) – (-1,-0.5);
[->] (0.6,-0.6) – (0.6,-0.4);

[style=none] (0) at (-0.5, -1) ;
[style=none] (1) at (0.5, -1) ;
[style=none] (2) at (0.5, 0) ;
[style=none] (3) at (-0.5, 0) ;
[style=none] (4) at (0, 1) ;
[style=none] (5) at (0, 1) ;

(2.center) to (1.center);
(3.center) to (0.center);
[in=180, out=90] (3.center) to (5.center);
[in=90, out=0] (5.center) to (2.center);
[->] (0.5,-0.2) – (0.5,0);
[->] (-0.5,0) – (-0.5,-0.1);

Another name for this operation is `discarding', since the thick wire terminates.

In the operator formulation of mixed states it holds that $\tr\tilde\qr=1$.
Diagrammatically this is expressed as

[style=STATERIGHT] (0) at (0, -1.25) 90$\rho$;
[style=none] (1) at (0, -1.5) ;
[style=none] (2) at (0, 0.25) ;
[style=none] (3) at (0, -1.5) ;
[style=none] (4) at (-0.75, 0.25) ;
[style=none] (5) at (0.75, 0.25) ;
[style=none] (6) at (-0.5, 0.5) ;
[style=none] (7) at (0.5, 0.5) ;
[style=none] (8) at (-0.25, 0.75) ;
[style=none] (9) at (0.25, 0.75) ;

[style=WIRE, in=90, out=-90] (2.center) to (3.center);
[style=WIRE] (4.center) to (5.center);
[style=WIRE] (6.center) to (7.center);
[style=WIRE] (8.center) to (9.center);

(<ref>)(<ref>) ∑_ij_ij
[style=none] (0) at (-1, -1) ;
[style=none] (1) at (1, -1) ;
[style=none] (2) at (1, 0) ;
[style=none] (3) at (-1, 0) ;
[style=none] (4) at (0, 1) ;
[style=none] (5) at (0, 1) ;

[style=StateLeft] (9) at (-1, -0.75) 180i;
[style=StateRight] (10) at (1, -0.75) 90j;

(2.center) to (1.center);
(3.center) to (0.center);
[in=180, out=90] (3.center) to (5.center);
[in=90, out=0] (5.center) to (2.center);
[->] (1,-0.5) – (1,0);
[->] (-1,-0.0) – (-1,-0.1);

(<ref>) ∑_ij ρ_ij _ij
= ∑_i ρ_ii =1.
For a bipartite system,
taking the partial trace $\tr_{\!\rm A}\tilde\qr^{\rm AB}$ to obtain the state of the `B' subsystem
is depicted as

[style=WIDESTATERIGHT] (0) at (0, 0) 90$\rho$;
[style=none] (1) at (-0.5, -0.25) ;
[style=none] (2) at (0.5, -0.15) ;
[style=none] (3) at (0.5, 1.5) ;
[style=none] (4) at (-0.5, 1) ;
[style=none] (0) at (-0.8, 0.6) A;
[style=none] (0) at (0.8, 0.6) B;
[style=none] (10) at (-1, 1) ;
[style=none] (11) at (0, 1) ;
[style=none] (12) at (-0.75, 1.25) ;
[style=none] (13) at (-0.25, 1.25) ;
[style=none] (14) at (-0.625, 1.5) ;
[style=none] (15) at (-0.375, 1.5) ;

[style=WIRE] (3.center) to (2.center);
[style=WIRE] (4.center) to (1.center);
[style=WIRE] (10.center) to (11.center);
[style=WIRE] (12.center) to (13.center);
[style=WIRE] (14.center) to (15.center);

Similarly, a non-pure map $\qF$ can be represented as a partially traced out pure map $\hat f$,

[style=ASYM BOX] (0) at (0, 0) ${\Phi}$;
[style=none] (1) at (0, 1.5) ;
[style=none] (2) at (0, -1.5) ;

[style=WIRE] (1.center) to (2.center);

[style=ASYM BOX] (0) at (0, 0) $\hat{f}$;
[style=none] (1) at (0.25, 1.5) ;
[style=none] (2) at (0.25, 0) ;
[style=none] (6) at (-0.5, 1) ;
[style=none] (7) at (-0.5, 0) ;
[style=none] (8) at (-0.175, 0) ;
[style=none] (9) at (-0.175, -1.5) ;
[style=none] (10) at (-1, 1) ;
[style=none] (11) at (0, 1) ;
[style=none] (12) at (-0.75, 1.25) ;
[style=none] (13) at (-0.25, 1.25) ;
[style=none] (14) at (-0.625, 1.5) ;
[style=none] (15) at (-0.375, 1.5) ;

[style=WIRE] (1.center) to (2.center);
[style=WIRE] (6.center) to (7.center);
[style=WIRE] (8.center) to (9.center);
[style=WIRE] (10.center) to (11.center);
[style=WIRE] (12.center) to (13.center);
[style=WIRE] (14.center) to (15.center);

[style=asym box] (1) at (1.25, 0) $f$;
[style=asym box conjugate] (2) at (-1.5, 0) $f$;
[style=none] (34) at (1.25, 0) ;
[style=none] (40) at (1.25, 0) ;
[style=none] (41) at (0, 1) ;
[style=none] (42) at (-1.5, -1.25) ;
[style=none] (43) at (1.25, -1.25) ;
[style=none] (44) at (1.75, 1.25) ;
[style=none] (45) at (1.75, 0) ;
[style=none] (46) at (-2, 1.25) ;
[style=none] (47) at (-2, 0) ;

[bend left] (2) to (41.center);
[bend right] (40.center) to (41.center);
(2) to (42.center);
(40.center) to (43.center);
(46.center) to (47.center);
(44.center) to (45.center);
[->] (0.001,1) – (0,1);
[->] (1.75,1) – (1.75,1.1);
[->] (-2,1.2) – (-2,0.9);
[->] (1.25,-1.25) – (1.25,-0.9);
[->] (-1.5,-0.8) – (-1.5,-1);

The purified $f$ is unique up to a unitary operation applied to the traced-out wire.
This leads to the following lemma,

\begin{equation}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=ASYM BOX] (0) at (0, 0) {\reflectbox{$\hat F$}};
\node [style=none] (1) at (0, -1.5) {};
\node [style=none] (2) at (-0.5, 0) {};
\node [style=none] (3) at (1, 0) {};
\node [style=none] (4) at (0.75, 1.5) {};
\node [style=none] (5) at (-0.5, 1) {};
\node [style=none] (6) at (0.75, 0) {};
\node [style=none] (7) at (-0.5, 1) {};
\node [style=none] (8) at (-0.5, 1) {};
\node [style=none] (9) at (-1, 1) {};
\node [style=none] (10) at (0, 1) {};
\node [style=none] (11) at (-0.75, 1.25) {};
\node [style=none] (12) at (-0.25, 1.25) {};
\node [style=none] (13) at (-0.6, 1.5) {};
\node [style=none] (14) at (-0.6, 1.5) {};
\node [style=none] (15) at (-0.4, 1.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=WIRE] (4.center) to (6.center);
\draw [style=WIRE] (14.center) to (15.center);
\draw [style=WIRE] (11.center) to (12.center);
\draw [style=WIRE] (9.center) to (10.center);
\draw [style=WIRE] (8.center) to (2.center);
\draw [style=WIRE] (0) to (1.center);
\end{pgfonlayer}
\end{tikzpicture} =\; \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=ASYM BOX] (0) at (0, 0) {\reflectbox{$\hat G$}};
\node [style=none] (1) at (0, -1.5) {};
\node [style=none] (2) at (-0.5, 0) {};
\node [style=none] (3) at (1, 0) {};
\node [style=none] (4) at (0.75, 1.5) {};
\node [style=none] (5) at (-0.5, 1) {};
\node [style=none] (6) at (0.75, 0) {};
\node [style=none] (7) at (-0.5, 1) {};
\node [style=none] (8) at (-0.5, 1) {};
\node [style=none] (9) at (-1, 1) {};
\node [style=none] (10) at (0, 1) {};
\node [style=none] (11) at (-0.75, 1.25) {};
\node [style=none] (12) at (-0.25, 1.25) {};
\node [style=none] (13) at (-0.6, 1.5) {};
\node [style=none] (14) at (-0.6, 1.5) {};
\node [style=none] (15) at (-0.4, 1.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=WIRE] (4.center) to (6.center);
\draw [style=WIRE] (14.center) to (15.center);
\draw [style=WIRE] (11.center) to (12.center);
\draw [style=WIRE] (9.center) to (10.center);
\draw [style=WIRE] (8.center) to (2.center);
\draw [style=WIRE] (0) to (1.center);
\end{pgfonlayer}
\end{tikzpicture}
\quad\quad\quad  \implies \quad\quad\quad
\exists_{\mbox{unitary }U}\;\; \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=asym box] (0) at (0, 0) {\reflectbox{$F$}};
\node [style=none] (1) at (-0.75, 0) {};
\node [style=none] (2) at (0.75, 0) {};
\node [style=none] (3) at (0.75, 2) {};
\node [style=none] (4) at (-0.75, 2) {};
\node [style=none] (5) at (0, -1.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (3.center) to (2.center);
\draw (4.center) to (1.center);
\draw (0) to (5.center);
\end{pgfonlayer}
\end{tikzpicture} = \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=asym box] (0) at (0, 0) {\reflectbox{$G$}};
\node [style=none] (1) at (-0.75, 0) {};
\node [style=none] (2) at (0.75, 0) {};
\node [style=none] (3) at (0.75, 3) {};
\node [style=none] (4) at (-0.75, 3) {};
\node [style=none] (5) at (0, -1.5) {};
\node [style=medium box] (6) at (-0.75, 1.75) {U};
\node [style=none] (7) at (0.75, 3) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [in=90, out=-90] (3.center) to (2.center);
\draw (4.center) to (1.center);
\draw (0) to (5.center);
\end{pgfonlayer}
\end{tikzpicture}
\label{equation:uniquenesspurification}
\end{equation}

In the POVM formalism (Positive Operator Valued Measure), a measurement $\cM$ is described by a set of `elements' $\{E_x\}_{x\in\cX}$ acting on $\cH$,
with $\cX$ the possible outcomes of the measurement.
These elements satisfy $\sum_{x\in\cX}E_x\dagg E_x={\bf 1}$.
Given a state $\tilde\qr$, the probability of outcome $x$ is given by
$\pr[\cM\to x]_{\tilde\qr}=\tr  E_x\dagg E_x \tilde\qr$;
diagramatically this is depicted as
[→x]_   =
[style=STATERIGHT] (0) at (0, -2.625) 90$\rho$;
[style=none] (1) at (0, -2.5) ;
[style=none] (2) at (0, 2.3) ;
[style=none] (3) at (0.15, -2.25) ;
[style=none] (4) at (0.64, -1.6) ;
[style=asym box] (5) at (1.7, -0.6) $E_x$;
[style=none] (6) at (1.7, -1.2) ;
[style=asym box adjoint] (7) at (1.7, 1.2) $E_x$;
[style=none] (8) at (1.7, -0.1) ;
[style=none] (9) at (1.7, 2.3) ;
[style=none] (10) at (0.85, 2.9) ;

(1) to (2.center);
[in=180, out=90] (3.center) to (4.center);
[out=0, in=270] (4.center) to (6);
(8) to (9.center);
[in=180, out=90] (2.center) to (10.center);
[in=90, out=0] (10.center) to (9.center);
[->] (0,0) – (0,-0.1);
[->] (1.7,0) – (1.7,0.3);
[->] (1.7,1.8) – (1.7,2.2);
[->] (0.79,-1.6) – (0.8,-1.6);

[style=STATERIGHT] (0) at (0, -2.625) 90$\rho$;
[style=none] (1) at (-0.075, -2.25) ;
[style=none] (2) at (-0.64, -1.6) ;
[style=none] (3) at (0.075, -2.25) ;
[style=none] (4) at (0.64, -1.6) ;
[style=asym box] (5) at (1.7, -0.6) $E_x$;
[style=none] (6) at (1.7, -1.2) ;
[style=asym box conjugate] (7) at (-1.7, -0.6) $E_x$;
[style=none] (8) at (1.7, -0.1) ;
[style=none] (9) at (1.7, 0.5) ;
[style=none] (10) at (0, 1.1) ;
[style=none] (11) at (-1.7, 0.5) ;
[style=none] (12) at (-1.7, -1.2) ;
[style=none] (16) at (-1.7, -0.1) ;
[style=none] (18) at (-1.7, 0.5) ;

[in=180, out=90] (3.center) to (4.center);
[out=0, in=270] (4.center) to (6);
(8) to (9.center);
[in=180, out=90] (11.center) to (10.center);
[in=90, out=0] (10.center) to (9.center);
[out=90, in =0] (1.center) to (2.center);
[out=180, in=-90] (2.center) to (12.center);
(16) to (18.center);
[->] (1.7,0) – (1.7,0.3);
[->] (-1.7,0.3) – (-1.7,0.2);
[->] (0.6,-1.6) – (0.8,-1.6);
[->] (-0.71,-1.6) – (-0.7,-1.6);

[style=STATERIGHT] (0) at (0, -1.625) 90$\rho$;
[style=none] (1) at (0, 1.3) ;
[style=none] (2) at (0, -2.125) ;
[style=ASYM BOX] (3) at (0.5, 0) $\hat E_x$;
[style=none] (10) at (-0.5, 1.3) ;
[style=none] (11) at ( 0.5, 1.3) ;
[style=none] (12) at (-0.25, 1.55) ;
[style=none] (13) at ( 0.25, 1.55) ;
[style=none] (14) at (-0.125, 1.8) ;
[style=none] (15) at ( 0.125, 1.8) ;

[style=WIRE] (1.center) to (2.center);
[style=WIRE] (10.center) to (11.center);
[style=WIRE] (12.center) to (13.center);
[style=WIRE] (14.center) to (15.center);

The Hermitian conjugate of discarding equals the preparation of the fully mixed state, up to a factor $d$.

[style=none] (0) at (-0.5, -0.25) ;
[style=none] (1) at (0.5,  -0.25) ;
[style=none] (2) at (-0.25, -0.5) ;
[style=none] (3) at (0.25,  -0.5) ;
[style=none] (4) at (-0.75, 0) ;
[style=none] (5) at (0.75, 0) ;
[style=none] (6) at (0, 0) ;
[style=none] (7) at (0, 1) ;

[style=WIRE] (2.center) to (3.center);
[style=WIRE] (0.center) to (1.center);
[style=WIRE] (4.center) to (5.center);
[style=WIRE] (6.center) to (7.center);

(<ref>) ∑_i
[style=none] (3) at (0, -0.5) ;
[style=STATERIGHT] (4) at (0, 0) 90$i$;
[style=none] (6) at (0, 1) ;

[style=WIRE] (3.center) to (6.center);

(<ref>) ∑_i
[style=StateLeft] (0) at (-0.5, -0.6) 180$i$;
[style=StateRight] (1) at (0.5, -0.5)  90$i$;
[style=none] (2) at (-0.5, 1) ;
[style=none] (3) at (0.5, 1) ;

(2) to (0.center);
(3) to (1.center);
[->] (0.5,0) – (0.5,0.3);
[->] (-0.5,0.5) – (-0.5,0.2);

= d·{}.

§ PROTOCOLS

§.§ The Quantum One Time Pad

We showed the QOTP encryption step in (<ref>).
The full diagram for encryption and decryption of a qubit state
(and including the most general attack
that Eve could launch) is given below, up to a numerical factor $4$.

[style=GraySpider] (0) at (-2.5, -4.25) ;
[style=WHITESPIDER] (1) at (-3.25, -3.5) ;
[style=none] (2) at (-3.25, -5) ;
[style=none] (3) at (-3.25, -2.5) ;
[style=GraySpider] (5) at (-1.75, -5.25) ;
[style=none] (6) at (-3.25, -3.5) ;
[style=GRAYSPIDER] (8) at (-3.25, -2.5) ;
[style=WhiteSpider] (9) at (-2.5, -3.25) ;
[style=WhiteSpider] (10) at (-1.75, -4.25) ;
[style=GraySpider] (11) at (5, 3) ;
[style=WHITESPIDER] (12) at (2.25, 4.25) ;
[style=none] (13) at (2.25, 4.75) ;
[style=none] (14) at (2.25, 2.5) ;
[style=none] (18) at (-3.25, -2.5) ;
[style=GRAYSPIDER] (19) at (2.25, 3.25) ;
[style=WhiteSpider] (20) at (3.75, 2.75) ;
[style=WhiteSpider] (21) at (-1.75, -4.25) ;
[style=ASYM BOX] (23) at (0, 0.35) $\Phi$;
[style=none] (26) at (-3.25, -5) ;
[style=none] (34) at (-3.25, -2) ;
[style=none] (35) at (1.25, 1.5) ;
[style=none] (36) at (0.5, 0.75) ;
[style=none] (37) at (-2, -1) ;
[style=none] (38) at (-0.25, 0.25) ;
[style=none] (39) at (-0.25, 2) ;
[style=none] (40) at (-0.25, 2.75) ;
[style=none] (41) at (-1.325, -6.25) ;
[style=none] (42) at (1.825, -6.25) ;
[style=none] (43) at (1.825, 5) ;
[style=none] (44) at (-1.325, 5) ;
[style=none] (45) at (-2.25, -5.95) Alice;
[style=none] (46) at (0.1, -5.95) Eve;
[style=none] (47) at (2.625, -5.95) Bob;

[style=WIRE, bend left=45] (1) to (0);
[style=WIRE] (3.center) to (2.center);
(0) to (5);
[style=WIRE, bend left=45] (8) to (9);
(9) to (10);
[style=WIRE, bend left] (12) to (11);
[style=WIRE] (14.center) to (13.center);
[style=WIRE, bend left=45] (19) to (20);
[bend left=15] (20) to (21);
[bend left=15] (11) to (5);
[style=WIRE] (34.center) to (18.center);
[style=WIRE, bend left=45] (34.center) to (37.center);
[style=WIRE, bend right] (37.center) to (38.center);
[style=WIRE, bend left, looseness=1.25] (36.center) to (35.center);
[style=WIRE, bend right=45] (35.center) to (14.center);
[style=WIRE] (39.center) to (38.center);
[style=new edge style 0] (44.center) to (41.center);
[style=new edge style 0] (43.center) to (42.center);

The use of thick wires is necessary because (i) Eve's attack $\qF$ is allowed to be very general;
(ii) Alice may not know what state she is encrypting.
The thin spiders connected to thin wires, at the bottom of the diagram, generate the two random key bits.
One copy goes to Alice, one to Bob.
Eve does not learn the key; this is visually clear, as the attack $\qF$ does not have the key as input.
The encryption by Alice is the doubled version of (<ref>), with $u$ and $v$ replaced by the random
bits from the thin spiders.
Bob's decryption is the Hermitian conjugate of the encryption.
Correctness of the scheme means that Bob correctly receives the state that Alice sent if
Eve does not interfere. Diagramatically, correctness is proven by removing the $\qF$ box and
then using spider contraction rules to show that the protocol diagram reduces to a thick wire from Alice to Bob.

[style=GraySpider] (0) at (-1.25, -4) ;
[style=WHITESPIDER] (1) at (-2, -3.25) ;
[style=none] (2) at (-2, -4) ;
[style=none] (3) at (-2, -2.25) ;
[style=GraySpider] (5) at (-0.5, -4.5) ;
[style=none] (6) at (-2, -3.25) ;
[style=none] (7) at (-0.5, 0) ;
[style=GRAYSPIDER] (8) at (-2, -2.25) ;
[style=WhiteSpider] (9) at (-1.25, -3) ;
[style=WhiteSpider] (10) at (-0.5, -3.5) ;
[style=GraySpider] (11) at (3.5, 2.25) ;
[style=WHITESPIDER] (12) at (1, 3.5) ;
[style=none] (13) at (1, 2.5) ;
[style=none] (14) at (-0.5, 0) ;
[style=none] (18) at (-2, -2.25) ;
[style=GRAYSPIDER] (19) at (1, 2.5) ;
[style=WhiteSpider] (20) at (2.5, 2) ;
[style=WhiteSpider] (21) at (-0.5, -3.5) ;
[style=none] (33) at (-2, -5) ;
[style=none] (34) at (1, 4.25) ;
[style=none] (35) at (0, 4.25) ;
[style=none] (36) at (0, -5.75) ;
[style=none] (37) at (-1, -5.5) Alice;
[style=none] (38) at (0.85, -5.5) Bob;

[style=WIRE, bend left=45] (1) to (0);
[style=WIRE] (3.center) to (2.center);
(0) to (5);
[style=WIRE, bend left=45] (8) to (9);
(9) to (10);
[style=WIRE, bend left] (12) to (11);
[style=WIRE, bend right=15] (14.center) to (13.center);
[style=WIRE, bend left=45] (19) to (20);
[bend left=15] (20) to (21);
[bend left=15] (11) to (5);

[style=WIRE, bend left=15] (18.center) to (14.center);
[style=WIRE] (19) to (12);
[style=WIRE] (34.center) to (12);
[style=new edge style 0] (35.center) to (36.center);

[style=GraySpider] (0) at (2.75, 0.25) ;
[style=WHITESPIDER] (1) at (0, -1.75) ;
[style=none] (2) at (0, -2.5) ;
[style=none] (3) at (0, -0.75) ;
[style=none] (6) at (0, -1.75) ;
[style=none] (7) at (0, 0.25) ;
[style=GRAYSPIDER] (8) at (0, -0.75) ;
[style=WhiteSpider] (9) at (1.25, 0.5) ;
[style=GraySpider] (11) at (2.75, 0.25) ;
[style=WHITESPIDER] (12) at (0, 2.5) ;
[style=none] (13) at (0, 3.25) ;
[style=none] (14) at (0, 0.25) ;
[style=none] (18) at (0, -0.75) ;
[style=GRAYSPIDER] (19) at (0, 1.5) ;
[style=WhiteSpider] (20) at (1.25, 0.5) ;
[style=none] (21) at (0, -3.5) ;

[style=WIRE, bend right, looseness=0.75] (1) to (0);
[style=WIRE] (3.center) to (2.center);
[style=WIRE] (7.center) to (6.center);
[style=WIRE, bend right=15, looseness=0.75] (8) to (9);
[style=WIRE, bend left] (12) to (11);
[style=WIRE] (14.center) to (13.center);
[style=WIRE, bend left=45] (19) to (20);

[style=GraySpider] (0) at (2.75, 0.25) ;
[style=WHITESPIDER] (1) at (0, -0.75) ;
[style=none] (2) at (0, -2.5) ;
[style=none] (3) at (0, -0.75) ;
[style=none] (6) at (0, -1.25) ;
[style=none] (7) at (0, 0.25) ;
[style=GRAYSPIDER] (8) at (0, 0.25) ;
[style=WhiteSpider] (9) at (1.25, 0.5) ;
[style=GraySpider] (11) at (2.75, 0.25) ;
[style=WHITESPIDER] (12) at (0, 1.5) ;
[style=none] (13) at (0, 3.25) ;
[style=none] (14) at (0, 0.25) ;
[style=GRAYSPIDER] (19) at (0, 0.25) ;
[style=WhiteSpider] (20) at (1.25, 0.5) ;
[style=none] (21) at (0, -3.5) ;

[style=WIRE, bend right, looseness=0.75] (1) to (0);
[style=WIRE] (3.center) to (2.center);
[style=WIRE] (7.center) to (6.center);
[style=WIRE, bend right=15, looseness=0.75] (8) to (9);
[style=WIRE, bend left] (12) to (11);
[style=WIRE] (14.center) to (13.center);
[style=WIRE, bend left=45] (19) to (20);

(*)  1/2
[style=GraySpider] (0) at (1, 0.25) ;
[style=WHITESPIDER] (1) at (0, -0.75) ;
[style=none] (2) at (0, -2.5) ;
[style=none] (3) at (0, -0.75) ;
[style=none] (6) at (0, -1.25) ;
[style=none] (7) at (0, 0.25) ;
[style=GRAYSPIDER] (8) at (0, 0.25) ;

[style=WHITESPIDER] (12) at (0, 1.5) ;
[style=none] (13) at (0, 3.25) ;
[style=none] (14) at (0, 0.25) ;
[style=GRAYSPIDER] (19) at (0, 0.25) ;

[style=none] (21) at (0, -3.5) ;

[style=WIRE, bend right, looseness=0.75] (1) to (0);
[style=WIRE] (3.center) to (2.center);
[style=WIRE] (7.center) to (6.center);
[style=WIRE, bend left] (12) to (0);
[style=WIRE] (14.center) to (13.center);

(<ref>,<ref>) 1/2
[style=GraySpider] (0) at (1, 0.25) ;
[style=WHITESPIDER] (1) at (0, 0.25) ;
[style=none] (2) at (0, -2.5) ;
[style=none] (3) at (0, -0.25) ;
[style=none] (6) at (0, -1.25) ;
[style=none] (7) at (0, 0.25) ;

[style=WHITESPIDER] (12) at (0, 0.25) ;
[style=none] (13) at (0, 3.25) ;
[style=none] (21) at (0, -3.5) ;

[style=WIRE, bend right, looseness=0.75] (1) to (0);
[style=WIRE] (3.center) to (2.center);
[style=WIRE] (7.center) to (6.center);
[style=WIRE, bend left] (12) to (0);
[style=WIRE] (13.center) to (7.center);

(*) 1/4
[style=none] (2) at (-2, -1.75) ;
[style=none] (23) at (-2, -2.75) ;
[style=none] (24) at (2.25, 2.25) ;
[style=none] (25) at (0, 0) ;
[style=none] (26) at (0, 2.25) ;
[style=none] (27) at (0, -2.75) ;
[style=none] (28) at (-0.9, -2.5) Alice;
[style=none] (29) at (0.75, -2.5) Bob;

[style=WIRE, bend left=45] (2.center) to (25.center);
[style=WIRE, bend right=45] (25.center) to (24.center);
[style=new edge style 0] (26.center) to (27.center);

Step (*) consists of two parts:
First, a double thin connection between complementary thin spiders yields a numerical factor $1/2$ and a disconnect,[
We ignore a subtlety involving so-called `antipodes' [3], which is allowed here because the antipode evaluates to
the identity in the case of the combination of the $x$ and $z$ basis.
as we saw in (<ref>); now we have a version of this situation where one of the spiders is doubled,
yielding a factor $1/4$ instead of $1/2$.
Second, the isolated thin spider yields a factor $2$ due to the basis summation.

Security of the scheme means that Eve does not learn what Alice's state is.
Diagrammatically, security is `proven' by tracing out Bob and showing that the output of Eve's
attack $\qF$ is decoupled from Alice's input wire.
Tracing out Bob removes the entire branch going from Alice to Bob.
The part of the diagram that serves as input to $\qF$ reduces to

\begin{equation}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=GraySpider] (0) at (1, -0.75) {};
\node [style=WHITESPIDER] (1) at (0, 0.25) {};
\node [style=none] (2) at (0, -1.75) {};
\node [style=none] (3) at (0, 1.25) {};
%		\node [style=GraySpider] (4) at (1, -1.75) {};
%		\node [style=GraySpider] (5) at (1, -1.75) {};
\node [style=none] (6) at (0, 0.25) {};
\node [style=none] (7) at (0, 2.25) {};
\node [style=GRAYSPIDER] (8) at (0, 1.25) {};
\node [style=WhiteSpider] (9) at (1.75, 0.25) {};
%		\node [style=WhiteSpider] (10) at (1.75, -0.75) {};
\node [style=none] (11) at (0, -2.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=WIRE, bend left=45] (1) to (0);
\draw [style=WIRE] (3.center) to (2.center);
%		\draw (0) to (5);
\draw [style=WIRE] (7.center) to (6.center);
\draw [style=WIRE, out=0, in=100] (8) to (9);
%		\draw (9) to (10);
%		\draw [style=DOTTED] (2.center) to (11.center);
\end{pgfonlayer}
\end{tikzpicture}
\equaltext{(\ref{FullyMixed})} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=WHITESPIDER] (1) at (0, 0.25) {};
\node [style=none] (2) at (0, -1.75) {};
\node [style=none] (3) at (0, 1.25) {};
\node [style=none] (6) at (0, 0.25) {};
\node [style=none] (7) at (0, 2.25) {};
\node [style=GRAYSPIDER] (8) at (0, 1.25) {};

\node [style=none] (12) at (3.25, 0.25) {};
\node [style=none] (13) at (2, 0.25) {};
\node [style=none] (14) at (3, 0) {};
\node [style=none] (15) at (2.25, 0) {};
\node [style=none] (16) at (2.75, -0.25) {};
\node [style=none] (17) at (2.5, -0.25) {};

\node [style=none] (18) at (1.625, -0.75) {};
\node [style=none] (19) at (0.375, -0.75) {};
\node [style=none] (20) at (1.375, -1) {};
\node [style=none] (21) at (0.625, -1) {};
\node [style=none] (22) at (1.125, -1.25) {};
\node [style=none] (23) at (0.875, -1.25) {};

\node [style=none] (24) at (1, -0.75) {};
\node [style=none] (25) at (2.625, 0.25) {};
\node [style=none] (11) at (0, -2.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=WIRE] (3.center) to (2.center);
\draw [style=WIRE] (7.center) to (6.center);
\draw [style=WIRE] (12.center) to (13.center);
\draw [style=WIRE] (14.center) to (15.center);
\draw [style=WIRE] (16.center) to (17.center);
\draw [style=WIRE] (18.center) to (19.center);
\draw [style=WIRE] (20.center) to (21.center);
\draw [style=WIRE] (22.center) to (23.center);
\draw [style=WIRE, bend right=330] (8) to (25.center);
\draw [style=WIRE, bend right=315, looseness=1.25] (6.center) to (24.center);
%		\draw [style=DOTTED] (2.center) to (11.center);
\end{pgfonlayer}
\end{tikzpicture}
\equaltext{(\ref{FullyMixed})} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=WHITESPIDER] (1) at (0, 0.25) {};
\node [style=none] (2) at (0, -1.75) {};
\node [style=none] (3) at (0, 1.25) {};
\node [style=none] (6) at (0, 0.25) {};
\node [style=none] (7) at (0, 2.25) {};
\node [style=GRAYSPIDER] (8) at (0, 1.25) {};
\node [style=none] (24) at (1, -0.75) {};
\node [style=none] (25) at (1.975, 0.25) {};
\node [style=WhiteSpider] (26) at (1, -0.75) {};
\node [style=GraySpider] (27) at (2, 0.25) {};
\node [style=none] (11) at (0, -2.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=WIRE] (3.center) to (2.center);
\draw [style=WIRE] (7.center) to (6.center);
\draw [style=WIRE, bend right=330] (8) to (25.center);
\draw [style=WIRE, bend right=315, looseness=1.25] (6.center) to (24.center);
%		\draw [style=DOTTED] (2.center) to (11.center);
\end{pgfonlayer}
\end{tikzpicture}
\equaltext{(\ref{equation:bastardspiderfusion})} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (2) at (0, -1.75) {};
\node [style=none] (3) at (0, 1.25) {};
\node [style=none] (7) at (0, 2.25) {};
\node [style=GraySpider] (12) at (0, 1.25) {};
\node [style=WhiteSpider] (13) at (0, 0.25) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=WIRE] (3.center) to (2.center);
\draw [style=WIRE] (7.center) to (3.center);
%		\draw [style=DOTTED] (2.center) to (11.center);
\end{pgfonlayer}
\end{tikzpicture}
\equaltext{(\ref{equation:ComplementarityPositive})} \frac{1}{2} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (2) at (0, -1.75) {};
\node [style=none] (3) at (0, 1.25) {};
\node [style=none] (7) at (0, 2.25) {};
\node [style=GraySpider] (12) at (0, 1.25) {};
\node [style=WhiteSpider] (13) at (0, 0.25) {};
\node [style=none] (14) at (0, -2.5) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=WIRE] (7.center) to (3.center);
\draw [style=WIRE] (13) to (2.center);
%		\draw [style=DOTTED] (2.center) to (14.center);
\end{pgfonlayer}
\end{tikzpicture}
\equaltext{(\ref{FullyMixed})} \frac{1}{2} \begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (2) at (0, -1.75) {};
\node [style=none] (3) at (0, 1.425) {};
\node [style=none] (7) at (0, 2.25) {};
\node [style=none] (14) at (0, -2.5) {};
\node [style=none] (15) at (-0.625, 1.425) {};
\node [style=none] (16) at (0.625, 1.425) {};
\node [style=none] (17) at (-0.375, 1.175) {};
\node [style=none] (18) at (0.375, 1.175) {};
\node [style=none] (19) at (-0.125, 0.925) {};
\node [style=none] (20) at (0.125, 0.925) {};
\node [style=none] (21) at (0, -0.075) {};
\node [style=none] (22) at (0.625, -0.075) {};
\node [style=none] (23) at (-0.625, -0.075) {};
\node [style=none] (24) at (0.375, 0.175) {};
\node [style=none] (25) at (-0.375, 0.175) {};
\node [style=none] (26) at (0.125, 0.425) {};
\node [style=none] (27) at (-0.125, 0.425) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=WIRE] (7.center) to (3.center);
\draw [style=WIRE] (15.center) to (16.center);
\draw [style=WIRE] (17.center) to (18.center);
\draw [style=WIRE] (19.center) to (20.center);
\draw [style=WIRE] (22.center) to (23.center);
\draw [style=WIRE] (24.center) to (25.center);
\draw [style=WIRE] (26.center) to (27.center);
\draw [style=WIRE] (21.center) to (2.center);
%		\draw [style=DOTTED] (2.center) to (14.center);
\end{pgfonlayer}
\end{tikzpicture}
\label{disconnect8}
\end{equation}

which indeed entirely disconnects Eve from Alice's state.

§.§ Teleportation

Alice holds a qubit state $\ket\qj$.
Alice and Bob share an EPR qubit pair.
Alice performs a measurement on her qubit $\ket\qj$ and her half of the EPR pair,
in the Bell basis; this results in a two-bit measurement outcome $(u,v)$.
The two bits are communicated to Bob.
Bob applies the Bell operation $(u,v)$, which is essentially the decryption $\qs_x^v \qs_z^u$,
to his half of the EPR pair. The end result is that Bob's qubit has state $\ket\qj$.

Measurement in the Bell basis is the Hermitian conjugate of the Bell state preparation (<ref>)
and can be depicted as

[style=none] (0) at (-1, -1.5) ;
[style=none] (3) at (-1, -0.5) ;
[style=none] (9) at (-2, -1.5) ;
[style=GraySpider] (15) at (-2, 0.5) ;
[style=WhiteSpider] (18) at (-1, 0.5) ;
[style=GRAYSPIDER] (19) at (-1, -0.5) ;
[style=WHITESPIDER] (20) at (-2, -0.5) ;
[style=none] (30) at (-2,1.5) ;
[style=none] (31) at (-1,1.5) ;

[style=WIRE] (3.center) to (0.center);
[style=WIRE] (19) to (20);
[style=WIRE] (18) to (19);
[style=WIRE] (15) to (20);
[style=WIRE] (9.center) to (20);
(15) to (30);
(18) to (31);

The thin wires carry the bits $(u,v)$.
The full diagram for teleportation of a state $\qr$ is

\begin{equation}
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (-1, -1.5) {};
\node [style=none] (1) at (1, -1.5) {};
\node [style=none] (2) at (1, 1.75) {};
\node [style=none] (3) at (-1, -0.5) {};
\node [style=WHITESPIDER] (4) at (-1, -0.5) {};
\node [style=GRAYSPIDER] (5) at (-2, -0.5) {};
\node [style=GraySpider] (6) at (-1, 0.5) {};
\node [style=WhiteSpider] (7) at (-2, 0.5) {};
\node [style=none] (9) at (-2, -2.25) {};
\node [style=WHITESPIDER] (10) at (1, 1.75) {};
\node [style=GRAYSPIDER] (11) at (1, 2.75) {};
\node [style=GraySpider] (12) at (0, 1.75) {};
\node [style=WhiteSpider] (13) at (0, 2.75) {};
\node [style=none] (14) at (1, 3.75) {};
\node [style=GraySpider] (15) at (-2, 0.5) {};
\node [style=GraySpider] (16) at (0, 2.75) {};
\node [style=WhiteSpider] (17) at (0, 1.75) {};
\node [style=WhiteSpider] (18) at (-1, 0.5) {};
\node [style=GRAYSPIDER] (19) at (-1, -0.5) {};
\node [style=WHITESPIDER] (20) at (-2, -0.5) {};
\node [style=WHITESPIDER] (21) at (1, 2.75) {};
\node [style=GRAYSPIDER] (22) at (1, 1.75) {};
\node [style=none] (23) at (-0.5, 4.5) {};
\node [style=none] (24) at (-0.5, -2.3) {};
\node [style=none] (25) at (0.25, 4.25) {Bob};
\node [style=none] (26) at (-1.4, 4.25) {Alice};
\node [style=none] (27) at (-2, -3) {};
\node [style=none] (28) at (-2.4, -2) {\small $\rho$};
\node [style=none] (28) at (1.3,3.6) {\small $\rho$};
%		\node [style=none] (29) at (-1.25, -2) {\small $\rho_2$};
%		\node [style=none] (30) at (1.25, -2) {\small $\rho_3$};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=WIRE, bend right=90, looseness=1.25] (0.center) to (1.center);
\draw [style=WIRE] (2.center) to (1.center);
\draw [style=WIRE] (3.center) to (0.center);
\draw [style=WIRE] (4) to (5);
\draw [style=WIRE] (6) to (4);
\draw [style=WIRE] (7) to (5);
\draw [style=WIRE] (9.center) to (5);
\draw [style=WIRE] (11) to (10);
\draw [style=WIRE] (10) to (12);
\draw [style=WIRE] (11) to (13);
\draw [bend right=45] (12) to (6);
\draw [bend right=45] (13) to (7);
\draw [style=WIRE] (14.center) to (11);
\draw [style=new edge style 0] (23.center) to (24.center);
%		\draw [style=DOTTED] (9.center) to (27.center);
\end{pgfonlayer}
\end{tikzpicture}
\end{equation}

(Here the thick-wired `cup' represents the creation of the EPR state $\ket{\qF_{00}}$,
i.e. we have omitted the spider that creates the EPR state.)
By yanking the path of $\qr$ (thick wire) to a straight line, the above diagram can be deformed such
that it becomes precisely the leftmost picture in (<ref>).
Thus working with diagrams makes the equivalence between Quantum On-Time Padding and teleport
particularly easy to visualise.

§.§ Quantum Key Distribution

We briefly discuss Kissinger, Tull and Westerbaan's diagrammatic treatment [5] of BB84  [2].
The main component of BB84 is the use of the quantum channel:
Alice encodes a random bit $x$ in a randomly chosen basis (standard basis or complementary)
and sends it to Bob.
Bob also selects one of these two bases at random and measures in that basis.
Only the events where Bob's basis matches Alice's are relevant.
Before reaching Bob, the qubit may be manipulated by Eve.
Eve's attack is allowed to be anything at all, i.e. Eve may entangle her own quantum system with the qubit,
and use quantum memory and quantum computation.
The diagram for a single channel use (in the standard basis) is as follows.

[style=ASYM BOX] (0) at (0, 0) $\qF$;
[style=none] (1) at (-0.75, 0) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (-0.75, 1.25) ;
[style=none] (4) at (-0.5, 1.25) ;
[style=none] (5) at (0, -1.25) ;
[style=WhiteSpider] (9) at (0.5, 1.25) ;
[style=WhiteSpider] (10) at (0, -1.25) ;
[style=none] (11) at (0.5, 2) ;
[style=none] (12) at (0, -2) ;
[style=none] (13) at (-0.25, 1.25) ;
[style=none] (14) at (-1.25, 1.25) ;
[style=none] (15) at (-0.5, 1.5) ;
[style=none] (16) at (-1, 1.5) ;
[style=none] (17) at (-0.65, 1.75) ;
[style=none] (18) at (-0.65, 1.75) ;
[style=none] (19) at (-0.85, 1.75) ;
[style=none] (20) at (0.5, 0) ;
[style=none] (30) at (0.8,-1.8) Alice;
[style=none] (31) at (1.2, 1.8) Bob;
[style=none] (32) at (-1, 1.8) Eve;

[style=WIRE] (3.center) to (1.center);
[style=WIRE] (2.center) to (5.center);
(11.center) to (9);
(10) to (12.center);

[style=WIRE] (9) to (20.center);

Here $\qF$ stands for the attack.
The same diagram, but with grey spiders, applies to the other basis.
After the attack $\qF$, Eve learns the basis choice and tries to exploit her quantum side information
to guess the data bit sent by Alice.
The statement that the protocol is secure[
Here we show the noiseless case only. Noise is handled as in [5].
is formulated diagramatically as follows (Theorem 3.1 in [5]):

[style=ASYM BOX] (0) at (0, 0) $\Phi$;
[style=none] (1) at (-0.75, 0) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (-0.75, 1.25) ;
[style=none] (4) at (-0.5, 1.25) ;
[style=none] (5) at (0, -1.25) ;
[style=WhiteSpider] (9) at (0.5, 1.25) ;
[style=WhiteSpider] (10) at (0, -1.25) ;
[style=none] (11) at (0.5, 2) ;
[style=none] (12) at (0, -2) ;
[style=none] (13) at (-0.25, 1.25) ;
[style=none] (14) at (-1.25, 1.25) ;
[style=none] (15) at (-0.5, 1.5) ;
[style=none] (16) at (-1, 1.5) ;
[style=none] (17) at (-0.65, 1.75) ;
[style=none] (18) at (-0.65, 1.75) ;
[style=none] (19) at (-0.85, 1.75) ;
[style=none] (20) at (0.5, 0) ;

[style=WIRE] (3.center) to (1.center);
[style=WIRE] (2.center) to (5.center);
(11.center) to (9);
(10) to (12.center);
[style=WIRE] (18.center) to (19.center);
[style=WIRE] (15.center) to (16.center);
[style=WIRE] (13.center) to (14.center);
[style=WIRE] (9) to (20.center);

[style=none] (0) at (0, 1) ;
[style=none] (1) at (0, -1) ;

(0.center) to (1.center);

[style=ASYM BOX] (0) at (0, 0) $\Phi$;
[style=none] (1) at (-0.75, 0) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (-0.75, 1.25) ;
[style=none] (4) at (-1.25, 1.25) ;
[style=none] (5) at (0, -1.25) ;
[style=WhiteSpider] (9) at (0.5, 1.25) ;
[style=WhiteSpider] (10) at (0, -1.25) ;
[style=none] (11) at (0.5, 2) ;
[style=none] (12) at (0, -2) ;
[style=none] (13) at (-0.25, 1.25) ;
[style=none] (14) at (-1.25, 1.25) ;
[style=none] (15) at (-0.5, 1.5) ;
[style=none] (16) at (-1, 1.5) ;
[style=none] (17) at (-0.65, 1.75) ;
[style=none] (18) at (-0.65, 1.75) ;
[style=none] (19) at (-0.85, 1.75) ;
[style=GraySpider] (20) at (0.5, 1.25) ;
[style=GraySpider] (21) at (0, -1.25) ;
[style=none] (22) at (0.5, 0) ;

[style=WIRE] (3.center) to (1.center);
[style=WIRE] (2.center) to (5.center);
(11.center) to (9);
(10) to (12.center);
[style=WIRE] (18.center) to (19.center);
[style=WIRE] (15.center) to (16.center);
[style=WIRE] (13.center) to (14.center);
[style=WIRE] (20) to (22.center);

[style=none] (0) at (0, 1) ;
[style=none] (1) at (0, -1) ;

(0.center) to (1.center);

[style=ASYM BOX] (0) at (0, 0) $\Phi$;
[style=none] (1) at (0.5, 0) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (0.5, 1.25) ;
[style=none] (4) at (-0.5, 1.25) ;
[style=none] (5) at (0, -1.25) ;
[style=none] (6) at (-1, 1) Eve;
[style=none] (7) at (1, 1) Bob;
[style=none] (8) at (-0.75, -1) Alice;
[style=none] (9) at (-0.5, 0) ;

[style=WIRE] (3.center) to (1.center);
[style=WIRE] (2.center) to (5.center);
[style=WIRE] (4.center) to (9.center);

[style=STATERIGHT] (0) at (0, 0) 90$\rho$;
[style=none] (1) at (0, 1) ;
[style=none] (2) at (0, -0.5) ;
[style=none] (3) at (-0.1, 1.2) Eve;

[style=WIRE] (1.center) to (2.center);

[style=none] (0) at (0, 1) ;
[style=none] (1) at (0, -1.25) ;
[style=none] (2) at (0.6, -1.1) Alice;
[style=none] (3) at (0.5, 0.9) Bob;

[style=WIRE] (0.center) to (1.center);

The two diagrams to the left of the implication arrow say that Alice and Bob see no disturbance in the two bases
that they are using. The right hand side says that Eve is decoupled from the information that is going from Alice to Bob.

The proof of (<ref>) consists of two parts.
First, from the left hand side (non-disturbance) a rule is derived that allows one to pull
spiders through the purification of $\qF$; here it is important that the rule applies only to those bases
that are observed to have no disturbance, i.e. in BB84 the $z$-basis and $x$-basis.
Second, an additional disconnected branch is pasted to Bob's wire and then all the spiders involved with Bob's wire are
pulled through $\qF$.
Here we will not write out the full proof from [5]; we highlight only one part of it
that we will re-use in the diagrammatic reduction in Section <ref>.

Let the white spider represent any orthonormal basis.
Let $V$ be a purification of $\qF$.
It holds that

[style=ASYM BOX] (0) at (0, 0) $\Phi$;
[style=none] (1) at (-0.75, 0) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (-0.75, 1.25) ;
[style=none] (4) at (-0.5, 1.25) ;
[style=none] (5) at (0, -1.25) ;
[style=WhiteSpider] (9) at (0.5, 1.25) ;
[style=WhiteSpider] (10) at (0, -1.25) ;
[style=none] (11) at (0.5, 2) ;
[style=none] (12) at (0, -2) ;
[style=none] (13) at (-0.25, 1.25) ;
[style=none] (14) at (-1.25, 1.25) ;
[style=none] (15) at (-0.5, 1.5) ;
[style=none] (16) at (-1, 1.5) ;
[style=none] (17) at (-0.65, 1.75) ;
[style=none] (18) at (-0.65, 1.75) ;
[style=none] (19) at (-0.85, 1.75) ;
[style=none] (20) at (0.5, 0) ;

[style=WIRE] (3.center) to (1.center);
[style=WIRE] (2.center) to (5.center);
(11.center) to (9);
(10) to (12.center);
[style=WIRE] (18.center) to (19.center);
[style=WIRE] (15.center) to (16.center);
[style=WIRE] (13.center) to (14.center);
[style=WIRE] (9) to (20.center);

[style=none] (0) at (0, 1) ;
[style=none] (1) at (0, -1) ;

(0.center) to (1.center);

∃_, unitary U
[style=asym box] (0) at (0, 0) V;
[style=none] (1) at (0, -1.5) ;
[style=none] (11) at (-0.5, 0) ;
[style=none] (12) at (-0.5, 1.5) ;
[style=none] (13) at (0.35, 0) ;
[style=none] (14) at (0.35, 1.5) ;

(13.center) to (14.center);
(12.center) to (11.center);
(0) to (1);

[style=none] (0) at (0.8, 2) ;
[style=none] (1) at (0.8, -2) ;
[style=WhiteSpider] (2) at (0.8, -1) ;
[style=medium box] (3) at (-1.2, 0.25) U;
[style=StateMid] (4) at (-1.625, -1.5) -45$\psi$;
[style=none] (5) at (-1.95, 0.25) ;
[style=none] (6) at (-1.875, 0.75) ;
[style=none] (7) at (-1.2, 0.75) ;
[style=none] (8) at (-0.7, 0.75) ;
[style=none] (9) at (-0.45, 0.25) ;
[style=none] (10) at (-1.375, -2) ;
[style=none] (11) at (-1.925, 0.75) ;
[style=none] (12) at (-1.7, -2) ;
[style=none] (13) at (-0.5, 2) ;
[style=none] (14) at (-1.25, 2) ;
[style=none] (15) at (-2, 2) ;
[style=none] (16) at (-0.5, 0.75) ;
[style=none] (17) at (-1.25, 0.75) ;
[style=none] (18) at (-2, 0.75) ;
[style=WhiteSpider] (19) at (-2, 2) ;
[style=WhiteSpider] (20) at (-0.5, 2) ;

(0.center) to (1.center);
[bend left=45, looseness=1.25] (2) to (8.center);
[bend left=15] (7.center) to (10.center);
[bend right=15] (11.center) to (12.center);
(15.center) to (18.center);
(14.center) to (17.center);
(13.center) to (16.center);

See the proof of Theorem 3.1 in [5].

Let the white spider represent any orthonormal basis.
Let $V$ be a purification of $\qF$.
It holds that

[style=ASYM BOX] (0) at (0, 0) $\Phi$;
[style=none] (1) at (-0.75, 0) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (-0.75, 1.25) ;
[style=none] (4) at (-0.5, 1.25) ;
[style=none] (5) at (0, -1.25) ;
[style=WhiteSpider] (9) at (0.5, 1.25) ;
[style=WhiteSpider] (10) at (0, -1.25) ;
[style=none] (11) at (0.5, 2) ;
[style=none] (12) at (0, -2) ;
[style=none] (13) at (-0.25, 1.25) ;
[style=none] (14) at (-1.25, 1.25) ;
[style=none] (15) at (-0.5, 1.5) ;
[style=none] (16) at (-1, 1.5) ;
[style=none] (17) at (-0.65, 1.75) ;
[style=none] (18) at (-0.65, 1.75) ;
[style=none] (19) at (-0.85, 1.75) ;
[style=none] (20) at (0.5, 0) ;

[style=WIRE] (3.center) to (1.center);
[style=WIRE] (2.center) to (5.center);
(11.center) to (9);
(10) to (12.center);
[style=WIRE] (18.center) to (19.center);
[style=WIRE] (15.center) to (16.center);
[style=WIRE] (13.center) to (14.center);
[style=WIRE] (9) to (20.center);

[style=none] (0) at (0, 1) ;
[style=none] (1) at (0, -1) ;

(0.center) to (1.center);

[style=none] (0) at (0.025, 1.25) ;
[style=none] (1) at (-0.975, 2.25) ;
[style=none] (3) at (-0.275, -1.75) ;
[style=WhiteSpider] (5) at (0.025, 1.25) ;
[style=asym box] (9) at (-0.275, -0.25) $V$;
[style=none] (14) at (1.125, 2.25) ;
[style=none] (15) at (-0.725, -0.25) ;
[style=none] (16) at (-1.725, 2.25) ;
[style=none] (17) at (0, -0.25) ;

[bend right] (5) to (14.center);
[bend left] (5) to (1.center);
[bend left=15] (15.center) to (16.center);
(17.center) to (5);
(9) to (3.center);

[style=none] (1) at (-0.75, 1) ;
[style=none] (3) at (0, -1.25) ;
[style=WhiteSpider] (5) at (0, 0) ;
[style=asym box] (9) at (-0.75, 1.75) $V$;
[style=none] (14) at (1.375, 1.25) ;
[style=none] (15) at (-1.5, 1.75) ;
[style=none] (16) at (-1.5, 2.75) ;
[style=none] (17) at (-0.5, 2.75) ;
[style=none] (18) at (-0.5, 1.75) ;
[style=none] (19) at (1.375, 2.75) ;

[bend right=45] (5) to (14.center);
[bend left] (5) to (1.center);
(3.center) to (5);
(15.center) to (16.center);
(17.center) to (18.center);
(9) to (1.center);
(19.center) to (14.center);

[style=none] (0) at (0.75, 0) ;
[style=none] (1) at (1.75, -1.25) ;
[style=WhiteSpider] (5) at (0.75, 0) ;
[style=asym box] (9) at (-0.5, -1.75) V;
[style=none] (14) at (-0.35, -1.75) ;
[style=none] (15) at (-0.5, -3.25) ;
[style=none] (16) at (-1, -1.75) ;
[style=none] (17) at (-1, 1.25) ;
[style=none] (18) at (0.75, 1.25) ;
[style=none] (19) at (1.75, -3.25) ;

[bend right=45] (5) to (14.center);
[bend left] (5) to (1.center);
(16.center) to (17.center);
(18.center) to (5);
(9) to (15.center);
(1.center) to (19.center);

[style=none] (0) at (0, -1) ;
[style=none] (1) at (-1, -2) ;
[style=none] (3) at (-0.5, 2) ;
[style=WhiteSpider] (5) at (0, -1) ;
[style=asym box] (9) at (0, 0.5) V;
[style=none] (14) at (1.1, -2) ;
[style=none] (15) at (0.35, 0.5) ;
[style=none] (16) at (0.35, 2) ;
[style=none] (17) at (-0.5, 0.5) ;

[bend left] (5) to (14.center);
[bend right] (5) to (1.center);
(15.center) to (16.center);
(3.center) to (17.center);
(9) to (5);

See the proof of Theorem 3.1 in [5].

(If $\qF$ is not pure then the left output wire of $V$ represents a space that is larger than Eve's Hilbert space;
a part has to be traced out to obtain Eve's space.)
Note that the third equation in (<ref>) follows from the second equation by yanking down the rightmost wire.

§.§ Eight-state encoding

Eight-state encoding was introduced in [8] as a technique for
quantum-encrypting classical data, to be used in e.g. Quantum Key Recycling (QKR) protocols.
The eight states are the QOTP encryptions of two specially chosen basis states:
|_0⟩cos2 |0⟩+ √(i) sin2|1⟩
,   |_1⟩sin2 |0⟩- √(i) cos2|1⟩
where $\qa\isdef\arccos\fr1{\sqrt3}$ and $\inprod{\qj_a}{\qj_b}=\qd_{ab}$.
On the Bloch sphere the $\ket{\qj_0}$ points in the direction $(1,1,1)$,
and $\ket{\qj_1}$ in the direction $(-1,-1,-1)$.
The QOTP-encrypted states are denoted as $\ket{u,v,g}$,
|u,v,g⟩E_uv|_g⟩ = _z^u _x^v |_g⟩.
Their position on the Bloch sphere is depicted in Fig. <ref>.

The eight cipherstates $E_{uv}\ket{\psi_{g}}$ on the Bloch sphere,
forming the corner points $(-1)^g\Big((-1)^u,(-1)^{u+v},(-1)^v\Big)/\sqrt{3}$ of a cube.

We label the four bases as $(u,v)$.
Instead of introducing four shadings or colors, we choose for a diagrammatic representation with labels,
[style=none] (2) at (0, 1) ;
[style=none] (3) at (0, 1) ;
[style=WideStateRight] (4) at (0, 0) 90${}\!\!\!u,\!v,\!i$;
[style=none] (5) at (0, -0.25) ;

(3.center) to (5.center);

∑_i |u,v,i⟩^⊗n⟨u,v,i|^⊗m≡
[style=WhiteSpider] (0) at (0, 0) $u,\!v$;
[style=none] (1) at (-1, 1) ;
[style=none] (2) at (-0.5, 1) ;
[style=none] (3) at (1, 1) ;
[style=none] (4) at (-1, -1.25) ;
[style=none] (5) at (-0.5, -1.25) ;
[style=none] (6) at (1, -1.25) ;
[style=none] (7) at (-1, 1) ;
[style=none] (8) at (0, -1.25) ;
[style=none] (9) at (0.5, -1.25) ;
[style=none] (10) at (0, 1) ;
[style=none] (11) at (0.5, 1) ;
[style=none] (12) at (0, -1.75) $m$ inputs;
[style=none] (13) at (0, 1.5) $n$ outputs;

[bend left] (0) to (7.center);
[bend left=15] (0) to (2.center);
[bend right] (0) to (3.center);
[bend right] (0) to (4.center);
[bend right=15] (0) to (5.center);
[bend left] (0) to (6.center);
[style=new edge style 0] (10.center) to (11.center);
[style=new edge style 0] (8.center) to (9.center);

The basis states are not depicted as left-right symmetric, since
there is no basis in which all these eight states have a representation with real-valued
vector components.

§.§ Security of eight-state encoding

The diagram for encoding and decoding of a classical bit, plus Eve's attack, is essentially the diagram for QOTP
of general states (<ref>), but now the input is a classical bit encoded in the $\qj_0,\qj_1$ basis.

[style=GraySpider] (0) at (-2.5, -4.25) ;
[style=WHITESPIDER] (1) at (-3.25, -3.5) ;
[style=none] (2) at (-3.25, -5.5) ;
[style=none] (3) at (-3.25, -2.5) ;
[style=GraySpider] (5) at (-1.75, -5.25) ;
[style=none] (6) at (-3.25, -3.5) ;
[style=GRAYSPIDER] (8) at (-3.25, -2.5) ;
[style=WhiteSpider] (9) at (-2.5, -3.25) ;
[style=WhiteSpider] (10) at (-1.75, -4.25) ;
[style=GraySpider] (11) at (5, 3) ;
[style=WHITESPIDER] (12) at (2.25, 4.25) ;
[style=none] (13) at (2.25, 5) ;
[style=none] (14) at (2.25, 2.5) ;
[style=none] (18) at (-3.25, -2.5) ;
[style=GRAYSPIDER] (19) at (2.25, 3.25) ;
[style=WhiteSpider] (20) at (3.75, 2.75) ;
[style=WhiteSpider] (21) at (-1.75, -4.25) ;
[style=ASYM BOX] (23) at (0, 0.35) $\Phi$;
[style=none] (26) at (-3.25, -5) ;
[style=none] (34) at (-3.25, -2) ;
[style=none] (35) at (1.25, 1.5) ;
[style=none] (36) at (0.5, 0.75) ;
[style=none] (37) at (-2, -1) ;
[style=none] (38) at (-0.25, 0.25) ;
[style=none] (39) at (-0.25, 2) ;
[style=none] (40) at (-0.25, 2.75) ;
[style=none] (41) at (-1.325, -6.25) ;
[style=none] (42) at (1.825, -6.25) ;
[style=none] (43) at (1.825, 5) ;
[style=none] (44) at (-1.325, 5) ;
[style=none] (45) at (-2.25, -5.95) Alice;
[style=none] (46) at (0.1, -5.95) Eve;
[style=none] (47) at (2.625, -5.95) Bob;
[style=WIDESTATERIGHT] (50) at (-4, -5.5)  90$\!\!00g\;\;\;$;
[style=WIDEEFFECTRIGHT] (60) at (2.25, 5.2)  90$\!\!00g'\;\;\;$;

[style=WIRE, bend left=45] (1) to (0);
[style=WIRE] (3.center) to (2.center);
(0) to (5);
[style=WIRE, bend left=45] (8) to (9);
(9) to (10);
[style=WIRE, bend left] (12) to (11);
[style=WIRE] (14.center) to (13.center);
[style=WIRE, bend left=45] (19) to (20);
[bend left=15] (20) to (21);
[bend left=15] (11) to (5);
[style=WIRE] (34.center) to (18.center);
[style=WIRE, bend left=45] (34.center) to (37.center);
[style=WIRE, bend right] (37.center) to (38.center);
[style=WIRE, bend left, looseness=1.25] (36.center) to (35.center);
[style=WIRE, bend right=45] (35.center) to (14.center);
[style=WIRE] (39.center) to (38.center);
[style=new edge style 0] (44.center) to (41.center);
[style=new edge style 0] (43.center) to (42.center);

=     ∑_uv

[style=none] (2) at (-3.25, -5.5) ;
[style=none] (3) at (-3.25, -2.5) ;

[style=none] (6) at (-3.25, -3.5) ;

[style=none] (13) at (2.25, 5) ;
[style=none] (14) at (2.25, 2.5) ;
[style=none] (18) at (-3.25, -2.5) ;

[style=ASYM BOX] (23) at (0, 0.35) $\Phi$;
[style=none] (26) at (-3.25, -5) ;
[style=none] (34) at (-3.25, -2) ;
[style=none] (35) at (1.25, 1.5) ;
[style=none] (36) at (0.5, 0.75) ;
[style=none] (37) at (-2, -1) ;
[style=none] (38) at (-0.25, 0.25) ;
[style=none] (39) at (-0.25, 2) ;
[style=none] (40) at (-0.25, 2.75) ;
[style=none] (41) at (-1.325, -3) ;
[style=none] (42) at (1.825, -3) ;
[style=none] (43) at ( 1.825, 3.4) ;
[style=none] (44) at (-1.325, 3.4) ;
[style=none] (45) at (-2.25, -3) Alice;
[style=none] (46) at (0.1, -3) Eve;
[style=none] (47) at (2.625, -3) Bob;
[style=WIDESTATERIGHT] (50) at (-4, -2.5)  90$\!\!uvg\;\;\;$;
[style=WIDEEFFECTRIGHT] (60) at (2.25, 2.9)  90$\!\!uvg'\;\;\;$;

[style=WIRE] (34.center) to (18.center);
[style=WIRE, bend left=45] (34.center) to (37.center);
[style=WIRE, bend right] (37.center) to (38.center);
[style=WIRE, bend left, looseness=1.25] (36.center) to (35.center);
[style=WIRE, bend right=45] (35.center) to (14.center);
[style=WIRE] (39.center) to (38.center);
[style=new edge style 0] (44.center) to (41.center);
[style=new edge style 0] (43.center) to (42.center);

After the attack $\qF$, some information may leak about the basis $(u,v)$ or the data bit $g$.
Here too it is important that a security property like (<ref>) holds [6].
The main result of this paper is that indeed this is the case.

Consider the encoding of classical data as in diagram (<ref>).
Let the label $uv$ in a spider denote the $(u,v)$-basis in 8-state encoding.
Non-disturbance in all four bases implies that Eve is decoupled from the Alice-to-Bob channel,
[style=ASYM BOX] (0) at (0, 0) $\Phi$;
[style=none] (1) at (-0.75, 0) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (-0.75, 1.25) ;
[style=none] (4) at (-0.5, 1.25) ;
[style=none] (5) at (0, -1.25) ;
[style=WhiteSpider] (9) at (0.5, 1.25) $uv$;
[style=WhiteSpider] (10) at (0, -1.25) $uv$;
[style=none] (11) at (0.5, 2) ;
[style=none] (12) at (0, -2) ;
[style=none] (13) at (-0.25, 1.25) ;
[style=none] (14) at (-1.25, 1.25) ;
[style=none] (15) at (-0.5, 1.5) ;
[style=none] (16) at (-1, 1.5) ;
[style=none] (17) at (-0.65, 1.75) ;
[style=none] (18) at (-0.65, 1.75) ;
[style=none] (19) at (-0.85, 1.75) ;
[style=none] (20) at (0.5, 0) ;

[style=WIRE] (3.center) to (1.center);
[style=WIRE] (2.center) to (5.center);
(11.center) to (9);
(10) to (12.center);
[style=WIRE] (18.center) to (19.center);
[style=WIRE] (15.center) to (16.center);
[style=WIRE] (13.center) to (14.center);
[style=WIRE] (9) to (20.center);

[style=none] (0) at (0, 1) ;
[style=none] (1) at (0, -1) ;

(0.center) to (1.center);

[style=ASYM BOX] (0) at (0, 0) $\Phi$;
[style=none] (1) at (0.5, 0) ;
[style=none] (2) at (0, 0) ;
[style=none] (3) at (0.5, 1.25) ;
[style=none] (4) at (-0.5, 1.25) ;
[style=none] (5) at (0, -1.25) ;
[style=none] (6) at (-1, 1) Eve;
[style=none] (7) at (1, 1) Bob;
[style=none] (8) at (-0.75, -1) Alice;
[style=none] (9) at (-0.5, 0) ;

[style=WIRE] (3.center) to (1.center);
[style=WIRE] (2.center) to (5.center);
[style=WIRE] (4.center) to (9.center);

[style=STATERIGHT] (0) at (0, 0) 90$\rho$;
[style=none] (1) at (0, 1) ;
[style=none] (2) at (0, -0.5) ;
[style=none] (3) at (-0.1, 1.2) Eve;

[style=WIRE] (1.center) to (2.center);

[style=none] (0) at (0, 1) ;
[style=none] (1) at (0, -1.25) ;
[style=none] (2) at (0.6, -1.1) Alice;
[style=none] (3) at (0.5, 0.9) Bob;

[style=WIRE] (0.center) to (1.center);

We follow an approach similar to the proof of Theorem 3.1 in [5].
The strategy is to make use of Lemma <ref> by attaching a disconnect
to the wire that goes from $V$ to Bob, and then pull the disconnect through $V$.
However, we cannot literally re-use the steps of [5] since our four bases are not mutually unbiased.
Hence we cannot create a disconnect using (<ref>);
instead we will construct a disconnect using (<ref>).

We start by first showing that a QOTP encryption can be `pulled through" the purification of $\qF$.
This is proven as follows.
From Lemma <ref> and the condition in the left-hand side of (<ref>) we get
∀_a,b∈∃__ab,unitary U_ab
[style=asym box] (0) at (0, 0) V;
[style=none] (1) at (0, -1.5) ;
[style=none] (11) at (-0.5, 0) ;
[style=none] (12) at (-0.5, 1.5) ;
[style=none] (13) at (0.35, 0) ;
[style=none] (14) at (0.35, 1.5) ;

(13.center) to (14.center);
(12.center) to (11.center);
(0) to (1);

[style=none] (0) at (0.8, 2.5) ;
[style=none] (1) at (0.8, -3) ;
[style=WhiteSpider] (2) at (0.8, -1) $ab$;
[style=medium box] (3) at (-1.2, 0.25) $U_{ab}$;
[style=StateMid] (4) at (-1.625, -1.5) -45$\psi_{ab}$;
[style=none] (5) at (-1.95, 0.25) ;
[style=none] (6) at (-1.875, 0.75) ;
[style=none] (7) at (-1.2, 0.75) ;
[style=none] (8) at (-0.7, 0.75) ;
[style=none] (9) at (-0.45, 0.25) ;
[style=none] (10) at (-1.375, -2) ;
[style=none] (11) at (-1.925, 0.75) ;
[style=none] (12) at (-1.7, -2) ;
[style=none] (13) at (-0.5, 2) ;
[style=none] (14) at (-1.25, 2) ;
[style=none] (15) at (-2, 2) ;
[style=none] (16) at (-0.5, 0.75) ;
[style=none] (17) at (-1.25, 0.75) ;
[style=none] (18) at (-2, 0.75) ;
[style=WhiteSpider] (19) at (-2, 2) $ab$;
[style=WhiteSpider] (20) at (-0.5, 2) $ab$;

(0.center) to (1.center);
[bend left=45, looseness=1.25] (2) to (8.center);
[bend left=15] (7.center) to (10.center);
[bend right=15] (11.center) to (12.center);
(15.center) to (18.center);
(14.center) to (17.center);
(13.center) to (16.center);

Writing the $ab$-spiders as encryptions of $00$-spiders using phase spiders as in (<ref>) yields

[style=asym box] (0) at (0, 0) V;
[style=none] (1) at (0, -1.5) ;
[style=none] (11) at (-0.5, 0) ;
[style=none] (12) at (-0.5, 1.5) ;
[style=none] (13) at (0.35, 0) ;
[style=none] (14) at (0.35, 1.5) ;

(13.center) to (14.center);
(12.center) to (11.center);
(0) to (1);

[style=none] (0) at (2, 4) ;
[style=none] (1) at (2, -3) ;
[style=WhiteSpider] (2) at (2, -0.8) $00$;
[style=medium box] (3) at (-1.2, 0.25) $U_{ab}$;
[style=StateMid] (4) at (-1.625, -1.5) -45$\psi_{ab}$;
[style=none] (5) at (-1.95, 0.25) ;
[style=none] (6) at (-1.875, 0.75) ;
[style=none] (7) at (-1.2, 0.75) ;
[style=none] (8) at (-0.7, 0.75) ;
[style=none] (9) at (-0.45, 0.25) ;
[style=none] (10) at (-1.375, -2) ;
[style=none] (11) at (-1.925, 0.75) ;
[style=none] (12) at (-1.7, -2) ;
[style=none] (13) at (-0.5, 4) ;
[style=none] (14) at (-1.25, 4) ;
[style=none] (15) at (-2, 4) ;
[style=none] (16) at (-0.5, 0.75) ;
[style=none] (17) at (-1.25, 0.75) ;
[style=none] (18) at (-2, 0.75) ;
[style=WhiteSpider] (19) at (-2, 4) $00$;
[style=WhiteSpider] (20) at (-0.5, 4) $00$;
[style=GraySpider] (30) at (2, 0.5) $b\!\pi$;
[style=WhiteSpider] (31) at (2, 1.2) $a\!\pi$;
[style=GraySpider] (32) at (2, -1.8) $b\!\pi$;
[style=WhiteSpider] (33) at (2, -2.5) $a\!\pi$;
[style=GraySpider] (34) at (-2, 2.2) $b\!\pi$;
[style=WhiteSpider] (35) at (-2, 1.5) $a\!\pi$;
[style=GraySpider] (36) at (-0.5, 2.2) $b\!\pi$;
[style=WhiteSpider] (37) at (-0.5, 1.5) $a\!\pi$;
[style=GraySpider] (38) at (1.1, -0.9) $b\!\pi$;
[style=WhiteSpider] (39) at (0.4, -0.8) $a\!\pi$;

(0.center) to (1.center);
[bend left=45, looseness=1.25] (2) to (8.center);
[bend left=15] (7.center) to (10.center);
[bend right=15] (11.center) to (12.center);
(15.center) to (18.center);
(14.center) to (17.center);
(13.center) to (16.center);

[style=none] (0) at (2, 4) ;
[style=none] (1) at (2, -3) ;
[style=WhiteSpider] (2) at (2, -0.8) $00$;
[style=medium box] (3) at (-1.2, 0.25) $U_{00}$;
[style=StateMid] (4) at (-1.625, -1.5) -45$\psi_{00}$;
[style=none] (5) at (-1.95, 0.25) ;
[style=none] (6) at (-1.875, 0.75) ;
[style=none] (7) at (-1.2, 0.75) ;
[style=none] (8) at (-0.7, 0.75) ;
[style=none] (9) at (-0.45, 0.25) ;
[style=none] (10) at (-1.375, -2) ;
[style=none] (11) at (-1.925, 0.75) ;
[style=none] (12) at (-1.7, -2) ;
[style=none] (13) at (-0.5, 4) ;
[style=none] (14) at (-1.25, 4) ;
[style=none] (15) at (-2, 4) ;
[style=none] (16) at (-0.5, 0.75) ;
[style=none] (17) at (-1.25, 0.75) ;
[style=none] (18) at (-2, 0.75) ;
[style=WhiteSpider] (19) at (-2, 4) $00$;
[style=WhiteSpider] (20) at (-0.5, 4) $00$;
[style=GraySpider] (30) at (2, 0.5) $b\!\pi$;
[style=WhiteSpider] (31) at (2, 1.2) $a\!\pi$;
[style=GraySpider] (32) at (2, -1.8) $b\!\pi$;
[style=WhiteSpider] (33) at (2, -2.5) $a\!\pi$;

(0.center) to (1.center);
[bend left=45, looseness=1.25] (2) to (8.center);
[bend left=15] (7.center) to (10.center);
[bend right=15] (11.center) to (12.center);
(15.center) to (18.center);
(14.center) to (17.center);
(13.center) to (16.center);

[style=asym box] (0) at (0, 0) V;
[style=none] (1) at (0, -3) ;
[style=none] (11) at (-0.5, 0) ;
[style=none] (12) at (-0.5, 3) ;
[style=none] (13) at (0.35, 0) ;
[style=none] (14) at (0.35, 3) ;
[style=GraySpider] (30) at (0, -1.3) $b\!\pi$;
[style=WhiteSpider] (31) at (0, -2) $a\!\pi$;
[style=GraySpider] (32) at (0.35, 1.5) $b\!\pi$;
[style=WhiteSpider] (33) at (0.35, 2.2) $a\!\pi$;

(13.center) to (14.center);
(12.center) to (11.center);
(0) to (1);

In the step (*) we used that pulling the $ab$-encryptions into the $U_{ab}$ results in the $U_{00},\qj_{00}$ combination.
From (<ref>) it follows that

[style=asym box] (0) at (0, 0) V;
[style=none] (1) at (0, -3) ;
[style=none] (11) at (-0.5, 0) ;
[style=none] (12) at (-0.5, 3) ;
[style=none] (13) at (0.35, 0) ;
[style=none] (14) at (0.35, 3) ;

[style=GraySpider] (32) at (0.35, 1.5) $b\!\pi$;
[style=WhiteSpider] (33) at (0.35, 2.2) $a\!\pi$;

(13.center) to (14.center);
(12.center) to (11.center);
(0) to (1);

[style=asym box] (0) at (0, 0) V;
[style=none] (1) at (0, -3) ;
[style=none] (11) at (-0.5, 0) ;
[style=none] (12) at (-0.5, 3) ;
[style=none] (13) at (0.35, 0) ;
[style=none] (14) at (0.35, 3) ;
[style=GraySpider] (30) at (0, -2) $b\!\pi$;
[style=WhiteSpider] (31) at (0, -1.3) $a\!\pi$;

(13.center) to (14.center);
(12.center) to (11.center);
(0) to (1);

i.e. the encryption can be `pulled through' $V$.
Now we write, for any $u,v\in\bits$

[style=asym box] (0) at (0, 0) V;
[style=none] (1) at (0, -1.5) ;
[style=none] (11) at (-0.5, 0) ;
[style=none] (12) at (-0.5, 1.5) ;
[style=none] (13) at (0.35, 0) ;
[style=none] (14) at (0.35, 1.5) ;

(13.center) to (14.center);
(12.center) to (11.center);
(0) to (1);

[style=asym box] (0) at (-0.25, -2.25) V;
[style=none] (1) at (-0.75, -2.25) ;
[style=none] (2) at (0, -2.25) ;
[style=none] (3) at (0, -1) ;
[style=none] (4) at (0, -3.5) ;
[style=none] (5) at (-1.5, 0) ;
[style=WhiteSpider] (6) at (0, -1) $uv$;
[style=WhiteSpider] (7) at (-0.5, -0.25) $uv$;
[style=none] (8) at (1.5, 0.5) ;
[style=WhiteSpider] (9) at (-0.5, 1) $ab$;
[style=WhiteSpider] (10) at (-0.5, 2) $ab$;

[style=none] (13) at (-0.5, -0.25) ;

[style=none] (18) at (-0.5, 3) ;

(3.center) to (4.center);
[bend right=15] (5.center) to (1.center);
[bend left] (6) to (7);
[bend left] (8.center) to (6);
(10) to (9);

[style=WIRE] (7.center) to (9.center);

Lemma <ref>=
[style=asym box] (0) at (-0.75, 1.5) V;
[style=none] (1) at (-1.25, 1.5) ;
[style=none] (2) at (-0.5, 1.5) ;
[style=none] (3) at (0, -2) ;
[style=none] (4) at (0, -3.25) ;
[style=none] (5) at (-1.75, 2.75) ;
[style=WhiteSpider] (6) at (0, -2) $uv$;
[style=WhiteSpider] (7) at (-0.5, -0.75) $uv$;
[style=none] (8) at (1.5, -0.5) ;
[style=WhiteSpider] (9) at (-0.5, 0.25) $ab$;
[style=WhiteSpider] (10) at (-0.5, 2.8) $ab$;
[style=none] (13) at (-0.5, -0.5) ;
[style=none] (18) at (-0.5, 0.5) ;

(3.center) to (4.center);
[bend right=15] (5.center) to (1.center);
[bend left=15] (6) to (7);
[bend left] (8.center) to (6);
(10) to (9);
[style=WIRE] (7.center) to (9.center);

[style=asym box] (0) at (-0.75, 2.25) V;
[style=none] (1) at (-1.25, 2.25) ;
[style=none] (2) at (-0.5, 2.25) ;
[style=none] (3) at (0, -2.5) ;
[style=none] (4) at (0, -3.75) ;
[style=none] (5) at (-1.75, 3.5) ;
[style=WhiteSpider] (6) at (0, -2.5) $uv$;
[style=WhiteSpider] (7) at (-0.5, -1.5) $uv$;
[style=none] (8) at (1.5, -1) ;
[style=WhiteSpider] (9) at (-0.5, 1) $00$;
[style=WhiteSpider] (10) at (-0.5, 3.5) $00$;
[style=GraySpider] (11) at (0.25, -1) ;
[style=WHITESPIDER] (12) at (-0.5, -0.5) ;
[style=none] (13) at (-0.5, -1.25) ;

[style=none] (18) at (-0.5, 1.25) ;
[style=GRAYSPIDER] (19) at (-0.5, 0.25) ;
[style=WhiteSpider] (20) at (0.75, -0.75) ;

(3.center) to (4.center);
[bend right=15] (5.center) to (1.center);
[bend left=15] (6) to (7);
[bend left] (8.center) to (6);
(10) to (9);
[style=WIRE, bend left=45] (12) to (11);

[style=WIRE, bend left=45] (19) to (20);

[style=WIRE] (18.center) to (19);
[style=WIRE] (19.center) to (12.center);
[style=WIRE] (12.center) to (13.center);

[style=asym box] (0) at (-0.75, 2.25) V;
[style=none] (1) at (-1.25, 2.25) ;
[style=none] (2) at (-0.5, 2.25) ;
[style=none] (3) at (0, -2.9) ;
[style=none] (4) at (0, -4.15) ;
[style=none] (5) at (-1.75, 3.5) ;
[style=WhiteSpider] (6) at (0, -3.1) $uv$;
[style=WhiteSpider] (7) at (-0.5, -2.2) $uv$;
[style=none] (8) at (1.5, -1) ;
[style=WhiteSpider] (9) at (-0.5, 1) $00$;
[style=WhiteSpider] (10) at (-0.5, 3.5) $00$;

[style=none] (13) at (-0.5, -1.25) ;

[style=none] (18) at (-0.5, 1.25) ;

[style=none] (32) at (-0.5, -1.95) ;
[style=none] (33) at (-0.5, 0.225) ;
[style=none] (37) at (-0.5, 1.05) ;

[style=none] (45) at (-1.125, 0.225) ;
[style=none] (46) at (0.125, 0.225) ;
[style=none] (47) at (-0.875, -0.025) ;
[style=none] (48) at (-0.175, -0.025) ;
[style=none] (49) at (-0.625, -0.275) ;
[style=none] (50) at (-0.375,  -0.275) ;
[style=none] (51) at (-0.5, -1.275) ;
[style=none] (52) at (0.125, -1.275) ;
[style=none] (53) at (-1.125, -1.275) ;
[style=none] (54) at (-0.125, -1.025) ;
[style=none] (55) at (-0.875, -1.025) ;
[style=none] (56) at (-0.375, -0.775) ;
[style=none] (57) at (-0.625, -0.775) ;

(3.center) to (4.center);
[bend right=15] (5.center) to (1.center);
[bend left=15] (6) to (7);
[bend left] (8.center) to (6);
(10) to (9);

[style=WIRE] (37.center) to (33.center);
[style=WIRE] (45.center) to (46.center);
[style=WIRE] (47.center) to (48.center);
[style=WIRE] (49.center) to (50.center);
[style=WIRE] (52.center) to (53.center);
[style=WIRE] (54.center) to (55.center);
[style=WIRE] (56.center) to (57.center);
[style=WIRE] (51.center) to (32.center);

In the second diagram the two $ab$-spiders can be contracted; then the remaining $ab$-spider can be written
as the $ab$-encryption of a 00-spider, which is turned into a disconnect by the $\sum_{ab}$.
Then, the two $uv$-spiders fuse and form the identity operation.
This explains why the second diagram is equivalent to the first.
In the transition from the 3rd to the 4th diagram, both $ab$-spiders are rewritten as the $ab$-encryption of
a 00-spider; then the topmost encryption operator is pulled through $V$ and cancels the $ab$-encryption just below $V$.

Finally, in the last expression in (<ref>)
the trace on the $uv$-spider disappears and the two $uv$-spiders fuse to form the identity operator on the wire
from Alice to Bob.
Doubling the whole diagram yields the last expression in (<ref>), with $\qr$ being the doubling of $V$ acting
on a random input.

The proof deviates from [5] in the way in which the disconnect is constructed in the second diagram of (<ref>).
Whereas the disconnect in [5] is based on complementary bases (<ref>),
we make use of QOTP encryption (<ref>).

§ DISCUSSION

Most of what is written in this document is extracted from [3] and [5],
and rehashed into an introduction that we hope is appealing to physicists.
Because of the peculiarities of 8-state encoding, with basis states that do not allow for a
simultaneous real-valued representation, we have chosen to explicitly show arrows on the wires in many of the diagrams.

The only really new content is Section <ref>, the diagrammatic proof that non-disturbance
in 8-state encoding implies decoupling of Eve from Alice and Bob.
The security of 8-state encoding is of course known, but the derivation with diagrams is novel.

Our diagrammatic treatment of 8-state encoding may be of interest for Symmetric Informationally Complete measurements (`SIC-POVM') for tomography.

We have covered only the noiseless case.
The situation with channel noise can be dealt with in exactly the same way as BB84/6-state QKD [5].
Here it is important to note that the diagrammatic approach does not yield improved bounds
(in fact they are worse than state-of-the-art).
Instead of considering it as a numerical tool, we see diagrams as an
intuitive visualisation aid that is simple to master yet powerful enough to
derive security proofs.

§.§ Acknowledgements

We thank Aleks Kissinger and Daan Leermakers for useful discussions.

[1]
A. Ambainis, M. Mosca, A. Tapp, and R. de Wolf.
Private quantum channels.
In 41st Annual IEEE Symposium on Foundations of Computer
Science, pages 547––553, 2000.

[2]
C. H. Bennett and G. Brassard.
Quantum cryptography: Public key distribution and coin tossing.
In Proceedings of IEEE International Conference on Computers,
Systems and Signal Processing, volume 175, 1984.

[3]
B. Coecke and A. Kissinger.
Picturing Quantum Processes.
Cambridge University Press, Cambridge, 2017.

[4]
D.W. Leung.
Quantum Vernam cipher.
Quantum Information and Computation, 2(1):14–34, 2002.

[5]
A. Kissinger, S. Tull, and B. Westerbaan.
Picture-perfect Quantum Key Distribution, 2017.

[6]
D. Leermakers and B. Škorić.
Optimal attacks on qubit-based Quantum Key Recycling.
Quantum Information Processing, 17(3):57, 2018.

[7]
P.O. Boykin and V. Roychowdhury.
Optimal encryption of quantum bits.
Phys. Rev. A, 67(4):042317, 2003.

[8]
B. Škorić and M. de Vries.
Quantum Key Recycling with 8-state encoding (The Quantum One-Time
Pad is more interesting than we thought).
Int. J. of Quantum Information, 15(3):1750016, 2017.

[9]
Z. Wolffs.
An introduction to a novel diagrammatic notation for quantum
mechanics and its applications to some quantum cryptographic protocols,
Bachelor thesis, Maastricht University, The Netherlands.