Kaynağa Gözat

PIRCOT (KSearch) implemented

Boyang Wei 6 yıl önce
ebeveyn
işleme
d0c3cba5e0
40 değiştirilmiş dosya ile 275 ekleme ve 133 silme
  1. 14 15
      ObliVMGC/com/oblivm/backend/rand/ISAACEngine.java
  2. 14 16
      src/communication/Communication.java
  3. 4 0
      src/crypto/Crypto.java
  4. 1 0
      src/oram/Global.java
  5. 1 1
      src/pir/PIRAccess.java
  6. 147 50
      src/pir/PIRCOT.java
  7. 1 1
      src/pir/PIREviction.java
  8. 1 1
      src/pir/PIRIOT.java
  9. 1 1
      src/pir/PIRReshuffle.java
  10. 1 1
      src/pir/precomputation/PrePIRAccess.java
  11. 34 13
      src/pir/precomputation/PrePIRCOT.java
  12. 1 1
      src/pir/precomputation/PrePIRIOT.java
  13. 1 1
      src/pir/precomputation/PrePIRReshuffle.java
  14. 1 1
      src/pir/precomputation/PrePIRRetrieve.java
  15. 1 1
      src/protocols/Access.java
  16. 1 1
      src/protocols/Eviction.java
  17. 1 1
      src/protocols/PermuteIndex.java
  18. 1 1
      src/protocols/PermuteTarget.java
  19. 1 1
      src/protocols/PostProcessT.java
  20. 6 6
      src/protocols/Protocol.java
  21. 1 1
      src/protocols/Reshuffle.java
  22. 1 1
      src/protocols/Retrieve.java
  23. 1 1
      src/protocols/SSCOT.java
  24. 1 1
      src/protocols/SSIOT.java
  25. 1 1
      src/protocols/SSXOT.java
  26. 1 1
      src/protocols/UpdateRoot.java
  27. 1 1
      src/protocols/precomputation/PreAccess.java
  28. 1 1
      src/protocols/precomputation/PreEviction.java
  29. 1 1
      src/protocols/precomputation/PrePermuteIndex.java
  30. 1 1
      src/protocols/precomputation/PrePermuteTarget.java
  31. 1 1
      src/protocols/precomputation/PrePostProcessT.java
  32. 1 1
      src/protocols/precomputation/PreReshuffle.java
  33. 1 1
      src/protocols/precomputation/PreRetrieve.java
  34. 1 1
      src/protocols/precomputation/PreSSCOT.java
  35. 1 1
      src/protocols/precomputation/PreSSIOT.java
  36. 1 1
      src/protocols/precomputation/PreSSXOT.java
  37. 1 1
      src/protocols/precomputation/PreUpdateRoot.java
  38. 10 0
      src/protocols/struct/OutPIRCOT.java
  39. 3 0
      src/protocols/struct/PreData.java
  40. 12 3
      src/ui/CLI.java

+ 14 - 15
ObliVMGC/com/oblivm/backend/rand/ISAACEngine.java

@@ -83,8 +83,8 @@ public class ISAACEngine extends SecureRandomSpi {
 	}
 
 	/**
-	 * Reseeds this random object. The given seed supplements, rather than
-	 * replaces, the existing seed.
+	 * Reseeds this random object. The given seed supplements, rather than replaces,
+	 * the existing seed.
 	 * 
 	 * @param seed
 	 *            The seed.
@@ -100,10 +100,10 @@ public class ISAACEngine extends SecureRandomSpi {
 	private static final int[] mask = new int[] { 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF };
 
 	/**
-	 * Returns a byte array containing the two's-complement representation of
-	 * the integer.<br>
-	 * The byte array will be in big-endian byte-order with a fixes length of 4
-	 * (the least significant byte is in the 4th element).<br>
+	 * Returns a byte array containing the two's-complement representation of the
+	 * integer.<br>
+	 * The byte array will be in big-endian byte-order with a fixes length of 4 (the
+	 * least significant byte is in the 4th element).<br>
 	 * <br>
 	 * <u>Example:</u><br>
 	 * <code>toByteArray(258)</code> returns { 0, 0, 1, 2 },<br>
@@ -128,9 +128,9 @@ public class ISAACEngine extends SecureRandomSpi {
 	 * one-bit in the two's complement binary representation of the specified
 	 * integer value.
 	 * 
-	 * @return The number of zero bits preceding the highest-order one-bit in
-	 *         the two's complement binary representation of the specified
-	 *         integer value, or 32 if the value is equal to zero.
+	 * @return The number of zero bits preceding the highest-order one-bit in the
+	 *         two's complement binary representation of the specified integer
+	 *         value, or 32 if the value is equal to zero.
 	 */
 	private static int numberOfLeadingZeros(int intValue) {
 		if (intValue == 0)
@@ -150,16 +150,15 @@ public class ISAACEngine extends SecureRandomSpi {
 	}
 
 	/**
-	 * Creates an array of integers and "packs" the bytes from the byte array
-	 * into it.<br>
+	 * Creates an array of integers and "packs" the bytes from the byte array into
+	 * it.<br>
 	 * This method returns an integer array of length zero if <code>ba</code> is
 	 * <code>null</code>.<br>
 	 * <br>
 	 * <u>Example:</u><br>
-	 * <code>packToIntArray(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 })</code>
-	 * returns an integer array<br>
-	 * containing the values <code>0x01020304</code> and <code>0x00000005</code>
-	 * .
+	 * <code>packToIntArray(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 })</code> returns
+	 * an integer array<br>
+	 * containing the values <code>0x01020304</code> and <code>0x00000005</code> .
 	 * 
 	 * @param ba
 	 *            The byte array, may be <code>null</code>.

+ 14 - 16
src/communication/Communication.java

@@ -111,8 +111,8 @@ public class Communication {
 	}
 
 	/**
-	 * Start the communication service. Specifically start AcceptThread to begin
-	 * a session in listening (server) mode.
+	 * Start the communication service. Specifically start AcceptThread to begin a
+	 * session in listening (server) mode.
 	 */
 	public synchronized void start(int port) {
 		if (D)
@@ -203,8 +203,7 @@ public class Communication {
 
 		// Don't throw out connections if we are already connected
 		/*
-		 * if (mState == STATE_CONNECTING || mConnectedThread != null) { return;
-		 * }
+		 * if (mState == STATE_CONNECTING || mConnectedThread != null) { return; }
 		 */
 
 		mNumTries++;
@@ -511,9 +510,9 @@ public class Communication {
 	}
 
 	/*
-	 * This was added to allow backwords compaitibility with older versions
-	 * which used the default charset (usually utf-8) instead of asc-ii. This is
-	 * almost never what we want to do
+	 * This was added to allow backwords compaitibility with older versions which
+	 * used the default charset (usually utf-8) instead of asc-ii. This is almost
+	 * never what we want to do
 	 */
 	public void write(String buffer, Charset charset) {
 		write(buffer.getBytes(charset));
@@ -564,8 +563,8 @@ public class Communication {
 	}
 
 	/**
-	 * Read a specific number of bytes from the ConnectedThread in an
-	 * unsynchronized manner Note, this is a blocking call
+	 * Read a specific number of bytes from the ConnectedThread in an unsynchronized
+	 * manner Note, this is a blocking call
 	 * 
 	 * @return the bytes read
 	 * @see ConnectedThread#read()
@@ -732,9 +731,9 @@ public class Communication {
 	}
 
 	/**
-	 * This thread runs while listening for incoming connections. It behaves
-	 * like a server-side client. It runs until a connection is accepted (or
-	 * until cancelled).
+	 * This thread runs while listening for incoming connections. It behaves like a
+	 * server-side client. It runs until a connection is accepted (or until
+	 * cancelled).
 	 */
 	private class AcceptThread extends Thread {
 		// The local server socket
@@ -813,8 +812,7 @@ public class Communication {
 
 	/**
 	 * This thread runs while attempting to make an outgoing connection with a
-	 * device. It runs straight through; the connection either succeeds or
-	 * fails.
+	 * device. It runs straight through; the connection either succeeds or fails.
 	 */
 	private class ConnectThread extends Thread {
 		private final Socket mmSocket;
@@ -916,8 +914,8 @@ public class Communication {
 		/**
 		 * Read from the ConnectedThread in an unsynchronized manner
 		 * 
-		 * This is a blocking call and will only return data if the readLoop
-		 * flag is false
+		 * This is a blocking call and will only return data if the readLoop flag is
+		 * false
 		 * 
 		 * @return the bytes read
 		 * @see ConnectedThread#read()

+ 4 - 0
src/crypto/Crypto.java

@@ -9,6 +9,8 @@ public class Crypto {
 	public static MessageDigest sha1;
 	public static int secParam;
 	public static int secParamBytes;
+	public static int KSearchRerunParam;
+	public static int KSearchRerunParamBytes;
 
 	static {
 		try {
@@ -19,5 +21,7 @@ public class Crypto {
 		}
 		secParam = 80;
 		secParamBytes = (secParam + 7) / 8;
+		KSearchRerunParam = 32;
+		KSearchRerunParamBytes = (KSearchRerunParam + 7) / 8;
 	}
 }

+ 1 - 0
src/oram/Global.java

@@ -4,5 +4,6 @@ public class Global {
 
 	public static boolean cheat = true;
 	public static boolean pipeline = false;
+	public static boolean usePIR = true;
 
 }

+ 1 - 1
src/pir/PIRAccess.java

@@ -504,6 +504,6 @@ public class PIRAccess extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 147 - 50
src/pir/PIRCOT.java

@@ -8,6 +8,7 @@ import oram.Forest;
 import oram.Metadata;
 import pir.precomputation.PrePIRCOT;
 import protocols.Protocol;
+import protocols.struct.OutPIRCOT;
 import protocols.struct.OutSSCOT;
 import protocols.struct.Party;
 import protocols.struct.PreData;
@@ -24,6 +25,152 @@ public class PIRCOT extends Protocol {
 		super(con1, con2);
 	}
 
+	public OutPIRCOT runE(PreData predata, byte[][] u, byte[] v, Timer timer) {
+		int l = u.length;
+		byte[][] a = new byte[l][];
+		for (int j = 0; j < l; j++) {
+			a[j] = Util.xor(u[(j + predata.sscot_s_DE) % l], v);
+			a[j] = Util.padArray(a[j], predata.sscot_r[j].length);
+			Util.setXor(a[j], predata.sscot_r[j]);
+			a[j] = predata.sscot_F_k.compute(a[j]);
+		}
+
+		con2.write(pid, a);
+
+		int delta = con2.readInt(pid);
+		int t_E = (predata.sscot_s_DE + delta) % l;
+
+		OutPIRCOT out = new OutPIRCOT();
+		out.t_E = t_E;
+		out.s_DE = predata.sscot_s_DE;
+		out.s_CE = predata.sscot_s_CE;
+		return out;
+	}
+
+	public OutPIRCOT runD(PreData predata, byte[][] u, byte[] v, Timer timer) {
+		int l = u.length;
+		byte[][] a = new byte[l][];
+		for (int j = 0; j < l; j++) {
+			a[j] = Util.xor(u[(j + l - predata.sscot_s_DE) % l], v);
+			a[j] = Util.padArray(a[j], predata.sscot_r[j].length);
+			Util.setXor(a[j], predata.sscot_r[j]);
+			a[j] = predata.sscot_F_k.compute(a[j]);
+		}
+
+		con2.write(pid, a);
+
+		int delta = con2.readInt(pid);
+		int t_D = (predata.sscot_s_DE + delta) % l;
+
+		OutPIRCOT out = new OutPIRCOT();
+		out.t_D = t_D;
+		out.s_DE = predata.sscot_s_DE;
+		out.s_CD = predata.sscot_s_CD;
+		return out;
+	}
+
+	public OutPIRCOT runC(PreData predata, Timer timer) {
+		byte[][] x = con1.readDoubleByteArray(pid);
+		byte[][] y = con2.readDoubleByteArray(pid);
+		int l = x.length;
+
+		int count = 0;
+		int t_C = 0;
+		for (int i = 0; i < l; i++) {
+			if (Util.equal(x[i], y[i])) {
+				t_C = i;
+				count++;
+			}
+		}
+
+		if (count != 1) {
+			throw new SSCOTException("Invariant error: " + count);
+		}
+
+		int delta_D = (t_C - predata.sscot_s_CE + l) % l;
+		con2.write(pid, delta_D);
+		int delta_E = (t_C - predata.sscot_s_CD + l) % l;
+		con1.write(pid, delta_E);
+
+		OutPIRCOT out = new OutPIRCOT();
+		out.t_C = t_C;
+		out.s_CE = predata.sscot_s_CE;
+		out.s_CD = predata.sscot_s_CD;
+		return out;
+	}
+
+	@Override
+	public void run(Party party, Metadata md, Forest[] forest) {
+
+		Timer timer = new Timer();
+
+		for (int j = 0; j < 100; j++) {
+			int n = 100;
+			int FN = 5;
+			byte[][] a = new byte[n][FN];
+			byte[][] b = new byte[n][FN];
+			for (int i = 0; i < n; i++) {
+				Crypto.sr.nextBytes(a[i]);
+			}
+			int index = Crypto.sr.nextInt(n);
+			byte[] v = a[index].clone();
+
+			PreData predata = new PreData();
+			PrePIRCOT presscot = new PrePIRCOT(con1, con2);
+			OutPIRCOT output;
+
+			if (party == Party.Eddie) {
+				con2.write(index);
+				presscot.runE(predata, n, timer);
+				output = runE(predata, a, v, timer);
+
+				con2.write(output.t_E);
+				con2.write(output.s_CE);
+				con2.write(output.s_DE);
+
+			} else if (party == Party.Debbie) {
+				presscot.runD(predata, n, timer);
+				output = runD(predata, b, new byte[FN], timer);
+
+				con2.write(output.t_D);
+				con2.write(output.s_DE);
+				con2.write(output.s_CD);
+
+			} else if (party == Party.Charlie) {
+				index = con1.readInt();
+				presscot.runC(predata, timer);
+				output = runC(predata, timer);
+
+				int t_E = con1.readInt();
+				int s_CE = con1.readInt();
+				int s_DE = con1.readInt();
+				if ((t_E + output.s_CD) % n != index)
+					System.err.println(j + ": PIRCOT test failed 1");
+				else if (s_CE != output.s_CE)
+					System.err.println(j + ": PIRCOT test failed 2");
+				else if ((s_DE + output.t_C) % n != index)
+					System.err.println(j + ": PIRCOT test failed 3");
+				else
+					System.out.println(j + ": PIRCOT first half test passed");
+
+				int t_D = con2.readInt();
+				s_DE = con2.readInt();
+				int s_CD = con2.readInt();
+				if ((t_D + output.s_CE) % n != index)
+					System.err.println(j + ": PIRCOT test failed 4");
+				else if (s_CD != output.s_CD)
+					System.err.println(j + ": PIRCOT test failed 5");
+				else if ((s_DE + output.t_C) % n != index)
+					System.err.println(j + ": PIRCOT test failed 6");
+				else
+					System.out.println(j + ": PIRCOT all test passed");
+
+			} else {
+				throw new NoSuchPartyException(party + "");
+			}
+		}
+	}
+
 	public void runE(PreData predata, byte[][] a, Timer timer) {
 		timer.start(pid, M.online_comp);
 
@@ -101,55 +248,5 @@ public class PIRCOT extends Protocol {
 	// for testing correctness
 	@Override
 	public void run(Party party, Metadata md, Forest forest) {
-		Timer timer = new Timer();
-
-		for (int j = 0; j < 100; j++) {
-			int n = 100;
-			int FN = 5;
-			byte[][] a = new byte[n][FN];
-			byte[][] b = new byte[n][FN];
-			for (int i = 0; i < n; i++) {
-				Crypto.sr.nextBytes(a[i]);
-				Crypto.sr.nextBytes(b[i]);
-				while (Util.equal(a[i], b[i]))
-					Crypto.sr.nextBytes(b[i]);
-			}
-			int index = Crypto.sr.nextInt(n);
-			b[index] = a[index].clone();
-
-			PreData predata = new PreData();
-			PrePIRCOT presscot = new PrePIRCOT(con1, con2);
-			if (party == Party.Eddie) {
-				con1.write(b);
-				con2.write(index);
-				presscot.runE(predata, n, timer);
-				runE(predata, a, timer);
-
-			} else if (party == Party.Debbie) {
-				b = con1.readDoubleByteArray();
-				presscot.runD(predata, timer);
-				runD(predata, b, timer);
-
-			} else if (party == Party.Charlie) {
-				index = con1.readInt();
-				presscot.runC();
-				OutSSCOT output = runC(timer);
-				if (output.t == index)
-					System.out.println("PIRCOT test passed");
-				else
-					System.err.println("PIRCOT test failed");
-
-			} else {
-				throw new NoSuchPartyException(party + "");
-			}
-		}
-
-		// timer.print();
-	}
-
-	@Override
-	public void run(Party party, Metadata md, Forest[] forest) {
-		// TODO Auto-generated method stub
-		
 	}
 }

+ 1 - 1
src/pir/PIREviction.java

@@ -273,6 +273,6 @@ public class PIREviction extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/pir/PIRIOT.java

@@ -140,6 +140,6 @@ public class PIRIOT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/pir/PIRReshuffle.java

@@ -216,6 +216,6 @@ public class PIRReshuffle extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/pir/precomputation/PrePIRAccess.java

@@ -89,6 +89,6 @@ public class PrePIRAccess extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 34 - 13
src/pir/precomputation/PrePIRCOT.java

@@ -20,42 +20,63 @@ public class PrePIRCOT extends Protocol {
 		super(con1, con2);
 	}
 
-	public void runE(PreData predata, int n, Timer timer) {
+	// TODO: change PRF output bits to max(32, N)
+
+	public void runE(PreData predata, int l, Timer timer) {
 		timer.start(pid, M.offline_comp);
 
-		predata.sscot_kprime = PRF.generateKey(Crypto.sr);
-		predata.sscot_r = new byte[n][];
-		for (int i = 0; i < n; i++) {
+		predata.sscot_k = PRF.generateKey(Crypto.sr);
+		predata.sscot_r = new byte[l][];
+		for (int i = 0; i < l; i++) {
 			predata.sscot_r[i] = new byte[Crypto.secParamBytes];
 			Crypto.sr.nextBytes(predata.sscot_r[i]);
 		}
+		predata.sscot_s_DE = Crypto.sr.nextInt(l);
+		predata.sscot_s_CE = Crypto.sr.nextInt(l);
 
 		timer.start(pid, M.offline_write);
-		con1.write(predata.sscot_kprime);
+		con1.write(predata.sscot_k);
 		con1.write(predata.sscot_r);
+		con1.write(predata.sscot_s_DE);
+		con2.write(predata.sscot_s_CE);
 		timer.stop(pid, M.offline_write);
 
-		predata.sscot_F_kprime = new PRF(Crypto.secParam);
-		predata.sscot_F_kprime.init(predata.sscot_kprime);
+		predata.sscot_F_k = new PRF(Crypto.secParam);
+		predata.sscot_F_k.init(predata.sscot_k);
 
 		timer.stop(pid, M.offline_comp);
 	}
 
-	public void runD(PreData predata, Timer timer) {
+	public void runD(PreData predata, int l, Timer timer) {
 		timer.start(pid, M.offline_comp);
 
+		predata.sscot_s_CD = Crypto.sr.nextInt(l);
+
+		timer.start(pid, M.offline_write);
+		con2.write(predata.sscot_s_CD);
+		timer.stop(pid, M.offline_write);
+
 		timer.start(pid, M.offline_read);
-		predata.sscot_kprime = con1.read();
+		predata.sscot_k = con1.read();
 		predata.sscot_r = con1.readDoubleByteArray();
+		predata.sscot_s_DE = con1.readInt();
 		timer.stop(pid, M.offline_read);
 
-		predata.sscot_F_kprime = new PRF(Crypto.secParam);
-		predata.sscot_F_kprime.init(predata.sscot_kprime);
+		predata.sscot_F_k = new PRF(Crypto.secParam);
+		predata.sscot_F_k.init(predata.sscot_k);
 
 		timer.stop(pid, M.offline_comp);
 	}
 
-	public void runC() {
+	public void runC(PreData predata, Timer timer) {
+		timer.start(pid, M.offline_comp);
+
+		timer.start(pid, M.offline_read);
+		predata.sscot_s_CE = con1.readInt();
+		predata.sscot_s_CD = con2.readInt();
+		timer.stop(pid, M.offline_read);
+
+		timer.stop(pid, M.offline_comp);
 	}
 
 	@Override
@@ -65,6 +86,6 @@ public class PrePIRCOT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/pir/precomputation/PrePIRIOT.java

@@ -62,6 +62,6 @@ public class PrePIRIOT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/pir/precomputation/PrePIRReshuffle.java

@@ -70,6 +70,6 @@ public class PrePIRReshuffle extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/pir/precomputation/PrePIRRetrieve.java

@@ -94,6 +94,6 @@ public class PrePIRRetrieve extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/Access.java

@@ -391,6 +391,6 @@ public class Access extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/Eviction.java

@@ -256,6 +256,6 @@ public class Eviction extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/PermuteIndex.java

@@ -155,6 +155,6 @@ public class PermuteIndex extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/PermuteTarget.java

@@ -181,6 +181,6 @@ public class PermuteTarget extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/PostProcessT.java

@@ -241,6 +241,6 @@ public class PostProcessT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 6 - 6
src/protocols/Protocol.java

@@ -76,10 +76,10 @@ public abstract class Protocol {
 
 		run(party, md, forest);
 	}
-	
+
 	// a simulation using a path instead of building whole tree
 	public void run(Party party, Metadata md) {
-		System.err.println("Check");
+		// System.err.println("Check");
 		assert Global.cheat;
 		Forest[] forests = new Forest[2];
 		// Eddie has x1, x2
@@ -93,7 +93,7 @@ public abstract class Protocol {
 		} else if (party == Party.Debbie) {
 			forests[0] = new Forest(md, Crypto.sr);
 			forests[1] = new Forest(md, null);
-			
+
 		} else if (party == Party.Charlie) {
 			forests[0] = new Forest(md, null);
 			forests[1] = new Forest(md, null);
@@ -106,10 +106,10 @@ public abstract class Protocol {
 	}
 
 	/*
-	 * This is mostly just testing code and may need to change for the purpose
-	 * of an actual execution
+	 * This is mostly just testing code and may need to change for the purpose of an
+	 * actual execution
 	 */
 	public abstract void run(Party party, Metadata md, Forest forest);
-	
+
 	public abstract void run(Party party, Metadata md, Forest[] forests);
 }

+ 1 - 1
src/protocols/Reshuffle.java

@@ -209,6 +209,6 @@ public class Reshuffle extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/Retrieve.java

@@ -377,6 +377,6 @@ public class Retrieve extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/SSCOT.java

@@ -168,6 +168,6 @@ public class SSCOT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/SSIOT.java

@@ -159,6 +159,6 @@ public class SSIOT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/SSXOT.java

@@ -182,6 +182,6 @@ public class SSXOT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 1 - 1
src/protocols/UpdateRoot.java

@@ -257,6 +257,6 @@ public class UpdateRoot extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -87,6 +87,6 @@ public class PreAccess extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -226,6 +226,6 @@ public class PreEviction extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -64,6 +64,6 @@ public class PrePermuteIndex extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -109,6 +109,6 @@ public class PrePermuteTarget extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -84,6 +84,6 @@ public class PrePostProcessT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -71,6 +71,6 @@ public class PreReshuffle extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -91,6 +91,6 @@ public class PreRetrieve extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -72,6 +72,6 @@ public class PreSSCOT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -69,6 +69,6 @@ public class PreSSIOT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -75,6 +75,6 @@ public class PreSSXOT extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

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

@@ -135,6 +135,6 @@ public class PreUpdateRoot extends Protocol {
 	@Override
 	public void run(Party party, Metadata md, Forest[] forest) {
 		// TODO Auto-generated method stub
-		
+
 	}
 }

+ 10 - 0
src/protocols/struct/OutPIRCOT.java

@@ -0,0 +1,10 @@
+package protocols.struct;
+
+public class OutPIRCOT {
+	public int t_C;
+	public int t_D;
+	public int t_E;
+	public int s_CE;
+	public int s_DE;
+	public int s_CD;
+}

+ 3 - 0
src/protocols/struct/PreData.java

@@ -11,6 +11,9 @@ public class PreData {
 	public byte[] sscot_k;
 	public byte[] sscot_kprime;
 	public byte[][] sscot_r;
+	public int sscot_s_DE;
+	public int sscot_s_CE;
+	public int sscot_s_CD;
 	public PRF sscot_F_k;
 	public PRF sscot_F_kprime;
 

+ 12 - 3
src/ui/CLI.java

@@ -155,10 +155,13 @@ public class CLI {
 				Protocol p = operationCtor.newInstance(con1[0], con2[0]);
 				if (protocol.equals("rtv")) {
 					((Retrieve) p).setCons(con1, con2);
-					p.run(Party.Eddie, md, forestFile);
 				}
 				if (protocol.equals("pirrtv")) {
 					((PIRRetrieve) p).setCons(con1, con2);
+				}
+				if (!Global.usePIR) {
+					p.run(Party.Eddie, md, forestFile);
+				} else {
 					p.run(Party.Eddie, md);
 				}
 			} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
@@ -197,10 +200,13 @@ public class CLI {
 				Protocol p = operationCtor.newInstance(con1[0], con2[0]);
 				if (protocol.equals("rtv")) {
 					((Retrieve) p).setCons(con1, con2);
-					p.run(Party.Debbie, md, forestFile);
 				}
 				if (protocol.equals("pirrtv")) {
 					((PIRRetrieve) p).setCons(con1, con2);
+				}
+				if (!Global.usePIR) {
+					p.run(Party.Debbie, md, forestFile);
+				} else {
 					p.run(Party.Debbie, md);
 				}
 			} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
@@ -240,10 +246,13 @@ public class CLI {
 				Protocol p = operationCtor.newInstance(con1[0], con2[0]);
 				if (protocol.equals("rtv")) {
 					((Retrieve) p).setCons(con1, con2);
-					p.run(Party.Charlie, md, forestFile);
 				}
 				if (protocol.equals("pirrtv")) {
 					((PIRRetrieve) p).setCons(con1, con2);
+				}
+				if (!Global.usePIR) {
+					p.run(Party.Charlie, md, forestFile);
+				} else {
 					p.run(Party.Charlie, md);
 				}
 			} catch (InstantiationException | IllegalAccessException | IllegalArgumentException