perf(precompiles): add support for GLV strategy - #3426
Conversation
34daf0d to
5e40746
Compare
huitseeker
left a comment
There was a problem hiding this comment.
Thanks! overall this looks super promising!!
adr1anh
left a comment
There was a problem hiding this comment.
The signed GLV algebra looks correct to me:
u ≡ sa·a + λ·sb·b mod n
and the implementation consistently applies each sign both to the MSM base and to the scalar-field recomposition. Here λ is the scalar-field eigenvalue; β is only used to construct φ(P) = (βx, y).
I have two main blocking concerns:
- Valid zero GLV halves are always included in the 4-term MSM, but the curve precompile rejects zero-scalar terms. This can reject valid signatures.
- I don’t think GLV hints should become part of
encode_signature. Generating them through an event from the already-derivedU1/U2digests would preserve the signature API and avoid duplicating hashing, inversion, and scalar arithmetic.
There is also a mismatch between the PR description and the current branch: the description says selection remains manual and the benchmark uses Straus, while the implementation is now GLV-only and Straus is archived.
The remaining comments are documentation and MASM cleanup suggestions. There are also unrelated duplicate changelog entries, and the branch should be rebased rather than carrying the merge from next.
This was a static review; I did not compile or run tests.
dccc6c6 to
2509066
Compare
Move the secp256k1 GLV endomorphism scalar decomposition from the ECDSA verifier's MASM/advice ABI into the precompiles prover's addition-chain strategy: ecdsa_k256_keccak::verify logs a plain u1*G + u2*Q claim, and the deferred prover satisfies it with a GLV-decomposed chain, certified in-circuit (phi(P) proven via its value relation, lambda pinned by pointer, never an AIR constant). This also cleans up the CHANGELOG duplication left by the earlier merge with next, and drops the now-dead scalar_inv_mod_n/reduce_mod_n helpers.
2509066 to
22e3253
Compare
|
@adr1anh I've revamped the approach to account for our latest discussion. The initial overhead of GLV is now basically removed (and the gains are even bigger). This should also make it much easier / cleaner to integrate non-GLV curves like secp256r1 or Curve25519 in the future. |

Describe your changes
Add support for GLV strategy when computing MSMs.
Move the secp256k1 GLV endomorphism split from the ECDSA verifier's MASM/advice ABI into the precompiles prover's addition-chain strategy.
ecdsa_k256_keccak::verifynow always logs a plainu1*G + u2*Qclaim(Straus-shaped, no algorithm selector, no GLV advice), and the deferred prover satisfies it internally with a GLV-decomposed wNAF chain --
phi(P)is certified in-circuit via its value relation (x_phi = beta*x_P,y_phi = y_P), never trusted host advice.Performance comparison between the two algorithms: https://claude.ai/code/artifact/b2e7a755-9313-4397-9810-eba22ab4a39e?via=auto_preview
MASM overhead is negligible (12 cycles for
verify).Checklist before requesting a review
nextaccording to naming convention.CHANGELOG.md