public void generateParams(int size) throws Exception {
        SecureRandom rnd = new SecureRandom();
        //generate params
        do {
            g = new BigInteger(size, rnd);
            p = BigInteger.probablePrime(size, rnd);
        } while (g.modPow(p.subtract(BigInteger.ONE), p).compareTo(BigInteger.ONE) != 0);
        //generate keys
        do
            x = new BigInteger(size, rnd);
        while (x.compareTo(p.subtract(BigInteger.ONE)) != -1 && x.compareTo(BigInteger.ONE) != 1);
        System.out.println("Private: " + Utilities.getHexString(x.toByteArray()));
        y = g.modPow(x, p);
        System.out.println("Public: " + Utilities.getHexString(y.toByteArray()));
        System.out.println("Modulus: " + Utilities.getHexString(p.toByteArray()));
        System.out.println("Generator: " + Utilities.getHexString(g.toByteArray()));
    }