HelloWorld.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package misc;
  2. import java.math.BigInteger;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import crypto.Crypto;
  6. import oram.Forest;
  7. import oram.Metadata;
  8. import util.StopWatch;
  9. import util.Util;
  10. public class HelloWorld {
  11. public static void main(String[] args) {
  12. /*
  13. * System.out.println("HelloWorld!");
  14. *
  15. * byte[] tmp = new byte[3]; BigInteger bi = new BigInteger(1, tmp);
  16. * System.out.println(bi.toByteArray().length);
  17. *
  18. * // System.out.println(tmp[3]);
  19. *
  20. * // System.out.println(Arrays.copyOfRange(tmp, 2, 1).length);
  21. *
  22. * byte[] a = new byte[] { 0 }; byte[] b = a.clone(); a[0] = 1;
  23. * System.out.println(a[0] + " " + b[0]); // throw new
  24. * ArrayIndexOutOfBoundsException("" + 11);
  25. *
  26. * System.out.println((new long[3])[0]);
  27. *
  28. * byte[] negInt = Util.intToBytes(-3); System.out.println(new
  29. * BigInteger(negInt).intValue());
  30. *
  31. * byte aa = 1; aa ^= 1; System.out.println(aa);
  32. */
  33. /*Metadata md = new Metadata();
  34. Forest forest = Forest.readFromFile(md.getDefaultForestFileName());
  35. forest.print();*/
  36. StopWatch sw1 = new StopWatch();
  37. StopWatch sw2 = new StopWatch();
  38. byte[] arr1 = Util.nextBytes((int) Math.pow(2, 20), Crypto.sr);
  39. byte[] arr2 = Util.nextBytes((int) Math.pow(2, 20), Crypto.sr);
  40. sw1.start();
  41. Util.xor(arr1, arr2);
  42. sw1.stop();
  43. sw2.start();
  44. new BigInteger(1, arr1).xor(new BigInteger(1, arr2)).toByteArray();
  45. sw2.stop();
  46. System.out.println(sw1.toMS());
  47. System.out.println(sw2.toMS());
  48. }
  49. }