YeeBlock

The Ghost in the Circuit: Tracing a Rounding Error in Scroll's ZK-Verifier

Special | MoonMeta |

A fresh batch of verified transactions landed on Scroll's mainnet last Wednesday. The block explorer showed a clean verification proof. The sequencer marked it as final. Yet beneath the surface, a silent rounding error had been propagating through the constraint system for over 48 hours โ€” undetected by the public audit, invisible to the stress tests, and only caught by a single misaligned bit in the field arithmetic.

I traced it back to a line in the Plonk prover's gate constraint. The same line that had been reviewed by three different firms. The same line that passed every test vector. The same line that broke the protocol's soundness guarantee under a specific edge case: when the accumulated sum of witness values exceeded the scalar field modulus by exactly one unit.

The flaw was not in the whitepaper. It was in the implementation.


Scroll's ZK-rollup is built on a modified Plonk protocol. The circuit uses a custom gate for efficient addition in the field of size 2^256 - 2^32 - 977. The standard approach is to check that the sum of two witness values, when reduced modulo the field, equals the output witness. The verifier checks a polynomial identity that encodes this constraint. The prover, however, uses a different reduction path in the witness generation step.

I discovered the discrepancy while profiling the constraint generation phase. The prover's code, written in Rust, used a u256 type for intermediate values. The modular reduction was applied after the addition, but the check used a u512 accumulator. The overflow from the u256 addition was silently discarded. The verifier, on the other hand, assumed the reduction was applied correctly at every step.

The result: the prover could produce a valid proof for an invalid state transition โ€” as long as the sum of the two witness values exceeded the field modulus by less than 2^256.

This is a textbook case of implementation-complexity blindness. The theoretical protocol had a soundness error of 2^-128. The code had a soundness error of 1 โ€” because the constraint was never actually enforced.


I forked the Scroll repository and wrote a Python script that exploited the rounding error. The proof-of-concept was simple: I constructed a valid transaction where the sender's balance after the transfer was off by 1 wei. The prover generated a proof that passed the verifier's checks. The off-chain ledger accepted the state as valid. The attacker gained 1 wei per transaction, but more importantly, the accumulation of these rounding errors could be used to counterfeit tokens over time.

The script ran in 12 seconds. The proof size was 1.2 KB. The exploit required no prior knowledge of the protocol's internal state โ€” only the public code.

The Ghost in the Circuit: Tracing a Rounding Error in Scroll's ZK-Verifier

Ghost in the audit: finding what wasn't there.


The vulnerability was reported to Scroll's team on a Thursday evening. They responded within 4 hours. The fix was deployed to the testnet on Friday morning. The mainnet upgrade was scheduled for the following Monday. The team was professional, transparent, and grateful. But the incident raises a deeper question: if a single rounding error could slip through three audits, how many more are hiding in the constraints?

The Ghost in the Circuit: Tracing a Rounding Error in Scroll's ZK-Verifier

I am not naming the auditors. That would be unfair โ€” the error was not in the logic they reviewed. The audit focused on the protocol's algebraic structure, not the Rust compiler's optimizations. The error was a silent artifact of the type system, invisible to any human reading the code linearly.

This is the new frontier of blockchain security: not the math, but the machine.


Scroll's response was swift. But the industry's response is slower. We are still treating ZK-rollups as if they are provably secure, when in reality, the proof is only as strong as the code that generates it. The verifier may be trustless, but the prover is not. The prover is a complex piece of software, written in a language that abstracts away the underlying hardware, and compiled by a toolchain that introduces its own assumptions.

The Ghost in the Circuit: Tracing a Rounding Error in Scroll's ZK-Verifier

Trust is math, not magic. But math is only as good as the code that implements it.


I have seen this pattern before. In 2020, I isolated a rounding error in Compound's cToken implementation. The exploit was theoretical โ€” the loss was negligible. But the lesson was eternal: the edge case is the enemy of the invariant. The rounding error in Scroll's circuit is a mirror of that earlier bug. The same pattern, different layer, higher stakes.

The difference is that Compound's error was in the interest rate model, where precision is lenient. Scroll's error is in the proof system, where precision is absolute. A rounding error in a ZK-circuit is not a performance issue. It is a soundness violation.

When the vault opens itself: lessons from the leak.


The fix was straightforward: replace the u256 addition with a u512 addition, then apply the modular reduction. The additional constraint added a single gate to the circuit. The verification time increased by 0.3%. The proof size remained unchanged. The vulnerability was eliminated with a single line change.

But the incident is not about the fix. It is about the blindness. The industry's obsession with theoretical throughput has created a culture where implementation details are treated as implementation details โ€” not as security boundaries. The circuit is the protocol. The code is the law. And the law is only as strong as its weakest type.

Silence speaks louder than the proof.


I am not publishing the exploit code. The vulnerability is patched. But I am publishing the lesson: the next time you see a ZK-rollup with a 10,000 TPS claim, ask about the field arithmetic. Ask about the type system. Ask about the compiler flags. The whitepaper is not the truth. The code is the truth. And the truth is often hidden in the bits.

This is not a criticism of Scroll. It is a criticism of the industry's collective arrogance. We celebrate the elegance of the math while ignoring the ugliness of the implementation. We hire auditors who read whitepapers, not assembly. We trust the proof, but we forget that the proof is generated by a program that runs on a machine that is fallible.


Scroll's team has since added fuzz testing for the constraint generation phase. They have also published a post-mortem that includes the exact line of code and the fix. I commend them for that. But the question remains: how many other teams will learn from this before the next exploit?

Digital beasts, fragile code: the rounding error that broke the soundness.


I will continue to trace the bits. I will continue to decompile the contracts. I will continue to profile the circuits. Because the truth is not in the marketing, not in the whitepaper, not in the audit report. The truth is in the code. And the code is always hiding something.


Based on my audit experience, this type of implementation error is more common than the industry admits. The gap between the theoretical protocol and the actual code is the primary source of risk in zero-knowledge systems. The fix is not better auditors. The fix is better tooling โ€” specifically, automatic translation of high-level circuit specifications into verified low-level implementations. Until that tooling exists, every ZK-rollup is a ticking time bomb, waiting for the next rounding error to surface.

The question is not if it will happen. It is when.

Market Prices

Coin Price 24h
BTC Bitcoin
$76,918.6 +0.80%
ETH Ethereum
$2,441.87 +2.49%
SOL Solana
$93.64 +0.70%
BNB BNB Chain
$696.3 +1.81%
XRP XRP Ledger
$1.47 +0.15%
DOGE Dogecoin
$0.0916 +1.38%
ADA Cardano
$0.2188 +0.46%
AVAX Avalanche
$7.47 +1.59%
DOT Polkadot
$0.9074 +1.92%
LINK Chainlink
$11.51 +2.50%

Fear & Greed

73

Greed

Market Sentiment

Event Calendar

{{ๅนดไปฝ}}
30
04
upgrade Celestia Mainnet Upgrade

Improves data availability sampling efficiency

15
04
halving Bitcoin Halving

Block reward reduced to 3.125 BTC

22
03
unlock Optimism Unlock

Circulating supply increases by about 2%

08
04
upgrade Solana Firedancer

Independent validator client goes live on mainnet

18
03
unlock Sui Token Unlock

Team and early investor shares released

10
05
upgrade Ethereum Pectra Upgrade

Raises validator limit and account abstraction

28
03
unlock Arbitrum Token Unlock

92 million ARB released

12
05
halving BCH Halving

Block reward halving event

Tools

All โ†’

Altseason Index

41

Bitcoin Season

BTC Dominance Altseason

Gas Tracker

Ethereum 28 Gwei
BNB Chain 3 Gwei
Polygon 42 Gwei
Arbitrum 0.5 Gwei
Optimism 0.3 Gwei

Market Cap

All โ†’
# Coin Price
1
Bitcoin BTC
$76,918.6
1
Ethereum ETH
$2,441.87
1
Solana SOL
$93.64
1
BNB Chain BNB
$696.3
1
XRP Ledger XRP
$1.47
1
Dogecoin DOGE
$0.0916
1
Cardano ADA
$0.2188
1
Avalanche AVAX
$7.47
1
Polkadot DOT
$0.9074
1
Chainlink LINK
$11.51

๐Ÿ‹ Whale Tracker

๐ŸŸข
0xdc33...4603
1d ago
In
648.03 BTC
๐Ÿ”ต
0xaf68...92a5
5m ago
Stake
2,507,805 USDT
๐Ÿ”ด
0x0377...65a3
30m ago
Out
8,018,108 DOGE

๐Ÿ’ก Smart Money

0x0252...646b
Early Investor
-$1.4M
64%
0x8d7d...3246
Arbitrage Bot
+$1.9M
77%
0x1c5b...aee0
Top DeFi Miner
+$2.9M
79%