ch.openchvote.electionauthority.plain.tasks.TE1 Maven / Gradle / Ivy
/*
* 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.plain.tasks;
import ch.openchvote.algorithms.AlgorithmService;
import ch.openchvote.algorithms.protocols.plain.algorithms.CheckKeyPairProof;
import ch.openchvote.electionauthority.plain.PublicData;
import ch.openchvote.framework.exceptions.TaskException;
import ch.openchvote.protocol.parameters.SecurityParameters;
@SuppressWarnings("MissingJavadoc")
public final class TE1 {
static public void
run(int k, PublicData publicData) {
// get algorithm service
var algorithmService = AlgorithmService.load();
// select setup parameters
var ES = publicData.get_ES().get();
var SL = ES.get_SL();
// get security parameters
var securityParameters = new SecurityParameters(SL);
// select event data
var pi_k = publicData.get_bold_pi().get(k);
var pk_k = publicData.get_bold_pk().get(k);
// perform task
if (!algorithmService.run(CheckKeyPairProof.class, securityParameters, pi_k, pk_k)) {
throw new TaskException(TaskException.Type.INVALID_ZKP_PROOF, TE1.class);
}
}
}