diff options
Diffstat (limited to 'vendor/github.com/btcsuite/btcd/btcec/pubkey.go')
-rw-r--r-- | vendor/github.com/btcsuite/btcd/btcec/pubkey.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/vendor/github.com/btcsuite/btcd/btcec/pubkey.go b/vendor/github.com/btcsuite/btcd/btcec/pubkey.go index f145414ec..b74917718 100644 --- a/vendor/github.com/btcsuite/btcd/btcec/pubkey.go +++ b/vendor/github.com/btcsuite/btcd/btcec/pubkey.go @@ -54,6 +54,15 @@ const ( pubkeyHybrid byte = 0x6 // y_bit + x coord + y coord ) +// IsCompressedPubKey returns true the the passed serialized public key has +// been encoded in compressed format, and false otherwise. +func IsCompressedPubKey(pubKey []byte) bool { + // The public key is only compressed if it is the correct length and + // the format (first byte) is one of the compressed pubkey values. + return len(pubKey) == PubKeyBytesLenCompressed && + (pubKey[0]&^byte(0x1) == pubkeyCompressed) +} + // ParsePubKey parses a public key for a koblitz curve from a bytestring into a // ecdsa.Publickey, verifying that it is valid. It supports compressed, // uncompressed and hybrid signature formats. |