Browse Source

used pid to unify timer arg

Boyoung- 9 years ago
parent
commit
238fff517b

+ 18 - 16
src/protocols/Access.java

@@ -27,19 +27,21 @@ import util.Util;
 
 public class Access extends Protocol {
 
+	private int pid = P.ACC;
+
 	public Access(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public OutAccess runE(PreData predata, Tree OTi, byte[] Ni, byte[] Nip1_pr, Timer timer) {
-		timer.start(P.ACC, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 0: get Li from C
 		byte[] Li = new byte[0];
-		timer.start(P.ACC, M.online_read);
+		timer.start(pid, M.online_read);
 		if (OTi.getTreeIndex() > 0)
 			Li = con2.read();
-		timer.stop(P.ACC, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 1
 		Bucket[] pathBuckets = OTi.getBucketsOnPath(Li);
@@ -91,19 +93,19 @@ public class Access extends Protocol {
 
 		OutAccess outaccess = new OutAccess(Li, null, null, null, null, Ti, pathTuples);
 
-		timer.stop(P.ACC, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return outaccess;
 	}
 
 	public byte[] runD(PreData predata, Tree OTi, byte[] Ni, byte[] Nip1_pr, Timer timer) {
-		timer.start(P.ACC, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 0: get Li from C
 		byte[] Li = new byte[0];
-		timer.start(P.ACC, M.online_read);
+		timer.start(pid, M.online_read);
 		if (OTi.getTreeIndex() > 0)
 			Li = con2.read();
-		timer.stop(P.ACC, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 1
 		Bucket[] pathBuckets = OTi.getBucketsOnPath(Li);
@@ -113,10 +115,10 @@ public class Access extends Protocol {
 		pathTuples = Util.permute(pathTuples, predata.access_sigma);
 
 		// step 2
-		timer.start(P.ACC, M.online_write);
+		timer.start(pid, M.online_write);
 		con2.write(pathTuples);
 		con2.write(Ni);
-		timer.stop(P.ACC, M.online_write);
+		timer.stop(pid, M.online_write);
 
 		// step 3
 		if (OTi.getTreeIndex() > 0) {
@@ -138,27 +140,27 @@ public class Access extends Protocol {
 			ssiot.runD(predata, Nip1_pr, timer);
 		}
 
-		timer.stop(P.ACC, M.online_comp);
+		timer.stop(pid, M.online_comp);
 
 		return Li;
 	}
 
 	public OutAccess runC(Metadata md, int treeIndex, byte[] Li, Timer timer) {
-		timer.start(P.ACC, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 0: send Li to E and D
-		timer.start(P.ACC, M.online_write);
+		timer.start(pid, M.online_write);
 		if (treeIndex > 0) {
 			con1.write(Li);
 			con2.write(Li);
 		}
-		timer.stop(P.ACC, M.online_write);
+		timer.stop(pid, M.online_write);
 
 		// step 2
-		timer.start(P.ACC, M.online_read);
+		timer.start(pid, M.online_read);
 		Tuple[] pathTuples = con2.readObject();
 		byte[] Ni = con2.read();
-		timer.stop(P.ACC, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 3
 		int j1 = 0;
@@ -201,7 +203,7 @@ public class Access extends Protocol {
 
 		OutAccess outaccess = new OutAccess(Li, Lip1, Ti, pathTuples, j2, null, null);
 
-		timer.stop(P.ACC, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return outaccess;
 	}
 

+ 12 - 10
src/protocols/PostProcessT.java

@@ -22,25 +22,27 @@ import util.Util;
 
 public class PostProcessT extends Protocol {
 
+	private int pid = P.PPT;
+
 	public PostProcessT(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public Tuple runE(PreData predata, Tuple Ti, boolean lastTree, Timer timer) {
-		timer.start(P.PPT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		if (lastTree) {
 			Tuple out = new Tuple(Ti);
 			Util.setXor(out.getL(), predata.ppt_Li);
 
-			timer.stop(P.PPT, M.online_comp);
+			timer.stop(pid, M.online_comp);
 			return out;
 		}
 
 		// step 1
-		timer.start(P.PPT, M.online_read);
+		timer.start(pid, M.online_read);
 		int delta = con2.readObject();
-		timer.stop(P.PPT, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 3
 		int twoTauPow = predata.ppt_s.length;
@@ -55,7 +57,7 @@ public class PostProcessT extends Protocol {
 		Util.setXor(out.getL(), predata.ppt_Li);
 		Util.setXor(out.getA(), e_all);
 
-		timer.stop(P.PPT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return out;
 	}
 
@@ -63,13 +65,13 @@ public class PostProcessT extends Protocol {
 	}
 
 	public Tuple runC(PreData predata, Tuple Ti, byte[] Li, byte[] Lip1, int j2, boolean lastTree, Timer timer) {
-		timer.start(P.PPT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		if (lastTree) {
 			Tuple out = new Tuple(Ti);
 			Util.setXor(out.getL(), Util.xor(Li, predata.ppt_Li));
 
-			timer.stop(P.PPT, M.online_comp);
+			timer.stop(pid, M.online_comp);
 			return out;
 		}
 
@@ -77,9 +79,9 @@ public class PostProcessT extends Protocol {
 		int twoTauPow = predata.ppt_r.length;
 		int delta = (predata.ppt_alpha - j2 + twoTauPow) % twoTauPow;
 
-		timer.start(P.PPT, M.online_write);
+		timer.start(pid, M.online_write);
 		con1.write(delta);
-		timer.stop(P.PPT, M.online_write);
+		timer.stop(pid, M.online_write);
 
 		// step 2
 		byte[][] c = new byte[twoTauPow][];
@@ -94,7 +96,7 @@ public class PostProcessT extends Protocol {
 		Util.setXor(out.getL(), Util.xor(Li, predata.ppt_Li));
 		Util.setXor(out.getA(), c_all);
 
-		timer.stop(P.PPT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return out;
 	}
 

+ 10 - 8
src/protocols/Reshuffle.java

@@ -22,6 +22,8 @@ import util.Util;
 
 public class Reshuffle extends Protocol {
 
+	private int pid = P.RSF;
+
 	public Reshuffle(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
@@ -30,12 +32,12 @@ public class Reshuffle extends Protocol {
 		if (firstTree)
 			return path;
 
-		timer.start(P.RSF, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
-		timer.start(P.RSF, M.online_read);
+		timer.start(pid, M.online_read);
 		Tuple[] z = con2.readObject();
-		timer.stop(P.RSF, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 2
 		Tuple[] b = new Tuple[z.length];
@@ -43,7 +45,7 @@ public class Reshuffle extends Protocol {
 			b[i] = path[i].xor(z[i]).xor(predata.reshuffle_r[i]);
 		Tuple[] b_prime = Util.permute(b, predata.reshuffle_pi);
 
-		timer.stop(P.RSF, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return b_prime;
 	}
 
@@ -54,18 +56,18 @@ public class Reshuffle extends Protocol {
 		if (firstTree)
 			return path;
 
-		timer.start(P.RSF, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
 		Tuple[] z = new Tuple[path.length];
 		for (int i = 0; i < z.length; i++)
 			z[i] = path[i].xor(predata.reshuffle_p[i]);
 
-		timer.start(P.RSF, M.online_write);
+		timer.start(pid, M.online_write);
 		con1.write(z);
-		timer.stop(P.RSF, M.online_write);
+		timer.stop(pid, M.online_write);
 
-		timer.stop(P.RSF, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return predata.reshuffle_a_prime;
 	}
 

+ 15 - 12
src/protocols/SSCOT.java

@@ -17,12 +17,15 @@ import util.Timer;
 import util.Util;
 
 public class SSCOT extends Protocol {
+
+	private int pid = P.COT;
+
 	public SSCOT(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, byte[][] m, byte[][] a, Timer timer) {
-		timer.start(P.COT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
 		int n = m.length;
@@ -40,16 +43,16 @@ public class SSCOT extends Protocol {
 			v[i] = predata.sscot_F_kprime.compute(x[i]);
 		}
 
-		timer.start(P.COT, M.online_write);
+		timer.start(pid, M.online_write);
 		con2.write(e);
 		con2.write(v);
-		timer.stop(P.COT, M.online_write);
+		timer.stop(pid, M.online_write);
 
-		timer.stop(P.COT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 	}
 
 	public void runD(PreData predata, byte[][] b, Timer timer) {
-		timer.start(P.COT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 2
 		int n = b.length;
@@ -65,26 +68,26 @@ public class SSCOT extends Protocol {
 			w[i] = predata.sscot_F_kprime.compute(y[i]);
 		}
 
-		timer.start(P.COT, M.online_write);
+		timer.start(pid, M.online_write);
 		con2.write(p);
 		con2.write(w);
-		timer.stop(P.COT, M.online_write);
+		timer.stop(pid, M.online_write);
 
-		timer.stop(P.COT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 	}
 
 	public OutSSCOT runC(Timer timer) {
-		timer.start(P.COT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
-		timer.start(P.COT, M.online_read);
+		timer.start(pid, M.online_read);
 		byte[][] e = con1.readObject();
 		byte[][] v = con1.readObject();
 
 		// step 2
 		byte[][] p = con2.readObject();
 		byte[][] w = con2.readObject();
-		timer.stop(P.COT, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 3
 		int n = e.length;
@@ -104,7 +107,7 @@ public class SSCOT extends Protocol {
 		if (invariant != 1)
 			throw new SSCOTException("Invariant error: " + invariant);
 
-		timer.stop(P.COT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return output;
 	}
 

+ 15 - 12
src/protocols/SSIOT.java

@@ -17,12 +17,15 @@ import util.Timer;
 import util.Util;
 
 public class SSIOT extends Protocol {
+
+	private int pid = P.IOT;
+
 	public SSIOT(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, byte[][] y, byte[] Nip1_pr, Timer timer) {
-		timer.start(P.IOT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
 		int n = y.length;
@@ -42,16 +45,16 @@ public class SSIOT extends Protocol {
 			v[i] = predata.ssiot_F_kprime.compute(x[i]);
 		}
 
-		timer.start(P.IOT, M.online_write);
+		timer.start(pid, M.online_write);
 		con2.write(e);
 		con2.write(v);
-		timer.stop(P.IOT, M.online_write);
+		timer.stop(pid, M.online_write);
 
-		timer.stop(P.IOT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 	}
 
 	public void runD(PreData predata, byte[] Nip1_pr, Timer timer) {
-		timer.start(P.IOT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 2
 		byte[] y = predata.ssiot_r;
@@ -60,26 +63,26 @@ public class SSIOT extends Protocol {
 		byte[] p = predata.ssiot_F_k.compute(y);
 		byte[] w = predata.ssiot_F_kprime.compute(y);
 
-		timer.start(P.IOT, M.online_write);
+		timer.start(pid, M.online_write);
 		con2.write(p);
 		con2.write(w);
-		timer.stop(P.IOT, M.online_write);
+		timer.stop(pid, M.online_write);
 
-		timer.stop(P.IOT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 	}
 
 	public OutSSIOT runC(Timer timer) {
-		timer.start(P.IOT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
-		timer.start(P.IOT, M.online_read);
+		timer.start(pid, M.online_read);
 		byte[][] e = con1.readObject();
 		byte[][] v = con1.readObject();
 
 		// step 2
 		byte[] p = con2.read();
 		byte[] w = con2.read();
-		timer.stop(P.IOT, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 3
 		int n = e.length;
@@ -99,7 +102,7 @@ public class SSIOT extends Protocol {
 		if (invariant != 1)
 			throw new SSIOTException("Invariant error: " + invariant);
 
-		timer.stop(P.IOT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return output;
 	}
 

+ 19 - 16
src/protocols/SSXOT.java

@@ -18,48 +18,51 @@ import util.Util;
 public class SSXOT extends Protocol {
 
 	private int id;
+	private int pid;
 
 	public SSXOT(Communication con1, Communication con2) {
 		super(con1, con2);
 		this.id = 0;
+		pid = id == 0 ? P.URXOT : P.XOT;
 	}
 
 	public SSXOT(Communication con1, Communication con2, int id) {
 		super(con1, con2);
 		this.id = id;
+		pid = id == 0 ? P.URXOT : P.XOT;
 	}
 
 	public Tuple[] runE(PreData predata, Tuple[] m, Timer timer) {
-		timer.start(P.XOT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
 		Tuple[] a = new Tuple[m.length];
 		for (int i = 0; i < m.length; i++)
 			a[i] = m[predata.ssxot_E_pi[id][i]].xor(predata.ssxot_E_r[id][i]);
 
-		timer.start(P.XOT, M.online_write);
+		timer.start(pid, M.online_write);
 		con2.write(a);
-		timer.stop(P.XOT, M.online_write);
+		timer.stop(pid, M.online_write);
 
-		timer.start(P.XOT, M.online_read);
+		timer.start(pid, M.online_read);
 		a = con2.readObject();
 
 		// step 2
 		int[] j = con1.readObject();
 		Tuple[] p = con1.readObject();
-		timer.stop(P.XOT, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 3
 		Tuple[] z = new Tuple[j.length];
 		for (int i = 0; i < j.length; i++)
 			z[i] = a[j[i]].xor(p[i]);
 
-		timer.stop(P.XOT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return z;
 	}
 
 	public void runD(PreData predata, int[] index, Timer timer) {
-		timer.start(P.XOT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 2
 		int k = index.length;
@@ -74,42 +77,42 @@ public class SSXOT extends Protocol {
 			C_p[i] = predata.ssxot_C_r[id][C_j[i]].xor(predata.ssxot_delta[id][i]);
 		}
 
-		timer.start(P.XOT, M.online_write);
+		timer.start(pid, M.online_write);
 		con2.write(E_j);
 		con2.write(E_p);
 		con1.write(C_j);
 		con1.write(C_p);
-		timer.stop(P.XOT, M.online_write);
+		timer.stop(pid, M.online_write);
 
-		timer.stop(P.XOT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 	}
 
 	public Tuple[] runC(PreData predata, Tuple[] m, Timer timer) {
-		timer.start(P.XOT, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
 		Tuple[] a = new Tuple[m.length];
 		for (int i = 0; i < m.length; i++)
 			a[i] = m[predata.ssxot_C_pi[id][i]].xor(predata.ssxot_C_r[id][i]);
 
-		timer.start(P.XOT, M.online_write);
+		timer.start(pid, M.online_write);
 		con1.write(a);
-		timer.stop(P.XOT, M.online_write);
+		timer.stop(pid, M.online_write);
 
-		timer.start(P.XOT, M.online_read);
+		timer.start(pid, M.online_read);
 		a = con1.readObject();
 
 		// step 2
 		int[] j = con2.readObject();
 		Tuple[] p = con2.readObject();
-		timer.stop(P.XOT, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 3
 		Tuple[] z = new Tuple[j.length];
 		for (int i = 0; i < j.length; i++)
 			z[i] = a[j[i]].xor(p[i]);
 
-		timer.stop(P.XOT, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return z;
 	}
 

+ 15 - 12
src/protocols/UpdateRoot.java

@@ -22,6 +22,9 @@ import util.Timer;
 import util.Util;
 
 public class UpdateRoot extends Protocol {
+
+	private int pid = P.UR;
+
 	public UpdateRoot(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
@@ -30,7 +33,7 @@ public class UpdateRoot extends Protocol {
 		if (firstTree)
 			return R;
 
-		timer.start(P.UR, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
 		int j1 = Crypto.sr.nextInt(R.length);
@@ -39,19 +42,19 @@ public class UpdateRoot extends Protocol {
 		GCSignal[] E_feInputKeys = GCUtil.selectFeKeys(predata.ur_E_feKeyPairs, R);
 		GCSignal[][] E_labelInputKeys = GCUtil.selectLabelKeys(predata.ur_E_labelKeyPairs, R);
 
-		timer.start(P.UR, M.online_write);
+		timer.start(pid, M.online_write);
 		con1.write(j1InputKeys);
 		con1.write(LiInputKeys);
 		con1.write(E_feInputKeys);
 		con1.write(E_labelInputKeys);
-		timer.stop(P.UR, M.online_write);
+		timer.stop(pid, M.online_write);
 
 		// step 4
 		R = ArrayUtils.addAll(R, new Tuple[] { Ti });
 		SSXOT ssxot = new SSXOT(con1, con2, 0);
 		R = ssxot.runE(predata, R, timer);
 
-		timer.stop(P.UR, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return R;
 	}
 
@@ -59,17 +62,17 @@ public class UpdateRoot extends Protocol {
 		if (firstTree)
 			return;
 
-		timer.start(P.UR, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
-		timer.start(P.UR, M.online_read);
+		timer.start(pid, M.online_read);
 		GCSignal[] j1InputKeys = con1.readObject();
 		GCSignal[] LiInputKeys = con1.readObject();
 		GCSignal[] E_feInputKeys = con1.readObject();
 		GCSignal[][] E_labelInputKeys = con1.readObject();
 		GCSignal[] C_feInputKeys = con2.readObject();
 		GCSignal[][] C_labelInputKeys = con2.readObject();
-		timer.stop(P.UR, M.online_read);
+		timer.stop(pid, M.online_read);
 
 		// step 2
 		GCSignal[][] outKeys = predata.ur_gcur.rootFindDeepestAndEmpty(j1InputKeys, LiInputKeys, E_feInputKeys,
@@ -91,30 +94,30 @@ public class UpdateRoot extends Protocol {
 		SSXOT ssxot = new SSXOT(con1, con2, 0);
 		ssxot.runD(predata, I, timer);
 
-		timer.stop(P.UR, M.online_comp);
+		timer.stop(pid, M.online_comp);
 	}
 
 	public Tuple[] runC(PreData predata, boolean firstTree, Tuple[] R, Tuple Ti, Timer timer) {
 		if (firstTree)
 			return R;
 
-		timer.start(P.UR, M.online_comp);
+		timer.start(pid, M.online_comp);
 
 		// step 1
 		GCSignal[] C_feInputKeys = GCUtil.selectFeKeys(predata.ur_C_feKeyPairs, R);
 		GCSignal[][] C_labelInputKeys = GCUtil.selectLabelKeys(predata.ur_C_labelKeyPairs, R);
 
-		timer.start(P.UR, M.online_write);
+		timer.start(pid, M.online_write);
 		con2.write(C_feInputKeys);
 		con2.write(C_labelInputKeys);
-		timer.stop(P.UR, M.online_write);
+		timer.stop(pid, M.online_write);
 
 		// step 4
 		R = ArrayUtils.addAll(R, new Tuple[] { Ti });
 		SSXOT ssxot = new SSXOT(con1, con2, 0);
 		R = ssxot.runC(predata, R, timer);
 
-		timer.stop(P.UR, M.online_comp);
+		timer.stop(pid, M.online_comp);
 		return R;
 	}
 

+ 13 - 10
src/protocols/precomputation/PreAccess.java

@@ -14,12 +14,15 @@ import util.Timer;
 import util.Util;
 
 public class PreAccess extends Protocol {
+
+	private int pid = P.ACC;
+
 	public PreAccess(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, int twotaupow, int numTuples, int[] tupleParam, Timer timer) {
-		timer.start(P.ACC, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		// SSCOT
 		PreSSCOT presscot = new PreSSCOT(con1, con2);
@@ -35,16 +38,16 @@ public class PreAccess extends Protocol {
 		for (int i = 0; i < numTuples; i++)
 			predata.access_p[i] = new Tuple(tupleParam[0], tupleParam[1], tupleParam[2], tupleParam[3], Crypto.sr);
 
-		timer.start(P.ACC, M.offline_write);
+		timer.start(pid, M.offline_write);
 		con1.write(predata.access_sigma);
 		con1.write(predata.access_p);
-		timer.stop(P.ACC, M.offline_write);
+		timer.stop(pid, M.offline_write);
 
-		timer.stop(P.ACC, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runD(PreData predata, Timer timer) {
-		timer.start(P.ACC, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		// SSCOT
 		PreSSCOT presscot = new PreSSCOT(con1, con2);
@@ -55,16 +58,16 @@ public class PreAccess extends Protocol {
 		pressiot.runD(predata, timer);
 
 		// Access
-		timer.start(P.ACC, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.access_sigma = con1.readObject();
 		predata.access_p = con1.readObject();
-		timer.stop(P.ACC, M.offline_read);
+		timer.stop(pid, M.offline_read);
 
-		timer.stop(P.ACC, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runC(Timer timer) {
-		timer.start(P.ACC, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		// SSCOT
 		PreSSCOT presscot = new PreSSCOT(con1, con2);
@@ -74,7 +77,7 @@ public class PreAccess extends Protocol {
 		PreSSIOT pressiot = new PreSSIOT(con1, con2);
 		pressiot.runC();
 
-		timer.stop(P.ACC, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	@Override

+ 13 - 10
src/protocols/precomputation/PrePostProcessT.java

@@ -13,21 +13,24 @@ import util.Timer;
 import util.Util;
 
 public class PrePostProcessT extends Protocol {
+
+	private int pid = P.PPT;
+
 	public PrePostProcessT(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, Timer timer) {
-		timer.start(P.PPT, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.ppt_Li = con1.read();
 		predata.ppt_Lip1 = con1.read();
 
 		predata.ppt_s = con1.readObject();
-		timer.stop(P.PPT, M.offline_read);
+		timer.stop(pid, M.offline_read);
 	}
 
 	public void runD(PreData predata, PreData prev, int LiBytes, int Lip1Bytes, int tau, Timer timer) {
-		timer.start(P.PPT, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		if (prev != null)
 			predata.ppt_Li = prev.ppt_Lip1;
@@ -45,20 +48,20 @@ public class PrePostProcessT extends Protocol {
 		}
 		predata.ppt_s[predata.ppt_alpha] = Util.xor(predata.ppt_r[predata.ppt_alpha], predata.ppt_Lip1);
 
-		timer.start(P.PPT, M.offline_write);
+		timer.start(pid, M.offline_write);
 		con1.write(predata.ppt_Li);
 		con1.write(predata.ppt_Lip1);
 
 		con2.write(predata.ppt_alpha);
 		con2.write(predata.ppt_r);
 		con1.write(predata.ppt_s);
-		timer.stop(P.PPT, M.offline_write);
+		timer.stop(pid, M.offline_write);
 
-		timer.stop(P.PPT, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runC(PreData predata, PreData prev, int LiBytes, int Lip1Bytes, Timer timer) {
-		timer.start(P.PPT, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		if (prev != null)
 			predata.ppt_Li = prev.ppt_Lip1;
@@ -66,12 +69,12 @@ public class PrePostProcessT extends Protocol {
 			predata.ppt_Li = Util.nextBytes(LiBytes, Crypto.sr);
 		predata.ppt_Lip1 = Util.nextBytes(Lip1Bytes, Crypto.sr);
 
-		timer.start(P.PPT, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.ppt_alpha = con2.readObject();
 		predata.ppt_r = con2.readObject();
-		timer.stop(P.PPT, M.offline_read);
+		timer.stop(pid, M.offline_read);
 
-		timer.stop(P.PPT, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	@Override

+ 13 - 10
src/protocols/precomputation/PreReshuffle.java

@@ -14,24 +14,27 @@ import util.Timer;
 import util.Util;
 
 public class PreReshuffle extends Protocol {
+
+	private int pid = P.RSF;
+
 	public PreReshuffle(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, Timer timer) {
-		timer.start(P.RSF, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		predata.reshuffle_pi = Util.inversePermutation(predata.access_sigma);
 
-		timer.start(P.RSF, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.reshuffle_r = con1.readObject();
-		timer.stop(P.RSF, M.offline_read);
+		timer.stop(pid, M.offline_read);
 
-		timer.stop(P.RSF, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runD(PreData predata, int[] tupleParam, Timer timer) {
-		timer.start(P.RSF, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		predata.reshuffle_pi = Util.inversePermutation(predata.access_sigma);
 		int numTuples = predata.reshuffle_pi.length;
@@ -45,20 +48,20 @@ public class PreReshuffle extends Protocol {
 		}
 		predata.reshuffle_a_prime = Util.permute(a, predata.reshuffle_pi);
 
-		timer.start(P.RSF, M.offline_write);
+		timer.start(pid, M.offline_write);
 		con2.write(predata.reshuffle_p);
 		con2.write(predata.reshuffle_a_prime);
 		con1.write(predata.reshuffle_r);
-		timer.stop(P.RSF, M.offline_write);
+		timer.stop(pid, M.offline_write);
 
-		timer.stop(P.RSF, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runC(PreData predata, Timer timer) {
-		timer.start(P.RSF, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.reshuffle_p = con2.readObject();
 		predata.reshuffle_a_prime = con2.readObject();
-		timer.stop(P.RSF, M.offline_read);
+		timer.stop(pid, M.offline_read);
 	}
 
 	@Override

+ 11 - 8
src/protocols/precomputation/PreSSCOT.java

@@ -13,12 +13,15 @@ import util.P;
 import util.Timer;
 
 public class PreSSCOT extends Protocol {
+
+	private int pid = P.COT;
+
 	public PreSSCOT(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, int n, Timer timer) {
-		timer.start(P.COT, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		predata.sscot_k = PRF.generateKey(Crypto.sr);
 		predata.sscot_kprime = PRF.generateKey(Crypto.sr);
@@ -28,35 +31,35 @@ public class PreSSCOT extends Protocol {
 			Crypto.sr.nextBytes(predata.sscot_r[i]);
 		}
 
-		timer.start(P.COT, M.offline_write);
+		timer.start(pid, M.offline_write);
 		con1.write(predata.sscot_k);
 		con1.write(predata.sscot_kprime);
 		con1.write(predata.sscot_r);
-		timer.stop(P.COT, M.offline_write);
+		timer.stop(pid, M.offline_write);
 
 		predata.sscot_F_k = new PRF(Crypto.secParam);
 		predata.sscot_F_k.init(predata.sscot_k);
 		predata.sscot_F_kprime = new PRF(Crypto.secParam);
 		predata.sscot_F_kprime.init(predata.sscot_kprime);
 
-		timer.stop(P.COT, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runD(PreData predata, Timer timer) {
-		timer.start(P.COT, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
-		timer.start(P.COT, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.sscot_k = con1.read();
 		predata.sscot_kprime = con1.read();
 		predata.sscot_r = con1.readObject();
-		timer.stop(P.COT, M.offline_read);
+		timer.stop(pid, M.offline_read);
 
 		predata.sscot_F_k = new PRF(Crypto.secParam);
 		predata.sscot_F_k.init(predata.sscot_k);
 		predata.sscot_F_kprime = new PRF(Crypto.secParam);
 		predata.sscot_F_kprime.init(predata.sscot_kprime);
 
-		timer.stop(P.COT, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runC() {

+ 11 - 8
src/protocols/precomputation/PreSSIOT.java

@@ -14,46 +14,49 @@ import util.Timer;
 import util.Util;
 
 public class PreSSIOT extends Protocol {
+
+	private int pid = P.IOT;
+
 	public PreSSIOT(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, int n, Timer timer) {
-		timer.start(P.IOT, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		predata.ssiot_k = PRF.generateKey(Crypto.sr);
 		predata.ssiot_kprime = PRF.generateKey(Crypto.sr);
 		predata.ssiot_r = Util.nextBytes(Crypto.secParamBytes, Crypto.sr);
 
-		timer.start(P.IOT, M.offline_write);
+		timer.start(pid, M.offline_write);
 		con1.write(predata.ssiot_k);
 		con1.write(predata.ssiot_kprime);
 		con1.write(predata.ssiot_r);
-		timer.stop(P.IOT, M.offline_write);
+		timer.stop(pid, M.offline_write);
 
 		predata.ssiot_F_k = new PRF(Crypto.secParam);
 		predata.ssiot_F_k.init(predata.ssiot_k);
 		predata.ssiot_F_kprime = new PRF(Crypto.secParam);
 		predata.ssiot_F_kprime.init(predata.ssiot_kprime);
 
-		timer.stop(P.IOT, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runD(PreData predata, Timer timer) {
-		timer.start(P.IOT, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
-		timer.start(P.IOT, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.ssiot_k = con1.read();
 		predata.ssiot_kprime = con1.read();
 		predata.ssiot_r = con1.read();
-		timer.stop(P.IOT, M.offline_read);
+		timer.stop(pid, M.offline_read);
 
 		predata.ssiot_F_k = new PRF(Crypto.secParam);
 		predata.ssiot_F_k.init(predata.ssiot_k);
 		predata.ssiot_F_kprime = new PRF(Crypto.secParam);
 		predata.ssiot_F_kprime.init(predata.ssiot_kprime);
 
-		timer.stop(P.IOT, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runC() {

+ 10 - 8
src/protocols/precomputation/PreSSXOT.java

@@ -16,21 +16,23 @@ import util.Util;
 public class PreSSXOT extends Protocol {
 
 	private int id;
+	private int pid;
 
 	public PreSSXOT(Communication con1, Communication con2, int id) {
 		super(con1, con2);
 		this.id = id;
+		pid = id == 0 ? P.URXOT : P.XOT;
 	}
 
 	public void runE(PreData predata, Timer timer) {
-		timer.start(P.XOT, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.ssxot_E_pi[id] = con1.readObject();
 		predata.ssxot_E_r[id] = con1.readObject();
-		timer.stop(P.XOT, M.offline_read);
+		timer.stop(pid, M.offline_read);
 	}
 
 	public void runD(PreData predata, int n, int k, int[] tupleParam, Timer timer) {
-		timer.start(P.XOT, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		predata.ssxot_delta[id] = new Tuple[k];
 		for (int i = 0; i < k; i++)
@@ -49,21 +51,21 @@ public class PreSSXOT extends Protocol {
 			predata.ssxot_C_r[id][i] = new Tuple(tupleParam[0], tupleParam[1], tupleParam[2], tupleParam[3], Crypto.sr);
 		}
 
-		timer.start(P.XOT, M.offline_write);
+		timer.start(pid, M.offline_write);
 		con1.write(predata.ssxot_E_pi[id]);
 		con1.write(predata.ssxot_E_r[id]);
 		con2.write(predata.ssxot_C_pi[id]);
 		con2.write(predata.ssxot_C_r[id]);
-		timer.stop(P.XOT, M.offline_write);
+		timer.stop(pid, M.offline_write);
 
-		timer.stop(P.XOT, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runC(PreData predata, Timer timer) {
-		timer.start(P.XOT, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.ssxot_C_pi[id] = con2.readObject();
 		predata.ssxot_C_r[id] = con2.readObject();
-		timer.stop(P.XOT, M.offline_read);
+		timer.stop(pid, M.offline_read);
 	}
 
 	@Override

+ 17 - 14
src/protocols/precomputation/PreUpdateRoot.java

@@ -21,12 +21,15 @@ import util.P;
 import util.Timer;
 
 public class PreUpdateRoot extends Protocol {
+
+	private int pid = P.UR;
+
 	public PreUpdateRoot(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
 	public void runE(PreData predata, int sw, int lBits, Timer timer) {
-		timer.start(P.UR, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		int sLogW = (int) Math.ceil(Math.log(sw) / Math.log(2));
 		predata.ur_j1KeyPairs = GCUtil.genKeyPairs(sLogW);
@@ -49,7 +52,7 @@ public class PreUpdateRoot extends Protocol {
 		}
 
 		Network channel = new Network(null, con1);
-		CompEnv<GCSignal> gen = new GCGen(channel, timer, P.UR, M.offline_write);
+		CompEnv<GCSignal> gen = new GCGen(channel, timer, pid, M.offline_write);
 		GCSignal[][] outZeroKeys = new GCUpdateRoot<GCSignal>(gen, lBits + 1, sw).rootFindDeepestAndEmpty(j1ZeroKeys,
 				LiZeroKeys, E_feZeroKeys, C_feZeroKeys, E_labelZeroKeys, C_labelZeroKeys);
 
@@ -57,20 +60,20 @@ public class PreUpdateRoot extends Protocol {
 		for (int i = 0; i < outZeroKeys.length; i++)
 			predata.ur_outKeyHashes[i] = GCUtil.genOutKeyHashes(outZeroKeys[i]);
 
-		timer.start(P.UR, M.offline_write);
+		timer.start(pid, M.offline_write);
 		con2.write(predata.ur_C_feKeyPairs);
 		con2.write(predata.ur_C_labelKeyPairs);
 		con1.write(predata.ur_outKeyHashes);
-		timer.stop(P.UR, M.offline_write);
+		timer.stop(pid, M.offline_write);
 
 		PreSSXOT pressxot = new PreSSXOT(con1, con2, 0);
 		pressxot.runE(predata, timer);
 
-		timer.stop(P.UR, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runD(PreData predata, int sw, int lBits, int[] tupleParam, Timer timer) {
-		timer.start(P.UR, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
 		int logSW = (int) Math.ceil(Math.log(sw) / Math.log(2));
 		GCSignal[] j1ZeroKeys = GCUtil.genEmptyKeys(logSW);
@@ -85,34 +88,34 @@ public class PreUpdateRoot extends Protocol {
 		}
 
 		Network channel = new Network(con1, null);
-		CompEnv<GCSignal> eva = new GCEva(channel, timer, P.UR, M.offline_read);
+		CompEnv<GCSignal> eva = new GCEva(channel, timer, pid, M.offline_read);
 		predata.ur_gcur = new GCUpdateRoot<GCSignal>(eva, lBits + 1, sw);
 		predata.ur_gcur.rootFindDeepestAndEmpty(j1ZeroKeys, LiZeroKeys, E_feZeroKeys, C_feZeroKeys, E_labelZeroKeys,
 				C_labelZeroKeys);
 		eva.setEvaluate();
 
-		timer.start(P.UR, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.ur_outKeyHashes = con1.readObject();
-		timer.stop(P.UR, M.offline_read);
+		timer.stop(pid, M.offline_read);
 
 		PreSSXOT pressxot = new PreSSXOT(con1, con2, 0);
 		pressxot.runD(predata, sw + 1, sw, tupleParam, timer);
 
-		timer.stop(P.UR, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	public void runC(PreData predata, Timer timer) {
-		timer.start(P.UR, M.offline_comp);
+		timer.start(pid, M.offline_comp);
 
-		timer.start(P.UR, M.offline_read);
+		timer.start(pid, M.offline_read);
 		predata.ur_C_feKeyPairs = con1.readObject();
 		predata.ur_C_labelKeyPairs = con1.readObject();
-		timer.stop(P.UR, M.offline_read);
+		timer.stop(pid, M.offline_read);
 
 		PreSSXOT pressxot = new PreSSXOT(con1, con2, 0);
 		pressxot.runC(predata, timer);
 
-		timer.stop(P.UR, M.offline_comp);
+		timer.stop(pid, M.offline_comp);
 	}
 
 	@Override

+ 6 - 5
src/util/P.java

@@ -8,11 +8,12 @@ public class P {
 	public static final int PPT = 3;
 	public static final int RSF = 4;
 	public static final int UR = 5;
-	public static final int EVI = 6;
-	public static final int PT = 7;
-	public static final int PI = 8;
-	public static final int XOT = 9;
+	public static final int URXOT = 6;
+	public static final int EVI = 7;
+	public static final int PT = 8;
+	public static final int PI = 9;
+	public static final int XOT = 10;
 
-	public static final String[] names = { "ACC", "COT", "IOT", "PPT", "RSF", "UR", "EVI", "PT", "PI", "XOT" };
+	public static final String[] names = { "ACC", "COT", "IOT", "PPT", "RSF", "UR", "URXOT", "EVI", "PT", "PI", "XOT" };
 	public static final int size = names.length;
 }