PR12460 backport https://github.com/bitcoin/bitcoin/pull/12460/files
f8c249ab91 Assert CPubKey::ValidLength to the pubkey's header-relevent size (Ben Woosley)
Pull request description:
A pubkey's length is specific to its type which is indicated by its header value. GetLen returns the header-indicated length, so this change ensures that a key matches its header-indicated length. And replace some magic values with their constant equivalents.
Backporter note: the changes to IsCompressedOrUncompressedPubKey and
IsCompressedPubKey needed to be massaged somewhat (due to D1569)