[package]
name = "revm-precompile"
description = "Revm Precompiles - Ethereum compatible precompiled contracts"
version = "36.0.1"
authors.workspace = true
edition.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true
rust-version.workspace = true

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints]
workspace = true

[dependencies]
# revm
primitives.workspace = true
context-interface.workspace = true

# modexp precompiles
aurora-engine-modexp.workspace = true
# gmp ffi
gmp-mpfr-sys = { workspace = true, default-features = false, optional = true }

# ecRecover
k256 = { workspace = true, features = ["ecdsa"] }
secp256k1 = { workspace = true, features = [
	"alloc",
	"recovery",
	"rand",
	"global-context",
], optional = true }

# SHA2-256 and RIPEMD-160
sha2.workspace = true
ripemd.workspace = true

# Optionally use substrate implementation for eip1962
bn = { workspace = true, optional = true }

# Use arkworks implementation for eip1962
ark-bn254 = { workspace = true, features = ["curve"] }
ark-ec = { workspace = true }
ark-ff = { workspace = true, features = ["asm"] }
ark-serialize = { workspace = true }

# KZG point evaluation precompile
c-kzg = { workspace = true, optional = true, features = [
	"ethereum_kzg_settings",
] }


# Use the BLS12-381 implementation of blst for EIP2537
blst = { workspace = true, optional = true }

# Use the BLS12-381 implementation of arkworks for EIP2537
ark-bls12-381 = { workspace = true, features = ["curve"] }

# p256verify precompile
p256 = { workspace = true, features = ["ecdsa"] }
aws-lc-rs = { workspace = true, optional = true }

# utils
cfg-if.workspace = true
arrayref = "0.3.6"

[dev-dependencies]
criterion.workspace = true
rand = { workspace = true, features = ["std"] }
ark-std = { workspace = true }
rstest.workspace = true
p256 = { workspace = true, features = ["ecdsa"] }

[features]
default = ["std", "secp256k1", "blst", "c-kzg", "portable"]

std = [
	"primitives/std",
	"context-interface/std",
	"k256/std",
	"ripemd/std",
	"sha2/std",
	"c-kzg?/std",
	"secp256k1?/std",
	"ark-bn254/std",
	"ark-bls12-381/std",
	"aurora-engine-modexp/std",
	"ark-ec/std",
	"ark-ff/std",
	"ark-serialize/std",
	"ark-std/std",
	"p256/std",
]
hashbrown = ["primitives/hashbrown"]
asm-keccak = ["primitives/asm-keccak"]
asm-sha2 = ["sha2/asm"]


# Enables the c-kzg point evaluation precompile. Enabled by default as most stable/used implementation.
c-kzg = ["dep:c-kzg"]

# Compile in portable mode, without ISA extensions.
# Binary can be executed on all systems.
portable = ["c-kzg?/portable", "blst?/portable"]

# Use `secp256k1` as a faster alternative to `k256`.
# The problem that `secp256k1` has is it fails to build for `wasm` target on Windows and Mac as it is c lib.
# In Linux it passes. If you don't require to build wasm on win/mac, it is safe to use it and it is enabled by default.
secp256k1 = ["dep:secp256k1"]

# Enables the blst implementation of the BLS12-381 precompile.
blst = ["dep:blst"]

# Enables the substrate implementation of eip1962
bn = ["dep:bn"]

# Use GMP for accelerated modexp precompile. Dynamically links to libgmp at runtime.
gmp = ["dep:gmp-mpfr-sys"]

# Use aws-lc-rs as a faster alternative to `p256` for secp256r1 signature verification.
p256-aws-lc-rs = ["dep:aws-lc-rs"]

[[bench]]
name = "bench"
path = "bench/main.rs"
harness = false
required-features = ["secp256k1"]
