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

ch.openchvote.electionauthority.writein.tasks.TE6 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.writein.tasks;

import ch.openchvote.algorithms.AlgorithmService;
import ch.openchvote.algorithms.protocols.common.algorithms.GetPublicCredentials;
import ch.openchvote.electionauthority.writein.PublicData;
import ch.openchvote.protocol.parameters.SecurityParameters;
import ch.openchvote.utilities.sequence.Matrix;
import ch.openchvote.utilities.set.IntSet;

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

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

    static public void
    run(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);

        // perform task
        var bold_X_hat = publicData.get_bold_X_hat().mapTo(Matrix::ofCols);
        var bold_Y_hat = publicData.get_bold_Y_hat().mapTo(Matrix::ofCols);
        var bold_Z_hat = publicData.get_bold_Z_hat().mapTo(Matrix::ofCols);
        var publicCredenitals = algorithmService.run(GetPublicCredentials.class, securityParameters, bold_X_hat, bold_Y_hat, bold_Z_hat);
        var bold_x_hat = publicCredenitals.get_bold_x_hat();
        var bold_y_hat = publicCredenitals.get_bold_y_hat();
        var bold_z_hat = publicCredenitals.get_bold_z_hat();

        // update event data
        publicData.get_bold_x_hat().set(bold_x_hat);
        publicData.get_bold_y_hat().set(bold_y_hat);
        publicData.get_bold_z_hat().set(bold_z_hat);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy