perf: cache the Bulletproofs generators instead of rebuilding them per call - #1013
Merged
Conversation
jonas-lj
marked this pull request as ready for review
August 27, 2026 13:24
…r call `prove_batch` and `verify_batch` called `BulletproofGens::new(bits, m)` on every invocation, which dominated both operations: at 64-bit x32 the build alone costs ~32 ms against ~17 ms of actual verification. The generators are prefix stable in both dimensions, so a single oversized instance serves every configuration and yields byte-identical proofs. `Range` caps the bit width at 64, so only the batch size can exceed the cached object; larger batches keep building generators per call as before. No API or wire-format change.
jonas-lj
force-pushed
the
jonas/bp-cache-generators
branch
from
August 27, 2026 13:31
ca7e18a to
151e363
Compare
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.
prove_batchandverify_batchrebuiltBulletproofGenson every call. This PR caches them on first use.Verification benchmarks: