Factoring · Circuits

Modular exponentiation

Theorem statement

Let $m,n\geq0$, $1\leq N\leq2^n$, and $0\leq a<N$ be integers with $\gcd(a,N)=1$. There exists a reversible quantum circuit on $m+3n$ qubits, using at most $2n$ ancilla qubits, $24mn\left((3744n+624)\lceil\log_2(n+1)\rceil+160n+65\right)+3n$ Toffoli gates, $24mn^2\left(39\lceil\log_2(n+1)\rceil+2\right)+n$ CNOT gates, and $2$ single-qubit gates, whose action on computational basis states satisfies $$ U_{N,a}\ket{z}\ket{y} =\ket{z}\ket{y\oplus(a^z\bmod N)} $$ for every $z<2^m$ and $y<2^n$.

Copy a short prompt with the import, theorem name, citations, and public source link.

Open Lean source