Docs

How Qflip works

Short version: a qubit is measured on IBM hardware, the bits are published, and each result takes the next unused bit with a record on Robinhood Chain.

The circuit

One qubit starts in |0⟩. A Hadamard gate puts it into an equal superposition of |0⟩ and |1⟩. Measuring it gives 0 or 1 with equal odds, decided by the measurement itself. In OpenQASM 3:

OPENQASM 3.0; include "stdgates.inc";
bit[1] c; qubit[1] q;
h q[0];
c[0] = measure q[0];

Qflip runs this circuit on a real IBM Quantum backend through the IBM Quantum open plan, with thousands of shots per job. Each shot is one bit. Real hardware is not perfectly balanced, so the share of ones in each job is shown on the Proof page.

Why batches

The open plan queue can take minutes or longer, which is too slow for a button. So the keeper runs a job ahead of time, stores its bits in shot order and publishes them. Results consume the bits strictly in order, each bit at most once.

A flip, step by step

  1. The keeper calls request(listHash, kind) on the ledger contract. The Requested event is now on-chain.
  2. It takes the next unused bit of the current job. 0 is heads, 1 is tails.
  3. It calls fulfill(id, result, jobId, backend, bitOffset). The Fulfilled event stores the result with the job ID, the backend and the bit position.

A draw

The list is joined with newlines and hashed with keccak256. That hash goes on-chain in the request. To pick among n entries, Qflip reads k = ceil(log2 n) bits as a binary number. If it is n or more, it reads the next k bits (rejection sampling), so every entry has the same chance.

Recheck any result

Open the Proof page, enter a result number and press Recheck. Your browser reads the event from a public Robinhood Chain RPC, downloads the job bits, recomputes the result and, for draws, re-hashes the list. Or do it by hand from /api/job/<jobId> and the explorer.

What the operator can and cannot do

  • The contract holds no funds and has no fee.
  • Only the keeper address can fulfill, and each request only once.
  • The keeper cannot change a recorded result. Skipping or reusing bits would leave gaps or repeats in the offsets on-chain.
  • The IBM job is run from the operator's IBM account, so outsiders see the job ID, backend, timestamps and the full returned bits, not IBM's own dashboard.

Use it from a contract

Anyone can call request(bytes32(0), 0) on the ledger for a flip. The keeper fulfills direct requests too. Direct draws are fulfilled once their list is published through the API.