| 61 | } |
| 62 | |
| 63 | bool static IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) { |
| 64 | if (vchPubKey.size() < CPubKey::COMPRESSED_PUBLIC_KEY_SIZE) { |
| 65 | // Non-canonical public key: too short |
| 66 | return false; |
| 67 | } |
| 68 | if (vchPubKey[0] == 0x04) { |
| 69 | if (vchPubKey.size() != CPubKey::PUBLIC_KEY_SIZE) { |
| 70 | // Non-canonical public key: invalid length for uncompressed key |
| 71 | return false; |
| 72 | } |
| 73 | } else if (vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03) { |
| 74 | if (vchPubKey.size() != CPubKey::COMPRESSED_PUBLIC_KEY_SIZE) { |
| 75 | // Non-canonical public key: invalid length for compressed key |
| 76 | return false; |
| 77 | } |
| 78 | } else { |
| 79 | // Non-canonical public key: neither compressed nor uncompressed |
| 80 | return false; |
| 81 | } |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | bool static IsCompressedPubKey(const valtype &vchPubKey) { |
| 86 | if (vchPubKey.size() != CPubKey::COMPRESSED_PUBLIC_KEY_SIZE) { |
no test coverage detected