Skip to content

Inject LambdaVM crypto into the ethrex guest#702

Open
jotabulacios wants to merge 2 commits into
mainfrom
feat/ethrex-crypto-injected
Open

Inject LambdaVM crypto into the ethrex guest#702
jotabulacios wants to merge 2 commits into
mainfrom
feat/ethrex-crypto-injected

Conversation

@jotabulacios

@jotabulacios jotabulacios commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

This PR builds on #666 by adding ECSM-accelerated secp256k1_ecrecover and moving the crypto implementation into this repo.

Accelerates secp256k1_ecrecover via the ECSM precompile. The ECDSA recovery's linear combination pk = u1·G + u2·R is evaluated through four x-only ecsm_mul queries and full-point reconstruction via the chord law, with all three inversions batched. Falls back to pure-Rust ProjectivePoint::lincomb for degenerate cases (zero scalars, identity points, cancelling terms). Uses the existing x-only ABI — no executor or prover changes required. keccak256 continues routing to the keccak_permute precompile as before.

Moves the crypto implementation into this repo as a new crate crypto/ethrex-crypto (lambda-vm-ethrex-crypto). Previously the LambdaVmCrypto impl lived inside the ethrex repo (crates/guest-program/src/crypto/lambdavm.rs). The guest now constructs LambdaVmEcsmCrypto from this crate and injects it via Arc<dyn Crypto> — crypto changes no longer require an ethrex PR.

Validation

  • crypto/ethrex-crypto host tests: 5/5lincomb2 correctness on fixed inputs and recovery shape, plus three degenerate fallback guards (edge scalars, identity points, cancelling terms).
  • Guest ELF builds for riscv64, links clean.
  • Cycle counts on vm-benchmarks-1 — each ETH transfer triggers one secp256k1_ecrecover:
Block ecrecover Cycles
simple_tx (1 tx) software k256 4,642,452
simple_tx (1 tx) ECSM (this PR) 1,794,386
10 transfers ECSM (this PR) 6,879,038

@jotabulacios jotabulacios marked this pull request as ready for review June 23, 2026 21:10
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