NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

SafetyNets: Verifiable Execution of Deep Neural Networks on an Untrusted Cloud

Zahra Ghodsi, Tianyu Gu, Siddharth Garg

Deep learning has become a staple of modern software, but its heavy computational requirements often force developers to outsource inference to the cloud. This "Machine Learning as a Service" (MLaaS) model introduces a significant trust gap: How do you know the cloud provider actually ran your model? A "lazy" provider might swap your complex model for a cheaper, less accurate one to save on compute costs, or a compromised server might maliciously return specific wrong answers.

In their paper SafetyNets, Ghodsi et al. present a framework that allows a client to verify the integrity of deep neural network (DNN) inference performed by an untrusted server using mathematical proofs.

TL;DR

SafetyNets is a verifiable computing framework that enables an untrusted cloud to provide a short, mathematical proof that DNN inference was performed correctly. By restricting networks to "arithmetic-circuit-friendly" components, it achieves verification speeds up to 80x faster than local execution with negligible server overhead.

What Problem Does This Paper Address?

The core issue is integrity in outsourced computing. When you send data to the cloud for processing, you typically receive only the result. In security-critical applications—like face recognition for authentication or medical diagnosis—simply trusting the result isn't enough.

Existing Verifiable Computing (VC) techniques often suffer from massive overhead, sometimes making the "proof generation" thousands of times slower than the original computation. SafetyNets aims to bridge this gap specifically for DNNs, ensuring that:

  1. The client's verification effort is much lower than running the model locally.
  2. The server's overhead for generating the proof is minimal.
  3. The proof itself is small enough to keep bandwidth costs low.

Methods

SafetyNets leverages Interactive Proof (IP) systems, specifically the GKR protocol (named after Goldwasser, Kalai, and Rothblum). The process involves a "dialogue" between a Verifier (the client) and a Prover (the server), as illustrated in the protocol overview below:

Figure 1: High-level overview of the SafetyNets IP protocol. In this example, an untrusted server intentionally changes the classification output from 4 to 5.

To make DNNs compatible with these mathematical proofs, SafetyNets represents them as arithmetic circuits over finite fields (integers modulo a large prime $p$). This requires three specific architectural choices:

  • Quadratic Activations: Instead of the standard ReLU or Sigmoid functions, SafetyNets uses $x^2$. While unusual, prior research shows these are expressive enough for complex tasks.
  • Sum Pooling: Max-pooling is difficult to represent as a simple polynomial, so SafetyNets uses sum-pooling to maintain compatibility with arithmetic circuits.
  • Finite Field Arithmetic: All weights and inputs are quantized and scaled into a large finite field (using Mersenne primes like $2^{61}-1$).

The protocol works backward: the verifier checks the output layer, which generates a "claim" about the previous layer. This continues layer-by-layer until the verifier reaches the input, which it can check against its own data.

Datasets

The authors evaluated SafetyNets on three distinct tasks:

  1. MNIST: The classic handwritten digit recognition benchmark.
  2. MNIST-Back-Rand: A more difficult version of MNIST where digits are placed over random backgrounds.
  3. TIMIT: A widely used speech recognition dataset, mapped to 39 phoneme classes.

Key Insights and Ideas

  • DNNs are Naturally Layered Circuits: The authors realized that the structure of a DNN perfectly matches the requirements of the GKR protocol, which is designed to verify layered arithmetic circuits.
  • Amortization is Key: By verifying inputs in batches, the cost of the proof protocol is spread across many inferences, making the per-image overhead for the client extremely low.
  • Integrity vs. Privacy: The paper highlights a trade-off. While other methods like CryptoNets focus on data privacy (using homomorphic encryption), they are incredibly slow. SafetyNets focuses on integrity and is orders of magnitude faster, making it more practical for real-time applications where the data itself isn't necessarily secret, but the result must be correct.

Key Results

SafetyNets proves that verifiable inference is practical today:

  • Efficiency: For the client, verifying the proof is 8x to 82x faster than actually running the neural network locally.
  • Low Server Overhead: The server only spends about 5% more time generating the proof compared to a standard unverified execution.
  • High Accuracy: Despite the switch to quadratic activations, the models remain competitive, achieving 99.4% on MNIST and 75.22% on TIMIT.
Figure 3: Run-time comparison showing that as batch size increases, the client's verification time becomes significantly lower than the baseline execution time.

As shown in Figure 2, the training and test errors for the "Quad" versions of the networks (blue lines) converge similarly to standard ReLU networks (red lines), proving that the architectural restrictions don't cripple the model's learning ability.

Figure 2: Evolution of training and test error. The quadratic-activation networks (blue) perform competitively with standard ReLU networks (red).

Limitations and Future Work

While a major step forward, SafetyNets has some constraints:

  • Architectural Rigidity: You cannot use Max-pooling or ReLUs within the hidden layers. This might limit the performance of much deeper or more specialized architectures (like Transformers) that rely on these components.
  • Overflow Risks: Because the system works in a finite field, scaling factors must be chosen carefully. If intermediate values grow too large and "wrap around" the prime $p$, the model's accuracy will collapse.
  • No Privacy: SafetyNets ensures the cloud didn't lie, but it doesn't stop the cloud from seeing your data. The authors suggest that future work could combine SafetyNets with privacy-preserving techniques, though this would likely increase the computational cost.

Summary updated

BibTeX
@inproceedings{ghodsi2017safetynets,
  author = {Zahra Ghodsi and Tianyu Gu and Siddharth Garg},
  title = {{SafetyNets: Verifiable Execution of Deep Neural Networks on an Untrusted Cloud}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2017},
}
Figure