Skip to content

Smaller circuit terms - #151

Open
frozenspider wants to merge 4 commits into
mainfrom
fs/smaller-circuit-terms
Open

frozenspider wants to merge 4 commits into
mainfrom
fs/smaller-circuit-terms

Conversation

@frozenspider

@frozenspider frozenspider commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Resolves #41

Summary of changes:

  • Change coefficients in SHA-256 circuit from BigInt to i64 - this is safe to do as all coefficients are $\le 2^{35}$.
  • Relax BitzSemiring: From<u64> to From<u32>. This does not involve any kind of performance penalty, but lets i64 become BitzConstraintRing: BitzSemiring.
  • As a guardrail, check_witness and IntegerProducts::is_satisfied now perform check for arithmetics overflow.
  • As another guardrail, constraint generator now checks limb capacity of a ring at compile time.

Result:

Measured on my machine:
cargo run --release -p bitz-cli -- circuit-e2e --circuit sha256-2kb --threads 5

What Before After
Setup/Synthesize constraints ~420 ms ~300 ms
Setup/Prepare integer matrices ~290 ms ~210 ms
Peak RSS of circuit-e2e 270 MiB 186 MiB
Generator output matrices 95 MiB 54 MiB
Synthesis peak 132 MiB 89 MiB
Prepare integer matrices peak 159 MiB 89 MiB

cargo run --release -p bitz-cli -- circuit-e2e --circuit sha256-chain --num-blocks 600 --threads 5

What Before After
Setup/Synthesize constraints ~8.4 s ~6.9 s
Setup/Prepare integer matrices ~3.6 s ~1.3 s
Peak RSS of circuit-e2e 4790 MiB 3220 MiB
Generator output matrices 1781 MiB 1020 MiB
Synthesis peak 2328 MiB 1543 MiB
Prepare integer matrices peak 2889 MiB 1543 MiB

Other running time numbers are unaffected.

@frozenspider frozenspider changed the title [WIP] Smaller circuit terms Smaller circuit terms Nov 13, 2026
@frozenspider
frozenspider marked this pull request as ready for review November 13, 2026 15:14
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.

Prover and verifier optimisation: tracking issue

1 participant