mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-06 07:34:21 +01:00
bitcoin/pubkey: add pubkey_from_secret.
Really, we should have a 'struct point' since we don't use all points as pubkeys. But this is the minimal fix to avoid type cast nastiness. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
9dd0415a15
commit
289e39a0a3
@@ -28,14 +28,18 @@ void pubkey_to_der(u8 der[PUBKEY_DER_LEN], const struct pubkey *key)
|
||||
assert(outlen == PUBKEY_DER_LEN);
|
||||
}
|
||||
|
||||
/* Pubkey from privkey */
|
||||
bool pubkey_from_secret(const struct secret *secret, struct pubkey *key)
|
||||
{
|
||||
if (!secp256k1_ec_pubkey_create(secp256k1_ctx,
|
||||
&key->pubkey, secret->data))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pubkey_from_privkey(const struct privkey *privkey,
|
||||
struct pubkey *key)
|
||||
{
|
||||
if (!secp256k1_ec_pubkey_create(secp256k1_ctx,
|
||||
&key->pubkey, privkey->secret.data))
|
||||
return false;
|
||||
return true;
|
||||
return pubkey_from_secret(&privkey->secret, key);
|
||||
}
|
||||
|
||||
bool pubkey_from_hexstr(const char *derstr, size_t slen, struct pubkey *key)
|
||||
|
||||
Reference in New Issue
Block a user