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.votingclient.plain;
import ch.openchvote.algorithms.protocols.common.model.*;
import ch.openchvote.framework.party.EventData;
import ch.openchvote.algorithms.protocols.plain.model.Ballot;
import ch.openchvote.algorithms.protocols.plain.model.KeyPairProof;
import ch.openchvote.algorithms.protocols.plain.model.VotingParametersPlain;
import ch.openchvote.protocol.protocols.plain.content.requestresponse.response.RAC1;
import ch.openchvote.protocol.protocols.plain.content.requestresponse.response.REC1;
import ch.openchvote.protocol.protocols.plain.content.requestresponse.response.REC2;
import ch.openchvote.protocol.protocols.plain.content.requestresponse.response.REC3;
import ch.openchvote.protocol.protocols.plain.content.userinterface.input.UVC1;
import ch.openchvote.utilities.sequence.Matrix;
import ch.openchvote.utilities.sequence.Vector;
import ch.openchvote.utilities.tuples.Tuple;
import ch.openchvote.utilities.tuples.decuple.QuattuorDecuple;
import java.math.BigInteger;
/**
* Instances of this class represent the voting client's public data. The class inherits from the generic {@link Tuple}
* subclass, that matches with the number of {@link EventData.Data} and {@link EventData.DataMap} objects to store.
* Convenience methods for accessing the fields with names as specified by the CHVote protocol are provided.
*/
@SuppressWarnings("MissingJavadoc")
public final class PublicData extends QuattuorDecuple<
// the administrator's id
EventData.Data, // AD
// voter index
EventData.Data, // v
// event setup and voting parameters
EventData.Data, // ES
EventData.Data, // VP_v
// public keys
EventData.DataMap, // bold_pk
EventData.Data, // pk
EventData.DataMap, // bold_pi
// ballot, response, participation code
EventData.Data, // alpha
EventData.DataMap, // bold_beta
EventData.Data>, // bold_P
EventData.Data>, // bold_vc
// confirmation, finalization, participation code
EventData.Data, // gamma
EventData.DataMap, // bold_delta
EventData.Data> // PC
implements EventData {
public PublicData() {
this(new Data<>(), new Data<>(), new Data<>(), new Data<>(), new DataMap<>(), new Data<>(), new DataMap<>(), new Data<>(), new DataMap<>(), new Data<>(), new Data<>(), new Data<>(), new DataMap<>(), new Data<>());
}
// private constructor for initializing all fields
private PublicData(Data AD, Data v, Data ES, Data VP_v, DataMap bold_pk, Data pk, DataMap bold_pi, Data alpha, DataMap bold_beta, Data> bold_P, Data> bold_vc, Data gamma, DataMap bold_delta, Data PC) {
super(AD, v, ES, VP_v, bold_pk, pk, bold_pi, alpha, bold_beta, bold_P, bold_vc, gamma, bold_delta, PC);
}
// private copy constructor
@SuppressWarnings("unused")
private PublicData(PublicData publicData) {
this(publicData.get_AD(), publicData.get_v(), publicData.get_ES(), publicData.get_VP_v(), publicData.get_bold_pk(), publicData.get_pk(), publicData.get_bold_pi(), publicData.get_alpha(), publicData.get_bold_beta(), publicData.get_bold_P(), publicData.get_bold_vc(), publicData.get_gamma(), publicData.get_bold_delta(), publicData.get_PC());
}
public Data get_AD() {
return this.getFirst();
}
public Data get_v() {
return this.getSecond();
}
public Data get_ES() {
return this.getThird();
}
public Data get_VP_v() {
return this.getFourth();
}
public DataMap get_bold_pk() {
return this.getFifth();
}
public Data get_pk() {
return this.getSixth();
}
public DataMap get_bold_pi() {
return this.getSeventh();
}
public Data get_alpha() {
return this.getEighth();
}
public DataMap get_bold_beta() {
return this.getNinth();
}
public Data> get_bold_P() {
return this.getTenth();
}
public Data> get_bold_vc() {
return this.getEleventh();
}
public Data get_gamma() {
return this.getTwelfth();
}
public DataMap get_bold_delta() {
return this.getThirteenth();
}
public Data get_PC() {
return this.getFourteenth();
}
/**
* Calling this method stores the given content of type {@link RAC1} into the voting client's public data.
*
* @param content The given content
*/
public void setContent(RAC1 content) {
this.get_ES().set(content.get_ES());
this.get_VP_v().set(content.get_VP());
this.get_bold_pk().set(0, content.get_pk());
this.get_bold_pi().set(0, content.get_pi());
}
/**
* Calling this method stores the given content of type {@link REC1} into the voting client's public data.
*
* @param index The index of the received content
* @param content The given content
*/
public void setContent(int index, REC1 content) {
this.get_bold_pk().set(index, content.get_pk());
this.get_bold_pi().set(index, content.get_pi());
}
/**
* Calling this method stores the given content of type {@link REC2} into the voting client's public data.
*
* @param index The index of the received content
* @param content The given content
*/
public void setContent(int index, REC2 content) {
this.get_bold_beta().set(index, content.get_beta());
}
/**
* Calling this method stores the given content of type {@link REC3} into the voting client's public data.
*
* @param index The index of the received content
* @param content The given content
*/
public void setContent(int index, REC3 content) {
this.get_bold_delta().set(index, content.get_delta());
}
/**
* Calling this method stores the given content of type {@link UVC1} into the voting client's public data.
*
* @param content The given content
*/
public void setContent(UVC1 content) {
this.get_AD().set(content.get_AD());
this.get_v().set(content.get_v());
}
}