//! The smallest complete thing: build a circuit, simulate it exactly, and get a //! hash that is the same on every machine. //! //! cargo run --example bell use wai_quantum::quantum::Circuit; use wai_quantum::quantum_toolchain as qt; fn main() { let mut c = Circuit::new(2); c.h(0).cx(0, 1); // a Bell pair let sv = c.simulate().expect("simulate"); println!("circuit {} qubits, {} gates", c.n_qubits, c.ops.len()); let (backend, why) = qt::recommend_backend(&c); println!("backend {backend:?} — {why}"); println!("outcomes"); for (state, p) in qt::top_outcomes(&sv, 4) { if p > 0.0 { println!(" |{state:02b}> {p:.6}"); } } // Not "a hash of this run" — the reconstruction is byte-exact, so this is the // same value natively, in a browser, and in a WASI component at the edge. let h = sv.statevector_hash(); print!("state-hash "); for b in h { print!("{b:02x}"); } println!(); }