wai-quantum 0.3.21

A deterministic quantum stack in pure Rust: byte-exact circuit simulation (statevector / stabilizer / tensor-network MPS / sparse-Pauli backends), error mitigation, qLDPC decoding, noise learning, circuit-equivalence proofs, a phasor interference-ML layer, information-theoretic limits, noisy channels and state tomography, and signed energy-accounted receipts. No QPU, no cloud, no system libraries — identical results native, in the browser, and as a WASI component at the edge.
Documentation
//! Sealing a computation into a signed, energy-accounted receipt — and watching
//! verification reject a doctored one.
//!
//!     cargo run --example receipt

use wai_quantum::ed25519_dalek::SigningKey;
use wai_quantum::quantum::Measure;
use wai_quantum::quantum_receipt::QuantumReceipt;
use wai_quantum::quantum_toolchain as qt;

fn main() {
    let circuit = qt::ghz(3);
    let key = SigningKey::from_bytes(&[42u8; 32]); // demo key; use a real one

    let receipt = QuantumReceipt::seal(
        &key,
        "did:key:example",
        &circuit,
        Some(Measure { seed: 7, shots: 4096 }),
        0, // measured microjoules; 0 means unmetered
        None,
    )
    .expect("seal");

    println!("verifies              {}", receipt.verify());
    println!("re-simulates to claim {}", receipt.verify_reconstruction(&circuit));
    println!("work                  {} amplitude updates", receipt.work_amp_updates);
    println!("energy                {} uJ (0 = unmetered)", receipt.joules_micro);

    // The work is recomputable by anyone from (n_qubits, n_ops), so a sink cannot
    // inflate it. The energy is only as good as the signature, and says so.
    let json = receipt.to_json();
    let tampered = json.replace("\"work_amp_updates\":24", "\"work_amp_updates\":2400");
    assert_ne!(json, tampered, "expected the work field in the JSON");
    let forged = QuantumReceipt::from_json(&tampered).expect("still parses");
    println!("\nclaiming 100x the work: verifies = {}", forged.verify());
}