public void evalGarbledGate(boolean alice_interpret, boolean bob_interpret)  {
        int i;
        int permuted_index;
        byte[] dec_key;
        byte[] cipher;
        byte perm_dec_key;

        // Do something only if gate hasn't been evaluated yet
        if (garbled_value == null) {
            // Construct permuted_index
            for (i = permuted_index = 0; i < n_inputs; i++)
                permuted_index |= (in_gates[i].garbled_perm << i);

            // Calculate decryption keys
            dec_key = genKey(-1, permuted_index);
            perm_dec_key = dec_key[PPOS];

            // Decrypt
            cipher = encrypted_truth_table.get(permuted_index);
            garbled_value = MyUtil.decArrays(cipher, dec_key);
            garbled_perm = (byte) (encrypted_perm[permuted_index] ^ perm_dec_key);

            // Sanity check
            if ((garbled_perm != 0) && (garbled_perm != 1)) {
               logger.warn("evalGarbledGate: garbled_perm isn't a bit! garbled_perm = " + garbled_perm);
		       garbled_perm = 0;
		       value = 0;
               return;
            }

            // Interpret the output only for relevant output gates
            if ((alice_interpret && isAliceOutput()) ||
                (bob_interpret && isBobOutput())) {
                value = interpretCode();
		    }
        }

        logger.debug("evalGarbledGate: output value is " + value);
    }