Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2024 Berner Fachhochschule https://e-voting.bfh.ch
*
* - This program is free software: you can redistribute it and/or modify -
* - it under the terms of the GNU Affero General Public License as published by -
* - the Free Software Foundation, either version 3 of the License, or -
* - (at your option) any later version. -
* - -
* - This program is distributed in the hope that it will be useful, -
* - but WITHOUT ANY WARRANTY; without even the implied warranty of -
* - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -
* - GNU General Public License for more details. -
* - -
* - You should have received a copy of the GNU Affero General Public License -
* - along with this program. If not, see . -
*/
package ch.openchvote.electionauthority.writein.tasks;
import ch.openchvote.algorithms.AlgorithmService;
import ch.openchvote.algorithms.protocols.common.algorithms.GenResponse;
import ch.openchvote.algorithms.protocols.common.model.Response;
import ch.openchvote.algorithms.protocols.writein.algorithms.CheckBallot;
import ch.openchvote.algorithms.protocols.writein.algorithms.GetVotingParameters;
import ch.openchvote.algorithms.protocols.writein.model.Ballot;
import ch.openchvote.algorithms.protocols.writein.model.VotingParametersWriteIn;
import ch.openchvote.electionauthority.writein.PublicData;
import ch.openchvote.framework.exceptions.TaskException;
import ch.openchvote.protocol.parameters.SecurityParameters;
import ch.openchvote.protocol.protocols.writein.UsabilityParameters;
import ch.openchvote.utilities.tuples.Pair;
@SuppressWarnings("MissingJavadoc")
public final class TE8 {
static public Pair
run(int v, Ballot alpha, PublicData publicData) {
// get algorithm service
var algorithmService = AlgorithmService.load();
// select setup parameters
var ES = publicData.get_ES().get();
var SL = ES.get_SL();
var UC = ES.get_UC();
// get security and usability parameters
var securityParameters = new SecurityParameters(SL);
var usabilityParameters = new UsabilityParameters(UC, SL);
// select election parameters
var EP = publicData.get_EP().get();
var bold_u = EP.get_bold_u();
var bold_n = EP.get_bold_n();
var bold_k = EP.get_bold_k();
var bold_E = EP.get_bold_E();
var bold_z = EP.get_bold_z();
var bold_v = EP.get_bold_v();
// select event data
var pk = publicData.get_pk().get();
var bold_pk_prime = publicData.get_bold_pk_prime().get();
var bold_x_hat = publicData.get_bold_x_hat().get();
var bold_P_j = publicData.get_bold_P_j().get();
var B_j = publicData.get_B_j();
var F_j = publicData.get_F_j();
// perform task
if (!algorithmService.run(CheckBallot.class, securityParameters, usabilityParameters, v, alpha, pk, bold_pk_prime, bold_u, bold_n, bold_k, bold_E, bold_v, bold_z, bold_x_hat)) {
throw new TaskException(TaskException.Type.INVALID_BALLOT, TE8.class);
}
var bold_a = alpha.get_bold_a();
var pair = algorithmService.run(GenResponse.class, securityParameters, v, bold_a, pk, bold_u, bold_n, bold_k, bold_E, bold_P_j);
var beta_j = pair.getFirst();
var delta_j = pair.getSecond();
var VP_v = algorithmService.run(GetVotingParameters.class, v, EP);
if (B_j.isPresent(v)) {
throw new TaskException(TaskException.Type.DUPLICATE_BALLOT, TE8.class);
}
B_j.set(v, alpha);
F_j.set(v, delta_j);
// return data
return new Pair<>(VP_v, beta_j);
}
}