public static function verify(
        string $message,
        SignaturePublicKey $publicKey,
        string $signature,
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): bool {
        $decoder = Halite::chooseEncoder($encoding, true);
        if ($decoder) {
            // We were given hex data:
            /** @var string $signature */
            $signature = $decoder($signature);
        }
        if (Binary::safeStrlen($signature) !== SODIUM_CRYPTO_SIGN_BYTES) {
            // @codeCoverageIgnoreStart
            throw new InvalidSignature(
                'Signature is not the correct length; is it encoded?'
            );
            // @codeCoverageIgnoreEnd
        }
        
        return (bool) \sodium_crypto_sign_verify_detached(
            $signature,
            $message,
            $publicKey->getRawKeyMaterial()
        );
    }