@Test
public void testVerificationWithWycheproofVectors() throws Exception {

  JSONObject json =
      WycheproofTestUtil.readJson("../wycheproof/testvectors/eddsa_test.json");
  int errors = 0;
  JSONArray testGroups = json.getJSONArray("testGroups");
  for (int i = 0; i < testGroups.length(); i++) {
    JSONObject group = testGroups.getJSONObject(i);
    JSONObject key = group.getJSONObject("key");
    byte[] publicKey = Hex.decode(key.getString("pk"));
    JSONArray tests = group.getJSONArray("tests");
    for (int j = 0; j < tests.length(); j++) {
      JSONObject testcase = tests.getJSONObject(j);
      String tcId =
          String.format(
              "testcase %d (%s)", testcase.getInt("tcId"), testcase.getString("comment"));
      byte[] msg = getMessage(testcase);
      byte[] sig = Hex.decode(testcase.getString("sig"));
      String result = testcase.getString("result");
      Ed25519Verify verifier = new Ed25519Verify(publicKey);
      try {
        verifier.verify(sig, msg);
        if (result.equals("invalid")) {
          System.out.printf("FAIL %s: accepting invalid signature%n", tcId);
          errors++;
        }
      } catch (GeneralSecurityException ex) {
        if (result.equals("valid")) {
          System.out.printf("FAIL %s: rejecting valid signature, exception: %s%n", tcId, ex);
          errors++;
        }
      }
    }
  }
  assertEquals(0, errors);
}