package profiling.BigInteger; import com.google.protobuf.InvalidProtocolBufferException; import meerkat.crypto.concrete.ECElGamalEncryption; import meerkat.protobuf.ConcreteCrypto; import mixer.Utiles; import org.junit.Before; import org.junit.Test; import qilin.primitives.concrete.ECElGamal; import qilin.primitives.concrete.ECGroup; import java.math.BigInteger; import java.util.Random; /** * Created by Tzlil on 1/25/2016. */ public class GenerateRandomness { int tests; ECElGamalEncryption enc; Random rand; @Before public void setup() throws Exception { rand = new Random(); ECGroup group = new ECGroup("secp256k1"); tests = 1<<18; BigInteger sk = ECElGamal.generateSecretKey(group, rand); ECElGamal.SK key = new ECElGamal.SK(group, sk); ConcreteCrypto.ElGamalPublicKey serializedPk = Utiles.serializePk(group, key); enc = new ECElGamalEncryption(); enc.init(serializedPk); } @Test public void GenerateRandomnessProfiling() throws InvalidProtocolBufferException { System.out.println("GenerateRandomnessProfiling"); System.out.println("#" + tests + " tests"); long startTime = System.currentTimeMillis(); for (int i =0 ; i < tests ; i++){ enc.generateRandomness(rand).getData().toByteArray(); } long finishTime = System.currentTimeMillis(); System.out.println(" that took: "+(finishTime-startTime)+ " ms"); System.out.println(" avg of "+((double)(finishTime-startTime))/tests + " ms"); } }