@SuppressWarnings("UnusedException") // Prevents leaking key material
  private static Ed25519PrivateKey parsePrivateKey(
      ProtoKeySerialization serialization, @Nullable SecretKeyAccess access)
      throws GeneralSecurityException {
    if (!serialization.getTypeUrl().equals(PRIVATE_TYPE_URL)) {
      throw new IllegalArgumentException(
          "Wrong type URL in call to Ed25519ProtoSerialization.parsePrivateKey: "
              + serialization.getTypeUrl());
    }
    try {
      com.google.crypto.tink.proto.Ed25519PrivateKey protoKey =
          com.google.crypto.tink.proto.Ed25519PrivateKey.parseFrom(
              serialization.getValue(), ExtensionRegistryLite.getEmptyRegistry());
      if (protoKey.getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys are accepted");
      }
      com.google.crypto.tink.proto.Ed25519PublicKey protoPublicKey = protoKey.getPublicKey();
      Ed25519PublicKey publicKey =
          Ed25519PublicKey.create(
              VARIANT_CONVERTER.fromProtoEnum(serialization.getOutputPrefixType()),
              Bytes.copyFrom(protoPublicKey.getKeyValue().toByteArray()),
              serialization.getIdRequirementOrNull());

      return Ed25519PrivateKey.create(
          publicKey,
          SecretBytes.copyFrom(
              protoKey.getKeyValue().toByteArray(), SecretKeyAccess.requireAccess(access)));
    } catch (InvalidProtocolBufferException e) {
      throw new GeneralSecurityException("Parsing Ed25519PrivateKey failed");
    }
  }
Returns the proto serialization of a {@link Ed25519PublicKey}.

@param access may be null for public key material
@throws GeneralSecurityException if the key cannot be serialized (e.g. unknown variant)
java_src/src/main/java/com/google/crypto/tink/signature/internal/Ed25519ProtoSerialization.java