mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: use buffered ancestor to determine sync target (#2802)
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
@ -113,7 +113,7 @@ impl Signature {
|
||||
})
|
||||
}
|
||||
|
||||
/// Recover signature from hash.
|
||||
/// Recover signer address from message hash.
|
||||
pub fn recover_signer(&self, hash: H256) -> Option<Address> {
|
||||
let mut sig: [u8; 65] = [0; 65];
|
||||
|
||||
|
||||
@ -10,12 +10,17 @@ pub(crate) mod secp256k1 {
|
||||
};
|
||||
use revm_primitives::{B256, U256};
|
||||
|
||||
/// secp256k1 signer recovery
|
||||
/// Recovers the address of the sender using secp256k1 pubkey recovery.
|
||||
///
|
||||
/// Converts the public key into an ethereum address by hashing the public key with keccak256.
|
||||
pub fn recover_signer(sig: &[u8; 65], msg: &[u8; 32]) -> Result<Address, Error> {
|
||||
let sig =
|
||||
RecoverableSignature::from_compact(&sig[0..64], RecoveryId::from_i32(sig[64] as i32)?)?;
|
||||
|
||||
let public = SECP256K1.recover_ecdsa(&Message::from_slice(&msg[..32])?, &sig)?;
|
||||
|
||||
// strip out the first byte because that should be the SECP256K1_TAG_PUBKEY_UNCOMPRESSED
|
||||
// tag returned by libsecp's uncompressed pubkey serialization
|
||||
let hash = keccak256(&public.serialize_uncompressed()[1..]);
|
||||
Ok(Address::from_slice(&hash[12..]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user