1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-30 09:11:07 +00:00

Hashing of secp256k1 pubkey recognizes point at infinity.

This commit is contained in:
Ondrej Mikle 2014-07-01 16:16:06 +02:00
parent e588906f81
commit 0ad302ea4e

View File

@ -338,10 +338,12 @@ void ecdsa_get_public_key65(const uint8_t *priv_key, uint8_t *pub_key)
void ecdsa_get_pubkeyhash(const uint8_t *pub_key, uint8_t *pubkeyhash) void ecdsa_get_pubkeyhash(const uint8_t *pub_key, uint8_t *pubkeyhash)
{ {
uint8_t h[32]; uint8_t h[32];
if (pub_key[0] == 0x04) { if (pub_key[0] == 0x04) { // uncompressed format
sha256_Raw(pub_key, 65, h); sha256_Raw(pub_key, 65, h);
} else if (pub_key[0] == 0x00) { // point at infinity
sha256_Raw(pub_key, 1, h);
} else { } else {
sha256_Raw(pub_key, 33, h); sha256_Raw(pub_key, 33, h); // expecting compressed format
} }
ripemd160(h, 32, pubkeyhash); ripemd160(h, 32, pubkeyhash);
} }