Skip to content

perf:avoid wasteful to_affine inversions in ecrecover#859

Merged
diegokingston merged 1 commit into
mainfrom
perf/ecsm-avoid-to-affine
Jul 24, 2026
Merged

perf:avoid wasteful to_affine inversions in ecrecover#859
diegokingston merged 1 commit into
mainfrom
perf/ecsm-avoid-to-affine

Conversation

@jotabulacios

@jotabulacios jotabulacios commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

The ECSM ecrecover path lifted already-affine points (G, decompressed R, and the result) to Z=1 projective and called k256's to_affine, which runs a full field inversion regardless of Z — paying a ~256-mul inversion to recover coordinates we already had, 3× per recovery.

lincomb2_with_oracle/ecsm_lincomb2 now take and return AffinePoint and ecrecover uses the affine result directly. Results are identical; guards and the on-curve check are unchanged.

@jotabulacios

Copy link
Copy Markdown
Collaborator Author

/bench-prove

@github-actions

Copy link
Copy Markdown

Benchmark — ethrex 20 transfers (median of 3)

Table parallelism: auto (cores / 3)

Metric main PR Δ
Peak heap 73028 MB 56581 MB -16447 MB (-22.5%) 🟢
Prove time 37.771s 30.782s -6.989s (-18.5%) 🟢

🎉 Improvement detected — heap or time decreased by more than 5%.

✅ Low variance (time: 1.4%, heap: 1.0%)

Commit: 29de893 · Baseline: cached · Runner: self-hosted bench

@jotabulacios
jotabulacios marked this pull request as ready for review July 23, 2026 20:18
@jotabulacios jotabulacios changed the title Avoid wasteful to_affine inversions in ecrecover perf:avoid wasteful to_affine inversions in ecrecover Jul 23, 2026
@diegokingston
diegokingston added this pull request to the merge queue Jul 24, 2026
Merged via the queue into main with commit 73aeb41 Jul 24, 2026
15 checks passed
@diegokingston
diegokingston deleted the perf/ecsm-avoid-to-affine branch July 24, 2026 18:40
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.

3 participants