public static function export($key) : HiddenString
{
if ($key instanceof KeyPair) {
return self::export($key->getSecretKey());
}
if ($key instanceof Key) {
return new HiddenString(\Sodium\bin2hex(Halite::HALITE_VERSION_KEYS . $key->getRawKeyMaterial() . \Sodium\crypto_generichash(Halite::HALITE_VERSION_KEYS . $key->getRawKeyMaterial(), '', \Sodium\CRYPTO_GENERICHASH_BYTES_MAX)));
}
throw new \TypeError('Expected a Key.');
}