Преглед изворни кода

this is a commit that should be changed because Communication is really slow on write() on arrays in Communication

Boyoung- пре 9 година
родитељ
комит
ef11907025

+ 293 - 7
src/communication/Communication.java

@@ -5,6 +5,7 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.Serializable;
 import java.io.StreamCorruptedException;
+import java.math.BigInteger;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
@@ -16,6 +17,10 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 import org.apache.commons.lang3.SerializationUtils;
 
+import com.oblivm.backend.gc.GCSignal;
+
+import oram.Bucket;
+import oram.Tuple;
 import util.Bandwidth;
 import util.P;
 import util.Util;
@@ -344,12 +349,184 @@ public class Communication {
 		write(out);
 	}
 
-	public <T> void write(T out) {
-		write(SerializationUtils.serialize((Serializable) out));
+	/*
+	 * public <T> void write(T out) {
+	 * write(SerializationUtils.serialize((Serializable) out)); }
+	 * 
+	 * public <T> void write(int pid, T out) { write(pid,
+	 * SerializationUtils.serialize((Serializable) out)); }
+	 */
+
+	public void write(byte[][] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, byte[][] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
+	}
+
+	public void write(BigInteger b) {
+		write(b.toByteArray());
+	}
+
+	public void write(int pid, BigInteger b) {
+		write(pid, b.toByteArray());
+	}
+
+	public void write(BigInteger[] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, BigInteger[] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
+	}
+
+	public void write(BigInteger[][] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, BigInteger[][] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
+	}
+
+	public void write(int n) {
+		write(BigInteger.valueOf(n).toByteArray());
+	}
+
+	public void write(int pid, int n) {
+		write(pid, BigInteger.valueOf(n).toByteArray());
+	}
+
+	public void write(int[] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, int[] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
+	}
+
+	public void write(int[][] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, int[][] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
+	}
+
+	public void write(Tuple t) {
+		write(SerializationUtils.serialize(t));
+	}
+
+	public void write(int pid, Tuple t) {
+		write(pid, SerializationUtils.serialize(t));
+	}
+
+	public void write(Tuple[] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, Tuple[] tuples) {
+		write(pid, tuples.length);
+		for (int i = 0; i < tuples.length; i++)
+			write(pid, tuples[i]);
+	}
+
+	public void write(Bucket b) {
+		write(b.getTuples());
+	}
+
+	public void write(int pid, Bucket b) {
+		write(pid, b.getTuples());
+	}
+
+	public void write(Bucket[] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, Bucket[] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
+	}
+
+	public void write(GCSignal key) {
+		write(key.bytes);
 	}
 
-	public <T> void write(int pid, T out) {
-		write(pid, SerializationUtils.serialize((Serializable) out));
+	public void write(int pid, GCSignal key) {
+		write(pid, key.bytes);
+	}
+
+	public void write(GCSignal[] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, GCSignal[] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
+	}
+
+	public void write(GCSignal[][] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, GCSignal[][] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
+	}
+
+	public void write(GCSignal[][][] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, GCSignal[][][] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
+	}
+
+	public void write(GCSignal[][][][] arr) {
+		write(arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(arr[i]);
+	}
+
+	public void write(int pid, GCSignal[][][][] arr) {
+		write(pid, arr.length);
+		for (int i = 0; i < arr.length; i++)
+			write(pid, arr[i]);
 	}
 
 	public static final Charset defaultCharset = Charset.forName("ASCII");
@@ -432,9 +609,118 @@ public class Communication {
 		return total;
 	}
 
-	public <T> T readObject() {
-		T object = SerializationUtils.deserialize(read());
-		return object;
+	/*
+	 * public <T> T readObject() { T object =
+	 * SerializationUtils.deserialize(read()); return object; }
+	 */
+
+	public byte[][] readDoubleByteArray() {
+		int len = readInt();
+		byte[][] arr = new byte[len][];
+		for (int i = 0; i < len; i++)
+			arr[i] = read();
+		return arr;
+	}
+
+	public BigInteger readBigInteger() {
+		return new BigInteger(read());
+	}
+
+	public BigInteger[] readBigIntegerArray() {
+		int len = readInt();
+		BigInteger[] arr = new BigInteger[len];
+		for (int i = 0; i < len; i++)
+			arr[i] = readBigInteger();
+		return arr;
+	}
+
+	public BigInteger[][] readDoubleBigIntegerArray() {
+		int len = readInt();
+		BigInteger[][] arr = new BigInteger[len][];
+		for (int i = 0; i < len; i++)
+			arr[i] = readBigIntegerArray();
+		return arr;
+	}
+
+	public int readInt() {
+		return new BigInteger(read()).intValue();
+	}
+
+	public int[] readIntArray() {
+		int len = readInt();
+		int[] arr = new int[len];
+		for (int i = 0; i < len; i++)
+			arr[i] = readInt();
+		return arr;
+	}
+
+	public int[][] readDoubleIntArray() {
+		int len = readInt();
+		int[][] arr = new int[len][];
+		for (int i = 0; i < len; i++)
+			arr[i] = readIntArray();
+		return arr;
+	}
+
+	public Tuple readTuple() {
+		Tuple t = SerializationUtils.deserialize(read());
+		return t;
+	}
+
+	public Tuple[] readTupleArray() {
+		int len = readInt();
+		Tuple[] arr = new Tuple[len];
+		for (int i = 0; i < len; i++)
+			arr[i] = readTuple();
+		return arr;
+	}
+
+	public Bucket readBucket() {
+		return new Bucket(readTupleArray());
+	}
+
+	public Bucket[] readBucketArray() {
+		int len = readInt();
+		Bucket[] arr = new Bucket[len];
+		for (int i = 0; i < len; i++)
+			arr[i] = readBucket();
+		return arr;
+	}
+
+	public GCSignal readGCSignal() {
+		return new GCSignal(read());
+	}
+
+	public GCSignal[] readGCSignalArray() {
+		int len = readInt();
+		GCSignal[] arr = new GCSignal[len];
+		for (int i = 0; i < len; i++)
+			arr[i] = readGCSignal();
+		return arr;
+	}
+
+	public GCSignal[][] readDoubleGCSignalArray() {
+		int len = readInt();
+		GCSignal[][] arr = new GCSignal[len][];
+		for (int i = 0; i < len; i++)
+			arr[i] = readGCSignalArray();
+		return arr;
+	}
+
+	public GCSignal[][][] readTripleGCSignalArray() {
+		int len = readInt();
+		GCSignal[][][] arr = new GCSignal[len][][];
+		for (int i = 0; i < len; i++)
+			arr[i] = readDoubleGCSignalArray();
+		return arr;
+	}
+
+	public GCSignal[][][][] readQuadGCSignalArray() {
+		int len = readInt();
+		GCSignal[][][][] arr = new GCSignal[len][][][];
+		for (int i = 0; i < len; i++)
+			arr[i] = readTripleGCSignalArray();
+		return arr;
 	}
 
 	/**

+ 5 - 4
src/protocols/Access.java

@@ -4,6 +4,7 @@ import java.math.BigInteger;
 import java.util.Arrays;
 
 import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.SerializationUtils;
 
 import communication.Communication;
 import crypto.Crypto;
@@ -158,7 +159,7 @@ public class Access extends Protocol {
 
 		// step 2
 		timer.start(pid, M.online_read);
-		Tuple[] pathTuples = con2.readObject();
+		Tuple[] pathTuples = con2.readTupleArray();
 		byte[] Ni = con2.read();
 		timer.stop(pid, M.online_read);
 
@@ -272,7 +273,7 @@ public class Access extends Protocol {
 
 		// step 2
 		timer.start(pid, M.online_read);
-		Tuple[] pathTuples = con2.readObject();
+		Tuple[] pathTuples = con2.readTupleArray();
 		timer.stop(pid, M.online_read);
 
 		// step 5
@@ -345,7 +346,7 @@ public class Access extends Protocol {
 						runE(predata, OTi, sE_Ni, sE_Nip1_pr, timer);
 
 						if (ti == numTrees - 1)
-							con2.write(N);
+							con2.write(BigInteger.valueOf(N));
 
 					} else if (party == Party.Debbie) {
 						Tree OTi = forest.getTree(ti);
@@ -367,7 +368,7 @@ public class Access extends Protocol {
 						Li = outaccess.C_Lip1;
 
 						if (ti == numTrees - 1) {
-							N = con1.readObject();
+							N = con1.readBigInteger().longValue();
 							long data = new BigInteger(1, outaccess.C_Ti.getA()).longValue();
 							if (N == data) {
 								System.out.println("Access passed");

+ 8 - 8
src/protocols/Eviction.java

@@ -125,7 +125,7 @@ public class Eviction extends Protocol {
 
 		if (firstTree) {
 			timer.start(pid, M.online_read);
-			Tuple[] originalPath = con2.readObject();
+			Tuple[] originalPath = con2.readTupleArray();
 			timer.stop(pid, M.online_read);
 
 			OTi.setBucketsOnPath(new BigInteger(1, Li).longValue(), new Bucket[] { new Bucket(originalPath) });
@@ -135,13 +135,13 @@ public class Eviction extends Protocol {
 		}
 
 		timer.start(pid, M.online_read);
-		GCSignal[] LiInputKeys = con1.readObject();
-		GCSignal[][] E_feInputKeys = con1.readObject();
-		GCSignal[][][] E_labelInputKeys = con1.readObject();
-		GCSignal[][] deltaInputKeys = con1.readObject();
+		GCSignal[] LiInputKeys = con1.readGCSignalArray();
+		GCSignal[][] E_feInputKeys = con1.readDoubleGCSignalArray();
+		GCSignal[][][] E_labelInputKeys = con1.readTripleGCSignalArray();
+		GCSignal[][] deltaInputKeys = con1.readDoubleGCSignalArray();
 
-		GCSignal[][] C_feInputKeys = con2.readObject();
-		GCSignal[][][] C_labelInputKeys = con2.readObject();
+		GCSignal[][] C_feInputKeys = con2.readDoubleGCSignalArray();
+		GCSignal[][][] C_labelInputKeys = con2.readTripleGCSignalArray();
 		timer.stop(pid, M.online_read);
 
 		GCSignal[][][] outKeys = predata.evict_gcroute.routing(LiInputKeys, E_feInputKeys, C_feInputKeys,
@@ -167,7 +167,7 @@ public class Eviction extends Protocol {
 		ssxot.runD(predata, evict, timer);
 
 		timer.start(pid, M.online_read);
-		Bucket[] pathBuckets = con2.readObject();
+		Bucket[] pathBuckets = con2.readBucketArray();
 		timer.stop(pid, M.online_read);
 
 		OTi.setBucketsOnPath(new BigInteger(1, Li).longValue(), pathBuckets);

+ 8 - 8
src/protocols/PermuteIndex.java

@@ -43,7 +43,7 @@ public class PermuteIndex extends Protocol {
 		timer.stop(pid, M.online_write);
 
 		timer.start(pid, M.online_read);
-		BigInteger[] g = con2.readObject();
+		BigInteger[] g = con2.readBigIntegerArray();
 		timer.stop(pid, M.online_read);
 
 		ti_p = Util.xor(predata.pi_a, g);
@@ -63,7 +63,7 @@ public class PermuteIndex extends Protocol {
 		timer.start(pid, M.online_comp);
 
 		timer.start(pid, M.online_read);
-		BigInteger[] z = con2.readObject();
+		BigInteger[] z = con2.readBigIntegerArray();
 		timer.stop(pid, M.online_read);
 
 		z = Util.xor(z, predata.pi_r);
@@ -113,7 +113,7 @@ public class PermuteIndex extends Protocol {
 
 				runE();
 
-				int[] ti_pp = con1.readObject();
+				int[] ti_pp = con1.readIntArray();
 				ti = Util.permute(ti, predata.evict_pi);
 				int j = 0;
 				for (; j < d; j++) {
@@ -127,9 +127,9 @@ public class PermuteIndex extends Protocol {
 					System.out.println("PermuteIndex test passed");
 
 			} else if (party == Party.Debbie) {
-				predata.evict_pi = con1.readObject();
-				predata.evict_rho = con1.readObject();
-				int[] ti = con1.readObject();
+				predata.evict_pi = con1.readIntArray();
+				predata.evict_rho = con1.readBigIntegerArray();
+				int[] ti = con1.readIntArray();
 
 				prepermuteindex.runD(predata, timer);
 
@@ -137,8 +137,8 @@ public class PermuteIndex extends Protocol {
 				con1.write(ti_pp);
 
 			} else if (party == Party.Charlie) {
-				predata.evict_pi = con1.readObject();
-				predata.evict_rho = con1.readObject();
+				predata.evict_pi = con1.readIntArray();
+				predata.evict_rho = con1.readBigIntegerArray();
 
 				prepermuteindex.runC(predata, timer);
 

+ 9 - 9
src/protocols/PermuteTarget.java

@@ -60,7 +60,7 @@ public class PermuteTarget extends Protocol {
 		timer.stop(pid, M.online_write);
 
 		timer.start(pid, M.online_read);
-		BigInteger[] g = con2.readObject();
+		BigInteger[] g = con2.readBigIntegerArray();
 		timer.stop(pid, M.online_read);
 
 		target = Util.xor(predata.pt_a, g);
@@ -81,8 +81,8 @@ public class PermuteTarget extends Protocol {
 
 		// PermuteTargetII
 		timer.start(pid, M.online_read);
-		BigInteger[] z = con2.readObject();
-		int[] I = con2.readObject();
+		BigInteger[] z = con2.readBigIntegerArray();
+		int[] I = con2.readIntArray();
 		timer.stop(pid, M.online_read);
 
 		BigInteger[] mk = new BigInteger[z.length];
@@ -136,7 +136,7 @@ public class PermuteTarget extends Protocol {
 
 				runE();
 
-				int[] target_pp = con1.readObject();
+				int[] target_pp = con1.readIntArray();
 				int[] pi_ivs = Util.inversePermutation(predata.evict_pi);
 				int[] piTargetPiIvs = new int[d];
 
@@ -152,10 +152,10 @@ public class PermuteTarget extends Protocol {
 					System.out.println("PermuteTarget test passed");
 
 			} else if (party == Party.Debbie) {
-				int d = con1.readObject();
-				predata.evict_pi = con1.readObject();
-				predata.evict_targetOutKeyPairs = con1.readObject();
-				GCSignal[][] targetOutKeys = con1.readObject();
+				int d = con1.readInt();
+				predata.evict_pi = con1.readIntArray();
+				predata.evict_targetOutKeyPairs = con1.readTripleGCSignalArray();
+				GCSignal[][] targetOutKeys = con1.readDoubleGCSignalArray();
 
 				prepermutetarget.runD(predata, d, timer);
 
@@ -163,7 +163,7 @@ public class PermuteTarget extends Protocol {
 				con1.write(target_pp);
 
 			} else if (party == Party.Charlie) {
-				predata.evict_pi = con1.readObject();
+				predata.evict_pi = con1.readIntArray();
 
 				prepermutetarget.runC(predata, timer);
 

+ 6 - 6
src/protocols/PostProcessT.java

@@ -41,7 +41,7 @@ public class PostProcessT extends Protocol {
 
 		// step 1
 		timer.start(pid, M.online_read);
-		int delta = con2.readObject();
+		int delta = con2.readInt();
 		timer.stop(pid, M.online_read);
 
 		// step 3
@@ -158,16 +158,16 @@ public class PostProcessT extends Protocol {
 						OutAccess outaccess = access.runE(predata, OTi, sE_Ni, sE_Nip1_pr, timer);
 
 						if (ti == numTrees - 1)
-							con2.write(N);
+							con2.write(BigInteger.valueOf(N));
 
 						prepostprocesst.runE(predata, timer);
 						Tuple Ti_prime = runE(predata, outaccess.E_Ti, ti == numTrees - 1, timer);
 
-						Ti_prime.setXor(con2.readObject());
+						Ti_prime.setXor(con2.readTuple());
 						byte[] Li_prime = Util.xor(predata.ppt_Li, con2.read());
 						byte[] Lip1_prime = Util.xor(predata.ppt_Lip1, con2.read());
-						int j2 = con2.readObject();
-						Tuple Ti = outaccess.E_Ti.xor(con2.readObject());
+						int j2 = con2.readInt();
+						Tuple Ti = outaccess.E_Ti.xor(con2.readTuple());
 
 						if (!Util.equal(Ti.getF(), Ti_prime.getF()))
 							System.err.println("PPT test failed");
@@ -209,7 +209,7 @@ public class PostProcessT extends Protocol {
 						Li = outaccess.C_Lip1;
 
 						if (ti == numTrees - 1) {
-							N = con1.readObject();
+							N = con1.readBigInteger().longValue();
 							long data = new BigInteger(1, outaccess.C_Ti.getA()).longValue();
 							if (N == data) {
 								System.out.println("Access passed");

+ 5 - 5
src/protocols/Reshuffle.java

@@ -36,7 +36,7 @@ public class Reshuffle extends Protocol {
 
 		// step 1
 		timer.start(pid, M.online_read);
-		Tuple[] z = con2.readObject();
+		Tuple[] z = con2.readTupleArray();
 		timer.stop(pid, M.online_read);
 
 		// step 2
@@ -127,13 +127,13 @@ public class Reshuffle extends Protocol {
 						OutAccess outaccess = access.runE(predata, OTi, sE_Ni, sE_Nip1_pr, timer);
 
 						if (ti == numTrees - 1)
-							con2.write(N);
+							con2.write(BigInteger.valueOf(N));
 
 						prereshuffle.runE(predata, timer);
 						Tuple[] E_P_prime = runE(predata, outaccess.E_P, ti == 0, timer);
 
-						Tuple[] C_P = con2.readObject();
-						Tuple[] C_P_prime = con2.readObject();
+						Tuple[] C_P = con2.readTupleArray();
+						Tuple[] C_P_prime = con2.readTupleArray();
 						Tuple[] oldPath = new Tuple[C_P.length];
 						Tuple[] newPath = new Tuple[C_P.length];
 
@@ -182,7 +182,7 @@ public class Reshuffle extends Protocol {
 						Li = outaccess.C_Lip1;
 
 						if (ti == numTrees - 1) {
-							N = con1.readObject();
+							N = con1.readBigInteger().longValue();
 							long data = new BigInteger(1, outaccess.C_Ti.getA()).longValue();
 							if (N == data) {
 								System.out.println("Access passed");

+ 2 - 2
src/protocols/Retrieve.java

@@ -196,7 +196,7 @@ public class Retrieve extends Protocol {
 						ete_on.stop();
 
 						if (ti == numTrees - 1)
-							con2.write(N);
+							con2.write(BigInteger.valueOf(N));
 
 					} else if (party == Party.Debbie) {
 						Tree OTi = forest.getTree(ti);
@@ -220,7 +220,7 @@ public class Retrieve extends Protocol {
 						Li = outaccess.C_Lip1;
 
 						if (ti == numTrees - 1) {
-							N = con1.readObject();
+							N = con1.readBigInteger().longValue();
 							long data = new BigInteger(1, outaccess.C_Ti.getA()).longValue();
 							if (N == data) {
 								System.out.println("Access passed");

+ 7 - 7
src/protocols/SSCOT.java

@@ -81,12 +81,12 @@ public class SSCOT extends Protocol {
 
 		// step 1
 		timer.start(pid, M.online_read);
-		byte[][] e = con1.readObject();
-		byte[][] v = con1.readObject();
+		byte[][] e = con1.readDoubleByteArray();
+		byte[][] v = con1.readDoubleByteArray();
 
 		// step 2
-		byte[][] p = con2.readObject();
-		byte[][] w = con2.readObject();
+		byte[][] p = con2.readDoubleByteArray();
+		byte[][] w = con2.readDoubleByteArray();
 		timer.stop(pid, M.online_read);
 
 		// step 3
@@ -143,13 +143,13 @@ public class SSCOT extends Protocol {
 				runE(predata, m, a, timer);
 
 			} else if (party == Party.Debbie) {
-				b = con1.readObject();
+				b = con1.readDoubleByteArray();
 				presscot.runD(predata, timer);
 				runD(predata, b, timer);
 
 			} else if (party == Party.Charlie) {
-				m = con1.readObject();
-				index = con1.readObject();
+				m = con1.readDoubleByteArray();
+				index = con1.readInt();
 				presscot.runC();
 				OutSSCOT output = runC(timer);
 				if (output.t == index && Util.equal(output.m_t, m[index]))

+ 4 - 4
src/protocols/SSIOT.java

@@ -76,8 +76,8 @@ public class SSIOT extends Protocol {
 
 		// step 1
 		timer.start(pid, M.online_read);
-		byte[][] e = con1.readObject();
-		byte[][] v = con1.readObject();
+		byte[][] e = con1.readDoubleByteArray();
+		byte[][] v = con1.readDoubleByteArray();
 
 		// step 2
 		byte[] p = con2.read();
@@ -139,8 +139,8 @@ public class SSIOT extends Protocol {
 				runD(predata, sD_Nip1_pr, timer);
 
 			} else if (party == Party.Charlie) {
-				y = con1.readObject();
-				index = con1.readObject();
+				y = con1.readDoubleByteArray();
+				index = con1.readInt();
 				pressiot.runC();
 				OutSSIOT output = runC(timer);
 				if (output.t == index && Util.equal(output.m_t, y[index]))

+ 9 - 9
src/protocols/SSXOT.java

@@ -45,11 +45,11 @@ public class SSXOT extends Protocol {
 		timer.stop(pid, M.online_write);
 
 		timer.start(pid, M.online_read);
-		a = con2.readObject();
+		a = con2.readTupleArray();
 
 		// step 2
-		int[] j = con1.readObject();
-		Tuple[] p = con1.readObject();
+		int[] j = con1.readIntArray();
+		Tuple[] p = con1.readTupleArray();
 		timer.stop(pid, M.online_read);
 
 		// step 3
@@ -100,11 +100,11 @@ public class SSXOT extends Protocol {
 		timer.stop(pid, M.online_write);
 
 		timer.start(pid, M.online_read);
-		a = con1.readObject();
+		a = con1.readTupleArray();
 
 		// step 2
-		int[] j = con2.readObject();
-		Tuple[] p = con2.readObject();
+		int[] j = con2.readIntArray();
+		Tuple[] p = con2.readTupleArray();
 		timer.stop(pid, M.online_read);
 
 		// step 3
@@ -153,9 +153,9 @@ public class SSXOT extends Protocol {
 				pressxot.runC(predata, timer);
 				Tuple[] C_out_m = runC(predata, C_m, timer);
 
-				index = con2.readObject();
-				E_m = con1.readObject();
-				Tuple[] E_out_m = con1.readObject();
+				index = con2.readIntArray();
+				E_m = con1.readTupleArray();
+				Tuple[] E_out_m = con1.readTupleArray();
 
 				boolean pass = true;
 				for (int i = 0; i < index.length; i++) {

+ 11 - 11
src/protocols/UpdateRoot.java

@@ -66,12 +66,12 @@ public class UpdateRoot extends Protocol {
 
 		// step 1
 		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();
+		GCSignal[] j1InputKeys = con1.readGCSignalArray();
+		GCSignal[] LiInputKeys = con1.readGCSignalArray();
+		GCSignal[] E_feInputKeys = con1.readGCSignalArray();
+		GCSignal[][] E_labelInputKeys = con1.readDoubleGCSignalArray();
+		GCSignal[] C_feInputKeys = con2.readGCSignalArray();
+		GCSignal[][] C_labelInputKeys = con2.readDoubleGCSignalArray();
 		timer.stop(pid, M.online_read);
 
 		// step 2
@@ -151,7 +151,7 @@ public class UpdateRoot extends Protocol {
 				preupdateroot.runE(predata, sw, lBits, timer);
 				Tuple[] newR = runE(predata, false, Li, R, Ti, timer);
 
-				Tuple[] R_C = con2.readObject();
+				Tuple[] R_C = con2.readTupleArray();
 				int cnt = 0;
 				int[] index = new int[3];
 				for (int j = 0; j < sw; j++) {
@@ -225,8 +225,8 @@ public class UpdateRoot extends Protocol {
 				System.out.println();
 
 			} else if (party == Party.Debbie) {
-				int sw = con1.readObject();
-				int lBits = con1.readObject();
+				int sw = con1.readInt();
+				int lBits = con1.readInt();
 				byte[] Li = con1.read();
 				int[] tupleParam = new int[] { 1, 2, (lBits + 7) / 8, 3 };
 
@@ -234,8 +234,8 @@ public class UpdateRoot extends Protocol {
 				runD(predata, false, Li, md.getW(), timer);
 
 			} else if (party == Party.Charlie) {
-				int sw = con1.readObject();
-				int lBits = con1.readObject();
+				int sw = con1.readInt();
+				int lBits = con1.readInt();
 				Tuple[] R = new Tuple[sw];
 				for (int j = 0; j < sw; j++)
 					R[j] = new Tuple(1, 2, (lBits + 7) / 8, 3, null);

+ 2 - 2
src/protocols/precomputation/PreAccess.java

@@ -59,8 +59,8 @@ public class PreAccess extends Protocol {
 
 		// Access
 		timer.start(pid, M.offline_read);
-		predata.access_sigma = con1.readObject();
-		predata.access_p = con1.readObject();
+		predata.access_sigma = con1.readIntArray();
+		predata.access_p = con1.readTupleArray();
 		timer.stop(pid, M.offline_read);
 
 		timer.stop(pid, M.offline_comp);

+ 9 - 9
src/protocols/precomputation/PreEviction.java

@@ -164,8 +164,8 @@ public class PreEviction extends Protocol {
 		eva.setEvaluate();
 
 		timer.start(pid, M.offline_read);
-		predata.evict_tiOutKeyHashes = con1.readObject();
-		predata.evict_targetOutKeyPairs = con1.readObject();
+		predata.evict_tiOutKeyHashes = con1.readDoubleBigIntegerArray();
+		predata.evict_targetOutKeyPairs = con1.readTripleGCSignalArray();
 		timer.stop(pid, M.offline_read);
 
 		// PermuteTarget
@@ -192,15 +192,15 @@ public class PreEviction extends Protocol {
 
 		// GC
 		timer.start(pid, M.offline_read);
-		predata.evict_C_feKeyPairs = con1.readObject();
-		predata.evict_C_labelKeyPairs = con1.readObject();
+		predata.evict_C_feKeyPairs = con1.readTripleGCSignalArray();
+		predata.evict_C_labelKeyPairs = con1.readQuadGCSignalArray();
 
 		// Permutation
-		predata.evict_pi = con1.readObject();
-		predata.evict_delta = con1.readObject();
-		predata.evict_rho = con1.readObject();
-		predata.evict_delta_p = con1.readObject();
-		predata.evict_rho_p = con1.readObject();
+		predata.evict_pi = con1.readIntArray();
+		predata.evict_delta = con1.readBigIntegerArray();
+		predata.evict_rho = con1.readBigIntegerArray();
+		predata.evict_delta_p = con1.readDoubleIntArray();
+		predata.evict_rho_p = con1.readDoubleIntArray();
 		timer.stop(pid, M.offline_read);
 
 		// PermuteTarget

+ 3 - 3
src/protocols/precomputation/PrePermuteIndex.java

@@ -48,14 +48,14 @@ public class PrePermuteIndex extends Protocol {
 
 	public void runD(PreData predata, Timer timer) {
 		timer.start(pid, M.offline_read);
-		predata.pi_p = con1.readObject();
-		predata.pi_a = con1.readObject();
+		predata.pi_p = con1.readBigIntegerArray();
+		predata.pi_a = con1.readBigIntegerArray();
 		timer.stop(pid, M.offline_read);
 	}
 
 	public void runC(PreData predata, Timer timer) {
 		timer.start(pid, M.offline_read);
-		predata.pi_r = con1.readObject();
+		predata.pi_r = con1.readBigIntegerArray();
 		timer.stop(pid, M.offline_read);
 	}
 

+ 6 - 6
src/protocols/precomputation/PrePermuteTarget.java

@@ -81,22 +81,22 @@ public class PrePermuteTarget extends Protocol {
 	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();
+		predata.pt_keyT = con1.readDoubleBigIntegerArray();
+		predata.pt_targetT = con1.readDoubleBigIntegerArray();
 
 		// PermuteTargetII
-		predata.pt_p = con1.readObject();
-		predata.pt_a = con1.readObject();
+		predata.pt_p = con1.readBigIntegerArray();
+		predata.pt_a = con1.readBigIntegerArray();
 		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();
+		predata.pt_maskT = con1.readDoubleBigIntegerArray();
 
 		// PermuteTargetII
-		predata.pt_r = con1.readObject();
+		predata.pt_r = con1.readBigIntegerArray();
 		timer.stop(pid, M.offline_read);
 	}
 

+ 3 - 3
src/protocols/precomputation/PrePostProcessT.java

@@ -25,7 +25,7 @@ public class PrePostProcessT extends Protocol {
 		predata.ppt_Li = con1.read();
 		predata.ppt_Lip1 = con1.read();
 
-		predata.ppt_s = con1.readObject();
+		predata.ppt_s = con1.readDoubleByteArray();
 		timer.stop(pid, M.offline_read);
 	}
 
@@ -70,8 +70,8 @@ public class PrePostProcessT extends Protocol {
 		predata.ppt_Lip1 = Util.nextBytes(Lip1Bytes, Crypto.sr);
 
 		timer.start(pid, M.offline_read);
-		predata.ppt_alpha = con2.readObject();
-		predata.ppt_r = con2.readObject();
+		predata.ppt_alpha = con2.readInt();
+		predata.ppt_r = con2.readDoubleByteArray();
 		timer.stop(pid, M.offline_read);
 
 		timer.stop(pid, M.offline_comp);

+ 3 - 3
src/protocols/precomputation/PreReshuffle.java

@@ -27,7 +27,7 @@ public class PreReshuffle extends Protocol {
 		predata.reshuffle_pi = Util.inversePermutation(predata.access_sigma);
 
 		timer.start(pid, M.offline_read);
-		predata.reshuffle_r = con1.readObject();
+		predata.reshuffle_r = con1.readTupleArray();
 		timer.stop(pid, M.offline_read);
 
 		timer.stop(pid, M.offline_comp);
@@ -59,8 +59,8 @@ public class PreReshuffle extends Protocol {
 
 	public void runC(PreData predata, Timer timer) {
 		timer.start(pid, M.offline_read);
-		predata.reshuffle_p = con2.readObject();
-		predata.reshuffle_a_prime = con2.readObject();
+		predata.reshuffle_p = con2.readTupleArray();
+		predata.reshuffle_a_prime = con2.readTupleArray();
 		timer.stop(pid, M.offline_read);
 	}
 

+ 1 - 1
src/protocols/precomputation/PreSSCOT.java

@@ -51,7 +51,7 @@ public class PreSSCOT extends Protocol {
 		timer.start(pid, M.offline_read);
 		predata.sscot_k = con1.read();
 		predata.sscot_kprime = con1.read();
-		predata.sscot_r = con1.readObject();
+		predata.sscot_r = con1.readDoubleByteArray();
 		timer.stop(pid, M.offline_read);
 
 		predata.sscot_F_k = new PRF(Crypto.secParam);

+ 4 - 4
src/protocols/precomputation/PreSSXOT.java

@@ -26,8 +26,8 @@ public class PreSSXOT extends Protocol {
 
 	public void runE(PreData predata, Timer timer) {
 		timer.start(pid, M.offline_read);
-		predata.ssxot_E_pi[id] = con1.readObject();
-		predata.ssxot_E_r[id] = con1.readObject();
+		predata.ssxot_E_pi[id] = con1.readIntArray();
+		predata.ssxot_E_r[id] = con1.readTupleArray();
 		timer.stop(pid, M.offline_read);
 	}
 
@@ -63,8 +63,8 @@ public class PreSSXOT extends Protocol {
 
 	public void runC(PreData predata, Timer timer) {
 		timer.start(pid, M.offline_read);
-		predata.ssxot_C_pi[id] = con2.readObject();
-		predata.ssxot_C_r[id] = con2.readObject();
+		predata.ssxot_C_pi[id] = con2.readIntArray();
+		predata.ssxot_C_r[id] = con2.readTupleArray();
 		timer.stop(pid, M.offline_read);
 	}
 

+ 3 - 3
src/protocols/precomputation/PreUpdateRoot.java

@@ -95,7 +95,7 @@ public class PreUpdateRoot extends Protocol {
 		eva.setEvaluate();
 
 		timer.start(pid, M.offline_read);
-		predata.ur_outKeyHashes = con1.readObject();
+		predata.ur_outKeyHashes = con1.readDoubleBigIntegerArray();
 		timer.stop(pid, M.offline_read);
 
 		PreSSXOT pressxot = new PreSSXOT(con1, con2, 0);
@@ -108,8 +108,8 @@ public class PreUpdateRoot extends Protocol {
 		timer.start(pid, M.offline_comp);
 
 		timer.start(pid, M.offline_read);
-		predata.ur_C_feKeyPairs = con1.readObject();
-		predata.ur_C_labelKeyPairs = con1.readObject();
+		predata.ur_C_feKeyPairs = con1.readDoubleGCSignalArray();
+		predata.ur_C_labelKeyPairs = con1.readTripleGCSignalArray();
 		timer.stop(pid, M.offline_read);
 
 		PreSSXOT pressxot = new PreSSXOT(con1, con2, 0);