private static ProtoParametersSerialization serializeParameters(
      PrfBasedKeyDerivationParameters parameters) throws GeneralSecurityException {
    try {
      byte[] serializedPrfParameters =
          TinkProtoParametersFormat.serialize(parameters.getPrfParameters());
      KeyTemplate prfKeyTemplate =
          KeyTemplate.parseFrom(serializedPrfParameters, ExtensionRegistryLite.getEmptyRegistry());
      byte[] serializedDerivedKeyParameters =
          TinkProtoParametersFormat.serialize(parameters.getDerivedKeyParameters());
      KeyTemplate derivedKeyTemplate =
          KeyTemplate.parseFrom(
              serializedDerivedKeyParameters, ExtensionRegistryLite.getEmptyRegistry());
      PrfBasedDeriverKeyFormat format =
          PrfBasedDeriverKeyFormat.newBuilder()
              .setPrfKeyTemplate(prfKeyTemplate)
              .setParams(
                  PrfBasedDeriverParams.newBuilder().setDerivedKeyTemplate(derivedKeyTemplate))
              .build();
      return ProtoParametersSerialization.create(
          KeyTemplate.newBuilder()
              .setTypeUrl(TYPE_URL)
              .setValue(format.toByteString())
              .setOutputPrefixType(derivedKeyTemplate.getOutputPrefixType())
              .build());
    } catch (InvalidProtocolBufferException e) {
      throw new GeneralSecurityException("Serializing PrfBasedKeyDerivationParameters failed: ", e);
    }
  }
Methods to serialize and parse {@link PrfBasedKeyDerivationKey} and {@link
PrfBasedKeyDerivationParameters} objects.
java_src/src/main/java/com/google/crypto/tink/keyderivation/internal/PrfBasedKeyDerivationKeyProtoSerialization.java