public void generateEncGate() {
        int i;
        int permuted_index;
        byte[] enc_key;

		// !!!Added by FairplayPF
        MyUtil.randomBytes(code0);
        MyUtil.randomBytes(code1);
        perm = (byte) (MyUtil.randomByte() & 0x01);        
        
        if (isInput()) {
            return;
        }

        logger.debug("generateEncGate: encrypt gate with " + n_inputs +
            " inputs");

        int n_ent = (1 << n_inputs); // n_ent = 2^(n_inputs)

        // Create vector and array + fill vector with dummy data
        encrypted_truth_table = new Vector<byte[]>(n_ent);
        encrypted_perm = new byte[n_ent];

        for (i = 0; i < n_ent; i++)
            encrypted_truth_table.add(i, null);

        // Loop enumerates through all possible input values
        for (i = 0; i < n_ent; i++) {

            // create encrypted garbled value for specific input
            permuted_index = genPermIndex(i);
            enc_key = genKey (i, permuted_index);
            encrypted_truth_table.set(permuted_index, generateEncOutput(i, enc_key));

            // create encrypted garbled perm
            encrypted_perm[permuted_index] = generateEncPerm(i, enc_key[PPOS]);
            logger.debug("generateEncGate: i = " + i + " - encrypted_perm[" +
                permuted_index + "] = " + encrypted_perm[permuted_index]);
        }

        if (isAliceOutput()) {
            hcode0 = MyUtil.hash(code0, NBYTESG);
            hcode1 = MyUtil.hash(code1, NBYTESG);
        }
    }