ch.openchvote.votingclient.writein.SecretData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of voting-client Show documentation
Show all versions of voting-client Show documentation
This module implements the 'voting client' party of the CHVote protocol.
/*
* 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.writein;
import ch.openchvote.framework.party.EventData;
import ch.openchvote.algorithms.protocols.writein.model.WriteIn;
import ch.openchvote.protocol.protocols.writein.content.userinterface.input.UVC2;
import ch.openchvote.protocol.protocols.writein.content.userinterface.input.UVC3;
import ch.openchvote.utilities.sequence.IntVector;
import ch.openchvote.utilities.sequence.Vector;
import ch.openchvote.utilities.tuples.Quintuple;
import ch.openchvote.utilities.tuples.Tuple;
import java.math.BigInteger;
/**
* Instances of this class represent the voting client's secret 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 SecretData extends Quintuple<
// ballot
EventData.Data, // X_v
EventData.Data, // bold_s
EventData.Data>, // bold_s_prime
EventData.Data>, // bold_r
// confirmation
EventData.Data> // Y_v
implements EventData {
public SecretData() {
this(new Data<>(), new Data<>(), new Data<>(), new Data<>(), new Data<>());
}
// private constructor for initializing all fields
private SecretData(Data X_v, Data bold_s, Data> bold_s_prime, Data> bold_r, Data Y_v) {
super(X_v, bold_s, bold_s_prime, bold_r, Y_v);
}
// private copy constructor
@SuppressWarnings("unused")
private SecretData(SecretData secretData) {
this(secretData.get_X_v(), secretData.get_bold_s(), secretData.get_bold_s_prime(), secretData.get_bold_r(), secretData.get_Y_v());
}
public Data get_X_v() {
return this.getFirst();
}
public Data get_bold_s() {
return this.getSecond();
}
public Data> get_bold_s_prime() {
return this.getThird();
}
public Data> get_bold_r() {
return this.getFourth();
}
public Data get_Y_v() {
return this.getFifth();
}
/**
* Calling this method stores the given content of type {@link UVC2} into the election authority's secret data.
*
* @param content The given content
*/
public void setContent(UVC2 content) {
this.get_X_v().set(content.get_X());
this.get_bold_s().set(content.get_bold_s());
this.get_bold_s_prime().set(content.get_bold_s_prime());
}
/**
* Calling this method stores the given content of type {@link UVC3} into the election authority's secret data.
*
* @param content The given content
*/
public void setContent(UVC3 content) {
this.get_Y_v().set(content.get_Y());
}
}