@Test
  public void readNoSecretWithBinaryKeysetReader_shouldWork() throws Exception {
    KeysetHandle privateHandle = KeysetHandle.generateNew(KeyTemplates.get("ECDSA_P256"));
    Keyset keyset = privateHandle.getPublicKeysetHandle().getKeyset();
    byte[] serializedKeyset = keyset.toByteArray();

    Keyset readKeyset =
        KeysetHandle.readNoSecret(BinaryKeysetReader.withBytes(serializedKeyset)).getKeyset();

    expect.that(readKeyset).isEqualTo(keyset);
  }
Tests that when encryption failed an exception is thrown.
java_src/src/test/java/com/google/crypto/tink/KeysetHandleTest.java