| 64 | } |
| 65 | |
| 66 | bool static IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) { |
| 67 | if (vchPubKey.size() < 33) { |
| 68 | // Non-canonical public key: too short |
| 69 | return false; |
| 70 | } |
| 71 | if (vchPubKey[0] == 0x04) { |
| 72 | if (vchPubKey.size() != 65) { |
| 73 | // Non-canonical public key: invalid length for uncompressed key |
| 74 | return false; |
| 75 | } |
| 76 | } else if (vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03) { |
| 77 | if (vchPubKey.size() != 33) { |
| 78 | // Non-canonical public key: invalid length for compressed key |
| 79 | return false; |
| 80 | } |
| 81 | } else { |
| 82 | // Non-canonical public key: neither compressed nor uncompressed |
| 83 | return false; |
| 84 | } |
| 85 | return true; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * A canonical signature exists of: <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype> |
no test coverage detected