public function isSignatureValid(string $response, string $signature, string $publicKey) : bool
    {
        if (\strlen($publicKey) !== SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES) {
            throw new InvalidArgumentException(sprintf("Public key should be %d bytes.", SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES));
        }

        if (\strlen($signature) !== 64) {
            throw new InvalidArgumentException(sprintf("Signature %d bytes.", 64));
        }

        try {
            return \sodium_crypto_sign_verify_detached(
                $signature,
                $response,
                $publicKey
            );
        } catch (SodiumException $e) {
            throw new InvalidArgumentException($e->getMessage());
        }
    }
public function isSignatureValid(string $response, string $signature, string $publicKey) : bool
    {
        if (\strlen($publicKey) !== SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES) {
            throw new InvalidArgumentException(sprintf("Public key should be %d bytes.", SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES));
        }

        if (\strlen($signature) !== 64) {
            throw new InvalidArgumentException(sprintf("Signature %d bytes.", 64));
        }

        try {
            return \sodium_crypto_sign_verify_detached(
                $signature,
                $response,
                $publicKey
            );
        } catch (SodiumException $e) {
            throw new InvalidArgumentException($e->getMessage());
        }
    }
public function isSignatureValid ( string $ response , string $ signature , string $ publicKey ) : bool { if ( \ strlen ( $ publicKey ) !== SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES ) { throw new InvalidArgumentException ( sprintf ( "Public key should be %d bytes." , SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES ) ) ; } if ( \ strlen ( $ signature ) !== 64 ) { throw new InvalidArgumentException ( sprintf ( "Signature %d bytes." , 64 ) ) ; } try { return \ sodium_crypto_sign_verify_detached ( $ signature , $ response , $ publicKey ) ; } catch ( SodiumException $ e ) { throw new InvalidArgumentException ( $ e -> getMessage ( ) ) ; } }
Returns true if the signature validates the response

@param string $response  The raw http response, after decoding
@param string $signature The raw multi-byte signature
@param string $publicKey The signing public key
@return bool

@throws InvalidArgumentException
Returns true if the signature validates the response