0) && (\abs(\time() - $timestamp) > $tolerance)) { throw Exception\SignatureVerificationException::factory( 'Timestamp outside the tolerance zone', $payload, $signature_header ); } // Convert base64 string to bytes for sodium crypto functions $public_key_bytes = base64_decode($my_public_key); $signature_header_bytes = base64_decode($signature_header); // Construct a message to test against the signature header using the timestamp and payload $signed_payload = $timestamp . '|' . $payload; if (!\sodium_crypto_sign_verify_detached($signature_header_bytes, $signed_payload, $public_key_bytes)) { throw Exception\SignatureVerificationException::factory( 'Signature is invalid and does not match the payload', $payload, $signature_header ); } return true; } }