Skip to content

Add Composer::component_mul_generator_pair - #1016

Closed
HDauven wants to merge 1 commit into
masterfrom
feat/mul-generator-pair
Closed

HDauven wants to merge 1 commit into
masterfrom
feat/mul-generator-pair

Conversation

@HDauven

@HDauven HDauven commented Oct 8, 2026

Copy link
Copy Markdown
Member

Part of #1015

component_mul_generator_pair(jubjub, generator_a, generator_b) returns jubjub · generator_a and jubjub · generator_b from one scalar decomposition. It emits component_mul_generator's gates for the first generator, then the second generator's signed-digit rows, which read the same digit witnesses. The canonical range check, the zero pin, the leading-zero bound and the closing equality apply once to the shared accumulator, so both results carry the single call's bounds. Invalid generators and non-canonical scalars return the single call's errors before any gate is appended.

It takes 590 gates instead of 2 × 331. The existing gadgets' layouts and golden digests are unchanged. The fixed-base host code moves into a shared FixedBaseChain, which git diff --color-moved shows as a move.

Tests:

  • a golden digest for the pair, and layout checks against the single gadget;
  • honest round trips;
  • forgeries that give the second chain different digits (at the first, middle or last row, or another scalar's digits), or wrap the shared scalar (r, k + r, q, 1 − q). Each is rejected with CircuitUnsatisfied against keys compiled from the honest gadget.

Multiply two generators by one scalar from a single decomposition. The
gadget emits component_mul_generator for the first generator verbatim,
then the signed-digit rows of the second, which read their digits off
the first chain's scalar accumulator. The second multiplication shares
the canonicality check, the zero pin, the leading-zero bound and the
closing equality: 590 gates against 662 for two single calls.

The emission of component_mul_generator is unchanged; its golden digest
holds. The soundness suite gains forgeries that fill the two chains from
different digits, noncanonical aliases or modulus wraps, a golden digest
for the pair, and a check that the pair starts with the single gadget.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The implementation appears coherent and well tested, but changes cryptographic constraint wiring and therefore warrants final human review.

0 open findings

What changed in this PR

Adds an optimized fixed-base gadget that multiplies two generators using one securely constrained scalar decomposition.

Changes:

  • Adds component_mul_generator_pair, reducing two multiplications from 662 to 590 gates.
  • Refactors fixed-base chain construction for shared scalar witnesses.
  • Adds layout, correctness, validation, and soundness tests.
File Description
src/​composer/​fixed_base.rs Implements the paired gadget and shared chain logic.
src/​composer/​constraint_system/​ecc.rs Documents the new torsion-free point source.
src/​composer/​tests/​soundness/​fixed_base.rs Tests wiring, layout, and forgery resistance.
tests/​ecc.rs Adds integration and input-validation tests.
CHANGELOG.md Records the public API addition.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.33%. Comparing base (7381206) to head (6a59ede).

Files with missing lines Patch % Lines
src/composer/tests/soundness/fixed_base.rs 94.36% 8 Missing ⚠️
tests/ecc.rs 90.90% 8 Missing ⚠️
src/composer/fixed_base.rs 97.87% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1016      +/-   ##
==========================================
+ Coverage   92.25%   92.33%   +0.07%     
==========================================
  Files          81       81              
  Lines        8887     9162     +275     
==========================================
+ Hits         8199     8460     +261     
- Misses        688      702      +14     
Files with missing lines Coverage Δ
src/composer/constraint_system/ecc.rs 0.00% <ø> (ø)
src/composer/fixed_base.rs 94.61% <97.87%> (+3.04%) ⬆️
src/composer/tests/soundness/fixed_base.rs 88.25% <94.36%> (+3.09%) ⬆️
tests/ecc.rs 95.10% <90.90%> (-1.24%) ⬇️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7381206...6a59ede. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@HDauven
HDauven marked this pull request as draft October 8, 2026 16:34
@HDauven

HDauven commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

None of our circuits lands in a smaller proving domain with these savings, so they would not speed up proving. Closing; 0.24.1 ships without them. The branch stays in case a later circuit needs it.

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.

2 participants