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()
        );
    }
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()
        );
    }
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 ( ) ) ; }
Verify a signed message with the correct public key

@param string $message               Message to verify
@param SignaturePublicKey $publicKey Public key
@param string $signature             Signature
@param mixed $encoding               Which encoding scheme to use?
@return bool

@throws InvalidSignature
@throws InvalidType
@throws \TypeError
Verify a signed message with the correct public key