You are reading without signing in. Sign in or continue as guest to take quizzes and keep XP.
Bernstein–Vazirani: read a hidden string
Same circuit shape, more useful result: recover an n-bit secret with one query.
- Build the oracle for a given secret s.
- Explain why the output register reads s exactly.
Secret s = 101
Simulate: every shot reads 101. Change which CNOTs are present to encode another secret and watch the histogram follow.
OPENQASM 3.0; include "stdgates.inc"; qubit[4] q; bit[3] c; x q[3]; h q[0]; h q[1]; h q[2]; h q[3]; barrier q; cx q[0], q[3]; cx q[2], q[3]; barrier q; h q[0]; h q[1]; h q[2]; c[0] = measure q[0]; c[1] = measure q[1]; c[2] = measure q[2];
Classically you need n queries (one per bit: query with x = 0…010…0). Quantumly one. Unlike Deutsch–Jozsa the gap holds even against randomised classical algorithms, which is why Bernstein–Vazirani is the first 'real' separation in the oracle model.
With secret s = 011 (s0 = 1, s1 = 1, s2 = 0), which CNOTs form the oracle?
Sign in to answer and earn XP; you will come back to this lesson.
Bernstein–Vazirani turns the Deutsch–Jozsa template into a deterministic n-to-1 query advantage: the Hadamard transform of the kicked-back phases is the secret itself.
Up next: Grover's search