Function ink_env::ecdsa_recover
source · pub fn ecdsa_recover(
signature: &[u8; 65],
message_hash: &[u8; 32],
output: &mut [u8; 33],
) -> Result<()>
Expand description
Recovers the compressed ECDSA public key for given signature
and message_hash
,
and stores the result in output
.
§Example
const signature: [u8; 65] = [
195, 218, 227, 165, 226, 17, 25, 160, 37, 92, 142, 238, 4, 41, 244, 211, 18, 94,
131, 116, 231, 116, 255, 164, 252, 248, 85, 233, 173, 225, 26, 185, 119, 235,
137, 35, 204, 251, 134, 131, 186, 215, 76, 112, 17, 192, 114, 243, 102, 166, 176,
140, 180, 124, 213, 102, 117, 212, 89, 89, 92, 209, 116, 17, 28,
];
const message_hash: [u8; 32] = [
167, 124, 116, 195, 220, 156, 244, 20, 243, 69, 1, 98, 189, 205, 79, 108, 213,
78, 65, 65, 230, 30, 17, 37, 184, 220, 237, 135, 1, 209, 101, 229,
];
const EXPECTED_COMPRESSED_PUBLIC_KEY: [u8; 33] = [
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 mut output = [0; 33];
ink_env::ecdsa_recover(&signature, &message_hash, &mut output);
assert_eq!(output, EXPECTED_COMPRESSED_PUBLIC_KEY);