Pipeline.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package protocols;
  2. import java.util.Arrays;
  3. import communication.Communication;
  4. import crypto.Crypto;
  5. import exceptions.NoSuchPartyException;
  6. import oram.Metadata;
  7. import oram.Tree;
  8. import oram.Tuple;
  9. import struct.Party;
  10. import util.Timer;
  11. import util.Util;
  12. public class Pipeline extends Thread {
  13. // private Communication con1;
  14. // private Communication con2;
  15. // private Party party;
  16. // private PreData[] predata;
  17. // private Tree OTi;
  18. // private int h;
  19. // private Timer timer;
  20. // private Metadata md;
  21. // private int treeIndex;
  22. // private byte[] Li;
  23. // private OutAccess outaccess;
  24. //
  25. // public Pipeline(Communication con1, Communication con2, Party party,
  26. // PreData[] predata, Tree OTi, int h,
  27. // Timer timer, Metadata md, int treeIndex, byte[] Li, OutAccess outaccess) {
  28. // this.con1 = con1;
  29. // this.con2 = con2;
  30. // this.party = party;
  31. // this.predata = predata;
  32. // this.OTi = OTi;
  33. // this.h = h;
  34. // this.timer = timer;
  35. // this.md = md;
  36. // this.treeIndex = treeIndex;
  37. // this.Li = Li;
  38. // this.outaccess = outaccess;
  39. // }
  40. //
  41. // public void runE(PreData[] predata, Tree OTi, int h, Timer timer) {
  42. // // 1st eviction
  43. // Access access = new Access(con1, con2);
  44. // Reshuffle reshuffle = new Reshuffle(con1, con2);
  45. // PostProcessT postprocesst = new PostProcessT(con1, con2);
  46. // UpdateRoot updateroot = new UpdateRoot(con1, con2);
  47. // Eviction eviction = new Eviction(con1, con2);
  48. //
  49. // Tuple[] path = reshuffle.runE(predata[0], outaccess.E_P, OTi.getTreeIndex()
  50. // == 0, timer);
  51. // Tuple Ti = postprocesst.runE(predata[0], outaccess.E_Ti, OTi.getTreeIndex()
  52. // == h - 1, timer);
  53. // Tuple[] root = Arrays.copyOfRange(path, 0, OTi.getStashSize());
  54. // root = updateroot.runE(predata[0], OTi.getTreeIndex() == 0, outaccess.Li,
  55. // root, Ti, timer);
  56. // System.arraycopy(root, 0, path, 0, root.length);
  57. // eviction.runE(predata[0], OTi.getTreeIndex() == 0, outaccess.Li,
  58. // OTi.getTreeIndex() == 0 ? new Tuple[] { Ti } : path, OTi, timer);
  59. //
  60. // // 2nd eviction
  61. // OutAccess outaccess2 = access.runE2(OTi, timer);
  62. // Tuple[] path2 = outaccess2.E_P;
  63. // Tuple Ti2 = outaccess2.E_Ti;
  64. // Tuple[] root2 = Arrays.copyOfRange(path2, 0, OTi.getStashSize());
  65. // root2 = updateroot.runE(predata[1], OTi.getTreeIndex() == 0, outaccess2.Li,
  66. // root2, Ti2, timer);
  67. // System.arraycopy(root2, 0, path2, 0, root2.length);
  68. // eviction.runE(predata[1], OTi.getTreeIndex() == 0, outaccess2.Li,
  69. // OTi.getTreeIndex() == 0 ? new Tuple[] { Ti2 } : path2, OTi, timer);
  70. // }
  71. //
  72. // public void runD(PreData predata[], Tree OTi, Timer timer) {
  73. // // 1st eviction
  74. // Access access = new Access(con1, con2);
  75. // Reshuffle reshuffle = new Reshuffle(con1, con2);
  76. // PostProcessT postprocesst = new PostProcessT(con1, con2);
  77. // UpdateRoot updateroot = new UpdateRoot(con1, con2);
  78. // Eviction eviction = new Eviction(con1, con2);
  79. //
  80. // reshuffle.runD();
  81. // postprocesst.runD();
  82. // updateroot.runD(predata[0], OTi.getTreeIndex() == 0, Li, OTi.getW(), timer);
  83. // eviction.runD(predata[0], OTi.getTreeIndex() == 0, Li, OTi, timer);
  84. //
  85. // // 2nd eviction
  86. // byte[] Li2 = access.runD2(OTi, timer);
  87. // updateroot.runD(predata[1], OTi.getTreeIndex() == 0, Li2, OTi.getW(), timer);
  88. // eviction.runD(predata[1], OTi.getTreeIndex() == 0, Li2, OTi, timer);
  89. // }
  90. //
  91. // public OutAccess runC(PreData[] predata, Metadata md, int ti, byte[] Li,
  92. // Timer timer) {
  93. // // 1st eviction
  94. // Access access = new Access(con1, con2);
  95. // Reshuffle reshuffle = new Reshuffle(con1, con2);
  96. // PostProcessT postprocesst = new PostProcessT(con1, con2);
  97. // UpdateRoot updateroot = new UpdateRoot(con1, con2);
  98. // Eviction eviction = new Eviction(con1, con2);
  99. //
  100. // Tuple[] path = reshuffle.runC(predata[0], outaccess.C_P, ti == 0, timer);
  101. // Tuple Ti = postprocesst.runC(predata[0], outaccess.C_Ti, Li,
  102. // outaccess.C_Lip1, outaccess.C_j2,
  103. // ti == md.getNumTrees() - 1, timer);
  104. // Tuple[] root = Arrays.copyOfRange(path, 0, md.getStashSizeOfTree(ti));
  105. // root = updateroot.runC(predata[0], ti == 0, root, Ti, timer);
  106. // System.arraycopy(root, 0, path, 0, root.length);
  107. // eviction.runC(predata[0], ti == 0, ti == 0 ? new Tuple[] { Ti } : path,
  108. // md.getLBitsOfTree(ti) + 1,
  109. // md.getStashSizeOfTree(ti), md.getW(), timer);
  110. //
  111. // // 2nd eviction
  112. // byte[] Li2 = Util.nextBytes(md.getLBytesOfTree(ti), Crypto.sr);
  113. // OutAccess outaccess2 = access.runC2(md, ti, Li2, timer);
  114. // Tuple[] path2 = outaccess2.C_P;
  115. // Tuple Ti2 = outaccess2.C_Ti;
  116. // Tuple[] root2 = Arrays.copyOfRange(path2, 0, md.getStashSizeOfTree(ti));
  117. // root2 = updateroot.runC(predata[1], ti == 0, root2, Ti2, timer);
  118. // System.arraycopy(root2, 0, path2, 0, root2.length);
  119. // eviction.runC(predata[1], ti == 0, ti == 0 ? new Tuple[] { Ti2 } : path2,
  120. // md.getLBitsOfTree(ti) + 1,
  121. // md.getStashSizeOfTree(ti), md.getW(), timer);
  122. //
  123. // return outaccess;
  124. // }
  125. //
  126. // public void run() {
  127. // if (party == Party.Eddie) {
  128. // runE(predata, OTi, h, timer);
  129. //
  130. // } else if (party == Party.Debbie) {
  131. // runD(predata, OTi, timer);
  132. //
  133. // } else if (party == Party.Charlie) {
  134. // runC(predata, md, treeIndex, Li, timer);
  135. //
  136. // } else {
  137. // throw new NoSuchPartyException(party + "");
  138. // }
  139. // }
  140. }