@AccessesPartialKey
  private static KmsEnvelopeAeadKeyFormat serializeParametersToKmsEnvelopeAeadKeyFormat(
      LegacyKmsEnvelopeAeadParameters parameters) throws GeneralSecurityException {
    byte[] serializedDekParameters =
        TinkProtoParametersFormat.serialize(parameters.getDekParametersForNewKeys());
    try {
      KeyTemplate dekKeyTemplate =
          KeyTemplate.parseFrom(serializedDekParameters, ExtensionRegistryLite.getEmptyRegistry());
      return KmsEnvelopeAeadKeyFormat.newBuilder()
          .setKekUri(parameters.getKekUri())
          .setDekTemplate(dekKeyTemplate)
          .build();
    } catch (InvalidProtocolBufferException e) {
      throw new GeneralSecurityException("Parsing KmsEnvelopeAeadKeyFormat failed: ", e);
    }
  }
Serializers and Parsers for LegacyKmsEnvelopeAeadProtoKey and
LegacyKmsEnvelopeAeadProtoParameters
java_src/src/main/java/com/google/crypto/tink/aead/LegacyKmsEnvelopeAeadProtoSerialization.java