Repository navigation
Three minor optimizations - #149
Merged
Merged
Conversation
6 of 14 tasks
frozenspider
force-pushed
the
fs/minor-optimizations
branch
from
November 11, 2026 11:47
27f1498 to
f5a3ed7
Compare
frozenspider
marked this pull request as ready for review
November 11, 2026 16:28
zkfriendly
force-pushed
the
fs/minor-optimizations
branch
from
November 11, 2026 16:53
f5a3ed7 to
6681fd1
Compare
zkfriendly
approved these changes
Nov 12, 2026
zkfriendly
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the PR. Everything looks correct. I also ran the benchmarks on smaller and larger sha-256 inputs and 1 5 and 16 threads and all showed faster proofs overall.
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.
This PR introduces 3 small optimizations:
(Timing verified using
cargo run --release -p bitz-cli -- circuit-e2e --circuit sha256-chain --num-blocks 600 --threads 5on my machine)Precompute
MaterializedMTransposedigest at setup.Build virtual mapBind circuit statementBind virtual map digestStoredIntegerused to beBox<[u64]>, now it can also store single u64 inline.This allows trivial freeing of SHA-256 witness, and speeds up witness generation as well:
Free witnessCompute$M^T * v$ without materializing full weights vector $v$
(where$v_{c \cdot 2^t + b} = \mathrm{row\_weights}[b] * \mathrm{column\_weights}[c]$ )
Instead we keep
row_weightsandcolumn_weightsseparately and materialize when needed.Transpose claimOverall, this reduces prover time from 1.5 s to 1.2 s and verifier time from 400 ms to 200 ms.
Some full measurements (highly inconsistent between runs, picked best ones)
Before:
After: