@Test
public void getPublicKeyData_works() throws Exception {

  TestPrivateKeyTypeManager privateManager = new TestPrivateKeyTypeManager();
  TestPublicKeyTypeManager publicManager = new TestPublicKeyTypeManager();
  PrivateKeyManager<Void> manager =
      new PrivateKeyManagerImpl<>(privateManager, publicManager, Void.class);
  Ed25519PrivateKey privateKey =
      Ed25519PrivateKey.newBuilder()
          .setPublicKey(
              Ed25519PublicKey.newBuilder()
                  .setKeyValue(ByteString.copyFrom(Random.randBytes(32))))
          .setKeyValue(ByteString.copyFrom(Random.randBytes(32)))
          .build();
  KeyData keyData = manager.getPublicKeyData(privateKey.toByteString());
  assertThat(keyData.getTypeUrl())
      .isEqualTo("type.googleapis.com/google.crypto.tink.Ed25519PublicKey");
  Ed25519PublicKey publicKey =
      Ed25519PublicKey.parseFrom(keyData.getValue(), ExtensionRegistryLite.getEmptyRegistry());
  assertThat(publicKey).isEqualTo(privateKey.getPublicKey());
  assertThat(keyData.getKeyMaterialType()).isEqualTo(KeyMaterialType.ASYMMETRIC_PUBLIC);
}