foundry_evm_core/
precompiles.rsuse alloy_primitives::{address, Address, Bytes, B256};
use revm::{
precompile::{secp256r1::p256_verify as revm_p256_verify, PrecompileWithAddress},
primitives::{Precompile, PrecompileResult},
};
pub const EC_RECOVER: Address = address!("0000000000000000000000000000000000000001");
pub const SHA_256: Address = address!("0000000000000000000000000000000000000002");
pub const RIPEMD_160: Address = address!("0000000000000000000000000000000000000003");
pub const IDENTITY: Address = address!("0000000000000000000000000000000000000004");
pub const MOD_EXP: Address = address!("0000000000000000000000000000000000000005");
pub const EC_ADD: Address = address!("0000000000000000000000000000000000000006");
pub const EC_MUL: Address = address!("0000000000000000000000000000000000000007");
pub const EC_PAIRING: Address = address!("0000000000000000000000000000000000000008");
pub const BLAKE_2F: Address = address!("0000000000000000000000000000000000000009");
pub const POINT_EVALUATION: Address = address!("000000000000000000000000000000000000000a");
pub const PRECOMPILES: &[Address] = &[
EC_RECOVER,
SHA_256,
RIPEMD_160,
IDENTITY,
MOD_EXP,
EC_ADD,
EC_MUL,
EC_PAIRING,
BLAKE_2F,
POINT_EVALUATION,
ALPHANET_P256_ADDRESS,
];
pub const ALPHANET_P256_ADDRESS: Address = address!("0000000000000000000000000000000000000014");
pub fn p256_verify(input: &Bytes, gas_limit: u64) -> PrecompileResult {
revm_p256_verify(input, gas_limit).map(|mut result| {
if result.bytes.is_empty() {
result.bytes = B256::default().into();
}
result
})
}
pub const ALPHANET_P256: PrecompileWithAddress =
PrecompileWithAddress(ALPHANET_P256_ADDRESS, Precompile::Standard(p256_verify));