fix: splitting scalars edge case#20686
Merged
notnotraju merged 5 commits intoFeb 27, 2026
Merged
Conversation
…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.
…ztec-packages into rk/splitting-scalars-edge-case
notnotraju
commented
Feb 19, 2026
| // 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. |
Contributor
Author
There was a problem hiding this comment.
this is the main content change.
notnotraju
commented
Feb 20, 2026
| * | ||
| * See ecc/fields/endomorphism_scalars.py for an analysis. | ||
| */ | ||
| static void test_endomorphism_negative_k2_regression() |
Contributor
Author
There was a problem hiding this comment.
regression test that shows that this splitting scalars thing affected goblin
…d secpk1 (to at least generate parameters)
notnotraju
commented
Feb 23, 2026
| # 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: |
Contributor
Author
There was a problem hiding this comment.
this was the issue that we needed to fix.
suyash67
approved these changes
Feb 27, 2026
suyash67
left a comment
Contributor
There was a problem hiding this comment.
Good stuff! Thanks for doing this.
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>
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.
Fixes an edge case in the
split_into_endomorphism_scalarsmethod. Adds detailed documentation for the algorithm in the form of a literate python program and regression tests for EC edge cases andbiggroup_goblin.