Skip to content

Security/zk verifier hardening#108

Merged
nol4lej merged 25 commits into
mainfrom
security/zk-verifier-hardening
Jul 5, 2026
Merged

Security/zk verifier hardening#108
nol4lej merged 25 commits into
mainfrom
security/zk-verifier-hardening

Conversation

@nol4lej

@nol4lej nol4lej commented Jul 4, 2026

Copy link
Copy Markdown
Member

No description provided.

nol4lej added 25 commits July 2, 2026 17:51
A verifying key was registered with only a size check — its bytes were
never deserialized and its arity never checked against the circuit. A
wrong-arity or malformed key was accepted silently and only surfaced at
proof time (failing, or worse, verifying over the wrong public inputs).

Add expected_public_inputs() and VerifyingKey::num_public_inputs() to
the primitive, and an ensure_vk_arity check in the pallet's
register_verification_key and batch_register_verification_keys. The
pallet test mock now builds real BN254 Groth16 VKs of the right arity.
Genesis is unaffected (keys are registered post-genesis via extrinsic).
The bypass that lets benchmarks run with dummy proofs was gated on
runtime-benchmarks, the same feature a release runtime enables to expose
its benchmarks. Such a runtime accepted any proof, enabling trivial
double-spends.
… count

The verify_proof weight scales with the number of public inputs (one G1
scalar-mul per input), but the benchmark ran a fixed 7-input case, so the
generated weight had no `n` component and did not match the
`WeightInfo::verify_proof(n)` trait signature.

Add `n: Linear<1, 32>`: the benchmark builds a synthetic VK of arity `n` via
`synthetic_vk`, so the runner measures the real per-input slope and emits
`fn verify_proof(n: u32) -> Weight`. The proof no longer needs to satisfy the
VK — the pairing runs, fails, and `skip-proof-verification` records the weight
anyway, removing the dependency on a verifiable fixture triple.

Drop the now-unused vk_transfer.bin and public_inputs_transfer.bin fixtures.
Rewrite generate-bench-fixtures.mjs to resolve circuit and proof-compressor
artifacts from the @orbinum/circuits and @orbinum/groth16-proofs npm packages
instead of local sibling checkouts, so fixtures can be regenerated on any VPS
(cd scripts && npm install && node generate-bench-fixtures.mjs).
Measured on Hetzner CPX62 (16 vCPU AMD, 32 GB RAM),
steps=50 repeat=20. verify_proof(n) now carries the measured per-input slope
Re-run pallet_zk_verifier benchmarks on reference hardware with the
parametrized verify_proof(n) benchmark. Replaces the conservative
placeholder (200ms/input) with the measured slope (~19us/input over an
~11ms Groth16 pairing base)
Removed batch_verify + field_utils, added arity-check APIs, canonical/LE
parser fixes. Date the CHANGELOG Unreleased section.
Removed CircuitId::SHIELD, verify_proof rejects non-32-byte inputs,
skip-proof-verification feature, measured verify_proof(n) weights.
skip-proof-verification feature + integrity_test mirroring the zk-verifier
change. Cargo.lock picks up all three version bumps.
@nol4lej nol4lej merged commit 8930d62 into main Jul 5, 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