@Test
public void testShouldFailIfSignatureWasChanged() throws Exception {

  EcdsaSignJce signer =
      new EcdsaSignJce(
          EllipticCurves.getEcPrivateKey(Base64.decode(GOOGLE_SIGNING_PRIVATE_KEY_PKCS8_BASE64)),
          HashType.SHA256,
          EcdsaEncoding.DER);
  RewardedAdsVerifier verifier =
      new RewardedAdsVerifier.Builder()
          .setVerifyingPublicKeys(GOOGLE_VERIFYING_PUBLIC_KEYS_JSON)
          .build();
  byte[] validSig = signer.sign(REWARD_URL.getBytes(UTF_8));
  for (int i = 0; i < validSig.length; i++) {
    byte[] modifiedSig = Arrays.copyOf(validSig, validSig.length);
    modifiedSig[i] = (byte) (modifiedSig[i] ^ 0xff);
    String modifiedUrl = buildUrl(REWARD_URL, modifiedSig, KEY_ID);
    try {
      verifier.verify(modifiedUrl);
      fail("Expected GeneralSecurityException");
    } catch (GeneralSecurityException e) {
      // Expected.
      System.out.println(e);
    }
  }
}