Function ink_env::ecdsa_to_eth_address
source · pub fn ecdsa_to_eth_address(
pubkey: &[u8; 33],
output: &mut [u8; 20],
) -> Result<()>
Expand description
Returns an Ethereum address from the ECDSA compressed public key.
§Example
let pub_key = [
3, 110, 192, 35, 209, 24, 189, 55, 218, 250, 100, 89, 40, 76, 222, 208, 202, 127,
31, 13, 58, 51, 242, 179, 13, 63, 19, 22, 252, 164, 226, 248, 98,
];
let EXPECTED_ETH_ADDRESS = [
253, 240, 181, 194, 143, 66, 163, 109, 18, 211, 78, 49, 177, 94, 159, 79, 207,
37, 21, 191,
];
let mut output = [0; 20];
ink_env::ecdsa_to_eth_address(&pub_key, &mut output);
assert_eq!(output, EXPECTED_ETH_ADDRESS);
§Errors
- If the ECDSA public key cannot be recovered from the provided public key.