public static byte[] ElgamalEncrypt(String key, BigInteger y, BigInteger k, BigInteger p) throws Exception {
        BigInteger m = new BigInteger(key, 16);
        //encrypt c = (m + y^k)(mod p)
        BigInteger c = m.add(y.modPow(k, p)).mod(p);
        return Utilities.toBytes(c);
    }