Exemplo n.º 1
0
        public PublicKey GeneratePublicKey(VoteGroup group)
        {
            var key = new PublicKey();

            key.IsRegistered = false;
            key.PublicKeyId  = Util.IdGenerator.RandomString(25);
            group.PublicKeys.Add(key);
            return(key);
        }
Exemplo n.º 2
0
        public HiddenKey GenerateHiddenKey(VoteGroup group, string publicKey)
        {
            var publicKeyElement = group.PublicKeys.FirstOrDefault(n => n.PublicKeyId == publicKey);

            if (publicKeyElement == null || publicKeyElement.IsRegistered)
            {
                return(null);
            }

            publicKeyElement.IsRegistered = true;
            var hiddenKey = new HiddenKey();

            hiddenKey.HiddenKeyId = Util.IdGenerator.RandomString(32);
            return(hiddenKey);
        }
Exemplo n.º 3
0
        public VoteGroup GenerateNewVoteGroup(string id = null)
        {
            var group = new VoteGroup();

            // Allows the user to give a custom vote Group id by the given value if its available
            if (id != null)
            {
                if (_voteGroups.All(n => n.VoteGroupId != id))
                {
                    group.VoteGroupId = id;
                }
            }
            _voteGroups.Add(group);
            return(group);
        }