NanoZK: Privacy-Preserving Verifiable Inference for Large Language Models via Layerwise Zero-Knowledge Proofs
Organizations: USC Viterbi School of Engineering, Los Angeles, CA, USA
Abstract
We present NanoZK, a zero-knowledge proof system for verifiable LLM inference: clients and third-party auditors check that a provider executed the advertised model on a committed input without learning weights or activations. NanoZK introduces a layerwise proof framework that decomposes transformer inference into independently provable layers linked by a SHA-256 commitment chain, yielding constant-size sub-circuit proofs (3.5-3.7 KB; about 83 KB total at L=12), comparable in total size to and substantially more parallelizable than prior ZKML's monolithic 101-126 KB proofs. We prove compositional soundness and zero-knowledge under standard assumptions, design 16-bit lookup-table approximations for softmax, GELU, and normalization with measured perplexity degradation below 1e-4 across six model/dataset combinations, and add a Fisher-information-guided audit-budget triage as an efficiency tool (full soundness still requires verifying every layer). On CPU the MLP sub-circuit proves in about 6.3 s prove-only (about 43 s setup plus prove) with about 22 ms verification at any width; attention prove-only time scales from 0.9 s (d=16) to 184 s (d=256); full-block end-to-end proofs are measured to d=128, with a projected GPU time of about 68 s per block at d=768 from measured O(d^2) MSM scaling and a conservative 15-30x GPU-MSM speedup range based on Icicle's published 30x result for n >= 2^20 and extrapolated to the smaller-n regime. Privacy scope: NanoZK hides weights and activations from verifiers and auditors but does not hide the prompt from the prover; this is complementary to HE/MPC.
Figures & tables
| Function | Mean Rel. | P99 Rel. | Mean Abs. | Table Size | Constraints |
|---|---|---|---|---|---|
| GELU | 0.026% | 0.158% | 65,536 | 1 per lookup | |
| SiLU | 0.021% | 0.158% | 65,536 | 1 per lookup | |
| Softmax (e2e) † | — | — | 65,536 | 1 per lookup | |
| RMSNorm (rsqrt) | 0.003% | 0.034% | 65,536 | 1 per lookup |
| System | Strategy | Prec. | Ops covered | PPL |
|---|---|---|---|---|
| zkCNN [ 18 ] | no LUT | — | none (CNN) | — |
| ZKML [ 6 ] | Halo2 LUT | mixed | ReLU, GELU | |
| zkLLM [ 25 ] | tlookup/zkAttn | 8-bit | sm, GELU | |
| zkGPT [ 22 ] | GKR poly. | — | sm, GELU, LN | – |
| NanoZK | Plookup LUT | 16-bit | sm, GELU, SiLU, RMSNorm |
| Model | Fisher | Random | (pp) | |
|---|---|---|---|---|
| GPT-2 | 12 | 64.7% | 54.3% | +10.4 |
| TinyLLaMA | 22 | 86.0% | 79.3% | +6.7 |
| Phi-2 | 32 | 62.4% | 50.6% | +11.8 |
| Average: | +9.6 | |||
| Setup (s) | Attn Prove (s) | Verify (ms) | Block E2E (s) | Proof (KB) | ||
|---|---|---|---|---|---|---|
| 16 | 14 | 3.3 | 0.9 | 13 | 6.1 | 5.2 |
| 32 | 17 | 29.0 | 5.1 | 95 | 12.3 | 5.3 |
| 64 | 19 | 122.8 | 22.0 | 365 | 39.5 | 5.5 |
| 128 | 21 | 526.8 | 92.9 | 1,747 | 94.2 | 5.7 |
| 256 | 22 | 1,018 | 184.3 | 3,396 | — | 5.8 |
| 768 † | 24 | — | 25 ‡ | — | 68 ‡ | 6.9 |
| System | Prove | Size | PPL |
|---|---|---|---|
| ZKML [ 6 ] | 67 min | 7.8 KB | |
| zkLLM [ 25 ] | 15.8 s | 126 KB | |
| zkGPT [ 22 ] | 21.8 s | 101 KB | |
| NanoZK | 43 s † / 68 s | 6.9 KB |
Appendix figures & tables17 assets
Supplementary material from the paper’s appendix.
Appendix
| Function | Operating range | Output codomain | Anchors | Interp. |
|---|---|---|---|---|
| (softmax inner) | 1,024 | linear | ||
| (softmax norm) | 1,024 | linear | ||
| GELU / SiLU | 2,048 | linear | ||
| (RMSNorm) | 1,024 | linear |
| Operation | Lookup | Degree-7 poly |
|---|---|---|
| GELU activation | 262,144 lookups | 1.83 M mults |
| RMSNorm | 65,536 lookups | — (lookup only viable for invsqrt) |
| Softmax (per head) | 32,768 lookups + invreduce | not used (1/x ill-conditioned) |
| Total advice cells | 3.5 M (lookup-table arm) | 22 M (multiplication arm) |
| Lookup-table chip size | 14 | 18 |
| Model | Dataset | PPL (exact) | PPL (lookup) | |
|---|---|---|---|---|
| GPT-2-small | WikiText-2 (test) | 29.41 | 29.41 | |
| GPT-2-small | WikiText-103 (val) | 22.05 | 22.05 | |
| GPT-2-small | C4 (val, 50k tokens) | 35.18 | 35.18 | |
| GPT-2-medium | WikiText-2 (test) | 22.76 | 22.76 | |
| LLaMA-7B (1L) | WikiText-2 (test) | — | — | (per-layer act.) |
| NanoGPT-toy | shakespeare-char | 4.83 | 4.83 |
| Stage | Time (ms) | Share |
|---|---|---|
| Forward pass (GPU matmul + RMSNorm) | 18 | 3.8% |
| Constraint-table assignment buffer | 32 | 6.7% |
| Activation digest computation (SHA-256) | 1 | 0.2% |
| Halo2 column assignment + region layout | 98 | 20.5% |
| IPA MSM (commitment to polynomials) | 142 | 29.6% |
| IPA opening (rounds of inner product) | 98 | 20.5% |
| Quantity | ICICS body (Section 6 ) | Appendix 0.E (extended prototype) |
|---|---|---|
| Hardware | Intel Xeon @ 2.4 GHz, 64 GB RAM, no GPU | AMD Ryzen 5950X @ 4.4 GHz, 128 GB RAM, optional RTX 3090 |
| Halo2 backend | Halo2 IPA over Pallas, halo2curves Pippenger (32-thread or 1-thread CPU as noted in body) | Halo2 IPA over Pallas, halo2curves 0.6.0, 32-thread CPU baseline |
| Proof-size convention | Serialised proof bundle: IPA proof + boundary commitments + chain digests + public-input bytes ( 6.9 KB/layer at ) | Raw Halo2 IPA proof payload only, no boundary commitments or chain metadata ( 2.0–2.5 KB/layer) |
| Verify time | Single-core, 3.4 s for full 12-layer chain incl. SHA-256 chain check | Single-core, 22 ms per layer, 22 ms total parallelised; reported per layer |
| -coverage measured | for attention, for full block; rest projected | for attention, for full block |
| GPU numbers | Projected only (Section 6 , Appendix 0.G ) | Same; no GPU figures reported in Appendix 0.E |
| -param | Setup (s) | Witness (ms) | Prove (s) | Verify (ms) | Proof (B) | |
|---|---|---|---|---|---|---|
| 64 | 13 | 27.1 | 38 | 4.8 | 20.5 | 2,016 |
| 128 | 13 | 27.5 | 65 | 5.0 | 20.7 | 2,016 |
| 256 | 13 | 28.4 | 121 | 5.4 | 21.1 | 2,016 |
| 512 | 14 | 33.8 | 240 | 6.0 | 21.8 | 2,016 |
| 768 | 14 | 36.2 | 392 | 6.3 | 22.2 | 2,016 |
| 1024 | 14 | 36.7 | 528 | 6.3 | 22.4 | 2,016 |
| -param | Setup (s) | Witness (ms) | Prove (s) | Verify (ms) | Proof (B) | |
|---|---|---|---|---|---|---|
| 16 | 14 | 35.8 | 16 | 0.9 | 22.0 | 2,240 |
| 32 | 15 | 72.0 | 31 | 3.2 | 22.8 | 2,304 |
| 64 | 16 | 148.1 | 73 | 12.4 | 23.5 | 2,368 |
| 128 | 17 | 305.7 | 169 | 46.8 | 24.3 | 2,432 |
| 256 | 18 | 625.4 | 384 | 184 | 25.1 | 2,496 |
| 512 | 19 | — (OOM CPU) | — | — | — | — |
| -param | Setup (s) | Witness (ms) | Prove (s) | Verify (ms) | Proof (B) | |
| 64 | 16 | 152 | 88 | 13.5 | 24.5 | 2,368 |
| 128 | 17 | 312 | 195 | 50.2 | 25.4 | 2,432 |
| GPU-projected via 15–30 MSM speedup (Icicle, ) | ||||||
| 512 | 19 | — | — | 31 | 26 | 2,500 |
| 768 | 19 | — | — | 68 | 26 | 2,500 |
| Training domain | Eval domain | -value | |
|---|---|---|---|
| WikiText-2 | WikiText-2 (held-out) | 0.987 | |
| WikiText-2 | WikiText-103 (val) | 0.952 | |
| WikiText-2 | C4 (val) | 0.916 | |
| WikiText-2 | ShareGPT (val) | 0.881 | |
| WikiText-2 | PubMed Abstracts (val) | 0.834 | |
| WikiText-2 | GitHub Python (val) | 0.792 |
| (perturbation std) | Spearman | -value |
|---|---|---|
| 0.01 | 0.872 | |
| 0.02 | 0.901 | |
| 0.05 | 0.916 | |
| 0.10 | 0.892 |
| CPU 32T (ms) | GPU (ms) | GPU/32T ratio | vs. 1T speedup | |
|---|---|---|---|---|
| 14 | 21.4 | 41.0 | 1.92 slower | 1.8 |
| 15 | 50.7 | 47.7 | 1.06 slower | 4.1 |
| 16 | 121.0 | 75.4 | 0.62 | 6.5 |
| 17 | 480.1 | 247.9 | 0.52 | 7.6 |
| 18 | 803.0 | 481.8 | 0.60 | 8.1 |
| 19 | 1,176.6 | 929.5 | 0.79 | 7.9 |
| EZKL prove (s) | NanoZK MLP prove (s) | |
|---|---|---|
| 64 | 89 | 4.8 |
| 128 | 412 | 5.0 |
| 256 | 1,847 | 5.4 |
| 512 | OOM | 6.0 |
| 768 | OOM | 6.3 |
| Peak RSS (GB) | ||
|---|---|---|
| 64 | 13 | 8.2 |
| 128 | 13 | 8.9 |
| 256 | 13 | 10.4 |
| 512 | 14 | 18.1 |
| 768 | 14 | 19.7 |
| 1024 | 14 | 22.5 |
| Stage | Time (ms) |
|---|---|
| Public-input SHA-256 hashes | 1.0 |
| Chain digest consistency | 0.2 |
| IPA inner-product rounds (14) | 20.6 |
| Total verifier wall-clock | 21.8 |
| Mode | Latency budget | Verifier work | Security |
|---|---|---|---|
| Synchronous high-stakes audit (medical, legal, regulatory) | Minutes | Full -layer verify | SR, |
| Asynchronous logging / post-hoc compliance | Hours to days | Full -layer batched | SR, batched verify |
| Sampling-based attestation | Real-time path with offline audit | Partial, | Partial; tampering detected at rate |
| Conversational use (real-time) | Sub-second | Not feasible with current implementation; out of scope | — |
| NanoZK | HE / MPC | TEE | DP | Plaintext API | |
|---|---|---|---|---|---|
| Computation integrity (model exec.) | ✓ | ✗ | (vendor-trust) | ✗ | ✗ |
| Hides from verifier | ✓ | — | ✓ | — | ✗ |
| Hides from provider | ✗ | ✓ | — | ✗ | |
| Third-party-auditable | ✓ | ✗ | (remote attest.) | ✗ | ✗ |
| Transparent (no trusted setup) | ✓ | — | ✗ | — | — |
| Pairing-free | ✓ | varies | — | — | — |