示例#1
0
        public async Task GenerateSplitedSecret(SecureString hsmSecret, int electionId)
        {
            using (var initializedHsm = await hsmFactory.GetHsm(hsmSecret))
            {
                var keys = keyManager.GenerateNewSerializedKeyPair();

                var handle             = initializedHsm.GenerateMasterKey();
                var encryptedSecretKey = initializedHsm.Encrypt(handle, keys.Secretkey);

                var totalNumberOfShares = (int)ShareHolders.Sum(s => s.NumberOfShares);
                var splitedSecret       = SecretSplitter.SplitMessage(KeySerializer.ByteArrayToString(encryptedSecretKey), Treshold, totalNumberOfShares);
                int index = 0;

                foreach (var shareHolder in ShareHolders)
                {
                    var shares = splitedSecret.Skip(index).Take((int)shareHolder.NumberOfShares);
                    index += (int)shareHolder.NumberOfShares;
                    var bytes = SerializeShares(shares.ToArray());
                    await shareHolder.SaveShares(bytes);
                }

                await centralDbRepository.SaveCryptoDetailsAsync(electionId, handle, keys.PublicKey);
            }
        }
示例#2
0
        public void PerformDragAndDrop(RadTreeViewDropPosition dropPosition, RadTreeNode sourceNode,
                                               RadTreeNode destNode)
        {
            if (sourceNode.Equals(destNode) || sourceNode.IsAncestorOf(destNode))
            {
                return;
            }
            //Do not remove relation here.
            //sourceNode.Owner.Nodes.Remove(sourceNode);

            var shareHolders = new ShareHolders();
            bool validation = false;
            switch (dropPosition)
            {
                case RadTreeViewDropPosition.Over:

                    validation = shareHolders.AddSubsidiary(destNode.Text, sourceNode.Text);
                    // child
                    if (!sourceNode.IsAncestorOf(destNode) && validation == true)
                    {
                        destNode.Nodes.Add(sourceNode);
                    }

                    IsUpdated = validation;
                    break;

                case RadTreeViewDropPosition.Above:

                    validation = shareHolders.AddSubsidiary(destNode.ParentNode.Text, sourceNode.Text);
                    // sibling - above	
                    if (validation == true)
                    {
                        destNode.InsertBefore(sourceNode);
                    }
                    IsUpdated = validation;
                    break;

                case RadTreeViewDropPosition.Below:

                    validation = shareHolders.AddSubsidiary(destNode.Text, sourceNode.Text);
                    // sibling - below
                    if (validation == true)
                    {
                        destNode.InsertAfter(sourceNode);
                    }

                    IsUpdated = validation;
                    break;
            }
        }
示例#3
0
        protected void BuildTreeView(string zoekString, RadTreeView treeView, RelationView view)
        {
            string xml = new ShareHolders().CreateXMLOrganoTreeView(zoekString, view);
            XElement coloredXML = XElement.Parse(xml);
            ColorFoundNodes(zoekString, ref coloredXML);

            treeView.LoadXml(coloredXML.ToString());

            var nodes = treeView.GetAllNodes();

            if (nodes.Count() > 0 && nodes[0].Text.Equals(zoekString))
                nodes[0].BackColor = Color.Gold;

        }