Skip to content

perf:avoid wasteful to_affine inversions in ecrecover#859

Open
jotabulacios wants to merge 1 commit into
mainfrom
perf/ecsm-avoid-to-affine
Open

perf:avoid wasteful to_affine inversions in ecrecover#859
jotabulacios wants to merge 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
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.

1 participant