FeldmanEqRangeProof implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; FeldmanEqRangeProof other = (FeldmanEqRangeProof) obj; if (E1 == null) { if (other.E1 != null) return false; } else if (!E1.equals(other.E1)) return false; if (S1 == null) { if (other.S1 != null) return false; } else if (!S1.equals(other.S1)) return false; if (z == null) { if (other.z != null) return false; } else if (!z.equals(other.z)) return false; if (z1 == null) { if (other.z1 != null) return false; } else if (!z1.equals(other.z1)) return false; if (z2 == null) { if (other.z2 != null) return false; } else if (!z2.equals(other.z2)) return false; return true; } FeldmanEqRangeProof(final BigInteger E1, final EcPoint S1, final BigInteger z, final BigInteger z1,
			final BigInteger z2); @Override String toString(); BigInteger getE1(); EcPoint getS1(); BigInteger getZ(); BigInteger getZ1(); BigInteger getZ2(); @Override int hashCode(); @Override boolean equals(Object obj); long getSize();  }
@Test public void testAll() { System.out.println("Generating key..."); final PaillierKeyGenerator keyGenerator = new PaillierKeyGenerator(2048); long s1 = System.nanoTime(); final PaillierKeyPair keyPair = keyGenerator.generate(); long e1 = System.nanoTime(); System.out.println("Done. Took: " + ((e1 - s1) / 1_000_000.0) + " ms"); System.out.println(); final PaillierPublicKey publicKey = keyPair.getPublicKey(); final PaillierPrivateKey privateKey = keyPair.getPrivateKey(); final BigInteger share = BigInteger.valueOf(12345); System.out.println("Encrypting share..."); final BigInteger n = publicKey.getN(); PaillierCipher.encrypt(publicKey, share); long s2 = System.nanoTime(); final BigInteger r1 = RandomNumberGenerator.generateRandomCoprimeInRange(n); final BigInteger E = PaillierCipher.encrypt(publicKey, share, r1); long e2 = System.nanoTime(); System.out.println("Done. Took: " + ((e2 - s2) / 1_000_000.0) + " ms"); System.out.println(); System.out.println("Creating Pedersen commitment..."); long s3 = System.nanoTime(); final BigInteger r2 = RandomNumberGenerator.generateRandomPositiveInteger(curve.getR()); final EcPoint S = curve.addPoints(curve.multiply(g, share), curve.multiply(h, r2)); long e3 = System.nanoTime(); System.out.println("Done. Took: " + ((e3 - s3) / 1_000_000.0) + " ms"); System.out.println(); System.out.println("Generating zero knowledge proof..."); long s4 = System.nanoTime(); final FeldmanEqRangeProof proof = FeldmanEqRangeProofGenerator.generate(publicKey, share, r1, r2, E, S); long e4 = System.nanoTime(); System.out.println("Done. Took: " + ((e4 - s4) / 1_000_000.0) + " ms"); System.out.println(); System.out.println("Verifying zero knowledge proof..."); long s5 = System.nanoTime(); final boolean valid = FeldmanEqRangeProofVerifier.isValid(proof, E, S, publicKey); long e5 = System.nanoTime(); System.out.println("Done. Took: " + ((e5 - s5) / 1_000_000.0) + " ms"); System.out.println("Proof is valid: " + valid); Assert.assertTrue(valid); System.out.println(); System.out.println("Decrypting share..."); long s6 = System.nanoTime(); final BigInteger decryptedShare = PaillierCipher.decrypt(privateKey, E); long e6 = System.nanoTime(); System.out.println("Done. Took: " + ((e6 - s6) / 1_000_000.0) + " ms"); System.out.println("Recovered plaintext: " + share.equals(decryptedShare)); System.out.println("Result: " + decryptedShare); Assert.assertEquals(share, decryptedShare); System.out.println(); }