extract ecdsa_get_pubkeyhash

pull/25/head
Pavol Rusnak 10 years ago
parent d5e1ff8be8
commit b5ceb14f8d

@ -333,6 +333,17 @@ void ecdsa_get_public_key65(const uint8_t *priv_key, uint8_t *pub_key)
bn_write_be(&R.y, pub_key + 33);
}
void ecdsa_get_pubkeyhash(const uint8_t *pub_key, uint8_t *pubkeyhash)
{
uint8_t h[32];
if (pub_key[0] == 0x04) {
sha256_Raw(pub_key, 65, h);
} else {
sha256_Raw(pub_key, 33, h);
}
ripemd160(h, 32, pubkeyhash);
}
void ecdsa_get_address(const uint8_t *pub_key, uint8_t version, char *addr)
{
const char code[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@ -342,13 +353,8 @@ void ecdsa_get_address(const uint8_t *pub_key, uint8_t version, char *addr)
bignum256 c;
int i, l;
if (pub_key[0] == 0x04) {
sha256_Raw(pub_key, 65, a);
} else {
sha256_Raw(pub_key, 33, a);
}
b[0] = version;
ripemd160(a, 32, b + 1);
ecdsa_get_pubkeyhash(pub_key, b + 1);
sha256_Raw(b, 21, a);
sha256_Raw(a, 32, a);

@ -43,6 +43,7 @@ int ecdsa_sign_double(const uint8_t *priv_key, const uint8_t *msg, uint32_t msg_
int ecdsa_sign_digest(const uint8_t *priv_key, const uint8_t *digest, uint8_t *sig);
void ecdsa_get_public_key33(const uint8_t *priv_key, uint8_t *pub_key);
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_address(const uint8_t *pub_key, uint8_t version, char *addr);
int ecdsa_address_decode(const char *addr, uint8_t *out);
int ecdsa_read_pubkey(const uint8_t *pub_key, curve_point *pub);

Loading…
Cancel
Save