Boyoung- 9 лет назад
Родитель
Сommit
65ece39f27
3 измененных файлов с 31 добавлено и 29 удалено
  1. 21 14
      src/protocols/Access.java
  2. 7 11
      src/protocols/PreAccess.java
  3. 3 4
      src/protocols/PreData.java

+ 21 - 14
src/protocols/Access.java

@@ -24,12 +24,11 @@ public class Access extends Protocol {
 	public void runE(PreData predata, Tree OTi, byte[] Li, byte[] Nip1, byte[] Ni, byte[] Nip1_pr) {
 		// step 1
 		Bucket[] pathBuckets = OTi.getBucketsOnPath(new BigInteger(1, Li).longValue());
-		// Object[] objArray = Util.permute(pathBuckets, predata.access_sigma);
-		// pathBuckets = Arrays.copyOf(objArray, objArray.length,
-		// Bucket[].class);
-		for (int i = 0; i < pathBuckets.length; i++)
-			pathBuckets[i].setXor(predata.access_p[i]);
 		Tuple[] pathTuples = Bucket.bucketsToTuples(pathBuckets);
+		for (int i = 0; i < pathTuples.length; i++)
+			pathTuples[i].setXor(predata.access_p[i]);
+		Object[] objArray = Util.permute(pathTuples, predata.access_sigma);
+		pathTuples = Arrays.copyOf(objArray, objArray.length, Tuple[].class);
 
 		// step 3
 		byte[][] a = new byte[pathTuples.length][];
@@ -46,22 +45,23 @@ public class Access extends Protocol {
 		sscot.runE(predata, m, a);
 
 		// step 4
-		System.out.println(OTi.getTau() + " " + OTi.getTwoTauPow());
 		int ySegBytes = y.length / OTi.getTwoTauPow();
 		byte[][] y_array = new byte[OTi.getTwoTauPow()][];
 		for (int i = 0; i < OTi.getTwoTauPow(); i++)
 			y_array[i] = Arrays.copyOfRange(y, i * ySegBytes, (i + 1) * ySegBytes);
+
+		SSIOT ssiot = new SSIOT(con1, con2);
+		ssiot.runE(predata, y_array, Nip1_pr);
 	}
 
 	public void runD(PreData predata, Tree OTi, byte[] Li, byte[] Nip1, byte[] Ni, byte[] Nip1_pr) {
 		// step 1
 		Bucket[] pathBuckets = OTi.getBucketsOnPath(new BigInteger(1, Li).longValue());
-		// Object[] objArray = Util.permute(pathBuckets, predata.access_sigma);
-		// pathBuckets = Arrays.copyOf(objArray, objArray.length,
-		// Bucket[].class);
-		for (int i = 0; i < pathBuckets.length; i++)
-			pathBuckets[i].setXor(predata.access_p[i]);
 		Tuple[] pathTuples = Bucket.bucketsToTuples(pathBuckets);
+		for (int i = 0; i < pathTuples.length; i++)
+			pathTuples[i].setXor(predata.access_p[i]);
+		Object[] objArray = Util.permute(pathTuples, predata.access_sigma);
+		pathTuples = Arrays.copyOf(objArray, objArray.length, Tuple[].class);
 
 		// step 2
 		con2.write(pathTuples);
@@ -78,6 +78,10 @@ public class Access extends Protocol {
 
 		SSCOT sscot = new SSCOT(con1, con2);
 		sscot.runD(predata, b);
+
+		// step 4
+		SSIOT ssiot = new SSIOT(con1, con2);
+		ssiot.runD(predata, Nip1_pr);
 	}
 
 	public void runC() {
@@ -92,6 +96,9 @@ public class Access extends Protocol {
 		byte[] d = pathTuples[je.t].getA();
 		byte[] z = Util.xor(je.m_t, d);
 
+		// step 4
+		SSIOT ssiot = new SSIOT(con1, con2);
+		OutSSIOT jy = ssiot.runC();
 	}
 
 	@Override
@@ -100,17 +107,17 @@ public class Access extends Protocol {
 		PreAccess preaccess = new PreAccess(con1, con2);
 		int treeIndex = 1;
 		Tree tree = null;
-		int numBuckets = 0;
+		int numTuples = 0;
 		if (forest != null) {
 			tree = forest.getTree(treeIndex);
-			numBuckets = tree.getD();
+			numTuples = (tree.getD() - 1) * tree.getW() + tree.getStashSize();
 		}
 		byte[] Li = new BigInteger("11", 2).toByteArray();
 		byte[] Nip1 = new byte[] { 0 };
 		byte[] Ni = new byte[] { 0 };
 		byte[] Nip1_pr = new byte[] { 0 };
 		if (party == Party.Eddie) {
-			preaccess.runE(predata, tree, numBuckets);
+			preaccess.runE(predata, tree, numTuples);
 			runE(predata, tree, Li, Nip1, Ni, Nip1_pr);
 
 		} else if (party == Party.Debbie) {

+ 7 - 11
src/protocols/PreAccess.java

@@ -4,10 +4,10 @@ import java.util.Arrays;
 
 import communication.Communication;
 import crypto.Crypto;
-import oram.Bucket;
 import oram.Forest;
 import oram.Metadata;
 import oram.Tree;
+import oram.Tuple;
 import util.Util;
 
 public class PreAccess extends Protocol {
@@ -15,9 +15,8 @@ public class PreAccess extends Protocol {
 		super(con1, con2);
 	}
 
-	public void runE(PreData predata, Tree OT, int numBuckets) {
+	public void runE(PreData predata, Tree OT, int numTuples) {
 		// SSCOT
-		int numTuples = OT.getStashSize() + (numBuckets - 1) * OT.getW();
 		PreSSCOT presscot = new PreSSCOT(con1, con2);
 		presscot.runE(predata, numTuples);
 
@@ -26,13 +25,10 @@ public class PreAccess extends Protocol {
 		pressiot.runE(predata, OT.getTwoTauPow());
 
 		// Access
-		predata.access_sigma = Util.randomPermutation(numBuckets, Crypto.sr);
-
-		int[] tupleParam = new int[] { OT.getFBytes(), OT.getNBytes(), OT.getLBytes(), OT.getABytes() };
-		predata.access_p = new Bucket[numBuckets];
-		predata.access_p[0] = new Bucket(OT.getStashSize(), tupleParam, Crypto.sr);
-		for (int i = 1; i < numBuckets; i++)
-			predata.access_p[i] = new Bucket(OT.getW(), tupleParam, Crypto.sr);
+		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);
 
 		con1.write(predata.access_sigma);
 		con1.write(predata.access_p);
@@ -50,7 +46,7 @@ public class PreAccess extends Protocol {
 		// Access
 		predata.access_sigma = con1.readIntArray();
 		Object[] objArray = con1.readObjectArray();
-		predata.access_p = Arrays.copyOf(objArray, objArray.length, Bucket[].class);
+		predata.access_p = Arrays.copyOf(objArray, objArray.length, Tuple[].class);
 	}
 
 	public void runC() {

+ 3 - 4
src/protocols/PreData.java

@@ -1,6 +1,6 @@
 package protocols;
 
-import oram.Bucket;
+import oram.Tuple;
 
 public class PreData {
 	public byte[] sscot_k;
@@ -12,7 +12,6 @@ public class PreData {
 	public byte[] ssiot_r;
 
 	public int[] access_sigma;
-	public int[] access_delta;
-	public int[] access_rho;
-	public Bucket[] access_p;
+	// public int[] access_rho;
+	public Tuple[] access_p;
 }