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

ch.openchvote.electionauthority.plain.tasks.TE3 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.common.algorithms.GetPublicKey;
import ch.openchvote.electionauthority.plain.PublicData;
import ch.openchvote.protocol.parameters.SecurityParameters;
import ch.openchvote.utilities.sequence.Vector;
import ch.openchvote.utilities.set.IntSet;

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

    static public boolean isReady(PublicData publicData) {
        var s = publicData.get_ES().get().get_SP().get_s();
        return publicData.get_bold_pk().arePresent(IntSet.range(0, 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_pk = publicData.get_bold_pk().mapTo(Vector::of);
        var pk = algorithmService.run(GetPublicKey.class, securityParameters, bold_pk);

        // update event data
        publicData.get_pk().set(pk);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy