private void CreateHomomorphicTree()
        {
            try
            {
                HATTree <string> HTree = new HATTree <string>();

                HTree.CreateTree(ApplicationState.FileManager.CurrentSelectedFile.FileBlocks.ToList());
                List <HATNode <string> > nodes = HTree.PreOrderTraversal();

                StringBuilder compleString = new StringBuilder();
                foreach (HATNode <string> item in nodes)
                {
                    string logText = item.Index + "\t" + item.LeafNodesCount + "\t " + item.Version + "\t" + item.Tag + "\r\n";
                    compleString.Append(logText);
                }

                HomomorphicTextLog = compleString.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void ExecutePoSCommand(Object data)
        {
            try
            {
                StringBuilder logger = new StringBuilder();

                this.challangedIndexes.Clear();
                string[] stringItems = this.commaSepratedBlockIndexes.Split(',');

                logger.AppendLine("Challanged Indexes for file blocks: ");

                foreach (var item in stringItems)
                {
                    int index = int.Parse(item);
                    this.challangedIndexes.Add(index);

                    logger.Append(index.ToString() + "  ");
                }

                logger.AppendLine("Get the list of file blocks with version information");
                List <FileBlock> fileBlocks = selectedFile.getFileBlocksForUser(SelectedUser, this.challangedIndexes);


                List <FileBlock> cloudRecievedFileBlocks = new List <FileBlock>();

                foreach (FileBlock fileBlock in fileBlocks)
                {
                    logger.AppendLine();
                    logger.AppendLine("File block: " + fileBlock.Index + " , Version: " + fileBlock.Version + " , known content Hash: " + fileBlock.ContentHash);
                    string location = SelectedFile.GetCloudLocationForVersion(fileBlock.Version);
                    string hashRecievedFromCloudContent = Utility.ToString(Utility.ComputeHashSumForFile(location + "//" + fileBlock.Index), true);;
                    logger.AppendLine("Getting File block from cloud: " + fileBlock.Index + " , Cloud content Hash: " + fileBlock.ContentHash);
                    logger.AppendLine("Verifying hash :" + string.Compare(hashRecievedFromCloudContent, fileBlock.ContentHash));

                    // We are creating the empty file block which have hash recieved from cloud
                    cloudRecievedFileBlocks.Add(new FileBlock(fileBlock.FileHashID, fileBlock.Index, fileBlock.Size)
                    {
                        ContentHash = hashRecievedFromCloudContent
                    });
                }


                try
                {
                    // We are creatinng Homomorphic authenticated tree for requested and calculated top node hash code
                    logger.AppendLine("Cloud creatinng Homomorphic authenticated tree for challanged indexes");
                    HATTree <string> HTreeCloud = new HATTree <string>();
                    HTreeCloud.CreateTree(cloudRecievedFileBlocks);

                    logger.AppendLine("Cloud Homomorphic authenticated tree root node hash :" + HTreeCloud.Root.Hash);


                    logger.AppendLine("Locally creatinng Homomorphic authenticated tree for challanged indexes");
                    HATTree <string> HTreeLocal = new HATTree <string>();
                    HTreeLocal.CreateTree(fileBlocks);

                    logger.AppendLine("Locally created Homomorphic authenticated tree root node hash :" + HTreeLocal.Root.Hash);

                    if (HTreeCloud.Root.Hash == HTreeLocal.Root.Hash)
                    {
                        logger.AppendLine("Root hash matched. Content same");
                    }
                    else
                    {
                        logger.AppendLine("Root hash failed to match. Content differs");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }


                Log = logger.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
            }
        }