Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions crates/vm/levm/src/precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,11 @@ pub fn bn254_g1_mul(g1: G1, scalar: U256) -> Result<Bytes, VMError> {
Fq::from_slice(&g1.1.to_big_endian()).map_err(|_| PrecompileError::ParsingInputError)?,
);

let g1: G1 = AffineG1::new(g1_x, g1_y)
.map_err(|_| PrecompileError::InvalidPoint)?
.into();
let g1 = AffineG1::new(g1_x, g1_y).map_err(|_| PrecompileError::InvalidPoint)?;

// Small difference between the patched versions of substrate-bn
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should explain WHY this conditional conversion is needed and what the actual difference is between the SP1 and ZisK substrate-bn patches. Consider expanding it to something like:

// SP1's substrate-bn patch implements multiplication for AffineG1 * Fr differently
// than ZisK's patch. For ZisK, we need to convert to G1 first, while SP1 requires
// AffineG1 to avoid gas mismatch issues (e.g., block 23919500 from Mainnet).

This would help future maintainers understand the reasoning behind this platform-specific behavior.

Suggested change
// Small difference between the patched versions of substrate-bn
// SP1's substrate-bn patch implements multiplication for AffineG1 * Fr differently
// than ZisK's patch. For ZisK, we need to convert to G1 first, while SP1 requires
// AffineG1 to avoid gas mismatch issues (e.g., block 23919500 from Mainnet).

Copilot uses AI. Check for mistakes.
#[cfg(feature = "zisk")]
let g1: G1 = g1.into();

let scalar =
Fr::from_slice(&scalar.to_big_endian()).map_err(|_| PrecompileError::ParsingInputError)?;
Expand Down