Skip to content

fix: splitting scalars edge case#20686

Merged
notnotraju merged 5 commits into
merge-train/barretenbergfrom
rk/splitting-scalars-edge-case
Feb 27, 2026
Merged

fix: splitting scalars edge case#20686
notnotraju merged 5 commits into
merge-train/barretenbergfrom
rk/splitting-scalars-edge-case

Conversation

@notnotraju

@notnotraju notnotraju commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Fixes an edge case in the split_into_endomorphism_scalars method. Adds detailed documentation for the algorithm in the form of a literate python program and regression tests for EC edge cases and biggroup_goblin.

notnotraju and others added 2 commits February 19, 2026 10:47
…alar multiplication

Tests for the negative-k2 bug in split_into_endomorphism_scalars (Fr and Fq),
plus EC-level scalar multiplication tests (g1 and grumpkin) showing the bug
produces wrong points. Includes endomorphism_scalars.py for deriving the
boundary scalars.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…and changed the tests to be regression tests accordingly.
@notnotraju notnotraju self-assigned this Feb 19, 2026
@notnotraju notnotraju added bberg-int-audit All things related to barretenberg internal audit ci-barretenberg-full Run all barretenberg checks. labels Feb 19, 2026
…ztec-packages into rk/splitting-scalars-edge-case
// When negative, t1 = k2 + r is 254 bits (upper limbs nonzero).
// Fix: decrement c1 by 1, equivalent to adding |b1| to k2.
// This shifts k2 by +|b1| (~127 bits, now positive) and k1 by -a1 (~64 bits),
// keeping both within 128 bits. See endomorphism_scalars.py for more details.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is the main content change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice!

*
* See ecc/fields/endomorphism_scalars.py for an analysis.
*/
static void test_endomorphism_negative_k2_regression()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

regression test that shows that this splitting scalars thing affected goblin

…d secpk1 (to at least generate parameters)
# Computes (k1, k2) with k ≡ k1 - λ·k2 (mod r) and |k1|, |k2| < 2^128.
# See §0 for the derivation (Babai's nearest plane).
#
# SUBTLETY — k2 CAN BE NEGATIVE:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this was the issue that we needed to fix.

@notnotraju notnotraju requested a review from suyash67 February 23, 2026 13:11

@suyash67 suyash67 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good stuff! Thanks for doing this.

@notnotraju notnotraju merged commit 0d76e20 into merge-train/barretenberg Feb 27, 2026
10 checks passed
@notnotraju notnotraju deleted the rk/splitting-scalars-edge-case branch February 27, 2026 11:57
github-merge-queue Bot pushed a commit that referenced this pull request Feb 27, 2026
BEGIN_COMMIT_OVERRIDE
chore: cleanup polynomials module (#20585)
fix: splitting scalars edge case (#20686)
feat: parallelize ACIR parsing and decompression (#20873)
END_COMMIT_OVERRIDE
johnathan79717 pushed a commit that referenced this pull request Mar 4, 2026
Fixes an edge case in the `split_into_endomorphism_scalars` method. Adds
detailed documentation for the algorithm in the form of a literate
python program and regression tests for EC edge cases and
`biggroup_goblin`.

---------

Co-authored-by: notnotraju <raju@aztec-labs.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bberg-int-audit All things related to barretenberg internal audit ci-barretenberg-full Run all barretenberg checks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants