refactor: create crypto submodules for each precompile#3529
Open
jdh847 wants to merge 4 commits intobluealloy:mainfrom
Open
refactor: create crypto submodules for each precompile#3529jdh847 wants to merge 4 commits intobluealloy:mainfrom
jdh847 wants to merge 4 commits intobluealloy:mainfrom
Conversation
added 4 commits
March 29, 2026 11:17
Move `ecrecover_bytes` and the backend selection (`cfg_if!` for k256 vs bitcoin_secp256k1) into a dedicated `crypto.rs` submodule, separating pure cryptographic logic from the precompile runner. Closes part of bluealloy#2782
Move `verify_signature` and its feature-gated implementations (p256 vs aws-lc-rs) into a dedicated `crypto.rs` submodule, separating pure cryptographic logic from the precompile runner. Closes part of bluealloy#2782
Move the BLAKE2b compression algorithm (`algo` module with SIGMA, IV, G function, compress, round) and the AVX2 optimized variant into a dedicated `crypto.rs` submodule, separating pure cryptographic logic from the precompile runner. Closes part of bluealloy#2782
Move the `modexp` function (both GMP and aurora-engine-modexp fallback implementations) into a dedicated `crypto.rs` submodule, separating pure cryptographic logic from the precompile runner and gas calculation code. Closes bluealloy#2782
e283fa6 to
dfb5425
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2782
Creates a dedicated
crypto.rssubmodule for each precompile that has mixed runner + cryptographic code, isolating pure cryptographic implementations from EVM-specific precompile logic (gas accounting, input parsing, output formatting).Changes per precompile:
ecrecover_bytesandcfg_if!backend selection (k256 vs bitcoin_secp256k1) intosecp256k1/crypto.rsverify_signatureand feature-gated implementations (p256 vs aws-lc-rs) intosecp256r1/crypto.rsalgomodule (SIGMA, IV, G function, compress, round) and AVX2 optimized variant intoblake2/crypto.rsmodexpfunction (GMP + aurora-engine-modexp fallback) intomodexp/crypto.rsNot changed (already separated):
arkworks.rs/substrate.rsascrypto_backendarkworks.rs/blst.rsascrypto_backendarkworks.rs/blst.rsascrypto_backendCryptotrait default implementations (thin wrappers aroundsha2/ripemdcrates)Design decisions:
crate::secp256k1::ecrecover_bytes) still work via re-exportsCryptotrait ininterface.rsunchanged — default implementations still delegate to the same functionspub use crypto::algoin blake2 preserves theblake2::algo::compresspathTest plan
cargo check -p revm-precompile— compiles cleancargo clippy -p revm-precompile --all-targets --all-features— no warningscargo test -p revm-precompile— 52 tests pass, 0 failures