| 143 | } |
| 144 | |
| 145 | bool static IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) { |
| 146 | if (vchPubKey.size() < CPubKey::COMPRESSED_SIZE) { |
| 147 | // Non-canonical public key: too short |
| 148 | return false; |
| 149 | } |
| 150 | if (vchPubKey[0] == 0x04) { |
| 151 | if (vchPubKey.size() != CPubKey::SIZE) { |
| 152 | // Non-canonical public key: invalid length for uncompressed key |
| 153 | return false; |
| 154 | } |
| 155 | } else if (vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03) { |
| 156 | if (vchPubKey.size() != CPubKey::COMPRESSED_SIZE) { |
| 157 | // Non-canonical public key: invalid length for compressed key |
| 158 | return false; |
| 159 | } |
| 160 | } else { |
| 161 | // Non-canonical public key: neither compressed nor uncompressed |
| 162 | return false; |
| 163 | } |
| 164 | return true; |
| 165 | } |
| 166 | |
| 167 | bool static IsCompressedPubKey(const valtype &vchPubKey) { |
| 168 | if (vchPubKey.size() != CPubKey::COMPRESSED_SIZE) { |
no test coverage detected