-
Notifications
You must be signed in to change notification settings - Fork 80
feat: ec mul chip #2304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: ec mul chip #2304
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces an EC (Elliptic Curve) multiplication chip to accelerate elliptic curve scalar multiplication operations. The implementation replaces manual IntrinsicCurve trait implementations with a declarative curve_declare! macro that generates the necessary boilerplate code. The PR adds hardware acceleration for EC multiplication while maintaining backward compatibility through a heuristic fallback for small operations.
Key Changes:
- Introduces
openvm-ecc-curve-macroscrate withcurve_declare!andcurve_init!macros - Adds EC multiplication adapter, AIR, and circuit implementations
- Updates
IntrinsicCurve::msmsignature to includeCHECK_SETUPconst generic parameter - Adds
curve_namefield to all curve configurations across the codebase
Reviewed changes
Copilot reviewed 48 out of 49 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/ecc/curve-macros/src/lib.rs | New proc macro crate implementing curve_declare! and curve_init! macros for code generation |
| extensions/rv32-adapters/src/ec_mul.rs | New adapter for EC multiplication with memory operations and register handling |
| extensions/ecc/circuit/src/weierstrass_chip/mul/* | EC multiplication chip implementation with execution logic and AIR constraints |
| extensions/ecc/circuit/src/weierstrass_chip/curves.rs | Native EC multiplication implementations for K256, P256, BN254, and BLS12_381 curves |
| extensions/ecc/guest/src/weierstrass.rs | Updated IntrinsicCurve trait with CHECK_SETUP parameter and set_up_once method |
| guest-libs/{p256,k256,pairing}/src/*.rs | Replaced manual IntrinsicCurve implementations with curve_declare! macro usage |
| extensions/ecc/circuit/src/extension/weierstrass.rs | Added EC mul executor, AIR, and chip integration for both 32 and 48 limb primes |
| crates/vm/src/arch/integration_api.rs | Added Rv32EcMulAdapterInterface and conversions for different-sized tuple arrays |
| **/openvm.toml | Added curve_name field to all curve configurations |
| extensions/ecc/transpiler/src/lib.rs | Added EC_MUL and SETUP_EC_MUL opcodes to the transpiler |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// from the ELF and used by the VM. Usage: | ||
| /// ``` | ||
| /// curve_declare! { | ||
| /// [TODO] |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation comment at line 14-16 contains a TODO placeholder that should be replaced with an actual usage example showing how to use the curve_declare! macro with the point_type and scalar_type parameters.
| /// [TODO] | |
| /// MyCurve { | |
| /// point_type: my_crate::Point, | |
| /// scalar_type: my_crate::Scalar, | |
| /// } |
| # bls12_381 | ||
| "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787", # coordinate | ||
| "52435875175126190479447740508185965837690552500527637822603658699938581184513", # scalar | ||
| "52435875175126190479447740508185965837690552500527637822603658699938581184513", # scalar |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent formatting: this line has excessive spacing (multiple spaces) before the # scalar comment, while other similar lines use a single space. Should maintain consistent spacing with surrounding lines.
| "52435875175126190479447740508185965837690552500527637822603658699938581184513", # scalar | |
| "52435875175126190479447740508185965837690552500527637822603658699938581184513", # scalar |
WIP
Resolves INT-5099