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

ch.openchvote.electionauthority.plain.tasks.TE11 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.GenShuffle;
import ch.openchvote.algorithms.protocols.plain.algorithms.GenShuffleProof;
import ch.openchvote.electionauthority.plain.PublicData;
import ch.openchvote.protocol.parameters.SecurityParameters;

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

    static public boolean isReady(PublicData publicData, int j) {
        return publicData.get_bold_E_tilde().isPresent(j - 1);
    }

    static public void
    run(int j, 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 pk = publicData.get_pk().get();
        var bold_e_tilde_j_minus_1 = publicData.get_bold_E_tilde().get(j - 1);

        // perform task
        var triple = algorithmService.run(GenShuffle.class, securityParameters, bold_e_tilde_j_minus_1, pk);
        var bold_e_tilde_j = triple.getFirst();
        var bold_r_tilde_j = triple.getSecond();
        var psi_j = triple.getThird();
        var pi_tilde_j = algorithmService.run(GenShuffleProof.class, securityParameters, bold_e_tilde_j_minus_1, bold_e_tilde_j, bold_r_tilde_j, psi_j, pk);

        // update event data
        publicData.get_bold_E_tilde().set(j, bold_e_tilde_j);
        publicData.get_bold_pi_tilde().set(j, pi_tilde_j);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy