Browse Source

simplified some func args

Boyoung- 8 years ago
parent
commit
0243b04d52

+ 3 - 1
src/protocols/Access.java

@@ -238,7 +238,9 @@ public class Access extends Protocol {
 					if (party == Party.Eddie) {
 						Tree OTi = forest.getTree(ti);
 						int numTuples = (OTi.getD() - 1) * OTi.getW() + OTi.getStashSize();
-						preaccess.runE(predata, OTi, numTuples, timer);
+						int[] tupleParam = new int[] { ti == 0 ? 0 : 1, md.getNBytesOfTree(ti), md.getLBytesOfTree(ti),
+								md.getABytesOfTree(ti) };
+						preaccess.runE(predata, md.getTwoTauPow(), numTuples, tupleParam, timer);
 
 						byte[] sE_Ni = Util.nextBytes(Ni.length, Crypto.sr);
 						byte[] sD_Ni = Util.xor(Ni, sE_Ni);

+ 3 - 1
src/protocols/PostProcessT.java

@@ -136,7 +136,9 @@ public class PostProcessT extends Protocol {
 					if (party == Party.Eddie) {
 						Tree OTi = forest.getTree(ti);
 						int numTuples = (OTi.getD() - 1) * OTi.getW() + OTi.getStashSize();
-						preaccess.runE(predata, OTi, numTuples, timer);
+						int[] tupleParam = new int[] { ti == 0 ? 0 : 1, md.getNBytesOfTree(ti), md.getLBytesOfTree(ti),
+								md.getABytesOfTree(ti) };
+						preaccess.runE(predata, md.getTwoTauPow(), numTuples, tupleParam, timer);
 
 						byte[] sE_Ni = Util.nextBytes(Ni.length, Crypto.sr);
 						byte[] sD_Ni = Util.xor(Ni, sE_Ni);

+ 3 - 4
src/protocols/PreAccess.java

@@ -7,7 +7,6 @@ import measure.P;
 import measure.Timer;
 import oram.Forest;
 import oram.Metadata;
-import oram.Tree;
 import oram.Tuple;
 import util.Util;
 
@@ -16,7 +15,7 @@ public class PreAccess extends Protocol {
 		super(con1, con2);
 	}
 
-	public void runE(PreData predata, Tree OT, int numTuples, Timer timer) {
+	public void runE(PreData predata, int twotaupow, int numTuples, int[] tupleParam, Timer timer) {
 		timer.start(P.ACC, M.offline_comp);
 
 		// SSCOT
@@ -25,13 +24,13 @@ public class PreAccess extends Protocol {
 
 		// SSIOT
 		PreSSIOT pressiot = new PreSSIOT(con1, con2);
-		pressiot.runE(predata, OT.getTwoTauPow(), timer);
+		pressiot.runE(predata, twotaupow, timer);
 
 		// Access
 		predata.access_sigma = Util.randomPermutation(numTuples, Crypto.sr);
 		predata.access_p = new Tuple[numTuples];
 		for (int i = 0; i < numTuples; i++)
-			predata.access_p[i] = new Tuple(OT.getFBytes(), OT.getNBytes(), OT.getLBytes(), OT.getABytes(), Crypto.sr);
+			predata.access_p[i] = new Tuple(tupleParam[0], tupleParam[1], tupleParam[2], tupleParam[3], Crypto.sr);
 
 		timer.start(P.ACC, M.offline_write);
 		con1.write(predata.access_sigma);

+ 10 - 4
src/protocols/PreRetrieve.java

@@ -4,28 +4,34 @@ import communication.Communication;
 import measure.Timer;
 import oram.Forest;
 import oram.Metadata;
-import oram.Tree;
 
 public class PreRetrieve extends Protocol {
 	public PreRetrieve(Communication con1, Communication con2) {
 		super(con1, con2);
 	}
 
-	public void runE(PreData predata, Metadata md, int ti, Tree OT, int numTuples, Timer timer) {
+	public void runE(PreData predata, Metadata md, int ti, Timer timer) {
 		PreAccess preaccess = new PreAccess(con1, con2);
 		PreReshuffle prereshuffle = new PreReshuffle(con1, con2);
 		PrePostProcessT prepostprocesst = new PrePostProcessT(con1, con2);
 		
-		preaccess.runE(predata, OT, numTuples, timer);
+		int numTuples = md.getStashSizeOfTree(ti) + md.getLBitsOfTree(ti) * md.getW();
+		int[] tupleParam = new int[] { ti == 0 ? 0 : 1, md.getNBytesOfTree(ti), md.getLBytesOfTree(ti),
+				md.getABytesOfTree(ti) };
+		
+		preaccess.runE(predata, md.getTwoTauPow(), numTuples, tupleParam, timer);
 		prereshuffle.runE(predata, timer);
 		prepostprocesst.runE(predata, timer);
 	}
 
-	public void runD(PreData predata, Metadata md, int ti, PreData prev, int[] tupleParam, Timer timer) {
+	public void runD(PreData predata, Metadata md, int ti, PreData prev, Timer timer) {
 		PreAccess preaccess = new PreAccess(con1, con2);
 		PreReshuffle prereshuffle = new PreReshuffle(con1, con2); 
 		PrePostProcessT prepostprocesst = new PrePostProcessT(con1, con2);
 		
+		int[] tupleParam = new int[] { ti == 0 ? 0 : 1, md.getNBytesOfTree(ti), md.getLBytesOfTree(ti),
+				md.getABytesOfTree(ti) };
+		
 		preaccess.runD(predata, timer);
 		prereshuffle.runD(predata, tupleParam, timer);
 		prepostprocesst.runD(predata, prev, md.getLBytesOfTree(ti), md.getAlBytesOfTree(ti), md.getTau(), timer);

+ 3 - 1
src/protocols/Reshuffle.java

@@ -105,7 +105,9 @@ public class Reshuffle extends Protocol {
 					if (party == Party.Eddie) {
 						Tree OTi = forest.getTree(ti);
 						int numTuples = (OTi.getD() - 1) * OTi.getW() + OTi.getStashSize();
-						preaccess.runE(predata, OTi, numTuples, timer);
+						int[] tupleParam = new int[] { ti == 0 ? 0 : 1, md.getNBytesOfTree(ti), md.getLBytesOfTree(ti),
+								md.getABytesOfTree(ti) };
+						preaccess.runE(predata, md.getTwoTauPow(), numTuples, tupleParam, timer);
 
 						byte[] sE_Ni = Util.nextBytes(Ni.length, Crypto.sr);
 						byte[] sD_Ni = Util.xor(Ni, sE_Ni);

+ 2 - 5
src/protocols/Retrieve.java

@@ -95,8 +95,7 @@ public class Retrieve extends Protocol {
 
 					if (party == Party.Eddie) {
 						Tree OTi = forest.getTree(ti);
-						int numTuples = (OTi.getD() - 1) * OTi.getW() + OTi.getStashSize();
-						preretrieve.runE(predata, md, ti, OTi, numTuples, timer);
+						preretrieve.runE(predata, md, ti, timer);
 
 						byte[] sE_Ni = Util.nextBytes(Ni.length, Crypto.sr);
 						byte[] sD_Ni = Util.xor(Ni, sE_Ni);
@@ -115,9 +114,7 @@ public class Retrieve extends Protocol {
 
 					} else if (party == Party.Debbie) {
 						Tree OTi = forest.getTree(ti);
-						int[] tupleParam = new int[] { ti == 0 ? 0 : 1, md.getNBytesOfTree(ti), md.getLBytesOfTree(ti),
-								md.getABytesOfTree(ti) };
-						preretrieve.runD(predata, md, ti, prev, tupleParam, timer);
+						preretrieve.runD(predata, md, ti, prev, timer);
 
 						byte[] sD_Ni = con1.read();
 

+ 1 - 1
src/ui/CLI.java

@@ -87,7 +87,7 @@ public class CLI {
 			operation = PrepareTarget.class;
 		} else if (protocol.equals("mc")) {
 			operation = MakeCycle.class;
-		} else if (protocol.equals("rtv")) {
+		} else if (protocol.equals("retrieve")) {
 			operation = Retrieve.class;
 		} else {
 			System.out.println("Protocol " + protocol + " not supported");

+ 50 - 0
test/protocols/TestRetrieve_C.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestRetrieve_C {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol retrieve charlie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestRetrieve_D.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestRetrieve_D {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol retrieve debbie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 50 - 0
test/protocols/TestRetrieve_E.java

@@ -0,0 +1,50 @@
+package protocols;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestRetrieve_E {
+
+	public static void main(String[] args) {
+		Runtime runTime = Runtime.getRuntime();
+		Process process = null;
+		String dir = System.getProperty("user.dir");
+		String binDir = dir + "\\bin";
+		String libs = dir + "\\lib\\*";
+		try {
+			process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol retrieve eddie");
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		InputStream inputStream = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(inputStream);
+		InputStream errorStream = process.getErrorStream();
+		InputStreamReader esr = new InputStreamReader(errorStream);
+
+		System.out.println("STANDARD OUTPUT:");
+		int n1;
+		char[] c1 = new char[1024];
+		try {
+			while ((n1 = isr.read(c1)) > 0) {
+				System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		System.out.println("STANDARD ERROR:");
+		int n2;
+		char[] c2 = new char[1024];
+		try {
+			while ((n2 = esr.read(c2)) > 0) {
+				System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}