def get_eckey_type(key_pem):
  """ get EC key type public or private from PEM format key

      return "public", "private", or 'invalid'

  :param key_pem: EC key in PEM format

  """
  with open(key_pem, 'rt') as f:
    key=f.read()
  if 'PUBLIC'  in key: return 'public'
  elif 'PRIVATE' in key: return 'private'
  else: return 'invalid'