package meerkat.voting.encryptor;

import meerkat.protobuf.Voting.*;

import java.io.IOException;
import java.security.SignatureException;

/**
 * An interface for the encryptor component of the voting booth
 * It handles both the encryption and the digital signature
 */
public interface VBCryptoManager {
    /**
     * A simple class for pairing EncrypedBallot together with its matching BallotSecrets
     */
    public class EncryptionAndSecrets {
        private final SignedEncryptedBallot signedEncryptedBallot;
        private final BallotSecrets secrets;

        public EncryptionAndSecrets (SignedEncryptedBallot encryptedBallot, BallotSecrets secrets) {
            this.signedEncryptedBallot = encryptedBallot;
            this.secrets = secrets;
        }

        public SignedEncryptedBallot getSignedEncryptedBallot()  {
            return signedEncryptedBallot;
        }

        public BallotSecrets getSecrets()  {
            return secrets;
        }
    }


    /**
     * This function encrypts the plaintext ballot using the booth's keys
     * @param plaintextBallot - all plaintext ballot info of the voter
     * @return an encryption of the ballot
     */
    // TODO: do we seed the random here?
    public EncryptionAndSecrets encrypt (PlaintextBallot plaintextBallot) throws SignatureException, IOException;


}
