Skip to content

Commit

Permalink
perf(precompile): use secp256k1 global context for ecrecover (blueall…
Browse files Browse the repository at this point in the history
…oy#1843)

* perf(precompile): use secp256k1 global context for ecrecover

* remove secp var
  • Loading branch information
Rjected authored Nov 4, 2024
1 parent 51d50f6 commit bbc8d81
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/precompile/src/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down

0 comments on commit bbc8d81

Please sign in to comment.