public function decrypt($cypherText) {
    $envelope = json_decode(base64_decode($cypherText));

    if (!is_object($envelope) || empty($envelope->key) || empty($envelope->message)) {
      throw new EncryptionException('Encrypted message is not understood');
    }

    $key = base64_decode($envelope->key);
    $message = base64_decode($envelope->message);

    $decrypted = '';
    $result = openssl_open($message, $decrypted, $key, $this->getPublicKey());

    if ($result === FALSE) {
      throw new EncryptionException('Unable to decrypt a message: ' . openssl_error_string());
    }

    return json_decode($decrypted);
  }