private static PrfBasedKeyDerivationParameters parseParameters(
      ProtoParametersSerialization serialization) throws GeneralSecurityException {
    if (!serialization.getKeyTemplate().getTypeUrl().equals(TYPE_URL)) {
      throw new IllegalArgumentException(
          "Wrong type URL in call to PrfBasedKeyDerivationKeyProtoSerialization.parseParameters: "
              + serialization.getKeyTemplate().getTypeUrl());
    }
    PrfBasedDeriverKeyFormat format;
    try {
      format =
          PrfBasedDeriverKeyFormat.parseFrom(
              serialization.getKeyTemplate().getValue(), ExtensionRegistryLite.getEmptyRegistry());
    } catch (InvalidProtocolBufferException e) {
      throw new GeneralSecurityException("Parsing PrfBasedDeriverKeyFormat failed: ", e);
    }

    Parameters derivedKeyParameters =
        TinkProtoParametersFormat.parse(format.getParams().getDerivedKeyTemplate().toByteArray());
    Parameters prfParameters =
        TinkProtoParametersFormat.parse(format.getPrfKeyTemplate().toByteArray());
    if (!(prfParameters instanceof PrfParameters)) {
      throw new GeneralSecurityException("Non-PRF parameters stored in the field prf_key_template");
    }

    if (serialization.getKeyTemplate().getOutputPrefixType()
        != format.getParams().getDerivedKeyTemplate().getOutputPrefixType()) {
      throw new GeneralSecurityException(
          "Output-Prefix mismatch in parameters while parsing " + format);
    }

    return PrfBasedKeyDerivationParameters.builder()
        .setPrfParameters((PrfParameters) prfParameters)
        .setDerivedKeyParameters(derivedKeyParameters)
        .build();
  }
Methods to serialize and parse {@link PrfBasedKeyDerivationKey} and {@link
PrfBasedKeyDerivationParameters} objects.
java_src/src/main/java/com/google/crypto/tink/keyderivation/internal/PrfBasedKeyDerivationKeyProtoSerialization.java