Exemple #1
0
 /// <summary>
 /// Creates a new voting result.
 /// </summary>
 /// <remarks>
 /// Don't forget adding option and envelopes results.
 /// </remarks>
 /// <param name="votingId">Id of the voting procedure.</param>
 /// <param name="votingParameters">Parameters of the voting in question.</param>
 public VotingResult(Guid votingId, VotingParameters votingParameters)
 {
     this.votingId = votingId;
       this.title = votingParameters.Title;
       this.description = votingParameters.Description;
       this.questions = new List<QuestionResult>();
       this.voters = new List<EnvelopeResult>();
 }
Exemple #2
0
        /// <summary>
        /// Creates a new vote receipt.
        /// </summary>
        /// <param name="parameters">Voting parameters.</param>
        /// <param name="signedEnvelope">Signed envelope.</param>
        public VoteReceipt(VotingParameters parameters, Signed<Envelope> signedEnvelope)
        {
            if (signedEnvelope.Value.VotingId != parameters.VotingId)
            throw new InvalidOperationException("Wrong parameters for envelope.");
              if (signedEnvelope.Value.VoterId != signedEnvelope.Certificate.Id)
            throw new InvalidOperationException("Inconsistent envelope.");

              VotingId = parameters.VotingId;
              VotingTitle = parameters.Title;
              VoterId = signedEnvelope.Certificate.Id;
              SHA256Managed sha256 = new SHA256Managed();
              byte[] signedEnvelopeData = signedEnvelope.ToBinary();
              SignedEnvelopeHash = sha256.ComputeHash(signedEnvelopeData);
        }
Exemple #3
0
 /// <summary>
 /// Create a new voting descriptor.
 /// </summary>
 /// <param name="parameters">Parameters of voting to describe.</param>
 /// <param name="status">Status of the voting.</param>
 /// <param name="authoritiesDone">List of authorities that have completed the current step if applicable.</param>
 public VotingDescriptor(VotingParameters parameters, VotingStatus status, List<Guid> authoritiesDone, int envelopeCount)
 {
     this.id = parameters.VotingId;
       this.title = parameters.Title;
       this.descripton = parameters.Description;
       this.url = parameters.Url;
       this.status = status;
       this.authoritiesDone = authoritiesDone;
       this.voteFrom = parameters.VotingBeginDate;
       this.voteUntil = parameters.VotingEndDate;
       this.authorityCount = status == VotingStatus.Deciphering ? parameters.Thereshold + 1 : parameters.AuthorityCount;
       this.envelopeCount = envelopeCount;
       this.questions = new List<QuestionDescriptor>();
       this.questions.AddRange(parameters.Questions.Select(question => new QuestionDescriptor(question)));
       this.groupId = parameters.GroupId;
 }
Exemple #4
0
        /// <summary>
        /// Creates a set of test parameters.
        /// </summary>
        /// <param name="dataPath">Path where application data is stored.</param>
        /// <returns>Test voting parameters</returns>
        public static VotingParameters CreateTestParameters(string dataPath)
        {
            VotingParameters parameters = new VotingParameters();
              parameters.GenerateNumbers(dataPath, 512);
              Question question = new Question(new MultiLanguageString("?"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty), 2);
              question.AddOption(new Option(new MultiLanguageString("A"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty)));
              question.AddOption(new Option(new MultiLanguageString("B"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty)));
              question.AddOption(new Option(new MultiLanguageString("C"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty)));
              question.AddOption(new Option(new MultiLanguageString("D"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty)));
              parameters.AddQuestion(question);

              return parameters;
        }
Exemple #5
0
        private bool SetVotingMaterial(VotingMaterial votingMaterial)
        {
            bool acceptMaterial = votingMaterial.Valid(CertificateStorage);

              if (acceptMaterial)
              {
            this.parameters = votingMaterial.Parameters.Value;
            this.publicKey = new BigInt(1);

            foreach (Signed<ShareResponse> signedShareResponse in votingMaterial.PublicKeyParts)
            {
              ShareResponse shareResponse = signedShareResponse.Value;
              this.publicKey = (this.publicKey * shareResponse.PublicKeyPart).Mod(this.parameters.P);
            }
              }

              return acceptMaterial;
        }
Exemple #6
0
        /// <summary>
        /// Creates a new summation of votes.
        /// </summary>
        /// <param name="parameters">Voting parameters.</param>
        /// <param name="certificateStorage">Certificate storage to verify against.</param>
        /// <param name="publicKey">Public key with which the votes where encrypted.</param>
        public Tally(
            VotingParameters parameters,
            CertificateStorage certificateStorage,
            BigInt publicKey,
            int checkProofCount)
        {
            this.rng = RandomNumberGenerator.Create();
              this.parameters = parameters;
              this.proofCheckCount = Math.Min(parameters.ProofCount, checkProofCount);
              this.certificateStorage = certificateStorage;
              this.publicKey = publicKey;

              this.voteSums = new Vote[this.parameters.Questions.Count()][];
              for (int questionIndex = 0; questionIndex < this.parameters.Questions.Count(); questionIndex++)
              {
            Question question = this.parameters.Questions.ElementAt(questionIndex);
            this.voteSums[questionIndex] = new Vote[question.Options.Count()];
              }

              this.result = new VotingResult(this.parameters.VotingId, this.parameters);
              this.partialDeciphers = new List<PartialDecipher>();
              this.countedVoters = new List<Guid>();
              this.nextEnvelopeIndex = 0;
              this.envelopeSequencerList = new Dictionary<int, Tuple<Signed<Envelope>, bool>>();

              EnvelopeHash = new byte[] { };
              EnvelopeCount = 0;
              ValidEnvelopeCount = 0;

              CryptoLog.Begin(CryptoLogLevel.Summary, "Begin tallying");
              CryptoLog.Add(CryptoLogLevel.Summary, "Voting id", parameters.VotingId);
              CryptoLog.Add(CryptoLogLevel.Summary, "Voting title", parameters.Title.Text);
              CryptoLog.Add(CryptoLogLevel.Detailed, "ProofCount", parameters.ProofCount);
              CryptoLog.Add(CryptoLogLevel.Detailed, "Thereshold", parameters.Thereshold);
              CryptoLog.Add(CryptoLogLevel.Numeric, "P", parameters.P);
              CryptoLog.Add(CryptoLogLevel.Numeric, "G", parameters.G);
              CryptoLog.Add(CryptoLogLevel.Numeric, "F", parameters.F);
              CryptoLog.Add(CryptoLogLevel.Numeric, "Q", parameters.Q);
              CryptoLog.EndWrite();
        }
Exemple #7
0
        /// <summary>
        /// Create a new voting procedure.
        /// </summary>
        /// <param name="logger">Logs messages to file.</param>
        /// <param name="DataAccess.DbConnection">Connection to the database.</param>
        /// <param name="parameters">Voting parameters.</param>
        /// <param name="rootCertificate">Certificate storage.</param>
        /// <param name="status">Voting status.</param>
        public VotingServerEntity(
            VotingRpcServer server,
            Signed<VotingParameters> signedParameters,
            ICertificateStorage certificateStorage,
            ServerCertificate serverCertificate,
            VotingStatus status)
        {
            if (server == null)
            throw new ArgumentNullException("server");
              if (signedParameters == null)
            throw new ArgumentNullException("signedParameters");
              if (serverCertificate == null)
            throw new ArgumentNullException("serverCertificate");

              Server = server;
              this.lastProcessTime = DateTime.Now;
              this.certificateStorage = certificateStorage;
              this.serverCertificate = serverCertificate;
              this.signedParameters = signedParameters;
              this.parameters = this.signedParameters.Value;
              this.status = status;
        }
Exemple #8
0
        /// <summary>
        /// Load data of authority from file.
        /// </summary>
        /// <param name="fileName">Name of file to load.</param>
        private void Load(string fileName)
        {
            FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
              DeserializeContext context = new DeserializeContext(fileStream);

              this.parameters = context.ReadObject<VotingParameters>();
              this.signedParameters = context.ReadObject<Signed<VotingParameters>>();

              this.authorities = new Dictionary<int,Certificate>();
              int count = context.ReadInt32();
              count.Times(() => this.authorities.Add(context.ReadInt32(), context.ReadObject<Certificate>()));

              this.authority = new Authority(context, this.parameters);

              context.Close();
              fileStream.Close();
        }
Exemple #9
0
        /// <summary>
        /// Prepares the authority for voting procedure.
        /// </summary>
        /// <param name="index">Index given to this authority.</param>
        /// <param name="parameters">Voting parameters for the procedure.</param>
        public void Prepare(int index, Signed<VotingParameters> signedParameters)
        {
            if (index < 1)
            throw new ArgumentException("Index must be at least 1.");
              if (signedParameters == null)
            throw new ArgumentNullException("signedParameters");

              this.signedParameters = signedParameters;
              this.parameters = signedParameters.Value;
              this.authority = new Authority(index, this.parameters);
              this.authority.CreatePolynomial();
              this.authorities = new Dictionary<int, Certificate>();
        }
Exemple #10
0
 public void MyTestInitialize()
 {
     this.parameters = VotingParameters.CreateTestParameters(Files.TestDataPath);
 }
Exemple #11
0
        private void doneButton_Click(object sender, EventArgs e)
        {
            FindForm().Enabled = false;

              this.progressLabel.Text = Resources.CreateVotingVerifyingSafePrime;
              this.progressBar.Style = ProgressBarStyle.Marquee;

              this.run = true;
              this.worker = new Thread(TakePrime);
              this.worker.Start();

              while (this.run)
              {
            this.progressLabel.Text = Resources.CreateVotingVerifyingSafePrime;
            Application.DoEvents();
            Thread.Sleep(1);
              }

              this.progressLabel.Text = string.Empty;
              this.progressBar.Style = ProgressBarStyle.Blocks;

              int primesStored = Prime.CountPregeneratedSafePrimes(Status.Controller.Status.DataPath);
              this.storedPrimesLabel.Text = string.Format(Resources.CreateVotingStored, primesStored);
              this.doneButton.Enabled = primesStored > 0;

              FindForm().Enabled = true;

              if (this.havePrimes)
              {
            var certificate = Status.Controller.GetAdminCertificate();

            if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(certificate, GuiResources.UnlockActionCreateVoting))
            {
              try
              {
            var parameters = new VotingParameters(
              Status.Data.Title,
              Status.Data.Descrption,
              Status.Data.Url,
              Status.FromDate,
              Status.UntilDate,
              Status.VotingGroup.Id);

            foreach (var question in Status.Data.Questions)
            {
              if (question.MaxVota > 1)
              {
                for (int index = 0; index < question.MaxVota; index++)
                {
                  question.AddOption(Option.CreateAbstentionSpecial());
                }
              }
              else
              {
                question.AddOption(Option.CreateAbstention());
              }

              parameters.AddQuestion(question);
            }

            parameters.SetNumbers(Status.Prime, Status.SafePrime);
            var signedParameters = new Signed<VotingParameters>(parameters, certificate);

            Pirate.PiVote.Circle.Status.TextStatusDialog.ShowInfo(Status.Controller, FindForm());
            Status.Controller.CreateVoting(signedParameters, Status.Authorites);
              }
              catch (Exception exception)
              {
            Error.ErrorDialog.ShowError(exception);
              }
              finally
              {
            certificate.Lock();
            Pirate.PiVote.Circle.Status.TextStatusDialog.HideInfo();
            OnCloseCreateDialog();
              }
            }
              }
        }
Exemple #12
0
        /// <summary>
        /// Voting entity test.
        /// </summary>
        /// <remarks>
        /// Used only during development.
        /// </remarks>
        public void EntityTest()
        {
            IRpcConnection connection = new DummyConnection();

              DateTime validUntil = DateTime.Now.AddDays(1);
              var root = new CACertificate(null, "Root");
              root.CreateSelfSignature();
              var rootCrl = new RevocationList(root.Id, DateTime.Now, validUntil, new List<Guid>());
              var sigRootCrl = new Signed<RevocationList>(rootCrl, root);

              var intermediate = new CACertificate(null, "Intermediate");
              intermediate.CreateSelfSignature();
              intermediate.AddSignature(root, validUntil);
              var intCrl = new RevocationList(intermediate.Id, DateTime.Now, validUntil, new List<Guid>());
              var sigIntCrl = new Signed<RevocationList>(intCrl, intermediate);

              var admin = new AdminCertificate(Language.English, null, "Admin");
              admin.CreateSelfSignature();
              admin.AddSignature(intermediate, DateTime.Now.AddDays(1));

              var serverCert = new ServerCertificate("Server");
              serverCert.CreateSelfSignature();
              serverCert.AddSignature(intermediate, DateTime.Now.AddDays(1));

              VotingParameters parameters =
            new VotingParameters(
              new MultiLanguageString("Zufrieden"),
              new MultiLanguageString("Tada"),
              new MultiLanguageString(string.Empty),
              DateTime.Now,
              DateTime.Now.AddDays(1),
              0);
              parameters.GenerateNumbers(Files.TestDataPath);

              Question question = new Question(new MultiLanguageString("Zufrieden?"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty), 1);
              question.AddOption(new Option(new MultiLanguageString("Nein"), new MultiLanguageString("Dagegen"), new MultiLanguageString(string.Empty)));
              question.AddOption(new Option(new MultiLanguageString("Ja"), new MultiLanguageString("Dafür"), new MultiLanguageString(string.Empty)));
              parameters.AddQuestion(question);

              Signed<VotingParameters> signedParameters = new Signed<VotingParameters>(parameters, admin);

              DateTime start = DateTime.Now;
              Console.WriteLine();
              Console.Write("Voting begins...");

              CertificateStorage serverCertStorage = new CertificateStorage();
              serverCertStorage.AddRoot(root);
              serverCertStorage.Add(intermediate);
              serverCertStorage.AddRevocationList(sigRootCrl);
              serverCertStorage.AddRevocationList(sigIntCrl);

              VotingServerEntity vs = new VotingServerEntity(null, signedParameters, serverCertStorage, serverCert);

              var a1c = new AuthorityCertificate(Language.English, "Authority 1", null);
              a1c.CreateSelfSignature();
              a1c.AddSignature(intermediate, validUntil);
              var a2c = new AuthorityCertificate(Language.English, "Authority 2", null);
              a2c.CreateSelfSignature();
              a2c.AddSignature(intermediate, validUntil);
              var a3c = new AuthorityCertificate(Language.English, "Authority 3", null);
              a3c.CreateSelfSignature();
              a3c.AddSignature(intermediate, validUntil);
              var a4c = new AuthorityCertificate(Language.English, "Authority 4", null);
              a4c.CreateSelfSignature();
              a4c.AddSignature(intermediate, validUntil);
              var a5c = new AuthorityCertificate(Language.English, "Authority 5", null);
              a5c.CreateSelfSignature();
              a5c.AddSignature(intermediate, validUntil);

              var a1 = new AuthorityEntity(serverCertStorage, a1c);
              var a2 = new AuthorityEntity(serverCertStorage, a2c);
              var a3 = new AuthorityEntity(serverCertStorage, a3c);
              var a4 = new AuthorityEntity(serverCertStorage, a4c);
              var a5 = new AuthorityEntity(serverCertStorage, a5c);

              vs.AddAuthority(connection, a1.Certificate);
              vs.AddAuthority(connection, a2.Certificate);
              vs.AddAuthority(connection, a3.Certificate);
              vs.AddAuthority(connection, a4.Certificate);
              vs.AddAuthority(connection, a5.Certificate);

              a1.Prepare(1, vs.SignedParameters);
              a2.Prepare(2, vs.SignedParameters);
              a3.Prepare(3, vs.SignedParameters);
              a4.Prepare(4, vs.SignedParameters);
              a5.Prepare(5, vs.SignedParameters);

              a1.SetAuthorities(vs.AuthorityList);
              a2.SetAuthorities(vs.AuthorityList);
              a3.SetAuthorities(vs.AuthorityList);
              a4.SetAuthorities(vs.AuthorityList);
              a5.SetAuthorities(vs.AuthorityList);

              vs.DepositShares(connection, a1.GetShares());
              vs.DepositShares(connection, a2.GetShares());
              vs.DepositShares(connection, a3.GetShares());
              vs.DepositShares(connection, a4.GetShares());
              vs.DepositShares(connection, a5.GetShares());

              var r1 = a1.VerifyShares(vs.GetAllShares());
              var r2 = a2.VerifyShares(vs.GetAllShares());
              var r3 = a3.VerifyShares(vs.GetAllShares());
              var r4 = a4.VerifyShares(vs.GetAllShares());
              var r5 = a5.VerifyShares(vs.GetAllShares());

              vs.DepositShareResponse(connection, r1);
              vs.DepositShareResponse(connection, r2);
              vs.DepositShareResponse(connection, r3);
              vs.DepositShareResponse(connection, r4);
              vs.DepositShareResponse(connection, r5);

              var v1c = new VoterCertificate(Language.English, null, 0);
              v1c.CreateSelfSignature();
              v1c.AddSignature(intermediate, validUntil);

              var cs = new CertificateStorage();
              cs.AddRoot(root);
              var v1 = new VoterEntity(cs);

              IEnumerable<int> questionVota = new int[] { 0, 1 };

              var vote1 = v1.Vote(vs.GetVotingMaterial(), v1c, new IEnumerable<int>[] { questionVota }, null);

              vs.Vote(connection, vote1);

              int voters = 10;

              for (int i = 1000; i < 1000 + voters; i++)
              {
            var vc = new VoterCertificate(Language.English, null, 0);
            vc.CreateSelfSignature();
            vc.AddSignature(intermediate, validUntil);

            var vx = new VoterEntity(cs);

            IEnumerable<int> questionVota2 = new int[] { 0, 1 };
            var votex = vx.Vote(vs.GetVotingMaterial(), vc, new IEnumerable<int>[] { questionVota2 }, null);

            vs.Vote(connection, votex);
              }

              for (int i = 2000; i < 2000 + voters; i++)
              {
            var vc = new VoterCertificate(Language.English, null, 0);
            vc.CreateSelfSignature();
            vc.AddSignature(intermediate, validUntil);

            var vx = new VoterEntity(cs);

            IEnumerable<int> questionVota3 = new int[] { 1, 0 };
            var votex = vx.Vote(vs.GetVotingMaterial(), vc, new IEnumerable<int>[] { questionVota3 }, null);

            vs.Vote(connection, votex);
              }

              vs.EndVote();

              a1.TallyBegin(vs.GetVotingMaterial());
              a2.TallyBegin(vs.GetVotingMaterial());
              a3.TallyBegin(vs.GetVotingMaterial());
              a4.TallyBegin(vs.GetVotingMaterial());
              a5.TallyBegin(vs.GetVotingMaterial());

              for (int envelopeIndex = 0; envelopeIndex < vs.GetEnvelopeCount(); envelopeIndex++)
              {
            a1.TallyAdd(envelopeIndex, vs.GetEnvelope(envelopeIndex), new Progress(null));
            a2.TallyAdd(envelopeIndex, vs.GetEnvelope(envelopeIndex), new Progress(null));
            a3.TallyAdd(envelopeIndex, vs.GetEnvelope(envelopeIndex), new Progress(null));
            a4.TallyAdd(envelopeIndex, vs.GetEnvelope(envelopeIndex), new Progress(null));
            a5.TallyAdd(envelopeIndex, vs.GetEnvelope(envelopeIndex), new Progress(null));
              }

              var pd1 = a1.PartiallyDecipher();
              var pd2 = a2.PartiallyDecipher();
              var pd3 = a3.PartiallyDecipher();
              var pd4 = a4.PartiallyDecipher();
              var pd5 = a5.PartiallyDecipher();

              vs.DepositPartialDecipher(connection, pd1);
              vs.DepositPartialDecipher(connection, pd2);
              vs.DepositPartialDecipher(connection, pd3);
              vs.DepositPartialDecipher(connection, pd4);
              vs.DepositPartialDecipher(connection, pd5);

              v1.TallyBegin(vs.GetVotingMaterial(), BaseParameters.StandardProofCount);

              for (int envelopeIndex = 0; envelopeIndex < vs.GetEnvelopeCount(); envelopeIndex++)
              {
            v1.TallyAdd(envelopeIndex, vs.GetEnvelope(envelopeIndex), new Progress(null));
              }

              for (int authorityIndex = 1; authorityIndex < vs.Parameters.AuthorityCount + 1; authorityIndex++)
              {
            v1.TallyAddPartialDecipher(vs.GetPartialDecipher(authorityIndex));
              }

              var res1 = v1.TallyResult;

              TimeSpan duration = DateTime.Now.Subtract(start);
              Console.WriteLine("Succeded {0}", duration.ToString());
        }
Exemple #13
0
        private void TryLoadVoting()
        {
            string fileNameParameters = Path.Combine(Status.DataPath, SavedVotingParametersFileName);
              string fileNameAuthorities = Path.Combine(Status.DataPath, SavedVotingAuthoritiesFileName);

              if (File.Exists(fileNameParameters))
              {
            this.votingParameters = Serializable.Load<VotingParameters>(fileNameParameters);

            this.titleBox.Text = this.votingParameters.Title;
            this.descriptionBox.Text = this.votingParameters.Description;
            this.urlTextBox.Text = this.votingParameters.Url;
            this.votingFromPicker.Value = this.votingParameters.VotingBeginDate;
            this.votingUntilPicker.Value = this.votingParameters.VotingEndDate;
            this.groupComboBox.Value = Status.Groups.Where(group => group.Id == this.votingParameters.GroupId).FirstOrDefault();

            foreach (Question question in this.votingParameters.Questions)
            {
              Question newQuestion = new Question(question.Text, question.Description, question.Url, question.MaxVota);
              question.Options
            .Where(option => option.Text.Get(Language.English) != LibraryResources.OptionAbstainEnglish &&
                             option.Text.Get(Language.English) != LibraryResources.OptionAbstainSpecial)
            .Foreach(option => newQuestion.AddOption(option));

              ListViewItem item = new ListViewItem(question.Text.AllLanguages);
              item.SubItems.Add(question.Description.AllLanguages);
              item.Tag = newQuestion;
              this.questionListView.Items.Add(item);
            }
              }

              if (File.Exists(fileNameAuthorities))
              {
            VotingAuthoritiesFile authoritiesFile = Serializable.Load<VotingAuthoritiesFile>(fileNameAuthorities);

            if (this.authorityIndices[this.authority0List].ContainsKey(authoritiesFile.AuthorityIds.ElementAt(0)))
            {
              this.authority0List.SelectedIndex = this.authorityIndices[this.authority0List][authoritiesFile.AuthorityIds.ElementAt(0)];
            }

            if (this.authorityIndices[this.authority1List].ContainsKey(authoritiesFile.AuthorityIds.ElementAt(1)))
            {
              this.authority1List.SelectedIndex = this.authorityIndices[this.authority1List][authoritiesFile.AuthorityIds.ElementAt(1)];
            }

            if (this.authorityIndices[this.authority2List].ContainsKey(authoritiesFile.AuthorityIds.ElementAt(2)))
            {
              this.authority2List.SelectedIndex = this.authorityIndices[this.authority2List][authoritiesFile.AuthorityIds.ElementAt(2)];
            }

            if (this.authorityIndices[this.authority3List].ContainsKey(authoritiesFile.AuthorityIds.ElementAt(3)))
            {
              this.authority3List.SelectedIndex = this.authorityIndices[this.authority3List][authoritiesFile.AuthorityIds.ElementAt(3)];
            }

            if (this.authorityIndices[this.authority4List].ContainsKey(authoritiesFile.AuthorityIds.ElementAt(4)))
            {
              this.authority4List.SelectedIndex = this.authorityIndices[this.authority4List][authoritiesFile.AuthorityIds.ElementAt(4)];
            }
              }

              SetEnable(true);
        }
Exemple #14
0
        private void createButton_Click(object sender, EventArgs e)
        {
            this.run = true;
              OnUpdateWizard();
              SetEnable(false);

              this.votingParameters =
            new VotingParameters(
              this.titleBox.Text,
              this.descriptionBox.Text,
              this.urlTextBox.Text,
              this.votingFromPicker.Value.Date,
              this.votingUntilPicker.Value.Date,
              this.group.Id);

              Status.SetProgress(Resources.CreateVotingCreating, 0d);
              Application.DoEvents();

              foreach (ListViewItem item in this.questionListView.Items)
              {
            Question question = (Question)item.Tag;

            if (question.MaxVota == 1)
            {
              question.AddOption(Option.CreateAbstention());
            }
            else
            {
              for (int index = 0; index < question.MaxVota; index++)
              {
            question.AddOption(Option.CreateAbstentionSpecial());
              }
            }

            votingParameters.AddQuestion(question);
              }

              votingParameters.Save(Path.Combine(Status.DataPath, SavedVotingParametersFileName));

              List<AuthorityCertificate> authorities = new List<AuthorityCertificate>();
              authorities.Add(this.authorityCertificates[this.authority0List.SelectedIndex]);
              authorities.Add(this.authorityCertificates[this.authority1List.SelectedIndex]);
              authorities.Add(this.authorityCertificates[this.authority2List.SelectedIndex]);
              authorities.Add(this.authorityCertificates[this.authority3List.SelectedIndex]);
              authorities.Add(this.authorityCertificates[this.authority4List.SelectedIndex]);

              var invalidAuthorities = authorities
            .Where(authority => authority.Validate(Status.CertificateStorage, votingParameters.VotingBeginDate) != CertificateValidationResult.Valid);

              if (invalidAuthorities.Count() > 0)
              {
            StringBuilder message = new StringBuilder();
            message.AppendLine(Resources.CreateVotingInvalidAuthorities);
            invalidAuthorities.Foreach(authority => message.AppendLine(authority.Id.ToString() + " " + authority.FullName));
            MessageForm.Show(message.ToString(), GuiResources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
              }

              var authoritiesFile = new VotingAuthoritiesFile(authorities);
              authoritiesFile.Save(Path.Combine(Status.DataPath, SavedVotingAuthoritiesFileName));

              WaitForGeneration();

              if (this.votingParameters.Valid)
              {
            if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(Status.Certificate, GuiResources.UnlockActionCreateVoting))
            {
              Signed<VotingParameters> signedVotingParameters = new Signed<VotingParameters>(votingParameters, Status.Certificate);

              Status.VotingClient.CreateVoting(signedVotingParameters, authorities, CreateVotingCompleted);

              while (this.run)
              {
            Application.DoEvents();
            Thread.Sleep(10);
              }

              if (this.exception == null)
              {
            Status.SetMessage(Resources.CreateVotingCreated, MessageType.Success);
              }
              else
              {
            Status.SetMessage(this.exception.Message, MessageType.Error);
              }

              Status.Certificate.Lock();
            }
            else
            {
              Status.SetMessage(Resources.CreateVotingCanceled, MessageType.Info);
            }
              }
              else
              {
            Status.SetMessage(Resources.CreateVotingCanceled, MessageType.Info);
              }

              Application.DoEvents();

              this.done = true;
              OnUpdateWizard();
        }