All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.openchvote.votingclient.plain.tasks.TC4 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.votingclient.plain.tasks;

import ch.openchvote.algorithms.AlgorithmService;
import ch.openchvote.algorithms.protocols.common.algorithms.GetPointMatrix;
import ch.openchvote.algorithms.protocols.common.algorithms.GetVerificationCodes;
import ch.openchvote.protocol.parameters.SecurityParameters;
import ch.openchvote.protocol.protocols.plain.UsabilityParameters;
import ch.openchvote.utilities.sequence.Vector;
import ch.openchvote.utilities.set.IntSet;
import ch.openchvote.votingclient.plain.PublicData;
import ch.openchvote.votingclient.plain.SecretData;

@SuppressWarnings("MissingJavadoc")
public final class TC4 {

    static public boolean isReady(PublicData publicData) {
        var s = publicData.get_ES().get().get_SP().get_s();
        return publicData.get_bold_beta().arePresent(IntSet.range(1, s));
    }

    static public void
    run(PublicData publicData, SecretData secretData, AlgorithmService algorithmService) {

        // 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 event data
        var bold_n = publicData.get_VP_v().get().get_bold_n();
        var bold_s = secretData.get_bold_s().get();
        var bold_r = secretData.get_bold_r().get();

        // perform task
        var bold_beta = publicData.get_bold_beta().mapTo(Vector::of);
        var bold_P = algorithmService.run(GetPointMatrix.class, securityParameters, bold_n, bold_beta, bold_s, bold_r);
        var bold_vc = algorithmService.run(GetVerificationCodes.class, securityParameters, usabilityParameters, bold_s, bold_P);

        // update event data
        publicData.get_bold_P().set(bold_P);
        publicData.get_bold_vc().set(bold_vc);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy