Vote() public static method

public static Vote ( string host, int port, CookieCollection cookieCollection, System.Guid electionId, System.Numerics.BigInteger encryptedVector ) : void
host string
port int
cookieCollection System.Net.CookieCollection
electionId System.Guid
encryptedVector System.Numerics.BigInteger
return void
示例#1
0
        public static int ProcessPut(string host, string id, string flag)
        {
            log.Info("Processing Vuln2.Put");

            var candidateUsers = RegisterCandidates(host, flag.Distinct().Select(c => UsersManager.GenUser(null, c.ToString())).OrderBy(user => user.Login).ToArray());

            var election   = StartElection(host, candidateUsers[0], false, nominateTimeInSec, voteTimeInSec);
            var privateKey = election.PrivateKeyForCandidates;

            var sw = Stopwatch.StartNew();

            election = NominateUsers(host, election, candidateUsers.Skip(1).ToArray());
            sw.Stop();

            var tts = nominateTimeInSec * 1000 - sw.ElapsedMilliseconds;

            if (tts > 0)
            {
                log.InfoFormat("Sleeping for {0}ms before voting (nomination duration is {1}s)", tts, nominateTimeInSec);
                Thread.Sleep((int)tts);
            }

            var votes = GenVotes(flag, election);

            var voters = RegisterVoters(host, votes, candidateUsers);

            log.InfoFormat("Voting by {0} voters", voters.Length);
            foreach (var voter in voters)
            {
                ElectroClient.Vote(host, Program.PORT, voter.Key.Cookies, election.Id, HomoCrypto.EncryptVector(voter.Value, election.PublicKey));
            }
            log.Info("Voted");

            var state = new Vuln2State
            {
                ElectionId = election.Id.ToString(),
                Voter      = voters[0].Key,
                PrivateKey = privateKey
            };

            log.Info("Flag put");
            Console.Out.WriteLine(Convert.ToBase64String(Encoding.UTF8.GetBytes(state.ToJsonString())));
            return((int)ExitCode.OK);
        }