HelloWorld.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. /*
  34. * Metadata md = new Metadata(); Forest forest =
  35. * Forest.readFromFile(md.getDefaultForestFileName()); forest.print();
  36. */
  37. StopWatch sw1 = new StopWatch();
  38. StopWatch sw2 = new StopWatch();
  39. byte[] arr1 = Util.nextBytes((int) Math.pow(2, 20), Crypto.sr);
  40. byte[] arr2 = Util.nextBytes((int) Math.pow(2, 20), Crypto.sr);
  41. sw1.start();
  42. Util.xor(arr1, arr2);
  43. sw1.stop();
  44. sw2.start();
  45. new BigInteger(1, arr1).xor(new BigInteger(1, arr2)).toByteArray();
  46. sw2.stop();
  47. System.out.println(sw1.toMS());
  48. System.out.println(sw2.toMS());
  49. }
  50. }