public async Task HandleAsync()
        {
            NodeResponse response;

            if (request.KeyId == null)
            {
                response = new PublicKeyNodeResponse(
                    request.RequestId,
                    NodeData.Instance.NodeKeys.PublicKey,
                    NodeData.Instance.NodeKeys.SignPublicKey,
                    NodeData.Instance.NodeKeys.KeyId,
                    NodeData.Instance.NodeKeys.ExpirationTime);
            }
            else
            {
                var key = await keysService.GetNodeKeysAsync(NodeSettings.Configs.Node.Id, request.KeyId.Value);

                if (key == null)
                {
                    response = new ResultNodeResponse(request.RequestId, ObjectsLibrary.Enums.ErrorCode.ObjectDoesNotExists, "The key was not found.");
                }
                else
                {
                    response = new PublicKeyNodeResponse(request.RequestId, key.PublicKey, key.SignPublicKey, key.KeyId, key.ExpirationTime);
                }
            }
            await NodeWebSocketCommunicationManager.SendResponseAsync(response, current).ConfigureAwait(false);
        }
        public async Task HandleAsync()
        {
            var nodeKey = await keysService.GetNodeKeysAsync(notice.Block.NodeId, notice.Block.Header.SignKeyId.GetValueOrDefault()).ConfigureAwait(false);

            if (await BlocksService.AcceptOrRejectNewBlockAsync(notice.Block, nodeKey?.SignPublicKey, NodeData.Instance.NodeKeys.Password).ConfigureAwait(false))
            {
                BlockGenerationHelper.Instance.HandleNewBlock(notice.Block);
                await dataRestorer.SaveBlockDataAsync(notice.Block).ConfigureAwait(false);
            }
        }
        private bool TryDecryptPrivateData <T>(BlockSegmentVm segment, out T decryptedObject)
        {
            if (segment.PrivateData != null && segment.KeyId != null && segment.NodeId == NodeSettings.Configs.Node.Id)
            {
                try
                {
                    NodeKeysDto nodeKeys = null;
                    if (Convert.ToInt64(segment.KeyId) != NodeData.Instance.NodeKeys.KeyId)
                    {
                        nodeKeys = _keysService.GetNodeKeysAsync(Convert.ToInt64(segment.KeyId)).Result;
                    }
                    else
                    {
                        nodeKeys = NodeData.Instance.NodeKeys;
                    }

                    if (nodeKeys != null)
                    {
                        byte[] password      = NodeData.Instance.NodeKeys.Password;
                        var    decryptedData = Encryptor.SymmetricDataDecrypt(
                            segment.PrivateData,
                            nodeKeys.PublicKey,
                            nodeKeys.SymmetricKey,
                            password).DecryptedData;
                        decryptedObject = ObjectSerializer.JsonToObject <T>(Encoding.UTF8.GetString(decryptedData), new BitArrayJsonConverter());
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLog(ex);
                    decryptedObject = default;
                    return(false);
                }
            }
            decryptedObject = default;
            return(false);
        }