MCPcopy Create free account
hub / github.com/LUX-Core/lux / IsCompressedOrUncompressedPubKey

Function IsCompressedOrUncompressedPubKey

src/script/interpreter.cpp:69–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69bool 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
91bool static IsCompressedPubKey(const valtype &vchPubKey) {
92 if (vchPubKey.size() != 33) {

Callers 1

CheckPubKeyEncodingFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected