package meerkat.voting;

import static meerkat.protobuf.Voting.*;

/**
 * Created by talm on 25/10/15.
 */
public interface VotingBooth {

    public interface UI {
        /**
         * Prepare UI for a new user.
         */
        void votingBegin();

        /**
         * UI must physically commit to an encrypted (or Wombat style) ballot.
         * (probably by printing)
         *
         * When commitment is complete, should ask voter to choose between
         * cast and audit.
         *
         * Called by votingbooth thread.
         */
        void commitToEncryptedBallot(EncryptedBallot ballot);


        /**
         * Finalize a vote for casting
         * Called by votingbooth in case user decides to cast.
         */
        void castVote();

        /**
         * Submit audit information and spoil vote.
         * Called by votingbooth in case user decides to audit
         * @param ballotSecrets
         */
        void auditVote(BallotSecrets ballotSecrets);


    }

    /**
     * Must be called before using any other method.
     * @param globalParams global election parameters (e.g., global signing key, global encryption key)
     * @param boothParams local parameters (e.g., private signature key for booth, randomness table?)
     */
    void init(ElectionParams globalParams, BoothParams boothParams);


    /**
     * Called from UI thread when voter has finished making selection.
     *
     * Should encrypt ballot and commit.
     * @param ballot
     */
    void submitBallot(PlaintextBallot ballot);

    /**
     * UI calls this when the user cancels the voting process in the middle.
     */
    void cancelBallot();

    /**
     * Called by UI thread after voter made choice to cast or audit ballot.
     * @param castVote
     */
    void voterCastOrAudit(boolean castVote);
}
