diff options
author | Pieter Wuille <pieter@wuille.net> | 2023-10-04 10:56:52 -0400 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2023-10-04 11:28:13 -0400 |
commit | c1e6c542af6d89a499e2a65465865aec651c4d67 (patch) | |
tree | ccd9db4d6ea1b8f12f7fc9a47c56e84249c50ba4 /src/pubkey.h | |
parent | db7b5dfcc502a8a81c51f56fe753990ae8b3a202 (diff) | |
download | bitcoin-c1e6c542af6d89a499e2a65465865aec651c4d67.tar.xz |
descriptors: disallow hybrid public keys
The descriptor documentation (doc/descriptors.md) and BIP380 explicitly
require that hex-encoded public keys start with 02 or 03 (compressed) or
04 (uncompressed). However, the current parsing/inference code permit 06
and 07 (hybrid) encoding as well. Fix this.
Diffstat (limited to 'src/pubkey.h')
-rw-r--r-- | src/pubkey.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pubkey.h b/src/pubkey.h index 274779f9a4..4b34fd829b 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -191,6 +191,12 @@ public: return size() > 0; } + /** Check if a public key is a syntactically valid compressed or uncompressed key. */ + bool IsValidNonHybrid() const noexcept + { + return size() > 0 && (vch[0] == 0x02 || vch[0] == 0x03 || vch[0] == 0x04); + } + //! fully validate whether this is a valid public key (more expensive than IsValid()) bool IsFullyValid() const; |