code: func isPubKey(script []byte) (bool, []byte) {
  	// Pay-to-compressed-pubkey script.
  	if len(script) == 35 && script[0] == txscript.OP_DATA_33 &&
  		script[34] == txscript.OP_CHECKSIG && (script[1] == 0x02 ||
  		script[1] == 0x03) {
  
  		// Ensure the public key is valid.
  		serializedPubKey := script[1:34]
  		_, err := btcec.ParsePubKey(serializedPubKey, btcec.S256())
  		if err == nil {
  			return true, serializedPubKey
  		}
  	}
  
  	// Pay-to-uncompressed-pubkey script.
  	if len(script) == 67 && script[0] == txscript.OP_DATA_65 &&
  		script[66] == txscript.OP_CHECKSIG && script[1] == 0x04 {
  
  		// Ensure the public key is valid.
  		serializedPubKey := script[1:66]
  		_, err := btcec.ParsePubKey(serializedPubKey, btcec.S256())
  		if err == nil {
  			return true, serializedPubKey
  		}
  	}
  
  	return false, nil
  }
docs: // isPubKey returns whether or not the passed public key script is a standard
  // pay-to-pubkey script that pays to a valid compressed or uncompressed public
  // key along with the serialized pubkey it is paying to if it is.
  //
  // NOTE: This function ensures the public key is actually valid since the
  // compression algorithm requires valid pubkeys.  It does not support hybrid
  // pubkeys.  This means that even if the script has the correct form for a
  // pay-to-pubkey script, this function will only return true when it is paying
  // to a valid compressed or uncompressed pubkey.