package meerkat.mixer;

import com.google.protobuf.ByteString;
import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import meerkat.crypto.concrete.ECElGamalEncryption;
import meerkat.crypto.concrete.GlobalCryptoSetup;
import meerkat.protobuf.ConcreteCrypto;
import meerkat.protobuf.Crypto;
import meerkat.protobuf.Voting;
import org.spongycastle.jce.spec.ECParameterSpec;
import org.spongycastle.jce.spec.ECPublicKeySpec;
import org.spongycastle.math.ec.ECPoint;
import org.factcenter.qilin.primitives.concrete.ECElGamal;
import org.factcenter.qilin.primitives.concrete.ECGroup;
import org.factcenter.qilin.primitives.generic.ElGamal;
import org.factcenter.qilin.util.Pair;

import java.io.ByteArrayInputStream;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.util.Random;

/**
 * Created by Tzlil on 1/1/2016.
 */
public class Utils {
    static Random random = new Random(0);

    public static Voting.PlaintextBallot genRandomBallot(int numQuestions, int numAnswers, int maxAnswer) {
        Voting.PlaintextBallot.Builder ballot = Voting.PlaintextBallot.newBuilder();
        ballot.setSerialNumber(random.nextInt(1000000));
        for (int i = 0; i < numQuestions; ++i) {
            Voting.BallotAnswer.Builder answers = ballot.addAnswersBuilder();
            for (int j = 0; j < numAnswers; ++j) {
                answers.addAnswer(random.nextInt(maxAnswer));
            }
        }
        return ballot.build();
    }
}
