contents()); if ($actualKeyLength < self::MINIMUM_KEY_LENGTH_IN_BITS) { throw InvalidKeyProvided::tooShort(self::MINIMUM_KEY_LENGTH_IN_BITS, $actualKeyLength); } return sodium_crypto_generichash($payload, $key->contents()); } public function verify(string $expected, string $payload, Key $key): bool { return hash_equals($expected, $this->sign($payload, $key)); } }