예제 #1
0
        public VoteBruteForceStatus BruteForceVerification()
        {
            VVK_WPRC.EncryptVote voteEncrypter = new VVK_WPRC.EncryptVote();
            if (voteEncrypter.initPublicKey(Conf.Instance.Model.AppConfig.Params.PublikKey) == false)
            {
                return(VoteBruteForceStatus.KeyInitFailed);
            }

            _verifiedCandidates = new List <Candidate>();

            foreach (EncryptedVote encVote in _encryptedVotes)
            {
                foreach (Candidate candidate in _candidates)
                {
                    if (encVote.ElectionName.Equals(candidate.ElectionName))
                    {
                        string decodedVote = string.Format("{0}\n{1}\n{2}\n", VersionNumber, encVote.ElectionName, candidate.Code);
                        string result      = voteEncrypter.encryptVote(decodedVote, QRResult.Instance.ElectionHexSeeds[encVote.ElectionName]);

                        if (result == null)
                        {
                            return(VoteBruteForceStatus.KeyInitFailed);
                        }

                        if (result.ToLower().Equals(encVote.EncryptedHex.ToLower()))
                        {
                            _verifiedCandidates.Add(candidate);
                        }
                    }
                }
            }
            voteEncrypter.clearPublicKey();

            if (_verifiedCandidates.Count < 1)
            {
                return(VoteBruteForceStatus.NoVerifiedCandidates);
            }

            return(VoteBruteForceStatus.Success);
        }
예제 #2
0
        public VoteBruteForceStatus BruteForceVerification()
        {
            VVK_WPRC.EncryptVote voteEncrypter = new VVK_WPRC.EncryptVote();
            if (voteEncrypter.initPublicKey(Conf.Instance.Model.AppConfig.Params.PublikKey) == false)
            {
                return VoteBruteForceStatus.KeyInitFailed;
            }

            _verifiedCandidates = new List<Candidate>();

            foreach (EncryptedVote encVote in _encryptedVotes)
            {
                foreach (Candidate candidate in _candidates)
                {
                    if (encVote.ElectionName.Equals(candidate.ElectionName))
                    {
                        string decodedVote = string.Format("{0}\n{1}\n{2}\n", VersionNumber, encVote.ElectionName, candidate.Code);
                        string result = voteEncrypter.encryptVote(decodedVote, QRResult.Instance.ElectionHexSeeds[encVote.ElectionName]);

                        if (result == null)
                        {
                            return VoteBruteForceStatus.KeyInitFailed;
                        }

                        if (result.ToLower().Equals(encVote.EncryptedHex.ToLower()))
                        {
                            _verifiedCandidates.Add(candidate);
                        }
                    }
                }
            }
            voteEncrypter.clearPublicKey();

            if (_verifiedCandidates.Count < 1)
            {
                return VoteBruteForceStatus.NoVerifiedCandidates;
            }

            return VoteBruteForceStatus.Success;
        }