perf: switch SW_EC to projective coordinates - extension -circuit crate#2404
Merged
jonathanpwang merged 4 commits intodevelop-v1.7.0from Feb 17, 2026
Merged
perf: switch SW_EC to projective coordinates - extension -circuit crate#2404jonathanpwang merged 4 commits intodevelop-v1.7.0from
jonathanpwang merged 4 commits intodevelop-v1.7.0from
Conversation
4ba875c to
f0e7b98
Compare
2dac4e5 to
2a11ba0
Compare
3eb3209 to
32fcd69
Compare
- Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations for secp256k1 (hybrid approach) - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Update setup validation to check 3 fields (X=modulus, Y=a, Z=b)
…ing (INT-6134) - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.) - Fix save_output() ordering in ec_double_proj_a0_expr and ec_double_proj_general_expr to (X3, Y3, Z3) - Fix sanity test proj_to_affine index mapping to match corrected output order - Remove dangling mod projective_test declaration
32fcd69 to
d8bb191
Compare
Contributor
|
@claude Review this PR. Check the equations in the AIR expressions against the ePrint algorithms in the PR description. Give a summary of the overall PR. |
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
jonathanpwang
left a comment
There was a problem hiding this comment.
Left some small comments. Please also fix the cuda issue claude raised
- Move EcAddExecutor/EcDoubleExecutor struct definitions from mod.rs to execution.rs with pub(crate) visibility on inner field - Fix CUDA constructor calls missing curve coefficient params (a, b) for WeierstrassAddChipGpu and WeierstrassDoubleChipGpu - Replace stale TODO with proper ec_add_sanity_test using projective coordinates and proj_to_affine helper, matching old test structure
Add comments to the four projective EC expression functions (add/double for a=0 and general a) documenting the optimization strategy, spec step references, and algebraic equivalence proofs. Each function now includes: - Column count with percentage reduction from naive implementation - Explanation of why saves are called explicitly (avoid suboptimal automatic save_if_overflow calls) - Spec step references mapping code to ePrint 2015/1060 algorithms - Algebraic proofs for non-obvious rearrangements (e.g. difference of squares, absorbed spec steps, combined mul-sub)
jonathanpwang
approved these changes
Feb 17, 2026
shuklaayush
pushed a commit
that referenced
this pull request
Apr 1, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 1, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 1, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 2, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 2, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 8, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 8, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 9, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 9, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 10, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 10, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
shuklaayush
pushed a commit
that referenced
this pull request
Apr 10, 2026
…te (#2404) Resolves INT-6134 - Update ec_add and ec_double to use projective coordinates (X:Y:Z) instead of affine coordinates (x,y), eliminating field inversions - Implement algorithms from ePrint 2015/1060: - Algorithm 7 (add, a=0) and Algorithm 1 (add, general) - Algorithm 9 (double, a=0) and Algorithm 3 (double, general) - Add k256-specific implementations with normalize_weak() for magnitude tracking - Update BLOCKS constants from affine (2,6) to projective (3,9) - Rename opcodes: SW_EC_ADD_NE -> SW_EC_ADD_PROJ, SW_EC_DOUBLE -> SW_EC_DOUBLE_PROJ - Rename add_ne directory and all identifiers to add (EcAddNeExecutor -> EcAddExecutor, etc.)
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.
Resolves INT-6134