Skip to content

fix(verifier): call OpenVM wrapper through its typed entry point - #181

Merged
Thegaram merged 1 commit into
mainfrom
fix-openvm-verifier-bypass-via-selector
Nov 10, 2026
Merged

Thegaram merged 1 commit into
mainfrom
fix-openvm-verifier-bypass-via-selector

Conversation

@Thegaram

Copy link
Copy Markdown
Contributor

Summary

ZkEvmVerifierPostFeynman built the Halo2 payload by hand and sent it with a raw staticcall. The first 4 bytes of that call came from the caller's bundleProof. The OpenVM 2.0 wrapper has a function dispatcher, so these bytes can select the wrapper's own verify(...). That function reads public values from caller-chosen offsets, so a valid old proof can pass for a new public input.

This PR replaces the raw call with the typed call IOpenVmHalo2Verifier.verify(publicInputHash, bundleProof, verifierDigest1, verifierDigest2). The compiler now fixes the selector. The contract supplies the commitments and the public-input hash.

Changes

  • ZkEvmVerifierPostFeynman.sol: typed call in try/catch. The hand-built payload is gone. Constructor checks for the verifier and the digests.
  • IOpenVmHalo2Verifier.sol: new interface.
  • Tests: unit tests, a differential fuzz, a frozen copy of the old contract, and the vendored OpenVM 2.0 wrapper (src/test/openvm/, verbatim except the pragma).

Equivalence with the old encoding

  • Side-by-side review: both versions write the same layout (accumulator, digests, 32 public-input bytes one per word, proof suffix). Byte order matches.
  • Differential fuzz: the old and new payloads are byte-identical across 10,000 random inputs. A mutation (swapped digests) makes the test fail.
  • Fork test (mainnet, batch 520733): the live old verifier and the live wrapper produce byte-identical payloads (2848 bytes). The real proof verifies. A one-bit change in the public input reverts. This test runs manually and is not in the repo.
  • Bytecode identity: the deployed wrapper runtime matches zkvm-prover@bf88715 releases/dev/verifier/verifier.bin, the same commit as the vendored source.

Behavior changes

  • Stricter input: bundleProof must be exactly 1760 bytes. The old path also accepted a valid proof with extra bytes on the end; the new path rejects it. All 38 sampled mainnet proofs are 1760 bytes.
  • Constructor checks: reverts if plonkVerifier has no code (InvalidPlonkVerifier) or if a digest is at or above the BN254 field modulus (InvalidVerifierDigest).
  • Errors: verify failures still revert with VerificationFailed().
  • Gas: +2.4k per verification (300,662 → 303,044), about +0.5% of a finalize tx.

Deployment

Deploy a new ZkEvmVerifierPostFeynman. Check that plonkVerifier and protocolVersion equal the live 0x7966… values. Then register it for version 10 in MultipleVersionRollupVerifier.

@Thegaram

Copy link
Copy Markdown
Contributor Author

Previously reviewed on a private fork by @lispc.

@Thegaram
Thegaram merged commit 8264260 into main Nov 10, 2026
5 checks passed
@Thegaram
Thegaram deleted the fix-openvm-verifier-bypass-via-selector branch November 10, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant