For $2N$ qubits $\{i_1,j_1\ldots i_N,j_N\}$ I would like to have a circuit changing the value of an ancillary register from $0$ to $1$ if $i_1=j_1$ AND $i_2=j_2$ AND ... AND $i_N=j_N$.
One way to construct such a circuit is to use a separate ancillary qubit to store the value of comparison of $i_n$ and $j_n$ and then use a multi-controlled Toffoli on all ancillas. This requires $N$ ancillas and an $N$-qubit Toffoli. Can we do better than that? (Multi-controlled gates are extremely expensive, and using a number of them linear in the input size is highly undesireable.)
One idea I had is that since comparison $|i,j,k\rangle\mapsto|i,j,k\oplus (i=j)\rangle$ is implemented as $|i,j,k\rangle\mapsto|i,j,k\oplus i\oplus j\oplus 1\rangle$ (please correct me if I'm wrong), one could probably use instead $|i,j\rangle\mapsto|i\oplus j\oplus1,j\rangle$ (and the inverse operation at the end, to restore the original values of qubits) to avoid using ancillas. This solves the problem with the number of ancillas but not with multi-controlled gates.
Another idea is to use arithmetic and calculate the product of qubits.