소스 검색

verified Access timing and test

Boyoung- 8 년 전
부모
커밋
2841af2cd8

+ 0 - 1
ObliVMGC/com/oblivm/backend/lang/inter/MainRunnable.java

@@ -7,7 +7,6 @@ import com.oblivm.backend.flexsc.CompEnv;
 /***
  * Copyright (C) 2015 by Chang Liu <liuchang@cs.umd.edu>
  */
-import com.oblivm.backend.gc.BadLabelException;
 import com.oblivm.backend.lang.inter.input.BitFileInput;
 import com.oblivm.backend.util.EvaRunnable;
 import com.oblivm.backend.util.GenRunnable;

+ 0 - 1
ObliVMGC/com/oblivm/backend/lang/inter/Util.java

@@ -6,7 +6,6 @@ import java.util.Arrays;
 import com.oblivm.backend.circuits.arithmetic.IntegerLib;
 import com.oblivm.backend.flexsc.CompEnv;
 import com.oblivm.backend.oram.SecureArray;
-import com.oblivm.backend.util.Utils;
 
 public class Util {
 	public static <T> T[][] intToArray(T[] intInput, int bitSize, int arraySize) {

+ 0 - 1
ObliVMGC/com/oblivm/backend/oram/CircuitOram.java

@@ -5,7 +5,6 @@ import java.util.Arrays;
 
 import com.oblivm.backend.flexsc.CompEnv;
 import com.oblivm.backend.flexsc.Party;
-import com.oblivm.backend.util.Utils;
 
 public class CircuitOram<T> extends TreeBasedOramParty<T> {
 	public CircuitOramLib<T> lib;

+ 0 - 1
ObliVMGC/com/oblivm/backend/util/EvaRunnable.java

@@ -2,7 +2,6 @@ package com.oblivm.backend.util;
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.util.Arrays;
 import java.util.Scanner;
 
 import org.apache.commons.cli.ParseException;

+ 0 - 1
ObliVMGC/com/oblivm/backend/util/GenRunnable.java

@@ -2,7 +2,6 @@ package com.oblivm.backend.util;
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.util.Arrays;
 import java.util.Scanner;
 
 import org.apache.commons.cli.ParseException;

+ 5 - 0
ObliVMGC/com/oblivm/backend/util/Utils.java

@@ -242,6 +242,7 @@ public class Utils {
 		return ret;
 	}
 
+	@SafeVarargs
 	public static <T> T[] flatten(CompEnv<T> env, T[]... data) {
 		int length = 0;
 		for (int i = 0; i < data.length; i++) {
@@ -256,6 +257,7 @@ public class Utils {
 		return ret;
 	}
 
+	@SafeVarargs
 	public static <T> T[][] flatten(CompEnv<T> env, T[][]... data) {
 		int length = 0;
 		for (int i = 0; i < data.length; i++) {
@@ -272,6 +274,7 @@ public class Utils {
 		return ret;
 	}
 
+	@SafeVarargs
 	public static <T> void unflatten(T[][] flat, T[][]... x) {
 		int pos = 0;
 		for (int i = 0; i < x.length; i++) {
@@ -282,6 +285,7 @@ public class Utils {
 		}
 	}
 
+	@SafeVarargs
 	public static <T> void unflatten(T[] flat, T[]... x) {
 		int pos = 0;
 		for (int i = 0; i < x.length; i++) {
@@ -300,6 +304,7 @@ public class Utils {
 		}
 	}
 
+	@SuppressWarnings("unused")
 	private static double getMega(double bytes) {
 		return bytes / (1024.0 * 1024);
 	}

+ 5 - 16
src/protocols/Access.java

@@ -22,7 +22,6 @@ import protocols.struct.Party;
 import protocols.struct.PreData;
 import util.M;
 import util.P;
-import util.StopWatch;
 import util.Timer;
 import util.Util;
 
@@ -36,14 +35,14 @@ public class Access extends Protocol {
 		timer.start(P.ACC, M.online_comp);
 
 		// step 0: get Li from C
-		timer.start(P.ACC, M.online_read);
 		byte[] Li = new byte[0];
+		timer.start(P.ACC, M.online_read);
 		if (OTi.getTreeIndex() > 0)
 			Li = con2.read();
 		timer.stop(P.ACC, M.online_read);
 
 		// step 1
-		Bucket[] pathBuckets = OTi.getBucketsOnPath(new BigInteger(1, Li).longValue());
+		Bucket[] pathBuckets = OTi.getBucketsOnPath(Li);
 		Tuple[] pathTuples = Bucket.bucketsToTuples(pathBuckets);
 		for (int i = 0; i < pathTuples.length; i++)
 			pathTuples[i].setXor(predata.access_p[i]);
@@ -100,14 +99,14 @@ public class Access extends Protocol {
 		timer.start(P.ACC, M.online_comp);
 
 		// step 0: get Li from C
-		timer.start(P.ACC, M.online_read);
 		byte[] Li = new byte[0];
+		timer.start(P.ACC, M.online_read);
 		if (OTi.getTreeIndex() > 0)
 			Li = con2.read();
 		timer.stop(P.ACC, M.online_read);
 
 		// step 1
-		Bucket[] pathBuckets = OTi.getBucketsOnPath(new BigInteger(1, Li).longValue());
+		Bucket[] pathBuckets = OTi.getBucketsOnPath(Li);
 		Tuple[] pathTuples = Bucket.bucketsToTuples(pathBuckets);
 		for (int i = 0; i < pathTuples.length; i++)
 			pathTuples[i].setXor(predata.access_p[i]);
@@ -218,7 +217,6 @@ public class Access extends Protocol {
 		int addrBits = md.getAddrBits();
 
 		Timer timer = new Timer();
-		StopWatch sw = new StopWatch();
 
 		sanityCheck();
 
@@ -258,9 +256,7 @@ public class Access extends Protocol {
 						byte[] sD_Nip1_pr = Util.xor(Nip1_pr, sE_Nip1_pr);
 						con1.write(sD_Nip1_pr);
 
-						sw.start();
 						runE(predata, OTi, sE_Ni, sE_Nip1_pr, timer);
-						sw.stop();
 
 						if (ti == numTrees - 1)
 							con2.write(N);
@@ -273,18 +269,14 @@ public class Access extends Protocol {
 
 						byte[] sD_Nip1_pr = con1.read();
 
-						sw.start();
 						runD(predata, OTi, sD_Ni, sD_Nip1_pr, timer);
-						sw.stop();
 
 					} else if (party == Party.Charlie) {
 						preaccess.runC(timer);
 
 						System.out.println("L" + ti + "=" + new BigInteger(1, Li).toString(2));
 
-						sw.start();
 						OutAccess outaccess = runC(md, ti, Li, timer);
-						sw.stop();
 
 						Li = outaccess.C_Lip1;
 
@@ -306,9 +298,6 @@ public class Access extends Protocol {
 			}
 		}
 
-		timer.print();
-
-		System.out.println();
-		System.out.println(sw.toMS());
+		//timer.print();
 	}
 }

+ 0 - 78
test/misc/MiscTests.java

@@ -1,78 +0,0 @@
-package misc;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import crypto.Crypto;
-import oram.Forest;
-import oram.Metadata;
-import oram.Tuple;
-import util.StopWatch;
-import util.Util;
-
-public class MiscTests {
-
-	public static void main(String[] args) {
-		/*
-		 * System.out.println("HelloWorld!");
-		 * 
-		 * byte[] tmp = new byte[3]; BigInteger bi = new BigInteger(1, tmp);
-		 * System.out.println(bi.toByteArray().length);
-		 * 
-		 * // System.out.println(tmp[3]);
-		 * 
-		 * // System.out.println(Arrays.copyOfRange(tmp, 2, 1).length);
-		 * 
-		 * byte[] a = new byte[] { 0 }; byte[] b = a.clone(); a[0] = 1;
-		 * System.out.println(a[0] + " " + b[0]); // throw new
-		 * ArrayIndexOutOfBoundsException("" + 11);
-		 * 
-		 * System.out.println((new long[3])[0]);
-		 * 
-		 * byte[] negInt = Util.intToBytes(-3); System.out.println(new
-		 * BigInteger(negInt).intValue());
-		 * 
-		 * byte aa = 1; aa ^= 1; System.out.println(aa);
-		 */
-
-		/*
-		 * Metadata md = new Metadata(); Forest forest =
-		 * Forest.readFromFile(md.getDefaultForestFileName()); forest.print();
-		 */
-
-		/*
-		 * StopWatch sw1 = new StopWatch(); StopWatch sw2 = new StopWatch();
-		 * byte[] arr1 = Util.nextBytes((int) Math.pow(2, 20), Crypto.sr);
-		 * byte[] arr2 = Util.nextBytes((int) Math.pow(2, 20), Crypto.sr);
-		 * 
-		 * sw1.start(); Util.xor(arr1, arr2); sw1.stop();
-		 * 
-		 * sw2.start(); new BigInteger(1, arr1).xor(new BigInteger(1,
-		 * arr2)).toByteArray(); sw2.stop();
-		 * 
-		 * System.out.println(sw1.toMS()); System.out.println(sw2.toMS());
-		 */
-
-		int n = 20;
-		Integer[] oldArr = new Integer[n];
-		for (int i = 0; i < n; i++)
-			oldArr[i] = Crypto.sr.nextInt(50);
-		int[] pi = Util.randomPermutation(n, Crypto.sr);
-		int[] pi_ivs = Util.inversePermutation(pi);
-		Integer[] newArr = Util.permute(oldArr, pi);
-		newArr = Util.permute(newArr, pi_ivs);
-
-		for (int i = 0; i < n; i++) {
-			System.out.println(oldArr[i] + " " + newArr[i]);
-		}
-
-		BigInteger b = new BigInteger("101", 2);
-		int[] p = Util.getXorPermutation(b, 3);
-		for (int i = 0; i < p.length; i++)
-			System.out.print(p[i] + " ");
-		System.out.println();
-	}
-
-}