ch.openchvote.inspectionclient.plain.tasks.TI1 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of inspection-client Show documentation
Show all versions of inspection-client Show documentation
This module implements the 'verification client' party of the CHVote protocol.
The newest version!
/*
* 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.inspectionclient.plain.tasks;
import ch.openchvote.algorithms.AlgorithmService;
import ch.openchvote.algorithms.protocols.common.algorithms.GetInspectionCode;
import ch.openchvote.inspectionclient.plain.PublicData;
import ch.openchvote.protocol.protocols.plain.UsabilityParameters;
import ch.openchvote.utilities.sequence.Vector;
import ch.openchvote.utilities.set.IntSet;
@SuppressWarnings("MissingJavadoc")
public final class TI1 {
static public boolean isReady(PublicData publicData) {
var s = publicData.get_ES().get().get_SP().get_s();
return publicData.get_bold_i().arePresent(IntSet.range(1, s));
}
static public void
run(PublicData publicData, AlgorithmService algorithmService) {
// get usability parameters
var ES = publicData.get_ES().get();
var SL = ES.get_SL();
var UC = ES.get_UC();
var usabilityParameters = new UsabilityParameters(UC, SL);
// perform task
var bold_i = publicData.get_bold_i().mapTo(Vector::of);
var IC = algorithmService.run(GetInspectionCode.class, usabilityParameters, bold_i);
// update event data
publicData.get_IC().set(IC);
}
}