1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! **The proof-of-inference role** — the abstract contract every zk backend behind
//! Primitive I fulfils, so the settlement layer never cares *which* proof system
//! collapsed the dispute window.
//!
//! A dispute window is long only because unaided refutation is slow: a challenger
//! must hold the model and re-run the whole forward pass. A proof-of-inference
//! removes that cost — it binds a public `(input, output)` pair to a correct forward
//! pass of a committed model, and a relying party verifies it *without re-executing
//! the network*. A valid proof resolves a bond deterministically via
//! [`crate::coordinator::DisputeCoordinator::resolve_via_oracle`]
//! ([`crate::settlement::FinalizeReason::ProofVerified`]) — which is exactly how any
//! real zk backend shrinks the window `W` toward zero.
//!
//! Two implementations ship, both behind this same trait:
//!
//! - **Transparent** ([`crate::zkbackend::SpotCheckProof`], always compiled) — a
//! hash-based interactive-oracle proof (STARK-family core, Fiat-Shamir), no trusted
//! setup, tunable soundness via spot-check count. Succinct *verification*, but the
//! proof carries per-query openings and reveals the weights it opens.
//! - **SNARK** ([`crate::zksnark::SnarkInferenceProof`], `snark` feature) — arkworks
//! Groth16 over BN254: a constant-size (~200-byte) proof, cryptographic soundness,
//! and genuine zero-knowledge — the weights live behind the verifying key and never
//! appear in the proof. This is the "real SNARK" the transparent backend documents
//! as the piece that slots in behind this role without touching the coordinator.
//!
//! Because both satisfy [`InferenceProof`], settlement code binds to the trait and a
//! deployment swaps proof systems by swapping the concrete type — nothing downstream
//! of [`verify_inference`](InferenceProof::verify_inference) changes.
/// A backend-agnostic proof that some committed model maps a caller-supplied input to
/// a claimed output, checkable without re-running the model.
///
/// The settlement facilitator only ever calls
/// [`verify_inference`](Self::verify_inference) with its own soundness floor and turns
/// the boolean into a [`BondOutcome`](crate::route::BondOutcome) fed to
/// [`resolve_via_oracle`](crate::coordinator::DisputeCoordinator::resolve_via_oracle).
/// The effective bit-security a cryptographic SNARK proof reports as its
/// [`soundness`](InferenceProof::soundness). Groth16 over BN254 sits at roughly this
/// level; a relying party's floor is compared against it. It dwarfs any spot-check
/// count a transparent proof can practically carry, which is the honest reflection of
/// "a SNARK's soundness is cryptographic, not sampling-based."
pub const SNARK_SOUNDNESS: usize = 128;