/**
  * @param $hex
  * @return PublicKey
  * @throws \Exception
  */
 public function parse($hex)
 {
     $hex = Buffer::hex($hex);
     if (!in_array($hex->getSize(), [PublicKey::LENGTH_COMPRESSED, PublicKey::LENGTH_UNCOMPRESSED])) {
         throw new \Exception('Invalid hex string, must match size of compressed or uncompressed public key');
     }
     return $this->ecAdapter->publicKeyFromBuffer($hex);
 }