ZeroKnowledgeProver { public static ZeroKnowledgeProof createProof(final BigInteger a0, final BigInteger b0) { final EcPoint A0 = curve.multiply(g, a0); final EcPoint B0 = curve.multiply(h, b0); final BigInteger r1 = RandomNumberGenerator.generateRandomInteger(curve.getR()); final BigInteger r2 = RandomNumberGenerator.generateRandomInteger(curve.getR()); final EcPoint p1 = curve.multiply(g, r1); final EcPoint p2 = curve.multiply(h, r2); final EcPoint sum = curve.addPoints(p1, p2); final byte[] input = Parse.concatenate(g, h, sum); final MessageDigest digest; try { digest = MessageDigest.getInstance(HASH_ALGORITHM); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("Should not happen"); } final BigInteger c = new BigInteger(1, digest.digest(input)).mod(curve.getR()); final BigInteger sa = (r1.subtract(c.multiply(a0))).mod(curve.getR()); final BigInteger sb = (r2.subtract(c.multiply(b0))).mod(curve.getR()); return new ZeroKnowledgeProof(A0, B0, c, sa, sb); }  static ZeroKnowledgeProof createProof(final BigInteger a0, final BigInteger b0); static boolean verifyProof(final EcPoint C0, final ZeroKnowledgeProof proof); static final EcCurve curve; static final EcPoint g; static final EcPoint h; static final String HASH_ALGORITHM; }
@Test public void testCreateProof() { fail("Not yet implemented"); }
@Test public void testProofPerformance() { final EcCurve curve = CommonConfiguration.CURVE; final BigInteger a0 = RandomNumberGenerator.generateRandomInteger(curve.getR()); final BigInteger b0 = RandomNumberGenerator.generateRandomInteger(curve.getR()); ZeroKnowledgeProof zkp = null; for (int i = 0; i < 20; i++) { zkp = ZeroKnowledgeProver.createProof(a0, b0); } int length = (zkp.getA0().getX().toByteArray().length + 1) + (zkp.getB0().getX().toByteArray().length + 1) + zkp.getC().toByteArray().length + zkp.getSa().toByteArray().length + zkp.getSb().toByteArray().length; System.out.println("size: " + length); long timeNs = 0; final int iterations = 1000; for (int i = 0; i < iterations; i++) { final BigInteger a = RandomNumberGenerator.generateRandomInteger(curve.getR()); final BigInteger b = RandomNumberGenerator.generateRandomInteger(curve.getR()); final long start = System.nanoTime(); ZeroKnowledgeProver.createProof(a, b); final long end = System.nanoTime(); timeNs += (end - start); } System.out.println("Total time (ms): " + timeNs / (((long)iterations) * 1_000_000.0)); }