pubkey: introduce a GetEvenCorrespondingCPubKey helper

We'll need to get a compressed key out of an x-only one in other places.
Avoid duplicating the code.
This commit is contained in:
Antoine Poinsot
2023-02-14 10:31:32 +01:00
parent ce8845f5dd
commit fcb6f13f44
3 changed files with 10 additions and 3 deletions

View File

@@ -204,6 +204,13 @@ std::vector<CKeyID> XOnlyPubKey::GetKeyIDs() const
return out;
}
CPubKey XOnlyPubKey::GetEvenCorrespondingCPubKey() const
{
unsigned char full_key[CPubKey::COMPRESSED_SIZE] = {0x02};
std::copy(begin(), end(), full_key + 1);
return CPubKey{full_key};
}
bool XOnlyPubKey::IsFullyValid() const
{
secp256k1_xonly_pubkey pubkey;