PedersenEqRangeProof implements Serializable { public long getSize() { return Ealpha.toByteArray().length + Ebeta.toByteArray().length + (S1.getX().toByteArray().length + 1) + z1.toByteArray().length + z2.toByteArray().length + e1.toByteArray().length + e2.toByteArray().length; } PedersenEqRangeProof(final BigInteger Ealpha, BigInteger Ebeta, final EcPoint S1, final BigInteger z1,
			final BigInteger z2, final BigInteger e1, BigInteger e2); BigInteger getEalpha(); BigInteger getEbeta(); EcPoint getS1(); BigInteger getZ1(); BigInteger getZ2(); BigInteger getE1(); BigInteger getE2(); @Override String toString(); long getSize(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testProofPerformance() { final PaillierKeyGenerator keyGenerator = new PaillierKeyGenerator(2048); final PaillierKeyPair keyPair = keyGenerator.generate(); final PaillierPublicKey publicKey = keyPair.getPublicKey(); final BigInteger share1 = RandomNumberGenerator.generateRandomInteger(curve.getR()); final BigInteger share2 = RandomNumberGenerator.generateRandomInteger(curve.getR()); final BigInteger n = publicKey.getN(); final BigInteger r1 = RandomNumberGenerator.generateRandomCoprimeInRange(n); final BigInteger Ea = PaillierCipher.encrypt(publicKey, share1, r1); final BigInteger r2 = RandomNumberGenerator.generateRandomCoprimeInRange(n); final BigInteger Eb = PaillierCipher.encrypt(publicKey, share2, r2); final EcPoint S = curve.addPoints(curve.multiply(g, share1), curve.multiply(h, share2)); PedersenEqRangeProof proof = null; for (int i = 0; i < 20; i++) { proof = PedersenEqRangeProofGenerator.generate(publicKey, share1, share2, r1, r2, Ea, Eb, S); } System.out.println("ZKP size: " + proof.getSize()); long timeNs = 0; final int iterations = 1000; for (int i = 0; i < iterations; i++) { final long start = System.nanoTime(); proof = PedersenEqRangeProofGenerator.generate(publicKey, share1, share2, r1, r2, Ea, Eb, S); final long end = System.nanoTime(); timeNs += (end - start); } System.out.println("Total time (ms): " + timeNs / (((long) iterations) * 1_000_000.0)); }
@Test public void testVerifyPerformance() { final PaillierKeyGenerator keyGenerator = new PaillierKeyGenerator(2048); final PaillierKeyPair keyPair = keyGenerator.generate(); final PaillierPublicKey publicKey = keyPair.getPublicKey(); final BigInteger share1 = RandomNumberGenerator.generateRandomInteger(curve.getR()); final BigInteger share2 = RandomNumberGenerator.generateRandomInteger(curve.getR()); final BigInteger n = publicKey.getN(); final BigInteger r1 = RandomNumberGenerator.generateRandomCoprimeInRange(n); final BigInteger Ea = PaillierCipher.encrypt(publicKey, share1, r1); final BigInteger r2 = RandomNumberGenerator.generateRandomCoprimeInRange(n); final BigInteger Eb = PaillierCipher.encrypt(publicKey, share2, r2); final EcPoint S = curve.addPoints(curve.multiply(g, share1), curve.multiply(h, share2)); PedersenEqRangeProof proof = null; for (int i = 0; i < 20; i++) { proof = PedersenEqRangeProofGenerator.generate(publicKey, share1, share2, r1, r2, Ea, Eb, S); } System.out.println("ZKP size: " + proof.getSize()); long timeNs = 0; final int iterations = 1000; for (int i = 0; i < iterations; i++) { proof = PedersenEqRangeProofGenerator.generate(publicKey, share1, share2, r1, r2, Ea, Eb, S); final long start = System.nanoTime(); PedersenEqRangeProofVerifier.isValid(proof, Ea, Eb, S, publicKey); final long end = System.nanoTime(); timeNs += (end - start); } System.out.println("Total time (ms): " + timeNs / (((long) iterations) * 1_000_000.0)); }