Boyoung- 8 лет назад
Родитель
Сommit
adaeb536e5

+ 19 - 8
src/pir/PIRRetrieve.java

@@ -12,12 +12,11 @@ import oram.Global;
 import oram.Metadata;
 import oram.Tree;
 import oram.Tuple;
+import pir.precomputation.PrePIRRetrieve;
 import protocols.Pipeline;
 import protocols.PostProcessT;
 import protocols.Protocol;
-import protocols.Reshuffle;
 import protocols.UpdateRoot;
-import protocols.precomputation.PreRetrieve;
 import protocols.struct.OutAccess;
 import protocols.struct.OutRetrieve;
 import protocols.struct.Party;
@@ -45,13 +44,19 @@ public class PIRRetrieve extends Protocol {
 	public byte[] runE(PreData[] predata, Tree OTi, byte[] Ni, byte[] Nip1_pr, int h, Timer timer) {
 		// 1st eviction
 		PIRAccess access = new PIRAccess(con1, con2);
-		Reshuffle reshuffle = new Reshuffle(con1, con2);
+		PIRReshuffle reshuffle = new PIRReshuffle(con1, con2);
 		PostProcessT postprocesst = new PostProcessT(con1, con2);
 		UpdateRoot updateroot = new UpdateRoot(con1, con2);
 		PIREviction eviction = new PIREviction(con1, con2);
 
 		OutAccess outaccess = access.runE(predata[0], OTi, Ni, Nip1_pr, timer);
-		Tuple[] path = reshuffle.runE(predata[0], outaccess.E_P, OTi.getTreeIndex() == 0, timer);
+		// Tuple[] path = reshuffle.runE(predata[0], outaccess.E_P,
+		// OTi.getTreeIndex() == 0, timer);
+		Tuple[] path = outaccess.E_P;
+		byte[][] fbArray = new byte[outaccess.E_P.length][];
+		for (int i = 0; i < fbArray.length; i++)
+			fbArray[i] = outaccess.E_P[i].getF();
+		reshuffle.runE(predata[0], fbArray, OTi.getTreeIndex() == 0, timer);
 		Tuple Ti = postprocesst.runE(predata[0], outaccess.E_Ti, OTi.getTreeIndex() == h - 1, timer);
 		Tuple[] root = Arrays.copyOfRange(path, 0, OTi.getStashSize());
 		root = updateroot.runE(predata[0], OTi.getTreeIndex() == 0, outaccess.Li, root, Ti, timer);
@@ -75,7 +80,7 @@ public class PIRRetrieve extends Protocol {
 	public void runD(PreData predata[], Tree OTi, byte[] Ni, byte[] Nip1_pr, Timer timer) {
 		// 1st eviction
 		PIRAccess access = new PIRAccess(con1, con2);
-		Reshuffle reshuffle = new Reshuffle(con1, con2);
+		PIRReshuffle reshuffle = new PIRReshuffle(con1, con2);
 		PostProcessT postprocesst = new PostProcessT(con1, con2);
 		UpdateRoot updateroot = new UpdateRoot(con1, con2);
 		PIREviction eviction = new PIREviction(con1, con2);
@@ -95,13 +100,19 @@ public class PIRRetrieve extends Protocol {
 	public OutAccess runC(PreData[] predata, Metadata md, Tree OTi, int ti, byte[] Li, Timer timer) {
 		// 1st eviction
 		PIRAccess access = new PIRAccess(con1, con2);
-		Reshuffle reshuffle = new Reshuffle(con1, con2);
+		PIRReshuffle reshuffle = new PIRReshuffle(con1, con2);
 		PostProcessT postprocesst = new PostProcessT(con1, con2);
 		UpdateRoot updateroot = new UpdateRoot(con1, con2);
 		PIREviction eviction = new PIREviction(con1, con2);
 
 		OutAccess outaccess = access.runC(md, OTi, ti, Li, timer);
-		Tuple[] path = reshuffle.runC(predata[0], outaccess.C_P, ti == 0, timer);
+		// Tuple[] path = reshuffle.runC(predata[0], outaccess.C_P, ti == 0,
+		// timer);
+		Tuple[] path = outaccess.C_P;
+		byte[][] fbArray = new byte[outaccess.C_P.length][];
+		for (int i = 0; i < fbArray.length; i++)
+			fbArray[i] = outaccess.C_P[i].getF();
+		reshuffle.runC(predata[0], fbArray, ti == 0, timer);
 		Tuple Ti = postprocesst.runC(predata[0], outaccess.C_Ti, Li, outaccess.C_Lip1, outaccess.C_j2,
 				ti == md.getNumTrees() - 1, timer);
 		Tuple[] root = Arrays.copyOfRange(path, 0, md.getStashSizeOfTree(ti));
@@ -216,7 +227,7 @@ public class PIRRetrieve extends Protocol {
 				System.out.print("Precomputation... ");
 
 				PreData[][] predata = new PreData[numTrees][2];
-				PreRetrieve preretrieve = new PreRetrieve(con1, con2);
+				PrePIRRetrieve preretrieve = new PrePIRRetrieve(con1, con2);
 				for (int ti = 0; ti < numTrees; ti++) {
 					predata[ti][0] = new PreData();
 					predata[ti][1] = new PreData();

+ 3 - 4
src/pir/precomputation/PrePIRRetrieve.java

@@ -6,7 +6,6 @@ import oram.Metadata;
 import protocols.Protocol;
 import protocols.precomputation.PreEviction;
 import protocols.precomputation.PrePostProcessT;
-import protocols.precomputation.PreReshuffle;
 import protocols.precomputation.PreUpdateRoot;
 import protocols.struct.Party;
 import protocols.struct.PreData;
@@ -22,7 +21,7 @@ public class PrePIRRetrieve extends Protocol {
 	public void runE(PreData[] predata, Metadata md, int ti, Timer timer) {
 		// 1st eviction
 		PrePIRAccess preaccess = new PrePIRAccess(con1, con2);
-		PreReshuffle prereshuffle = new PreReshuffle(con1, con2);
+		PrePIRReshuffle prereshuffle = new PrePIRReshuffle(con1, con2);
 		PrePostProcessT prepostprocesst = new PrePostProcessT(con1, con2);
 		PreUpdateRoot preupdateroot = new PreUpdateRoot(con1, con2);
 		PreEviction preeviction = new PreEviction(con1, con2);
@@ -45,7 +44,7 @@ public class PrePIRRetrieve extends Protocol {
 	public long[] runD(PreData[] predata, Metadata md, int ti, PreData prev, Timer timer) {
 		// 1st eviction
 		PrePIRAccess preaccess = new PrePIRAccess(con1, con2);
-		PreReshuffle prereshuffle = new PreReshuffle(con1, con2);
+		PrePIRReshuffle prereshuffle = new PrePIRReshuffle(con1, con2);
 		PrePostProcessT prepostprocesst = new PrePostProcessT(con1, con2);
 		PreUpdateRoot preupdateroot = new PreUpdateRoot(con1, con2);
 		PreEviction preeviction = new PreEviction(con1, con2);
@@ -72,7 +71,7 @@ public class PrePIRRetrieve extends Protocol {
 	public void runC(PreData[] predata, Metadata md, int ti, PreData prev, Timer timer) {
 		// 1st eviction
 		PrePIRAccess preaccess = new PrePIRAccess(con1, con2);
-		PreReshuffle prereshuffle = new PreReshuffle(con1, con2);
+		PrePIRReshuffle prereshuffle = new PrePIRReshuffle(con1, con2);
 		PrePostProcessT prepostprocesst = new PrePostProcessT(con1, con2);
 		PreUpdateRoot preupdateroot = new PreUpdateRoot(con1, con2);
 		PreEviction preeviction = new PreEviction(con1, con2);

+ 50 - 0
test/pir/TestPIRRetrieve_C.java

@@ -0,0 +1,50 @@
+package pir;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestPIRRetrieve_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 pirrtv 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/pir/TestPIRRetrieve_D.java

@@ -0,0 +1,50 @@
+package pir;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestPIRRetrieve_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 pirrtv 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/pir/TestPIRRetrieve_E.java

@@ -0,0 +1,50 @@
+package pir;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+public class TestPIRRetrieve_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 pirrtv 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();
+		}
+	}
+
+}