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

ch.openchvote.voter.writein.states.S700 Maven / Gradle / Ivy

The newest version!
/*
 * 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.voter.writein.states;

import ch.openchvote.framework.annotations.state.Notify;
import ch.openchvote.framework.annotations.state.Phase;
import ch.openchvote.framework.communication.Status;
import ch.openchvote.framework.party.State;
import ch.openchvote.protocol.phases.Testing;
import ch.openchvote.protocol.protocols.writein.content.testdata.TVT1;
import ch.openchvote.protocol.protocols.writein.content.testdata.TVT2;
import ch.openchvote.voter.Voter;
import ch.openchvote.voter.writein.EventContext;

@SuppressWarnings("MissingJavadoc")
@Phase(Testing.class)
@Notify(Status.Type.READY)
public final class S700 extends State {

    public S700(Voter voter, EventContext eventContext) {
        super(voter, eventContext);
    }

    @SuppressWarnings("unused")
    @Override
    public void handleStart() {

        // decompose event context
        var eventId = this.eventContext.getEventId();
        var secretData = this.eventContext.getSecretData();

        // select event data
        var pb = secretData.get_pb().get();
        var EC_v = secretData.get_EC_v().get();
        var v = EC_v.get_v();

        // provide test data
        if (pb == 1) {
            var bold_s = secretData.get_bold_s().get();
            var bold_s_prime = secretData.get_bold_s_prime().get();
            this.party.sendTestData(eventId, new TVT1(v, bold_s, bold_s_prime));
        } else {
            this.party.sendTestData(eventId, new TVT2(v));
        }

        // update state
        this.party.updateState(this.eventContext, FINAL.class);

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy