@AccessesPartialKey
  private static ProtoKeySerialization serializeKey(
      PrfBasedKeyDerivationKey key, @Nullable SecretKeyAccess access)
      throws GeneralSecurityException {
    ProtoKeySerialization prfKeySerialization =
        MutableSerializationRegistry.globalInstance()
            .serializeKey(key.getPrfKey(), ProtoKeySerialization.class, access);
    ProtoParametersSerialization derivedKeyParametersSerialization =
        MutableSerializationRegistry.globalInstance()
            .serializeParameters(
                key.getParameters().getDerivedKeyParameters(), ProtoParametersSerialization.class);
    return ProtoKeySerialization.create(
        TYPE_URL,
        PrfBasedDeriverKey.newBuilder()
            .setPrfKey(
                KeyData.newBuilder()
                    .setValue(prfKeySerialization.getValue())
                    .setTypeUrl(prfKeySerialization.getTypeUrl())
                    .setKeyMaterialType(prfKeySerialization.getKeyMaterialType()))
            .setParams(
                PrfBasedDeriverParams.newBuilder()
                    .setDerivedKeyTemplate(derivedKeyParametersSerialization.getKeyTemplate()))
            .build()
            .toByteString(),
        KeyMaterialType.SYMMETRIC,
        derivedKeyParametersSerialization.getKeyTemplate().getOutputPrefixType(),
        key.getIdRequirementOrNull());
  }
Methods to serialize and parse {@link PrfBasedKeyDerivationKey} and {@link
PrfBasedKeyDerivationParameters} objects.
java_src/src/main/java/com/google/crypto/tink/keyderivation/internal/PrfBasedKeyDerivationKeyProtoSerialization.java