MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / IsCompressedOrUncompressedPubKey

Function IsCompressedOrUncompressedPubKey

src/script/interpreter.cpp:63–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63bool 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
85bool static IsCompressedPubKey(const valtype &vchPubKey) {
86 if (vchPubKey.size() != CPubKey::COMPRESSED_PUBLIC_KEY_SIZE) {

Callers 1

CheckPubKeyEncodingFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected