The Bernstein-Vazirani algorithm is a quantum algorithm that solves a specific problem known as the "oracle problem". In this problem, we are given a black-box oracle (a function) that computes a dot product between an unknown binary string "s" and an input binary string "x," modulo 2. The goal is to determine the unknown string "s." The Bernstein-Vazirani quantum circuit uses quantum parallelism to determine the unknown string "s" in a single query to the oracle, whereas a classical algorithm would require multiple queries—one for each bit of "s".

Using QuantumCircuitOperator[{"BernsteinVazirani",st}], one can generate the Bernstein–Vazirani for the given secret string st.

Generate Bernstein–Vazirani circuit for the secret string 101:

bv=QuantumCircuitOperator[{"BernsteinVazirani","101"}]

Circuit diagram:

bv["Diagram"]

Only oracle part of the circuit:

QuantumCircuitOperator[{"BernsteinVaziraniOracle","101"}]["Diagram"]

Evaluate the BV circuit and get the measurement:

meas=bv[]

Return quantum probabilities:

meas["Probabilities"]

meas["ProbabilityPlot"]

As one can see, the only result corresponds to the secret string.