Skip to content

fix(zk-verifier): real Groth16 weights in verify_proof benchmark#88

Merged
nol4lej merged 1 commit into
mainfrom
fix/zk-verifier-real-benchmark-weights
May 22, 2026
Merged

fix(zk-verifier): real Groth16 weights in verify_proof benchmark#88
nol4lej merged 1 commit into
mainfrom
fix/zk-verifier-real-benchmark-weights

Conversation

@nol4lej
Copy link
Copy Markdown
Member

@nol4lej nol4lej commented May 22, 2026

do_verify previously short-circuited to 'return true' under feature = "runtime-benchmarks", so the benchmark only measured FRAME overhead (~µs) instead of the real BN254 pairing cost (~8-10 ms). This caused a severe weight underestimation — a potential DoS vector.

Fix:

  • Remove 'runtime-benchmarks' from the #[cfg] bypass in do_verify. Short-circuit now applies only in #[cfg(test)].
  • Embed real Groth16 fixtures via include_bytes!:
    src/bench_fixtures/vk_transfer.bin (488 B, arkworks VK)
    src/bench_fixtures/proof_transfer.bin (128 B, compressed proof)
    src/bench_fixtures/public_inputs_transfer.bin (224 B, 7×32 B LE)
  • benchmarking.rs verify_proof now uses the real fixtures so that
    weight generation on Hetzner CCX33 captures true on-chain cost.
  • Add scripts/generate-bench-fixtures.mjs to regenerate fixtures
    after any circuit change.

Closes: #
Version: 0.7.0

do_verify previously short-circuited to 'return true' under
feature = \"runtime-benchmarks\", so the benchmark only measured FRAME
overhead (~µs) instead of the real BN254 pairing cost (~8-10 ms).
This caused a severe weight underestimation — a potential DoS vector.

Fix:
- Remove 'runtime-benchmarks' from the #[cfg] bypass in do_verify.
  Short-circuit now applies only in #[cfg(test)].
- Embed real Groth16 fixtures via include_bytes!:
    src/bench_fixtures/vk_transfer.bin       (488 B, arkworks VK)
    src/bench_fixtures/proof_transfer.bin    (128 B, compressed proof)
    src/bench_fixtures/public_inputs_transfer.bin (224 B, 7×32 B LE)
- benchmarking.rs verify_proof now uses the real fixtures so that
  weight generation on Hetzner CCX33 captures true on-chain cost.
- Add scripts/generate-bench-fixtures.mjs to regenerate fixtures
  after any circuit change.

Closes: #<issue>
Version: 0.7.0
@nol4lej nol4lej merged commit f8a637a into main May 22, 2026
6 checks passed
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