Fetching user's random pre key

@param uid        User's id
@param keyGroupId User's key group id
174997
private Promise<PublicKey> fetchUserPreKey(final int uid, final int keyGroupId) {
        return pickUserGroup(uid, keyGroupId)
                .flatMap(new Function<Tuple2<UserKeysGroup, UserKeys>, Promise<PublicKey>>() {
                    @Override
                    public Promise<PublicKey> apply(final Tuple2<UserKeysGroup, UserKeys> keyGroups) {
                        return api(new RequestLoadPrePublicKeys(new ApiUserOutPeer(uid, getUser(uid).getAccessHash()), keyGroupId))
                                .map(new Function<ResponsePublicKeys, PublicKey>() {
                                    @Override
                                    public PublicKey apply(ResponsePublicKeys response) {
                                        if (response.getPublicKey().size() == 0) {
                                            throw new RuntimeException("User doesn't have pre keys");
                                        }
                                        ApiEncryptionKey key = response.getPublicKey().get(0);
                                        ApiEncryptionKeySignature sig = null;
                                        for (ApiEncryptionKeySignature s : response.getSignatures()) {
                                            if (s.getKeyId() == key.getKeyId() && "Ed25519".equals(s.getSignatureAlg())) {
                                                sig = s;
                                                break;
                                            }
                                        }
                                        if (sig == null) {
                                            throw new RuntimeException("Unable to find public key on server");
                                        }

                                        byte[] keyHash = RatchetKeySignature.hashForSignature(key.getKeyId(), key.getKeyAlg(),
                                                key.getKeyMaterial());

                                        if (!Curve25519.verifySignature(keyGroups.getT1().getIdentityKey().getPublicKey(),
                                                keyHash, sig.getSignature())) {
                                            throw new RuntimeException("Key signature does not isMatch");
                                        }

                                        return new PublicKey(key.getKeyId(), key.getKeyAlg(), key.getKeyMaterial());
                                    }
                                });
                    }
                });
    }
920127
public static Key<CounterShardOperationData> key(final Key<CounterShardData> counterShardDataKey, final UUID id)
	{
		Preconditions.checkNotNull(counterShardDataKey);
		Preconditions.checkNotNull(id);

		return Key.create(counterShardDataKey, CounterShardOperationData.class, id.toString());
	}
592779
@Override
	public CommerceRegion fetchCommerceRegionByUuidAndGroupId(String uuid,
		long groupId) {
		return commerceRegionPersistence.fetchByUUID_G(uuid, groupId);
	}
389181
@RequestMapping(value = "/{userId}/userGroups", method = RequestMethod.GET)
    public ResponseEntity<Set<UserGroup>> findGroupsOfUser(@PathVariable Integer userId) {

        try {
            Set<UserGroup> userGroupsSet = this.service.getGroupsOfUser(userId);
            return new ResponseEntity<Set<UserGroup>>(userGroupsSet, HttpStatus.OK);
        } catch (Exception e) {
            LOG.error("Error finding user with id " + userId + ": "
                + e.getMessage());
            return new ResponseEntity<Set<UserGroup>>(HttpStatus.NOT_FOUND);
        }
    }
920686
public static function getTagGroupByUid(string $uid): TagGroup
    {
        $query = TagGroup::find();
        $query->andWhere(['uid' => $uid]);
        return $query->one() ?? new TagGroup();
    }
678298
public static String printUUID(UUID guid)
   {
      return guid == null ? null : "{" + guid.toString().toUpperCase() + "}";
   }
293530
private Promise<PrivateKey> fetchPreKey(long keyId) {
        try {
            return Promise.success(ManagedList.of(ownKeys.getPreKeys())
                    .filter(PrivateKey.PRE_KEY_EQUALS_ID(keyId))
                    .first());
        } catch (Exception e) {
            Log.d(TAG, "Unable to find own pre key #" + keyId);
            throw e;
        }
    }
496091
public Group getGroupByUUID(final UUID UUID) {
        List<Group> allGroups = getGroups();

        List<Group> groups = ListFilter.filter(allGroups, new Filter<Group>() {

            @Override
            public boolean matches(Group item) {

                if (item.getUuid() != null && item.getUuid().compareTo(UUID) == 0) {
                    return true;
                } else {
                    return false;
                }
            }
        });

        if (groups.size() == 1) {
            return groups.get(0);
        } else {
            return null;
        }
    }
513804
def get_user(uid, **kwargs):
    
    user_id=kwargs.get('user_id')
    if uid is None:
        uid = user_id
    user_i = _get_user(uid)
    return user_i
1277465
private void onPublicKeysGroupAdded(int uid, ApiEncryptionKeyGroup keyGroup) {
        UserKeys userKeys = getCachedUserKeys(uid);
        if (userKeys == null) {
            return;
        }
        UserKeysGroup validatedKeysGroup = validateUserKeysGroup(uid, keyGroup);
        if (validatedKeysGroup != null) {
            UserKeys updatedUserKeys = userKeys.addUserKeyGroup(validatedKeysGroup);
            cacheUserKeys(updatedUserKeys);
            context().getEncryption().getEncryptedChatManager(uid)
                    .send(new EncryptedPeerActor.KeyGroupUpdated(userKeys));
        }
    }
524268
@Override
	public com.liferay.commerce.model.CommerceOrder fetchCommerceOrderByUuidAndGroupId(
		String uuid, long groupId) {
		return _commerceOrderLocalService.fetchCommerceOrderByUuidAndGroupId(uuid,
			groupId);
	}
257236
@Override
  public String getOrCreateForKey(String key) {
    return uuidsByKey.computeIfAbsent(key, k -> Uuids.create());
  }
1083802
public static com.liferay.commerce.product.model.CPOptionValue getCPOptionValueByUuidAndGroupId(
		String uuid, long groupId)
		throws com.liferay.portal.kernel.exception.PortalException {
		return getService().getCPOptionValueByUuidAndGroupId(uuid, groupId);
	}
972746
public final String key() {
    key = (key == null) ? UUID.randomUUID().toString() : key;
    return key;
  }
437456
public function getGroupIds($uid){
        
        $groupIds = Db::table($this->dbTablePrefix . $this->tableUserGroup)
                    ->where('user_id',$uid)
                    ->column('group_id');
        
        return $groupIds;
    }
918421
private Promise<UserKeys> fetchUserGroups(final int uid) {

        User user = users().getValue(uid);
        if (user == null) {
            throw new RuntimeException("Unable to find user #" + uid);
        }

        final UserKeys userKeys = getCachedUserKeys(uid);
        if (userKeys != null) {
            return Promise.success(userKeys);
        }

        return api(new RequestLoadPublicKeyGroups(new ApiUserOutPeer(uid, user.getAccessHash())))
                .map(new Function<ResponsePublicKeyGroups, ArrayList<UserKeysGroup>>() {
                    @Override
                    public ArrayList<UserKeysGroup> apply(ResponsePublicKeyGroups response) {
                        ArrayList<UserKeysGroup> keysGroups = new ArrayList<>();
                        for (ApiEncryptionKeyGroup keyGroup : response.getPublicKeyGroups()) {
                            UserKeysGroup validatedKeysGroup = validateUserKeysGroup(uid, keyGroup);
                            if (validatedKeysGroup != null) {
                                keysGroups.add(validatedKeysGroup);
                            }
                        }
                        return keysGroups;
                    }
                })
                .map(new Function<ArrayList<UserKeysGroup>, UserKeys>() {
                    @Override
                    public UserKeys apply(ArrayList<UserKeysGroup> userKeysGroups) {
                        UserKeys userKeys = new UserKeys(uid, userKeysGroups.toArray(new UserKeysGroup[userKeysGroups.size()]));
                        cacheUserKeys(userKeys);
                        return userKeys;
                    }
                });
    }
759839
public static UUID randomUUID(boolean isSecure) {
		final Random ng = isSecure ? Holder.numberGenerator : RandomUtil.getRandom();

		byte[] randomBytes = new byte[16];
		ng.nextBytes(randomBytes);
		randomBytes[6] &= 0x0f; /* clear version */
		randomBytes[6] |= 0x40; /* set to version 4 */
		randomBytes[8] &= 0x3f; /* clear variant */
		randomBytes[8] |= 0x80; /* set to IETF variant */
		return new UUID(randomBytes);
	}