perf: twisted Edwards lattice-based double-base MSM#1765
Open
yelhousni wants to merge 9 commits into
Open
Conversation
13 tasks
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d230b53. Configure here.
Contributor
Author
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.

Description
This PR is stacked on #1763 and contains the native twisted Edwards MSM follow-up only. It adds lattice-based double-base scalar multiplication variants for native twisted Edwards curves:
DoubleBaseScalarMulNonZeroas the optimized non-degenerate path.DoubleBaseScalarMulremains complete for the public API and handles zero scalars / identity edge cases before dispatching to the optimized non-zero path. The branch also includes the review fixes that remove redundant hint outputs, wire scalar decomposition verification into the twisted Edwards scalar multiplication path, and bind the non-GLV MSM hint to a single result with the sound relation[x1]P1 + [x2]P2 - [z]R = O.This PR intentionally does not include the emulated G2 GLV+FakeGLV work; that is split into #1764.
Type of change
How has this been tested?
Focused test run:
go test -short ./std/algebra/native/twistededwards ./internal/statsSpecifically covered:
How has this been benchmarked?
internal/stats/latest_stats.csvwas regenerated with new MSM(2) snippets.msm_G1_bn254_2msm_P256_2msm_secp256k1_2msm_babyjubjub_2msm_jubjub_2msm_bandersnatch_2Checklist:
golangci-lintdoes not output errors locallygnark-crypto/algebra/lattice)Note
High Risk
Touches cryptographic scalar decomposition and hint verification logic used in-circuit (GLV/fake-GLV and new TE MSM paths), where mistakes can cause soundness or incorrect proofs. Adds new hint-driven MSM implementations and parameter handling across multiple curves, increasing surface area despite added regression tests.
Overview
Adds an optimized native twisted Edwards
DoubleBaseScalarMulNonZerothat dispatches to new lattice-based MSM variants: a 3-MSM path for non-GLV curves and a 6-MSM (with φ endomorphism) path for Bandersnatch, including wiring endomorphism parameters intoNewEdCurve.Replaces HalfGCD/Eisenstein HalfGCD hint usage with LLL-backed rational reconstruction (
rationalReconstruct,rationalReconstructExt) in both emulated SW and native BLS12-377 GLV+FakeGLV paths, and tightens bit-length bounds for the GLV accumulator loops.Introduces new twisted Edwards hints (
doubleBaseScalarMulHint, multi-scalar rational reconstruction hints) plus emulated-order parameters and in-circuit decomposition verification helpers, and adds/updates regression tests to reject trivial decompositions and forged MSM hint outputs. Updatesinternal/statssnippets/bench CSV with new MSM(2) measurements (including TE curves).Reviewed by Cursor Bugbot for commit 82edcb3. Bugbot is set up for automated code reviews on this repo. Configure here.