Skip to content

Comments

fix: splitting scalars edge case#20686

Open
notnotraju wants to merge 5 commits intomerge-train/barretenbergfrom
rk/splitting-scalars-edge-case
Open

fix: splitting scalars edge case#20686
notnotraju wants to merge 5 commits intomerge-train/barretenbergfrom
rk/splitting-scalars-edge-case

Conversation

@notnotraju
Copy link
Contributor

@notnotraju notnotraju commented Feb 19, 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.

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
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.

*
* See ecc/fields/endomorphism_scalars.py for an analysis.
*/
static void test_endomorphism_negative_k2_regression()
Copy link
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
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
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.

1 participant