# How does the unitary encoding procedure in quantum secret sharing schemes or error correcting codes work?

In Cleve et al.'s paper "How to share a quantum secret", two encodings of quantum states are mentioned. The first one encodes one qutrit into three qutrits,

$$\alpha|0\rangle + \beta|1\rangle + \gamma|2\rangle \mapsto \\ \alpha(|000\rangle + |111\rangle + |222\rangle) \\ + \beta(|012\rangle + |120\rangle + |201\rangle) \\ + \gamma(|021\rangle + |102\rangle + |210\rangle).$$

The second encoding is in fact a quantum error-correcting code and encodes one qubit into four qubits,

$$\alpha|0\rangle + \beta|1\rangle \mapsto \alpha(|0000\rangle + |1111\rangle) + \beta(|0011\rangle + |1100\rangle)$$.

Such succinct ways of encoding pure quantum states can often be found in the literature of quantum error correction. I am wondering how the above encodings can be implemented unitarily and if there are any general results that these brief descriptions draw on that I am missing here.

Let's say you're given a transformation $$\sum_i\alpha_i|\psi_i\rangle\mapsto\sum_i\alpha_i|\phi_i\rangle$$ where $$\langle\psi_i|\psi_j\rangle=\langle\phi_i|\phi_j\rangle=\delta_{ij}$$. What this really means is that you want a unitary $$U$$ that transforms $$U|\psi_i\rangle=|\phi_i\rangle$$ for all $$i$$.
Now, in the cases you give, the Hilbert space dimensions don't match, so that's a problem. We get around this by introducing ancillas. Basically, we introduce extra quantum systems, in a known state (usually denoted $$|0\rangle$$) to make up the Hilbert space to the correct dimension. So, perhaps we really mean $$U|\psi_i\rangle|00\rangle=|\phi_i\rangle,$$ for example.
For example, if you're looking at the transformation $$\alpha|0\rangle+\beta|1\rangle\mapsto \alpha|00\rangle+\beta|11\rangle$$, we know that $$U|00\rangle=|00\rangle,\qquad U|10\rangle=|11\rangle.$$ This tells us certain parts of the unitary: $$U=\left[\begin{array}{cccc} 1 & ? & 0 & ? \\ 0 & ? & 0 & ? \\ 0 & ? & 0 & ? \\ 0 & ? & 1 & ?\end{array} \right].$$ Orthogonality of the two remaining columns means we can fill in a bit more $$U=\left[\begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & ? & 0 & ? \\ 0 & ? & 0 & ? \\ 0 & 0 & 1 & 0\end{array} \right].$$ The remaining $$2\times 2$$ submatrix can be any $$2\times 2$$ unitary that you want, but the choice $$U=\left[\begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0\end{array} \right]$$ conveniently corresponds to the controlled-not gate.