Repository navigation
perf: optimize single-proof BSB22 verification - #37
Draft
ananas-block wants to merge 1 commit into
Draft
ananas-block wants to merge 1 commit into
ananas-block wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Single-commitment gnark Groth16 proofs currently require separate four-term and two-term pairing calls. Add
verify_opt()to combine the two equations with a nonzero Fiat–Shamir coefficient derived from the full key, public inputs, and proof. It verifies one proof at a time using the existing gnark proof and verifying key.Optional
verify_opt_with_options()accelerators validate a 49-byte quotient/remainder hint for the commitment hash and reuse a key digest pinned at build time. The hash hint is untrusted and checked with exact integer arithmetic and a canonical remainder bound. The key digest is a trusted verifier parameter and must never come from prover-controlled instruction data.verify()keeps its existing separate checks and error diagnostics.Measured with the same profiled SBF program and deterministic gnark fixtures:
verify_opt()adds no instruction data. The optional hash hint adds 49 bytes; the pinned digest adds none. The full benchmark matrix includes all combinations. The fully accelerated path saves 17,082–17,195 CU per proof, or 10.3–12.8%.The method documentation derives the prime-order cancellation bound and cites Bellare–Garay–Rabin, section 3.3 / Theorem 3.3 and BSB22, sections 5.1.2, 5.5 and 6.1. It states the classical random-oracle and trusted-setup assumptions. This concrete transcript adaptation has not received an independent cryptographic audit.
Validation:
cargo test --workspace, including gnark FFI, hash-to-field differential, Circom integration, and SBF rejection tests.bsb22 gnark-vk circom-vk.go test ./...for the gnark fixtures and deterministic generation.just lint,just check-nostd, and Rustdoc with broken-link warnings denied.verify_optrejects.