Explorar o código

all protocol timing and test added

Boyoung- %!s(int64=9) %!d(string=hai) anos
pai
achega
d3270de747

+ 0 - 1
src/gc/GCUtil.java

@@ -8,7 +8,6 @@ import com.oblivm.backend.gc.GCSignal;
 import crypto.Crypto;
 import exceptions.LengthNotMatchException;
 import oram.Tuple;
-import util.Util;
 
 public class GCUtil {
 

+ 44 - 108
src/protocols/Eviction.java

@@ -6,21 +6,23 @@ import java.util.Arrays;
 import com.oblivm.backend.gc.GCSignal;
 
 import communication.Communication;
-import crypto.Crypto;
-import exceptions.NoSuchPartyException;
 import gc.GCUtil;
 import oram.Bucket;
 import oram.Forest;
 import oram.Metadata;
 import oram.Tree;
 import oram.Tuple;
-import protocols.precomputation.PreEviction;
 import protocols.struct.Party;
 import protocols.struct.PreData;
+import util.M;
+import util.P;
 import util.Timer;
 import util.Util;
 
 public class Eviction extends Protocol {
+
+	private int pid = P.EVI;
+
 	public Eviction(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
@@ -42,14 +44,18 @@ public class Eviction extends Protocol {
 		return evict;
 	}
 
-	public void runE(PreData predata, boolean firstTree, byte[] Li, Tuple[] originalPath, int d, int w, Tree OTi,
-			Timer timer) {
+	public void runE(PreData predata, boolean firstTree, byte[] Li, Tuple[] originalPath, Tree OTi, Timer timer) {
+		timer.start(pid, M.online_comp);
+
 		if (firstTree) {
 			OTi.setBucketsOnPath(new BigInteger(1, Li).longValue(), new Bucket[] { new Bucket(originalPath) });
+			timer.stop(pid, M.online_comp);
 			return;
 		}
 
+		int d = OTi.getD();
 		int sw = OTi.getStashSize();
+		int w = OTi.getW();
 		Tuple[] pathTuples = new Tuple[d * w];
 		System.arraycopy(originalPath, 0, pathTuples, 0, w);
 		System.arraycopy(originalPath, sw, pathTuples, w, (d - 1) * w);
@@ -67,10 +73,12 @@ public class Eviction extends Protocol {
 					predata.evict_delta[i].toByteArray());
 		}
 
+		timer.start(pid, M.online_write);
 		con1.write(LiInputKeys);
 		con1.write(E_feInputKeys);
 		con1.write(E_labelInputKeys);
 		con1.write(deltaInputKeys);
+		timer.stop(pid, M.online_write);
 
 		PermuteTarget permutetarget = new PermuteTarget(con1, con2);
 		permutetarget.runE();
@@ -108,15 +116,25 @@ public class Eviction extends Protocol {
 
 		pathBuckets[0].expand(Arrays.copyOfRange(originalPath, w, sw));
 		OTi.setBucketsOnPath(new BigInteger(1, Li).longValue(), pathBuckets);
+
+		timer.stop(pid, M.online_comp);
 	}
 
-	public void runD(PreData predata, boolean firstTree, byte[] Li, int w, Tree OTi, Timer timer) {
+	public void runD(PreData predata, boolean firstTree, byte[] Li, Tree OTi, Timer timer) {
+		timer.start(pid, M.online_comp);
+
 		if (firstTree) {
+			timer.start(pid, M.online_read);
 			Tuple[] originalPath = con2.readObject();
+			timer.stop(pid, M.online_read);
+
 			OTi.setBucketsOnPath(new BigInteger(1, Li).longValue(), new Bucket[] { new Bucket(originalPath) });
+
+			timer.stop(pid, M.online_comp);
 			return;
 		}
 
+		timer.start(pid, M.online_read);
 		GCSignal[] LiInputKeys = con1.readObject();
 		GCSignal[][] E_feInputKeys = con1.readObject();
 		GCSignal[][][] E_labelInputKeys = con1.readObject();
@@ -124,6 +142,7 @@ public class Eviction extends Protocol {
 
 		GCSignal[][] C_feInputKeys = con2.readObject();
 		GCSignal[][][] C_labelInputKeys = con2.readObject();
+		timer.stop(pid, M.online_read);
 
 		GCSignal[][][] outKeys = predata.evict_gcroute.routing(LiInputKeys, E_feInputKeys, C_feInputKeys,
 				E_labelInputKeys, C_labelInputKeys, deltaInputKeys);
@@ -133,46 +152,39 @@ public class Eviction extends Protocol {
 			ti_p[i] = GCUtil.evaOutKeys(outKeys[1][i], predata.evict_tiOutKeyHashes[i]).intValue();
 		}
 
-		/*
-		 * System.out.println("ti:"); for (int i = 0; i < ti_p.length; i++)
-		 * System.out.print(ti_p[i] + " "); System.out.println();
-		 */
-
 		PermuteTarget permutetarget = new PermuteTarget(con1, con2);
 		int[] target_pp = permutetarget.runD(predata, firstTree, outKeys[0], timer);
 
 		PermuteIndex permuteindex = new PermuteIndex(con1, con2);
 		int[] ti_pp = permuteindex.runD(predata, firstTree, ti_p, timer);
 
-		/*
-		 * System.out.println("ti_pp:"); for (int i = 0; i < ti_p.length; i++)
-		 * System.out.print(ti_pp[i] + " "); System.out.println();
-		 * 
-		 * System.out.println("target_pp:"); for (int i = 0; i < ti_p.length;
-		 * i++) System.out.print(target_pp[i] + " "); System.out.println();
-		 */
-
+		int w = OTi.getW();
 		int logW = (int) Math.ceil(Math.log(w + 1) / Math.log(2));
 		int W = (int) Math.pow(2, logW);
 		int[] evict = prepareEviction(target_pp, ti_pp, W);
-		/*
-		 * for (int i = 0; i < evict.length; i++) System.out.print(evict[i] +
-		 * " "); System.out.println();
-		 */
 
 		SSXOT ssxot = new SSXOT(con1, con2, 1);
 		ssxot.runD(predata, evict, timer);
 
+		timer.start(pid, M.online_read);
 		Bucket[] pathBuckets = con2.readObject();
+		timer.stop(pid, M.online_read);
+
 		OTi.setBucketsOnPath(new BigInteger(1, Li).longValue(), pathBuckets);
+
+		timer.stop(pid, M.online_comp);
 	}
 
-	public void runC(PreData predata, boolean firstTree, Tuple[] originalPath, int d, int w, int sw, Timer timer) {
+	public void runC(PreData predata, boolean firstTree, Tuple[] originalPath, int d, int sw, int w, Timer timer) {
 		if (firstTree) {
+			timer.start(pid, M.online_write);
 			con2.write(originalPath);
+			timer.stop(pid, M.online_write);
 			return;
 		}
 
+		timer.start(pid, M.online_comp);
+
 		Tuple[] pathTuples = new Tuple[d * w];
 		System.arraycopy(originalPath, 0, pathTuples, 0, w);
 		System.arraycopy(originalPath, sw, pathTuples, w, (d - 1) * w);
@@ -186,8 +198,10 @@ public class Eviction extends Protocol {
 			C_labelInputKeys[i] = GCUtil.selectLabelKeys(predata.evict_C_labelKeyPairs[i], pathBuckets[i].getTuples());
 		}
 
+		timer.start(pid, M.online_write);
 		con2.write(C_feInputKeys);
 		con2.write(C_labelInputKeys);
+		timer.stop(pid, M.online_write);
 
 		PermuteTarget permutetarget = new PermuteTarget(con1, con2);
 		permutetarget.runC(predata, firstTree, timer);
@@ -224,95 +238,17 @@ public class Eviction extends Protocol {
 		}
 
 		pathBuckets[0].expand(Arrays.copyOfRange(originalPath, w, sw));
+
+		timer.start(pid, M.online_write);
 		con2.write(pathBuckets);
+		timer.stop(pid, M.online_write);
+
+		timer.stop(pid, M.online_comp);
 	}
 
 	// for testing correctness
 	@Override
 	public void run(Party party, Metadata md, Forest forest) {
-		Timer timer = new Timer();
-
-		for (int i = 0; i < 2; i++) {
-
-			System.out.println("i=" + i);
-
-			PreData predata = new PreData();
-			PreEviction preeviction = new PreEviction(con1, con2);
-
-			if (party == Party.Eddie) {
-				int w = Crypto.sr.nextInt(1) + 4;
-				int d = Crypto.sr.nextInt(1) + 5;
-				int lBits = d - 1;
-				int lBytes = (lBits + 7) / 8;
-				byte[] Li = Util.nextBytes(lBytes, Crypto.sr);
-				Tuple[] path = new Tuple[d * w];
-				for (int j = 0; j < d * w; j++)
-					path[j] = new Tuple(1, 2, lBytes, 3, Crypto.sr);
-
-				System.out.println("d, w: " + d + " " + w);
-
-				con1.write(d);
-				con1.write(w);
-				con1.write(Li);
-				con2.write(d);
-				con2.write(w);
-
-				preeviction.runE(predata, false, d, w, timer);
-				// runE(predata, false, Li, path, d, w, null, timer);
-
-				int emptyIndex = 0;
-				for (int j = 0; j < d * w; j++) {
-					if (new BigInteger(path[j].getF()).testBit(0)) {
-						String l = Util.addZeros(
-								Util.getSubBits(new BigInteger(1, Util.xor(path[j].getL(), Li)), lBits, 0).toString(2),
-								lBits);
-						System.out.println(j + ":\t" + l);
-					} else {
-						emptyIndex = j;
-					}
-				}
-				System.out.println("last empty: " + emptyIndex);
-
-				System.out.println("pi:");
-				for (int j = 0; j < d; j++)
-					System.out.print(predata.evict_pi[j] + " ");
-				System.out.println();
-
-				System.out.println("delta:");
-				for (int j = 0; j < d; j++)
-					System.out.print(predata.evict_delta[j].intValue() + " ");
-				System.out.println();
-
-				System.out.println("rho:");
-				for (int j = 0; j < d; j++)
-					System.out.print(predata.evict_rho[j].intValue() + " ");
-				System.out.println();
-
-			} else if (party == Party.Debbie) {
-				int d = con1.readObject();
-				int w = con1.readObject();
-				byte[] Li = con1.read();
-				int[] tupleParam = new int[] { 1, 2, (d - 1 + 7) / 8, 3 };
-
-				preeviction.runD(predata, false, d, w, tupleParam, timer);
-				// runD(predata, false, Li, w, null, timer);
-
-			} else if (party == Party.Charlie) {
-				int d = con1.readObject();
-				int w = con1.readObject();
-				int lBytes = (d - 1 + 7) / 8;
-				Tuple[] path = new Tuple[d * w];
-				for (int j = 0; j < d * w; j++)
-					path[j] = new Tuple(1, 2, lBytes, 3, null);
-
-				preeviction.runC(predata, false, timer);
-				// runC(predata, false, path, d, w, timer);
-
-			} else {
-				throw new NoSuchPartyException(party + "");
-			}
-		}
-
-		// timer.print();
+		System.out.println("Use Retrieve to test Eviction");
 	}
 }

+ 33 - 10
src/protocols/PermuteIndex.java

@@ -10,10 +10,15 @@ import oram.Metadata;
 import protocols.precomputation.PrePermuteIndex;
 import protocols.struct.Party;
 import protocols.struct.PreData;
+import util.M;
+import util.P;
 import util.Timer;
 import util.Util;
 
 public class PermuteIndex extends Protocol {
+
+	private int pid = P.PI;
+
 	public PermuteIndex(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
@@ -25,15 +30,21 @@ public class PermuteIndex extends Protocol {
 		if (firstTree)
 			return null;
 
+		timer.start(pid, M.online_comp);
+
 		BigInteger[] ti_p = new BigInteger[ti.length];
 		for (int i = 0; i < ti.length; i++)
 			ti_p[i] = BigInteger.valueOf(ti[i]);
 
 		BigInteger[] z = Util.xor(ti_p, predata.pi_p);
 
+		timer.start(pid, M.online_write);
 		con2.write(z);
+		timer.stop(pid, M.online_write);
 
+		timer.start(pid, M.online_read);
 		BigInteger[] g = con2.readObject();
+		timer.stop(pid, M.online_read);
 
 		ti_p = Util.xor(predata.pi_a, g);
 
@@ -41,6 +52,7 @@ public class PermuteIndex extends Protocol {
 		for (int i = 0; i < ti.length; i++)
 			ti_pp[i] = ti_p[i].intValue();
 
+		timer.stop(pid, M.online_comp);
 		return ti_pp;
 	}
 
@@ -48,13 +60,21 @@ public class PermuteIndex extends Protocol {
 		if (firstTree)
 			return;
 
+		timer.start(pid, M.online_comp);
+
+		timer.start(pid, M.online_read);
 		BigInteger[] z = con2.readObject();
+		timer.stop(pid, M.online_read);
 
 		z = Util.xor(z, predata.pi_r);
 		z = Util.permute(z, predata.evict_pi);
 		BigInteger[] g = Util.xor(predata.evict_rho, z);
 
+		timer.start(pid, M.online_write);
 		con2.write(g);
+		timer.stop(pid, M.online_write);
+
+		timer.stop(pid, M.online_comp);
 	}
 
 	// for testing correctness
@@ -62,7 +82,7 @@ public class PermuteIndex extends Protocol {
 	public void run(Party party, Metadata md, Forest forest) {
 		Timer timer = new Timer();
 
-		for (int i = 0; i < 10; i++) {
+		for (int i = 0; i < 50; i++) {
 
 			System.out.println("i=" + i);
 
@@ -70,8 +90,8 @@ public class PermuteIndex extends Protocol {
 			PrePermuteIndex prepermuteindex = new PrePermuteIndex(con1, con2);
 
 			if (party == Party.Eddie) {
-				int d = Crypto.sr.nextInt(5) + 5;
-				int w = Crypto.sr.nextInt(5) + 5;
+				int d = Crypto.sr.nextInt(15) + 5;
+				int w = Crypto.sr.nextInt(15) + 5;
 				int logW = (int) Math.ceil(Math.log(w + 1) / Math.log(2));
 
 				int[] ti = new int[d];
@@ -93,12 +113,18 @@ public class PermuteIndex extends Protocol {
 
 				runE();
 
+				int[] ti_pp = con1.readObject();
 				ti = Util.permute(ti, predata.evict_pi);
-				for (int j = 0; j < d; j++) {
+				int j = 0;
+				for (; j < d; j++) {
 					ti[j] = predata.evict_rho[j].intValue() ^ ti[j];
-					System.out.print(ti[j] + " ");
+					if (ti[j] != ti_pp[j]) {
+						System.err.println("PermuteIndex test failed");
+						break;
+					}
 				}
-				System.out.println();
+				if (j == d)
+					System.out.println("PermuteIndex test passed");
 
 			} else if (party == Party.Debbie) {
 				predata.evict_pi = con1.readObject();
@@ -108,10 +134,7 @@ public class PermuteIndex extends Protocol {
 				prepermuteindex.runD(predata, timer);
 
 				int[] ti_pp = runD(predata, false, ti, timer);
-				for (int j = 0; j < ti.length; j++) {
-					System.out.print(ti_pp[j] + " ");
-				}
-				System.out.println();
+				con1.write(ti_pp);
 
 			} else if (party == Party.Charlie) {
 				predata.evict_pi = con1.readObject();

+ 33 - 10
src/protocols/PermuteTarget.java

@@ -13,10 +13,15 @@ import oram.Metadata;
 import protocols.precomputation.PrePermuteTarget;
 import protocols.struct.Party;
 import protocols.struct.PreData;
+import util.M;
+import util.P;
 import util.Timer;
 import util.Util;
 
 public class PermuteTarget extends Protocol {
+
+	private int pid = P.PT;
+
 	public PermuteTarget(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
@@ -28,6 +33,8 @@ public class PermuteTarget extends Protocol {
 		if (firstTree)
 			return null;
 
+		timer.start(pid, M.online_comp);
+
 		// PermuteTargetI
 		int d = targetOutKeys.length;
 		int I[] = new int[d];
@@ -47,10 +54,14 @@ public class PermuteTarget extends Protocol {
 		// PermuteTargetII
 		BigInteger[] z = Util.xor(target, predata.pt_p);
 
+		timer.start(pid, M.online_write);
 		con2.write(z);
 		con2.write(I);
+		timer.stop(pid, M.online_write);
 
+		timer.start(pid, M.online_read);
 		BigInteger[] g = con2.readObject();
+		timer.stop(pid, M.online_read);
 
 		target = Util.xor(predata.pt_a, g);
 
@@ -58,6 +69,7 @@ public class PermuteTarget extends Protocol {
 		for (int i = 0; i < d; i++)
 			target_pp[i] = target[i].intValue();
 
+		timer.stop(pid, M.online_comp);
 		return target_pp;
 	}
 
@@ -65,9 +77,13 @@ public class PermuteTarget extends Protocol {
 		if (firstTree)
 			return;
 
+		timer.start(pid, M.online_comp);
+
 		// PermuteTargetII
+		timer.start(pid, M.online_read);
 		BigInteger[] z = con2.readObject();
 		int[] I = con2.readObject();
+		timer.stop(pid, M.online_read);
 
 		BigInteger[] mk = new BigInteger[z.length];
 		for (int i = 0; i < mk.length; i++) {
@@ -76,7 +92,11 @@ public class PermuteTarget extends Protocol {
 		}
 		BigInteger[] g = Util.permute(mk, predata.evict_pi);
 
+		timer.start(pid, M.online_write);
 		con2.write(g);
+		timer.stop(pid, M.online_write);
+
+		timer.stop(pid, M.online_comp);
 	}
 
 	// for testing correctness
@@ -84,7 +104,7 @@ public class PermuteTarget extends Protocol {
 	public void run(Party party, Metadata md, Forest forest) {
 		Timer timer = new Timer();
 
-		for (int i = 0; i < 10; i++) {
+		for (int i = 0; i < 50; i++) {
 
 			System.out.println("i=" + i);
 
@@ -92,7 +112,7 @@ public class PermuteTarget extends Protocol {
 			PrePermuteTarget prepermutetarget = new PrePermuteTarget(con1, con2);
 
 			if (party == Party.Eddie) {
-				int d = Crypto.sr.nextInt(1) + 5;
+				int d = Crypto.sr.nextInt(20) + 5;
 				int logD = (int) Math.ceil(Math.log(d) / Math.log(2));
 				int[] target = Util.randomPermutation(d, Crypto.sr);
 
@@ -116,14 +136,20 @@ public class PermuteTarget extends Protocol {
 
 				runE();
 
+				int[] target_pp = con1.readObject();
 				int[] pi_ivs = Util.inversePermutation(predata.evict_pi);
-
 				int[] piTargetPiIvs = new int[d];
-				for (int j = 0; j < d; j++) {
+
+				int j = 0;
+				for (; j < d; j++) {
 					piTargetPiIvs[j] = predata.evict_pi[target[pi_ivs[j]]];
-					System.out.print(piTargetPiIvs[j] + " ");
+					if (piTargetPiIvs[j] != target_pp[j]) {
+						System.err.println("PermuteTarget test failed");
+						break;
+					}
 				}
-				System.out.println();
+				if (j == d)
+					System.out.println("PermuteTarget test passed");
 
 			} else if (party == Party.Debbie) {
 				int d = con1.readObject();
@@ -134,10 +160,7 @@ public class PermuteTarget extends Protocol {
 				prepermutetarget.runD(predata, d, timer);
 
 				int[] target_pp = runD(predata, false, targetOutKeys, timer);
-				for (int j = 0; j < d; j++) {
-					System.out.print(target_pp[j] + " ");
-				}
-				System.out.println();
+				con1.write(target_pp);
 
 			} else if (party == Party.Charlie) {
 				predata.evict_pi = con1.readObject();

+ 4 - 4
src/protocols/Retrieve.java

@@ -39,7 +39,7 @@ public class Retrieve extends Protocol {
 		root = updateroot.runE(predata, OTi.getTreeIndex() == 0, outaccess.Li, root, Ti, timer);
 		System.arraycopy(root, 0, path, 0, root.length);
 		eviction.runE(predata, OTi.getTreeIndex() == 0, outaccess.Li,
-				OTi.getTreeIndex() == 0 ? new Tuple[] { Ti } : path, OTi.getD(), OTi.getW(), OTi, timer);
+				OTi.getTreeIndex() == 0 ? new Tuple[] { Ti } : path, OTi, timer);
 
 		return outaccess;
 	}
@@ -55,7 +55,7 @@ public class Retrieve extends Protocol {
 		reshuffle.runD();
 		postprocesst.runD();
 		updateroot.runD(predata, OTi.getTreeIndex() == 0, Li, OTi.getW(), timer);
-		eviction.runD(predata, OTi.getTreeIndex() == 0, Li, OTi.getW(), OTi, timer);
+		eviction.runD(predata, OTi.getTreeIndex() == 0, Li, OTi, timer);
 	}
 
 	public OutAccess runC(PreData predata, Metadata md, int ti, byte[] Li, int h, Timer timer) {
@@ -71,8 +71,8 @@ public class Retrieve extends Protocol {
 		Tuple[] root = Arrays.copyOfRange(path, 0, md.getStashSizeOfTree(ti));
 		root = updateroot.runC(predata, ti == 0, root, Ti, timer);
 		System.arraycopy(root, 0, path, 0, root.length);
-		eviction.runC(predata, ti == 0, ti == 0 ? new Tuple[] { Ti } : path, md.getLBitsOfTree(ti) + 1, md.getW(),
-				md.getStashSizeOfTree(ti), timer);
+		eviction.runC(predata, ti == 0, ti == 0 ? new Tuple[] { Ti } : path, md.getLBitsOfTree(ti) + 1,
+				md.getStashSizeOfTree(ti), md.getW(), timer);
 
 		return outaccess;
 	}

+ 27 - 7
src/protocols/precomputation/PreEviction.java

@@ -17,10 +17,15 @@ import oram.Metadata;
 import protocols.Protocol;
 import protocols.struct.Party;
 import protocols.struct.PreData;
+import util.M;
+import util.P;
 import util.Timer;
 import util.Util;
 
 public class PreEviction extends Protocol {
+
+	private int pid = P.EVI;
+
 	public PreEviction(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
@@ -29,6 +34,8 @@ public class PreEviction extends Protocol {
 		if (firstTree)
 			return;
 
+		timer.start(pid, M.offline_comp);
+
 		// GC
 		int logW = (int) Math.ceil(Math.log(w + 1) / Math.log(2));
 
@@ -66,26 +73,24 @@ public class PreEviction extends Protocol {
 		}
 
 		Network channel = new Network(null, con1);
-		CompEnv<GCSignal> gen = new GCGen(channel);
+		CompEnv<GCSignal> gen = new GCGen(channel, timer, pid, M.offline_write);
 		GCSignal[][][] outZeroKeys = new GCRoute<GCSignal>(gen, d, w).routing(LiZeroKeys, E_feZeroKeys, C_feZeroKeys,
 				E_labelZeroKeys, C_labelZeroKeys, deltaZeroKeys);
 
 		predata.evict_tiOutKeyHashes = new BigInteger[d][];
 		predata.evict_targetOutKeyPairs = new GCSignal[d][][];
-		// predata.tmpKeyHashes = new BigInteger[d][];
 		for (int i = 0; i < d; i++) {
 			predata.evict_tiOutKeyHashes[i] = GCUtil.genOutKeyHashes(outZeroKeys[1][i]);
 			predata.evict_targetOutKeyPairs[i] = GCUtil.recoverOutKeyPairs(outZeroKeys[0][i]);
-			// predata.tmpKeyHashes[i] =
-			// GCUtil.genOutKeyHashes(outZeroKeys[0][i]);
 		}
 
+		timer.start(pid, M.offline_write);
 		con2.write(predata.evict_C_feKeyPairs);
 		con2.write(predata.evict_C_labelKeyPairs);
 
 		con1.write(predata.evict_tiOutKeyHashes);
 		con1.write(predata.evict_targetOutKeyPairs);
-		// con1.write(predata.tmpKeyHashes);
+		timer.stop(pid, M.offline_write);
 
 		// Permutation
 		predata.evict_pi = Util.randomPermutation(d, Crypto.sr);
@@ -101,11 +106,13 @@ public class PreEviction extends Protocol {
 			predata.evict_rho_p[i] = Util.getXorPermutation(predata.evict_rho[i], logW);
 		}
 
+		timer.start(pid, M.offline_write);
 		con2.write(predata.evict_pi);
 		con2.write(predata.evict_delta);
 		con2.write(predata.evict_rho);
 		con2.write(predata.evict_delta_p);
 		con2.write(predata.evict_rho_p);
+		timer.stop(pid, M.offline_write);
 
 		// PermuteTarget
 		PrePermuteTarget prepermutetarget = new PrePermuteTarget(con1, con2);
@@ -118,12 +125,16 @@ public class PreEviction extends Protocol {
 		// SSXOT
 		PreSSXOT pressxot = new PreSSXOT(con1, con2, 1);
 		pressxot.runE(predata, timer);
+
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runD(PreData predata, boolean firstTree, int d, int w, int[] tupleParam, Timer timer) {
 		if (firstTree)
 			return;
 
+		timer.start(pid, M.offline_comp);
+
 		// GC
 		int logW = (int) Math.ceil(Math.log(w + 1) / Math.log(2));
 
@@ -146,15 +157,16 @@ public class PreEviction extends Protocol {
 		}
 
 		Network channel = new Network(con1, null);
-		CompEnv<GCSignal> eva = new GCEva(channel);
+		CompEnv<GCSignal> eva = new GCEva(channel, timer, pid, M.offline_read);
 		predata.evict_gcroute = new GCRoute<GCSignal>(eva, d, w);
 		predata.evict_gcroute.routing(LiZeroKeys, E_feZeroKeys, C_feZeroKeys, E_labelZeroKeys, C_labelZeroKeys,
 				deltaZeroKeys);
 		eva.setEvaluate();
 
+		timer.start(pid, M.offline_read);
 		predata.evict_tiOutKeyHashes = con1.readObject();
 		predata.evict_targetOutKeyPairs = con1.readObject();
-		// predata.tmpKeyHashes = con1.readObject();
+		timer.stop(pid, M.offline_read);
 
 		// PermuteTarget
 		PrePermuteTarget prepermutetarget = new PrePermuteTarget(con1, con2);
@@ -168,13 +180,18 @@ public class PreEviction extends Protocol {
 		int W = (int) Math.pow(2, logW);
 		PreSSXOT pressxot = new PreSSXOT(con1, con2, 1);
 		pressxot.runD(predata, d * W, d * W, tupleParam, timer);
+
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runC(PreData predata, boolean firstTree, Timer timer) {
 		if (firstTree)
 			return;
 
+		timer.start(pid, M.offline_comp);
+
 		// GC
+		timer.start(pid, M.offline_read);
 		predata.evict_C_feKeyPairs = con1.readObject();
 		predata.evict_C_labelKeyPairs = con1.readObject();
 
@@ -184,6 +201,7 @@ public class PreEviction extends Protocol {
 		predata.evict_rho = con1.readObject();
 		predata.evict_delta_p = con1.readObject();
 		predata.evict_rho_p = con1.readObject();
+		timer.stop(pid, M.offline_read);
 
 		// PermuteTarget
 		PrePermuteTarget prepermutetarget = new PrePermuteTarget(con1, con2);
@@ -196,6 +214,8 @@ public class PreEviction extends Protocol {
 		// SSXOT
 		PreSSXOT pressxot = new PreSSXOT(con1, con2, 1);
 		pressxot.runC(predata, timer);
+
+		timer.stop(pid, M.offline_comp);
 	}
 
 	@Override

+ 15 - 1
src/protocols/precomputation/PrePermuteIndex.java

@@ -9,15 +9,22 @@ import oram.Metadata;
 import protocols.Protocol;
 import protocols.struct.Party;
 import protocols.struct.PreData;
+import util.M;
+import util.P;
 import util.Timer;
 import util.Util;
 
 public class PrePermuteIndex extends Protocol {
+
+	private int pid = P.PI;
+
 	public PrePermuteIndex(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, int d, int w, Timer timer) {
+		timer.start(pid, M.offline_comp);
+
 		int logW = (int) Math.ceil(Math.log(w + 1) / Math.log(2));
 
 		predata.pi_p = new BigInteger[d];
@@ -30,19 +37,26 @@ public class PrePermuteIndex extends Protocol {
 		}
 		predata.pi_a = Util.permute(predata.pi_a, predata.evict_pi);
 
+		timer.start(pid, M.offline_write);
 		con1.write(predata.pi_p);
 		con1.write(predata.pi_a);
-
 		con2.write(predata.pi_r);
+		timer.stop(pid, M.offline_write);
+
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runD(PreData predata, Timer timer) {
+		timer.start(pid, M.offline_read);
 		predata.pi_p = con1.readObject();
 		predata.pi_a = con1.readObject();
+		timer.stop(pid, M.offline_read);
 	}
 
 	public void runC(PreData predata, Timer timer) {
+		timer.start(pid, M.offline_read);
 		predata.pi_r = con1.readObject();
+		timer.stop(pid, M.offline_read);
 	}
 
 	@Override

+ 17 - 2
src/protocols/precomputation/PrePermuteTarget.java

@@ -12,15 +12,22 @@ import oram.Metadata;
 import protocols.Protocol;
 import protocols.struct.Party;
 import protocols.struct.PreData;
+import util.M;
+import util.P;
 import util.Timer;
 import util.Util;
 
 public class PrePermuteTarget extends Protocol {
+
+	private int pid = P.PT;
+
 	public PrePermuteTarget(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, int d, Timer timer) {
+		timer.start(pid, M.offline_comp);
+
 		// PermuteTargetI
 		int logD = (int) Math.ceil(Math.log(d) / Math.log(2));
 
@@ -45,10 +52,11 @@ public class PrePermuteTarget extends Protocol {
 			predata.pt_targetT[i] = Util.permute(predata.pt_targetT[i], randPerm);
 		}
 
+		timer.start(pid, M.offline_write);
 		con1.write(predata.pt_keyT);
 		con1.write(predata.pt_targetT);
-
 		con2.write(predata.pt_maskT);
+		timer.stop(pid, M.offline_write);
 
 		// PermuteTargetII
 		predata.pt_p = new BigInteger[d];
@@ -61,13 +69,17 @@ public class PrePermuteTarget extends Protocol {
 		}
 		predata.pt_a = Util.permute(predata.pt_a, predata.evict_pi);
 
+		timer.start(pid, M.offline_write);
 		con1.write(predata.pt_p);
 		con1.write(predata.pt_a);
-
 		con2.write(predata.pt_r);
+		timer.stop(pid, M.offline_write);
+
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runD(PreData predata, int d, Timer timer) {
+		timer.start(pid, M.offline_read);
 		// PermuteTargetI
 		predata.pt_keyT = con1.readObject();
 		predata.pt_targetT = con1.readObject();
@@ -75,14 +87,17 @@ public class PrePermuteTarget extends Protocol {
 		// PermuteTargetII
 		predata.pt_p = con1.readObject();
 		predata.pt_a = con1.readObject();
+		timer.stop(pid, M.offline_read);
 	}
 
 	public void runC(PreData predata, Timer timer) {
+		timer.start(pid, M.offline_read);
 		// PermuteTargetI
 		predata.pt_maskT = con1.readObject();
 
 		// PermuteTargetII
 		predata.pt_r = con1.readObject();
+		timer.stop(pid, M.offline_read);
 	}
 
 	@Override