Browse Source

makeCycle tested

Boyoung- 9 years ago
parent
commit
ca922fa7a6

+ 39 - 0
src/gc/GCLib.java

@@ -173,4 +173,43 @@ public class GCLib<T> extends IntegerLib<T> {
 		return prepareTarget(out[0], out[1], out[2], out[3]);
 	}
 
+	public T[][] makeCycle(T[][] target, T[] nTop, T[] nBot, T[] eTop, T[] eBot) {
+		T[] perpD = ones(logD + 1);
+		T[] nPrev = perpD;
+
+		for (int i = 0; i < d; i++) {
+			T[] index = toSignals(i, logD + 1);
+
+			T nTopEqPerp = eq(nTop, perpD);
+			T iEqEBot = eq(index, eBot);
+			target[i] = mux(target[i], eTop, and(nTopEqPerp, iEqEBot));
+
+			T thirdIf = and(not(nTopEqPerp), iEqEBot);
+			target[i] = mux(target[i], nBot, thirdIf);
+
+			T fourthIf = and(not(or(nTopEqPerp, iEqEBot)), eq(target[i], perpD));
+			T iEqNTop = eq(index, nTop);
+			T fifthIf = and(fourthIf, iEqNTop);
+			T eTopEqPerp = eq(eTop, perpD);
+			target[i] = mux(target[i], nBot, and(fifthIf, eTopEqPerp));
+			target[i] = mux(target[i], eTop, and(fifthIf, not(eTopEqPerp)));
+
+			target[i] = mux(target[i], nPrev, and(fourthIf, not(iEqNTop)));
+
+			nPrev = mux(nPrev, index, fourthIf);
+		}
+
+		return target;
+	}
+
+	public T[][][] combineDeepestTargetCycle(byte[] Li, T[][] E_feBits, T[][] C_feBits, T[][][] E_tupleLabels,
+			T[][][] C_tupleLabels) {
+		T[][][] out = combineDeepestAndTarget(Li, E_feBits, C_feBits, E_tupleLabels, C_tupleLabels);
+		makeCycle(out[0], out[2][0], out[2][1], out[2][2], out[2][3]);
+
+		T[][][] output = env.newTArray(2, 0, 0);
+		output[0] = out[0];
+		output[1] = out[1];
+		return output;
+	}
 }

+ 249 - 0
src/protocols/MakeCycle.java

@@ -0,0 +1,249 @@
+package protocols;
+
+import java.math.BigInteger;
+
+import com.oblivm.backend.flexsc.CompEnv;
+import com.oblivm.backend.gc.GCGenComp;
+import com.oblivm.backend.gc.GCSignal;
+import com.oblivm.backend.gc.regular.GCEva;
+import com.oblivm.backend.gc.regular.GCGen;
+import com.oblivm.backend.network.Network;
+
+import communication.Communication;
+import crypto.Crypto;
+import exceptions.NoSuchPartyException;
+import gc.GCLib;
+import oram.Forest;
+import oram.Metadata;
+import util.Util;
+
+public class MakeCycle extends Protocol {
+
+	private int d = 10;
+	private int w = 8;
+	private int logD = (int) Math.ceil(Math.log(d) / Math.log(2));
+
+	public MakeCycle(Communication con1, Communication con2) {
+		super(con1, con2);
+	}
+
+	private GCSignal[] revSelectKeys(GCSignal[][] pairs, byte[] input) {
+		BigInteger in = new BigInteger(1, input);
+		GCSignal[] out = new GCSignal[pairs.length];
+		for (int i = 0; i < pairs.length; i++)
+			out[i] = pairs[i][in.testBit(i) ? 1 : 0];
+		return out;
+	}
+
+	private GCSignal[] selectKeys(GCSignal[][] pairs, byte[] input) {
+		BigInteger in = new BigInteger(1, input);
+		GCSignal[] out = new GCSignal[pairs.length];
+		for (int i = 0; i < pairs.length; i++)
+			out[i] = pairs[i][in.testBit(pairs.length - 1 - i) ? 1 : 0];
+		return out;
+	}
+
+	private GCSignal[][] genKeyPairs(int n) {
+		GCSignal[][] pairs = new GCSignal[n][];
+		for (int i = 0; i < n; i++)
+			pairs[i] = GCGenComp.genPair();
+		return pairs;
+	}
+
+	private GCSignal[] getZeroKeys(GCSignal[][] pairs) {
+		GCSignal[] keys = new GCSignal[pairs.length];
+		for (int i = 0; i < keys.length; i++)
+			keys[i] = pairs[i][0];
+		return keys;
+	}
+
+	private BigInteger decodeOutput(GCSignal[] out1, GCSignal[] out2) {
+		BigInteger output = BigInteger.ZERO;
+		for (int i = 0; i < out1.length; i++) {
+			if (out2[i].isPublic()) {
+				if (out2[i].v)
+					output = output.setBit(i);
+			} else if (out1[i].equals(out2[i])) {
+				;
+			} else if (out1[i].equals(GCGenComp.R.xor(out2[i]))) {
+				output = output.setBit(i);
+			} else {
+				System.err.println("ERROR on GC output!");
+				return null;
+			}
+		}
+		return output;
+	}
+
+	private String addZeros(String a, int n) {
+		String out = a;
+		for (int i = 0; i < n - a.length(); i++)
+			out = "0" + out;
+		return out;
+	}
+
+	public void runE() {
+		byte[] Li = Util.nextBytes((d - 1 + 7) / 8, Crypto.sr);
+
+		byte[][] feBits = new byte[d][];
+		byte[][][] tupleLabels = new byte[d][w][];
+
+		GCSignal[][][] E_feKeyPairs = new GCSignal[d][][];
+		GCSignal[][][] C_feKeyPairs = new GCSignal[d][][];
+		GCSignal[][] E_feZeroKeys = new GCSignal[d][];
+		GCSignal[][] C_feZeroKeys = new GCSignal[d][];
+		GCSignal[][] E_feKeyInput = new GCSignal[d][];
+
+		GCSignal[][][][] E_labelKeyPairs = new GCSignal[d][w][][];
+		GCSignal[][][][] C_labelKeyPairs = new GCSignal[d][w][][];
+		GCSignal[][][] E_labelZeroKeys = new GCSignal[d][w][];
+		GCSignal[][][] C_labelZeroKeys = new GCSignal[d][w][];
+		GCSignal[][][] E_labelKeyInput = new GCSignal[d][w][];
+
+		for (int i = 0; i < d; i++) {
+			feBits[i] = Util.nextBytes((w + 7) / 8, Crypto.sr);
+			// feBits[i] = new byte[(w + 7) / 8];
+			for (int j = 0; j < w; j++)
+				tupleLabels[i][j] = Util.nextBytes((d - 1 + 7) / 8, Crypto.sr);
+
+			E_feKeyPairs[i] = genKeyPairs(w);
+			C_feKeyPairs[i] = genKeyPairs(w);
+			E_feZeroKeys[i] = getZeroKeys(E_feKeyPairs[i]);
+			C_feZeroKeys[i] = getZeroKeys(C_feKeyPairs[i]);
+			E_feKeyInput[i] = selectKeys(E_feKeyPairs[i], feBits[i]);
+
+			for (int j = 0; j < w; j++) {
+				E_labelKeyPairs[i][j] = genKeyPairs(d - 1);
+				C_labelKeyPairs[i][j] = genKeyPairs(d - 1);
+				E_labelZeroKeys[i][j] = getZeroKeys(E_labelKeyPairs[i][j]);
+				C_labelZeroKeys[i][j] = getZeroKeys(C_labelKeyPairs[i][j]);
+				E_labelKeyInput[i][j] = revSelectKeys(E_labelKeyPairs[i][j], tupleLabels[i][j]);
+			}
+		}
+
+		con1.write(Li);
+		con1.write(E_feKeyInput);
+		con1.write(C_feZeroKeys);
+		con1.write(E_labelKeyInput);
+		con1.write(C_labelZeroKeys);
+
+		Network channel = new Network(null, con1);
+
+		CompEnv<GCSignal> gen1 = new GCGen(channel);
+		GCSignal[][][] E_out1 = new GCLib<GCSignal>(gen1, d, w).combineDeepestAndTarget(Li, E_feZeroKeys, C_feZeroKeys,
+				E_labelZeroKeys, C_labelZeroKeys);
+
+		GCSignal[][][] D_out1 = con1.readObject();
+
+		CompEnv<GCSignal> gen = new GCGen(channel);
+		GCSignal[][][] E_out = new GCLib<GCSignal>(gen, d, w).combineDeepestTargetCycle(Li, E_feZeroKeys, C_feZeroKeys,
+				E_labelZeroKeys, C_labelZeroKeys);
+
+		GCSignal[][][] D_out = con1.readObject();
+
+		int[] target1 = new int[d];
+		int[] f1 = new int[d];
+		int[] target2 = new int[d];
+		int[] f2 = new int[d];
+
+		int nTop = decodeOutput(E_out1[2][0], D_out1[2][0]).intValue();
+		int nBot = decodeOutput(E_out1[2][1], D_out1[2][1]).intValue();
+		int eTop = decodeOutput(E_out1[2][2], D_out1[2][2]).intValue();
+		int eBot = decodeOutput(E_out1[2][3], D_out1[2][3]).intValue();
+
+		for (int i = 0; i < d; i++) {
+			target2[i] = decodeOutput(E_out[0][i], D_out[0][i]).intValue();
+			f2[i] = decodeOutput(E_out[1][i], D_out[1][i]).intValue();
+
+			target1[i] = decodeOutput(E_out1[0][i], D_out1[0][i]).intValue();
+			f1[i] = decodeOutput(E_out1[1][i], D_out1[1][i]).intValue();
+
+			System.out.println("i=" + i);
+
+			System.out.print("full tuples: ");
+			BigInteger fe = new BigInteger(1, feBits[i]);
+			for (int j = 0; j < w; j++)
+				if (fe.testBit(w - 1 - j))
+					System.out.print(j + " ");
+			System.out.println();
+			System.out.print("empty tuples: ");
+			for (int j = 0; j < w; j++)
+				if (!fe.testBit(w - 1 - j))
+					System.out.print(j + " ");
+			System.out.println();
+
+			System.out.println("tuple labels xor path label:");
+			BigInteger pathLabel = new BigInteger(1, Li);
+			for (int j = 0; j < w; j++) {
+				BigInteger xor = Util.getSubBits(new BigInteger(1, tupleLabels[i][j]).xor(pathLabel), d - 1, 0);
+				System.out.println(j + ": " + addZeros(xor.toString(2), d - 1));
+			}
+
+			int perp = (int) (Math.pow(2, logD + 1)) - 1;
+
+			System.out.println();
+			System.out.println("target1[i]: " + ((target1[i] == perp) ? "\\perp" : "" + target1[i]));
+			System.out.println("f1[i]: " + f1[i]);
+			System.out.println("target2[i]: " + ((target2[i] == perp) ? "\\perp" : "" + target2[i]));
+			System.out.println("f2[i]: " + f2[i]);
+
+			System.out.println();
+		}
+		System.out.println("nTop: " + nTop);
+		System.out.println("nBot: " + nBot);
+		System.out.println("eTop: " + eTop);
+		System.out.println("eBot: " + eBot);
+	}
+
+	public void runD() {
+		byte[] Li = con1.read();
+		GCSignal[][] E_feKeyInput = con1.readObject();
+		GCSignal[][] C_feZeroKeys = con1.readObject();
+		GCSignal[][][] E_labelKeyInput = con1.readObject();
+		GCSignal[][][] C_labelZeroKeys = con1.readObject();
+
+		Network channel = new Network(con1, null);
+
+		CompEnv<GCSignal> gen1 = new GCEva(channel);
+		GCLib<GCSignal> dae1 = new GCLib<GCSignal>(gen1, d, w);
+		dae1.combineDeepestAndTarget(Li, E_feKeyInput, C_feZeroKeys, E_labelKeyInput, C_labelZeroKeys);
+
+		gen1.setEvaluate();
+		GCSignal[][][] D_out1 = dae1.combineDeepestAndTarget(Li, E_feKeyInput, C_feZeroKeys, E_labelKeyInput,
+				C_labelZeroKeys);
+
+		con1.write(D_out1);
+
+		CompEnv<GCSignal> gen = new GCEva(channel);
+		GCLib<GCSignal> dae = new GCLib<GCSignal>(gen, d, w);
+		dae.combineDeepestTargetCycle(Li, E_feKeyInput, C_feZeroKeys, E_labelKeyInput, C_labelZeroKeys);
+
+		gen.setEvaluate();
+		GCSignal[][][] D_out = dae.combineDeepestTargetCycle(Li, E_feKeyInput, C_feZeroKeys, E_labelKeyInput,
+				C_labelZeroKeys);
+
+		con1.write(D_out);
+	}
+
+	public void runC() {
+
+	}
+
+	// for testing correctness
+	@Override
+	public void run(Party party, Metadata md, Forest forest) {
+
+		if (party == Party.Eddie) {
+			runE();
+
+		} else if (party == Party.Debbie) {
+			runD();
+
+		} else if (party == Party.Charlie) {
+			runC();
+
+		} else {
+			throw new NoSuchPartyException(party + "");
+		}
+	}
+}

+ 2 - 0
src/ui/CLI.java

@@ -85,6 +85,8 @@ public class CLI {
 			operation = PrepareDeepest.class;
 		} else if (protocol.equals("pt")) {
 			operation = PrepareTarget.class;
+		} else if (protocol.equals("mc")) {
+			operation = MakeCycle.class;
 		} else {
 			System.out.println("Protocol " + protocol + " not supported");
 			System.exit(-1);

+ 50 - 0
test/protocols/TestDeepestAndEmpty_C.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestDeepestAndEmpty_C {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol dae charlie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestDeepestAndEmpty_D.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestDeepestAndEmpty_D {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol dae debbie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestDeepestAndEmpty_E.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestDeepestAndEmpty_E {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol dae eddie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestMakeCycle_C.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestMakeCycle_C {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol mc charlie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestMakeCycle_D.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestMakeCycle_D {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol mc debbie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestMakeCycle_E.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestMakeCycle_E {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol mc eddie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestPrepareDeepest_C.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestPrepareDeepest_C {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol pd charlie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestPrepareDeepest_D.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestPrepareDeepest_D {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol pd debbie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestPrepareDeepest_E.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestPrepareDeepest_E {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol pd eddie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestPrepareTarget_C.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestPrepareTarget_C {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol pt charlie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestPrepareTarget_D.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestPrepareTarget_D {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol pt debbie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestPrepareTarget_E.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestPrepareTarget_E {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol pt eddie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}