public function verifySignedRequest(
        RequestInterface $request,
        SigningPublicKey $publicKey
    ): RequestInterface {
        /** @var array<int, string> */
        $headers = $request->getHeader((string) static::HEADER_SIGNATURE_NAME);
        if (!$headers) {
            throw new HeaderMissingException(
                'No signed request header (' . (string) static::HEADER_SIGNATURE_NAME . ') found.'
            );
        }

        $body = (string) $request->getBody();
        foreach ($headers as $head) {
            $result = \ParagonIE_Sodium_Compat::crypto_sign_verify_detached(
                Base64UrlSafe::decode($head),
                $body,
                $publicKey->getString(true)
            );
            if ($result) {
                return $request;
            }
        }
        throw new InvalidMessageException('No valid signature given for this HTTP request');
    }
public function verifySignedRequest(
        RequestInterface $request,
        SigningPublicKey $publicKey
    ): RequestInterface {
        /** @var array<int, string> */
        $headers = $request->getHeader((string) static::HEADER_SIGNATURE_NAME);
        if (!$headers) {
            throw new HeaderMissingException(
                'No signed request header (' . (string) static::HEADER_SIGNATURE_NAME . ') found.'
            );
        }

        $body = (string) $request->getBody();
        foreach ($headers as $head) {
            $result = \ParagonIE_Sodium_Compat::crypto_sign_verify_detached(
                Base64UrlSafe::decode($head),
                $body,
                $publicKey->getString(true)
            );
            if ($result) {
                return $request;
            }
        }
        throw new InvalidMessageException('No valid signature given for this HTTP request');
    }
public function verifySignedRequest ( RequestInterface $ request , SigningPublicKey $ publicKey ) : RequestInterface { /** @var array<int, string> */ $ headers = $ request -> getHeader ( ( string ) static :: HEADER_SIGNATURE_NAME ) ; if ( ! $ headers ) { throw new HeaderMissingException ( 'No signed request header (' . ( string ) static :: HEADER_SIGNATURE_NAME . ') found.' ) ; } $ body = ( string ) $ request -> getBody ( ) ; foreach ( $ headers as $ head ) { $ result = \ ParagonIE_Sodium_Compat :: crypto_sign_verify_detached ( Base64UrlSafe :: decode ( $ head ) , $ body , $ publicKey -> getString ( true ) ) ; if ( $ result ) { return $ request ; } } throw new InvalidMessageException ( 'No valid signature given for this HTTP request' ) ; }
Verifies the signature contained in the Body-Signature-Ed25519 header
is valid for the HTTP Request body provided. Will either return the
request given, or throw an InvalidMessageException if the signature
is invalid. Will also throw a HeaderMissingException is there is no
Body-Signature-Ed25519 header.

@param RequestInterface $request
@param SigningPublicKey $publicKey
@return RequestInterface
@throws HeaderMissingException
@throws InvalidMessageException
Verifies the signature contained in the Body - Signature - Ed25519 header is valid for the HTTP Request body provided . Will either return the request given or throw an InvalidMessageException if the signature is invalid . Will also throw a HeaderMissingException is there is no Body - Signature - Ed25519 header .