Browse Source

changed communicate write back to generic way

Boyoung- 9 years ago
parent
commit
a8f1b3ed42

+ 144 - 238
src/communication/Communication.java

@@ -3,6 +3,7 @@ package communication;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.io.Serializable;
 import java.io.StreamCorruptedException;
 import java.math.BigInteger;
 import java.net.InetSocketAddress;
@@ -14,12 +15,8 @@ import java.util.ArrayList;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 
-import org.bouncycastle.util.Arrays;
+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;
@@ -348,34 +345,12 @@ public class Communication {
 		write(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);
-		write(ComUtil.toByteArray(arr));
-	}
-
-	public void write(int pid, byte[][] arr) {
-		write(pid, arr.length);
-		write(pid, ComUtil.toByteArray(arr));
+	public <T> void write(T out) {
+		write(SerializationUtils.serialize((Serializable) out));
 	}
 
-	public void write(byte[][][] arr) {
-		write(arr.length);
-		write(arr[0].length);
-		write(ComUtil.toByteArray(arr));
-	}
-
-	public void write(int pid, byte[][][] arr) {
-		write(pid, arr.length);
-		write(pid, arr[0].length);
-		write(pid, ComUtil.toByteArray(arr));
+	public <T> void write(int pid, T out) {
+		write(pid, SerializationUtils.serialize((Serializable) out));
 	}
 
 	public void write(BigInteger b) {
@@ -394,125 +369,93 @@ public class Communication {
 		write(pid, BigInteger.valueOf(n));
 	}
 
-	public void write(int[] arr) {
-		write(ComUtil.toByteArray(arr));
-	}
-
-	public void write(int pid, int[] arr) {
-		write(pid, ComUtil.toByteArray(arr));
-	}
-
-	public void write(int[][] arr) {
-		write(arr.length);
-		write(ComUtil.toByteArray(arr));
-	}
-
-	public void write(int pid, int[][] arr) {
-		write(pid, arr.length);
-		write(pid, ComUtil.toByteArray(arr));
-	}
-
-	public void write(Tuple t) {
-		write(t.getF().length);
-		write(t.getN().length);
-		write(t.getL().length);
-		write(t.toByteArray());
-	}
-
-	public void write(int pid, Tuple t) {
-		write(pid, t.getF().length);
-		write(pid, t.getN().length);
-		write(pid, t.getL().length);
-		write(pid, t.toByteArray());
-	}
-
-	public void write(Tuple[] arr) {
-		write(arr.length);
-		write(arr[0].getF().length);
-		write(arr[0].getN().length);
-		write(arr[0].getL().length);
-		write(ComUtil.toByteArray(arr));
-	}
-
-	public void write(int pid, Tuple[] arr) {
-		write(pid, arr.length);
-		write(pid, arr[0].getF().length);
-		write(pid, arr[0].getN().length);
-		write(pid, arr[0].getL().length);
-		write(pid, ComUtil.toByteArray(arr));
-	}
-
-	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);
-		write(arr[0].getNumTuples());
-		write(Bucket.bucketsToTuples(arr));
-	}
-
-	public void write(int pid, Bucket[] arr) {
-		write(pid, arr.length);
-		write(pid, arr[0].getNumTuples());
-		write(pid, Bucket.bucketsToTuples(arr));
-	}
-
-	public void write(GCSignal key) {
-		write(key.bytes);
-	}
-
-	public void write(int pid, GCSignal key) {
-		write(pid, key.bytes);
-	}
-
-	public void write(GCSignal[] arr) {
-		write(ComUtil.toByteArray(arr));
-	}
-
-	public void write(int pid, GCSignal[] arr) {
-		write(pid, ComUtil.toByteArray(arr));
-	}
-
-	public void write(GCSignal[][] arr) {
-		write(arr.length);
-		write(ComUtil.toByteArray(arr));
-	}
-
-	public void write(int pid, GCSignal[][] arr) {
-		write(pid, arr.length);
-		write(pid, ComUtil.toByteArray(arr));
-	}
-
-	public void write(GCSignal[][][] arr) {
-		write(arr.length);
-		write(arr[0].length);
-		write(ComUtil.toByteArray(arr));
-	}
-
-	public void write(int pid, GCSignal[][][] arr) {
-		write(pid, arr.length);
-		write(pid, arr[0].length);
-		write(pid, ComUtil.toByteArray(arr));
+	public void write(long n) {
+		write(BigInteger.valueOf(n));
 	}
 
-	public void write(GCSignal[][][][] arr) {
-		write(arr.length);
-		write(arr[0].length);
-		write(arr[0][0].length);
-		write(ComUtil.toByteArray(arr));
+	public void write(int pid, long n) {
+		write(pid, BigInteger.valueOf(n));
 	}
 
-	public void write(int pid, GCSignal[][][][] arr) {
-		write(pid, arr.length);
-		write(pid, arr[0].length);
-		write(pid, arr[0][0].length);
-		write(pid, ComUtil.toByteArray(arr));
-	}
+	/*
+	 * public void write(byte[][] arr) { write(arr.length);
+	 * write(ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int pid, byte[][] arr) { write(pid, arr.length);
+	 * write(pid, ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(byte[][][] arr) { write(arr.length);
+	 * write(arr[0].length); write(ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int pid, byte[][][] arr) { write(pid, arr.length);
+	 * write(pid, arr[0].length); write(pid, ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int[] arr) { write(ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int pid, int[] arr) { write(pid,
+	 * ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int[][] arr) { write(arr.length);
+	 * write(ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int pid, int[][] arr) { write(pid, arr.length);
+	 * write(pid, ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(Tuple t) { write(t.getF().length);
+	 * write(t.getN().length); write(t.getL().length); write(t.toByteArray()); }
+	 * 
+	 * public void write(int pid, Tuple t) { write(pid, t.getF().length);
+	 * write(pid, t.getN().length); write(pid, t.getL().length); write(pid,
+	 * t.toByteArray()); }
+	 * 
+	 * public void write(Tuple[] arr) { write(arr.length);
+	 * write(arr[0].getF().length); write(arr[0].getN().length);
+	 * write(arr[0].getL().length); write(ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int pid, Tuple[] arr) { write(pid, arr.length);
+	 * write(pid, arr[0].getF().length); write(pid, arr[0].getN().length);
+	 * write(pid, arr[0].getL().length); write(pid, ComUtil.toByteArray(arr)); }
+	 * 
+	 * 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);
+	 * write(arr[0].getNumTuples()); write(Bucket.bucketsToTuples(arr)); }
+	 * 
+	 * public void write(int pid, Bucket[] arr) { write(pid, arr.length);
+	 * write(pid, arr[0].getNumTuples()); write(pid,
+	 * Bucket.bucketsToTuples(arr)); }
+	 * 
+	 * public void write(GCSignal key) { write(key.bytes); }
+	 * 
+	 * public void write(int pid, GCSignal key) { write(pid, key.bytes); }
+	 * 
+	 * public void write(GCSignal[] arr) { write(ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int pid, GCSignal[] arr) { write(pid,
+	 * ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(GCSignal[][] arr) { write(arr.length);
+	 * write(ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int pid, GCSignal[][] arr) { write(pid, arr.length);
+	 * write(pid, ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(GCSignal[][][] arr) { write(arr.length);
+	 * write(arr[0].length); write(ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int pid, GCSignal[][][] arr) { write(pid, arr.length);
+	 * write(pid, arr[0].length); write(pid, ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(GCSignal[][][][] arr) { write(arr.length);
+	 * write(arr[0].length); write(arr[0][0].length);
+	 * write(ComUtil.toByteArray(arr)); }
+	 * 
+	 * public void write(int pid, GCSignal[][][][] arr) { write(pid,
+	 * arr.length); write(pid, arr[0].length); write(pid, arr[0][0].length);
+	 * write(pid, ComUtil.toByteArray(arr)); }
+	 */
 
 	public static final Charset defaultCharset = Charset.forName("ASCII");
 
@@ -594,20 +537,9 @@ public class Communication {
 		return total;
 	}
 
-	/*
-	 * public <T> T readObject() { T object =
-	 * SerializationUtils.deserialize(read()); return object; }
-	 */
-
-	public byte[][] readDoubleByteArray() {
-		int len = readInt();
-		return ComUtil.toDoubleByteArray(read(), len);
-	}
-
-	public byte[][][] readTripleByteArray() {
-		int len1 = readInt();
-		int len2 = readInt();
-		return ComUtil.toTripleByteArray(read(), len1, len2);
+	public <T> T readObject() {
+		T object = SerializationUtils.deserialize(read());
+		return object;
 	}
 
 	public BigInteger readBigInteger() {
@@ -618,86 +550,60 @@ public class Communication {
 		return readBigInteger().intValue();
 	}
 
-	public int[] readIntArray() {
-		return ComUtil.toIntArray(read());
-	}
-
-	public int[][] readDoubleIntArray() {
-		int len = readInt();
-		return ComUtil.toDoubleIntArray(read(), len);
-	}
-
-	public Tuple readTuple() {
-		int f = readInt();
-		int n = readInt();
-		int l = readInt();
-		int endN = f + n;
-		int endL = endN + l;
-		byte[] b = read();
-		byte[] F = Arrays.copyOfRange(b, 0, f);
-		byte[] N = Arrays.copyOfRange(b, f, endN);
-		byte[] L = Arrays.copyOfRange(b, endN, endL);
-		byte[] A = Arrays.copyOfRange(b, endL, b.length);
-		return new Tuple(F, N, L, A);
-	}
-
-	public Tuple[] readTupleArray() {
-		int len1 = readInt();
-		int f = readInt();
-		int n = readInt();
-		int l = readInt();
-		byte[] b = read();
-		int len2 = b.length / len1;
-		int endN = f + n;
-		int endL = endN + l;
-		Tuple[] arr = new Tuple[len1];
-		for (int i = 0; i < len1; i++) {
-			byte[] F = Arrays.copyOfRange(b, i * len2, i * len2 + f);
-			byte[] N = Arrays.copyOfRange(b, i * len2 + f, i * len2 + endN);
-			byte[] L = Arrays.copyOfRange(b, i * len2 + endN, i * len2 + endL);
-			byte[] A = Arrays.copyOfRange(b, i * len2 + endL, (i + 1) * len2);
-			arr[i] = new Tuple(F, N, L, A);
-		}
-		return arr;
+	public long readLong() {
+		return readBigInteger().longValue();
 	}
 
-	public Bucket readBucket() {
-		return new Bucket(readTupleArray());
-	}
-
-	public Bucket[] readBucketArray() {
-		int d = readInt();
-		int sw = readInt();
-		Tuple[] arr = readTupleArray();
-		int w = (arr.length - sw) / (d - 1);
-		return Bucket.tuplesToBuckets(arr, d, sw, w);
-	}
-
-	public GCSignal readGCSignal() {
-		return new GCSignal(read());
-	}
-
-	public GCSignal[] readGCSignalArray() {
-		return ComUtil.toGCSignalArray(read());
-	}
-
-	public GCSignal[][] readDoubleGCSignalArray() {
-		int len = readInt();
-		return ComUtil.toDoubleGCSignalArray(read(), len);
-	}
-
-	public GCSignal[][][] readTripleGCSignalArray() {
-		int len1 = readInt();
-		int len2 = readInt();
-		return ComUtil.toTripleGCSignalArray(read(), len1, len2);
-	}
-
-	public GCSignal[][][][] readQuadGCSignalArray() {
-		int len1 = readInt();
-		int len2 = readInt();
-		int len3 = readInt();
-		return ComUtil.toQuadGCSignalArray(read(), len1, len2, len3);
-	}
+	/*
+	 * public byte[][] readDoubleByteArray() { int len = readInt(); return
+	 * ComUtil.toDoubleByteArray(read(), len); }
+	 * 
+	 * public byte[][][] readTripleByteArray() { int len1 = readInt(); int len2
+	 * = readInt(); return ComUtil.toTripleByteArray(read(), len1, len2); }
+	 * 
+	 * public int[] readIntArray() { return ComUtil.toIntArray(read()); }
+	 * 
+	 * public int[][] readDoubleIntArray() { int len = readInt(); return
+	 * ComUtil.toDoubleIntArray(read(), len); }
+	 * 
+	 * public Tuple readTuple() { int f = readInt(); int n = readInt(); int l =
+	 * readInt(); int endN = f + n; int endL = endN + l; byte[] b = read();
+	 * byte[] F = Arrays.copyOfRange(b, 0, f); byte[] N = Arrays.copyOfRange(b,
+	 * f, endN); byte[] L = Arrays.copyOfRange(b, endN, endL); byte[] A =
+	 * Arrays.copyOfRange(b, endL, b.length); return new Tuple(F, N, L, A); }
+	 * 
+	 * public Tuple[] readTupleArray() { int len1 = readInt(); int f =
+	 * readInt(); int n = readInt(); int l = readInt(); byte[] b = read(); int
+	 * len2 = b.length / len1; int endN = f + n; int endL = endN + l; Tuple[]
+	 * arr = new Tuple[len1]; for (int i = 0; i < len1; i++) { byte[] F =
+	 * Arrays.copyOfRange(b, i * len2, i * len2 + f); byte[] N =
+	 * Arrays.copyOfRange(b, i * len2 + f, i * len2 + endN); byte[] L =
+	 * Arrays.copyOfRange(b, i * len2 + endN, i * len2 + endL); byte[] A =
+	 * Arrays.copyOfRange(b, i * len2 + endL, (i + 1) * len2); arr[i] = new
+	 * Tuple(F, N, L, A); } return arr; }
+	 * 
+	 * public Bucket readBucket() { return new Bucket(readTupleArray()); }
+	 * 
+	 * public Bucket[] readBucketArray() { int d = readInt(); int sw =
+	 * readInt(); Tuple[] arr = readTupleArray(); int w = (arr.length - sw) / (d
+	 * - 1); return Bucket.tuplesToBuckets(arr, d, sw, w); }
+	 * 
+	 * public GCSignal readGCSignal() { return new GCSignal(read()); }
+	 * 
+	 * public GCSignal[] readGCSignalArray() { return
+	 * ComUtil.toGCSignalArray(read()); }
+	 * 
+	 * public GCSignal[][] readDoubleGCSignalArray() { int len = readInt();
+	 * return ComUtil.toDoubleGCSignalArray(read(), len); }
+	 * 
+	 * public GCSignal[][][] readTripleGCSignalArray() { int len1 = readInt();
+	 * int len2 = readInt(); return ComUtil.toTripleGCSignalArray(read(), len1,
+	 * len2); }
+	 * 
+	 * public GCSignal[][][][] readQuadGCSignalArray() { int len1 = readInt();
+	 * int len2 = readInt(); int len3 = readInt(); return
+	 * ComUtil.toQuadGCSignalArray(read(), len1, len2, len3); }
+	 */
 
 	/**
 	 * This thread runs while listening for incoming connections. It behaves

+ 4 - 4
src/protocols/Access.java

@@ -158,7 +158,7 @@ public class Access extends Protocol {
 
 		// step 2
 		timer.start(pid, M.online_read);
-		Tuple[] pathTuples = con2.readTupleArray();
+		Tuple[] pathTuples = con2.readObject();
 		byte[] Ni = con2.read();
 		timer.stop(pid, M.online_read);
 
@@ -272,7 +272,7 @@ public class Access extends Protocol {
 
 		// step 2
 		timer.start(pid, M.online_read);
-		Tuple[] pathTuples = con2.readTupleArray();
+		Tuple[] pathTuples = con2.readObject();
 		timer.stop(pid, M.online_read);
 
 		// step 5
@@ -345,7 +345,7 @@ public class Access extends Protocol {
 						runE(predata, OTi, sE_Ni, sE_Nip1_pr, timer);
 
 						if (ti == numTrees - 1)
-							con2.write(BigInteger.valueOf(N));
+							con2.write(N);
 
 					} else if (party == Party.Debbie) {
 						Tree OTi = forest.getTree(ti);
@@ -367,7 +367,7 @@ public class Access extends Protocol {
 						Li = outaccess.C_Lip1;
 
 						if (ti == numTrees - 1) {
-							N = con1.readBigInteger().longValue();
+							N = con1.readLong();
 							long data = new BigInteger(1, outaccess.C_Ti.getA()).longValue();
 							if (N == data) {
 								System.out.println("Access passed");

+ 8 - 8
src/protocols/Eviction.java

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

+ 8 - 8
src/protocols/PermuteIndex.java

@@ -39,7 +39,7 @@ public class PermuteIndex extends Protocol {
 		timer.stop(pid, M.online_write);
 
 		timer.start(pid, M.online_read);
-		byte[][] g = con2.readDoubleByteArray();
+		byte[][] g = con2.readObject();
 		timer.stop(pid, M.online_read);
 
 		ti = Util.xor(predata.pi_a, g);
@@ -60,7 +60,7 @@ public class PermuteIndex extends Protocol {
 		timer.start(pid, M.online_comp);
 
 		timer.start(pid, M.online_read);
-		byte[][] z = con2.readDoubleByteArray();
+		byte[][] z = con2.readObject();
 		timer.stop(pid, M.online_read);
 
 		z = Util.xor(z, predata.pi_r);
@@ -111,7 +111,7 @@ public class PermuteIndex extends Protocol {
 
 				runE();
 
-				int[] ti_pp = con1.readIntArray();
+				int[] ti_pp = con1.readObject();
 				ti = Util.permute(ti, predata.evict_pi);
 				int j = 0;
 				for (; j < d; j++) {
@@ -126,9 +126,9 @@ public class PermuteIndex extends Protocol {
 					System.out.println("PermuteIndex test passed");
 
 			} else if (party == Party.Debbie) {
-				predata.evict_pi = con1.readIntArray();
-				predata.evict_rho = con1.readDoubleByteArray();
-				byte[][] ti = con1.readDoubleByteArray();
+				predata.evict_pi = con1.readObject();
+				predata.evict_rho = con1.readObject();
+				byte[][] ti = con1.readObject();
 				int w = con1.readInt();
 
 				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.readIntArray();
-				predata.evict_rho = con1.readDoubleByteArray();
+				predata.evict_pi = con1.readObject();
+				predata.evict_rho = con1.readObject();
 
 				prepermuteindex.runC(predata, timer);
 

+ 8 - 8
src/protocols/PermuteTarget.java

@@ -61,7 +61,7 @@ public class PermuteTarget extends Protocol {
 		timer.stop(pid, M.online_write);
 
 		timer.start(pid, M.online_read);
-		byte[][] g = con2.readDoubleByteArray();
+		byte[][] g = con2.readObject();
 		timer.stop(pid, M.online_read);
 
 		target = Util.xor(predata.pt_a, g);
@@ -82,8 +82,8 @@ public class PermuteTarget extends Protocol {
 
 		// PermuteTargetII
 		timer.start(pid, M.online_read);
-		byte[][] z = con2.readDoubleByteArray();
-		int[] I = con2.readIntArray();
+		byte[][] z = con2.readObject();
+		int[] I = con2.readObject();
 		timer.stop(pid, M.online_read);
 
 		byte[][] mk = new byte[z.length][];
@@ -137,7 +137,7 @@ public class PermuteTarget extends Protocol {
 
 				runE();
 
-				int[] target_pp = con1.readIntArray();
+				int[] target_pp = con1.readObject();
 				int[] pi_ivs = Util.inversePermutation(predata.evict_pi);
 				int[] piTargetPiIvs = new int[d];
 
@@ -154,9 +154,9 @@ public class PermuteTarget extends Protocol {
 
 			} else if (party == Party.Debbie) {
 				int d = con1.readInt();
-				predata.evict_pi = con1.readIntArray();
-				predata.evict_targetOutKeyPairs = con1.readTripleGCSignalArray();
-				GCSignal[][] targetOutKeys = con1.readDoubleGCSignalArray();
+				predata.evict_pi = con1.readObject();
+				predata.evict_targetOutKeyPairs = con1.readObject();
+				GCSignal[][] targetOutKeys = con1.readObject();
 
 				prepermutetarget.runD(predata, d, timer);
 
@@ -164,7 +164,7 @@ public class PermuteTarget extends Protocol {
 				con1.write(target_pp);
 
 			} else if (party == Party.Charlie) {
-				predata.evict_pi = con1.readIntArray();
+				predata.evict_pi = con1.readObject();
 
 				prepermutetarget.runC(predata, timer);
 

+ 4 - 4
src/protocols/PostProcessT.java

@@ -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(BigInteger.valueOf(N));
+							con2.write(N);
 
 						prepostprocesst.runE(predata, timer);
 						Tuple Ti_prime = runE(predata, outaccess.E_Ti, ti == numTrees - 1, timer);
 
-						Ti_prime.setXor(con2.readTuple());
+						Ti_prime.setXor(con2.readObject());
 						byte[] Li_prime = Util.xor(predata.ppt_Li, con2.read());
 						byte[] Lip1_prime = Util.xor(predata.ppt_Lip1, con2.read());
 						int j2 = con2.readInt();
-						Tuple Ti = outaccess.E_Ti.xor(con2.readTuple());
+						Tuple Ti = outaccess.E_Ti.xor(con2.readObject());
 
 						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.readBigInteger().longValue();
+							N = con1.readLong();
 							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.readTupleArray();
+		Tuple[] z = con2.readObject();
 		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(BigInteger.valueOf(N));
+							con2.write(N);
 
 						prereshuffle.runE(predata, timer);
 						Tuple[] E_P_prime = runE(predata, outaccess.E_P, ti == 0, timer);
 
-						Tuple[] C_P = con2.readTupleArray();
-						Tuple[] C_P_prime = con2.readTupleArray();
+						Tuple[] C_P = con2.readObject();
+						Tuple[] C_P_prime = con2.readObject();
 						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.readBigInteger().longValue();
+							N = con1.readLong();
 							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(BigInteger.valueOf(N));
+							con2.write(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.readBigInteger().longValue();
+							N = con1.readLong();
 							long data = new BigInteger(1, outaccess.C_Ti.getA()).longValue();
 							if (N == data) {
 								System.out.println("Access passed");

+ 6 - 6
src/protocols/SSCOT.java

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

+ 3 - 3
src/protocols/SSIOT.java

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

+ 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.readTupleArray();
+		a = con2.readObject();
 
 		// step 2
-		int[] j = con1.readIntArray();
-		Tuple[] p = con1.readTupleArray();
+		int[] j = con1.readObject();
+		Tuple[] p = con1.readObject();
 		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.readTupleArray();
+		a = con1.readObject();
 
 		// step 2
-		int[] j = con2.readIntArray();
-		Tuple[] p = con2.readTupleArray();
+		int[] j = con2.readObject();
+		Tuple[] p = con2.readObject();
 		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.readIntArray();
-				E_m = con1.readTupleArray();
-				Tuple[] E_out_m = con1.readTupleArray();
+				index = con2.readObject();
+				E_m = con1.readObject();
+				Tuple[] E_out_m = con1.readObject();
 
 				boolean pass = true;
 				for (int i = 0; i < index.length; i++) {

+ 7 - 7
src/protocols/UpdateRoot.java

@@ -66,12 +66,12 @@ public class UpdateRoot extends Protocol {
 
 		// step 1
 		timer.start(pid, M.online_read);
-		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();
+		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(pid, M.online_read);
 
 		// step 2
@@ -151,7 +151,7 @@ public class UpdateRoot extends Protocol {
 				preupdateroot.runE(predata, false, sw, lBits, timer);
 				Tuple[] newR = runE(predata, false, Li, R, Ti, timer);
 
-				Tuple[] R_C = con2.readTupleArray();
+				Tuple[] R_C = con2.readObject();
 				int cnt = 0;
 				int[] index = new int[3];
 				for (int j = 0; j < sw; j++) {

+ 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.readIntArray();
-		predata.access_p = con1.readTupleArray();
+		predata.access_sigma = con1.readObject();
+		predata.access_p = con1.readObject();
 		timer.stop(pid, M.offline_read);
 
 		timer.stop(pid, M.offline_comp);

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

@@ -162,8 +162,8 @@ public class PreEviction extends Protocol {
 		eva.setEvaluate();
 
 		timer.start(pid, M.offline_read);
-		predata.evict_tiOutKeyHashes = con1.readTripleByteArray();
-		predata.evict_targetOutKeyPairs = con1.readTripleGCSignalArray();
+		predata.evict_tiOutKeyHashes = con1.readObject();
+		predata.evict_targetOutKeyPairs = con1.readObject();
 		timer.stop(pid, M.offline_read);
 
 		// PermuteTarget
@@ -190,15 +190,15 @@ public class PreEviction extends Protocol {
 
 		// GC
 		timer.start(pid, M.offline_read);
-		predata.evict_C_feKeyPairs = con1.readTripleGCSignalArray();
-		predata.evict_C_labelKeyPairs = con1.readQuadGCSignalArray();
+		predata.evict_C_feKeyPairs = con1.readObject();
+		predata.evict_C_labelKeyPairs = con1.readObject();
 
 		// Permutation
-		predata.evict_pi = con1.readIntArray();
-		predata.evict_delta = con1.readDoubleByteArray();
-		predata.evict_rho = con1.readDoubleByteArray();
-		predata.evict_delta_p = con1.readDoubleIntArray();
-		predata.evict_rho_p = con1.readDoubleIntArray();
+		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();
 		timer.stop(pid, M.offline_read);
 
 		// PermuteTarget

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

@@ -46,14 +46,14 @@ public class PrePermuteIndex extends Protocol {
 
 	public void runD(PreData predata, Timer timer) {
 		timer.start(pid, M.offline_read);
-		predata.pi_p = con1.readDoubleByteArray();
-		predata.pi_a = con1.readDoubleByteArray();
+		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.readDoubleByteArray();
+		predata.pi_r = con1.readObject();
 		timer.stop(pid, M.offline_read);
 	}
 

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

@@ -83,22 +83,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.readTripleByteArray();
-		predata.pt_targetT = con1.readTripleByteArray();
+		predata.pt_keyT = con1.readObject();
+		predata.pt_targetT = con1.readObject();
 
 		// PermuteTargetII
-		predata.pt_p = con1.readDoubleByteArray();
-		predata.pt_a = con1.readDoubleByteArray();
+		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.readTripleByteArray();
+		predata.pt_maskT = con1.readObject();
 
 		// PermuteTargetII
-		predata.pt_r = con1.readDoubleByteArray();
+		predata.pt_r = con1.readObject();
 		timer.stop(pid, M.offline_read);
 	}
 

+ 2 - 2
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.readDoubleByteArray();
+		predata.ppt_s = con1.readObject();
 		timer.stop(pid, M.offline_read);
 	}
 
@@ -71,7 +71,7 @@ public class PrePostProcessT extends Protocol {
 
 		timer.start(pid, M.offline_read);
 		predata.ppt_alpha = con2.readInt();
-		predata.ppt_r = con2.readDoubleByteArray();
+		predata.ppt_r = con2.readObject();
 		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.readTupleArray();
+		predata.reshuffle_r = con1.readObject();
 		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.readTupleArray();
-		predata.reshuffle_a_prime = con2.readTupleArray();
+		predata.reshuffle_p = con2.readObject();
+		predata.reshuffle_a_prime = con2.readObject();
 		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.readDoubleByteArray();
+		predata.sscot_r = con1.readObject();
 		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.readIntArray();
-		predata.ssxot_E_r[id] = con1.readTupleArray();
+		predata.ssxot_E_pi[id] = con1.readObject();
+		predata.ssxot_E_r[id] = con1.readObject();
 		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.readIntArray();
-		predata.ssxot_C_r[id] = con2.readTupleArray();
+		predata.ssxot_C_pi[id] = con2.readObject();
+		predata.ssxot_C_r[id] = con2.readObject();
 		timer.stop(pid, M.offline_read);
 	}
 

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

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