From 4e4c2d987b1ad8fd5a43196e85ba7540ddae1efb Mon Sep 17 00:00:00 2001 From: zktony Date: Fri, 16 Feb 2024 09:23:40 +0530 Subject: [PATCH] Fixed key --- pallets/thea/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pallets/thea/src/lib.rs b/pallets/thea/src/lib.rs index 0eaa4e929..09619087e 100644 --- a/pallets/thea/src/lib.rs +++ b/pallets/thea/src/lib.rs @@ -771,6 +771,16 @@ impl Pallet { if let Ok(compressed_key) = libsecp256k1::PublicKey::parse_compressed(&public_key.0) { let uncompressed_key = compressed_key.serialize(); + let uncompressed_key: [u8; 64] = + if let Ok(uncompressed_key) = uncompressed_key[1..65].try_into() { + uncompressed_key + } else { + log::error!(target: "thea", "Unable to slice last 64 bytes of uncompressed_key for Evm"); + Self::deposit_event(Event::::UnableToSlicePublicKeyHash( + public_key.into(), + )); + return; + }; let hash: [u8; 32] = sp_io::hashing::keccak_256(&uncompressed_key); if let Ok(address) = hash[12..32].try_into() { uncompressed_keys.push(address);