public static Prf create(LegacyProtoKey key) throws GeneralSecurityException {
    ProtoKeySerialization protoKeySerialization =
        key.getSerialization(InsecureSecretKeyAccess.get());
    KeyData keyData =
        KeyData.newBuilder()
            .setTypeUrl(protoKeySerialization.getTypeUrl())
            .setValue(protoKeySerialization.getValue())
            .setKeyMaterialType(protoKeySerialization.getKeyMaterialType())
            .build();
    return new LegacyFullPrf(Registry.getPrimitive(keyData, Prf.class));
  }
This method covers the cases where users created their own prf/key classes.
java_src/src/main/java/com/google/crypto/tink/prf/internal/LegacyFullPrf.java