In ink! 4.0 ink::env
crate, it provides ecdsa_recover
function.
It returns compressed public key &[u8, 33]
as is explained here.
Assumed that blake2
is used for hashing.
#[ink(message)]
pub fn verify(&self, req: ForwardRequest, signature: [u8; 65]) -> bool {
let mut message_hash = <ink::env::hash::Blake2x256 as ink::env::hash::HashOutput>::Type::default();
ink::env::hash_encoded::<ink::env::hash::Blake2x256, _>(&req, &mut message_hash);
let output = self.env().ecdsa_recover(&signature, &message_hash).expect("Failed to recover");
let signature_account_id = // How to get AccountId from compressed public key?
todo!();
}
(Above code before todo!() is not confirmed to work)
How can I recover AccountId
from compressed public key?