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