From bbc8d81dbe2a6a4d184e32fa540e1c4e248a65c9 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Mon, 4 Nov 2024 04:56:23 -0500 Subject: [PATCH] perf(precompile): use secp256k1 global context for ecrecover (#1843) * perf(precompile): use secp256k1 global context for ecrecover * remove secp var --- crates/precompile/src/secp256k1.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/precompile/src/secp256k1.rs b/crates/precompile/src/secp256k1.rs index 72b5c602de..864b43eaf3 100644 --- a/crates/precompile/src/secp256k1.rs +++ b/crates/precompile/src/secp256k1.rs @@ -49,7 +49,7 @@ mod secp256k1 { use primitives::{alloy_primitives::B512, keccak256, B256}; use secp256k1::{ ecdsa::{RecoverableSignature, RecoveryId}, - Message, Secp256k1, + Message, SECP256K1, }; // Silence the unused crate dependency warning. @@ -59,9 +59,8 @@ mod secp256k1 { let recid = RecoveryId::from_i32(recid as i32).expect("recovery ID is valid"); let sig = RecoverableSignature::from_compact(sig.as_slice(), recid)?; - let secp = Secp256k1::new(); let msg = Message::from_digest(msg.0); - let public = secp.recover_ecdsa(&msg, &sig)?; + let public = SECP256K1.recover_ecdsa(&msg, &sig)?; let mut hash = keccak256(&public.serialize_uncompressed()[1..]); hash[..12].fill(0);