package meerkat.mixer;

import meerkat.crypto.concrete.ECElGamalEncryption;
import meerkat.crypto.concrete.Util;
import meerkat.protobuf.ConcreteCrypto;
import org.factcenter.qilin.primitives.RandomOracle;
import org.factcenter.qilin.primitives.concrete.DigestOracle;
import org.factcenter.qilin.primitives.concrete.ECElGamal;
import org.factcenter.qilin.primitives.concrete.ECGroup;

import java.math.BigInteger;
import java.security.spec.InvalidKeySpecException;
import java.util.Random;

/**
 * Base class with common parameters.
 */
public class ECParamTestBase {

    public Random rand;
    public ECElGamal.SK key;
    public ECGroup group;
    public ECElGamalEncryption enc;
    public ConcreteCrypto.ElGamalPublicKey serializedPk;

    public ECParamTestBase()  {
        rand = new Random(1);
        group = new ECGroup("secp256k1");
        BigInteger sk = ECElGamal.generateSecretKey(group, rand);
        key = new ECElGamal.SK(group, sk);
        serializedPk = Util.encodePK(group, key);
        enc = new ECElGamalEncryption();
        try {
            enc.init(serializedPk);
        } catch (InvalidKeySpecException e) {
            e.printStackTrace();
            assert(false);
        }
    }
}
