private static LegacyProtoKey createProtoKeyFromProtoParmaeters(
      LegacyProtoParameters parameters, @Nullable Integer idRequirement)
      throws GeneralSecurityException {
    KeyTemplate keyTemplate = parameters.getSerialization().getKeyTemplate();
    KeyManager<?> manager =
        KeyManagerRegistry.globalInstance().getUntypedKeyManager(keyTemplate.getTypeUrl());
    if (!KeyManagerRegistry.globalInstance().isNewKeyAllowed(keyTemplate.getTypeUrl())) {
      throw new GeneralSecurityException("Creating new keys is not allowed.");
    }
    KeyData keyData = manager.newKeyData(keyTemplate.getValue());
    ProtoKeySerialization protoSerialization =
        ProtoKeySerialization.create(
            keyData.getTypeUrl(),
            keyData.getValue(),
            keyData.getKeyMaterialType(),
            keyTemplate.getOutputPrefixType(),
            idRequirement);
    return new LegacyProtoKey(protoSerialization, InsecureSecretKeyAccess.get());
  }
A class to create key objects from parameters with given randomness.
java_src/src/main/java/com/google/crypto/tink/internal/MutableKeyCreationRegistry.java