Skip to content

perf: switch SW_EC to projective coordinates - extension -circuit crate#2404

Merged
jonathanpwang merged 4 commits intodevelop-v1.7.0from
perf/sw-ec-projective-INT-6034
Feb 17, 2026
Merged

perf: switch SW_EC to projective coordinates - extension -circuit crate#2404
jonathanpwang merged 4 commits intodevelop-v1.7.0from
perf/sw-ec-projective-INT-6034

Conversation

@Tuanlinh12312
Copy link
Copy Markdown

@Tuanlinh12312 Tuanlinh12312 commented Feb 10, 2026

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

- 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
@Tuanlinh12312 Tuanlinh12312 force-pushed the perf/sw-ec-projective-INT-6034 branch from 32fcd69 to d8bb191 Compare February 16, 2026 23:10
Comment thread extensions/ecc/circuit/src/weierstrass_chip/add/mod.rs Outdated
@jonathanpwang
Copy link
Copy Markdown
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.

@claude

This comment was marked as resolved.

Comment thread extensions/ecc/circuit/src/weierstrass_chip/add/mod.rs Outdated
Comment thread extensions/ecc/circuit/src/weierstrass_chip/double/mod.rs
Copy link
Copy Markdown
Contributor

@jonathanpwang jonathanpwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 jonathanpwang merged commit aa1d833 into develop-v1.7.0 Feb 17, 2026
30 of 61 checks passed
@jonathanpwang jonathanpwang deleted the perf/sw-ec-projective-INT-6034 branch February 17, 2026 22:00
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.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants