1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

Merge pull request #6 from hiviah/point_at_infinity

Hashing of secp256k1 pubkey recognizes point at infinity.
This commit is contained in:
Pavol Rusnak 2014-07-01 17:13:53 +02:00
commit 3308cc62a6

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)
{
uint8_t h[32];
if (pub_key[0] == 0x04) {
if (pub_key[0] == 0x04) { // uncompressed format
sha256_Raw(pub_key, 65, h);
} else if (pub_key[0] == 0x00) { // point at infinity
sha256_Raw(pub_key, 1, h);
} else {
sha256_Raw(pub_key, 33, h);
sha256_Raw(pub_key, 33, h); // expecting compressed format
}
ripemd160(h, 32, pubkeyhash);
}