In #28246 and #28122 , we add a PubKeyDestination
and a V0SilentPaymentsDestination
. Both of these PRs update fuzz/util.cpp
and need a way to create well-formed pubkeys. Currently in fuzz/util.cpp
, we have some logic for creating pubkeys in the multisig data provider. This logic is duplicated in #28246 and duplicated again in #28122. Seems much better to have a ConstructPubKeyBytes
function that both PRs (and any future work) can reuse.
This PR introduces a function to do this and has the existing code use it. While the purpose is to introduce a utility function, the previous multisig code used ConsumeIntegralInRange(4, 7)
which would have created some uncompressed pubkeys with the prefix 0x05, which is incorrect (see https://bitcoin.stackexchange.com/questions/57855/c-secp256k1-what-do-prefixes-0x06-and-0x07-in-an-uncompressed-public-key-signif)
tldr; using PickValueFromArray
is more correct as it limits to the set of defined prefixes for compressed and uncompressed pubkeys.