PreRetrieve.java 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package protocols.precomputation;
  2. import communication.Communication;
  3. import oram.Forest;
  4. import oram.Metadata;
  5. import protocols.Protocol;
  6. import protocols.struct.Party;
  7. import protocols.struct.PreData;
  8. import util.Timer;
  9. public class PreRetrieve extends Protocol {
  10. public PreRetrieve(Communication con1, Communication con2) {
  11. super(con1, con2);
  12. }
  13. // TODO: not all protocols run on all trees (remove unnecessary precomp)
  14. public void runE(PreData[] predata, Metadata md, int ti, Timer timer) {
  15. // 1st eviction
  16. PreAccess preaccess = new PreAccess(con1, con2);
  17. PreReshuffle prereshuffle = new PreReshuffle(con1, con2);
  18. PrePostProcessT prepostprocesst = new PrePostProcessT(con1, con2);
  19. PreUpdateRoot preupdateroot = new PreUpdateRoot(con1, con2);
  20. PreEviction preeviction = new PreEviction(con1, con2);
  21. int numTuples = md.getStashSizeOfTree(ti) + md.getLBitsOfTree(ti) * md.getW();
  22. int[] tupleParam = new int[] { ti == 0 ? 0 : 1, md.getNBytesOfTree(ti), md.getLBytesOfTree(ti),
  23. md.getABytesOfTree(ti) };
  24. preaccess.runE(predata[0], md.getTwoTauPow(), numTuples, tupleParam, timer);
  25. prereshuffle.runE(predata[0], timer);
  26. prepostprocesst.runE(predata[0], timer);
  27. preupdateroot.runE(predata[0], ti == 0, md.getStashSizeOfTree(ti), md.getLBitsOfTree(ti), timer);
  28. preeviction.runE(predata[0], ti == 0, md.getLBitsOfTree(ti) + 1, md.getW(), timer);
  29. // 2nd eviction
  30. preupdateroot.runE(predata[1], ti == 0, md.getStashSizeOfTree(ti), md.getLBitsOfTree(ti), timer);
  31. preeviction.runE(predata[1], ti == 0, md.getLBitsOfTree(ti) + 1, md.getW(), timer);
  32. }
  33. public void runD(PreData[] predata, Metadata md, int ti, PreData prev, Timer timer) {
  34. // 1st eviction
  35. PreAccess preaccess = new PreAccess(con1, con2);
  36. PreReshuffle prereshuffle = new PreReshuffle(con1, con2);
  37. PrePostProcessT prepostprocesst = new PrePostProcessT(con1, con2);
  38. PreUpdateRoot preupdateroot = new PreUpdateRoot(con1, con2);
  39. PreEviction preeviction = new PreEviction(con1, con2);
  40. int[] tupleParam = new int[] { ti == 0 ? 0 : 1, md.getNBytesOfTree(ti), md.getLBytesOfTree(ti),
  41. md.getABytesOfTree(ti) };
  42. preaccess.runD(predata[0], timer);
  43. prereshuffle.runD(predata[0], tupleParam, timer);
  44. prepostprocesst.runD(predata[0], prev, md.getLBytesOfTree(ti), md.getAlBytesOfTree(ti), md.getTau(), timer);
  45. preupdateroot.runD(predata[0], ti == 0, md.getStashSizeOfTree(ti), md.getLBitsOfTree(ti), tupleParam, timer);
  46. preeviction.runD(predata[0], ti == 0, md.getLBitsOfTree(ti) + 1, md.getW(), tupleParam, timer);
  47. // 2nd eviction
  48. preupdateroot.runD(predata[1], ti == 0, md.getStashSizeOfTree(ti), md.getLBitsOfTree(ti), tupleParam, timer);
  49. preeviction.runD(predata[1], ti == 0, md.getLBitsOfTree(ti) + 1, md.getW(), tupleParam, timer);
  50. }
  51. public void runC(PreData[] predata, Metadata md, int ti, PreData prev, Timer timer) {
  52. // 1st eviction
  53. PreAccess preaccess = new PreAccess(con1, con2);
  54. PreReshuffle prereshuffle = new PreReshuffle(con1, con2);
  55. PrePostProcessT prepostprocesst = new PrePostProcessT(con1, con2);
  56. PreUpdateRoot preupdateroot = new PreUpdateRoot(con1, con2);
  57. PreEviction preeviction = new PreEviction(con1, con2);
  58. preaccess.runC(timer);
  59. prereshuffle.runC(predata[0], timer);
  60. prepostprocesst.runC(predata[0], prev, md.getLBytesOfTree(ti), md.getAlBytesOfTree(ti), timer);
  61. preupdateroot.runC(predata[0], ti == 0, timer);
  62. preeviction.runC(predata[0], ti == 0, timer);
  63. // 2nd eviction
  64. preupdateroot.runC(predata[1], ti == 0, timer);
  65. preeviction.runC(predata[1], ti == 0, timer);
  66. }
  67. @Override
  68. public void run(Party party, Metadata md, Forest forest) {
  69. }
  70. }